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