em-x270.c 24 KB

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