hx4700.c 23 KB

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