raumfeld.c 25 KB

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