em-x270.c 24 KB

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