blob: 865f6d37372e32e24681a132482eb50235387455 [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>
Paul Parsonsb2596c62012-05-12 12:31:02 +010025#include <linux/input/navpoint.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020026#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>
Heiko Stübner6967cca2012-03-02 13:56:38 +010032#include <linux/regulator/driver.h>
33#include <linux/regulator/gpio-regulator.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020034#include <linux/regulator/machine.h>
Philipp Zabel6ea04142009-05-28 07:15:18 +020035#include <linux/regulator/max1586.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020036#include <linux/spi/ads7846.h>
37#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080038#include <linux/spi/pxa2xx_spi.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020039#include <linux/usb/gpio_vbus.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010040#include <linux/i2c/pxa-i2c.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020041
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>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020048#include <mach/irda.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020049
Axel Lind87f6142011-12-30 12:06:11 +080050#include <sound/ak4641.h>
Philipp Zabele2c509c2009-08-07 17:01:04 +020051#include <video/platform_lcd.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020052#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
63static 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,
Paul Parsonscd419cf2012-03-11 13:23:42 +0000102 GPIO43_BTUART_TXD_LPM_LOW,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200103 GPIO44_BTUART_CTS,
Paul Parsonscd419cf2012-03-11 13:23:42 +0000104 GPIO45_BTUART_RTS_LPM_LOW,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200105
106 /* PWM 1 (Backlight) */
107 GPIO17_PWM1_OUT,
108
109 /* I2S */
110 GPIO28_I2S_BITCLK_OUT,
111 GPIO29_I2S_SDATA_IN,
112 GPIO30_I2S_SDATA_OUT,
113 GPIO31_I2S_SYNC,
114 GPIO113_I2S_SYSCLK,
115
116 /* SSP 1 (NavPoint) */
Paul Parsonsb2596c62012-05-12 12:31:02 +0100117 GPIO23_SSP1_SCLK_IN,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200118 GPIO24_SSP1_SFRM,
119 GPIO25_SSP1_TXD,
120 GPIO26_SSP1_RXD,
121
122 /* SSP 2 (TSC2046) */
123 GPIO19_SSP2_SCLK,
124 GPIO86_SSP2_RXD,
125 GPIO87_SSP2_TXD,
126 GPIO88_GPIO,
127
128 /* HX4700 specific input GPIOs */
129 GPIO12_GPIO, /* ASIC3_IRQ */
130 GPIO13_GPIO, /* W3220_IRQ */
131 GPIO14_GPIO, /* nWLAN_IRQ */
132
Paul Parsonsb2596c62012-05-12 12:31:02 +0100133 /* HX4700 specific output GPIOs */
134 GPIO102_GPIO | MFP_LPM_DRIVE_LOW, /* SYNAPTICS_POWER_ON */
135
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200136 GPIO10_GPIO, /* GSM_IRQ */
137 GPIO13_GPIO, /* CPLD_IRQ */
138 GPIO107_GPIO, /* DS1WM_IRQ */
139 GPIO108_GPIO, /* GSM_READY */
140 GPIO58_GPIO, /* TSC2046_nPENIRQ */
141 GPIO66_GPIO, /* nSDIO_IRQ */
142};
143
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200144/*
145 * IRDA
146 */
147
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200148static struct pxaficp_platform_data ficp_info = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200149 .gpio_pwdown = GPIO105_HX4700_nIR_ON,
150 .transceiver_cap = IR_SIRMODE | IR_OFF,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200151};
152
153/*
154 * GPIO Keys
155 */
156
157#define INIT_KEY(_code, _gpio, _active_low, _desc) \
158 { \
159 .code = KEY_##_code, \
160 .gpio = _gpio, \
161 .active_low = _active_low, \
162 .desc = _desc, \
163 .type = EV_KEY, \
164 .wakeup = 1, \
165 }
166
167static struct gpio_keys_button gpio_keys_buttons[] = {
168 INIT_KEY(POWER, GPIO0_HX4700_nKEY_POWER, 1, "Power button"),
169 INIT_KEY(MAIL, GPIO94_HX4700_KEY_MAIL, 0, "Mail button"),
170 INIT_KEY(ADDRESSBOOK, GPIO99_HX4700_KEY_CONTACTS,0, "Contacts button"),
171 INIT_KEY(RECORD, GPIOD6_nKEY_RECORD, 1, "Record button"),
172 INIT_KEY(CALENDAR, GPIOD1_nKEY_CALENDAR, 1, "Calendar button"),
173 INIT_KEY(HOMEPAGE, GPIOD3_nKEY_HOME, 1, "Home button"),
174};
175
176static struct gpio_keys_platform_data gpio_keys_data = {
177 .buttons = gpio_keys_buttons,
178 .nbuttons = ARRAY_SIZE(gpio_keys_buttons),
179};
180
181static struct platform_device gpio_keys = {
182 .name = "gpio-keys",
183 .dev = {
184 .platform_data = &gpio_keys_data,
185 },
186 .id = -1,
187};
188
189/*
Paul Parsonsb2596c62012-05-12 12:31:02 +0100190 * Synaptics NavPoint connected to SSP1
191 */
192
193static struct navpoint_platform_data navpoint_platform_data = {
194 .port = 1,
195 .gpio = GPIO102_HX4700_SYNAPTICS_POWER_ON,
196};
197
198static struct platform_device navpoint = {
199 .name = "navpoint",
200 .id = -1,
201 .dev = {
202 .platform_data = &navpoint_platform_data,
203 },
204};
205
206/*
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200207 * ASIC3
208 */
209
210static u16 asic3_gpio_config[] = {
211 /* ASIC3 GPIO banks A and B along with some of C and D
212 implement the buffering for the CF slot. */
213 ASIC3_CONFIG_GPIO(0, 1, 1, 0),
214 ASIC3_CONFIG_GPIO(1, 1, 1, 0),
215 ASIC3_CONFIG_GPIO(2, 1, 1, 0),
216 ASIC3_CONFIG_GPIO(3, 1, 1, 0),
217 ASIC3_CONFIG_GPIO(4, 1, 1, 0),
218 ASIC3_CONFIG_GPIO(5, 1, 1, 0),
219 ASIC3_CONFIG_GPIO(6, 1, 1, 0),
220 ASIC3_CONFIG_GPIO(7, 1, 1, 0),
221 ASIC3_CONFIG_GPIO(8, 1, 1, 0),
222 ASIC3_CONFIG_GPIO(9, 1, 1, 0),
223 ASIC3_CONFIG_GPIO(10, 1, 1, 0),
224 ASIC3_CONFIG_GPIO(11, 1, 1, 0),
225 ASIC3_CONFIG_GPIO(12, 1, 1, 0),
226 ASIC3_CONFIG_GPIO(13, 1, 1, 0),
227 ASIC3_CONFIG_GPIO(14, 1, 1, 0),
228 ASIC3_CONFIG_GPIO(15, 1, 1, 0),
229
230 ASIC3_CONFIG_GPIO(16, 1, 1, 0),
231 ASIC3_CONFIG_GPIO(17, 1, 1, 0),
232 ASIC3_CONFIG_GPIO(18, 1, 1, 0),
233 ASIC3_CONFIG_GPIO(19, 1, 1, 0),
234 ASIC3_CONFIG_GPIO(20, 1, 1, 0),
235 ASIC3_CONFIG_GPIO(21, 1, 1, 0),
236 ASIC3_CONFIG_GPIO(22, 1, 1, 0),
237 ASIC3_CONFIG_GPIO(23, 1, 1, 0),
238 ASIC3_CONFIG_GPIO(24, 1, 1, 0),
239 ASIC3_CONFIG_GPIO(25, 1, 1, 0),
240 ASIC3_CONFIG_GPIO(26, 1, 1, 0),
241 ASIC3_CONFIG_GPIO(27, 1, 1, 0),
242 ASIC3_CONFIG_GPIO(28, 1, 1, 0),
243 ASIC3_CONFIG_GPIO(29, 1, 1, 0),
244 ASIC3_CONFIG_GPIO(30, 1, 1, 0),
245 ASIC3_CONFIG_GPIO(31, 1, 1, 0),
246
247 /* GPIOC - CF, LEDs, SD */
248 ASIC3_GPIOC0_LED0, /* red */
249 ASIC3_GPIOC1_LED1, /* green */
250 ASIC3_GPIOC2_LED2, /* blue */
251 ASIC3_GPIOC4_CF_nCD,
252 ASIC3_GPIOC5_nCIOW,
253 ASIC3_GPIOC6_nCIOR,
254 ASIC3_GPIOC7_nPCE_1,
255 ASIC3_GPIOC8_nPCE_2,
256 ASIC3_GPIOC9_nPOE,
257 ASIC3_GPIOC10_nPWE,
258 ASIC3_GPIOC11_PSKTSEL,
259 ASIC3_GPIOC12_nPREG,
260 ASIC3_GPIOC13_nPWAIT,
261 ASIC3_GPIOC14_nPIOIS16,
262 ASIC3_GPIOC15_nPIOR,
263
264 /* GPIOD: input GPIOs, CF */
265 ASIC3_GPIOD11_nCIOIS16,
266 ASIC3_GPIOD12_nCWAIT,
267 ASIC3_GPIOD15_nPIOW,
268};
269
Paul Parsons91cb8ee2011-06-22 19:31:49 +0000270static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
271 [0] = {
272 .name = "hx4700:amber",
273 .default_trigger = "ds2760-battery.0-charging-blink-full-solid",
274 },
275 [1] = {
276 .name = "hx4700:green",
277 .default_trigger = "unused",
278 },
279 [2] = {
280 .name = "hx4700:blue",
281 .default_trigger = "hx4700-radio",
282 },
283};
284
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200285static struct resource asic3_resources[] = {
286 /* GPIO part */
287 [0] = {
288 .start = ASIC3_PHYS,
289 .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
290 .flags = IORESOURCE_MEM,
291 },
292 [1] = {
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800293 .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
294 .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200295 .flags = IORESOURCE_IRQ,
296 },
297 /* SD part */
298 [2] = {
299 .start = ASIC3_SD_PHYS,
300 .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
301 .flags = IORESOURCE_MEM,
302 },
303 [3] = {
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800304 .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
305 .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200306 .flags = IORESOURCE_IRQ,
307 },
308};
309
310static struct asic3_platform_data asic3_platform_data = {
311 .gpio_config = asic3_gpio_config,
312 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
313 .irq_base = IRQ_BOARD_START,
314 .gpio_base = HX4700_ASIC3_GPIO_BASE,
Paul Parsons91cb8ee2011-06-22 19:31:49 +0000315 .leds = asic3_leds,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200316};
317
318static struct platform_device asic3 = {
319 .name = "asic3",
320 .id = -1,
321 .resource = asic3_resources,
322 .num_resources = ARRAY_SIZE(asic3_resources),
323 .dev = {
324 .platform_data = &asic3_platform_data,
325 },
326};
327
328/*
329 * EGPIO
330 */
331
332static struct resource egpio_resources[] = {
333 [0] = {
334 .start = PXA_CS5_PHYS,
335 .end = PXA_CS5_PHYS + 0x4 - 1,
336 .flags = IORESOURCE_MEM,
337 },
338};
339
340static struct htc_egpio_chip egpio_chips[] = {
341 [0] = {
342 .reg_start = 0,
343 .gpio_base = HX4700_EGPIO_BASE,
344 .num_gpios = 8,
345 .direction = HTC_EGPIO_OUTPUT,
346 },
347};
348
349static struct htc_egpio_platform_data egpio_info = {
350 .reg_width = 16,
351 .bus_width = 16,
352 .chip = egpio_chips,
353 .num_chips = ARRAY_SIZE(egpio_chips),
354};
355
356static struct platform_device egpio = {
357 .name = "htc-egpio",
358 .id = -1,
359 .resource = egpio_resources,
360 .num_resources = ARRAY_SIZE(egpio_resources),
361 .dev = {
362 .platform_data = &egpio_info,
363 },
364};
365
366/*
367 * LCD - Sony display connected to ATI Imageon w3220
368 */
369
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200370static void sony_lcd_init(void)
371{
372 gpio_set_value(GPIO84_HX4700_LCD_SQN, 1);
373 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
374 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
375 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0);
376 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
377 mdelay(10);
378 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
379 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
380 mdelay(20);
381
382 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1);
383 mdelay(5);
384 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1);
385
386 /* FIXME: init w3220 registers here */
387
388 mdelay(5);
389 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1);
390 mdelay(10);
391 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1);
392 mdelay(10);
393 gpio_set_value(GPIO59_HX4700_LCD_PC1, 1);
394 mdelay(10);
395 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1);
396}
397
398static void sony_lcd_off(void)
399{
400 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
401 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
402 mdelay(10);
403 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0);
404 mdelay(10);
405 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
406 mdelay(10);
407 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
408}
409
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200410#ifdef CONFIG_PM
411static void w3220_lcd_suspend(struct w100fb_par *wfb)
412{
413 sony_lcd_off();
414}
415
416static void w3220_lcd_resume(struct w100fb_par *wfb)
417{
418 sony_lcd_init();
419}
420#else
421#define w3220_lcd_resume NULL
422#define w3220_lcd_suspend NULL
423#endif
424
425static struct w100_tg_info w3220_tg_info = {
426 .suspend = w3220_lcd_suspend,
427 .resume = w3220_lcd_resume,
428};
429
430/* W3220_VGA QVGA */
431static struct w100_gen_regs w3220_regs = {
432 .lcd_format = 0x00000003,
433 .lcdd_cntl1 = 0x00000000,
434 .lcdd_cntl2 = 0x0003ffff,
435 .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */
436 .genlcd_cntl2 = 0x00000003,
437 .genlcd_cntl3 = 0x000102aa,
438};
439
440static struct w100_mode w3220_modes[] = {
441{
442 .xres = 480,
443 .yres = 640,
444 .left_margin = 15,
445 .right_margin = 16,
446 .upper_margin = 8,
447 .lower_margin = 7,
448 .crtc_ss = 0x00000000,
449 .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */
450 .crtc_gs = 0xc0000000, /* 0x40000000 */
451 .crtc_vpos_gs = 0x0000028f,
452 .crtc_ps1_active = 0x00000000, /* 0x41060010 */
453 .crtc_rev = 0,
454 .crtc_dclk = 0x80000000,
455 .crtc_gclk = 0x040a0104,
456 .crtc_goe = 0,
457 .pll_freq = 95,
458 .pixclk_divider = 4,
459 .pixclk_divider_rotated = 4,
460 .pixclk_src = CLK_SRC_PLL,
461 .sysclk_divider = 0,
462 .sysclk_src = CLK_SRC_PLL,
463},
464{
465 .xres = 240,
466 .yres = 320,
467 .left_margin = 9,
468 .right_margin = 8,
469 .upper_margin = 5,
470 .lower_margin = 4,
471 .crtc_ss = 0x80150014,
472 .crtc_ls = 0xa0fb00f7,
473 .crtc_gs = 0xc0080007,
474 .crtc_vpos_gs = 0x00080007,
475 .crtc_rev = 0x0000000a,
476 .crtc_dclk = 0x81700030,
477 .crtc_gclk = 0x8015010f,
478 .crtc_goe = 0x00000000,
479 .pll_freq = 95,
480 .pixclk_divider = 4,
481 .pixclk_divider_rotated = 4,
482 .pixclk_src = CLK_SRC_PLL,
483 .sysclk_divider = 0,
484 .sysclk_src = CLK_SRC_PLL,
485},
486};
487
488struct w100_mem_info w3220_mem_info = {
489 .ext_cntl = 0x09640011,
490 .sdram_mode_reg = 0x00600021,
491 .ext_timing_cntl = 0x1a001545, /* 0x15001545 */
492 .io_cntl = 0x7ddd7333,
493 .size = 0x1fffff,
494};
495
496struct w100_bm_mem_info w3220_bm_mem_info = {
497 .ext_mem_bw = 0x50413e01,
498 .offset = 0,
499 .ext_timing_ctl = 0x00043f7f,
500 .ext_cntl = 0x00000010,
501 .mode_reg = 0x00250000,
502 .io_cntl = 0x0fff0000,
503 .config = 0x08301480,
504};
505
506static struct w100_gpio_regs w3220_gpio_info = {
507 .init_data1 = 0xdfe00100, /* GPIO_DATA */
508 .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */
509 .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */
510 .init_data2 = 0x00000000, /* GPIO_DATA2 */
511 .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */
512 .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */
513};
514
515static struct w100fb_mach_info w3220_info = {
516 .tg = &w3220_tg_info,
517 .mem = &w3220_mem_info,
518 .bm_mem = &w3220_bm_mem_info,
519 .gpio = &w3220_gpio_info,
520 .regs = &w3220_regs,
521 .modelist = w3220_modes,
522 .num_modes = 2,
523 .xtal_freq = 16000000,
524};
525
526static struct resource w3220_resources[] = {
527 [0] = {
528 .start = ATI_W3220_PHYS,
529 .end = ATI_W3220_PHYS + 0x00ffffff,
530 .flags = IORESOURCE_MEM,
531 },
532};
533
534static struct platform_device w3220 = {
535 .name = "w100fb",
536 .id = -1,
537 .dev = {
538 .platform_data = &w3220_info,
539 },
540 .num_resources = ARRAY_SIZE(w3220_resources),
541 .resource = w3220_resources,
542};
543
Philipp Zabele2c509c2009-08-07 17:01:04 +0200544static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power)
545{
546 if (power)
547 sony_lcd_init();
548 else
549 sony_lcd_off();
550}
551
552static struct plat_lcd_data hx4700_lcd_data = {
553 .set_power = hx4700_lcd_set_power,
554};
555
556static struct platform_device hx4700_lcd = {
557 .name = "platform-lcd",
558 .id = -1,
559 .dev = {
560 .platform_data = &hx4700_lcd_data,
561 .parent = &w3220.dev,
562 },
563};
564
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200565/*
566 * Backlight
567 */
568
569static struct platform_pwm_backlight_data backlight_data = {
570 .pwm_id = 1,
571 .max_brightness = 200,
572 .dft_brightness = 100,
573 .pwm_period_ns = 30923,
574};
575
576static struct platform_device backlight = {
577 .name = "pwm-backlight",
578 .id = -1,
579 .dev = {
580 .parent = &pxa27x_device_pwm1.dev,
581 .platform_data = &backlight_data,
582 },
583};
584
585/*
586 * USB "Transceiver"
587 */
588
589static struct gpio_vbus_mach_info gpio_vbus_info = {
590 .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
591 .gpio_vbus = GPIOD14_nUSBC_DETECT,
592 .gpio_vbus_inverted = 1,
593};
594
595static struct platform_device gpio_vbus = {
596 .name = "gpio-vbus",
597 .id = -1,
598 .dev = {
599 .platform_data = &gpio_vbus_info,
600 },
601};
602
603/*
604 * Touchscreen - TSC2046 connected to SSP2
605 */
606
607static const struct ads7846_platform_data tsc2046_info = {
608 .model = 7846,
609 .vref_delay_usecs = 100,
Paul Parsons10d5d992009-11-14 16:54:12 +0000610 .pressure_max = 1024,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200611 .debounce_max = 10,
612 .debounce_tol = 3,
613 .debounce_rep = 1,
614 .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ,
615};
616
617static struct pxa2xx_spi_chip tsc2046_chip = {
618 .tx_threshold = 1,
619 .rx_threshold = 2,
620 .timeout = 64,
621 .gpio_cs = GPIO88_HX4700_TSC2046_CS,
622};
623
624static struct spi_board_info tsc2046_board_info[] __initdata = {
625 {
626 .modalias = "ads7846",
627 .bus_num = 2,
628 .max_speed_hz = 2600000, /* 100 kHz sample rate */
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800629 .irq = PXA_GPIO_TO_IRQ(GPIO58_HX4700_TSC2046_nPENIRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200630 .platform_data = &tsc2046_info,
631 .controller_data = &tsc2046_chip,
632 },
633};
634
635static struct pxa2xx_spi_master pxa_ssp2_master_info = {
636 .num_chipselect = 1,
637 .clock_enable = CKEN_SSP2,
638 .enable_dma = 1,
639};
640
641/*
642 * External power
643 */
644
645static int power_supply_init(struct device *dev)
646{
647 return gpio_request(GPIOD9_nAC_IN, "AC charger detect");
648}
649
650static int hx4700_is_ac_online(void)
651{
652 return !gpio_get_value(GPIOD9_nAC_IN);
653}
654
655static void power_supply_exit(struct device *dev)
656{
657 gpio_free(GPIOD9_nAC_IN);
658}
659
660static char *hx4700_supplicants[] = {
661 "ds2760-battery.0", "backup-battery"
662};
663
664static struct pda_power_pdata power_supply_info = {
665 .init = power_supply_init,
666 .is_ac_online = hx4700_is_ac_online,
667 .exit = power_supply_exit,
668 .supplied_to = hx4700_supplicants,
669 .num_supplicants = ARRAY_SIZE(hx4700_supplicants),
670};
671
672static struct resource power_supply_resources[] = {
673 [0] = {
674 .name = "ac",
675 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
676 IORESOURCE_IRQ_LOWEDGE,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800677 .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
678 .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200679 },
680 [1] = {
681 .name = "usb",
682 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
683 IORESOURCE_IRQ_LOWEDGE,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800684 .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
685 .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200686 },
687};
688
689static struct platform_device power_supply = {
690 .name = "pda-power",
691 .id = -1,
692 .dev = {
693 .platform_data = &power_supply_info,
694 },
695 .resource = power_supply_resources,
696 .num_resources = ARRAY_SIZE(power_supply_resources),
697};
698
699/*
700 * Battery charger
701 */
702
703static struct regulator_consumer_supply bq24022_consumers[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800704 REGULATOR_SUPPLY("vbus_draw", NULL),
705 REGULATOR_SUPPLY("ac_draw", NULL),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200706};
707
708static struct regulator_init_data bq24022_init_data = {
709 .constraints = {
710 .max_uA = 500000,
Paul Parsons745b1f4f2011-04-15 14:39:27 +0000711 .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200712 },
713 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
714 .consumer_supplies = bq24022_consumers,
715};
716
Heiko Stübner6967cca2012-03-02 13:56:38 +0100717static struct gpio bq24022_gpios[] = {
718 { GPIO96_HX4700_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
719};
720
721static struct gpio_regulator_state bq24022_states[] = {
722 { .value = 100000, .gpios = (0 << 0) },
723 { .value = 500000, .gpios = (1 << 0) },
724};
725
726static struct gpio_regulator_config bq24022_info = {
727 .supply_name = "bq24022",
728
729 .enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN,
730 .enable_high = 0,
731 .enabled_at_boot = 0,
732
733 .gpios = bq24022_gpios,
734 .nr_gpios = ARRAY_SIZE(bq24022_gpios),
735
736 .states = bq24022_states,
737 .nr_states = ARRAY_SIZE(bq24022_states),
738
739 .type = REGULATOR_CURRENT,
740 .init_data = &bq24022_init_data,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200741};
742
743static struct platform_device bq24022 = {
Heiko Stübner6967cca2012-03-02 13:56:38 +0100744 .name = "gpio-regulator",
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200745 .id = -1,
746 .dev = {
747 .platform_data = &bq24022_info,
748 },
749};
750
751/*
752 * StrataFlash
753 */
754
Marc Zyngier667f3902011-05-18 10:51:55 +0100755static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200756{
757 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
758}
759
Paul Parsons11407e52012-02-27 01:17:19 +0000760static struct resource strataflash_resource[] = {
761 [0] = DEFINE_RES_MEM(PXA_CS0_PHYS, SZ_64M),
762 [1] = DEFINE_RES_MEM(PXA_CS0_PHYS + SZ_64M, SZ_64M),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200763};
764
765static struct physmap_flash_data strataflash_data = {
766 .width = 4,
767 .set_vpp = hx4700_set_vpp,
768};
769
770static struct platform_device strataflash = {
771 .name = "physmap-flash",
772 .id = -1,
Paul Parsons11407e52012-02-27 01:17:19 +0000773 .resource = strataflash_resource,
774 .num_resources = ARRAY_SIZE(strataflash_resource),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200775 .dev = {
776 .platform_data = &strataflash_data,
777 },
778};
779
780/*
Philipp Zabel6ea04142009-05-28 07:15:18 +0200781 * Maxim MAX1587A on PI2C
782 */
783
Axel Lin0bf189a2012-05-08 16:25:10 +0800784static struct regulator_consumer_supply max1587a_consumer =
785 REGULATOR_SUPPLY("vcc_core", NULL);
Philipp Zabel6ea04142009-05-28 07:15:18 +0200786
787static struct regulator_init_data max1587a_v3_info = {
788 .constraints = {
789 .name = "vcc_core range",
790 .min_uV = 900000,
791 .max_uV = 1705000,
792 .always_on = 1,
793 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
794 },
795 .num_consumer_supplies = 1,
796 .consumer_supplies = &max1587a_consumer,
797};
798
799static struct max1586_subdev_data max1587a_subdev = {
800 .name = "vcc_core",
801 .id = MAX1586_V3,
802 .platform_data = &max1587a_v3_info,
803};
804
805static struct max1586_platform_data max1587a_info = {
806 .num_subdevs = 1,
807 .subdevs = &max1587a_subdev,
808 .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
809};
810
811static struct i2c_board_info __initdata pi2c_board_info[] = {
812 {
813 I2C_BOARD_INFO("max1586", 0x14),
814 .platform_data = &max1587a_info,
815 },
816};
817
818/*
Axel Lind87f6142011-12-30 12:06:11 +0800819 * Asahi Kasei AK4641 on I2C
820 */
821
822static struct ak4641_platform_data ak4641_info = {
823 .gpio_power = GPIO27_HX4700_CODEC_ON,
824 .gpio_npdn = GPIO109_HX4700_CODEC_nPDN,
825};
826
827static struct i2c_board_info i2c_board_info[] __initdata = {
828 {
829 I2C_BOARD_INFO("ak4641", 0x12),
830 .platform_data = &ak4641_info,
831 },
832};
833
834static struct platform_device audio = {
835 .name = "hx4700-audio",
836 .id = -1,
837};
838
839
840/*
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200841 * Platform devices
842 */
843
844static struct platform_device *devices[] __initdata = {
845 &asic3,
846 &gpio_keys,
Paul Parsonsb2596c62012-05-12 12:31:02 +0100847 &navpoint,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200848 &backlight,
849 &w3220,
Dmitry Artamonow19d6c132009-11-25 14:33:15 +0300850 &hx4700_lcd,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200851 &egpio,
852 &bq24022,
853 &gpio_vbus,
854 &power_supply,
855 &strataflash,
Axel Lind87f6142011-12-30 12:06:11 +0800856 &audio,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200857};
858
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200859static struct gpio global_gpios[] = {
860 { GPIO12_HX4700_ASIC3_IRQ, GPIOF_IN, "ASIC3_IRQ" },
861 { GPIO13_HX4700_W3220_IRQ, GPIOF_IN, "W3220_IRQ" },
862 { GPIO14_HX4700_nWLAN_IRQ, GPIOF_IN, "WLAN_IRQ" },
863 { GPIO59_HX4700_LCD_PC1, GPIOF_OUT_INIT_HIGH, "LCD_PC1" },
864 { GPIO62_HX4700_LCD_nRESET, GPIOF_OUT_INIT_HIGH, "LCD_RESET" },
865 { GPIO70_HX4700_LCD_SLIN1, GPIOF_OUT_INIT_HIGH, "LCD_SLIN1" },
866 { GPIO84_HX4700_LCD_SQN, GPIOF_OUT_INIT_HIGH, "LCD_SQN" },
867 { GPIO110_HX4700_LCD_LVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_LVDD" },
868 { GPIO111_HX4700_LCD_AVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_AVDD" },
869 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
870 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
871 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200872};
873
874static void __init hx4700_init(void)
875{
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200876 int ret;
877
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200878 pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config));
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200879 ret = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
880 if (ret)
881 pr_err ("hx4700: Failed to request GPIOs.\n");
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200882
Russell Kingcc155c62009-11-09 13:34:08 +0800883 pxa_set_ffuart_info(NULL);
884 pxa_set_btuart_info(NULL);
885 pxa_set_stuart_info(NULL);
886
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200887 platform_add_devices(devices, ARRAY_SIZE(devices));
888
889 pxa_set_ficp_info(&ficp_info);
890 pxa27x_set_i2c_power_info(NULL);
891 pxa_set_i2c_info(NULL);
Axel Lind87f6142011-12-30 12:06:11 +0800892 i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
Philipp Zabel6ea04142009-05-28 07:15:18 +0200893 i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200894 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
895 spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
896
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200897 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0);
898 mdelay(10);
899 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
900 mdelay(10);
901}
902
903MACHINE_START(H4700, "HP iPAQ HX4700")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400904 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200905 .map_io = pxa27x_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800906 .nr_irqs = HX4700_NR_IRQS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200907 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800908 .handle_irq = pxa27x_handle_irq,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200909 .init_machine = hx4700_init,
910 .timer = &pxa_timer,
Russell King271a74f2011-11-04 14:15:53 +0000911 .restart = pxa_restart,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200912MACHINE_END