raumfeld.c 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * arch/arm/mach-pxa/raumfeld.c
  3. *
  4. * Support for the following Raumfeld devices:
  5. *
  6. * * Controller
  7. * * Connector
  8. * * Speaker S/M
  9. *
  10. * See http://www.raumfeld.com for details.
  11. *
  12. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/gpio.h>
  23. #include <linux/smsc911x.h>
  24. #include <linux/input.h>
  25. #include <linux/rotary_encoder.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/input/eeti_ts.h>
  28. #include <linux/leds.h>
  29. #include <linux/w1-gpio.h>
  30. #include <linux/sched.h>
  31. #include <linux/pwm_backlight.h>
  32. #include <linux/i2c.h>
  33. #include <linux/i2c/pxa-i2c.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/spi_gpio.h>
  36. #include <linux/lis3lv02d.h>
  37. #include <linux/pda_power.h>
  38. #include <linux/power_supply.h>
  39. #include <linux/regulator/max8660.h>
  40. #include <linux/regulator/machine.h>
  41. #include <linux/regulator/fixed.h>
  42. #include <linux/regulator/consumer.h>
  43. #include <linux/delay.h>
  44. #include <asm/system_info.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/mach/arch.h>
  47. #include <mach/pxa300.h>
  48. #include <linux/platform_data/usb-ohci-pxa27x.h>
  49. #include <linux/platform_data/video-pxafb.h>
  50. #include <linux/platform_data/mmc-pxamci.h>
  51. #include <linux/platform_data/mtd-nand-pxa3xx.h>
  52. #include "generic.h"
  53. #include "devices.h"
  54. /* common GPIO definitions */
  55. /* inputs */
  56. #define GPIO_ON_OFF (14)
  57. #define GPIO_VOLENC_A (19)
  58. #define GPIO_VOLENC_B (20)
  59. #define GPIO_CHARGE_DONE (23)
  60. #define GPIO_CHARGE_IND (27)
  61. #define GPIO_TOUCH_IRQ (32)
  62. #define GPIO_ETH_IRQ (40)
  63. #define GPIO_SPI_MISO (98)
  64. #define GPIO_ACCEL_IRQ (104)
  65. #define GPIO_RESCUE_BOOT (115)
  66. #define GPIO_DOCK_DETECT (116)
  67. #define GPIO_KEY1 (117)
  68. #define GPIO_KEY2 (118)
  69. #define GPIO_KEY3 (119)
  70. #define GPIO_CHARGE_USB_OK (112)
  71. #define GPIO_CHARGE_DC_OK (101)
  72. #define GPIO_CHARGE_USB_SUSP (102)
  73. /* outputs */
  74. #define GPIO_SHUTDOWN_SUPPLY (16)
  75. #define GPIO_SHUTDOWN_BATT (18)
  76. #define GPIO_CHRG_PEN2 (31)
  77. #define GPIO_TFT_VA_EN (33)
  78. #define GPIO_SPDIF_CS (34)
  79. #define GPIO_LED2 (35)
  80. #define GPIO_LED1 (36)
  81. #define GPIO_SPDIF_RESET (38)
  82. #define GPIO_SPI_CLK (95)
  83. #define GPIO_MCLK_DAC_CS (96)
  84. #define GPIO_SPI_MOSI (97)
  85. #define GPIO_W1_PULLUP_ENABLE (105)
  86. #define GPIO_DISPLAY_ENABLE (106)
  87. #define GPIO_MCLK_RESET (111)
  88. #define GPIO_W2W_RESET (113)
  89. #define GPIO_W2W_PDN (114)
  90. #define GPIO_CODEC_RESET (120)
  91. #define GPIO_AUDIO_VA_ENABLE (124)
  92. #define GPIO_ACCEL_CS (125)
  93. #define GPIO_ONE_WIRE (126)
  94. /*
  95. * GPIO configurations
  96. */
  97. static mfp_cfg_t raumfeld_controller_pin_config[] __initdata = {
  98. /* UART1 */
  99. GPIO77_UART1_RXD,
  100. GPIO78_UART1_TXD,
  101. GPIO79_UART1_CTS,
  102. GPIO81_UART1_DSR,
  103. GPIO83_UART1_DTR,
  104. GPIO84_UART1_RTS,
  105. /* UART3 */
  106. GPIO110_UART3_RXD,
  107. /* USB Host */
  108. GPIO0_2_USBH_PEN,
  109. GPIO1_2_USBH_PWR,
  110. /* I2C */
  111. GPIO21_I2C_SCL | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  112. GPIO22_I2C_SDA | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  113. /* SPI */
  114. GPIO34_GPIO, /* SPDIF_CS */
  115. GPIO96_GPIO, /* MCLK_CS */
  116. GPIO125_GPIO, /* ACCEL_CS */
  117. /* MMC */
  118. GPIO3_MMC1_DAT0,
  119. GPIO4_MMC1_DAT1,
  120. GPIO5_MMC1_DAT2,
  121. GPIO6_MMC1_DAT3,
  122. GPIO7_MMC1_CLK,
  123. GPIO8_MMC1_CMD,
  124. /* One-wire */
  125. GPIO126_GPIO | MFP_LPM_FLOAT,
  126. GPIO105_GPIO | MFP_PULL_LOW | MFP_LPM_PULL_LOW,
  127. /* CHRG_USB_OK */
  128. GPIO101_GPIO | MFP_PULL_HIGH,
  129. /* CHRG_USB_OK */
  130. GPIO112_GPIO | MFP_PULL_HIGH,
  131. /* CHRG_USB_SUSP */
  132. GPIO102_GPIO,
  133. /* DISPLAY_ENABLE */
  134. GPIO106_GPIO,
  135. /* DOCK_DETECT */
  136. GPIO116_GPIO | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  137. /* LCD */
  138. GPIO54_LCD_LDD_0,
  139. GPIO55_LCD_LDD_1,
  140. GPIO56_LCD_LDD_2,
  141. GPIO57_LCD_LDD_3,
  142. GPIO58_LCD_LDD_4,
  143. GPIO59_LCD_LDD_5,
  144. GPIO60_LCD_LDD_6,
  145. GPIO61_LCD_LDD_7,
  146. GPIO62_LCD_LDD_8,
  147. GPIO63_LCD_LDD_9,
  148. GPIO64_LCD_LDD_10,
  149. GPIO65_LCD_LDD_11,
  150. GPIO66_LCD_LDD_12,
  151. GPIO67_LCD_LDD_13,
  152. GPIO68_LCD_LDD_14,
  153. GPIO69_LCD_LDD_15,
  154. GPIO70_LCD_LDD_16,
  155. GPIO71_LCD_LDD_17,
  156. GPIO72_LCD_FCLK,
  157. GPIO73_LCD_LCLK,
  158. GPIO74_LCD_PCLK,
  159. GPIO75_LCD_BIAS,
  160. };
  161. static mfp_cfg_t raumfeld_connector_pin_config[] __initdata = {
  162. /* UART1 */
  163. GPIO77_UART1_RXD,
  164. GPIO78_UART1_TXD,
  165. GPIO79_UART1_CTS,
  166. GPIO81_UART1_DSR,
  167. GPIO83_UART1_DTR,
  168. GPIO84_UART1_RTS,
  169. /* UART3 */
  170. GPIO110_UART3_RXD,
  171. /* USB Host */
  172. GPIO0_2_USBH_PEN,
  173. GPIO1_2_USBH_PWR,
  174. /* I2C */
  175. GPIO21_I2C_SCL | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  176. GPIO22_I2C_SDA | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  177. /* SPI */
  178. GPIO34_GPIO, /* SPDIF_CS */
  179. GPIO96_GPIO, /* MCLK_CS */
  180. GPIO125_GPIO, /* ACCEL_CS */
  181. /* MMC */
  182. GPIO3_MMC1_DAT0,
  183. GPIO4_MMC1_DAT1,
  184. GPIO5_MMC1_DAT2,
  185. GPIO6_MMC1_DAT3,
  186. GPIO7_MMC1_CLK,
  187. GPIO8_MMC1_CMD,
  188. /* Ethernet */
  189. GPIO1_nCS2, /* CS */
  190. GPIO40_GPIO | MFP_PULL_HIGH, /* IRQ */
  191. /* SSP for I2S */
  192. GPIO85_SSP1_SCLK,
  193. GPIO89_SSP1_EXTCLK,
  194. GPIO86_SSP1_FRM,
  195. GPIO87_SSP1_TXD,
  196. GPIO88_SSP1_RXD,
  197. GPIO90_SSP1_SYSCLK,
  198. /* SSP2 for S/PDIF */
  199. GPIO25_SSP2_SCLK,
  200. GPIO26_SSP2_FRM,
  201. GPIO27_SSP2_TXD,
  202. GPIO29_SSP2_EXTCLK,
  203. /* LEDs */
  204. GPIO35_GPIO | MFP_LPM_PULL_LOW,
  205. GPIO36_GPIO | MFP_LPM_DRIVE_HIGH,
  206. };
  207. static mfp_cfg_t raumfeld_speaker_pin_config[] __initdata = {
  208. /* UART1 */
  209. GPIO77_UART1_RXD,
  210. GPIO78_UART1_TXD,
  211. GPIO79_UART1_CTS,
  212. GPIO81_UART1_DSR,
  213. GPIO83_UART1_DTR,
  214. GPIO84_UART1_RTS,
  215. /* UART3 */
  216. GPIO110_UART3_RXD,
  217. /* USB Host */
  218. GPIO0_2_USBH_PEN,
  219. GPIO1_2_USBH_PWR,
  220. /* I2C */
  221. GPIO21_I2C_SCL | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  222. GPIO22_I2C_SDA | MFP_LPM_FLOAT | MFP_PULL_FLOAT,
  223. /* SPI */
  224. GPIO34_GPIO, /* SPDIF_CS */
  225. GPIO96_GPIO, /* MCLK_CS */
  226. GPIO125_GPIO, /* ACCEL_CS */
  227. /* MMC */
  228. GPIO3_MMC1_DAT0,
  229. GPIO4_MMC1_DAT1,
  230. GPIO5_MMC1_DAT2,
  231. GPIO6_MMC1_DAT3,
  232. GPIO7_MMC1_CLK,
  233. GPIO8_MMC1_CMD,
  234. /* Ethernet */
  235. GPIO1_nCS2, /* CS */
  236. GPIO40_GPIO | MFP_PULL_HIGH, /* IRQ */
  237. /* SSP for I2S */
  238. GPIO85_SSP1_SCLK,
  239. GPIO89_SSP1_EXTCLK,
  240. GPIO86_SSP1_FRM,
  241. GPIO87_SSP1_TXD,
  242. GPIO88_SSP1_RXD,
  243. GPIO90_SSP1_SYSCLK,
  244. /* LEDs */
  245. GPIO35_GPIO | MFP_LPM_PULL_LOW,
  246. GPIO36_GPIO | MFP_LPM_DRIVE_HIGH,
  247. };
  248. /*
  249. * SMSC LAN9220 Ethernet
  250. */
  251. static struct resource smc91x_resources[] = {
  252. {
  253. .start = PXA3xx_CS2_PHYS,
  254. .end = PXA3xx_CS2_PHYS + 0xfffff,
  255. .flags = IORESOURCE_MEM,
  256. },
  257. {
  258. .start = PXA_GPIO_TO_IRQ(GPIO_ETH_IRQ),
  259. .end = PXA_GPIO_TO_IRQ(GPIO_ETH_IRQ),
  260. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  261. }
  262. };
  263. static struct smsc911x_platform_config raumfeld_smsc911x_config = {
  264. .phy_interface = PHY_INTERFACE_MODE_MII,
  265. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  266. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  267. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  268. };
  269. static struct platform_device smc91x_device = {
  270. .name = "smsc911x",
  271. .id = -1,
  272. .num_resources = ARRAY_SIZE(smc91x_resources),
  273. .resource = smc91x_resources,
  274. .dev = {
  275. .platform_data = &raumfeld_smsc911x_config,
  276. }
  277. };
  278. /**
  279. * NAND
  280. */
  281. static struct mtd_partition raumfeld_nand_partitions[] = {
  282. {
  283. .name = "Bootloader",
  284. .offset = 0,
  285. .size = 0xa0000,
  286. .mask_flags = MTD_WRITEABLE, /* force read-only */
  287. },
  288. {
  289. .name = "BootloaderEnvironment",
  290. .offset = 0xa0000,
  291. .size = 0x20000,
  292. },
  293. {
  294. .name = "BootloaderSplashScreen",
  295. .offset = 0xc0000,
  296. .size = 0x60000,
  297. },
  298. {
  299. .name = "UBI",
  300. .offset = 0x120000,
  301. .size = MTDPART_SIZ_FULL,
  302. },
  303. };
  304. static struct pxa3xx_nand_platform_data raumfeld_nand_info = {
  305. .enable_arbiter = 1,
  306. .keep_config = 1,
  307. .num_cs = 1,
  308. .parts[0] = raumfeld_nand_partitions,
  309. .nr_parts[0] = ARRAY_SIZE(raumfeld_nand_partitions),
  310. };
  311. /**
  312. * USB (OHCI) support
  313. */
  314. static struct pxaohci_platform_data raumfeld_ohci_info = {
  315. .port_mode = PMM_GLOBAL_MODE,
  316. .flags = ENABLE_PORT1,
  317. };
  318. /**
  319. * Rotary encoder input device
  320. */
  321. static struct rotary_encoder_platform_data raumfeld_rotary_encoder_info = {
  322. .steps = 24,
  323. .axis = REL_X,
  324. .relative_axis = 1,
  325. .gpio_a = GPIO_VOLENC_A,
  326. .gpio_b = GPIO_VOLENC_B,
  327. .inverted_a = 1,
  328. .inverted_b = 0,
  329. };
  330. static struct platform_device rotary_encoder_device = {
  331. .name = "rotary-encoder",
  332. .id = 0,
  333. .dev = {
  334. .platform_data = &raumfeld_rotary_encoder_info,
  335. }
  336. };
  337. /**
  338. * GPIO buttons
  339. */
  340. static struct gpio_keys_button gpio_keys_button[] = {
  341. {
  342. .code = KEY_F1,
  343. .type = EV_KEY,
  344. .gpio = GPIO_KEY1,
  345. .active_low = 1,
  346. .wakeup = 0,
  347. .debounce_interval = 5, /* ms */
  348. .desc = "Button 1",
  349. },
  350. {
  351. .code = KEY_F2,
  352. .type = EV_KEY,
  353. .gpio = GPIO_KEY2,
  354. .active_low = 1,
  355. .wakeup = 0,
  356. .debounce_interval = 5, /* ms */
  357. .desc = "Button 2",
  358. },
  359. {
  360. .code = KEY_F3,
  361. .type = EV_KEY,
  362. .gpio = GPIO_KEY3,
  363. .active_low = 1,
  364. .wakeup = 0,
  365. .debounce_interval = 5, /* ms */
  366. .desc = "Button 3",
  367. },
  368. {
  369. .code = KEY_F4,
  370. .type = EV_KEY,
  371. .gpio = GPIO_RESCUE_BOOT,
  372. .active_low = 0,
  373. .wakeup = 0,
  374. .debounce_interval = 5, /* ms */
  375. .desc = "rescue boot button",
  376. },
  377. {
  378. .code = KEY_F5,
  379. .type = EV_KEY,
  380. .gpio = GPIO_DOCK_DETECT,
  381. .active_low = 1,
  382. .wakeup = 0,
  383. .debounce_interval = 5, /* ms */
  384. .desc = "dock detect",
  385. },
  386. {
  387. .code = KEY_F6,
  388. .type = EV_KEY,
  389. .gpio = GPIO_ON_OFF,
  390. .active_low = 0,
  391. .wakeup = 0,
  392. .debounce_interval = 5, /* ms */
  393. .desc = "on_off button",
  394. },
  395. };
  396. static struct gpio_keys_platform_data gpio_keys_platform_data = {
  397. .buttons = gpio_keys_button,
  398. .nbuttons = ARRAY_SIZE(gpio_keys_button),
  399. .rep = 0,
  400. };
  401. static struct platform_device raumfeld_gpio_keys_device = {
  402. .name = "gpio-keys",
  403. .id = -1,
  404. .dev = {
  405. .platform_data = &gpio_keys_platform_data,
  406. }
  407. };
  408. /**
  409. * GPIO LEDs
  410. */
  411. static struct gpio_led raumfeld_leds[] = {
  412. {
  413. .name = "raumfeld:1",
  414. .gpio = GPIO_LED1,
  415. .active_low = 1,
  416. .default_state = LEDS_GPIO_DEFSTATE_ON,
  417. },
  418. {
  419. .name = "raumfeld:2",
  420. .gpio = GPIO_LED2,
  421. .active_low = 0,
  422. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  423. }
  424. };
  425. static struct gpio_led_platform_data raumfeld_led_platform_data = {
  426. .leds = raumfeld_leds,
  427. .num_leds = ARRAY_SIZE(raumfeld_leds),
  428. };
  429. static struct platform_device raumfeld_led_device = {
  430. .name = "leds-gpio",
  431. .id = -1,
  432. .dev = {
  433. .platform_data = &raumfeld_led_platform_data,
  434. },
  435. };
  436. /**
  437. * One-wire (W1 bus) support
  438. */
  439. static void w1_enable_external_pullup(int enable)
  440. {
  441. gpio_set_value(GPIO_W1_PULLUP_ENABLE, enable);
  442. msleep(100);
  443. }
  444. static struct w1_gpio_platform_data w1_gpio_platform_data = {
  445. .pin = GPIO_ONE_WIRE,
  446. .is_open_drain = 0,
  447. .enable_external_pullup = w1_enable_external_pullup,
  448. .ext_pullup_enable_pin = -EINVAL,
  449. };
  450. struct platform_device raumfeld_w1_gpio_device = {
  451. .name = "w1-gpio",
  452. .dev = {
  453. .platform_data = &w1_gpio_platform_data
  454. }
  455. };
  456. static void __init raumfeld_w1_init(void)
  457. {
  458. int ret = gpio_request(GPIO_W1_PULLUP_ENABLE,
  459. "W1 external pullup enable");
  460. if (ret < 0)
  461. pr_warn("Unable to request GPIO_W1_PULLUP_ENABLE\n");
  462. else
  463. gpio_direction_output(GPIO_W1_PULLUP_ENABLE, 0);
  464. platform_device_register(&raumfeld_w1_gpio_device);
  465. }
  466. /**
  467. * Framebuffer device
  468. */
  469. /* PWM controlled backlight */
  470. static struct platform_pwm_backlight_data raumfeld_pwm_backlight_data = {
  471. .pwm_id = 0,
  472. .max_brightness = 100,
  473. .dft_brightness = 100,
  474. /* 10000 ns = 10 ms ^= 100 kHz */
  475. .pwm_period_ns = 10000,
  476. .enable_gpio = -1,
  477. };
  478. static struct platform_device raumfeld_pwm_backlight_device = {
  479. .name = "pwm-backlight",
  480. .dev = {
  481. .parent = &pxa27x_device_pwm0.dev,
  482. .platform_data = &raumfeld_pwm_backlight_data,
  483. }
  484. };
  485. /* LT3593 controlled backlight */
  486. static struct gpio_led raumfeld_lt3593_led = {
  487. .name = "backlight",
  488. .gpio = mfp_to_gpio(MFP_PIN_GPIO17),
  489. .default_state = LEDS_GPIO_DEFSTATE_ON,
  490. };
  491. static struct gpio_led_platform_data raumfeld_lt3593_platform_data = {
  492. .leds = &raumfeld_lt3593_led,
  493. .num_leds = 1,
  494. };
  495. static struct platform_device raumfeld_lt3593_device = {
  496. .name = "leds-lt3593",
  497. .id = -1,
  498. .dev = {
  499. .platform_data = &raumfeld_lt3593_platform_data,
  500. },
  501. };
  502. static struct pxafb_mode_info sharp_lq043t3dx02_mode = {
  503. .pixclock = 111000,
  504. .xres = 480,
  505. .yres = 272,
  506. .bpp = 16,
  507. .hsync_len = 41,
  508. .left_margin = 2,
  509. .right_margin = 1,
  510. .vsync_len = 10,
  511. .upper_margin = 3,
  512. .lower_margin = 1,
  513. .sync = 0,
  514. };
  515. static struct pxafb_mach_info raumfeld_sharp_lcd_info = {
  516. .modes = &sharp_lq043t3dx02_mode,
  517. .num_modes = 1,
  518. .video_mem_size = 0x400000,
  519. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  520. #ifdef CONFIG_PXA3XX_GCU
  521. .acceleration_enabled = 1,
  522. #endif
  523. };
  524. static void __init raumfeld_lcd_init(void)
  525. {
  526. int ret;
  527. ret = gpio_request(GPIO_TFT_VA_EN, "display VA enable");
  528. if (ret < 0)
  529. pr_warn("Unable to request GPIO_TFT_VA_EN\n");
  530. else
  531. gpio_direction_output(GPIO_TFT_VA_EN, 1);
  532. msleep(100);
  533. ret = gpio_request(GPIO_DISPLAY_ENABLE, "display enable");
  534. if (ret < 0)
  535. pr_warn("Unable to request GPIO_DISPLAY_ENABLE\n");
  536. else
  537. gpio_direction_output(GPIO_DISPLAY_ENABLE, 1);
  538. /* Hardware revision 2 has the backlight regulator controlled
  539. * by an LT3593, earlier and later devices use PWM for that. */
  540. if ((system_rev & 0xff) == 2) {
  541. platform_device_register(&raumfeld_lt3593_device);
  542. } else {
  543. mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT;
  544. pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1);
  545. platform_device_register(&raumfeld_pwm_backlight_device);
  546. }
  547. pxa_set_fb_info(NULL, &raumfeld_sharp_lcd_info);
  548. platform_device_register(&pxa3xx_device_gcu);
  549. }
  550. /**
  551. * SPI devices
  552. */
  553. struct spi_gpio_platform_data raumfeld_spi_platform_data = {
  554. .sck = GPIO_SPI_CLK,
  555. .mosi = GPIO_SPI_MOSI,
  556. .miso = GPIO_SPI_MISO,
  557. .num_chipselect = 3,
  558. };
  559. static struct platform_device raumfeld_spi_device = {
  560. .name = "spi_gpio",
  561. .id = 0,
  562. .dev = {
  563. .platform_data = &raumfeld_spi_platform_data,
  564. }
  565. };
  566. static struct lis3lv02d_platform_data lis3_pdata = {
  567. .click_flags = LIS3_CLICK_SINGLE_X |
  568. LIS3_CLICK_SINGLE_Y |
  569. LIS3_CLICK_SINGLE_Z,
  570. .irq_cfg = LIS3_IRQ1_CLICK | LIS3_IRQ2_CLICK,
  571. .wakeup_flags = LIS3_WAKEUP_X_LO | LIS3_WAKEUP_X_HI |
  572. LIS3_WAKEUP_Y_LO | LIS3_WAKEUP_Y_HI |
  573. LIS3_WAKEUP_Z_LO | LIS3_WAKEUP_Z_HI,
  574. .wakeup_thresh = 10,
  575. .click_thresh_x = 10,
  576. .click_thresh_y = 10,
  577. .click_thresh_z = 10,
  578. };
  579. #define SPI_AK4104 \
  580. { \
  581. .modalias = "ak4104-codec", \
  582. .max_speed_hz = 10000, \
  583. .bus_num = 0, \
  584. .chip_select = 0, \
  585. .controller_data = (void *) GPIO_SPDIF_CS, \
  586. }
  587. #define SPI_LIS3 \
  588. { \
  589. .modalias = "lis3lv02d_spi", \
  590. .max_speed_hz = 1000000, \
  591. .bus_num = 0, \
  592. .chip_select = 1, \
  593. .controller_data = (void *) GPIO_ACCEL_CS, \
  594. .platform_data = &lis3_pdata, \
  595. .irq = PXA_GPIO_TO_IRQ(GPIO_ACCEL_IRQ), \
  596. }
  597. #define SPI_DAC7512 \
  598. { \
  599. .modalias = "dac7512", \
  600. .max_speed_hz = 1000000, \
  601. .bus_num = 0, \
  602. .chip_select = 2, \
  603. .controller_data = (void *) GPIO_MCLK_DAC_CS, \
  604. }
  605. static struct spi_board_info connector_spi_devices[] __initdata = {
  606. SPI_AK4104,
  607. SPI_DAC7512,
  608. };
  609. static struct spi_board_info speaker_spi_devices[] __initdata = {
  610. SPI_DAC7512,
  611. };
  612. static struct spi_board_info controller_spi_devices[] __initdata = {
  613. SPI_LIS3,
  614. };
  615. /**
  616. * MMC for Marvell Libertas 8688 via SDIO
  617. */
  618. static int raumfeld_mci_init(struct device *dev, irq_handler_t isr, void *data)
  619. {
  620. gpio_set_value(GPIO_W2W_RESET, 1);
  621. gpio_set_value(GPIO_W2W_PDN, 1);
  622. return 0;
  623. }
  624. static void raumfeld_mci_exit(struct device *dev, void *data)
  625. {
  626. gpio_set_value(GPIO_W2W_RESET, 0);
  627. gpio_set_value(GPIO_W2W_PDN, 0);
  628. }
  629. static struct pxamci_platform_data raumfeld_mci_platform_data = {
  630. .init = raumfeld_mci_init,
  631. .exit = raumfeld_mci_exit,
  632. .detect_delay_ms = 200,
  633. .gpio_card_detect = -1,
  634. .gpio_card_ro = -1,
  635. .gpio_power = -1,
  636. };
  637. /*
  638. * External power / charge logic
  639. */
  640. static int power_supply_init(struct device *dev)
  641. {
  642. return 0;
  643. }
  644. static void power_supply_exit(struct device *dev)
  645. {
  646. }
  647. static int raumfeld_is_ac_online(void)
  648. {
  649. return !gpio_get_value(GPIO_CHARGE_DC_OK);
  650. }
  651. static int raumfeld_is_usb_online(void)
  652. {
  653. return 0;
  654. }
  655. static char *raumfeld_power_supplicants[] = { "ds2760-battery.0" };
  656. static void raumfeld_power_signal_charged(void)
  657. {
  658. struct power_supply *psy =
  659. power_supply_get_by_name(raumfeld_power_supplicants[0]);
  660. if (psy) {
  661. power_supply_set_battery_charged(psy);
  662. power_supply_put(psy);
  663. }
  664. }
  665. static int raumfeld_power_resume(void)
  666. {
  667. /* check if GPIO_CHARGE_DONE went low while we were sleeping */
  668. if (!gpio_get_value(GPIO_CHARGE_DONE))
  669. raumfeld_power_signal_charged();
  670. return 0;
  671. }
  672. static struct pda_power_pdata power_supply_info = {
  673. .init = power_supply_init,
  674. .is_ac_online = raumfeld_is_ac_online,
  675. .is_usb_online = raumfeld_is_usb_online,
  676. .exit = power_supply_exit,
  677. .supplied_to = raumfeld_power_supplicants,
  678. .num_supplicants = ARRAY_SIZE(raumfeld_power_supplicants),
  679. .resume = raumfeld_power_resume,
  680. };
  681. static struct resource power_supply_resources[] = {
  682. {
  683. .name = "ac",
  684. .flags = IORESOURCE_IRQ |
  685. IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
  686. .start = GPIO_CHARGE_DC_OK,
  687. .end = GPIO_CHARGE_DC_OK,
  688. },
  689. };
  690. static irqreturn_t charge_done_irq(int irq, void *dev_id)
  691. {
  692. raumfeld_power_signal_charged();
  693. return IRQ_HANDLED;
  694. }
  695. static struct platform_device raumfeld_power_supply = {
  696. .name = "pda-power",
  697. .id = -1,
  698. .dev = {
  699. .platform_data = &power_supply_info,
  700. },
  701. .resource = power_supply_resources,
  702. .num_resources = ARRAY_SIZE(power_supply_resources),
  703. };
  704. static void __init raumfeld_power_init(void)
  705. {
  706. int ret;
  707. /* Set PEN2 high to enable maximum charge current */
  708. ret = gpio_request(GPIO_CHRG_PEN2, "CHRG_PEN2");
  709. if (ret < 0)
  710. pr_warn("Unable to request GPIO_CHRG_PEN2\n");
  711. else
  712. gpio_direction_output(GPIO_CHRG_PEN2, 1);
  713. ret = gpio_request(GPIO_CHARGE_DC_OK, "CABLE_DC_OK");
  714. if (ret < 0)
  715. pr_warn("Unable to request GPIO_CHARGE_DC_OK\n");
  716. ret = gpio_request(GPIO_CHARGE_USB_SUSP, "CHARGE_USB_SUSP");
  717. if (ret < 0)
  718. pr_warn("Unable to request GPIO_CHARGE_USB_SUSP\n");
  719. else
  720. gpio_direction_output(GPIO_CHARGE_USB_SUSP, 0);
  721. power_supply_resources[0].start = gpio_to_irq(GPIO_CHARGE_DC_OK);
  722. power_supply_resources[0].end = gpio_to_irq(GPIO_CHARGE_DC_OK);
  723. ret = request_irq(gpio_to_irq(GPIO_CHARGE_DONE),
  724. &charge_done_irq, IORESOURCE_IRQ_LOWEDGE,
  725. "charge_done", NULL);
  726. if (ret < 0)
  727. printk(KERN_ERR "%s: unable to register irq %d\n", __func__,
  728. GPIO_CHARGE_DONE);
  729. else
  730. platform_device_register(&raumfeld_power_supply);
  731. }
  732. /* Fixed regulator for AUDIO_VA, 0-0048 maps to the cs4270 codec device */
  733. static struct regulator_consumer_supply audio_va_consumer_supply =
  734. REGULATOR_SUPPLY("va", "0-0048");
  735. struct regulator_init_data audio_va_initdata = {
  736. .consumer_supplies = &audio_va_consumer_supply,
  737. .num_consumer_supplies = 1,
  738. .constraints = {
  739. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  740. },
  741. };
  742. static struct fixed_voltage_config audio_va_config = {
  743. .supply_name = "audio_va",
  744. .microvolts = 5000000,
  745. .gpio = GPIO_AUDIO_VA_ENABLE,
  746. .enable_high = 1,
  747. .enabled_at_boot = 0,
  748. .init_data = &audio_va_initdata,
  749. };
  750. static struct platform_device audio_va_device = {
  751. .name = "reg-fixed-voltage",
  752. .id = 0,
  753. .dev = {
  754. .platform_data = &audio_va_config,
  755. },
  756. };
  757. /* Dummy supplies for Codec's VD/VLC */
  758. static struct regulator_consumer_supply audio_dummy_supplies[] = {
  759. REGULATOR_SUPPLY("vd", "0-0048"),
  760. REGULATOR_SUPPLY("vlc", "0-0048"),
  761. };
  762. struct regulator_init_data audio_dummy_initdata = {
  763. .consumer_supplies = audio_dummy_supplies,
  764. .num_consumer_supplies = ARRAY_SIZE(audio_dummy_supplies),
  765. .constraints = {
  766. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  767. },
  768. };
  769. static struct fixed_voltage_config audio_dummy_config = {
  770. .supply_name = "audio_vd",
  771. .microvolts = 3300000,
  772. .gpio = -1,
  773. .init_data = &audio_dummy_initdata,
  774. };
  775. static struct platform_device audio_supply_dummy_device = {
  776. .name = "reg-fixed-voltage",
  777. .id = 1,
  778. .dev = {
  779. .platform_data = &audio_dummy_config,
  780. },
  781. };
  782. static struct platform_device *audio_regulator_devices[] = {
  783. &audio_va_device,
  784. &audio_supply_dummy_device,
  785. };
  786. /**
  787. * Regulator support via MAX8660
  788. */
  789. static struct regulator_consumer_supply vcc_mmc_supply =
  790. REGULATOR_SUPPLY("vmmc", "pxa2xx-mci.0");
  791. static struct regulator_init_data vcc_mmc_init_data = {
  792. .constraints = {
  793. .min_uV = 3300000,
  794. .max_uV = 3300000,
  795. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  796. .valid_ops_mask = REGULATOR_CHANGE_STATUS |
  797. REGULATOR_CHANGE_VOLTAGE |
  798. REGULATOR_CHANGE_MODE,
  799. },
  800. .consumer_supplies = &vcc_mmc_supply,
  801. .num_consumer_supplies = 1,
  802. };
  803. struct max8660_subdev_data max8660_v6_subdev_data = {
  804. .id = MAX8660_V6,
  805. .name = "vmmc",
  806. .platform_data = &vcc_mmc_init_data,
  807. };
  808. static struct max8660_platform_data max8660_pdata = {
  809. .subdevs = &max8660_v6_subdev_data,
  810. .num_subdevs = 1,
  811. };
  812. /**
  813. * I2C devices
  814. */
  815. static struct i2c_board_info raumfeld_pwri2c_board_info = {
  816. .type = "max8660",
  817. .addr = 0x34,
  818. .platform_data = &max8660_pdata,
  819. };
  820. static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
  821. .type = "cs4270",
  822. .addr = 0x48,
  823. };
  824. static struct eeti_ts_platform_data eeti_ts_pdata = {
  825. .irq_active_high = 1,
  826. .irq_gpio = GPIO_TOUCH_IRQ,
  827. };
  828. static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
  829. .type = "eeti_ts",
  830. .addr = 0x0a,
  831. .platform_data = &eeti_ts_pdata,
  832. };
  833. static struct platform_device *raumfeld_common_devices[] = {
  834. &raumfeld_gpio_keys_device,
  835. &raumfeld_led_device,
  836. &raumfeld_spi_device,
  837. };
  838. static void __init raumfeld_audio_init(void)
  839. {
  840. int ret;
  841. ret = gpio_request(GPIO_CODEC_RESET, "cs4270 reset");
  842. if (ret < 0)
  843. pr_warn("unable to request GPIO_CODEC_RESET\n");
  844. else
  845. gpio_direction_output(GPIO_CODEC_RESET, 1);
  846. ret = gpio_request(GPIO_SPDIF_RESET, "ak4104 s/pdif reset");
  847. if (ret < 0)
  848. pr_warn("unable to request GPIO_SPDIF_RESET\n");
  849. else
  850. gpio_direction_output(GPIO_SPDIF_RESET, 1);
  851. ret = gpio_request(GPIO_MCLK_RESET, "MCLK reset");
  852. if (ret < 0)
  853. pr_warn("unable to request GPIO_MCLK_RESET\n");
  854. else
  855. gpio_direction_output(GPIO_MCLK_RESET, 1);
  856. platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
  857. }
  858. static void __init raumfeld_common_init(void)
  859. {
  860. int ret;
  861. /* The on/off button polarity has changed after revision 1 */
  862. if ((system_rev & 0xff) > 1) {
  863. int i;
  864. for (i = 0; i < ARRAY_SIZE(gpio_keys_button); i++)
  865. if (!strcmp(gpio_keys_button[i].desc, "on_off button"))
  866. gpio_keys_button[i].active_low = 1;
  867. }
  868. enable_irq_wake(IRQ_WAKEUP0);
  869. pxa3xx_set_nand_info(&raumfeld_nand_info);
  870. pxa3xx_set_i2c_power_info(NULL);
  871. pxa_set_ohci_info(&raumfeld_ohci_info);
  872. pxa_set_mci_info(&raumfeld_mci_platform_data);
  873. pxa_set_i2c_info(NULL);
  874. pxa_set_ffuart_info(NULL);
  875. ret = gpio_request(GPIO_W2W_RESET, "Wi2Wi reset");
  876. if (ret < 0)
  877. pr_warn("Unable to request GPIO_W2W_RESET\n");
  878. else
  879. gpio_direction_output(GPIO_W2W_RESET, 0);
  880. ret = gpio_request(GPIO_W2W_PDN, "Wi2Wi powerup");
  881. if (ret < 0)
  882. pr_warn("Unable to request GPIO_W2W_PDN\n");
  883. else
  884. gpio_direction_output(GPIO_W2W_PDN, 0);
  885. /* this can be used to switch off the device */
  886. ret = gpio_request(GPIO_SHUTDOWN_SUPPLY, "supply shutdown");
  887. if (ret < 0)
  888. pr_warn("Unable to request GPIO_SHUTDOWN_SUPPLY\n");
  889. else
  890. gpio_direction_output(GPIO_SHUTDOWN_SUPPLY, 0);
  891. platform_add_devices(ARRAY_AND_SIZE(raumfeld_common_devices));
  892. i2c_register_board_info(1, &raumfeld_pwri2c_board_info, 1);
  893. }
  894. static void __init raumfeld_controller_init(void)
  895. {
  896. int ret;
  897. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config));
  898. platform_device_register(&rotary_encoder_device);
  899. spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices));
  900. i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
  901. ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
  902. if (ret < 0)
  903. pr_warn("Unable to request GPIO_SHUTDOWN_BATT\n");
  904. else
  905. gpio_direction_output(GPIO_SHUTDOWN_BATT, 0);
  906. raumfeld_common_init();
  907. raumfeld_power_init();
  908. raumfeld_lcd_init();
  909. raumfeld_w1_init();
  910. }
  911. static void __init raumfeld_connector_init(void)
  912. {
  913. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_connector_pin_config));
  914. spi_register_board_info(ARRAY_AND_SIZE(connector_spi_devices));
  915. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  916. platform_device_register(&smc91x_device);
  917. raumfeld_audio_init();
  918. raumfeld_common_init();
  919. }
  920. static void __init raumfeld_speaker_init(void)
  921. {
  922. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_speaker_pin_config));
  923. spi_register_board_info(ARRAY_AND_SIZE(speaker_spi_devices));
  924. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  925. platform_device_register(&smc91x_device);
  926. platform_device_register(&rotary_encoder_device);
  927. raumfeld_audio_init();
  928. raumfeld_common_init();
  929. }
  930. /* physical memory regions */
  931. #define RAUMFELD_SDRAM_BASE 0xa0000000 /* SDRAM region */
  932. #ifdef CONFIG_MACH_RAUMFELD_RC
  933. MACHINE_START(RAUMFELD_RC, "Raumfeld Controller")
  934. .atag_offset = 0x100,
  935. .init_machine = raumfeld_controller_init,
  936. .map_io = pxa3xx_map_io,
  937. .nr_irqs = PXA_NR_IRQS,
  938. .init_irq = pxa3xx_init_irq,
  939. .handle_irq = pxa3xx_handle_irq,
  940. .init_time = pxa_timer_init,
  941. .restart = pxa_restart,
  942. MACHINE_END
  943. #endif
  944. #ifdef CONFIG_MACH_RAUMFELD_CONNECTOR
  945. MACHINE_START(RAUMFELD_CONNECTOR, "Raumfeld Connector")
  946. .atag_offset = 0x100,
  947. .init_machine = raumfeld_connector_init,
  948. .map_io = pxa3xx_map_io,
  949. .nr_irqs = PXA_NR_IRQS,
  950. .init_irq = pxa3xx_init_irq,
  951. .handle_irq = pxa3xx_handle_irq,
  952. .init_time = pxa_timer_init,
  953. .restart = pxa_restart,
  954. MACHINE_END
  955. #endif
  956. #ifdef CONFIG_MACH_RAUMFELD_SPEAKER
  957. MACHINE_START(RAUMFELD_SPEAKER, "Raumfeld Speaker")
  958. .atag_offset = 0x100,
  959. .init_machine = raumfeld_speaker_init,
  960. .map_io = pxa3xx_map_io,
  961. .nr_irqs = PXA_NR_IRQS,
  962. .init_irq = pxa3xx_init_irq,
  963. .handle_irq = pxa3xx_handle_irq,
  964. .init_time = pxa_timer_init,
  965. .restart = pxa_restart,
  966. MACHINE_END
  967. #endif