em-x270.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. /*
  2. * Support for CompuLab EM-X270 platform
  3. *
  4. * Copyright (C) 2007, 2008 CompuLab, Ltd.
  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. #include <linux/irq.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/dm9000.h>
  14. #include <linux/rtc-v3020.h>
  15. #include <linux/mtd/nand.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/input.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/gpio.h>
  21. #include <linux/mfd/da903x.h>
  22. #include <linux/regulator/machine.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/tdo24m.h>
  25. #include <media/soc_camera.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <mach/mfp-pxa27x.h>
  29. #include <mach/pxa-regs.h>
  30. #include <mach/pxa27x-udc.h>
  31. #include <mach/audio.h>
  32. #include <mach/pxafb.h>
  33. #include <mach/ohci.h>
  34. #include <mach/mmc.h>
  35. #include <mach/pxa27x_keypad.h>
  36. #include <mach/i2c.h>
  37. #include <mach/camera.h>
  38. #include <mach/pxa2xx_spi.h>
  39. #include "generic.h"
  40. /* GPIO IRQ usage */
  41. #define GPIO41_ETHIRQ (41)
  42. #define GPIO13_MMC_CD (13)
  43. #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
  44. #define EM_X270_MMC_CD IRQ_GPIO(GPIO13_MMC_CD)
  45. /* NAND control GPIOs */
  46. #define GPIO11_NAND_CS (11)
  47. #define GPIO56_NAND_RB (56)
  48. /* Miscelaneous GPIOs */
  49. #define GPIO93_CAM_RESET (93)
  50. static unsigned long em_x270_pin_config[] = {
  51. /* AC'97 */
  52. GPIO28_AC97_BITCLK,
  53. GPIO29_AC97_SDATA_IN_0,
  54. GPIO30_AC97_SDATA_OUT,
  55. GPIO31_AC97_SYNC,
  56. GPIO98_AC97_SYSCLK,
  57. GPIO113_AC97_nRESET,
  58. /* BTUART */
  59. GPIO42_BTUART_RXD,
  60. GPIO43_BTUART_TXD,
  61. GPIO44_BTUART_CTS,
  62. GPIO45_BTUART_RTS,
  63. /* STUART */
  64. GPIO46_STUART_RXD,
  65. GPIO47_STUART_TXD,
  66. /* MCI controller */
  67. GPIO32_MMC_CLK,
  68. GPIO112_MMC_CMD,
  69. GPIO92_MMC_DAT_0,
  70. GPIO109_MMC_DAT_1,
  71. GPIO110_MMC_DAT_2,
  72. GPIO111_MMC_DAT_3,
  73. /* LCD */
  74. GPIO58_LCD_LDD_0,
  75. GPIO59_LCD_LDD_1,
  76. GPIO60_LCD_LDD_2,
  77. GPIO61_LCD_LDD_3,
  78. GPIO62_LCD_LDD_4,
  79. GPIO63_LCD_LDD_5,
  80. GPIO64_LCD_LDD_6,
  81. GPIO65_LCD_LDD_7,
  82. GPIO66_LCD_LDD_8,
  83. GPIO67_LCD_LDD_9,
  84. GPIO68_LCD_LDD_10,
  85. GPIO69_LCD_LDD_11,
  86. GPIO70_LCD_LDD_12,
  87. GPIO71_LCD_LDD_13,
  88. GPIO72_LCD_LDD_14,
  89. GPIO73_LCD_LDD_15,
  90. GPIO74_LCD_FCLK,
  91. GPIO75_LCD_LCLK,
  92. GPIO76_LCD_PCLK,
  93. GPIO77_LCD_BIAS,
  94. /* QCI */
  95. GPIO84_CIF_FV,
  96. GPIO25_CIF_LV,
  97. GPIO53_CIF_MCLK,
  98. GPIO54_CIF_PCLK,
  99. GPIO81_CIF_DD_0,
  100. GPIO55_CIF_DD_1,
  101. GPIO51_CIF_DD_2,
  102. GPIO50_CIF_DD_3,
  103. GPIO52_CIF_DD_4,
  104. GPIO48_CIF_DD_5,
  105. GPIO17_CIF_DD_6,
  106. GPIO12_CIF_DD_7,
  107. /* I2C */
  108. GPIO117_I2C_SCL,
  109. GPIO118_I2C_SDA,
  110. /* Keypad */
  111. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  112. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  113. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  114. GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  115. GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
  116. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  117. GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
  118. GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
  119. GPIO103_KP_MKOUT_0,
  120. GPIO104_KP_MKOUT_1,
  121. GPIO105_KP_MKOUT_2,
  122. GPIO106_KP_MKOUT_3,
  123. GPIO107_KP_MKOUT_4,
  124. GPIO108_KP_MKOUT_5,
  125. GPIO96_KP_MKOUT_6,
  126. GPIO22_KP_MKOUT_7,
  127. /* SSP1 */
  128. GPIO26_SSP1_RXD,
  129. GPIO23_SSP1_SCLK,
  130. GPIO24_SSP1_SFRM,
  131. GPIO57_SSP1_TXD,
  132. /* SSP2 */
  133. GPIO19_SSP2_SCLK,
  134. GPIO14_SSP2_SFRM,
  135. GPIO89_SSP2_TXD,
  136. GPIO88_SSP2_RXD,
  137. /* SDRAM and local bus */
  138. GPIO15_nCS_1,
  139. GPIO78_nCS_2,
  140. GPIO79_nCS_3,
  141. GPIO80_nCS_4,
  142. GPIO49_nPWE,
  143. GPIO18_RDY,
  144. /* GPIO */
  145. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  146. /* power controls */
  147. GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
  148. GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
  149. GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
  150. /* NAND controls */
  151. GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
  152. GPIO56_GPIO, /* NAND Ready/Busy */
  153. /* interrupts */
  154. GPIO13_GPIO, /* MMC card detect */
  155. GPIO41_GPIO, /* DM9000 interrupt */
  156. };
  157. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  158. static struct resource em_x270_dm9000_resource[] = {
  159. [0] = {
  160. .start = PXA_CS2_PHYS,
  161. .end = PXA_CS2_PHYS + 3,
  162. .flags = IORESOURCE_MEM,
  163. },
  164. [1] = {
  165. .start = PXA_CS2_PHYS + 8,
  166. .end = PXA_CS2_PHYS + 8 + 0x3f,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. [2] = {
  170. .start = EM_X270_ETHIRQ,
  171. .end = EM_X270_ETHIRQ,
  172. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  173. }
  174. };
  175. static struct dm9000_plat_data em_x270_dm9000_platdata = {
  176. .flags = DM9000_PLATF_32BITONLY,
  177. };
  178. static struct platform_device em_x270_dm9000 = {
  179. .name = "dm9000",
  180. .id = 0,
  181. .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
  182. .resource = em_x270_dm9000_resource,
  183. .dev = {
  184. .platform_data = &em_x270_dm9000_platdata,
  185. }
  186. };
  187. static void __init em_x270_init_dm9000(void)
  188. {
  189. platform_device_register(&em_x270_dm9000);
  190. }
  191. #else
  192. static inline void em_x270_init_dm9000(void) {}
  193. #endif
  194. /* V3020 RTC */
  195. #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
  196. static struct resource em_x270_v3020_resource[] = {
  197. [0] = {
  198. .start = PXA_CS4_PHYS,
  199. .end = PXA_CS4_PHYS + 3,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. };
  203. static struct v3020_platform_data em_x270_v3020_platdata = {
  204. .leftshift = 0,
  205. };
  206. static struct platform_device em_x270_rtc = {
  207. .name = "v3020",
  208. .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
  209. .resource = em_x270_v3020_resource,
  210. .id = -1,
  211. .dev = {
  212. .platform_data = &em_x270_v3020_platdata,
  213. }
  214. };
  215. static void __init em_x270_init_rtc(void)
  216. {
  217. platform_device_register(&em_x270_rtc);
  218. }
  219. #else
  220. static inline void em_x270_init_rtc(void) {}
  221. #endif
  222. /* NAND flash */
  223. #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  224. static inline void nand_cs_on(void)
  225. {
  226. gpio_set_value(GPIO11_NAND_CS, 0);
  227. }
  228. static void nand_cs_off(void)
  229. {
  230. dsb();
  231. gpio_set_value(GPIO11_NAND_CS, 1);
  232. }
  233. /* hardware specific access to control-lines */
  234. static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
  235. unsigned int ctrl)
  236. {
  237. struct nand_chip *this = mtd->priv;
  238. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  239. dsb();
  240. if (ctrl & NAND_CTRL_CHANGE) {
  241. if (ctrl & NAND_ALE)
  242. nandaddr |= (1 << 3);
  243. else
  244. nandaddr &= ~(1 << 3);
  245. if (ctrl & NAND_CLE)
  246. nandaddr |= (1 << 2);
  247. else
  248. nandaddr &= ~(1 << 2);
  249. if (ctrl & NAND_NCE)
  250. nand_cs_on();
  251. else
  252. nand_cs_off();
  253. }
  254. dsb();
  255. this->IO_ADDR_W = (void __iomem *)nandaddr;
  256. if (dat != NAND_CMD_NONE)
  257. writel(dat, this->IO_ADDR_W);
  258. dsb();
  259. }
  260. /* read device ready pin */
  261. static int em_x270_nand_device_ready(struct mtd_info *mtd)
  262. {
  263. dsb();
  264. return gpio_get_value(GPIO56_NAND_RB);
  265. }
  266. static struct mtd_partition em_x270_partition_info[] = {
  267. [0] = {
  268. .name = "em_x270-0",
  269. .offset = 0,
  270. .size = SZ_4M,
  271. },
  272. [1] = {
  273. .name = "em_x270-1",
  274. .offset = MTDPART_OFS_APPEND,
  275. .size = MTDPART_SIZ_FULL
  276. },
  277. };
  278. static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
  279. struct platform_nand_data em_x270_nand_platdata = {
  280. .chip = {
  281. .nr_chips = 1,
  282. .chip_offset = 0,
  283. .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
  284. .partitions = em_x270_partition_info,
  285. .chip_delay = 20,
  286. .part_probe_types = em_x270_part_probes,
  287. },
  288. .ctrl = {
  289. .hwcontrol = 0,
  290. .dev_ready = em_x270_nand_device_ready,
  291. .select_chip = 0,
  292. .cmd_ctrl = em_x270_nand_cmd_ctl,
  293. },
  294. };
  295. static struct resource em_x270_nand_resource[] = {
  296. [0] = {
  297. .start = PXA_CS1_PHYS,
  298. .end = PXA_CS1_PHYS + 12,
  299. .flags = IORESOURCE_MEM,
  300. },
  301. };
  302. static struct platform_device em_x270_nand = {
  303. .name = "gen_nand",
  304. .num_resources = ARRAY_SIZE(em_x270_nand_resource),
  305. .resource = em_x270_nand_resource,
  306. .id = -1,
  307. .dev = {
  308. .platform_data = &em_x270_nand_platdata,
  309. }
  310. };
  311. static void __init em_x270_init_nand(void)
  312. {
  313. int err;
  314. err = gpio_request(GPIO11_NAND_CS, "NAND CS");
  315. if (err) {
  316. pr_warning("EM-X270: failed to request NAND CS gpio\n");
  317. return;
  318. }
  319. gpio_direction_output(GPIO11_NAND_CS, 1);
  320. err = gpio_request(GPIO56_NAND_RB, "NAND R/B");
  321. if (err) {
  322. pr_warning("EM-X270: failed to request NAND R/B gpio\n");
  323. gpio_free(GPIO11_NAND_CS);
  324. return;
  325. }
  326. gpio_direction_input(GPIO56_NAND_RB);
  327. platform_device_register(&em_x270_nand);
  328. }
  329. #else
  330. static inline void em_x270_init_nand(void) {}
  331. #endif
  332. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  333. static struct mtd_partition em_x270_nor_parts[] = {
  334. {
  335. .name = "Bootloader",
  336. .offset = 0x00000000,
  337. .size = 0x00050000,
  338. .mask_flags = MTD_WRITEABLE /* force read-only */
  339. }, {
  340. .name = "Environment",
  341. .offset = 0x00050000,
  342. .size = 0x00010000,
  343. }, {
  344. .name = "Reserved",
  345. .offset = 0x00060000,
  346. .size = 0x00050000,
  347. .mask_flags = MTD_WRITEABLE /* force read-only */
  348. }, {
  349. .name = "Splashscreen",
  350. .offset = 0x000b0000,
  351. .size = 0x00050000,
  352. }
  353. };
  354. static struct physmap_flash_data em_x270_nor_data[] = {
  355. [0] = {
  356. .width = 2,
  357. .parts = em_x270_nor_parts,
  358. .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
  359. },
  360. };
  361. static struct resource em_x270_nor_flash_resource = {
  362. .start = PXA_CS0_PHYS,
  363. .end = PXA_CS0_PHYS + SZ_1M - 1,
  364. .flags = IORESOURCE_MEM,
  365. };
  366. static struct platform_device em_x270_physmap_flash = {
  367. .name = "physmap-flash",
  368. .id = 0,
  369. .num_resources = 1,
  370. .resource = &em_x270_nor_flash_resource,
  371. .dev = {
  372. .platform_data = &em_x270_nor_data,
  373. },
  374. };
  375. static void __init em_x270_init_nor(void)
  376. {
  377. platform_device_register(&em_x270_physmap_flash);
  378. }
  379. #else
  380. static inline void em_x270_init_nor(void) {}
  381. #endif
  382. /* PXA27x OHCI controller setup */
  383. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  384. static int em_x270_ohci_init(struct device *dev)
  385. {
  386. /* enable port 2 transiever */
  387. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
  388. return 0;
  389. }
  390. static struct pxaohci_platform_data em_x270_ohci_platform_data = {
  391. .port_mode = PMM_PERPORT_MODE,
  392. .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
  393. .init = em_x270_ohci_init,
  394. };
  395. static void __init em_x270_init_ohci(void)
  396. {
  397. pxa_set_ohci_info(&em_x270_ohci_platform_data);
  398. }
  399. #else
  400. static inline void em_x270_init_ohci(void) {}
  401. #endif
  402. /* MCI controller setup */
  403. #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
  404. static int em_x270_mci_init(struct device *dev,
  405. irq_handler_t em_x270_detect_int,
  406. void *data)
  407. {
  408. int err = request_irq(EM_X270_MMC_CD, em_x270_detect_int,
  409. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  410. "MMC card detect", data);
  411. if (err) {
  412. printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
  413. __func__, err);
  414. return err;
  415. }
  416. return 0;
  417. }
  418. static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
  419. {
  420. /*
  421. FIXME: current hardware implementation does not allow to
  422. enable/disable MMC power. This will be fixed in next HW releases,
  423. and we'll need to add implmentation here.
  424. */
  425. return;
  426. }
  427. static void em_x270_mci_exit(struct device *dev, void *data)
  428. {
  429. int irq = gpio_to_irq(GPIO13_MMC_CD);
  430. free_irq(irq, data);
  431. }
  432. static struct pxamci_platform_data em_x270_mci_platform_data = {
  433. .ocr_mask = MMC_VDD_28_29|MMC_VDD_29_30|MMC_VDD_30_31,
  434. .init = em_x270_mci_init,
  435. .setpower = em_x270_mci_setpower,
  436. .exit = em_x270_mci_exit,
  437. };
  438. static void __init em_x270_init_mmc(void)
  439. {
  440. pxa_set_mci_info(&em_x270_mci_platform_data);
  441. }
  442. #else
  443. static inline void em_x270_init_mmc(void) {}
  444. #endif
  445. /* LCD */
  446. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  447. static struct pxafb_mode_info em_x270_lcd_modes[] = {
  448. [0] = {
  449. .pixclock = 38250,
  450. .bpp = 16,
  451. .xres = 480,
  452. .yres = 640,
  453. .hsync_len = 8,
  454. .vsync_len = 2,
  455. .left_margin = 8,
  456. .upper_margin = 2,
  457. .right_margin = 24,
  458. .lower_margin = 4,
  459. .sync = 0,
  460. },
  461. [1] = {
  462. .pixclock = 153800,
  463. .bpp = 16,
  464. .xres = 240,
  465. .yres = 320,
  466. .hsync_len = 8,
  467. .vsync_len = 2,
  468. .left_margin = 8,
  469. .upper_margin = 2,
  470. .right_margin = 88,
  471. .lower_margin = 2,
  472. .sync = 0,
  473. },
  474. };
  475. static struct pxafb_mach_info em_x270_lcd = {
  476. .modes = em_x270_lcd_modes,
  477. .num_modes = 2,
  478. .lcd_conn = LCD_COLOR_TFT_16BPP,
  479. };
  480. static void __init em_x270_init_lcd(void)
  481. {
  482. set_pxa_fb_info(&em_x270_lcd);
  483. }
  484. #else
  485. static inline void em_x270_init_lcd(void) {}
  486. #endif
  487. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  488. static struct pxa2xx_spi_master em_x270_spi_info = {
  489. .num_chipselect = 1,
  490. };
  491. static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
  492. .rx_threshold = 1,
  493. .tx_threshold = 1,
  494. };
  495. static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
  496. .model = TDO35S,
  497. };
  498. static struct spi_board_info em_x270_spi_devices[] __initdata = {
  499. {
  500. .modalias = "tdo24m",
  501. .max_speed_hz = 1000000,
  502. .bus_num = 1,
  503. .chip_select = 0,
  504. .controller_data = &em_x270_tdo24m_chip,
  505. .platform_data = &em_x270_tdo24m_pdata,
  506. },
  507. };
  508. static void __init em_x270_init_spi(void)
  509. {
  510. pxa2xx_set_spi_info(1, &em_x270_spi_info);
  511. spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
  512. }
  513. #else
  514. static inline void em_x270_init_spi(void) {}
  515. #endif
  516. #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
  517. static void __init em_x270_init_ac97(void)
  518. {
  519. pxa_set_ac97_info(NULL);
  520. }
  521. #else
  522. static inline void em_x270_init_ac97(void) {}
  523. #endif
  524. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  525. static unsigned int em_x270_matrix_keys[] = {
  526. KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
  527. KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
  528. KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
  529. };
  530. struct pxa27x_keypad_platform_data em_x270_keypad_info = {
  531. /* code map for the matrix keys */
  532. .matrix_key_rows = 3,
  533. .matrix_key_cols = 3,
  534. .matrix_key_map = em_x270_matrix_keys,
  535. .matrix_key_map_size = ARRAY_SIZE(em_x270_matrix_keys),
  536. };
  537. static void __init em_x270_init_keypad(void)
  538. {
  539. pxa_set_keypad_info(&em_x270_keypad_info);
  540. }
  541. #else
  542. static inline void em_x270_init_keypad(void) {}
  543. #endif
  544. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  545. static struct gpio_keys_button gpio_keys_button[] = {
  546. [0] = {
  547. .desc = "sleep/wakeup",
  548. .code = KEY_SUSPEND,
  549. .type = EV_PWR,
  550. .gpio = 1,
  551. .wakeup = 1,
  552. },
  553. };
  554. static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
  555. .buttons = gpio_keys_button,
  556. .nbuttons = 1,
  557. };
  558. static struct platform_device em_x270_gpio_keys = {
  559. .name = "gpio-keys",
  560. .id = -1,
  561. .dev = {
  562. .platform_data = &em_x270_gpio_keys_data,
  563. },
  564. };
  565. static void __init em_x270_init_gpio_keys(void)
  566. {
  567. platform_device_register(&em_x270_gpio_keys);
  568. }
  569. #else
  570. static inline void em_x270_init_gpio_keys(void) {}
  571. #endif
  572. /* Quick Capture Interface and sensor setup */
  573. #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
  574. static struct regulator *em_x270_camera_ldo;
  575. static int em_x270_sensor_init(struct device *dev)
  576. {
  577. int ret;
  578. ret = gpio_request(GPIO93_CAM_RESET, "camera reset");
  579. if (ret)
  580. return ret;
  581. gpio_direction_output(GPIO93_CAM_RESET, 0);
  582. em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
  583. if (em_x270_camera_ldo == NULL) {
  584. gpio_free(GPIO93_CAM_RESET);
  585. return -ENODEV;
  586. }
  587. ret = regulator_enable(em_x270_camera_ldo);
  588. if (ret) {
  589. regulator_put(em_x270_camera_ldo);
  590. gpio_free(GPIO93_CAM_RESET);
  591. return ret;
  592. }
  593. gpio_set_value(GPIO93_CAM_RESET, 1);
  594. return 0;
  595. }
  596. struct pxacamera_platform_data em_x270_camera_platform_data = {
  597. .init = em_x270_sensor_init,
  598. .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
  599. PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
  600. .mclk_10khz = 2600,
  601. };
  602. static int em_x270_sensor_power(struct device *dev, int on)
  603. {
  604. int ret;
  605. int is_on = regulator_is_enabled(em_x270_camera_ldo);
  606. if (on == is_on)
  607. return 0;
  608. gpio_set_value(GPIO93_CAM_RESET, !on);
  609. if (on)
  610. ret = regulator_enable(em_x270_camera_ldo);
  611. else
  612. ret = regulator_disable(em_x270_camera_ldo);
  613. if (ret)
  614. return ret;
  615. gpio_set_value(GPIO93_CAM_RESET, on);
  616. return 0;
  617. }
  618. static struct soc_camera_link iclink = {
  619. .bus_id = 0,
  620. .power = em_x270_sensor_power,
  621. };
  622. static struct i2c_board_info em_x270_i2c_cam_info[] = {
  623. {
  624. I2C_BOARD_INFO("mt9m111", 0x48),
  625. .platform_data = &iclink,
  626. },
  627. };
  628. static struct i2c_pxa_platform_data em_x270_i2c_info = {
  629. .fast_mode = 1,
  630. };
  631. static void __init em_x270_init_camera(void)
  632. {
  633. pxa_set_i2c_info(&em_x270_i2c_info);
  634. i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
  635. pxa_set_camera_info(&em_x270_camera_platform_data);
  636. }
  637. #else
  638. static inline void em_x270_init_camera(void) {}
  639. #endif
  640. /* DA9030 related initializations */
  641. static struct regulator_consumer_supply ldo3_consumers[] = {
  642. {
  643. .dev = NULL,
  644. .supply = "vcc gps",
  645. },
  646. };
  647. static struct regulator_consumer_supply ldo5_consumers[] = {
  648. {
  649. .dev = NULL,
  650. .supply = "vcc cam",
  651. },
  652. };
  653. static struct regulator_consumer_supply ldo12_consumers[] = {
  654. {
  655. .dev = NULL,
  656. .supply = "vcc usb",
  657. },
  658. };
  659. static struct regulator_consumer_supply ldo19_consumers[] = {
  660. {
  661. .dev = NULL,
  662. .supply = "vcc gprs",
  663. },
  664. };
  665. static struct regulator_init_data ldo3_data = {
  666. .constraints = {
  667. .min_uV = 3200000,
  668. .max_uV = 3200000,
  669. .state_mem = {
  670. .enabled = 0,
  671. },
  672. },
  673. .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
  674. .consumer_supplies = ldo3_consumers,
  675. };
  676. static struct regulator_init_data ldo5_data = {
  677. .constraints = {
  678. .min_uV = 3000000,
  679. .max_uV = 3000000,
  680. .state_mem = {
  681. .enabled = 0,
  682. },
  683. },
  684. .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
  685. .consumer_supplies = ldo5_consumers,
  686. };
  687. static struct regulator_init_data ldo12_data = {
  688. .constraints = {
  689. .min_uV = 3000000,
  690. .max_uV = 3000000,
  691. .state_mem = {
  692. .enabled = 0,
  693. },
  694. },
  695. .num_consumer_supplies = ARRAY_SIZE(ldo12_consumers),
  696. .consumer_supplies = ldo12_consumers,
  697. };
  698. static struct regulator_init_data ldo19_data = {
  699. .constraints = {
  700. .min_uV = 3200000,
  701. .max_uV = 3200000,
  702. .state_mem = {
  703. .enabled = 0,
  704. },
  705. },
  706. .num_consumer_supplies = ARRAY_SIZE(ldo19_consumers),
  707. .consumer_supplies = ldo19_consumers,
  708. };
  709. struct led_info em_x270_led_info = {
  710. .name = "em-x270:orange",
  711. .default_trigger = "battery-charging-or-full",
  712. };
  713. struct da903x_subdev_info em_x270_da9030_subdevs[] = {
  714. {
  715. .name = "da903x-regulator",
  716. .id = DA9030_ID_LDO3,
  717. .platform_data = &ldo3_data,
  718. }, {
  719. .name = "da903x-regulator",
  720. .id = DA9030_ID_LDO5,
  721. .platform_data = &ldo5_data,
  722. }, {
  723. .name = "da903x-regulator",
  724. .id = DA9030_ID_LDO12,
  725. .platform_data = &ldo12_data,
  726. }, {
  727. .name = "da903x-regulator",
  728. .id = DA9030_ID_LDO19,
  729. .platform_data = &ldo19_data,
  730. }, {
  731. .name = "da903x-led",
  732. .id = DA9030_ID_LED_PC,
  733. .platform_data = &em_x270_led_info,
  734. }, {
  735. .name = "da903x-backlight",
  736. .id = DA9030_ID_WLED,
  737. }
  738. };
  739. static struct da903x_platform_data em_x270_da9030_info = {
  740. .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
  741. .subdevs = em_x270_da9030_subdevs,
  742. };
  743. static struct i2c_board_info em_x270_i2c_pmic_info = {
  744. I2C_BOARD_INFO("da9030", 0x49),
  745. .irq = IRQ_GPIO(0),
  746. .platform_data = &em_x270_da9030_info,
  747. };
  748. static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
  749. .use_pio = 1,
  750. };
  751. static void __init em_x270_init_da9030(void)
  752. {
  753. pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
  754. i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
  755. }
  756. static void __init em_x270_init(void)
  757. {
  758. pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
  759. em_x270_init_da9030();
  760. em_x270_init_dm9000();
  761. em_x270_init_rtc();
  762. em_x270_init_nand();
  763. em_x270_init_nor();
  764. em_x270_init_lcd();
  765. em_x270_init_mmc();
  766. em_x270_init_ohci();
  767. em_x270_init_keypad();
  768. em_x270_init_gpio_keys();
  769. em_x270_init_ac97();
  770. em_x270_init_camera();
  771. em_x270_init_spi();
  772. }
  773. MACHINE_START(EM_X270, "Compulab EM-X270")
  774. .boot_params = 0xa0000100,
  775. .phys_io = 0x40000000,
  776. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  777. .map_io = pxa_map_io,
  778. .init_irq = pxa27x_init_irq,
  779. .timer = &pxa_timer,
  780. .init_machine = em_x270_init,
  781. MACHINE_END