em-x270.c 27 KB

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