]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/arm/mach-pxa/em-x270.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / arch / arm / mach-pxa / em-x270.c
CommitLineData
3d50527b 1/*
3c85bce6 2 * Support for CompuLab EM-X270 platform
3d50527b 3 *
3c85bce6 4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
3d50527b
MR
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/irq.h>
13#include <linux/platform_device.h>
7f14a787 14#include <linux/delay.h>
3d50527b
MR
15
16#include <linux/dm9000.h>
cd9b518b 17#include <linux/platform_data/rtc-v3020.h>
d4092d76 18#include <linux/mtd/rawnand.h>
3d50527b 19#include <linux/mtd/partitions.h>
28c88046 20#include <linux/mtd/physmap.h>
3c85bce6
MR
21#include <linux/input.h>
22#include <linux/gpio_keys.h>
23#include <linux/gpio.h>
28c88046
MR
24#include <linux/mfd/da903x.h>
25#include <linux/regulator/machine.h>
d9fa0472 26#include <linux/regulator/fixed.h>
28c88046
MR
27#include <linux/spi/spi.h>
28#include <linux/spi/tdo24m.h>
c9be0e39 29#include <linux/spi/libertas_spi.h>
8348c259 30#include <linux/spi/pxa2xx_spi.h>
9f055c49
MR
31#include <linux/power_supply.h>
32#include <linux/apm-emulation.h>
76e3fc36 33#include <linux/i2c.h>
5877457a 34#include <linux/platform_data/pca953x.h>
b459396e 35#include <linux/i2c/pxa-i2c.h>
a37ed431 36#include <linux/regulator/userspace-consumer.h>
28c88046 37
3d50527b 38#include <asm/mach-types.h>
3d50527b
MR
39#include <asm/mach/arch.h>
40
4c25c5d2
AB
41#include "pxa27x.h"
42#include "pxa27x-udc.h"
a09e64fb 43#include <mach/audio.h>
293b2da1
AB
44#include <linux/platform_data/video-pxafb.h>
45#include <linux/platform_data/usb-ohci-pxa27x.h>
46#include <linux/platform_data/mmc-pxamci.h>
47#include <linux/platform_data/keypad-pxa27x.h>
a71daaa1 48#include <linux/platform_data/media/camera-pxa.h>
3d50527b
MR
49
50#include "generic.h"
6432f46c 51#include "devices.h"
3d50527b 52
7f14a787 53/* EM-X270 specific GPIOs */
3c85bce6 54#define GPIO13_MMC_CD (13)
7f14a787
MR
55#define GPIO95_MMC_WP (95)
56#define GPIO56_NAND_RB (56)
76e3fc36 57#define GPIO93_CAM_RESET (93)
128d88b8 58#define GPIO16_USB_HUB_RESET (16)
3c85bce6 59
7f14a787
MR
60/* eXeda specific GPIOs */
61#define GPIO114_MMC_CD (114)
62#define GPIO20_NAND_RB (20)
63#define GPIO38_SD_PWEN (38)
76e3fc36
MR
64#define GPIO37_WLAN_RST (37)
65#define GPIO95_TOUCHPAD_INT (95)
66#define GPIO130_CAM_RESET (130)
128d88b8 67#define GPIO10_USB_HUB_RESET (10)
3c85bce6 68
7f14a787
MR
69/* common GPIOs */
70#define GPIO11_NAND_CS (11)
7f14a787 71#define GPIO41_ETHIRQ (41)
6384fdad 72#define EM_X270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO41_ETHIRQ)
c9be0e39
MR
73#define GPIO115_WLAN_PWEN (115)
74#define GPIO19_WLAN_STRAP (19)
128d88b8 75#define GPIO9_USB_VBUS_EN (9)
28c88046 76
4a697e83
MR
77static int mmc_cd;
78static int nand_rb;
79static int dm9000_flags;
76e3fc36 80static int cam_reset;
128d88b8 81static int usb_hub_reset;
4a697e83
MR
82
83static unsigned long common_pin_config[] = {
3c85bce6
MR
84 /* AC'97 */
85 GPIO28_AC97_BITCLK,
86 GPIO29_AC97_SDATA_IN_0,
87 GPIO30_AC97_SDATA_OUT,
88 GPIO31_AC97_SYNC,
89 GPIO98_AC97_SYSCLK,
90 GPIO113_AC97_nRESET,
91
92 /* BTUART */
93 GPIO42_BTUART_RXD,
94 GPIO43_BTUART_TXD,
95 GPIO44_BTUART_CTS,
96 GPIO45_BTUART_RTS,
97
98 /* STUART */
99 GPIO46_STUART_RXD,
100 GPIO47_STUART_TXD,
101
102 /* MCI controller */
103 GPIO32_MMC_CLK,
104 GPIO112_MMC_CMD,
105 GPIO92_MMC_DAT_0,
106 GPIO109_MMC_DAT_1,
107 GPIO110_MMC_DAT_2,
108 GPIO111_MMC_DAT_3,
109
110 /* LCD */
bedbda97 111 GPIOxx_LCD_TFT_16BPP,
3c85bce6
MR
112
113 /* QCI */
114 GPIO84_CIF_FV,
115 GPIO25_CIF_LV,
116 GPIO53_CIF_MCLK,
117 GPIO54_CIF_PCLK,
118 GPIO81_CIF_DD_0,
119 GPIO55_CIF_DD_1,
120 GPIO51_CIF_DD_2,
121 GPIO50_CIF_DD_3,
122 GPIO52_CIF_DD_4,
123 GPIO48_CIF_DD_5,
124 GPIO17_CIF_DD_6,
125 GPIO12_CIF_DD_7,
126
127 /* I2C */
128 GPIO117_I2C_SCL,
129 GPIO118_I2C_SDA,
130
131 /* Keypad */
132 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
133 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
134 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
136 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
137 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
138 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
139 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
140 GPIO103_KP_MKOUT_0,
141 GPIO104_KP_MKOUT_1,
142 GPIO105_KP_MKOUT_2,
143 GPIO106_KP_MKOUT_3,
144 GPIO107_KP_MKOUT_4,
145 GPIO108_KP_MKOUT_5,
146 GPIO96_KP_MKOUT_6,
147 GPIO22_KP_MKOUT_7,
148
149 /* SSP1 */
150 GPIO26_SSP1_RXD,
151 GPIO23_SSP1_SCLK,
152 GPIO24_SSP1_SFRM,
153 GPIO57_SSP1_TXD,
154
155 /* SSP2 */
c9be0e39
MR
156 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
157 GPIO14_GPIO,
3c85bce6
MR
158 GPIO89_SSP2_TXD,
159 GPIO88_SSP2_RXD,
160
161 /* SDRAM and local bus */
162 GPIO15_nCS_1,
163 GPIO78_nCS_2,
164 GPIO79_nCS_3,
165 GPIO80_nCS_4,
166 GPIO49_nPWE,
167 GPIO18_RDY,
168
169 /* GPIO */
6432f46c 170 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
3c85bce6
MR
171
172 /* power controls */
173 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
174 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
175
176 /* NAND controls */
177 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
3c85bce6
MR
178
179 /* interrupts */
3c85bce6
MR
180 GPIO41_GPIO, /* DM9000 interrupt */
181};
3d50527b 182
4a697e83 183static unsigned long em_x270_pin_config[] = {
76e3fc36 184 GPIO13_GPIO, /* MMC card detect */
128d88b8 185 GPIO16_GPIO, /* USB hub reset */
76e3fc36
MR
186 GPIO56_GPIO, /* NAND Ready/Busy */
187 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
188 GPIO95_GPIO, /* MMC Write protect */
4a697e83
MR
189};
190
7f14a787 191static unsigned long exeda_pin_config[] = {
128d88b8 192 GPIO10_GPIO, /* USB hub reset */
7f14a787
MR
193 GPIO20_GPIO, /* NAND Ready/Busy */
194 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
76e3fc36 195 GPIO95_GPIO, /* touchpad IRQ */
7f14a787
MR
196 GPIO114_GPIO, /* MMC card detect */
197};
198
3c85bce6
MR
199#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
200static struct resource em_x270_dm9000_resource[] = {
3d50527b
MR
201 [0] = {
202 .start = PXA_CS2_PHYS,
203 .end = PXA_CS2_PHYS + 3,
204 .flags = IORESOURCE_MEM,
205 },
206 [1] = {
207 .start = PXA_CS2_PHYS + 8,
208 .end = PXA_CS2_PHYS + 8 + 0x3f,
209 .flags = IORESOURCE_MEM,
210 },
211 [2] = {
212 .start = EM_X270_ETHIRQ,
213 .end = EM_X270_ETHIRQ,
3c85bce6 214 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
3d50527b
MR
215 }
216};
217
3c85bce6 218static struct dm9000_plat_data em_x270_dm9000_platdata = {
4a697e83 219 .flags = DM9000_PLATF_NO_EEPROM,
3d50527b
MR
220};
221
3c85bce6 222static struct platform_device em_x270_dm9000 = {
3d50527b
MR
223 .name = "dm9000",
224 .id = 0,
3c85bce6
MR
225 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
226 .resource = em_x270_dm9000_resource,
3d50527b 227 .dev = {
3c85bce6 228 .platform_data = &em_x270_dm9000_platdata,
3d50527b
MR
229 }
230};
231
3c85bce6
MR
232static void __init em_x270_init_dm9000(void)
233{
4a697e83 234 em_x270_dm9000_platdata.flags |= dm9000_flags;
3c85bce6
MR
235 platform_device_register(&em_x270_dm9000);
236}
237#else
238static inline void em_x270_init_dm9000(void) {}
239#endif
3d50527b 240
3c85bce6
MR
241/* V3020 RTC */
242#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
3d50527b
MR
243static struct resource em_x270_v3020_resource[] = {
244 [0] = {
245 .start = PXA_CS4_PHYS,
246 .end = PXA_CS4_PHYS + 3,
247 .flags = IORESOURCE_MEM,
248 },
249};
250
251static struct v3020_platform_data em_x270_v3020_platdata = {
252 .leftshift = 0,
253};
254
255static struct platform_device em_x270_rtc = {
256 .name = "v3020",
257 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
258 .resource = em_x270_v3020_resource,
259 .id = -1,
260 .dev = {
261 .platform_data = &em_x270_v3020_platdata,
262 }
263};
264
3c85bce6
MR
265static void __init em_x270_init_rtc(void)
266{
267 platform_device_register(&em_x270_rtc);
268}
269#else
270static inline void em_x270_init_rtc(void) {}
271#endif
3d50527b 272
3c85bce6
MR
273/* NAND flash */
274#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
3d50527b
MR
275static inline void nand_cs_on(void)
276{
3c85bce6 277 gpio_set_value(GPIO11_NAND_CS, 0);
3d50527b
MR
278}
279
280static void nand_cs_off(void)
281{
282 dsb();
283
3c85bce6 284 gpio_set_value(GPIO11_NAND_CS, 1);
3d50527b
MR
285}
286
287/* hardware specific access to control-lines */
288static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
289 unsigned int ctrl)
290{
c993e095 291 struct nand_chip *this = mtd_to_nand(mtd);
3d50527b
MR
292 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
293
294 dsb();
295
296 if (ctrl & NAND_CTRL_CHANGE) {
297 if (ctrl & NAND_ALE)
298 nandaddr |= (1 << 3);
299 else
300 nandaddr &= ~(1 << 3);
301 if (ctrl & NAND_CLE)
302 nandaddr |= (1 << 2);
303 else
304 nandaddr &= ~(1 << 2);
305 if (ctrl & NAND_NCE)
306 nand_cs_on();
307 else
308 nand_cs_off();
309 }
310
311 dsb();
312 this->IO_ADDR_W = (void __iomem *)nandaddr;
313 if (dat != NAND_CMD_NONE)
314 writel(dat, this->IO_ADDR_W);
315
316 dsb();
317}
318
319/* read device ready pin */
320static int em_x270_nand_device_ready(struct mtd_info *mtd)
321{
322 dsb();
323
4a697e83 324 return gpio_get_value(nand_rb);
3d50527b
MR
325}
326
327static struct mtd_partition em_x270_partition_info[] = {
328 [0] = {
329 .name = "em_x270-0",
330 .offset = 0,
331 .size = SZ_4M,
332 },
333 [1] = {
334 .name = "em_x270-1",
335 .offset = MTDPART_OFS_APPEND,
336 .size = MTDPART_SIZ_FULL
337 },
338};
339
3d50527b
MR
340struct platform_nand_data em_x270_nand_platdata = {
341 .chip = {
342 .nr_chips = 1,
343 .chip_offset = 0,
344 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
345 .partitions = em_x270_partition_info,
346 .chip_delay = 20,
3d50527b
MR
347 },
348 .ctrl = {
349 .hwcontrol = 0,
350 .dev_ready = em_x270_nand_device_ready,
351 .select_chip = 0,
352 .cmd_ctrl = em_x270_nand_cmd_ctl,
353 },
354};
355
356static struct resource em_x270_nand_resource[] = {
357 [0] = {
358 .start = PXA_CS1_PHYS,
359 .end = PXA_CS1_PHYS + 12,
360 .flags = IORESOURCE_MEM,
361 },
362};
363
364static struct platform_device em_x270_nand = {
365 .name = "gen_nand",
366 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
367 .resource = em_x270_nand_resource,
368 .id = -1,
369 .dev = {
370 .platform_data = &em_x270_nand_platdata,
371 }
372};
373
3c85bce6
MR
374static void __init em_x270_init_nand(void)
375{
376 int err;
3d50527b 377
3c85bce6
MR
378 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
379 if (err) {
7b472ac7 380 pr_warn("EM-X270: failed to request NAND CS gpio\n");
3c85bce6
MR
381 return;
382 }
383
384 gpio_direction_output(GPIO11_NAND_CS, 1);
385
4a697e83 386 err = gpio_request(nand_rb, "NAND R/B");
3c85bce6 387 if (err) {
7b472ac7 388 pr_warn("EM-X270: failed to request NAND R/B gpio\n");
3c85bce6
MR
389 gpio_free(GPIO11_NAND_CS);
390 return;
391 }
392
4a697e83 393 gpio_direction_input(nand_rb);
3c85bce6
MR
394
395 platform_device_register(&em_x270_nand);
396}
397#else
398static inline void em_x270_init_nand(void) {}
399#endif
3d50527b 400
28c88046
MR
401#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
402static struct mtd_partition em_x270_nor_parts[] = {
403 {
404 .name = "Bootloader",
405 .offset = 0x00000000,
406 .size = 0x00050000,
407 .mask_flags = MTD_WRITEABLE /* force read-only */
408 }, {
409 .name = "Environment",
410 .offset = 0x00050000,
411 .size = 0x00010000,
412 }, {
413 .name = "Reserved",
414 .offset = 0x00060000,
415 .size = 0x00050000,
416 .mask_flags = MTD_WRITEABLE /* force read-only */
417 }, {
418 .name = "Splashscreen",
419 .offset = 0x000b0000,
420 .size = 0x00050000,
421 }
422};
423
424static struct physmap_flash_data em_x270_nor_data[] = {
425 [0] = {
426 .width = 2,
427 .parts = em_x270_nor_parts,
428 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
429 },
430};
431
432static struct resource em_x270_nor_flash_resource = {
433 .start = PXA_CS0_PHYS,
434 .end = PXA_CS0_PHYS + SZ_1M - 1,
435 .flags = IORESOURCE_MEM,
436};
437
438static struct platform_device em_x270_physmap_flash = {
439 .name = "physmap-flash",
440 .id = 0,
441 .num_resources = 1,
442 .resource = &em_x270_nor_flash_resource,
443 .dev = {
444 .platform_data = &em_x270_nor_data,
445 },
446};
447
448static void __init em_x270_init_nor(void)
449{
450 platform_device_register(&em_x270_physmap_flash);
451}
452#else
453static inline void em_x270_init_nor(void) {}
454#endif
455
3d50527b 456/* PXA27x OHCI controller setup */
3c85bce6 457#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
128d88b8
MR
458static struct regulator *em_x270_usb_ldo;
459
460static int em_x270_usb_hub_init(void)
461{
462 int err;
463
464 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
465 if (IS_ERR(em_x270_usb_ldo))
466 return PTR_ERR(em_x270_usb_ldo);
467
468 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
469 if (err)
470 goto err_free_usb_ldo;
471
472 err = gpio_request(usb_hub_reset, "hub rst");
473 if (err)
474 goto err_free_vbus_gpio;
475
476 /* USB Hub power-on and reset */
1b82e4c3
IG
477 gpio_direction_output(usb_hub_reset, 1);
478 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
a829abf8
AB
479 err = regulator_enable(em_x270_usb_ldo);
480 if (err)
481 goto err_free_rst_gpio;
482
128d88b8 483 gpio_set_value(usb_hub_reset, 0);
1b82e4c3 484 gpio_set_value(usb_hub_reset, 1);
128d88b8 485 regulator_disable(em_x270_usb_ldo);
a829abf8
AB
486 err = regulator_enable(em_x270_usb_ldo);
487 if (err)
488 goto err_free_rst_gpio;
489
1b82e4c3
IG
490 gpio_set_value(usb_hub_reset, 0);
491 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
128d88b8
MR
492
493 return 0;
494
a829abf8
AB
495err_free_rst_gpio:
496 gpio_free(usb_hub_reset);
128d88b8
MR
497err_free_vbus_gpio:
498 gpio_free(GPIO9_USB_VBUS_EN);
499err_free_usb_ldo:
500 regulator_put(em_x270_usb_ldo);
501
502 return err;
503}
504
3d50527b
MR
505static int em_x270_ohci_init(struct device *dev)
506{
128d88b8
MR
507 int err;
508
509 /* we don't want to entirely disable USB if the HUB init failed */
510 err = em_x270_usb_hub_init();
511 if (err)
512 pr_err("USB Hub initialization failed: %d\n", err);
513
3d50527b
MR
514 /* enable port 2 transiever */
515 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
516
517 return 0;
518}
519
128d88b8
MR
520static void em_x270_ohci_exit(struct device *dev)
521{
522 gpio_free(usb_hub_reset);
523 gpio_free(GPIO9_USB_VBUS_EN);
524
525 if (!IS_ERR(em_x270_usb_ldo)) {
526 if (regulator_is_enabled(em_x270_usb_ldo))
527 regulator_disable(em_x270_usb_ldo);
528
529 regulator_put(em_x270_usb_ldo);
530 }
531}
532
3d50527b
MR
533static struct pxaohci_platform_data em_x270_ohci_platform_data = {
534 .port_mode = PMM_PERPORT_MODE,
097b5334 535 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
3d50527b 536 .init = em_x270_ohci_init,
128d88b8 537 .exit = em_x270_ohci_exit,
3d50527b
MR
538};
539
3c85bce6
MR
540static void __init em_x270_init_ohci(void)
541{
542 pxa_set_ohci_info(&em_x270_ohci_platform_data);
543}
544#else
545static inline void em_x270_init_ohci(void) {}
546#endif
3d50527b 547
3c85bce6
MR
548/* MCI controller setup */
549#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
6432f46c
MR
550static struct regulator *em_x270_sdio_ldo;
551
3d50527b
MR
552static int em_x270_mci_init(struct device *dev,
553 irq_handler_t em_x270_detect_int,
554 void *data)
555{
6432f46c
MR
556 int err;
557
558 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
559 if (IS_ERR(em_x270_sdio_ldo)) {
560 dev_err(dev, "can't request SDIO power supply: %ld\n",
561 PTR_ERR(em_x270_sdio_ldo));
562 return PTR_ERR(em_x270_sdio_ldo);
563 }
564
4a697e83 565 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
ed7936f9 566 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
3c85bce6 567 "MMC card detect", data);
3d50527b 568 if (err) {
6432f46c
MR
569 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
570 goto err_irq;
571 }
572
7f14a787
MR
573 if (machine_is_em_x270()) {
574 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
575 if (err) {
576 dev_err(dev, "can't request MMC write protect: %d\n",
577 err);
578 goto err_gpio_wp;
579 }
580 gpio_direction_input(GPIO95_MMC_WP);
581 } else {
582 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
583 if (err) {
584 dev_err(dev, "can't request MMC power control : %d\n",
585 err);
586 goto err_gpio_wp;
587 }
588 gpio_direction_output(GPIO38_SD_PWEN, 1);
3d50527b
MR
589 }
590
591 return 0;
6432f46c
MR
592
593err_gpio_wp:
4a697e83 594 free_irq(gpio_to_irq(mmc_cd), data);
6432f46c
MR
595err_irq:
596 regulator_put(em_x270_sdio_ldo);
597
598 return err;
3d50527b
MR
599}
600
a829abf8 601static int em_x270_mci_setpower(struct device *dev, unsigned int vdd)
3d50527b 602{
6432f46c
MR
603 struct pxamci_platform_data* p_d = dev->platform_data;
604
605 if ((1 << vdd) & p_d->ocr_mask) {
606 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
607
608 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
a829abf8 609 return regulator_enable(em_x270_sdio_ldo);
6432f46c
MR
610 } else {
611 regulator_disable(em_x270_sdio_ldo);
612 }
a829abf8 613 return 0;
3d50527b
MR
614}
615
616static void em_x270_mci_exit(struct device *dev, void *data)
617{
4a697e83 618 free_irq(gpio_to_irq(mmc_cd), data);
7f14a787
MR
619 regulator_put(em_x270_sdio_ldo);
620
621 if (machine_is_em_x270())
622 gpio_free(GPIO95_MMC_WP);
623 else
624 gpio_free(GPIO38_SD_PWEN);
6432f46c
MR
625}
626
627static int em_x270_mci_get_ro(struct device *dev)
628{
629 return gpio_get_value(GPIO95_MMC_WP);
3d50527b
MR
630}
631
632static struct pxamci_platform_data em_x270_mci_platform_data = {
f97cab28 633 .detect_delay_ms = 250,
7a648256
RJ
634 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
635 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
636 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
637 MMC_VDD_30_31|MMC_VDD_31_32,
638 .init = em_x270_mci_init,
639 .setpower = em_x270_mci_setpower,
640 .exit = em_x270_mci_exit,
641 .gpio_card_detect = -1,
642 .gpio_card_ro = -1,
643 .gpio_power = -1,
3d50527b
MR
644};
645
3c85bce6
MR
646static void __init em_x270_init_mmc(void)
647{
7f14a787
MR
648 if (machine_is_em_x270())
649 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
650
3c85bce6
MR
651 pxa_set_mci_info(&em_x270_mci_platform_data);
652}
653#else
654static inline void em_x270_init_mmc(void) {}
655#endif
656
28c88046 657/* LCD */
3c85bce6 658#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
28c88046
MR
659static struct pxafb_mode_info em_x270_lcd_modes[] = {
660 [0] = {
661 .pixclock = 38250,
662 .bpp = 16,
663 .xres = 480,
664 .yres = 640,
665 .hsync_len = 8,
666 .vsync_len = 2,
667 .left_margin = 8,
668 .upper_margin = 2,
669 .right_margin = 24,
670 .lower_margin = 4,
671 .sync = 0,
672 },
673 [1] = {
674 .pixclock = 153800,
675 .bpp = 16,
676 .xres = 240,
677 .yres = 320,
678 .hsync_len = 8,
679 .vsync_len = 2,
680 .left_margin = 8,
681 .upper_margin = 2,
682 .right_margin = 88,
683 .lower_margin = 2,
684 .sync = 0,
685 },
3d50527b
MR
686};
687
688static struct pxafb_mach_info em_x270_lcd = {
28c88046
MR
689 .modes = em_x270_lcd_modes,
690 .num_modes = 2,
3c85bce6 691 .lcd_conn = LCD_COLOR_TFT_16BPP,
3d50527b 692};
28c88046 693
3c85bce6 694static void __init em_x270_init_lcd(void)
3d50527b 695{
4321e1a1 696 pxa_set_fb_info(NULL, &em_x270_lcd);
3c85bce6
MR
697}
698#else
699static inline void em_x270_init_lcd(void) {}
700#endif
3d50527b 701
28c88046
MR
702#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
703static struct pxa2xx_spi_master em_x270_spi_info = {
704 .num_chipselect = 1,
705};
706
707static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
bd9d0740
MR
708 .rx_threshold = 1,
709 .tx_threshold = 1,
710 .gpio_cs = -1,
28c88046
MR
711};
712
713static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
714 .model = TDO35S,
715};
716
c9be0e39
MR
717static struct pxa2xx_spi_master em_x270_spi_2_info = {
718 .num_chipselect = 1,
719 .enable_dma = 1,
720};
721
722static struct pxa2xx_spi_chip em_x270_libertas_chip = {
723 .rx_threshold = 1,
724 .tx_threshold = 1,
725 .timeout = 1000,
3cb05c97 726 .gpio_cs = 14,
c9be0e39
MR
727};
728
729static unsigned long em_x270_libertas_pin_config[] = {
730 /* SSP2 */
731 GPIO19_SSP2_SCLK,
732 GPIO14_GPIO,
733 GPIO89_SSP2_TXD,
734 GPIO88_SSP2_RXD,
735};
736
737static int em_x270_libertas_setup(struct spi_device *spi)
738{
739 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
740 if (err)
741 return err;
742
2f15cb59
MR
743 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
744 if (err)
745 goto err_free_pwen;
746
747 if (machine_is_exeda()) {
748 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
749 if (err)
750 goto err_free_strap;
751
752 gpio_direction_output(GPIO37_WLAN_RST, 1);
753 msleep(100);
754 }
755
c9be0e39 756 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
2f15cb59 757 msleep(100);
c9be0e39
MR
758
759 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
760
761 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
2f15cb59 762 msleep(100);
c9be0e39 763 gpio_set_value(GPIO115_WLAN_PWEN, 1);
2f15cb59 764 msleep(100);
c9be0e39
MR
765
766 spi->bits_per_word = 16;
767 spi_setup(spi);
768
769 return 0;
2f15cb59
MR
770
771err_free_strap:
772 gpio_free(GPIO19_WLAN_STRAP);
773err_free_pwen:
774 gpio_free(GPIO115_WLAN_PWEN);
775
776 return err;
c9be0e39
MR
777}
778
779static int em_x270_libertas_teardown(struct spi_device *spi)
780{
781 gpio_set_value(GPIO115_WLAN_PWEN, 0);
782 gpio_free(GPIO115_WLAN_PWEN);
2f15cb59
MR
783 gpio_free(GPIO19_WLAN_STRAP);
784
785 if (machine_is_exeda()) {
786 gpio_set_value(GPIO37_WLAN_RST, 0);
787 gpio_free(GPIO37_WLAN_RST);
788 }
c9be0e39
MR
789
790 return 0;
791}
792
793struct libertas_spi_platform_data em_x270_libertas_pdata = {
794 .use_dummy_writes = 1,
c9be0e39
MR
795 .setup = em_x270_libertas_setup,
796 .teardown = em_x270_libertas_teardown,
797};
798
28c88046
MR
799static struct spi_board_info em_x270_spi_devices[] __initdata = {
800 {
c9be0e39
MR
801 .modalias = "tdo24m",
802 .max_speed_hz = 1000000,
803 .bus_num = 1,
804 .chip_select = 0,
805 .controller_data = &em_x270_tdo24m_chip,
806 .platform_data = &em_x270_tdo24m_pdata,
807 },
808 {
809 .modalias = "libertas_spi",
810 .max_speed_hz = 13000000,
811 .bus_num = 2,
6384fdad 812 .irq = PXA_GPIO_TO_IRQ(116),
c9be0e39
MR
813 .chip_select = 0,
814 .controller_data = &em_x270_libertas_chip,
815 .platform_data = &em_x270_libertas_pdata,
28c88046
MR
816 },
817};
818
819static void __init em_x270_init_spi(void)
820{
821 pxa2xx_set_spi_info(1, &em_x270_spi_info);
c9be0e39 822 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
28c88046
MR
823 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
824}
825#else
826static inline void em_x270_init_spi(void) {}
827#endif
828
303f2d7d 829#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
c63a5751
MR
830static pxa2xx_audio_ops_t em_x270_ac97_info = {
831 .reset_gpio = 113,
832};
833
3c85bce6
MR
834static void __init em_x270_init_ac97(void)
835{
c63a5751 836 pxa_set_ac97_info(&em_x270_ac97_info);
3c85bce6
MR
837}
838#else
839static inline void em_x270_init_ac97(void) {}
840#endif
841
842#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0a085a94 843static const unsigned int em_x270_module_matrix_keys[] = {
3c85bce6
MR
844 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
845 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
846 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
847};
3d50527b 848
0a085a94
CX
849static struct matrix_keymap_data em_x270_matrix_keymap_data = {
850 .keymap = em_x270_module_matrix_keys,
851 .keymap_size = ARRAY_SIZE(em_x270_module_matrix_keys),
852};
853
7f14a787 854struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
3c85bce6
MR
855 /* code map for the matrix keys */
856 .matrix_key_rows = 3,
857 .matrix_key_cols = 3,
0a085a94 858 .matrix_keymap_data = &em_x270_matrix_keymap_data,
7f14a787
MR
859};
860
0a085a94 861static const unsigned int em_x270_exeda_matrix_keys[] = {
7f14a787
MR
862 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
863 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
864 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
865 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
866
867 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
868 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
869 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
870 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
871
872 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
873 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
874 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
875 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
876
877 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
878 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
879 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
880 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
881
882 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
883 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
884 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
885 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
886
887 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
888 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
889 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
890 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
891
892 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
893 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
894 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
895 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
896
897 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
898 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
899 KEY(7, 4, 0), KEY(7, 5, 0),
900 KEY(7, 6, 0), KEY(7, 7, 0),
901};
902
0a085a94
CX
903static struct matrix_keymap_data em_x270_exeda_matrix_keymap_data = {
904 .keymap = em_x270_exeda_matrix_keys,
905 .keymap_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
906};
907
7f14a787
MR
908struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
909 /* code map for the matrix keys */
910 .matrix_key_rows = 8,
911 .matrix_key_cols = 8,
0a085a94 912 .matrix_keymap_data = &em_x270_exeda_matrix_keymap_data,
3c85bce6
MR
913};
914
915static void __init em_x270_init_keypad(void)
916{
7f14a787
MR
917 if (machine_is_em_x270())
918 pxa_set_keypad_info(&em_x270_module_keypad_info);
919 else
920 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
3c85bce6
MR
921}
922#else
923static inline void em_x270_init_keypad(void) {}
924#endif
3d50527b 925
3c85bce6
MR
926#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
927static struct gpio_keys_button gpio_keys_button[] = {
928 [0] = {
929 .desc = "sleep/wakeup",
930 .code = KEY_SUSPEND,
931 .type = EV_PWR,
932 .gpio = 1,
933 .wakeup = 1,
934 },
935};
3d50527b 936
3c85bce6
MR
937static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
938 .buttons = gpio_keys_button,
939 .nbuttons = 1,
940};
3d50527b 941
3c85bce6
MR
942static struct platform_device em_x270_gpio_keys = {
943 .name = "gpio-keys",
944 .id = -1,
945 .dev = {
946 .platform_data = &em_x270_gpio_keys_data,
947 },
948};
949
950static void __init em_x270_init_gpio_keys(void)
951{
952 platform_device_register(&em_x270_gpio_keys);
953}
954#else
955static inline void em_x270_init_gpio_keys(void) {}
956#endif
957
28c88046
MR
958/* Quick Capture Interface and sensor setup */
959#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
a7f2bdb3 960static int em_x270_sensor_init(void)
28c88046
MR
961{
962 int ret;
963
76e3fc36 964 ret = gpio_request(cam_reset, "camera reset");
28c88046
MR
965 if (ret)
966 return ret;
967
76e3fc36 968 gpio_direction_output(cam_reset, 0);
76e3fc36 969 gpio_set_value(cam_reset, 1);
28c88046
MR
970
971 return 0;
972}
973
d9fa0472
RJ
974static struct regulator_consumer_supply camera_dummy_supplies[] = {
975 REGULATOR_SUPPLY("vdd", "0-005d"),
28c88046
MR
976};
977
d9fa0472
RJ
978static struct regulator_init_data camera_dummy_initdata = {
979 .consumer_supplies = camera_dummy_supplies,
980 .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies),
981 .constraints = {
982 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
489db6a6
GL
983 },
984};
985
d9fa0472
RJ
986static struct fixed_voltage_config camera_dummy_config = {
987 .supply_name = "camera_vdd",
988 .input_supply = "vcc cam",
989 .microvolts = 2800000,
990 .gpio = -1,
991 .enable_high = 0,
992 .init_data = &camera_dummy_initdata,
489db6a6
GL
993};
994
d9fa0472
RJ
995static struct platform_device camera_supply_dummy_device = {
996 .name = "reg-fixed-voltage",
997 .id = 1,
489db6a6 998 .dev = {
d9fa0472 999 .platform_data = &camera_dummy_config,
28c88046
MR
1000 },
1001};
1002
d9fa0472
RJ
1003struct pxacamera_platform_data em_x270_camera_platform_data = {
1004 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
1005 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
1006 .mclk_10khz = 2600,
1007 .sensor_i2c_adapter_id = 0,
1008 .sensor_i2c_address = 0x5d,
1009};
1010
28c88046
MR
1011static void __init em_x270_init_camera(void)
1012{
d9fa0472 1013 if (em_x270_sensor_init() == 0)
a7f2bdb3 1014 pxa_set_camera_info(&em_x270_camera_platform_data);
d9fa0472 1015 platform_device_register(&camera_supply_dummy_device);
28c88046
MR
1016}
1017#else
1018static inline void em_x270_init_camera(void) {}
1019#endif
1020
a37ed431
MR
1021static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1022 .supply = "vcc gps",
1023};
1024
1025static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1026 .name = "vcc gps",
1027 .num_supplies = 1,
1028 .supplies = &em_x270_gps_consumer_supply,
1029};
1030
1031static struct platform_device em_x270_gps_userspace_consumer = {
1032 .name = "reg-userspace-consumer",
1033 .id = 0,
1034 .dev = {
1035 .platform_data = &em_x270_gps_consumer_data,
1036 },
1037};
1038
1039static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1040 .supply = "vcc gprs",
1041};
1042
1043static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1044 .name = "vcc gprs",
1045 .num_supplies = 1,
1046 .supplies = &em_x270_gprs_consumer_supply
1047};
1048
1049static struct platform_device em_x270_gprs_userspace_consumer = {
1050 .name = "reg-userspace-consumer",
1051 .id = 1,
1052 .dev = {
1053 .platform_data = &em_x270_gprs_consumer_data,
1054 }
1055};
1056
1057static struct platform_device *em_x270_userspace_consumers[] = {
1058 &em_x270_gps_userspace_consumer,
1059 &em_x270_gprs_userspace_consumer,
1060};
1061
1062static void __init em_x270_userspace_consumers_init(void)
1063{
1064 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1065}
1066
28c88046 1067/* DA9030 related initializations */
804d2312 1068#define REGULATOR_CONSUMER(_name, _dev_name, _supply) \
432adf18 1069 static struct regulator_consumer_supply _name##_consumers[] = { \
0bf189ab 1070 REGULATOR_SUPPLY(_supply, _dev_name), \
432adf18 1071 }
28c88046 1072
804d2312 1073REGULATOR_CONSUMER(ldo3, "reg-userspace-consumer.0", "vcc gps");
432adf18 1074REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
804d2312 1075REGULATOR_CONSUMER(ldo10, "pxa2xx-mci", "vcc sdio");
432adf18 1076REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
804d2312 1077REGULATOR_CONSUMER(ldo19, "reg-userspace-consumer.1", "vcc gprs");
100a1d25 1078REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
432adf18
MR
1079
1080#define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1081 static struct regulator_init_data _ldo##_data = { \
1082 .constraints = { \
1083 .min_uV = _min_uV, \
1084 .max_uV = _max_uV, \
1085 .state_mem = { \
1086 .enabled = 0, \
1087 }, \
1088 .valid_ops_mask = _ops_mask, \
a37ed431 1089 .apply_uV = 1, \
432adf18
MR
1090 }, \
1091 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1092 .consumer_supplies = _ldo##_consumers, \
1093 };
1094
1095REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1096REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1097REGULATOR_INIT(ldo10, 2000000, 3200000,
1098 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1099REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1100REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
100a1d25 1101REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
28c88046
MR
1102
1103struct led_info em_x270_led_info = {
1104 .name = "em-x270:orange",
1105 .default_trigger = "battery-charging-or-full",
1106};
1107
9f055c49 1108struct power_supply_info em_x270_psy_info = {
3690a0f4 1109 .name = "battery",
9f055c49
MR
1110 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1111 .voltage_max_design = 4200000,
1112 .voltage_min_design = 3000000,
1113 .use_for_apm = 1,
1114};
1115
1116static void em_x270_battery_low(void)
1117{
1d3e216f 1118#if defined(CONFIG_APM_EMULATION)
9f055c49 1119 apm_queue_event(APM_LOW_BATTERY);
1d3e216f 1120#endif
9f055c49
MR
1121}
1122
1123static void em_x270_battery_critical(void)
1124{
1d3e216f 1125#if defined(CONFIG_APM_EMULATION)
9f055c49 1126 apm_queue_event(APM_CRITICAL_SUSPEND);
1d3e216f 1127#endif
9f055c49
MR
1128}
1129
1130struct da9030_battery_info em_x270_batterty_info = {
1131 .battery_info = &em_x270_psy_info,
1132
1133 .charge_milliamp = 1000,
1134 .charge_millivolt = 4200,
1135
1136 .vbat_low = 3600,
1137 .vbat_crit = 3400,
1138 .vbat_charge_start = 4100,
1139 .vbat_charge_stop = 4200,
1140 .vbat_charge_restart = 4000,
1141
1142 .vcharge_min = 3200,
1143 .vcharge_max = 5500,
1144
1145 .tbat_low = 197,
1146 .tbat_high = 78,
1147 .tbat_restart = 100,
1148
1149 .batmon_interval = 0,
1150
1151 .battery_low = em_x270_battery_low,
1152 .battery_critical = em_x270_battery_critical,
1153};
1154
432adf18
MR
1155#define DA9030_SUBDEV(_name, _id, _pdata) \
1156 { \
1157 .name = "da903x-" #_name, \
1158 .id = DA9030_ID_##_id, \
1159 .platform_data = _pdata, \
28c88046 1160 }
432adf18
MR
1161
1162#define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1163
1164struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1165 DA9030_LDO(3),
1166 DA9030_LDO(5),
1167 DA9030_LDO(10),
1168 DA9030_LDO(12),
1169 DA9030_LDO(19),
1170
100a1d25
MR
1171 DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
1172
432adf18
MR
1173 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1174 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
9f055c49 1175 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
28c88046
MR
1176};
1177
1178static struct da903x_platform_data em_x270_da9030_info = {
1179 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1180 .subdevs = em_x270_da9030_subdevs,
1181};
1182
1183static struct i2c_board_info em_x270_i2c_pmic_info = {
1184 I2C_BOARD_INFO("da9030", 0x49),
6384fdad 1185 .irq = PXA_GPIO_TO_IRQ(0),
28c88046
MR
1186 .platform_data = &em_x270_da9030_info,
1187};
1188
1189static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1190 .use_pio = 1,
1191};
1192
1193static void __init em_x270_init_da9030(void)
1194{
1195 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1196 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1197}
1198
76e3fc36
MR
1199static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1200 .gpio_base = 128,
1201};
1202
1203static struct i2c_board_info exeda_i2c_info[] = {
1204 {
1205 I2C_BOARD_INFO("pca9555", 0x21),
1206 .platform_data = &exeda_gpio_ext_pdata,
1207 },
1208};
1209
1210static struct i2c_pxa_platform_data em_x270_i2c_info = {
1211 .fast_mode = 1,
1212};
1213
1214static void __init em_x270_init_i2c(void)
1215{
1216 pxa_set_i2c_info(&em_x270_i2c_info);
1217
1218 if (machine_is_exeda())
1219 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1220}
1221
4a697e83 1222static void __init em_x270_module_init(void)
3c85bce6
MR
1223{
1224 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1225
4a697e83
MR
1226 mmc_cd = GPIO13_MMC_CD;
1227 nand_rb = GPIO56_NAND_RB;
1228 dm9000_flags = DM9000_PLATF_32BITONLY;
76e3fc36 1229 cam_reset = GPIO93_CAM_RESET;
128d88b8 1230 usb_hub_reset = GPIO16_USB_HUB_RESET;
4a697e83
MR
1231}
1232
7f14a787
MR
1233static void __init em_x270_exeda_init(void)
1234{
7f14a787
MR
1235 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1236
1237 mmc_cd = GPIO114_MMC_CD;
1238 nand_rb = GPIO20_NAND_RB;
1239 dm9000_flags = DM9000_PLATF_16BITONLY;
76e3fc36 1240 cam_reset = GPIO130_CAM_RESET;
128d88b8 1241 usb_hub_reset = GPIO10_USB_HUB_RESET;
7f14a787
MR
1242}
1243
4a697e83
MR
1244static void __init em_x270_init(void)
1245{
1246 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1247
cc155c6f
RK
1248 pxa_set_ffuart_info(NULL);
1249 pxa_set_btuart_info(NULL);
1250 pxa_set_stuart_info(NULL);
1251
9599d1db
MR
1252#ifdef CONFIG_PM
1253 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1254#endif
1255
7f14a787
MR
1256 if (machine_is_em_x270())
1257 em_x270_module_init();
1258 else if (machine_is_exeda())
1259 em_x270_exeda_init();
1260 else
1261 panic("Unsupported machine: %d\n", machine_arch_type);
4a697e83 1262
28c88046 1263 em_x270_init_da9030();
3c85bce6
MR
1264 em_x270_init_dm9000();
1265 em_x270_init_rtc();
1266 em_x270_init_nand();
28c88046 1267 em_x270_init_nor();
3c85bce6
MR
1268 em_x270_init_lcd();
1269 em_x270_init_mmc();
1270 em_x270_init_ohci();
1271 em_x270_init_keypad();
1272 em_x270_init_gpio_keys();
1273 em_x270_init_ac97();
28c88046 1274 em_x270_init_spi();
76e3fc36
MR
1275 em_x270_init_i2c();
1276 em_x270_init_camera();
a37ed431 1277 em_x270_userspace_consumers_init();
a927ef89
RJ
1278
1279 regulator_has_full_constraints();
3d50527b
MR
1280}
1281
3c85bce6 1282MACHINE_START(EM_X270, "Compulab EM-X270")
7375aba6 1283 .atag_offset = 0x100,
851982c1 1284 .map_io = pxa27x_map_io,
4e611091 1285 .nr_irqs = PXA_NR_IRQS,
3d50527b 1286 .init_irq = pxa27x_init_irq,
8a97ae2f 1287 .handle_irq = pxa27x_handle_irq,
6bb27d73 1288 .init_time = pxa_timer_init,
3d50527b 1289 .init_machine = em_x270_init,
271a74fc 1290 .restart = pxa_restart,
3d50527b 1291MACHINE_END
7f14a787
MR
1292
1293MACHINE_START(EXEDA, "Compulab eXeda")
7375aba6 1294 .atag_offset = 0x100,
851982c1 1295 .map_io = pxa27x_map_io,
4e611091 1296 .nr_irqs = PXA_NR_IRQS,
7f14a787 1297 .init_irq = pxa27x_init_irq,
8a97ae2f 1298 .handle_irq = pxa27x_handle_irq,
6bb27d73 1299 .init_time = pxa_timer_init,
7f14a787 1300 .init_machine = em_x270_init,
271a74fc 1301 .restart = pxa_restart,
7f14a787 1302MACHINE_END