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