blob: 208eef1c04858a8ec76c40adcaddc131e5b5fb7f [file] [log] [blame]
Philipp Zabeld3ca1952009-05-28 07:05:18 +02001/*
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
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>
Philipp Zabel6ea04142009-05-28 07:15:18 +020033#include <linux/regulator/max1586.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020034#include <linux/spi/ads7846.h>
35#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080036#include <linux/spi/pxa2xx_spi.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020037#include <linux/usb/gpio_vbus.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010038#include <linux/i2c/pxa-i2c.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020039
40#include <mach/hardware.h>
41#include <asm/mach-types.h>
42#include <asm/mach/arch.h>
43
44#include <mach/pxa27x.h>
45#include <mach/hx4700.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020046#include <mach/irda.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020047
Axel Lind87f6142011-12-30 12:06:11 +080048#include <sound/ak4641.h>
Philipp Zabele2c509c2009-08-07 17:01:04 +020049#include <video/platform_lcd.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020050#include <video/w100fb.h>
51
52#include "devices.h"
53#include "generic.h"
54
55/* Physical address space information */
56
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)
60
61static unsigned long hx4700_pin_config[] __initdata = {
62
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 */
71
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,
83
84 /* I2C */
85 GPIO117_I2C_SCL,
86 GPIO118_I2C_SDA,
87
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,
97
98 /* BTUART */
99 GPIO42_BTUART_RXD,
100 GPIO43_BTUART_TXD,
101 GPIO44_BTUART_CTS,
102 GPIO45_BTUART_RTS,
103
104 /* PWM 1 (Backlight) */
105 GPIO17_PWM1_OUT,
106
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,
113
114 /* SSP 1 (NavPoint) */
115 GPIO23_SSP1_SCLK,
116 GPIO24_SSP1_SFRM,
117 GPIO25_SSP1_TXD,
118 GPIO26_SSP1_RXD,
119
120 /* SSP 2 (TSC2046) */
121 GPIO19_SSP2_SCLK,
122 GPIO86_SSP2_RXD,
123 GPIO87_SSP2_TXD,
124 GPIO88_GPIO,
125
126 /* HX4700 specific input GPIOs */
127 GPIO12_GPIO, /* ASIC3_IRQ */
128 GPIO13_GPIO, /* W3220_IRQ */
129 GPIO14_GPIO, /* nWLAN_IRQ */
130
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 */
137};
138
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200139/*
140 * IRDA
141 */
142
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200143static struct pxaficp_platform_data ficp_info = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200144 .gpio_pwdown = GPIO105_HX4700_nIR_ON,
145 .transceiver_cap = IR_SIRMODE | IR_OFF,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200146};
147
148/*
149 * GPIO Keys
150 */
151
152#define INIT_KEY(_code, _gpio, _active_low, _desc) \
153 { \
154 .code = KEY_##_code, \
155 .gpio = _gpio, \
156 .active_low = _active_low, \
157 .desc = _desc, \
158 .type = EV_KEY, \
159 .wakeup = 1, \
160 }
161
162static 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"),
169};
170
171static struct gpio_keys_platform_data gpio_keys_data = {
172 .buttons = gpio_keys_buttons,
173 .nbuttons = ARRAY_SIZE(gpio_keys_buttons),
174};
175
176static struct platform_device gpio_keys = {
177 .name = "gpio-keys",
178 .dev = {
179 .platform_data = &gpio_keys_data,
180 },
181 .id = -1,
182};
183
184/*
185 * ASIC3
186 */
187
188static 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
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),
224
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,
241
242 /* GPIOD: input GPIOs, CF */
243 ASIC3_GPIOD11_nCIOIS16,
244 ASIC3_GPIOD12_nCWAIT,
245 ASIC3_GPIOD15_nPIOW,
246};
247
248static struct resource asic3_resources[] = {
249 /* GPIO part */
250 [0] = {
251 .start = ASIC3_PHYS,
252 .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
253 .flags = IORESOURCE_MEM,
254 },
255 [1] = {
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800256 .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
257 .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200258 .flags = IORESOURCE_IRQ,
259 },
260 /* SD part */
261 [2] = {
262 .start = ASIC3_SD_PHYS,
263 .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
264 .flags = IORESOURCE_MEM,
265 },
266 [3] = {
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800267 .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
268 .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200269 .flags = IORESOURCE_IRQ,
270 },
271};
272
273static struct asic3_platform_data asic3_platform_data = {
274 .gpio_config = asic3_gpio_config,
275 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
276 .irq_base = IRQ_BOARD_START,
277 .gpio_base = HX4700_ASIC3_GPIO_BASE,
278};
279
280static 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/*
291 * EGPIO
292 */
293
294static struct resource egpio_resources[] = {
295 [0] = {
296 .start = PXA_CS5_PHYS,
297 .end = PXA_CS5_PHYS + 0x4 - 1,
298 .flags = IORESOURCE_MEM,
299 },
300};
301
302static struct htc_egpio_chip egpio_chips[] = {
303 [0] = {
304 .reg_start = 0,
305 .gpio_base = HX4700_EGPIO_BASE,
306 .num_gpios = 8,
307 .direction = HTC_EGPIO_OUTPUT,
308 },
309};
310
311static struct htc_egpio_platform_data egpio_info = {
312 .reg_width = 16,
313 .bus_width = 16,
314 .chip = egpio_chips,
315 .num_chips = ARRAY_SIZE(egpio_chips),
316};
317
318static struct platform_device egpio = {
319 .name = "htc-egpio",
320 .id = -1,
321 .resource = egpio_resources,
322 .num_resources = ARRAY_SIZE(egpio_resources),
323 .dev = {
324 .platform_data = &egpio_info,
325 },
326};
327
328/*
329 * LCD - Sony display connected to ATI Imageon w3220
330 */
331
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200332static void sony_lcd_init(void)
333{
334 gpio_set_value(GPIO84_HX4700_LCD_SQN, 1);
335 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
336 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
337 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0);
338 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
339 mdelay(10);
340 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
341 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
342 mdelay(20);
343
344 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1);
345 mdelay(5);
346 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1);
347
348 /* FIXME: init w3220 registers here */
349
350 mdelay(5);
351 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1);
352 mdelay(10);
353 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1);
354 mdelay(10);
355 gpio_set_value(GPIO59_HX4700_LCD_PC1, 1);
356 mdelay(10);
357 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1);
358}
359
360static void sony_lcd_off(void)
361{
362 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
363 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
364 mdelay(10);
365 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0);
366 mdelay(10);
367 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
368 mdelay(10);
369 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
370}
371
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200372#ifdef CONFIG_PM
373static void w3220_lcd_suspend(struct w100fb_par *wfb)
374{
375 sony_lcd_off();
376}
377
378static void w3220_lcd_resume(struct w100fb_par *wfb)
379{
380 sony_lcd_init();
381}
382#else
383#define w3220_lcd_resume NULL
384#define w3220_lcd_suspend NULL
385#endif
386
387static struct w100_tg_info w3220_tg_info = {
388 .suspend = w3220_lcd_suspend,
389 .resume = w3220_lcd_resume,
390};
391
392/* W3220_VGA QVGA */
393static struct w100_gen_regs w3220_regs = {
394 .lcd_format = 0x00000003,
395 .lcdd_cntl1 = 0x00000000,
396 .lcdd_cntl2 = 0x0003ffff,
397 .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */
398 .genlcd_cntl2 = 0x00000003,
399 .genlcd_cntl3 = 0x000102aa,
400};
401
402static struct w100_mode w3220_modes[] = {
403{
404 .xres = 480,
405 .yres = 640,
406 .left_margin = 15,
407 .right_margin = 16,
408 .upper_margin = 8,
409 .lower_margin = 7,
410 .crtc_ss = 0x00000000,
411 .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */
412 .crtc_gs = 0xc0000000, /* 0x40000000 */
413 .crtc_vpos_gs = 0x0000028f,
414 .crtc_ps1_active = 0x00000000, /* 0x41060010 */
415 .crtc_rev = 0,
416 .crtc_dclk = 0x80000000,
417 .crtc_gclk = 0x040a0104,
418 .crtc_goe = 0,
419 .pll_freq = 95,
420 .pixclk_divider = 4,
421 .pixclk_divider_rotated = 4,
422 .pixclk_src = CLK_SRC_PLL,
423 .sysclk_divider = 0,
424 .sysclk_src = CLK_SRC_PLL,
425},
426{
427 .xres = 240,
428 .yres = 320,
429 .left_margin = 9,
430 .right_margin = 8,
431 .upper_margin = 5,
432 .lower_margin = 4,
433 .crtc_ss = 0x80150014,
434 .crtc_ls = 0xa0fb00f7,
435 .crtc_gs = 0xc0080007,
436 .crtc_vpos_gs = 0x00080007,
437 .crtc_rev = 0x0000000a,
438 .crtc_dclk = 0x81700030,
439 .crtc_gclk = 0x8015010f,
440 .crtc_goe = 0x00000000,
441 .pll_freq = 95,
442 .pixclk_divider = 4,
443 .pixclk_divider_rotated = 4,
444 .pixclk_src = CLK_SRC_PLL,
445 .sysclk_divider = 0,
446 .sysclk_src = CLK_SRC_PLL,
447},
448};
449
450struct w100_mem_info w3220_mem_info = {
451 .ext_cntl = 0x09640011,
452 .sdram_mode_reg = 0x00600021,
453 .ext_timing_cntl = 0x1a001545, /* 0x15001545 */
454 .io_cntl = 0x7ddd7333,
455 .size = 0x1fffff,
456};
457
458struct w100_bm_mem_info w3220_bm_mem_info = {
459 .ext_mem_bw = 0x50413e01,
460 .offset = 0,
461 .ext_timing_ctl = 0x00043f7f,
462 .ext_cntl = 0x00000010,
463 .mode_reg = 0x00250000,
464 .io_cntl = 0x0fff0000,
465 .config = 0x08301480,
466};
467
468static struct w100_gpio_regs w3220_gpio_info = {
469 .init_data1 = 0xdfe00100, /* GPIO_DATA */
470 .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */
471 .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */
472 .init_data2 = 0x00000000, /* GPIO_DATA2 */
473 .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */
474 .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */
475};
476
477static struct w100fb_mach_info w3220_info = {
478 .tg = &w3220_tg_info,
479 .mem = &w3220_mem_info,
480 .bm_mem = &w3220_bm_mem_info,
481 .gpio = &w3220_gpio_info,
482 .regs = &w3220_regs,
483 .modelist = w3220_modes,
484 .num_modes = 2,
485 .xtal_freq = 16000000,
486};
487
488static struct resource w3220_resources[] = {
489 [0] = {
490 .start = ATI_W3220_PHYS,
491 .end = ATI_W3220_PHYS + 0x00ffffff,
492 .flags = IORESOURCE_MEM,
493 },
494};
495
496static struct platform_device w3220 = {
497 .name = "w100fb",
498 .id = -1,
499 .dev = {
500 .platform_data = &w3220_info,
501 },
502 .num_resources = ARRAY_SIZE(w3220_resources),
503 .resource = w3220_resources,
504};
505
Philipp Zabele2c509c2009-08-07 17:01:04 +0200506static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power)
507{
508 if (power)
509 sony_lcd_init();
510 else
511 sony_lcd_off();
512}
513
514static struct plat_lcd_data hx4700_lcd_data = {
515 .set_power = hx4700_lcd_set_power,
516};
517
518static struct platform_device hx4700_lcd = {
519 .name = "platform-lcd",
520 .id = -1,
521 .dev = {
522 .platform_data = &hx4700_lcd_data,
523 .parent = &w3220.dev,
524 },
525};
526
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200527/*
528 * Backlight
529 */
530
531static struct platform_pwm_backlight_data backlight_data = {
532 .pwm_id = 1,
533 .max_brightness = 200,
534 .dft_brightness = 100,
535 .pwm_period_ns = 30923,
536};
537
538static struct platform_device backlight = {
539 .name = "pwm-backlight",
540 .id = -1,
541 .dev = {
542 .parent = &pxa27x_device_pwm1.dev,
543 .platform_data = &backlight_data,
544 },
545};
546
547/*
548 * USB "Transceiver"
549 */
550
551static struct gpio_vbus_mach_info gpio_vbus_info = {
552 .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
553 .gpio_vbus = GPIOD14_nUSBC_DETECT,
554 .gpio_vbus_inverted = 1,
555};
556
557static struct platform_device gpio_vbus = {
558 .name = "gpio-vbus",
559 .id = -1,
560 .dev = {
561 .platform_data = &gpio_vbus_info,
562 },
563};
564
565/*
566 * Touchscreen - TSC2046 connected to SSP2
567 */
568
569static const struct ads7846_platform_data tsc2046_info = {
570 .model = 7846,
571 .vref_delay_usecs = 100,
Paul Parsons10d5d992009-11-14 16:54:12 +0000572 .pressure_max = 1024,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200573 .debounce_max = 10,
574 .debounce_tol = 3,
575 .debounce_rep = 1,
576 .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ,
577};
578
579static struct pxa2xx_spi_chip tsc2046_chip = {
580 .tx_threshold = 1,
581 .rx_threshold = 2,
582 .timeout = 64,
583 .gpio_cs = GPIO88_HX4700_TSC2046_CS,
584};
585
586static struct spi_board_info tsc2046_board_info[] __initdata = {
587 {
588 .modalias = "ads7846",
589 .bus_num = 2,
590 .max_speed_hz = 2600000, /* 100 kHz sample rate */
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800591 .irq = PXA_GPIO_TO_IRQ(GPIO58_HX4700_TSC2046_nPENIRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200592 .platform_data = &tsc2046_info,
593 .controller_data = &tsc2046_chip,
594 },
595};
596
597static struct pxa2xx_spi_master pxa_ssp2_master_info = {
598 .num_chipselect = 1,
599 .clock_enable = CKEN_SSP2,
600 .enable_dma = 1,
601};
602
603/*
604 * External power
605 */
606
607static int power_supply_init(struct device *dev)
608{
609 return gpio_request(GPIOD9_nAC_IN, "AC charger detect");
610}
611
612static int hx4700_is_ac_online(void)
613{
614 return !gpio_get_value(GPIOD9_nAC_IN);
615}
616
617static void power_supply_exit(struct device *dev)
618{
619 gpio_free(GPIOD9_nAC_IN);
620}
621
622static char *hx4700_supplicants[] = {
623 "ds2760-battery.0", "backup-battery"
624};
625
626static struct pda_power_pdata power_supply_info = {
627 .init = power_supply_init,
628 .is_ac_online = hx4700_is_ac_online,
629 .exit = power_supply_exit,
630 .supplied_to = hx4700_supplicants,
631 .num_supplicants = ARRAY_SIZE(hx4700_supplicants),
632};
633
634static struct resource power_supply_resources[] = {
635 [0] = {
636 .name = "ac",
637 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
638 IORESOURCE_IRQ_LOWEDGE,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800639 .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
640 .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200641 },
642 [1] = {
643 .name = "usb",
644 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
645 IORESOURCE_IRQ_LOWEDGE,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800646 .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
647 .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200648 },
649};
650
651static struct platform_device power_supply = {
652 .name = "pda-power",
653 .id = -1,
654 .dev = {
655 .platform_data = &power_supply_info,
656 },
657 .resource = power_supply_resources,
658 .num_resources = ARRAY_SIZE(power_supply_resources),
659};
660
661/*
662 * Battery charger
663 */
664
665static struct regulator_consumer_supply bq24022_consumers[] = {
666 {
667 .dev = &gpio_vbus.dev,
668 .supply = "vbus_draw",
669 },
670 {
671 .dev = &power_supply.dev,
672 .supply = "ac_draw",
673 },
674};
675
676static struct regulator_init_data bq24022_init_data = {
677 .constraints = {
678 .max_uA = 500000,
Paul Parsons745b1f4f2011-04-15 14:39:27 +0000679 .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200680 },
681 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
682 .consumer_supplies = bq24022_consumers,
683};
684
685static struct bq24022_mach_info bq24022_info = {
686 .gpio_nce = GPIO72_HX4700_BQ24022_nCHARGE_EN,
687 .gpio_iset2 = GPIO96_HX4700_BQ24022_ISET2,
688 .init_data = &bq24022_init_data,
689};
690
691static struct platform_device bq24022 = {
692 .name = "bq24022",
693 .id = -1,
694 .dev = {
695 .platform_data = &bq24022_info,
696 },
697};
698
699/*
700 * StrataFlash
701 */
702
Marc Zyngier667f3902011-05-18 10:51:55 +0100703static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200704{
705 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
706}
707
708static struct resource strataflash_resource = {
709 .start = PXA_CS0_PHYS,
710 .end = PXA_CS0_PHYS + SZ_128M - 1,
711 .flags = IORESOURCE_MEM,
712};
713
714static struct physmap_flash_data strataflash_data = {
715 .width = 4,
716 .set_vpp = hx4700_set_vpp,
717};
718
719static struct platform_device strataflash = {
720 .name = "physmap-flash",
721 .id = -1,
722 .resource = &strataflash_resource,
723 .num_resources = 1,
724 .dev = {
725 .platform_data = &strataflash_data,
726 },
727};
728
729/*
Philipp Zabel6ea04142009-05-28 07:15:18 +0200730 * Maxim MAX1587A on PI2C
731 */
732
733static struct regulator_consumer_supply max1587a_consumer = {
734 .supply = "vcc_core",
735};
736
737static struct regulator_init_data max1587a_v3_info = {
738 .constraints = {
739 .name = "vcc_core range",
740 .min_uV = 900000,
741 .max_uV = 1705000,
742 .always_on = 1,
743 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
744 },
745 .num_consumer_supplies = 1,
746 .consumer_supplies = &max1587a_consumer,
747};
748
749static struct max1586_subdev_data max1587a_subdev = {
750 .name = "vcc_core",
751 .id = MAX1586_V3,
752 .platform_data = &max1587a_v3_info,
753};
754
755static struct max1586_platform_data max1587a_info = {
756 .num_subdevs = 1,
757 .subdevs = &max1587a_subdev,
758 .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
759};
760
761static struct i2c_board_info __initdata pi2c_board_info[] = {
762 {
763 I2C_BOARD_INFO("max1586", 0x14),
764 .platform_data = &max1587a_info,
765 },
766};
767
768/*
Axel Lind87f6142011-12-30 12:06:11 +0800769 * Asahi Kasei AK4641 on I2C
770 */
771
772static struct ak4641_platform_data ak4641_info = {
773 .gpio_power = GPIO27_HX4700_CODEC_ON,
774 .gpio_npdn = GPIO109_HX4700_CODEC_nPDN,
775};
776
777static struct i2c_board_info i2c_board_info[] __initdata = {
778 {
779 I2C_BOARD_INFO("ak4641", 0x12),
780 .platform_data = &ak4641_info,
781 },
782};
783
784static struct platform_device audio = {
785 .name = "hx4700-audio",
786 .id = -1,
787};
788
789
790/*
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200791 * PCMCIA
792 */
793
794static struct platform_device pcmcia = {
795 .name = "hx4700-pcmcia",
796 .dev = {
797 .parent = &asic3.dev,
798 },
799};
800
801/*
802 * Platform devices
803 */
804
805static struct platform_device *devices[] __initdata = {
806 &asic3,
807 &gpio_keys,
808 &backlight,
809 &w3220,
Dmitry Artamonow19d6c132009-11-25 14:33:15 +0300810 &hx4700_lcd,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200811 &egpio,
812 &bq24022,
813 &gpio_vbus,
814 &power_supply,
815 &strataflash,
Axel Lind87f6142011-12-30 12:06:11 +0800816 &audio,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200817 &pcmcia,
818};
819
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200820static struct gpio global_gpios[] = {
821 { GPIO12_HX4700_ASIC3_IRQ, GPIOF_IN, "ASIC3_IRQ" },
822 { GPIO13_HX4700_W3220_IRQ, GPIOF_IN, "W3220_IRQ" },
823 { GPIO14_HX4700_nWLAN_IRQ, GPIOF_IN, "WLAN_IRQ" },
824 { GPIO59_HX4700_LCD_PC1, GPIOF_OUT_INIT_HIGH, "LCD_PC1" },
825 { GPIO62_HX4700_LCD_nRESET, GPIOF_OUT_INIT_HIGH, "LCD_RESET" },
826 { GPIO70_HX4700_LCD_SLIN1, GPIOF_OUT_INIT_HIGH, "LCD_SLIN1" },
827 { GPIO84_HX4700_LCD_SQN, GPIOF_OUT_INIT_HIGH, "LCD_SQN" },
828 { GPIO110_HX4700_LCD_LVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_LVDD" },
829 { GPIO111_HX4700_LCD_AVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_AVDD" },
830 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
831 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
832 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
833 { GPIO105_HX4700_nIR_ON, GPIOF_OUT_INIT_HIGH, "nIR_EN" },
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200834};
835
836static void __init hx4700_init(void)
837{
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200838 int ret;
839
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200840 pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config));
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200841 ret = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
842 if (ret)
843 pr_err ("hx4700: Failed to request GPIOs.\n");
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200844
Russell Kingcc155c62009-11-09 13:34:08 +0800845 pxa_set_ffuart_info(NULL);
846 pxa_set_btuart_info(NULL);
847 pxa_set_stuart_info(NULL);
848
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200849 platform_add_devices(devices, ARRAY_SIZE(devices));
850
851 pxa_set_ficp_info(&ficp_info);
852 pxa27x_set_i2c_power_info(NULL);
853 pxa_set_i2c_info(NULL);
Axel Lind87f6142011-12-30 12:06:11 +0800854 i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
Philipp Zabel6ea04142009-05-28 07:15:18 +0200855 i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200856 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
857 spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
858
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200859 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0);
860 mdelay(10);
861 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
862 mdelay(10);
863}
864
865MACHINE_START(H4700, "HP iPAQ HX4700")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400866 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200867 .map_io = pxa27x_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800868 .nr_irqs = HX4700_NR_IRQS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200869 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800870 .handle_irq = pxa27x_handle_irq,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200871 .init_machine = hx4700_init,
872 .timer = &pxa_timer,
Russell King271a74f2011-11-04 14:15:53 +0000873 .restart = pxa_restart,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200874MACHINE_END