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