raumfeld.c 25 KB

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