hx4700.c 20 KB

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