raumfeld.c 26 KB

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