em-x270.c 26 KB

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