em-x270.c 21 KB

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