raumfeld.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  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/property.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/gpio.h>
  24. #include <linux/gpio/machine.h>
  25. #include <linux/smsc911x.h>
  26. #include <linux/input.h>
  27. #include <linux/gpio_keys.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 gpiod_lookup_table raumfeld_rotary_gpios_table = {
  323. .dev_id = "rotary-encoder.0",
  324. .table = {
  325. GPIO_LOOKUP_IDX("gpio-0",
  326. GPIO_VOLENC_A, NULL, 0, GPIO_ACTIVE_LOW),
  327. GPIO_LOOKUP_IDX("gpio-0",
  328. GPIO_VOLENC_B, NULL, 1, GPIO_ACTIVE_HIGH),
  329. { },
  330. },
  331. };
  332. static struct property_entry raumfeld_rotary_properties[] = {
  333. PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24),
  334. PROPERTY_ENTRY_INTEGER("linux,axis", u32, REL_X),
  335. PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis", u32, 1),
  336. { },
  337. };
  338. static struct platform_device rotary_encoder_device = {
  339. .name = "rotary-encoder",
  340. .id = 0,
  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. .ext_pullup_enable_pin = -EINVAL,
  454. };
  455. static struct platform_device raumfeld_w1_gpio_device = {
  456. .name = "w1-gpio",
  457. .dev = {
  458. .platform_data = &w1_gpio_platform_data
  459. }
  460. };
  461. static void __init raumfeld_w1_init(void)
  462. {
  463. int ret = gpio_request(GPIO_W1_PULLUP_ENABLE,
  464. "W1 external pullup enable");
  465. if (ret < 0)
  466. pr_warn("Unable to request GPIO_W1_PULLUP_ENABLE\n");
  467. else
  468. gpio_direction_output(GPIO_W1_PULLUP_ENABLE, 0);
  469. platform_device_register(&raumfeld_w1_gpio_device);
  470. }
  471. /**
  472. * Framebuffer device
  473. */
  474. static struct pwm_lookup raumfeld_pwm_lookup[] = {
  475. PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 10000,
  476. PWM_POLARITY_NORMAL),
  477. };
  478. /* PWM controlled backlight */
  479. static struct platform_pwm_backlight_data raumfeld_pwm_backlight_data = {
  480. .max_brightness = 100,
  481. .dft_brightness = 100,
  482. .enable_gpio = -1,
  483. };
  484. static struct platform_device raumfeld_pwm_backlight_device = {
  485. .name = "pwm-backlight",
  486. .dev = {
  487. .parent = &pxa27x_device_pwm0.dev,
  488. .platform_data = &raumfeld_pwm_backlight_data,
  489. }
  490. };
  491. /* LT3593 controlled backlight */
  492. static struct gpio_led raumfeld_lt3593_led = {
  493. .name = "backlight",
  494. .gpio = mfp_to_gpio(MFP_PIN_GPIO17),
  495. .default_state = LEDS_GPIO_DEFSTATE_ON,
  496. };
  497. static struct gpio_led_platform_data raumfeld_lt3593_platform_data = {
  498. .leds = &raumfeld_lt3593_led,
  499. .num_leds = 1,
  500. };
  501. static struct platform_device raumfeld_lt3593_device = {
  502. .name = "leds-lt3593",
  503. .id = -1,
  504. .dev = {
  505. .platform_data = &raumfeld_lt3593_platform_data,
  506. },
  507. };
  508. static struct pxafb_mode_info sharp_lq043t3dx02_mode = {
  509. .pixclock = 111000,
  510. .xres = 480,
  511. .yres = 272,
  512. .bpp = 16,
  513. .hsync_len = 41,
  514. .left_margin = 2,
  515. .right_margin = 1,
  516. .vsync_len = 10,
  517. .upper_margin = 3,
  518. .lower_margin = 1,
  519. .sync = 0,
  520. };
  521. static struct pxafb_mach_info raumfeld_sharp_lcd_info = {
  522. .modes = &sharp_lq043t3dx02_mode,
  523. .num_modes = 1,
  524. .video_mem_size = 0x400000,
  525. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  526. #ifdef CONFIG_PXA3XX_GCU
  527. .acceleration_enabled = 1,
  528. #endif
  529. };
  530. static void __init raumfeld_lcd_init(void)
  531. {
  532. int ret;
  533. ret = gpio_request(GPIO_TFT_VA_EN, "display VA enable");
  534. if (ret < 0)
  535. pr_warn("Unable to request GPIO_TFT_VA_EN\n");
  536. else
  537. gpio_direction_output(GPIO_TFT_VA_EN, 1);
  538. msleep(100);
  539. ret = gpio_request(GPIO_DISPLAY_ENABLE, "display enable");
  540. if (ret < 0)
  541. pr_warn("Unable to request GPIO_DISPLAY_ENABLE\n");
  542. else
  543. gpio_direction_output(GPIO_DISPLAY_ENABLE, 1);
  544. /* Hardware revision 2 has the backlight regulator controlled
  545. * by an LT3593, earlier and later devices use PWM for that. */
  546. if ((system_rev & 0xff) == 2) {
  547. platform_device_register(&raumfeld_lt3593_device);
  548. } else {
  549. mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT;
  550. pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1);
  551. pwm_add_table(raumfeld_pwm_lookup,
  552. ARRAY_SIZE(raumfeld_pwm_lookup));
  553. platform_device_register(&raumfeld_pwm_backlight_device);
  554. }
  555. pxa_set_fb_info(NULL, &raumfeld_sharp_lcd_info);
  556. platform_device_register(&pxa3xx_device_gcu);
  557. }
  558. /**
  559. * SPI devices
  560. */
  561. static struct spi_gpio_platform_data raumfeld_spi_platform_data = {
  562. .sck = GPIO_SPI_CLK,
  563. .mosi = GPIO_SPI_MOSI,
  564. .miso = GPIO_SPI_MISO,
  565. .num_chipselect = 3,
  566. };
  567. static struct platform_device raumfeld_spi_device = {
  568. .name = "spi_gpio",
  569. .id = 0,
  570. .dev = {
  571. .platform_data = &raumfeld_spi_platform_data,
  572. }
  573. };
  574. static struct lis3lv02d_platform_data lis3_pdata = {
  575. .click_flags = LIS3_CLICK_SINGLE_X |
  576. LIS3_CLICK_SINGLE_Y |
  577. LIS3_CLICK_SINGLE_Z,
  578. .irq_cfg = LIS3_IRQ1_CLICK | LIS3_IRQ2_CLICK,
  579. .wakeup_flags = LIS3_WAKEUP_X_LO | LIS3_WAKEUP_X_HI |
  580. LIS3_WAKEUP_Y_LO | LIS3_WAKEUP_Y_HI |
  581. LIS3_WAKEUP_Z_LO | LIS3_WAKEUP_Z_HI,
  582. .wakeup_thresh = 10,
  583. .click_thresh_x = 10,
  584. .click_thresh_y = 10,
  585. .click_thresh_z = 10,
  586. };
  587. #define SPI_AK4104 \
  588. { \
  589. .modalias = "ak4104-codec", \
  590. .max_speed_hz = 10000, \
  591. .bus_num = 0, \
  592. .chip_select = 0, \
  593. .controller_data = (void *) GPIO_SPDIF_CS, \
  594. }
  595. #define SPI_LIS3 \
  596. { \
  597. .modalias = "lis3lv02d_spi", \
  598. .max_speed_hz = 1000000, \
  599. .bus_num = 0, \
  600. .chip_select = 1, \
  601. .controller_data = (void *) GPIO_ACCEL_CS, \
  602. .platform_data = &lis3_pdata, \
  603. .irq = PXA_GPIO_TO_IRQ(GPIO_ACCEL_IRQ), \
  604. }
  605. #define SPI_DAC7512 \
  606. { \
  607. .modalias = "dac7512", \
  608. .max_speed_hz = 1000000, \
  609. .bus_num = 0, \
  610. .chip_select = 2, \
  611. .controller_data = (void *) GPIO_MCLK_DAC_CS, \
  612. }
  613. static struct spi_board_info connector_spi_devices[] __initdata = {
  614. SPI_AK4104,
  615. SPI_DAC7512,
  616. };
  617. static struct spi_board_info speaker_spi_devices[] __initdata = {
  618. SPI_DAC7512,
  619. };
  620. static struct spi_board_info controller_spi_devices[] __initdata = {
  621. SPI_LIS3,
  622. };
  623. /**
  624. * MMC for Marvell Libertas 8688 via SDIO
  625. */
  626. static int raumfeld_mci_init(struct device *dev, irq_handler_t isr, void *data)
  627. {
  628. gpio_set_value(GPIO_W2W_RESET, 1);
  629. gpio_set_value(GPIO_W2W_PDN, 1);
  630. return 0;
  631. }
  632. static void raumfeld_mci_exit(struct device *dev, void *data)
  633. {
  634. gpio_set_value(GPIO_W2W_RESET, 0);
  635. gpio_set_value(GPIO_W2W_PDN, 0);
  636. }
  637. static struct pxamci_platform_data raumfeld_mci_platform_data = {
  638. .init = raumfeld_mci_init,
  639. .exit = raumfeld_mci_exit,
  640. .detect_delay_ms = 200,
  641. .gpio_card_detect = -1,
  642. .gpio_card_ro = -1,
  643. .gpio_power = -1,
  644. };
  645. /*
  646. * External power / charge logic
  647. */
  648. static int power_supply_init(struct device *dev)
  649. {
  650. return 0;
  651. }
  652. static void power_supply_exit(struct device *dev)
  653. {
  654. }
  655. static int raumfeld_is_ac_online(void)
  656. {
  657. return !gpio_get_value(GPIO_CHARGE_DC_OK);
  658. }
  659. static int raumfeld_is_usb_online(void)
  660. {
  661. return 0;
  662. }
  663. static char *raumfeld_power_supplicants[] = { "ds2760-battery.0" };
  664. static void raumfeld_power_signal_charged(void)
  665. {
  666. struct power_supply *psy =
  667. power_supply_get_by_name(raumfeld_power_supplicants[0]);
  668. if (psy) {
  669. power_supply_set_battery_charged(psy);
  670. power_supply_put(psy);
  671. }
  672. }
  673. static int raumfeld_power_resume(void)
  674. {
  675. /* check if GPIO_CHARGE_DONE went low while we were sleeping */
  676. if (!gpio_get_value(GPIO_CHARGE_DONE))
  677. raumfeld_power_signal_charged();
  678. return 0;
  679. }
  680. static struct pda_power_pdata power_supply_info = {
  681. .init = power_supply_init,
  682. .is_ac_online = raumfeld_is_ac_online,
  683. .is_usb_online = raumfeld_is_usb_online,
  684. .exit = power_supply_exit,
  685. .supplied_to = raumfeld_power_supplicants,
  686. .num_supplicants = ARRAY_SIZE(raumfeld_power_supplicants),
  687. .resume = raumfeld_power_resume,
  688. };
  689. static struct resource power_supply_resources[] = {
  690. {
  691. .name = "ac",
  692. .flags = IORESOURCE_IRQ |
  693. IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
  694. .start = GPIO_CHARGE_DC_OK,
  695. .end = GPIO_CHARGE_DC_OK,
  696. },
  697. };
  698. static irqreturn_t charge_done_irq(int irq, void *dev_id)
  699. {
  700. raumfeld_power_signal_charged();
  701. return IRQ_HANDLED;
  702. }
  703. static struct platform_device raumfeld_power_supply = {
  704. .name = "pda-power",
  705. .id = -1,
  706. .dev = {
  707. .platform_data = &power_supply_info,
  708. },
  709. .resource = power_supply_resources,
  710. .num_resources = ARRAY_SIZE(power_supply_resources),
  711. };
  712. static void __init raumfeld_power_init(void)
  713. {
  714. int ret;
  715. /* Set PEN2 high to enable maximum charge current */
  716. ret = gpio_request(GPIO_CHRG_PEN2, "CHRG_PEN2");
  717. if (ret < 0)
  718. pr_warn("Unable to request GPIO_CHRG_PEN2\n");
  719. else
  720. gpio_direction_output(GPIO_CHRG_PEN2, 1);
  721. ret = gpio_request(GPIO_CHARGE_DC_OK, "CABLE_DC_OK");
  722. if (ret < 0)
  723. pr_warn("Unable to request GPIO_CHARGE_DC_OK\n");
  724. ret = gpio_request(GPIO_CHARGE_USB_SUSP, "CHARGE_USB_SUSP");
  725. if (ret < 0)
  726. pr_warn("Unable to request GPIO_CHARGE_USB_SUSP\n");
  727. else
  728. gpio_direction_output(GPIO_CHARGE_USB_SUSP, 0);
  729. power_supply_resources[0].start = gpio_to_irq(GPIO_CHARGE_DC_OK);
  730. power_supply_resources[0].end = gpio_to_irq(GPIO_CHARGE_DC_OK);
  731. ret = request_irq(gpio_to_irq(GPIO_CHARGE_DONE),
  732. &charge_done_irq, IORESOURCE_IRQ_LOWEDGE,
  733. "charge_done", NULL);
  734. if (ret < 0)
  735. printk(KERN_ERR "%s: unable to register irq %d\n", __func__,
  736. GPIO_CHARGE_DONE);
  737. else
  738. platform_device_register(&raumfeld_power_supply);
  739. }
  740. /* Fixed regulator for AUDIO_VA, 0-0048 maps to the cs4270 codec device */
  741. static struct regulator_consumer_supply audio_va_consumer_supply =
  742. REGULATOR_SUPPLY("va", "0-0048");
  743. static struct regulator_init_data audio_va_initdata = {
  744. .consumer_supplies = &audio_va_consumer_supply,
  745. .num_consumer_supplies = 1,
  746. .constraints = {
  747. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  748. },
  749. };
  750. static struct fixed_voltage_config audio_va_config = {
  751. .supply_name = "audio_va",
  752. .microvolts = 5000000,
  753. .gpio = GPIO_AUDIO_VA_ENABLE,
  754. .enable_high = 1,
  755. .enabled_at_boot = 0,
  756. .init_data = &audio_va_initdata,
  757. };
  758. static struct platform_device audio_va_device = {
  759. .name = "reg-fixed-voltage",
  760. .id = 0,
  761. .dev = {
  762. .platform_data = &audio_va_config,
  763. },
  764. };
  765. /* Dummy supplies for Codec's VD/VLC */
  766. static struct regulator_consumer_supply audio_dummy_supplies[] = {
  767. REGULATOR_SUPPLY("vd", "0-0048"),
  768. REGULATOR_SUPPLY("vlc", "0-0048"),
  769. };
  770. static struct regulator_init_data audio_dummy_initdata = {
  771. .consumer_supplies = audio_dummy_supplies,
  772. .num_consumer_supplies = ARRAY_SIZE(audio_dummy_supplies),
  773. .constraints = {
  774. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  775. },
  776. };
  777. static struct fixed_voltage_config audio_dummy_config = {
  778. .supply_name = "audio_vd",
  779. .microvolts = 3300000,
  780. .gpio = -1,
  781. .init_data = &audio_dummy_initdata,
  782. };
  783. static struct platform_device audio_supply_dummy_device = {
  784. .name = "reg-fixed-voltage",
  785. .id = 1,
  786. .dev = {
  787. .platform_data = &audio_dummy_config,
  788. },
  789. };
  790. static struct platform_device *audio_regulator_devices[] = {
  791. &audio_va_device,
  792. &audio_supply_dummy_device,
  793. };
  794. /**
  795. * Regulator support via MAX8660
  796. */
  797. static struct regulator_consumer_supply vcc_mmc_supply =
  798. REGULATOR_SUPPLY("vmmc", "pxa2xx-mci.0");
  799. static struct regulator_init_data vcc_mmc_init_data = {
  800. .constraints = {
  801. .min_uV = 3300000,
  802. .max_uV = 3300000,
  803. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  804. .valid_ops_mask = REGULATOR_CHANGE_STATUS |
  805. REGULATOR_CHANGE_VOLTAGE |
  806. REGULATOR_CHANGE_MODE,
  807. },
  808. .consumer_supplies = &vcc_mmc_supply,
  809. .num_consumer_supplies = 1,
  810. };
  811. static struct max8660_subdev_data max8660_v6_subdev_data = {
  812. .id = MAX8660_V6,
  813. .name = "vmmc",
  814. .platform_data = &vcc_mmc_init_data,
  815. };
  816. static struct max8660_platform_data max8660_pdata = {
  817. .subdevs = &max8660_v6_subdev_data,
  818. .num_subdevs = 1,
  819. };
  820. /**
  821. * I2C devices
  822. */
  823. static struct i2c_board_info raumfeld_pwri2c_board_info = {
  824. .type = "max8660",
  825. .addr = 0x34,
  826. .platform_data = &max8660_pdata,
  827. };
  828. static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
  829. .type = "cs4270",
  830. .addr = 0x48,
  831. };
  832. static struct gpiod_lookup_table raumfeld_controller_gpios_table = {
  833. .dev_id = "0-000a",
  834. .table = {
  835. GPIO_LOOKUP("gpio-pxa",
  836. GPIO_TOUCH_IRQ, "attn", GPIO_ACTIVE_HIGH),
  837. { },
  838. },
  839. };
  840. static const struct resource raumfeld_controller_resources[] __initconst = {
  841. {
  842. .start = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
  843. .end = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
  844. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
  845. },
  846. };
  847. static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
  848. .type = "eeti_ts",
  849. .addr = 0x0a,
  850. .resources = raumfeld_controller_resources,
  851. .num_resources = ARRAY_SIZE(raumfeld_controller_resources),
  852. };
  853. static struct platform_device *raumfeld_common_devices[] = {
  854. &raumfeld_gpio_keys_device,
  855. &raumfeld_led_device,
  856. &raumfeld_spi_device,
  857. };
  858. static void __init raumfeld_audio_init(void)
  859. {
  860. int ret;
  861. ret = gpio_request(GPIO_CODEC_RESET, "cs4270 reset");
  862. if (ret < 0)
  863. pr_warn("unable to request GPIO_CODEC_RESET\n");
  864. else
  865. gpio_direction_output(GPIO_CODEC_RESET, 1);
  866. ret = gpio_request(GPIO_SPDIF_RESET, "ak4104 s/pdif reset");
  867. if (ret < 0)
  868. pr_warn("unable to request GPIO_SPDIF_RESET\n");
  869. else
  870. gpio_direction_output(GPIO_SPDIF_RESET, 1);
  871. ret = gpio_request(GPIO_MCLK_RESET, "MCLK reset");
  872. if (ret < 0)
  873. pr_warn("unable to request GPIO_MCLK_RESET\n");
  874. else
  875. gpio_direction_output(GPIO_MCLK_RESET, 1);
  876. platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
  877. }
  878. static void __init raumfeld_common_init(void)
  879. {
  880. int ret;
  881. /* The on/off button polarity has changed after revision 1 */
  882. if ((system_rev & 0xff) > 1) {
  883. int i;
  884. for (i = 0; i < ARRAY_SIZE(gpio_keys_button); i++)
  885. if (!strcmp(gpio_keys_button[i].desc, "on_off button"))
  886. gpio_keys_button[i].active_low = 1;
  887. }
  888. enable_irq_wake(IRQ_WAKEUP0);
  889. pxa3xx_set_nand_info(&raumfeld_nand_info);
  890. pxa3xx_set_i2c_power_info(NULL);
  891. pxa_set_ohci_info(&raumfeld_ohci_info);
  892. pxa_set_mci_info(&raumfeld_mci_platform_data);
  893. pxa_set_i2c_info(NULL);
  894. pxa_set_ffuart_info(NULL);
  895. ret = gpio_request(GPIO_W2W_RESET, "Wi2Wi reset");
  896. if (ret < 0)
  897. pr_warn("Unable to request GPIO_W2W_RESET\n");
  898. else
  899. gpio_direction_output(GPIO_W2W_RESET, 0);
  900. ret = gpio_request(GPIO_W2W_PDN, "Wi2Wi powerup");
  901. if (ret < 0)
  902. pr_warn("Unable to request GPIO_W2W_PDN\n");
  903. else
  904. gpio_direction_output(GPIO_W2W_PDN, 0);
  905. /* this can be used to switch off the device */
  906. ret = gpio_request(GPIO_SHUTDOWN_SUPPLY, "supply shutdown");
  907. if (ret < 0)
  908. pr_warn("Unable to request GPIO_SHUTDOWN_SUPPLY\n");
  909. else
  910. gpio_direction_output(GPIO_SHUTDOWN_SUPPLY, 0);
  911. platform_add_devices(ARRAY_AND_SIZE(raumfeld_common_devices));
  912. i2c_register_board_info(1, &raumfeld_pwri2c_board_info, 1);
  913. }
  914. static void __init __maybe_unused raumfeld_controller_init(void)
  915. {
  916. int ret;
  917. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config));
  918. gpiod_add_lookup_table(&raumfeld_rotary_gpios_table);
  919. device_add_properties(&rotary_encoder_device.dev,
  920. raumfeld_rotary_properties);
  921. platform_device_register(&rotary_encoder_device);
  922. spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices));
  923. gpiod_add_lookup_table(&raumfeld_controller_gpios_table);
  924. i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
  925. ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
  926. if (ret < 0)
  927. pr_warn("Unable to request GPIO_SHUTDOWN_BATT\n");
  928. else
  929. gpio_direction_output(GPIO_SHUTDOWN_BATT, 0);
  930. raumfeld_common_init();
  931. raumfeld_power_init();
  932. raumfeld_lcd_init();
  933. raumfeld_w1_init();
  934. }
  935. static void __init __maybe_unused raumfeld_connector_init(void)
  936. {
  937. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_connector_pin_config));
  938. spi_register_board_info(ARRAY_AND_SIZE(connector_spi_devices));
  939. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  940. platform_device_register(&smc91x_device);
  941. raumfeld_audio_init();
  942. raumfeld_common_init();
  943. }
  944. static void __init __maybe_unused raumfeld_speaker_init(void)
  945. {
  946. pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_speaker_pin_config));
  947. spi_register_board_info(ARRAY_AND_SIZE(speaker_spi_devices));
  948. i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
  949. platform_device_register(&smc91x_device);
  950. gpiod_add_lookup_table(&raumfeld_rotary_gpios_table);
  951. device_add_properties(&rotary_encoder_device.dev,
  952. raumfeld_rotary_properties);
  953. platform_device_register(&rotary_encoder_device);
  954. raumfeld_audio_init();
  955. raumfeld_common_init();
  956. }
  957. /* physical memory regions */
  958. #define RAUMFELD_SDRAM_BASE 0xa0000000 /* SDRAM region */
  959. #ifdef CONFIG_MACH_RAUMFELD_RC
  960. MACHINE_START(RAUMFELD_RC, "Raumfeld Controller")
  961. .atag_offset = 0x100,
  962. .init_machine = raumfeld_controller_init,
  963. .map_io = pxa3xx_map_io,
  964. .nr_irqs = PXA_NR_IRQS,
  965. .init_irq = pxa3xx_init_irq,
  966. .handle_irq = pxa3xx_handle_irq,
  967. .init_time = pxa_timer_init,
  968. .restart = pxa_restart,
  969. MACHINE_END
  970. #endif
  971. #ifdef CONFIG_MACH_RAUMFELD_CONNECTOR
  972. MACHINE_START(RAUMFELD_CONNECTOR, "Raumfeld Connector")
  973. .atag_offset = 0x100,
  974. .init_machine = raumfeld_connector_init,
  975. .map_io = pxa3xx_map_io,
  976. .nr_irqs = PXA_NR_IRQS,
  977. .init_irq = pxa3xx_init_irq,
  978. .handle_irq = pxa3xx_handle_irq,
  979. .init_time = pxa_timer_init,
  980. .restart = pxa_restart,
  981. MACHINE_END
  982. #endif
  983. #ifdef CONFIG_MACH_RAUMFELD_SPEAKER
  984. MACHINE_START(RAUMFELD_SPEAKER, "Raumfeld Speaker")
  985. .atag_offset = 0x100,
  986. .init_machine = raumfeld_speaker_init,
  987. .map_io = pxa3xx_map_io,
  988. .nr_irqs = PXA_NR_IRQS,
  989. .init_irq = pxa3xx_init_irq,
  990. .handle_irq = pxa3xx_handle_irq,
  991. .init_time = pxa_timer_init,
  992. .restart = pxa_restart,
  993. MACHINE_END
  994. #endif