raumfeld.c 25 KB

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