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