em-x270.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  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/delay.h>
  14. #include <linux/dm9000.h>
  15. #include <linux/rtc-v3020.h>
  16. #include <linux/mtd/nand.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/input.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/gpio.h>
  22. #include <linux/mfd/da903x.h>
  23. #include <linux/regulator/machine.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/tdo24m.h>
  26. #include <linux/spi/libertas_spi.h>
  27. #include <linux/power_supply.h>
  28. #include <linux/apm-emulation.h>
  29. #include <linux/i2c.h>
  30. #include <linux/i2c/pca953x.h>
  31. #include <linux/regulator/userspace-consumer.h>
  32. #include <media/soc_camera.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <mach/pxa27x.h>
  36. #include <mach/pxa27x-udc.h>
  37. #include <mach/audio.h>
  38. #include <mach/pxafb.h>
  39. #include <mach/ohci.h>
  40. #include <mach/mmc.h>
  41. #include <mach/pxa27x_keypad.h>
  42. #include <plat/i2c.h>
  43. #include <mach/camera.h>
  44. #include <mach/pxa2xx_spi.h>
  45. #include "generic.h"
  46. #include "devices.h"
  47. /* EM-X270 specific GPIOs */
  48. #define GPIO13_MMC_CD (13)
  49. #define GPIO95_MMC_WP (95)
  50. #define GPIO56_NAND_RB (56)
  51. #define GPIO93_CAM_RESET (93)
  52. #define GPIO16_USB_HUB_RESET (16)
  53. /* eXeda specific GPIOs */
  54. #define GPIO114_MMC_CD (114)
  55. #define GPIO20_NAND_RB (20)
  56. #define GPIO38_SD_PWEN (38)
  57. #define GPIO37_WLAN_RST (37)
  58. #define GPIO95_TOUCHPAD_INT (95)
  59. #define GPIO130_CAM_RESET (130)
  60. #define GPIO10_USB_HUB_RESET (10)
  61. /* common GPIOs */
  62. #define GPIO11_NAND_CS (11)
  63. #define GPIO41_ETHIRQ (41)
  64. #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
  65. #define GPIO115_WLAN_PWEN (115)
  66. #define GPIO19_WLAN_STRAP (19)
  67. #define GPIO9_USB_VBUS_EN (9)
  68. static int mmc_cd;
  69. static int nand_rb;
  70. static int dm9000_flags;
  71. static int cam_reset;
  72. static int usb_hub_reset;
  73. static unsigned long common_pin_config[] = {
  74. /* AC'97 */
  75. GPIO28_AC97_BITCLK,
  76. GPIO29_AC97_SDATA_IN_0,
  77. GPIO30_AC97_SDATA_OUT,
  78. GPIO31_AC97_SYNC,
  79. GPIO98_AC97_SYSCLK,
  80. GPIO113_AC97_nRESET,
  81. /* BTUART */
  82. GPIO42_BTUART_RXD,
  83. GPIO43_BTUART_TXD,
  84. GPIO44_BTUART_CTS,
  85. GPIO45_BTUART_RTS,
  86. /* STUART */
  87. GPIO46_STUART_RXD,
  88. GPIO47_STUART_TXD,
  89. /* MCI controller */
  90. GPIO32_MMC_CLK,
  91. GPIO112_MMC_CMD,
  92. GPIO92_MMC_DAT_0,
  93. GPIO109_MMC_DAT_1,
  94. GPIO110_MMC_DAT_2,
  95. GPIO111_MMC_DAT_3,
  96. /* LCD */
  97. GPIO58_LCD_LDD_0,
  98. GPIO59_LCD_LDD_1,
  99. GPIO60_LCD_LDD_2,
  100. GPIO61_LCD_LDD_3,
  101. GPIO62_LCD_LDD_4,
  102. GPIO63_LCD_LDD_5,
  103. GPIO64_LCD_LDD_6,
  104. GPIO65_LCD_LDD_7,
  105. GPIO66_LCD_LDD_8,
  106. GPIO67_LCD_LDD_9,
  107. GPIO68_LCD_LDD_10,
  108. GPIO69_LCD_LDD_11,
  109. GPIO70_LCD_LDD_12,
  110. GPIO71_LCD_LDD_13,
  111. GPIO72_LCD_LDD_14,
  112. GPIO73_LCD_LDD_15,
  113. GPIO74_LCD_FCLK,
  114. GPIO75_LCD_LCLK,
  115. GPIO76_LCD_PCLK,
  116. GPIO77_LCD_BIAS,
  117. /* QCI */
  118. GPIO84_CIF_FV,
  119. GPIO25_CIF_LV,
  120. GPIO53_CIF_MCLK,
  121. GPIO54_CIF_PCLK,
  122. GPIO81_CIF_DD_0,
  123. GPIO55_CIF_DD_1,
  124. GPIO51_CIF_DD_2,
  125. GPIO50_CIF_DD_3,
  126. GPIO52_CIF_DD_4,
  127. GPIO48_CIF_DD_5,
  128. GPIO17_CIF_DD_6,
  129. GPIO12_CIF_DD_7,
  130. /* I2C */
  131. GPIO117_I2C_SCL,
  132. GPIO118_I2C_SDA,
  133. /* Keypad */
  134. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  135. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  136. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  137. GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  138. GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
  139. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  140. GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
  141. GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
  142. GPIO103_KP_MKOUT_0,
  143. GPIO104_KP_MKOUT_1,
  144. GPIO105_KP_MKOUT_2,
  145. GPIO106_KP_MKOUT_3,
  146. GPIO107_KP_MKOUT_4,
  147. GPIO108_KP_MKOUT_5,
  148. GPIO96_KP_MKOUT_6,
  149. GPIO22_KP_MKOUT_7,
  150. /* SSP1 */
  151. GPIO26_SSP1_RXD,
  152. GPIO23_SSP1_SCLK,
  153. GPIO24_SSP1_SFRM,
  154. GPIO57_SSP1_TXD,
  155. /* SSP2 */
  156. GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
  157. GPIO14_GPIO,
  158. GPIO89_SSP2_TXD,
  159. GPIO88_SSP2_RXD,
  160. /* SDRAM and local bus */
  161. GPIO15_nCS_1,
  162. GPIO78_nCS_2,
  163. GPIO79_nCS_3,
  164. GPIO80_nCS_4,
  165. GPIO49_nPWE,
  166. GPIO18_RDY,
  167. /* GPIO */
  168. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
  169. /* power controls */
  170. GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
  171. GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
  172. /* NAND controls */
  173. GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
  174. /* interrupts */
  175. GPIO41_GPIO, /* DM9000 interrupt */
  176. };
  177. static unsigned long em_x270_pin_config[] = {
  178. GPIO13_GPIO, /* MMC card detect */
  179. GPIO16_GPIO, /* USB hub reset */
  180. GPIO56_GPIO, /* NAND Ready/Busy */
  181. GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
  182. GPIO95_GPIO, /* MMC Write protect */
  183. };
  184. static unsigned long exeda_pin_config[] = {
  185. GPIO10_GPIO, /* USB hub reset */
  186. GPIO20_GPIO, /* NAND Ready/Busy */
  187. GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
  188. GPIO95_GPIO, /* touchpad IRQ */
  189. GPIO114_GPIO, /* MMC card detect */
  190. };
  191. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  192. static struct resource em_x270_dm9000_resource[] = {
  193. [0] = {
  194. .start = PXA_CS2_PHYS,
  195. .end = PXA_CS2_PHYS + 3,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. [1] = {
  199. .start = PXA_CS2_PHYS + 8,
  200. .end = PXA_CS2_PHYS + 8 + 0x3f,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. [2] = {
  204. .start = EM_X270_ETHIRQ,
  205. .end = EM_X270_ETHIRQ,
  206. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  207. }
  208. };
  209. static struct dm9000_plat_data em_x270_dm9000_platdata = {
  210. .flags = DM9000_PLATF_NO_EEPROM,
  211. };
  212. static struct platform_device em_x270_dm9000 = {
  213. .name = "dm9000",
  214. .id = 0,
  215. .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
  216. .resource = em_x270_dm9000_resource,
  217. .dev = {
  218. .platform_data = &em_x270_dm9000_platdata,
  219. }
  220. };
  221. static void __init em_x270_init_dm9000(void)
  222. {
  223. em_x270_dm9000_platdata.flags |= dm9000_flags;
  224. platform_device_register(&em_x270_dm9000);
  225. }
  226. #else
  227. static inline void em_x270_init_dm9000(void) {}
  228. #endif
  229. /* V3020 RTC */
  230. #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
  231. static struct resource em_x270_v3020_resource[] = {
  232. [0] = {
  233. .start = PXA_CS4_PHYS,
  234. .end = PXA_CS4_PHYS + 3,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. };
  238. static struct v3020_platform_data em_x270_v3020_platdata = {
  239. .leftshift = 0,
  240. };
  241. static struct platform_device em_x270_rtc = {
  242. .name = "v3020",
  243. .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
  244. .resource = em_x270_v3020_resource,
  245. .id = -1,
  246. .dev = {
  247. .platform_data = &em_x270_v3020_platdata,
  248. }
  249. };
  250. static void __init em_x270_init_rtc(void)
  251. {
  252. platform_device_register(&em_x270_rtc);
  253. }
  254. #else
  255. static inline void em_x270_init_rtc(void) {}
  256. #endif
  257. /* NAND flash */
  258. #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  259. static inline void nand_cs_on(void)
  260. {
  261. gpio_set_value(GPIO11_NAND_CS, 0);
  262. }
  263. static void nand_cs_off(void)
  264. {
  265. dsb();
  266. gpio_set_value(GPIO11_NAND_CS, 1);
  267. }
  268. /* hardware specific access to control-lines */
  269. static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
  270. unsigned int ctrl)
  271. {
  272. struct nand_chip *this = mtd->priv;
  273. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  274. dsb();
  275. if (ctrl & NAND_CTRL_CHANGE) {
  276. if (ctrl & NAND_ALE)
  277. nandaddr |= (1 << 3);
  278. else
  279. nandaddr &= ~(1 << 3);
  280. if (ctrl & NAND_CLE)
  281. nandaddr |= (1 << 2);
  282. else
  283. nandaddr &= ~(1 << 2);
  284. if (ctrl & NAND_NCE)
  285. nand_cs_on();
  286. else
  287. nand_cs_off();
  288. }
  289. dsb();
  290. this->IO_ADDR_W = (void __iomem *)nandaddr;
  291. if (dat != NAND_CMD_NONE)
  292. writel(dat, this->IO_ADDR_W);
  293. dsb();
  294. }
  295. /* read device ready pin */
  296. static int em_x270_nand_device_ready(struct mtd_info *mtd)
  297. {
  298. dsb();
  299. return gpio_get_value(nand_rb);
  300. }
  301. static struct mtd_partition em_x270_partition_info[] = {
  302. [0] = {
  303. .name = "em_x270-0",
  304. .offset = 0,
  305. .size = SZ_4M,
  306. },
  307. [1] = {
  308. .name = "em_x270-1",
  309. .offset = MTDPART_OFS_APPEND,
  310. .size = MTDPART_SIZ_FULL
  311. },
  312. };
  313. static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
  314. struct platform_nand_data em_x270_nand_platdata = {
  315. .chip = {
  316. .nr_chips = 1,
  317. .chip_offset = 0,
  318. .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
  319. .partitions = em_x270_partition_info,
  320. .chip_delay = 20,
  321. .part_probe_types = em_x270_part_probes,
  322. },
  323. .ctrl = {
  324. .hwcontrol = 0,
  325. .dev_ready = em_x270_nand_device_ready,
  326. .select_chip = 0,
  327. .cmd_ctrl = em_x270_nand_cmd_ctl,
  328. },
  329. };
  330. static struct resource em_x270_nand_resource[] = {
  331. [0] = {
  332. .start = PXA_CS1_PHYS,
  333. .end = PXA_CS1_PHYS + 12,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. };
  337. static struct platform_device em_x270_nand = {
  338. .name = "gen_nand",
  339. .num_resources = ARRAY_SIZE(em_x270_nand_resource),
  340. .resource = em_x270_nand_resource,
  341. .id = -1,
  342. .dev = {
  343. .platform_data = &em_x270_nand_platdata,
  344. }
  345. };
  346. static void __init em_x270_init_nand(void)
  347. {
  348. int err;
  349. err = gpio_request(GPIO11_NAND_CS, "NAND CS");
  350. if (err) {
  351. pr_warning("EM-X270: failed to request NAND CS gpio\n");
  352. return;
  353. }
  354. gpio_direction_output(GPIO11_NAND_CS, 1);
  355. err = gpio_request(nand_rb, "NAND R/B");
  356. if (err) {
  357. pr_warning("EM-X270: failed to request NAND R/B gpio\n");
  358. gpio_free(GPIO11_NAND_CS);
  359. return;
  360. }
  361. gpio_direction_input(nand_rb);
  362. platform_device_register(&em_x270_nand);
  363. }
  364. #else
  365. static inline void em_x270_init_nand(void) {}
  366. #endif
  367. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  368. static struct mtd_partition em_x270_nor_parts[] = {
  369. {
  370. .name = "Bootloader",
  371. .offset = 0x00000000,
  372. .size = 0x00050000,
  373. .mask_flags = MTD_WRITEABLE /* force read-only */
  374. }, {
  375. .name = "Environment",
  376. .offset = 0x00050000,
  377. .size = 0x00010000,
  378. }, {
  379. .name = "Reserved",
  380. .offset = 0x00060000,
  381. .size = 0x00050000,
  382. .mask_flags = MTD_WRITEABLE /* force read-only */
  383. }, {
  384. .name = "Splashscreen",
  385. .offset = 0x000b0000,
  386. .size = 0x00050000,
  387. }
  388. };
  389. static struct physmap_flash_data em_x270_nor_data[] = {
  390. [0] = {
  391. .width = 2,
  392. .parts = em_x270_nor_parts,
  393. .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
  394. },
  395. };
  396. static struct resource em_x270_nor_flash_resource = {
  397. .start = PXA_CS0_PHYS,
  398. .end = PXA_CS0_PHYS + SZ_1M - 1,
  399. .flags = IORESOURCE_MEM,
  400. };
  401. static struct platform_device em_x270_physmap_flash = {
  402. .name = "physmap-flash",
  403. .id = 0,
  404. .num_resources = 1,
  405. .resource = &em_x270_nor_flash_resource,
  406. .dev = {
  407. .platform_data = &em_x270_nor_data,
  408. },
  409. };
  410. static void __init em_x270_init_nor(void)
  411. {
  412. platform_device_register(&em_x270_physmap_flash);
  413. }
  414. #else
  415. static inline void em_x270_init_nor(void) {}
  416. #endif
  417. /* PXA27x OHCI controller setup */
  418. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  419. static struct regulator *em_x270_usb_ldo;
  420. static int em_x270_usb_hub_init(void)
  421. {
  422. int err;
  423. em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
  424. if (IS_ERR(em_x270_usb_ldo))
  425. return PTR_ERR(em_x270_usb_ldo);
  426. err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
  427. if (err)
  428. goto err_free_usb_ldo;
  429. err = gpio_request(usb_hub_reset, "hub rst");
  430. if (err)
  431. goto err_free_vbus_gpio;
  432. /* USB Hub power-on and reset */
  433. gpio_direction_output(usb_hub_reset, 0);
  434. regulator_enable(em_x270_usb_ldo);
  435. gpio_set_value(usb_hub_reset, 1);
  436. gpio_set_value(usb_hub_reset, 0);
  437. regulator_disable(em_x270_usb_ldo);
  438. regulator_enable(em_x270_usb_ldo);
  439. gpio_set_value(usb_hub_reset, 1);
  440. /* enable VBUS */
  441. gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
  442. return 0;
  443. err_free_vbus_gpio:
  444. gpio_free(GPIO9_USB_VBUS_EN);
  445. err_free_usb_ldo:
  446. regulator_put(em_x270_usb_ldo);
  447. return err;
  448. }
  449. static int em_x270_ohci_init(struct device *dev)
  450. {
  451. int err;
  452. /* we don't want to entirely disable USB if the HUB init failed */
  453. err = em_x270_usb_hub_init();
  454. if (err)
  455. pr_err("USB Hub initialization failed: %d\n", err);
  456. /* enable port 2 transiever */
  457. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
  458. return 0;
  459. }
  460. static void em_x270_ohci_exit(struct device *dev)
  461. {
  462. gpio_free(usb_hub_reset);
  463. gpio_free(GPIO9_USB_VBUS_EN);
  464. if (!IS_ERR(em_x270_usb_ldo)) {
  465. if (regulator_is_enabled(em_x270_usb_ldo))
  466. regulator_disable(em_x270_usb_ldo);
  467. regulator_put(em_x270_usb_ldo);
  468. }
  469. }
  470. static struct pxaohci_platform_data em_x270_ohci_platform_data = {
  471. .port_mode = PMM_PERPORT_MODE,
  472. .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
  473. .init = em_x270_ohci_init,
  474. .exit = em_x270_ohci_exit,
  475. };
  476. static void __init em_x270_init_ohci(void)
  477. {
  478. pxa_set_ohci_info(&em_x270_ohci_platform_data);
  479. }
  480. #else
  481. static inline void em_x270_init_ohci(void) {}
  482. #endif
  483. /* MCI controller setup */
  484. #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
  485. static struct regulator *em_x270_sdio_ldo;
  486. static int em_x270_mci_init(struct device *dev,
  487. irq_handler_t em_x270_detect_int,
  488. void *data)
  489. {
  490. int err;
  491. em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
  492. if (IS_ERR(em_x270_sdio_ldo)) {
  493. dev_err(dev, "can't request SDIO power supply: %ld\n",
  494. PTR_ERR(em_x270_sdio_ldo));
  495. return PTR_ERR(em_x270_sdio_ldo);
  496. }
  497. err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
  498. IRQF_DISABLED | IRQF_TRIGGER_RISING |
  499. IRQF_TRIGGER_FALLING,
  500. "MMC card detect", data);
  501. if (err) {
  502. dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
  503. goto err_irq;
  504. }
  505. if (machine_is_em_x270()) {
  506. err = gpio_request(GPIO95_MMC_WP, "MMC WP");
  507. if (err) {
  508. dev_err(dev, "can't request MMC write protect: %d\n",
  509. err);
  510. goto err_gpio_wp;
  511. }
  512. gpio_direction_input(GPIO95_MMC_WP);
  513. } else {
  514. err = gpio_request(GPIO38_SD_PWEN, "sdio power");
  515. if (err) {
  516. dev_err(dev, "can't request MMC power control : %d\n",
  517. err);
  518. goto err_gpio_wp;
  519. }
  520. gpio_direction_output(GPIO38_SD_PWEN, 1);
  521. }
  522. return 0;
  523. err_gpio_wp:
  524. free_irq(gpio_to_irq(mmc_cd), data);
  525. err_irq:
  526. regulator_put(em_x270_sdio_ldo);
  527. return err;
  528. }
  529. static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
  530. {
  531. struct pxamci_platform_data* p_d = dev->platform_data;
  532. if ((1 << vdd) & p_d->ocr_mask) {
  533. int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
  534. regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
  535. regulator_enable(em_x270_sdio_ldo);
  536. } else {
  537. regulator_disable(em_x270_sdio_ldo);
  538. }
  539. }
  540. static void em_x270_mci_exit(struct device *dev, void *data)
  541. {
  542. free_irq(gpio_to_irq(mmc_cd), data);
  543. regulator_put(em_x270_sdio_ldo);
  544. if (machine_is_em_x270())
  545. gpio_free(GPIO95_MMC_WP);
  546. else
  547. gpio_free(GPIO38_SD_PWEN);
  548. }
  549. static int em_x270_mci_get_ro(struct device *dev)
  550. {
  551. return gpio_get_value(GPIO95_MMC_WP);
  552. }
  553. static struct pxamci_platform_data em_x270_mci_platform_data = {
  554. .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
  555. MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
  556. MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
  557. MMC_VDD_30_31|MMC_VDD_31_32,
  558. .init = em_x270_mci_init,
  559. .setpower = em_x270_mci_setpower,
  560. .exit = em_x270_mci_exit,
  561. .gpio_card_detect = -1,
  562. .gpio_card_ro = -1,
  563. .gpio_power = -1,
  564. };
  565. static void __init em_x270_init_mmc(void)
  566. {
  567. if (machine_is_em_x270())
  568. em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
  569. em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  570. pxa_set_mci_info(&em_x270_mci_platform_data);
  571. }
  572. #else
  573. static inline void em_x270_init_mmc(void) {}
  574. #endif
  575. /* LCD */
  576. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  577. static struct pxafb_mode_info em_x270_lcd_modes[] = {
  578. [0] = {
  579. .pixclock = 38250,
  580. .bpp = 16,
  581. .xres = 480,
  582. .yres = 640,
  583. .hsync_len = 8,
  584. .vsync_len = 2,
  585. .left_margin = 8,
  586. .upper_margin = 2,
  587. .right_margin = 24,
  588. .lower_margin = 4,
  589. .sync = 0,
  590. },
  591. [1] = {
  592. .pixclock = 153800,
  593. .bpp = 16,
  594. .xres = 240,
  595. .yres = 320,
  596. .hsync_len = 8,
  597. .vsync_len = 2,
  598. .left_margin = 8,
  599. .upper_margin = 2,
  600. .right_margin = 88,
  601. .lower_margin = 2,
  602. .sync = 0,
  603. },
  604. };
  605. static struct pxafb_mach_info em_x270_lcd = {
  606. .modes = em_x270_lcd_modes,
  607. .num_modes = 2,
  608. .lcd_conn = LCD_COLOR_TFT_16BPP,
  609. };
  610. static void __init em_x270_init_lcd(void)
  611. {
  612. set_pxa_fb_info(&em_x270_lcd);
  613. }
  614. #else
  615. static inline void em_x270_init_lcd(void) {}
  616. #endif
  617. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  618. static struct pxa2xx_spi_master em_x270_spi_info = {
  619. .num_chipselect = 1,
  620. };
  621. static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
  622. .rx_threshold = 1,
  623. .tx_threshold = 1,
  624. .gpio_cs = -1,
  625. };
  626. static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
  627. .model = TDO35S,
  628. };
  629. static struct pxa2xx_spi_master em_x270_spi_2_info = {
  630. .num_chipselect = 1,
  631. .enable_dma = 1,
  632. };
  633. static struct pxa2xx_spi_chip em_x270_libertas_chip = {
  634. .rx_threshold = 1,
  635. .tx_threshold = 1,
  636. .timeout = 1000,
  637. .gpio_cs = 14,
  638. };
  639. static unsigned long em_x270_libertas_pin_config[] = {
  640. /* SSP2 */
  641. GPIO19_SSP2_SCLK,
  642. GPIO14_GPIO,
  643. GPIO89_SSP2_TXD,
  644. GPIO88_SSP2_RXD,
  645. };
  646. static int em_x270_libertas_setup(struct spi_device *spi)
  647. {
  648. int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
  649. if (err)
  650. return err;
  651. err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
  652. if (err)
  653. goto err_free_pwen;
  654. if (machine_is_exeda()) {
  655. err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
  656. if (err)
  657. goto err_free_strap;
  658. gpio_direction_output(GPIO37_WLAN_RST, 1);
  659. msleep(100);
  660. }
  661. gpio_direction_output(GPIO19_WLAN_STRAP, 1);
  662. msleep(100);
  663. pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
  664. gpio_direction_output(GPIO115_WLAN_PWEN, 0);
  665. msleep(100);
  666. gpio_set_value(GPIO115_WLAN_PWEN, 1);
  667. msleep(100);
  668. spi->bits_per_word = 16;
  669. spi_setup(spi);
  670. return 0;
  671. err_free_strap:
  672. gpio_free(GPIO19_WLAN_STRAP);
  673. err_free_pwen:
  674. gpio_free(GPIO115_WLAN_PWEN);
  675. return err;
  676. }
  677. static int em_x270_libertas_teardown(struct spi_device *spi)
  678. {
  679. gpio_set_value(GPIO115_WLAN_PWEN, 0);
  680. gpio_free(GPIO115_WLAN_PWEN);
  681. gpio_free(GPIO19_WLAN_STRAP);
  682. if (machine_is_exeda()) {
  683. gpio_set_value(GPIO37_WLAN_RST, 0);
  684. gpio_free(GPIO37_WLAN_RST);
  685. }
  686. return 0;
  687. }
  688. struct libertas_spi_platform_data em_x270_libertas_pdata = {
  689. .use_dummy_writes = 1,
  690. .setup = em_x270_libertas_setup,
  691. .teardown = em_x270_libertas_teardown,
  692. };
  693. static struct spi_board_info em_x270_spi_devices[] __initdata = {
  694. {
  695. .modalias = "tdo24m",
  696. .max_speed_hz = 1000000,
  697. .bus_num = 1,
  698. .chip_select = 0,
  699. .controller_data = &em_x270_tdo24m_chip,
  700. .platform_data = &em_x270_tdo24m_pdata,
  701. },
  702. {
  703. .modalias = "libertas_spi",
  704. .max_speed_hz = 13000000,
  705. .bus_num = 2,
  706. .irq = IRQ_GPIO(116),
  707. .chip_select = 0,
  708. .controller_data = &em_x270_libertas_chip,
  709. .platform_data = &em_x270_libertas_pdata,
  710. },
  711. };
  712. static void __init em_x270_init_spi(void)
  713. {
  714. pxa2xx_set_spi_info(1, &em_x270_spi_info);
  715. pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
  716. spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
  717. }
  718. #else
  719. static inline void em_x270_init_spi(void) {}
  720. #endif
  721. #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
  722. static pxa2xx_audio_ops_t em_x270_ac97_info = {
  723. .reset_gpio = 113,
  724. };
  725. static void __init em_x270_init_ac97(void)
  726. {
  727. pxa_set_ac97_info(&em_x270_ac97_info);
  728. }
  729. #else
  730. static inline void em_x270_init_ac97(void) {}
  731. #endif
  732. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  733. static unsigned int em_x270_module_matrix_keys[] = {
  734. KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
  735. KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
  736. KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
  737. };
  738. struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
  739. /* code map for the matrix keys */
  740. .matrix_key_rows = 3,
  741. .matrix_key_cols = 3,
  742. .matrix_key_map = em_x270_module_matrix_keys,
  743. .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
  744. };
  745. static unsigned int em_x270_exeda_matrix_keys[] = {
  746. KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
  747. KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
  748. KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
  749. KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
  750. KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
  751. KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
  752. KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
  753. KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
  754. KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
  755. KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
  756. KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
  757. KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
  758. KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
  759. KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
  760. KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
  761. KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
  762. KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
  763. KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
  764. KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
  765. KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
  766. KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
  767. KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
  768. KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
  769. KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
  770. KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
  771. KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
  772. KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
  773. KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
  774. KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
  775. KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
  776. KEY(7, 4, 0), KEY(7, 5, 0),
  777. KEY(7, 6, 0), KEY(7, 7, 0),
  778. };
  779. struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
  780. /* code map for the matrix keys */
  781. .matrix_key_rows = 8,
  782. .matrix_key_cols = 8,
  783. .matrix_key_map = em_x270_exeda_matrix_keys,
  784. .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
  785. };
  786. static void __init em_x270_init_keypad(void)
  787. {
  788. if (machine_is_em_x270())
  789. pxa_set_keypad_info(&em_x270_module_keypad_info);
  790. else
  791. pxa_set_keypad_info(&em_x270_exeda_keypad_info);
  792. }
  793. #else
  794. static inline void em_x270_init_keypad(void) {}
  795. #endif
  796. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  797. static struct gpio_keys_button gpio_keys_button[] = {
  798. [0] = {
  799. .desc = "sleep/wakeup",
  800. .code = KEY_SUSPEND,
  801. .type = EV_PWR,
  802. .gpio = 1,
  803. .wakeup = 1,
  804. },
  805. };
  806. static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
  807. .buttons = gpio_keys_button,
  808. .nbuttons = 1,
  809. };
  810. static struct platform_device em_x270_gpio_keys = {
  811. .name = "gpio-keys",
  812. .id = -1,
  813. .dev = {
  814. .platform_data = &em_x270_gpio_keys_data,
  815. },
  816. };
  817. static void __init em_x270_init_gpio_keys(void)
  818. {
  819. platform_device_register(&em_x270_gpio_keys);
  820. }
  821. #else
  822. static inline void em_x270_init_gpio_keys(void) {}
  823. #endif
  824. /* Quick Capture Interface and sensor setup */
  825. #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
  826. static struct regulator *em_x270_camera_ldo;
  827. static int em_x270_sensor_init(struct device *dev)
  828. {
  829. int ret;
  830. ret = gpio_request(cam_reset, "camera reset");
  831. if (ret)
  832. return ret;
  833. gpio_direction_output(cam_reset, 0);
  834. em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
  835. if (em_x270_camera_ldo == NULL) {
  836. gpio_free(cam_reset);
  837. return -ENODEV;
  838. }
  839. ret = regulator_enable(em_x270_camera_ldo);
  840. if (ret) {
  841. regulator_put(em_x270_camera_ldo);
  842. gpio_free(cam_reset);
  843. return ret;
  844. }
  845. gpio_set_value(cam_reset, 1);
  846. return 0;
  847. }
  848. struct pxacamera_platform_data em_x270_camera_platform_data = {
  849. .init = em_x270_sensor_init,
  850. .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
  851. PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
  852. .mclk_10khz = 2600,
  853. };
  854. static int em_x270_sensor_power(struct device *dev, int on)
  855. {
  856. int ret;
  857. int is_on = regulator_is_enabled(em_x270_camera_ldo);
  858. if (on == is_on)
  859. return 0;
  860. gpio_set_value(cam_reset, !on);
  861. if (on)
  862. ret = regulator_enable(em_x270_camera_ldo);
  863. else
  864. ret = regulator_disable(em_x270_camera_ldo);
  865. if (ret)
  866. return ret;
  867. gpio_set_value(cam_reset, on);
  868. return 0;
  869. }
  870. static struct i2c_board_info em_x270_i2c_cam_info[] = {
  871. {
  872. I2C_BOARD_INFO("mt9m111", 0x48),
  873. },
  874. };
  875. static struct soc_camera_link iclink = {
  876. .bus_id = 0,
  877. .power = em_x270_sensor_power,
  878. .board_info = &em_x270_i2c_cam_info[0],
  879. .i2c_adapter_id = 0,
  880. .module_name = "mt9m111",
  881. };
  882. static struct platform_device em_x270_camera = {
  883. .name = "soc-camera-pdrv",
  884. .id = -1,
  885. .dev = {
  886. .platform_data = &iclink,
  887. },
  888. };
  889. static void __init em_x270_init_camera(void)
  890. {
  891. pxa_set_camera_info(&em_x270_camera_platform_data);
  892. platform_device_register(&em_x270_camera);
  893. }
  894. #else
  895. static inline void em_x270_init_camera(void) {}
  896. #endif
  897. static struct regulator_bulk_data em_x270_gps_consumer_supply = {
  898. .supply = "vcc gps",
  899. };
  900. static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
  901. .name = "vcc gps",
  902. .num_supplies = 1,
  903. .supplies = &em_x270_gps_consumer_supply,
  904. };
  905. static struct platform_device em_x270_gps_userspace_consumer = {
  906. .name = "reg-userspace-consumer",
  907. .id = 0,
  908. .dev = {
  909. .platform_data = &em_x270_gps_consumer_data,
  910. },
  911. };
  912. static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
  913. .supply = "vcc gprs",
  914. };
  915. static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
  916. .name = "vcc gprs",
  917. .num_supplies = 1,
  918. .supplies = &em_x270_gprs_consumer_supply
  919. };
  920. static struct platform_device em_x270_gprs_userspace_consumer = {
  921. .name = "reg-userspace-consumer",
  922. .id = 1,
  923. .dev = {
  924. .platform_data = &em_x270_gprs_consumer_data,
  925. }
  926. };
  927. static struct platform_device *em_x270_userspace_consumers[] = {
  928. &em_x270_gps_userspace_consumer,
  929. &em_x270_gprs_userspace_consumer,
  930. };
  931. static void __init em_x270_userspace_consumers_init(void)
  932. {
  933. platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
  934. }
  935. /* DA9030 related initializations */
  936. #define REGULATOR_CONSUMER(_name, _dev, _supply) \
  937. static struct regulator_consumer_supply _name##_consumers[] = { \
  938. { \
  939. .dev = _dev, \
  940. .supply = _supply, \
  941. }, \
  942. }
  943. REGULATOR_CONSUMER(ldo3, &em_x270_gps_userspace_consumer.dev, "vcc gps");
  944. REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
  945. REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
  946. REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
  947. REGULATOR_CONSUMER(ldo19, &em_x270_gprs_userspace_consumer.dev, "vcc gprs");
  948. REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
  949. #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
  950. static struct regulator_init_data _ldo##_data = { \
  951. .constraints = { \
  952. .min_uV = _min_uV, \
  953. .max_uV = _max_uV, \
  954. .state_mem = { \
  955. .enabled = 0, \
  956. }, \
  957. .valid_ops_mask = _ops_mask, \
  958. .apply_uV = 1, \
  959. }, \
  960. .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
  961. .consumer_supplies = _ldo##_consumers, \
  962. };
  963. REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
  964. REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
  965. REGULATOR_INIT(ldo10, 2000000, 3200000,
  966. REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
  967. REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
  968. REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
  969. REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
  970. struct led_info em_x270_led_info = {
  971. .name = "em-x270:orange",
  972. .default_trigger = "battery-charging-or-full",
  973. };
  974. struct power_supply_info em_x270_psy_info = {
  975. .name = "battery",
  976. .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
  977. .voltage_max_design = 4200000,
  978. .voltage_min_design = 3000000,
  979. .use_for_apm = 1,
  980. };
  981. static void em_x270_battery_low(void)
  982. {
  983. #if defined(CONFIG_APM_EMULATION)
  984. apm_queue_event(APM_LOW_BATTERY);
  985. #endif
  986. }
  987. static void em_x270_battery_critical(void)
  988. {
  989. #if defined(CONFIG_APM_EMULATION)
  990. apm_queue_event(APM_CRITICAL_SUSPEND);
  991. #endif
  992. }
  993. struct da9030_battery_info em_x270_batterty_info = {
  994. .battery_info = &em_x270_psy_info,
  995. .charge_milliamp = 1000,
  996. .charge_millivolt = 4200,
  997. .vbat_low = 3600,
  998. .vbat_crit = 3400,
  999. .vbat_charge_start = 4100,
  1000. .vbat_charge_stop = 4200,
  1001. .vbat_charge_restart = 4000,
  1002. .vcharge_min = 3200,
  1003. .vcharge_max = 5500,
  1004. .tbat_low = 197,
  1005. .tbat_high = 78,
  1006. .tbat_restart = 100,
  1007. .batmon_interval = 0,
  1008. .battery_low = em_x270_battery_low,
  1009. .battery_critical = em_x270_battery_critical,
  1010. };
  1011. #define DA9030_SUBDEV(_name, _id, _pdata) \
  1012. { \
  1013. .name = "da903x-" #_name, \
  1014. .id = DA9030_ID_##_id, \
  1015. .platform_data = _pdata, \
  1016. }
  1017. #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
  1018. struct da903x_subdev_info em_x270_da9030_subdevs[] = {
  1019. DA9030_LDO(3),
  1020. DA9030_LDO(5),
  1021. DA9030_LDO(10),
  1022. DA9030_LDO(12),
  1023. DA9030_LDO(19),
  1024. DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
  1025. DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
  1026. DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
  1027. DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
  1028. };
  1029. static struct da903x_platform_data em_x270_da9030_info = {
  1030. .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
  1031. .subdevs = em_x270_da9030_subdevs,
  1032. };
  1033. static struct i2c_board_info em_x270_i2c_pmic_info = {
  1034. I2C_BOARD_INFO("da9030", 0x49),
  1035. .irq = IRQ_GPIO(0),
  1036. .platform_data = &em_x270_da9030_info,
  1037. };
  1038. static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
  1039. .use_pio = 1,
  1040. };
  1041. static void __init em_x270_init_da9030(void)
  1042. {
  1043. pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
  1044. i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
  1045. }
  1046. static struct pca953x_platform_data exeda_gpio_ext_pdata = {
  1047. .gpio_base = 128,
  1048. };
  1049. static struct i2c_board_info exeda_i2c_info[] = {
  1050. {
  1051. I2C_BOARD_INFO("pca9555", 0x21),
  1052. .platform_data = &exeda_gpio_ext_pdata,
  1053. },
  1054. };
  1055. static struct i2c_pxa_platform_data em_x270_i2c_info = {
  1056. .fast_mode = 1,
  1057. };
  1058. static void __init em_x270_init_i2c(void)
  1059. {
  1060. pxa_set_i2c_info(&em_x270_i2c_info);
  1061. if (machine_is_exeda())
  1062. i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
  1063. }
  1064. static void __init em_x270_module_init(void)
  1065. {
  1066. pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
  1067. mmc_cd = GPIO13_MMC_CD;
  1068. nand_rb = GPIO56_NAND_RB;
  1069. dm9000_flags = DM9000_PLATF_32BITONLY;
  1070. cam_reset = GPIO93_CAM_RESET;
  1071. usb_hub_reset = GPIO16_USB_HUB_RESET;
  1072. }
  1073. static void __init em_x270_exeda_init(void)
  1074. {
  1075. pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
  1076. mmc_cd = GPIO114_MMC_CD;
  1077. nand_rb = GPIO20_NAND_RB;
  1078. dm9000_flags = DM9000_PLATF_16BITONLY;
  1079. cam_reset = GPIO130_CAM_RESET;
  1080. usb_hub_reset = GPIO10_USB_HUB_RESET;
  1081. }
  1082. static void __init em_x270_init(void)
  1083. {
  1084. pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
  1085. #ifdef CONFIG_PM
  1086. pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
  1087. #endif
  1088. if (machine_is_em_x270())
  1089. em_x270_module_init();
  1090. else if (machine_is_exeda())
  1091. em_x270_exeda_init();
  1092. else
  1093. panic("Unsupported machine: %d\n", machine_arch_type);
  1094. em_x270_init_da9030();
  1095. em_x270_init_dm9000();
  1096. em_x270_init_rtc();
  1097. em_x270_init_nand();
  1098. em_x270_init_nor();
  1099. em_x270_init_lcd();
  1100. em_x270_init_mmc();
  1101. em_x270_init_ohci();
  1102. em_x270_init_keypad();
  1103. em_x270_init_gpio_keys();
  1104. em_x270_init_ac97();
  1105. em_x270_init_spi();
  1106. em_x270_init_i2c();
  1107. em_x270_init_camera();
  1108. em_x270_userspace_consumers_init();
  1109. }
  1110. MACHINE_START(EM_X270, "Compulab EM-X270")
  1111. .boot_params = 0xa0000100,
  1112. .phys_io = 0x40000000,
  1113. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  1114. .map_io = pxa_map_io,
  1115. .init_irq = pxa27x_init_irq,
  1116. .timer = &pxa_timer,
  1117. .init_machine = em_x270_init,
  1118. MACHINE_END
  1119. MACHINE_START(EXEDA, "Compulab eXeda")
  1120. .boot_params = 0xa0000100,
  1121. .phys_io = 0x40000000,
  1122. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  1123. .map_io = pxa_map_io,
  1124. .init_irq = pxa27x_init_irq,
  1125. .timer = &pxa_timer,
  1126. .init_machine = em_x270_init,
  1127. MACHINE_END