PageRenderTime 76ms CodeModel.GetById 15ms app.highlight 55ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/arm/mach-pxa/hx4700.c

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