raumfeld.c 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  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/i2c/pxa-i2c.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/spi_gpio.h>
  37. #include <linux/lis3lv02d.h>
  38. #include <linux/pda_power.h>
  39. #include <linux/power_supply.h>
  40. #include <linux/regulator/max8660.h>
  41. #include <linux/regulator/machine.h>
  42. #include <linux/regulator/fixed.h>
  43. #include <linux/regulator/consumer.h>
  44. #include <linux/delay.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/mach/arch.h>
  47. #include <mach/hardware.h>
  48. #include <mach/pxa3xx-regs.h>
  49. #include <mach/mfp-pxa3xx.h>
  50. #include <mach/mfp-pxa300.h>
  51. #include <mach/ohci.h>
  52. #include <mach/pxafb.h>
  53. #include <mach/mmc.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. #ifdef CONFIG_PXA3XX_GCU
  522. .acceleration_enabled = 1,
  523. #endif
  524. };
  525. static void __init raumfeld_lcd_init(void)
  526. {
  527. int ret;
  528. set_pxa_fb_info(&raumfeld_sharp_lcd_info);
  529. /* Earlier devices had the backlight regulator controlled
  530. * via PWM, later versions use another controller for that */
  531. if ((system_rev & 0xff) < 2) {
  532. mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT;
  533. pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1);
  534. platform_device_register(&raumfeld_pwm_backlight_device);
  535. } else
  536. platform_device_register(&raumfeld_lt3593_device);
  537. ret = gpio_request(GPIO_TFT_VA_EN, "display VA enable");
  538. if (ret < 0)
  539. pr_warning("Unable to request GPIO_TFT_VA_EN\n");
  540. else
  541. gpio_direction_output(GPIO_TFT_VA_EN, 1);
  542. ret = gpio_request(GPIO_DISPLAY_ENABLE, "display enable");
  543. if (ret < 0)
  544. pr_warning("Unable to request GPIO_DISPLAY_ENABLE\n");
  545. else
  546. gpio_direction_output(GPIO_DISPLAY_ENABLE, 1);
  547. platform_device_register(&pxa3xx_device_gcu);
  548. }
  549. /**
  550. * SPI devices
  551. */
  552. struct spi_gpio_platform_data raumfeld_spi_platform_data = {
  553. .sck = GPIO_SPI_CLK,
  554. .mosi = GPIO_SPI_MOSI,
  555. .miso = GPIO_SPI_MISO,
  556. .num_chipselect = 3,
  557. };
  558. static struct platform_device raumfeld_spi_device = {
  559. .name = "spi_gpio",
  560. .id = 0,
  561. .dev = {
  562. .platform_data = &raumfeld_spi_platform_data,
  563. }
  564. };
  565. static struct lis3lv02d_platform_data lis3_pdata = {
  566. .click_flags = LIS3_CLICK_SINGLE_X |
  567. LIS3_CLICK_SINGLE_Y |
  568. LIS3_CLICK_SINGLE_Z,
  569. .irq_cfg = LIS3_IRQ1_CLICK | LIS3_IRQ2_CLICK,
  570. .wakeup_flags = LIS3_WAKEUP_X_LO | LIS3_WAKEUP_X_HI |
  571. LIS3_WAKEUP_Y_LO | LIS3_WAKEUP_Y_HI |
  572. LIS3_WAKEUP_Z_LO | LIS3_WAKEUP_Z_HI,
  573. .wakeup_thresh = 10,
  574. .click_thresh_x = 10,
  575. .click_thresh_y = 10,
  576. .click_thresh_z = 10,
  577. };
  578. #define SPI_AK4104 \
  579. { \
  580. .modalias = "ak4104", \
  581. .max_speed_hz = 10000, \
  582. .bus_num = 0, \
  583. .chip_select = 0, \
  584. .controller_data = (void *) GPIO_SPDIF_CS, \
  585. }
  586. #define SPI_LIS3 \
  587. { \
  588. .modalias = "lis3lv02d_spi", \
  589. .max_speed_hz = 1000000, \
  590. .bus_num = 0, \
  591. .chip_select = 1, \
  592. .controller_data = (void *) GPIO_ACCEL_CS, \
  593. .platform_data = &lis3_pdata, \
  594. .irq = gpio_to_irq(GPIO_ACCEL_IRQ), \
  595. }
  596. #define SPI_DAC7512 \
  597. { \
  598. .modalias = "dac7512", \
  599. .max_speed_hz = 1000000, \
  600. .bus_num = 0, \
  601. .chip_select = 2, \
  602. .controller_data = (void *) GPIO_MCLK_DAC_CS, \
  603. }
  604. static struct spi_board_info connector_spi_devices[] __initdata = {
  605. SPI_AK4104,
  606. SPI_DAC7512,
  607. };
  608. static struct spi_board_info speaker_spi_devices[] __initdata = {
  609. SPI_DAC7512,
  610. };
  611. static struct spi_board_info controller_spi_devices[] __initdata = {
  612. SPI_LIS3,
  613. };
  614. /**
  615. * MMC for Marvell Libertas 8688 via SDIO
  616. */
  617. static int raumfeld_mci_init(struct device *dev, irq_handler_t isr, void *data)
  618. {
  619. gpio_set_value(GPIO_W2W_RESET, 1);
  620. gpio_set_value(GPIO_W2W_PDN, 1);
  621. return 0;
  622. }
  623. static void raumfeld_mci_exit(struct device *dev, void *data)
  624. {
  625. gpio_set_value(GPIO_W2W_RESET, 0);
  626. gpio_set_value(GPIO_W2W_PDN, 0);
  627. }
  628. static struct pxamci_platform_data raumfeld_mci_platform_data = {
  629. .init = raumfeld_mci_init,
  630. .exit = raumfeld_mci_exit,
  631. .detect_delay_ms = 200,
  632. .gpio_card_detect = -1,
  633. .gpio_card_ro = -1,
  634. .gpio_power = -1,
  635. };
  636. /*
  637. * External power / charge logic
  638. */
  639. static int power_supply_init(struct device *dev)
  640. {
  641. return 0;
  642. }
  643. static void power_supply_exit(struct device *dev)
  644. {
  645. }
  646. static int raumfeld_is_ac_online(void)
  647. {
  648. return !gpio_get_value(GPIO_CHARGE_DC_OK);
  649. }
  650. static int raumfeld_is_usb_online(void)
  651. {
  652. return 0;
  653. }
  654. static char *raumfeld_power_supplicants[] = { "ds2760-battery.0" };
  655. static void raumfeld_power_signal_charged(void)
  656. {
  657. struct power_supply *psy =
  658. power_supply_get_by_name(raumfeld_power_supplicants[0]);
  659. if (psy)
  660. power_supply_set_battery_charged(psy);
  661. }
  662. static int raumfeld_power_resume(void)
  663. {
  664. /* check if GPIO_CHARGE_DONE went low while we were sleeping */
  665. if (!gpio_get_value(GPIO_CHARGE_DONE))
  666. raumfeld_power_signal_charged();
  667. return 0;
  668. }
  669. static struct pda_power_pdata power_supply_info = {
  670. .init = power_supply_init,
  671. .is_ac_online = raumfeld_is_ac_online,
  672. .is_usb_online = raumfeld_is_usb_online,
  673. .exit = power_supply_exit,
  674. .supplied_to = raumfeld_power_supplicants,
  675. .num_supplicants = ARRAY_SIZE(raumfeld_power_supplicants),
  676. .resume = raumfeld_power_resume,
  677. };
  678. static struct resource power_supply_resources[] = {
  679. {
  680. .name = "ac",
  681. .flags = IORESOURCE_IRQ |
  682. IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
  683. .start = GPIO_CHARGE_DC_OK,
  684. .end = GPIO_CHARGE_DC_OK,
  685. },
  686. };
  687. static irqreturn_t charge_done_irq(int irq, void *dev_id)
  688. {
  689. raumfeld_power_signal_charged();
  690. return IRQ_HANDLED;
  691. }
  692. static struct platform_device raumfeld_power_supply = {
  693. .name = "pda-power",
  694. .id = -1,
  695. .dev = {
  696. .platform_data = &power_supply_info,
  697. },
  698. .resource = power_supply_resources,
  699. .num_resources = ARRAY_SIZE(power_supply_resources),
  700. };
  701. static void __init raumfeld_power_init(void)
  702. {
  703. int ret;
  704. /* Set PEN2 high to enable maximum charge current */
  705. ret = gpio_request(GPIO_CHRG_PEN2, "CHRG_PEN2");
  706. if (ret < 0)
  707. pr_warning("Unable to request GPIO_CHRG_PEN2\n");
  708. else
  709. gpio_direction_output(GPIO_CHRG_PEN2, 1);
  710. ret = gpio_request(GPIO_CHARGE_DC_OK, "CABLE_DC_OK");
  711. if (ret < 0)
  712. pr_warning("Unable to request GPIO_CHARGE_DC_OK\n");
  713. ret = gpio_request(GPIO_CHARGE_USB_SUSP, "CHARGE_USB_SUSP");
  714. if (ret < 0)
  715. pr_warning("Unable to request GPIO_CHARGE_USB_SUSP\n");
  716. else
  717. gpio_direction_output(GPIO_CHARGE_USB_SUSP, 0);
  718. power_supply_resources[0].start = gpio_to_irq(GPIO_CHARGE_DC_OK);
  719. power_supply_resources[0].end = gpio_to_irq(GPIO_CHARGE_DC_OK);
  720. ret = request_irq(gpio_to_irq(GPIO_CHARGE_DONE),
  721. &charge_done_irq, IORESOURCE_IRQ_LOWEDGE,
  722. "charge_done", NULL);
  723. if (ret < 0)
  724. printk(KERN_ERR "%s: unable to register irq %d\n", __func__,
  725. GPIO_CHARGE_DONE);
  726. else
  727. platform_device_register(&raumfeld_power_supply);
  728. }
  729. /* Fixed regulator for AUDIO_VA, 0-0048 maps to the cs4270 codec device */
  730. static struct regulator_consumer_supply audio_va_consumer_supply =
  731. REGULATOR_SUPPLY("va", "0-0048");
  732. struct regulator_init_data audio_va_initdata = {
  733. .consumer_supplies = &audio_va_consumer_supply,
  734. .num_consumer_supplies = 1,
  735. .constraints = {
  736. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  737. },
  738. };
  739. static struct fixed_voltage_config audio_va_config = {
  740. .supply_name = "audio_va",
  741. .microvolts = 5000000,
  742. .gpio = GPIO_AUDIO_VA_ENABLE,
  743. .enable_high = 1,
  744. .enabled_at_boot = 0,
  745. .init_data = &audio_va_initdata,
  746. };
  747. static struct platform_device audio_va_device = {
  748. .name = "reg-fixed-voltage",
  749. .id = 0,
  750. .dev = {
  751. .platform_data = &audio_va_config,
  752. },
  753. };
  754. /* Dummy supplies for Codec's VD/VLC */
  755. static struct regulator_consumer_supply audio_dummy_supplies[] = {
  756. REGULATOR_SUPPLY("vd", "0-0048"),
  757. REGULATOR_SUPPLY("vlc", "0-0048"),
  758. };
  759. struct regulator_init_data audio_dummy_initdata = {
  760. .consumer_supplies = audio_dummy_supplies,
  761. .num_consumer_supplies = ARRAY_SIZE(audio_dummy_supplies),
  762. .constraints = {
  763. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  764. },
  765. };
  766. static struct fixed_voltage_config audio_dummy_config = {
  767. .supply_name = "audio_vd",
  768. .microvolts = 3300000,
  769. .gpio = -1,
  770. .init_data = &audio_dummy_initdata,
  771. };
  772. static struct platform_device audio_supply_dummy_device = {
  773. .name = "reg-fixed-voltage",
  774. .id = 1,
  775. .dev = {
  776. .platform_data = &audio_dummy_config,
  777. },
  778. };
  779. static struct platform_device *audio_regulator_devices[] = {
  780. &audio_va_device,
  781. &audio_supply_dummy_device,
  782. };
  783. /**
  784. * Regulator support via MAX8660
  785. */
  786. static struct regulator_consumer_supply vcc_mmc_supply =
  787. REGULATOR_SUPPLY("vmmc", "pxa2xx-mci.0");
  788. static struct regulator_init_data vcc_mmc_init_data = {
  789. .constraints = {
  790. .min_uV = 3300000,
  791. .max_uV = 3300000,
  792. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  793. .valid_ops_mask = REGULATOR_CHANGE_STATUS |
  794. REGULATOR_CHANGE_VOLTAGE |
  795. REGULATOR_CHANGE_MODE,
  796. },
  797. .consumer_supplies = &vcc_mmc_supply,
  798. .num_consumer_supplies = 1,
  799. };
  800. struct max8660_subdev_data max8660_v6_subdev_data = {
  801. .id = MAX8660_V6,
  802. .name = "vmmc",
  803. .platform_data = &vcc_mmc_init_data,
  804. };
  805. static struct max8660_platform_data max8660_pdata = {
  806. .subdevs = &max8660_v6_subdev_data,
  807. .num_subdevs = 1,
  808. };
  809. /**
  810. * I2C devices
  811. */
  812. static struct i2c_board_info raumfeld_pwri2c_board_info = {
  813. .type = "max8660",
  814. .addr = 0x34,
  815. .platform_data = &max8660_pdata,
  816. };
  817. static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
  818. .type = "cs4270",
  819. .addr = 0x48,
  820. };
  821. static struct eeti_ts_platform_data eeti_ts_pdata = {
  822. .irq_active_high = 1,
  823. };
  824. static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
  825. .type = "eeti_ts",
  826. .addr = 0x0a,
  827. .irq = gpio_to_irq(GPIO_TOUCH_IRQ),
  828. .platform_data = &eeti_ts_pdata,
  829. };
  830. static struct platform_device *raumfeld_common_devices[] = {
  831. &raumfeld_gpio_keys_device,
  832. &raumfeld_led_device,
  833. &raumfeld_spi_device,
  834. };
  835. static void __init raumfeld_audio_init(void)
  836. {
  837. int ret;
  838. ret = gpio_request(GPIO_CODEC_RESET, "cs4270 reset");
  839. if (ret < 0)
  840. pr_warning("unable to request GPIO_CODEC_RESET\n");
  841. else
  842. gpio_direction_output(GPIO_CODEC_RESET, 1);
  843. ret = gpio_request(GPIO_SPDIF_RESET, "ak4104 s/pdif reset");
  844. if (ret < 0)
  845. pr_warning("unable to request GPIO_SPDIF_RESET\n");
  846. else
  847. gpio_direction_output(GPIO_SPDIF_RESET, 1);
  848. ret = gpio_request(GPIO_MCLK_RESET, "MCLK reset");
  849. if (ret < 0)
  850. pr_warning("unable to request GPIO_MCLK_RESET\n");
  851. else
  852. gpio_direction_output(GPIO_MCLK_RESET, 1);
  853. platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
  854. }
  855. static void __init raumfeld_common_init(void)
  856. {
  857. int ret;
  858. /* The on/off button polarity has changed after revision 1 */
  859. if ((system_rev & 0xff) > 1) {
  860. int i;
  861. for (i = 0; i < ARRAY_SIZE(gpio_keys_button); i++)
  862. if (!strcmp(gpio_keys_button[i].desc, "on_off button"))
  863. gpio_keys_button[i].active_low = 1;
  864. }
  865. enable_irq_wake(IRQ_WAKEUP0);
  866. pxa3xx_set_nand_info(&raumfeld_nand_info);
  867. pxa3xx_set_i2c_power_info(NULL);
  868. pxa_set_ohci_info(&raumfeld_ohci_info);
  869. pxa_set_mci_info(&raumfeld_mci_platform_data);
  870. pxa_set_i2c_info(NULL);
  871. pxa_set_ffuart_info(NULL);
  872. ret = gpio_request(GPIO_W2W_RESET, "Wi2Wi reset");
  873. if (ret < 0)
  874. pr_warning("Unable to request GPIO_W2W_RESET\n");
  875. else
  876. gpio_direction_output(GPIO_W2W_RESET, 0);
  877. ret = gpio_request(GPIO_W2W_PDN, "Wi2Wi powerup");
  878. if (ret < 0)
  879. pr_warning("Unable to request GPIO_W2W_PDN\n");
  880. else
  881. gpio_direction_output(GPIO_W2W_PDN, 0);
  882. /* this can be used to switch off the device */
  883. ret = gpio_request(GPIO_SHUTDOWN_SUPPLY, "supply shutdown");
  884. if (ret < 0)
  885. pr_warning("Unable to request GPIO_SHUTDOWN_SUPPLY\n");
  886. else
  887. gpio_direction_output(GPIO_SHUTDOWN_SUPPLY, 0);
  888. platform_add_devices(ARRAY_AND_SIZE(raumfeld_common_devices));
  889. i2c_register_board_info(1, &raumfeld_pwri2c_board_info, 1);
  890. }
  891. static void __init raumfeld_controller_init(void)
  892. {
  893. int ret;
  894. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config));
  895. platform_device_register(&rotary_encoder_device);
  896. spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices));
  897. i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
  898. ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
  899. if (ret < 0)
  900. pr_warning("Unable to request GPIO_SHUTDOWN_BATT\n");
  901. else
  902. gpio_direction_output(GPIO_SHUTDOWN_BATT, 0);
  903. raumfeld_common_init();
  904. raumfeld_power_init();
  905. raumfeld_lcd_init();
  906. raumfeld_w1_init();
  907. }
  908. static void __init raumfeld_connector_init(void)
  909. {
  910. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_connector_pin_config));
  911. spi_register_board_info(ARRAY_AND_SIZE(connector_spi_devices));
  912. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  913. platform_device_register(&smc91x_device);
  914. raumfeld_audio_init();
  915. raumfeld_common_init();
  916. }
  917. static void __init raumfeld_speaker_init(void)
  918. {
  919. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_speaker_pin_config));
  920. spi_register_board_info(ARRAY_AND_SIZE(speaker_spi_devices));
  921. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  922. platform_device_register(&smc91x_device);
  923. platform_device_register(&rotary_encoder_device);
  924. raumfeld_audio_init();
  925. raumfeld_common_init();
  926. }
  927. /* physical memory regions */
  928. #define RAUMFELD_SDRAM_BASE 0xa0000000 /* SDRAM region */
  929. #ifdef CONFIG_MACH_RAUMFELD_RC
  930. MACHINE_START(RAUMFELD_RC, "Raumfeld Controller")
  931. .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
  932. .init_machine = raumfeld_controller_init,
  933. .map_io = pxa3xx_map_io,
  934. .init_irq = pxa3xx_init_irq,
  935. .timer = &pxa_timer,
  936. MACHINE_END
  937. #endif
  938. #ifdef CONFIG_MACH_RAUMFELD_CONNECTOR
  939. MACHINE_START(RAUMFELD_CONNECTOR, "Raumfeld Connector")
  940. .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
  941. .init_machine = raumfeld_connector_init,
  942. .map_io = pxa3xx_map_io,
  943. .init_irq = pxa3xx_init_irq,
  944. .timer = &pxa_timer,
  945. MACHINE_END
  946. #endif
  947. #ifdef CONFIG_MACH_RAUMFELD_SPEAKER
  948. MACHINE_START(RAUMFELD_SPEAKER, "Raumfeld Speaker")
  949. .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
  950. .init_machine = raumfeld_speaker_init,
  951. .map_io = pxa3xx_map_io,
  952. .init_irq = pxa3xx_init_irq,
  953. .timer = &pxa_timer,
  954. MACHINE_END
  955. #endif