em-x270.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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. #define REGULATOR_CONSUMER(_name, _dev, _supply) \
  673. static struct regulator_consumer_supply _name##_consumers[] = { \
  674. { \
  675. .dev = _dev, \
  676. .supply = _supply, \
  677. }, \
  678. }
  679. REGULATOR_CONSUMER(ldo3, NULL, "vcc gps");
  680. REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
  681. REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
  682. REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
  683. REGULATOR_CONSUMER(ldo19, NULL, "vcc gprs");
  684. #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
  685. static struct regulator_init_data _ldo##_data = { \
  686. .constraints = { \
  687. .min_uV = _min_uV, \
  688. .max_uV = _max_uV, \
  689. .state_mem = { \
  690. .enabled = 0, \
  691. }, \
  692. .valid_ops_mask = _ops_mask, \
  693. }, \
  694. .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
  695. .consumer_supplies = _ldo##_consumers, \
  696. };
  697. REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
  698. REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
  699. REGULATOR_INIT(ldo10, 2000000, 3200000,
  700. REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
  701. REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
  702. REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
  703. struct led_info em_x270_led_info = {
  704. .name = "em-x270:orange",
  705. .default_trigger = "battery-charging-or-full",
  706. };
  707. #define DA9030_SUBDEV(_name, _id, _pdata) \
  708. { \
  709. .name = "da903x-" #_name, \
  710. .id = DA9030_ID_##_id, \
  711. .platform_data = _pdata, \
  712. }
  713. #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
  714. struct da903x_subdev_info em_x270_da9030_subdevs[] = {
  715. DA9030_LDO(3),
  716. DA9030_LDO(5),
  717. DA9030_LDO(10),
  718. DA9030_LDO(12),
  719. DA9030_LDO(19),
  720. DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
  721. DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
  722. };
  723. static struct da903x_platform_data em_x270_da9030_info = {
  724. .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
  725. .subdevs = em_x270_da9030_subdevs,
  726. };
  727. static struct i2c_board_info em_x270_i2c_pmic_info = {
  728. I2C_BOARD_INFO("da9030", 0x49),
  729. .irq = IRQ_GPIO(0),
  730. .platform_data = &em_x270_da9030_info,
  731. };
  732. static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
  733. .use_pio = 1,
  734. };
  735. static void __init em_x270_init_da9030(void)
  736. {
  737. pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
  738. i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
  739. }
  740. static void __init em_x270_init(void)
  741. {
  742. pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
  743. em_x270_init_da9030();
  744. em_x270_init_dm9000();
  745. em_x270_init_rtc();
  746. em_x270_init_nand();
  747. em_x270_init_nor();
  748. em_x270_init_lcd();
  749. em_x270_init_mmc();
  750. em_x270_init_ohci();
  751. em_x270_init_keypad();
  752. em_x270_init_gpio_keys();
  753. em_x270_init_ac97();
  754. em_x270_init_camera();
  755. em_x270_init_spi();
  756. }
  757. MACHINE_START(EM_X270, "Compulab EM-X270")
  758. .boot_params = 0xa0000100,
  759. .phys_io = 0x40000000,
  760. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  761. .map_io = pxa_map_io,
  762. .init_irq = pxa27x_init_irq,
  763. .timer = &pxa_timer,
  764. .init_machine = em_x270_init,
  765. MACHINE_END