raumfeld.c 24 KB

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