hx4700.c 21 KB

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