raumfeld.c 27 KB

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