em-x270.c 26 KB

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