Linux Audio

Check our new training course

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