em-x270.c 21 KB

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