em-x270.c 21 KB

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