hx4700.c 19 KB

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