hx4700.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. /*
  2. * Support for HP iPAQ hx4700 PDAs.
  3. *
  4. * Copyright (c) 2008-2009 Philipp Zabel
  5. *
  6. * Based on code:
  7. * Copyright (c) 2004 Hewlett-Packard Company.
  8. * Copyright (c) 2005 SDG Systems, LLC
  9. * Copyright (c) 2006 Anton Vorontsov <cbou@mail.ru>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/delay.h>
  20. #include <linux/fb.h>
  21. #include <linux/gpio.h>
  22. #include <linux/gpio_keys.h>
  23. #include <linux/input.h>
  24. #include <linux/lcd.h>
  25. #include <linux/mfd/htc-egpio.h>
  26. #include <linux/mfd/asic3.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <linux/pda_power.h>
  29. #include <linux/pwm_backlight.h>
  30. #include <linux/regulator/bq24022.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/regulator/max1586.h>
  33. #include <linux/spi/ads7846.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/pxa2xx_spi.h>
  36. #include <linux/usb/gpio_vbus.h>
  37. #include <linux/i2c/pxa-i2c.h>
  38. #include <mach/hardware.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <mach/pxa27x.h>
  42. #include <mach/hx4700.h>
  43. #include <mach/irda.h>
  44. #include <video/platform_lcd.h>
  45. #include <video/w100fb.h>
  46. #include "devices.h"
  47. #include "generic.h"
  48. /* Physical address space information */
  49. #define ATI_W3220_PHYS PXA_CS2_PHYS /* ATI Imageon 3220 Graphics */
  50. #define ASIC3_PHYS PXA_CS3_PHYS
  51. #define ASIC3_SD_PHYS (PXA_CS3_PHYS + 0x02000000)
  52. static unsigned long hx4700_pin_config[] __initdata = {
  53. /* SDRAM and Static Memory I/O Signals */
  54. GPIO20_nSDCS_2,
  55. GPIO21_nSDCS_3,
  56. GPIO15_nCS_1,
  57. GPIO78_nCS_2, /* W3220 */
  58. GPIO79_nCS_3, /* ASIC3 */
  59. GPIO80_nCS_4,
  60. GPIO33_nCS_5, /* EGPIO, WLAN */
  61. /* PC CARD */
  62. GPIO48_nPOE,
  63. GPIO49_nPWE,
  64. GPIO50_nPIOR,
  65. GPIO51_nPIOW,
  66. GPIO54_nPCE_2,
  67. GPIO55_nPREG,
  68. GPIO56_nPWAIT,
  69. GPIO57_nIOIS16,
  70. GPIO85_nPCE_1,
  71. GPIO104_PSKTSEL,
  72. /* I2C */
  73. GPIO117_I2C_SCL,
  74. GPIO118_I2C_SDA,
  75. /* FFUART (RS-232) */
  76. GPIO34_FFUART_RXD,
  77. GPIO35_FFUART_CTS,
  78. GPIO36_FFUART_DCD,
  79. GPIO37_FFUART_DSR,
  80. GPIO38_FFUART_RI,
  81. GPIO39_FFUART_TXD,
  82. GPIO40_FFUART_DTR,
  83. GPIO41_FFUART_RTS,
  84. /* BTUART */
  85. GPIO42_BTUART_RXD,
  86. GPIO43_BTUART_TXD,
  87. GPIO44_BTUART_CTS,
  88. GPIO45_BTUART_RTS,
  89. /* PWM 1 (Backlight) */
  90. GPIO17_PWM1_OUT,
  91. /* I2S */
  92. GPIO28_I2S_BITCLK_OUT,
  93. GPIO29_I2S_SDATA_IN,
  94. GPIO30_I2S_SDATA_OUT,
  95. GPIO31_I2S_SYNC,
  96. GPIO113_I2S_SYSCLK,
  97. /* SSP 1 (NavPoint) */
  98. GPIO23_SSP1_SCLK,
  99. GPIO24_SSP1_SFRM,
  100. GPIO25_SSP1_TXD,
  101. GPIO26_SSP1_RXD,
  102. /* SSP 2 (TSC2046) */
  103. GPIO19_SSP2_SCLK,
  104. GPIO86_SSP2_RXD,
  105. GPIO87_SSP2_TXD,
  106. GPIO88_GPIO,
  107. /* HX4700 specific input GPIOs */
  108. GPIO12_GPIO, /* ASIC3_IRQ */
  109. GPIO13_GPIO, /* W3220_IRQ */
  110. GPIO14_GPIO, /* nWLAN_IRQ */
  111. GPIO10_GPIO, /* GSM_IRQ */
  112. GPIO13_GPIO, /* CPLD_IRQ */
  113. GPIO107_GPIO, /* DS1WM_IRQ */
  114. GPIO108_GPIO, /* GSM_READY */
  115. GPIO58_GPIO, /* TSC2046_nPENIRQ */
  116. GPIO66_GPIO, /* nSDIO_IRQ */
  117. };
  118. /*
  119. * IRDA
  120. */
  121. static struct pxaficp_platform_data ficp_info = {
  122. .gpio_pwdown = GPIO105_HX4700_nIR_ON,
  123. .transceiver_cap = IR_SIRMODE | IR_OFF,
  124. };
  125. /*
  126. * GPIO Keys
  127. */
  128. #define INIT_KEY(_code, _gpio, _active_low, _desc) \
  129. { \
  130. .code = KEY_##_code, \
  131. .gpio = _gpio, \
  132. .active_low = _active_low, \
  133. .desc = _desc, \
  134. .type = EV_KEY, \
  135. .wakeup = 1, \
  136. }
  137. static struct gpio_keys_button gpio_keys_buttons[] = {
  138. INIT_KEY(POWER, GPIO0_HX4700_nKEY_POWER, 1, "Power button"),
  139. INIT_KEY(MAIL, GPIO94_HX4700_KEY_MAIL, 0, "Mail button"),
  140. INIT_KEY(ADDRESSBOOK, GPIO99_HX4700_KEY_CONTACTS,0, "Contacts button"),
  141. INIT_KEY(RECORD, GPIOD6_nKEY_RECORD, 1, "Record button"),
  142. INIT_KEY(CALENDAR, GPIOD1_nKEY_CALENDAR, 1, "Calendar button"),
  143. INIT_KEY(HOMEPAGE, GPIOD3_nKEY_HOME, 1, "Home button"),
  144. };
  145. static struct gpio_keys_platform_data gpio_keys_data = {
  146. .buttons = gpio_keys_buttons,
  147. .nbuttons = ARRAY_SIZE(gpio_keys_buttons),
  148. };
  149. static struct platform_device gpio_keys = {
  150. .name = "gpio-keys",
  151. .dev = {
  152. .platform_data = &gpio_keys_data,
  153. },
  154. .id = -1,
  155. };
  156. /*
  157. * ASIC3
  158. */
  159. static u16 asic3_gpio_config[] = {
  160. /* ASIC3 GPIO banks A and B along with some of C and D
  161. implement the buffering for the CF slot. */
  162. ASIC3_CONFIG_GPIO(0, 1, 1, 0),
  163. ASIC3_CONFIG_GPIO(1, 1, 1, 0),
  164. ASIC3_CONFIG_GPIO(2, 1, 1, 0),
  165. ASIC3_CONFIG_GPIO(3, 1, 1, 0),
  166. ASIC3_CONFIG_GPIO(4, 1, 1, 0),
  167. ASIC3_CONFIG_GPIO(5, 1, 1, 0),
  168. ASIC3_CONFIG_GPIO(6, 1, 1, 0),
  169. ASIC3_CONFIG_GPIO(7, 1, 1, 0),
  170. ASIC3_CONFIG_GPIO(8, 1, 1, 0),
  171. ASIC3_CONFIG_GPIO(9, 1, 1, 0),
  172. ASIC3_CONFIG_GPIO(10, 1, 1, 0),
  173. ASIC3_CONFIG_GPIO(11, 1, 1, 0),
  174. ASIC3_CONFIG_GPIO(12, 1, 1, 0),
  175. ASIC3_CONFIG_GPIO(13, 1, 1, 0),
  176. ASIC3_CONFIG_GPIO(14, 1, 1, 0),
  177. ASIC3_CONFIG_GPIO(15, 1, 1, 0),
  178. ASIC3_CONFIG_GPIO(16, 1, 1, 0),
  179. ASIC3_CONFIG_GPIO(17, 1, 1, 0),
  180. ASIC3_CONFIG_GPIO(18, 1, 1, 0),
  181. ASIC3_CONFIG_GPIO(19, 1, 1, 0),
  182. ASIC3_CONFIG_GPIO(20, 1, 1, 0),
  183. ASIC3_CONFIG_GPIO(21, 1, 1, 0),
  184. ASIC3_CONFIG_GPIO(22, 1, 1, 0),
  185. ASIC3_CONFIG_GPIO(23, 1, 1, 0),
  186. ASIC3_CONFIG_GPIO(24, 1, 1, 0),
  187. ASIC3_CONFIG_GPIO(25, 1, 1, 0),
  188. ASIC3_CONFIG_GPIO(26, 1, 1, 0),
  189. ASIC3_CONFIG_GPIO(27, 1, 1, 0),
  190. ASIC3_CONFIG_GPIO(28, 1, 1, 0),
  191. ASIC3_CONFIG_GPIO(29, 1, 1, 0),
  192. ASIC3_CONFIG_GPIO(30, 1, 1, 0),
  193. ASIC3_CONFIG_GPIO(31, 1, 1, 0),
  194. /* GPIOC - CF, LEDs, SD */
  195. ASIC3_GPIOC0_LED0, /* red */
  196. ASIC3_GPIOC1_LED1, /* green */
  197. ASIC3_GPIOC2_LED2, /* blue */
  198. ASIC3_GPIOC4_CF_nCD,
  199. ASIC3_GPIOC5_nCIOW,
  200. ASIC3_GPIOC6_nCIOR,
  201. ASIC3_GPIOC7_nPCE_1,
  202. ASIC3_GPIOC8_nPCE_2,
  203. ASIC3_GPIOC9_nPOE,
  204. ASIC3_GPIOC10_nPWE,
  205. ASIC3_GPIOC11_PSKTSEL,
  206. ASIC3_GPIOC12_nPREG,
  207. ASIC3_GPIOC13_nPWAIT,
  208. ASIC3_GPIOC14_nPIOIS16,
  209. ASIC3_GPIOC15_nPIOR,
  210. /* GPIOD: input GPIOs, CF */
  211. ASIC3_GPIOD11_nCIOIS16,
  212. ASIC3_GPIOD12_nCWAIT,
  213. ASIC3_GPIOD15_nPIOW,
  214. };
  215. static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
  216. [0] = {
  217. .name = "hx4700:amber",
  218. .default_trigger = "ds2760-battery.0-charging-blink-full-solid",
  219. },
  220. [1] = {
  221. .name = "hx4700:green",
  222. .default_trigger = "unused",
  223. },
  224. [2] = {
  225. .name = "hx4700:blue",
  226. .default_trigger = "hx4700-radio",
  227. },
  228. };
  229. static struct resource asic3_resources[] = {
  230. /* GPIO part */
  231. [0] = {
  232. .start = ASIC3_PHYS,
  233. .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. [1] = {
  237. .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
  238. .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. /* SD part */
  242. [2] = {
  243. .start = ASIC3_SD_PHYS,
  244. .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
  245. .flags = IORESOURCE_MEM,
  246. },
  247. [3] = {
  248. .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
  249. .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
  250. .flags = IORESOURCE_IRQ,
  251. },
  252. };
  253. static struct asic3_platform_data asic3_platform_data = {
  254. .gpio_config = asic3_gpio_config,
  255. .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
  256. .irq_base = IRQ_BOARD_START,
  257. .gpio_base = HX4700_ASIC3_GPIO_BASE,
  258. .leds = asic3_leds,
  259. };
  260. static struct platform_device asic3 = {
  261. .name = "asic3",
  262. .id = -1,
  263. .resource = asic3_resources,
  264. .num_resources = ARRAY_SIZE(asic3_resources),
  265. .dev = {
  266. .platform_data = &asic3_platform_data,
  267. },
  268. };
  269. /*
  270. * EGPIO
  271. */
  272. static struct resource egpio_resources[] = {
  273. [0] = {
  274. .start = PXA_CS5_PHYS,
  275. .end = PXA_CS5_PHYS + 0x4 - 1,
  276. .flags = IORESOURCE_MEM,
  277. },
  278. };
  279. static struct htc_egpio_chip egpio_chips[] = {
  280. [0] = {
  281. .reg_start = 0,
  282. .gpio_base = HX4700_EGPIO_BASE,
  283. .num_gpios = 8,
  284. .direction = HTC_EGPIO_OUTPUT,
  285. },
  286. };
  287. static struct htc_egpio_platform_data egpio_info = {
  288. .reg_width = 16,
  289. .bus_width = 16,
  290. .chip = egpio_chips,
  291. .num_chips = ARRAY_SIZE(egpio_chips),
  292. };
  293. static struct platform_device egpio = {
  294. .name = "htc-egpio",
  295. .id = -1,
  296. .resource = egpio_resources,
  297. .num_resources = ARRAY_SIZE(egpio_resources),
  298. .dev = {
  299. .platform_data = &egpio_info,
  300. },
  301. };
  302. /*
  303. * LCD - Sony display connected to ATI Imageon w3220
  304. */
  305. static void sony_lcd_init(void)
  306. {
  307. gpio_set_value(GPIO84_HX4700_LCD_SQN, 1);
  308. gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
  309. gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
  310. gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0);
  311. gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
  312. mdelay(10);
  313. gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
  314. gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
  315. mdelay(20);
  316. gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1);
  317. mdelay(5);
  318. gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1);
  319. /* FIXME: init w3220 registers here */
  320. mdelay(5);
  321. gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1);
  322. mdelay(10);
  323. gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1);
  324. mdelay(10);
  325. gpio_set_value(GPIO59_HX4700_LCD_PC1, 1);
  326. mdelay(10);
  327. gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1);
  328. }
  329. static void sony_lcd_off(void)
  330. {
  331. gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
  332. gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
  333. mdelay(10);
  334. gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0);
  335. mdelay(10);
  336. gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
  337. mdelay(10);
  338. gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
  339. }
  340. #ifdef CONFIG_PM
  341. static void w3220_lcd_suspend(struct w100fb_par *wfb)
  342. {
  343. sony_lcd_off();
  344. }
  345. static void w3220_lcd_resume(struct w100fb_par *wfb)
  346. {
  347. sony_lcd_init();
  348. }
  349. #else
  350. #define w3220_lcd_resume NULL
  351. #define w3220_lcd_suspend NULL
  352. #endif
  353. static struct w100_tg_info w3220_tg_info = {
  354. .suspend = w3220_lcd_suspend,
  355. .resume = w3220_lcd_resume,
  356. };
  357. /* W3220_VGA QVGA */
  358. static struct w100_gen_regs w3220_regs = {
  359. .lcd_format = 0x00000003,
  360. .lcdd_cntl1 = 0x00000000,
  361. .lcdd_cntl2 = 0x0003ffff,
  362. .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */
  363. .genlcd_cntl2 = 0x00000003,
  364. .genlcd_cntl3 = 0x000102aa,
  365. };
  366. static struct w100_mode w3220_modes[] = {
  367. {
  368. .xres = 480,
  369. .yres = 640,
  370. .left_margin = 15,
  371. .right_margin = 16,
  372. .upper_margin = 8,
  373. .lower_margin = 7,
  374. .crtc_ss = 0x00000000,
  375. .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */
  376. .crtc_gs = 0xc0000000, /* 0x40000000 */
  377. .crtc_vpos_gs = 0x0000028f,
  378. .crtc_ps1_active = 0x00000000, /* 0x41060010 */
  379. .crtc_rev = 0,
  380. .crtc_dclk = 0x80000000,
  381. .crtc_gclk = 0x040a0104,
  382. .crtc_goe = 0,
  383. .pll_freq = 95,
  384. .pixclk_divider = 4,
  385. .pixclk_divider_rotated = 4,
  386. .pixclk_src = CLK_SRC_PLL,
  387. .sysclk_divider = 0,
  388. .sysclk_src = CLK_SRC_PLL,
  389. },
  390. {
  391. .xres = 240,
  392. .yres = 320,
  393. .left_margin = 9,
  394. .right_margin = 8,
  395. .upper_margin = 5,
  396. .lower_margin = 4,
  397. .crtc_ss = 0x80150014,
  398. .crtc_ls = 0xa0fb00f7,
  399. .crtc_gs = 0xc0080007,
  400. .crtc_vpos_gs = 0x00080007,
  401. .crtc_rev = 0x0000000a,
  402. .crtc_dclk = 0x81700030,
  403. .crtc_gclk = 0x8015010f,
  404. .crtc_goe = 0x00000000,
  405. .pll_freq = 95,
  406. .pixclk_divider = 4,
  407. .pixclk_divider_rotated = 4,
  408. .pixclk_src = CLK_SRC_PLL,
  409. .sysclk_divider = 0,
  410. .sysclk_src = CLK_SRC_PLL,
  411. },
  412. };
  413. struct w100_mem_info w3220_mem_info = {
  414. .ext_cntl = 0x09640011,
  415. .sdram_mode_reg = 0x00600021,
  416. .ext_timing_cntl = 0x1a001545, /* 0x15001545 */
  417. .io_cntl = 0x7ddd7333,
  418. .size = 0x1fffff,
  419. };
  420. struct w100_bm_mem_info w3220_bm_mem_info = {
  421. .ext_mem_bw = 0x50413e01,
  422. .offset = 0,
  423. .ext_timing_ctl = 0x00043f7f,
  424. .ext_cntl = 0x00000010,
  425. .mode_reg = 0x00250000,
  426. .io_cntl = 0x0fff0000,
  427. .config = 0x08301480,
  428. };
  429. static struct w100_gpio_regs w3220_gpio_info = {
  430. .init_data1 = 0xdfe00100, /* GPIO_DATA */
  431. .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */
  432. .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */
  433. .init_data2 = 0x00000000, /* GPIO_DATA2 */
  434. .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */
  435. .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */
  436. };
  437. static struct w100fb_mach_info w3220_info = {
  438. .tg = &w3220_tg_info,
  439. .mem = &w3220_mem_info,
  440. .bm_mem = &w3220_bm_mem_info,
  441. .gpio = &w3220_gpio_info,
  442. .regs = &w3220_regs,
  443. .modelist = w3220_modes,
  444. .num_modes = 2,
  445. .xtal_freq = 16000000,
  446. };
  447. static struct resource w3220_resources[] = {
  448. [0] = {
  449. .start = ATI_W3220_PHYS,
  450. .end = ATI_W3220_PHYS + 0x00ffffff,
  451. .flags = IORESOURCE_MEM,
  452. },
  453. };
  454. static struct platform_device w3220 = {
  455. .name = "w100fb",
  456. .id = -1,
  457. .dev = {
  458. .platform_data = &w3220_info,
  459. },
  460. .num_resources = ARRAY_SIZE(w3220_resources),
  461. .resource = w3220_resources,
  462. };
  463. static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power)
  464. {
  465. if (power)
  466. sony_lcd_init();
  467. else
  468. sony_lcd_off();
  469. }
  470. static struct plat_lcd_data hx4700_lcd_data = {
  471. .set_power = hx4700_lcd_set_power,
  472. };
  473. static struct platform_device hx4700_lcd = {
  474. .name = "platform-lcd",
  475. .id = -1,
  476. .dev = {
  477. .platform_data = &hx4700_lcd_data,
  478. .parent = &w3220.dev,
  479. },
  480. };
  481. /*
  482. * Backlight
  483. */
  484. static struct platform_pwm_backlight_data backlight_data = {
  485. .pwm_id = 1,
  486. .max_brightness = 200,
  487. .dft_brightness = 100,
  488. .pwm_period_ns = 30923,
  489. };
  490. static struct platform_device backlight = {
  491. .name = "pwm-backlight",
  492. .id = -1,
  493. .dev = {
  494. .parent = &pxa27x_device_pwm1.dev,
  495. .platform_data = &backlight_data,
  496. },
  497. };
  498. /*
  499. * USB "Transceiver"
  500. */
  501. static struct gpio_vbus_mach_info gpio_vbus_info = {
  502. .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
  503. .gpio_vbus = GPIOD14_nUSBC_DETECT,
  504. .gpio_vbus_inverted = 1,
  505. };
  506. static struct platform_device gpio_vbus = {
  507. .name = "gpio-vbus",
  508. .id = -1,
  509. .dev = {
  510. .platform_data = &gpio_vbus_info,
  511. },
  512. };
  513. /*
  514. * Touchscreen - TSC2046 connected to SSP2
  515. */
  516. static const struct ads7846_platform_data tsc2046_info = {
  517. .model = 7846,
  518. .vref_delay_usecs = 100,
  519. .pressure_max = 1024,
  520. .debounce_max = 10,
  521. .debounce_tol = 3,
  522. .debounce_rep = 1,
  523. .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ,
  524. };
  525. static struct pxa2xx_spi_chip tsc2046_chip = {
  526. .tx_threshold = 1,
  527. .rx_threshold = 2,
  528. .timeout = 64,
  529. .gpio_cs = GPIO88_HX4700_TSC2046_CS,
  530. };
  531. static struct spi_board_info tsc2046_board_info[] __initdata = {
  532. {
  533. .modalias = "ads7846",
  534. .bus_num = 2,
  535. .max_speed_hz = 2600000, /* 100 kHz sample rate */
  536. .irq = PXA_GPIO_TO_IRQ(GPIO58_HX4700_TSC2046_nPENIRQ),
  537. .platform_data = &tsc2046_info,
  538. .controller_data = &tsc2046_chip,
  539. },
  540. };
  541. static struct pxa2xx_spi_master pxa_ssp2_master_info = {
  542. .num_chipselect = 1,
  543. .clock_enable = CKEN_SSP2,
  544. .enable_dma = 1,
  545. };
  546. /*
  547. * External power
  548. */
  549. static int power_supply_init(struct device *dev)
  550. {
  551. return gpio_request(GPIOD9_nAC_IN, "AC charger detect");
  552. }
  553. static int hx4700_is_ac_online(void)
  554. {
  555. return !gpio_get_value(GPIOD9_nAC_IN);
  556. }
  557. static void power_supply_exit(struct device *dev)
  558. {
  559. gpio_free(GPIOD9_nAC_IN);
  560. }
  561. static char *hx4700_supplicants[] = {
  562. "ds2760-battery.0", "backup-battery"
  563. };
  564. static struct pda_power_pdata power_supply_info = {
  565. .init = power_supply_init,
  566. .is_ac_online = hx4700_is_ac_online,
  567. .exit = power_supply_exit,
  568. .supplied_to = hx4700_supplicants,
  569. .num_supplicants = ARRAY_SIZE(hx4700_supplicants),
  570. };
  571. static struct resource power_supply_resources[] = {
  572. [0] = {
  573. .name = "ac",
  574. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  575. IORESOURCE_IRQ_LOWEDGE,
  576. .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
  577. .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
  578. },
  579. [1] = {
  580. .name = "usb",
  581. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
  582. IORESOURCE_IRQ_LOWEDGE,
  583. .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
  584. .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
  585. },
  586. };
  587. static struct platform_device power_supply = {
  588. .name = "pda-power",
  589. .id = -1,
  590. .dev = {
  591. .platform_data = &power_supply_info,
  592. },
  593. .resource = power_supply_resources,
  594. .num_resources = ARRAY_SIZE(power_supply_resources),
  595. };
  596. /*
  597. * Battery charger
  598. */
  599. static struct regulator_consumer_supply bq24022_consumers[] = {
  600. {
  601. .dev = &gpio_vbus.dev,
  602. .supply = "vbus_draw",
  603. },
  604. {
  605. .dev = &power_supply.dev,
  606. .supply = "ac_draw",
  607. },
  608. };
  609. static struct regulator_init_data bq24022_init_data = {
  610. .constraints = {
  611. .max_uA = 500000,
  612. .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS,
  613. },
  614. .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
  615. .consumer_supplies = bq24022_consumers,
  616. };
  617. static struct bq24022_mach_info bq24022_info = {
  618. .gpio_nce = GPIO72_HX4700_BQ24022_nCHARGE_EN,
  619. .gpio_iset2 = GPIO96_HX4700_BQ24022_ISET2,
  620. .init_data = &bq24022_init_data,
  621. };
  622. static struct platform_device bq24022 = {
  623. .name = "bq24022",
  624. .id = -1,
  625. .dev = {
  626. .platform_data = &bq24022_info,
  627. },
  628. };
  629. /*
  630. * StrataFlash
  631. */
  632. static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
  633. {
  634. gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
  635. }
  636. static struct resource strataflash_resource[] = {
  637. [0] = DEFINE_RES_MEM(PXA_CS0_PHYS, SZ_64M),
  638. [1] = DEFINE_RES_MEM(PXA_CS0_PHYS + SZ_64M, SZ_64M),
  639. };
  640. static struct physmap_flash_data strataflash_data = {
  641. .width = 4,
  642. .set_vpp = hx4700_set_vpp,
  643. };
  644. static struct platform_device strataflash = {
  645. .name = "physmap-flash",
  646. .id = -1,
  647. .resource = strataflash_resource,
  648. .num_resources = ARRAY_SIZE(strataflash_resource),
  649. .dev = {
  650. .platform_data = &strataflash_data,
  651. },
  652. };
  653. /*
  654. * Maxim MAX1587A on PI2C
  655. */
  656. static struct regulator_consumer_supply max1587a_consumer = {
  657. .supply = "vcc_core",
  658. };
  659. static struct regulator_init_data max1587a_v3_info = {
  660. .constraints = {
  661. .name = "vcc_core range",
  662. .min_uV = 900000,
  663. .max_uV = 1705000,
  664. .always_on = 1,
  665. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  666. },
  667. .num_consumer_supplies = 1,
  668. .consumer_supplies = &max1587a_consumer,
  669. };
  670. static struct max1586_subdev_data max1587a_subdev = {
  671. .name = "vcc_core",
  672. .id = MAX1586_V3,
  673. .platform_data = &max1587a_v3_info,
  674. };
  675. static struct max1586_platform_data max1587a_info = {
  676. .num_subdevs = 1,
  677. .subdevs = &max1587a_subdev,
  678. .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
  679. };
  680. static struct i2c_board_info __initdata pi2c_board_info[] = {
  681. {
  682. I2C_BOARD_INFO("max1586", 0x14),
  683. .platform_data = &max1587a_info,
  684. },
  685. };
  686. /*
  687. * PCMCIA
  688. */
  689. static struct platform_device pcmcia = {
  690. .name = "hx4700-pcmcia",
  691. .dev = {
  692. .parent = &asic3.dev,
  693. },
  694. };
  695. /*
  696. * Platform devices
  697. */
  698. static struct platform_device *devices[] __initdata = {
  699. &asic3,
  700. &gpio_keys,
  701. &backlight,
  702. &w3220,
  703. &hx4700_lcd,
  704. &egpio,
  705. &bq24022,
  706. &gpio_vbus,
  707. &power_supply,
  708. &strataflash,
  709. &pcmcia,
  710. };
  711. static struct gpio global_gpios[] = {
  712. { GPIO12_HX4700_ASIC3_IRQ, GPIOF_IN, "ASIC3_IRQ" },
  713. { GPIO13_HX4700_W3220_IRQ, GPIOF_IN, "W3220_IRQ" },
  714. { GPIO14_HX4700_nWLAN_IRQ, GPIOF_IN, "WLAN_IRQ" },
  715. { GPIO59_HX4700_LCD_PC1, GPIOF_OUT_INIT_HIGH, "LCD_PC1" },
  716. { GPIO62_HX4700_LCD_nRESET, GPIOF_OUT_INIT_HIGH, "LCD_RESET" },
  717. { GPIO70_HX4700_LCD_SLIN1, GPIOF_OUT_INIT_HIGH, "LCD_SLIN1" },
  718. { GPIO84_HX4700_LCD_SQN, GPIOF_OUT_INIT_HIGH, "LCD_SQN" },
  719. { GPIO110_HX4700_LCD_LVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_LVDD" },
  720. { GPIO111_HX4700_LCD_AVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_AVDD" },
  721. { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
  722. { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
  723. { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
  724. { GPIO105_HX4700_nIR_ON, GPIOF_OUT_INIT_HIGH, "nIR_EN" },
  725. };
  726. static void __init hx4700_init(void)
  727. {
  728. int ret;
  729. pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config));
  730. ret = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
  731. if (ret)
  732. pr_err ("hx4700: Failed to request GPIOs.\n");
  733. pxa_set_ffuart_info(NULL);
  734. pxa_set_btuart_info(NULL);
  735. pxa_set_stuart_info(NULL);
  736. platform_add_devices(devices, ARRAY_SIZE(devices));
  737. pxa_set_ficp_info(&ficp_info);
  738. pxa27x_set_i2c_power_info(NULL);
  739. pxa_set_i2c_info(NULL);
  740. i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
  741. pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
  742. spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
  743. gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0);
  744. mdelay(10);
  745. gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
  746. mdelay(10);
  747. }
  748. MACHINE_START(H4700, "HP iPAQ HX4700")
  749. .atag_offset = 0x100,
  750. .map_io = pxa27x_map_io,
  751. .nr_irqs = HX4700_NR_IRQS,
  752. .init_irq = pxa27x_init_irq,
  753. .handle_irq = pxa27x_handle_irq,
  754. .init_machine = hx4700_init,
  755. .timer = &pxa_timer,
  756. .restart = pxa_restart,
  757. MACHINE_END