Merge branch 'board-specific' of git://github.com/hzhuang1/linux into next/boards
[linux-2.6/btrfs-unstable.git] / arch / arm / mach-pxa / hx4700.c
blobf309bf975202e2cd89921092a33bb684f209f5df
1 /*
2 * Support for HP iPAQ hx4700 PDAs.
4 * Copyright (c) 2008-2009 Philipp Zabel
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>
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.
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 #include <linux/fb.h>
22 #include <linux/gpio.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/input.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/bq24022.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/regulator/max1586.h>
34 #include <linux/spi/ads7846.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/pxa2xx_spi.h>
37 #include <linux/usb/gpio_vbus.h>
38 #include <linux/i2c/pxa-i2c.h>
40 #include <mach/hardware.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
44 #include <mach/pxa27x.h>
45 #include <mach/hx4700.h>
46 #include <mach/irda.h>
48 #include <sound/ak4641.h>
49 #include <video/platform_lcd.h>
50 #include <video/w100fb.h>
52 #include "devices.h"
53 #include "generic.h"
55 /* Physical address space information */
57 #define ATI_W3220_PHYS PXA_CS2_PHYS /* ATI Imageon 3220 Graphics */
58 #define ASIC3_PHYS PXA_CS3_PHYS
59 #define ASIC3_SD_PHYS (PXA_CS3_PHYS + 0x02000000)
61 static unsigned long hx4700_pin_config[] __initdata = {
63 /* SDRAM and Static Memory I/O Signals */
64 GPIO20_nSDCS_2,
65 GPIO21_nSDCS_3,
66 GPIO15_nCS_1,
67 GPIO78_nCS_2, /* W3220 */
68 GPIO79_nCS_3, /* ASIC3 */
69 GPIO80_nCS_4,
70 GPIO33_nCS_5, /* EGPIO, WLAN */
72 /* PC CARD */
73 GPIO48_nPOE,
74 GPIO49_nPWE,
75 GPIO50_nPIOR,
76 GPIO51_nPIOW,
77 GPIO54_nPCE_2,
78 GPIO55_nPREG,
79 GPIO56_nPWAIT,
80 GPIO57_nIOIS16,
81 GPIO85_nPCE_1,
82 GPIO104_PSKTSEL,
84 /* I2C */
85 GPIO117_I2C_SCL,
86 GPIO118_I2C_SDA,
88 /* FFUART (RS-232) */
89 GPIO34_FFUART_RXD,
90 GPIO35_FFUART_CTS,
91 GPIO36_FFUART_DCD,
92 GPIO37_FFUART_DSR,
93 GPIO38_FFUART_RI,
94 GPIO39_FFUART_TXD,
95 GPIO40_FFUART_DTR,
96 GPIO41_FFUART_RTS,
98 /* BTUART */
99 GPIO42_BTUART_RXD,
100 GPIO43_BTUART_TXD_LPM_LOW,
101 GPIO44_BTUART_CTS,
102 GPIO45_BTUART_RTS_LPM_LOW,
104 /* PWM 1 (Backlight) */
105 GPIO17_PWM1_OUT,
107 /* I2S */
108 GPIO28_I2S_BITCLK_OUT,
109 GPIO29_I2S_SDATA_IN,
110 GPIO30_I2S_SDATA_OUT,
111 GPIO31_I2S_SYNC,
112 GPIO113_I2S_SYSCLK,
114 /* SSP 1 (NavPoint) */
115 GPIO23_SSP1_SCLK,
116 GPIO24_SSP1_SFRM,
117 GPIO25_SSP1_TXD,
118 GPIO26_SSP1_RXD,
120 /* SSP 2 (TSC2046) */
121 GPIO19_SSP2_SCLK,
122 GPIO86_SSP2_RXD,
123 GPIO87_SSP2_TXD,
124 GPIO88_GPIO,
126 /* HX4700 specific input GPIOs */
127 GPIO12_GPIO, /* ASIC3_IRQ */
128 GPIO13_GPIO, /* W3220_IRQ */
129 GPIO14_GPIO, /* nWLAN_IRQ */
131 GPIO10_GPIO, /* GSM_IRQ */
132 GPIO13_GPIO, /* CPLD_IRQ */
133 GPIO107_GPIO, /* DS1WM_IRQ */
134 GPIO108_GPIO, /* GSM_READY */
135 GPIO58_GPIO, /* TSC2046_nPENIRQ */
136 GPIO66_GPIO, /* nSDIO_IRQ */
140 * IRDA
143 static struct pxaficp_platform_data ficp_info = {
144 .gpio_pwdown = GPIO105_HX4700_nIR_ON,
145 .transceiver_cap = IR_SIRMODE | IR_OFF,
149 * GPIO Keys
152 #define INIT_KEY(_code, _gpio, _active_low, _desc) \
154 .code = KEY_##_code, \
155 .gpio = _gpio, \
156 .active_low = _active_low, \
157 .desc = _desc, \
158 .type = EV_KEY, \
159 .wakeup = 1, \
162 static struct gpio_keys_button gpio_keys_buttons[] = {
163 INIT_KEY(POWER, GPIO0_HX4700_nKEY_POWER, 1, "Power button"),
164 INIT_KEY(MAIL, GPIO94_HX4700_KEY_MAIL, 0, "Mail button"),
165 INIT_KEY(ADDRESSBOOK, GPIO99_HX4700_KEY_CONTACTS,0, "Contacts button"),
166 INIT_KEY(RECORD, GPIOD6_nKEY_RECORD, 1, "Record button"),
167 INIT_KEY(CALENDAR, GPIOD1_nKEY_CALENDAR, 1, "Calendar button"),
168 INIT_KEY(HOMEPAGE, GPIOD3_nKEY_HOME, 1, "Home button"),
171 static struct gpio_keys_platform_data gpio_keys_data = {
172 .buttons = gpio_keys_buttons,
173 .nbuttons = ARRAY_SIZE(gpio_keys_buttons),
176 static struct platform_device gpio_keys = {
177 .name = "gpio-keys",
178 .dev = {
179 .platform_data = &gpio_keys_data,
181 .id = -1,
185 * ASIC3
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),
208 ASIC3_CONFIG_GPIO(16, 1, 1, 0),
209 ASIC3_CONFIG_GPIO(17, 1, 1, 0),
210 ASIC3_CONFIG_GPIO(18, 1, 1, 0),
211 ASIC3_CONFIG_GPIO(19, 1, 1, 0),
212 ASIC3_CONFIG_GPIO(20, 1, 1, 0),
213 ASIC3_CONFIG_GPIO(21, 1, 1, 0),
214 ASIC3_CONFIG_GPIO(22, 1, 1, 0),
215 ASIC3_CONFIG_GPIO(23, 1, 1, 0),
216 ASIC3_CONFIG_GPIO(24, 1, 1, 0),
217 ASIC3_CONFIG_GPIO(25, 1, 1, 0),
218 ASIC3_CONFIG_GPIO(26, 1, 1, 0),
219 ASIC3_CONFIG_GPIO(27, 1, 1, 0),
220 ASIC3_CONFIG_GPIO(28, 1, 1, 0),
221 ASIC3_CONFIG_GPIO(29, 1, 1, 0),
222 ASIC3_CONFIG_GPIO(30, 1, 1, 0),
223 ASIC3_CONFIG_GPIO(31, 1, 1, 0),
225 /* GPIOC - CF, LEDs, SD */
226 ASIC3_GPIOC0_LED0, /* red */
227 ASIC3_GPIOC1_LED1, /* green */
228 ASIC3_GPIOC2_LED2, /* blue */
229 ASIC3_GPIOC4_CF_nCD,
230 ASIC3_GPIOC5_nCIOW,
231 ASIC3_GPIOC6_nCIOR,
232 ASIC3_GPIOC7_nPCE_1,
233 ASIC3_GPIOC8_nPCE_2,
234 ASIC3_GPIOC9_nPOE,
235 ASIC3_GPIOC10_nPWE,
236 ASIC3_GPIOC11_PSKTSEL,
237 ASIC3_GPIOC12_nPREG,
238 ASIC3_GPIOC13_nPWAIT,
239 ASIC3_GPIOC14_nPIOIS16,
240 ASIC3_GPIOC15_nPIOR,
242 /* GPIOD: input GPIOs, CF */
243 ASIC3_GPIOD11_nCIOIS16,
244 ASIC3_GPIOD12_nCWAIT,
245 ASIC3_GPIOD15_nPIOW,
248 static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
249 [0] = {
250 .name = "hx4700:amber",
251 .default_trigger = "ds2760-battery.0-charging-blink-full-solid",
253 [1] = {
254 .name = "hx4700:green",
255 .default_trigger = "unused",
257 [2] = {
258 .name = "hx4700:blue",
259 .default_trigger = "hx4700-radio",
263 static struct resource asic3_resources[] = {
264 /* GPIO part */
265 [0] = {
266 .start = ASIC3_PHYS,
267 .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
268 .flags = IORESOURCE_MEM,
270 [1] = {
271 .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
272 .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
273 .flags = IORESOURCE_IRQ,
275 /* SD part */
276 [2] = {
277 .start = ASIC3_SD_PHYS,
278 .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
279 .flags = IORESOURCE_MEM,
281 [3] = {
282 .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
283 .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
284 .flags = IORESOURCE_IRQ,
288 static struct asic3_platform_data asic3_platform_data = {
289 .gpio_config = asic3_gpio_config,
290 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
291 .irq_base = IRQ_BOARD_START,
292 .gpio_base = HX4700_ASIC3_GPIO_BASE,
293 .leds = asic3_leds,
296 static struct platform_device asic3 = {
297 .name = "asic3",
298 .id = -1,
299 .resource = asic3_resources,
300 .num_resources = ARRAY_SIZE(asic3_resources),
301 .dev = {
302 .platform_data = &asic3_platform_data,
307 * EGPIO
310 static struct resource egpio_resources[] = {
311 [0] = {
312 .start = PXA_CS5_PHYS,
313 .end = PXA_CS5_PHYS + 0x4 - 1,
314 .flags = IORESOURCE_MEM,
318 static struct htc_egpio_chip egpio_chips[] = {
319 [0] = {
320 .reg_start = 0,
321 .gpio_base = HX4700_EGPIO_BASE,
322 .num_gpios = 8,
323 .direction = HTC_EGPIO_OUTPUT,
327 static struct htc_egpio_platform_data egpio_info = {
328 .reg_width = 16,
329 .bus_width = 16,
330 .chip = egpio_chips,
331 .num_chips = ARRAY_SIZE(egpio_chips),
334 static struct platform_device egpio = {
335 .name = "htc-egpio",
336 .id = -1,
337 .resource = egpio_resources,
338 .num_resources = ARRAY_SIZE(egpio_resources),
339 .dev = {
340 .platform_data = &egpio_info,
345 * LCD - Sony display connected to ATI Imageon w3220
348 static void sony_lcd_init(void)
350 gpio_set_value(GPIO84_HX4700_LCD_SQN, 1);
351 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
352 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
353 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0);
354 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
355 mdelay(10);
356 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
357 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
358 mdelay(20);
360 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1);
361 mdelay(5);
362 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1);
364 /* FIXME: init w3220 registers here */
366 mdelay(5);
367 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1);
368 mdelay(10);
369 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1);
370 mdelay(10);
371 gpio_set_value(GPIO59_HX4700_LCD_PC1, 1);
372 mdelay(10);
373 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1);
376 static void sony_lcd_off(void)
378 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
379 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
380 mdelay(10);
381 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0);
382 mdelay(10);
383 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
384 mdelay(10);
385 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
388 #ifdef CONFIG_PM
389 static void w3220_lcd_suspend(struct w100fb_par *wfb)
391 sony_lcd_off();
394 static void w3220_lcd_resume(struct w100fb_par *wfb)
396 sony_lcd_init();
398 #else
399 #define w3220_lcd_resume NULL
400 #define w3220_lcd_suspend NULL
401 #endif
403 static struct w100_tg_info w3220_tg_info = {
404 .suspend = w3220_lcd_suspend,
405 .resume = w3220_lcd_resume,
408 /* W3220_VGA QVGA */
409 static struct w100_gen_regs w3220_regs = {
410 .lcd_format = 0x00000003,
411 .lcdd_cntl1 = 0x00000000,
412 .lcdd_cntl2 = 0x0003ffff,
413 .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */
414 .genlcd_cntl2 = 0x00000003,
415 .genlcd_cntl3 = 0x000102aa,
418 static struct w100_mode w3220_modes[] = {
420 .xres = 480,
421 .yres = 640,
422 .left_margin = 15,
423 .right_margin = 16,
424 .upper_margin = 8,
425 .lower_margin = 7,
426 .crtc_ss = 0x00000000,
427 .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */
428 .crtc_gs = 0xc0000000, /* 0x40000000 */
429 .crtc_vpos_gs = 0x0000028f,
430 .crtc_ps1_active = 0x00000000, /* 0x41060010 */
431 .crtc_rev = 0,
432 .crtc_dclk = 0x80000000,
433 .crtc_gclk = 0x040a0104,
434 .crtc_goe = 0,
435 .pll_freq = 95,
436 .pixclk_divider = 4,
437 .pixclk_divider_rotated = 4,
438 .pixclk_src = CLK_SRC_PLL,
439 .sysclk_divider = 0,
440 .sysclk_src = CLK_SRC_PLL,
443 .xres = 240,
444 .yres = 320,
445 .left_margin = 9,
446 .right_margin = 8,
447 .upper_margin = 5,
448 .lower_margin = 4,
449 .crtc_ss = 0x80150014,
450 .crtc_ls = 0xa0fb00f7,
451 .crtc_gs = 0xc0080007,
452 .crtc_vpos_gs = 0x00080007,
453 .crtc_rev = 0x0000000a,
454 .crtc_dclk = 0x81700030,
455 .crtc_gclk = 0x8015010f,
456 .crtc_goe = 0x00000000,
457 .pll_freq = 95,
458 .pixclk_divider = 4,
459 .pixclk_divider_rotated = 4,
460 .pixclk_src = CLK_SRC_PLL,
461 .sysclk_divider = 0,
462 .sysclk_src = CLK_SRC_PLL,
466 struct w100_mem_info w3220_mem_info = {
467 .ext_cntl = 0x09640011,
468 .sdram_mode_reg = 0x00600021,
469 .ext_timing_cntl = 0x1a001545, /* 0x15001545 */
470 .io_cntl = 0x7ddd7333,
471 .size = 0x1fffff,
474 struct w100_bm_mem_info w3220_bm_mem_info = {
475 .ext_mem_bw = 0x50413e01,
476 .offset = 0,
477 .ext_timing_ctl = 0x00043f7f,
478 .ext_cntl = 0x00000010,
479 .mode_reg = 0x00250000,
480 .io_cntl = 0x0fff0000,
481 .config = 0x08301480,
484 static struct w100_gpio_regs w3220_gpio_info = {
485 .init_data1 = 0xdfe00100, /* GPIO_DATA */
486 .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */
487 .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */
488 .init_data2 = 0x00000000, /* GPIO_DATA2 */
489 .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */
490 .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */
493 static struct w100fb_mach_info w3220_info = {
494 .tg = &w3220_tg_info,
495 .mem = &w3220_mem_info,
496 .bm_mem = &w3220_bm_mem_info,
497 .gpio = &w3220_gpio_info,
498 .regs = &w3220_regs,
499 .modelist = w3220_modes,
500 .num_modes = 2,
501 .xtal_freq = 16000000,
504 static struct resource w3220_resources[] = {
505 [0] = {
506 .start = ATI_W3220_PHYS,
507 .end = ATI_W3220_PHYS + 0x00ffffff,
508 .flags = IORESOURCE_MEM,
512 static struct platform_device w3220 = {
513 .name = "w100fb",
514 .id = -1,
515 .dev = {
516 .platform_data = &w3220_info,
518 .num_resources = ARRAY_SIZE(w3220_resources),
519 .resource = w3220_resources,
522 static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power)
524 if (power)
525 sony_lcd_init();
526 else
527 sony_lcd_off();
530 static struct plat_lcd_data hx4700_lcd_data = {
531 .set_power = hx4700_lcd_set_power,
534 static struct platform_device hx4700_lcd = {
535 .name = "platform-lcd",
536 .id = -1,
537 .dev = {
538 .platform_data = &hx4700_lcd_data,
539 .parent = &w3220.dev,
544 * Backlight
547 static struct platform_pwm_backlight_data backlight_data = {
548 .pwm_id = 1,
549 .max_brightness = 200,
550 .dft_brightness = 100,
551 .pwm_period_ns = 30923,
554 static struct platform_device backlight = {
555 .name = "pwm-backlight",
556 .id = -1,
557 .dev = {
558 .parent = &pxa27x_device_pwm1.dev,
559 .platform_data = &backlight_data,
564 * USB "Transceiver"
567 static struct gpio_vbus_mach_info gpio_vbus_info = {
568 .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
569 .gpio_vbus = GPIOD14_nUSBC_DETECT,
570 .gpio_vbus_inverted = 1,
573 static struct platform_device gpio_vbus = {
574 .name = "gpio-vbus",
575 .id = -1,
576 .dev = {
577 .platform_data = &gpio_vbus_info,
582 * Touchscreen - TSC2046 connected to SSP2
585 static const struct ads7846_platform_data tsc2046_info = {
586 .model = 7846,
587 .vref_delay_usecs = 100,
588 .pressure_max = 1024,
589 .debounce_max = 10,
590 .debounce_tol = 3,
591 .debounce_rep = 1,
592 .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ,
595 static struct pxa2xx_spi_chip tsc2046_chip = {
596 .tx_threshold = 1,
597 .rx_threshold = 2,
598 .timeout = 64,
599 .gpio_cs = GPIO88_HX4700_TSC2046_CS,
602 static struct spi_board_info tsc2046_board_info[] __initdata = {
604 .modalias = "ads7846",
605 .bus_num = 2,
606 .max_speed_hz = 2600000, /* 100 kHz sample rate */
607 .irq = PXA_GPIO_TO_IRQ(GPIO58_HX4700_TSC2046_nPENIRQ),
608 .platform_data = &tsc2046_info,
609 .controller_data = &tsc2046_chip,
613 static struct pxa2xx_spi_master pxa_ssp2_master_info = {
614 .num_chipselect = 1,
615 .clock_enable = CKEN_SSP2,
616 .enable_dma = 1,
620 * External power
623 static int power_supply_init(struct device *dev)
625 return gpio_request(GPIOD9_nAC_IN, "AC charger detect");
628 static int hx4700_is_ac_online(void)
630 return !gpio_get_value(GPIOD9_nAC_IN);
633 static void power_supply_exit(struct device *dev)
635 gpio_free(GPIOD9_nAC_IN);
638 static char *hx4700_supplicants[] = {
639 "ds2760-battery.0", "backup-battery"
642 static struct pda_power_pdata power_supply_info = {
643 .init = power_supply_init,
644 .is_ac_online = hx4700_is_ac_online,
645 .exit = power_supply_exit,
646 .supplied_to = hx4700_supplicants,
647 .num_supplicants = ARRAY_SIZE(hx4700_supplicants),
650 static struct resource power_supply_resources[] = {
651 [0] = {
652 .name = "ac",
653 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
654 IORESOURCE_IRQ_LOWEDGE,
655 .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
656 .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
658 [1] = {
659 .name = "usb",
660 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
661 IORESOURCE_IRQ_LOWEDGE,
662 .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
663 .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
667 static struct platform_device power_supply = {
668 .name = "pda-power",
669 .id = -1,
670 .dev = {
671 .platform_data = &power_supply_info,
673 .resource = power_supply_resources,
674 .num_resources = ARRAY_SIZE(power_supply_resources),
678 * Battery charger
681 static struct regulator_consumer_supply bq24022_consumers[] = {
683 .dev = &gpio_vbus.dev,
684 .supply = "vbus_draw",
687 .dev = &power_supply.dev,
688 .supply = "ac_draw",
692 static struct regulator_init_data bq24022_init_data = {
693 .constraints = {
694 .max_uA = 500000,
695 .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS,
697 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
698 .consumer_supplies = bq24022_consumers,
701 static struct bq24022_mach_info bq24022_info = {
702 .gpio_nce = GPIO72_HX4700_BQ24022_nCHARGE_EN,
703 .gpio_iset2 = GPIO96_HX4700_BQ24022_ISET2,
704 .init_data = &bq24022_init_data,
707 static struct platform_device bq24022 = {
708 .name = "bq24022",
709 .id = -1,
710 .dev = {
711 .platform_data = &bq24022_info,
716 * StrataFlash
719 static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
721 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
724 static struct resource strataflash_resource[] = {
725 [0] = DEFINE_RES_MEM(PXA_CS0_PHYS, SZ_64M),
726 [1] = DEFINE_RES_MEM(PXA_CS0_PHYS + SZ_64M, SZ_64M),
729 static struct physmap_flash_data strataflash_data = {
730 .width = 4,
731 .set_vpp = hx4700_set_vpp,
734 static struct platform_device strataflash = {
735 .name = "physmap-flash",
736 .id = -1,
737 .resource = strataflash_resource,
738 .num_resources = ARRAY_SIZE(strataflash_resource),
739 .dev = {
740 .platform_data = &strataflash_data,
745 * Maxim MAX1587A on PI2C
748 static struct regulator_consumer_supply max1587a_consumer = {
749 .supply = "vcc_core",
752 static struct regulator_init_data max1587a_v3_info = {
753 .constraints = {
754 .name = "vcc_core range",
755 .min_uV = 900000,
756 .max_uV = 1705000,
757 .always_on = 1,
758 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
760 .num_consumer_supplies = 1,
761 .consumer_supplies = &max1587a_consumer,
764 static struct max1586_subdev_data max1587a_subdev = {
765 .name = "vcc_core",
766 .id = MAX1586_V3,
767 .platform_data = &max1587a_v3_info,
770 static struct max1586_platform_data max1587a_info = {
771 .num_subdevs = 1,
772 .subdevs = &max1587a_subdev,
773 .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
776 static struct i2c_board_info __initdata pi2c_board_info[] = {
778 I2C_BOARD_INFO("max1586", 0x14),
779 .platform_data = &max1587a_info,
784 * Asahi Kasei AK4641 on I2C
787 static struct ak4641_platform_data ak4641_info = {
788 .gpio_power = GPIO27_HX4700_CODEC_ON,
789 .gpio_npdn = GPIO109_HX4700_CODEC_nPDN,
792 static struct i2c_board_info i2c_board_info[] __initdata = {
794 I2C_BOARD_INFO("ak4641", 0x12),
795 .platform_data = &ak4641_info,
799 static struct platform_device audio = {
800 .name = "hx4700-audio",
801 .id = -1,
806 * Platform devices
809 static struct platform_device *devices[] __initdata = {
810 &asic3,
811 &gpio_keys,
812 &backlight,
813 &w3220,
814 &hx4700_lcd,
815 &egpio,
816 &bq24022,
817 &gpio_vbus,
818 &power_supply,
819 &strataflash,
820 &audio,
823 static struct gpio global_gpios[] = {
824 { GPIO12_HX4700_ASIC3_IRQ, GPIOF_IN, "ASIC3_IRQ" },
825 { GPIO13_HX4700_W3220_IRQ, GPIOF_IN, "W3220_IRQ" },
826 { GPIO14_HX4700_nWLAN_IRQ, GPIOF_IN, "WLAN_IRQ" },
827 { GPIO59_HX4700_LCD_PC1, GPIOF_OUT_INIT_HIGH, "LCD_PC1" },
828 { GPIO62_HX4700_LCD_nRESET, GPIOF_OUT_INIT_HIGH, "LCD_RESET" },
829 { GPIO70_HX4700_LCD_SLIN1, GPIOF_OUT_INIT_HIGH, "LCD_SLIN1" },
830 { GPIO84_HX4700_LCD_SQN, GPIOF_OUT_INIT_HIGH, "LCD_SQN" },
831 { GPIO110_HX4700_LCD_LVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_LVDD" },
832 { GPIO111_HX4700_LCD_AVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_AVDD" },
833 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
834 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
835 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
838 static void __init hx4700_init(void)
840 int ret;
842 pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config));
843 ret = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
844 if (ret)
845 pr_err ("hx4700: Failed to request GPIOs.\n");
847 pxa_set_ffuart_info(NULL);
848 pxa_set_btuart_info(NULL);
849 pxa_set_stuart_info(NULL);
851 platform_add_devices(devices, ARRAY_SIZE(devices));
853 pxa_set_ficp_info(&ficp_info);
854 pxa27x_set_i2c_power_info(NULL);
855 pxa_set_i2c_info(NULL);
856 i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
857 i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
858 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
859 spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
861 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0);
862 mdelay(10);
863 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
864 mdelay(10);
867 MACHINE_START(H4700, "HP iPAQ HX4700")
868 .atag_offset = 0x100,
869 .map_io = pxa27x_map_io,
870 .nr_irqs = HX4700_NR_IRQS,
871 .init_irq = pxa27x_init_irq,
872 .handle_irq = pxa27x_handle_irq,
873 .init_machine = hx4700_init,
874 .timer = &pxa_timer,
875 .restart = pxa_restart,
876 MACHINE_END