blob: 1d6b1d2fb6a9a1bc3fcd8f15adfae492c73d738b [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>
Linus Walleijd6cd33a2019-01-29 11:31:52 +010022#include <linux/gpio/machine.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020023#include <linux/gpio.h>
24#include <linux/gpio_keys.h>
25#include <linux/input.h>
Paul Parsonsb2596c62012-05-12 12:31:02 +010026#include <linux/input/navpoint.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020027#include <linux/lcd.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020028#include <linux/mfd/asic3.h>
29#include <linux/mtd/physmap.h>
30#include <linux/pda_power.h>
Linus Walleij3c6e8d02016-09-16 13:48:12 +020031#include <linux/platform_data/gpio-htc-egpio.h>
Paul Parsons8d6b00f2012-10-19 13:15:30 +010032#include <linux/pwm.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020033#include <linux/pwm_backlight.h>
Heiko Stübner6967cca2012-03-02 13:56:38 +010034#include <linux/regulator/driver.h>
35#include <linux/regulator/gpio-regulator.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020036#include <linux/regulator/machine.h>
Philipp Zabel6ea04142009-05-28 07:15:18 +020037#include <linux/regulator/max1586.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020038#include <linux/spi/ads7846.h>
39#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080040#include <linux/spi/pxa2xx_spi.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020041#include <linux/usb/gpio_vbus.h>
Wolfram Sangf15fc9b2017-11-13 18:27:39 +010042#include <linux/platform_data/i2c-pxa.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020043
44#include <mach/hardware.h>
45#include <asm/mach-types.h>
46#include <asm/mach/arch.h>
47
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010048#include "pxa27x.h"
Philipp Zabeld3ca1952009-05-28 07:05:18 +020049#include <mach/hx4700.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020050#include <linux/platform_data/irda-pxaficp.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020051
Axel Lind87f6142011-12-30 12:06:11 +080052#include <sound/ak4641.h>
Philipp Zabele2c509c2009-08-07 17:01:04 +020053#include <video/platform_lcd.h>
Philipp Zabeld3ca1952009-05-28 07:05:18 +020054#include <video/w100fb.h>
55
56#include "devices.h"
57#include "generic.h"
Robert Jarzmikf439b5c2018-05-26 11:38:34 +020058#include "udc.h"
Philipp Zabeld3ca1952009-05-28 07:05:18 +020059
60/* Physical address space information */
61
62#define ATI_W3220_PHYS PXA_CS2_PHYS /* ATI Imageon 3220 Graphics */
63#define ASIC3_PHYS PXA_CS3_PHYS
64#define ASIC3_SD_PHYS (PXA_CS3_PHYS + 0x02000000)
65
66static unsigned long hx4700_pin_config[] __initdata = {
67
68 /* SDRAM and Static Memory I/O Signals */
69 GPIO20_nSDCS_2,
70 GPIO21_nSDCS_3,
71 GPIO15_nCS_1,
72 GPIO78_nCS_2, /* W3220 */
73 GPIO79_nCS_3, /* ASIC3 */
74 GPIO80_nCS_4,
75 GPIO33_nCS_5, /* EGPIO, WLAN */
76
77 /* PC CARD */
78 GPIO48_nPOE,
79 GPIO49_nPWE,
80 GPIO50_nPIOR,
81 GPIO51_nPIOW,
82 GPIO54_nPCE_2,
83 GPIO55_nPREG,
84 GPIO56_nPWAIT,
85 GPIO57_nIOIS16,
86 GPIO85_nPCE_1,
87 GPIO104_PSKTSEL,
88
89 /* I2C */
90 GPIO117_I2C_SCL,
91 GPIO118_I2C_SDA,
92
93 /* FFUART (RS-232) */
94 GPIO34_FFUART_RXD,
95 GPIO35_FFUART_CTS,
96 GPIO36_FFUART_DCD,
97 GPIO37_FFUART_DSR,
98 GPIO38_FFUART_RI,
99 GPIO39_FFUART_TXD,
100 GPIO40_FFUART_DTR,
101 GPIO41_FFUART_RTS,
102
103 /* BTUART */
104 GPIO42_BTUART_RXD,
Paul Parsonscd419cf2012-03-11 13:23:42 +0000105 GPIO43_BTUART_TXD_LPM_LOW,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200106 GPIO44_BTUART_CTS,
Paul Parsonscd419cf2012-03-11 13:23:42 +0000107 GPIO45_BTUART_RTS_LPM_LOW,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200108
Paul Parsons0de91b62012-03-16 15:24:35 +0000109 /* STUART (IRDA) */
110 GPIO46_STUART_RXD,
111 GPIO47_STUART_TXD,
112
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200113 /* PWM 1 (Backlight) */
114 GPIO17_PWM1_OUT,
115
116 /* I2S */
117 GPIO28_I2S_BITCLK_OUT,
118 GPIO29_I2S_SDATA_IN,
119 GPIO30_I2S_SDATA_OUT,
120 GPIO31_I2S_SYNC,
121 GPIO113_I2S_SYSCLK,
122
123 /* SSP 1 (NavPoint) */
Paul Parsonsb2596c62012-05-12 12:31:02 +0100124 GPIO23_SSP1_SCLK_IN,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200125 GPIO24_SSP1_SFRM,
126 GPIO25_SSP1_TXD,
127 GPIO26_SSP1_RXD,
128
129 /* SSP 2 (TSC2046) */
130 GPIO19_SSP2_SCLK,
131 GPIO86_SSP2_RXD,
132 GPIO87_SSP2_TXD,
Paul Parsons6416c042012-06-11 15:31:14 +0100133 GPIO88_GPIO | MFP_LPM_DRIVE_HIGH, /* TSC2046_CS */
134
135 /* BQ24022 Regulator */
136 GPIO72_GPIO | MFP_LPM_KEEP_OUTPUT, /* BQ24022_nCHARGE_EN */
137 GPIO96_GPIO | MFP_LPM_KEEP_OUTPUT, /* BQ24022_ISET2 */
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200138
139 /* HX4700 specific input GPIOs */
Paul Parsonse949f932012-05-02 16:49:24 +0100140 GPIO12_GPIO | WAKEUP_ON_EDGE_RISE, /* ASIC3_IRQ */
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200141 GPIO13_GPIO, /* W3220_IRQ */
142 GPIO14_GPIO, /* nWLAN_IRQ */
143
Paul Parsonsb2596c62012-05-12 12:31:02 +0100144 /* HX4700 specific output GPIOs */
Paul Parsons6416c042012-06-11 15:31:14 +0100145 GPIO61_GPIO | MFP_LPM_DRIVE_HIGH, /* W3220_nRESET */
146 GPIO71_GPIO | MFP_LPM_DRIVE_HIGH, /* ASIC3_nRESET */
147 GPIO81_GPIO | MFP_LPM_DRIVE_HIGH, /* CPU_GP_nRESET */
148 GPIO116_GPIO | MFP_LPM_DRIVE_HIGH, /* CPU_HW_nRESET */
Paul Parsonsb2596c62012-05-12 12:31:02 +0100149 GPIO102_GPIO | MFP_LPM_DRIVE_LOW, /* SYNAPTICS_POWER_ON */
150
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200151 GPIO10_GPIO, /* GSM_IRQ */
152 GPIO13_GPIO, /* CPLD_IRQ */
153 GPIO107_GPIO, /* DS1WM_IRQ */
154 GPIO108_GPIO, /* GSM_READY */
155 GPIO58_GPIO, /* TSC2046_nPENIRQ */
156 GPIO66_GPIO, /* nSDIO_IRQ */
157};
158
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200159/*
160 * IRDA
161 */
162
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200163static struct pxaficp_platform_data ficp_info = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200164 .gpio_pwdown = GPIO105_HX4700_nIR_ON,
165 .transceiver_cap = IR_SIRMODE | IR_OFF,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200166};
167
168/*
169 * GPIO Keys
170 */
171
172#define INIT_KEY(_code, _gpio, _active_low, _desc) \
173 { \
174 .code = KEY_##_code, \
175 .gpio = _gpio, \
176 .active_low = _active_low, \
177 .desc = _desc, \
178 .type = EV_KEY, \
179 .wakeup = 1, \
180 }
181
182static struct gpio_keys_button gpio_keys_buttons[] = {
183 INIT_KEY(POWER, GPIO0_HX4700_nKEY_POWER, 1, "Power button"),
184 INIT_KEY(MAIL, GPIO94_HX4700_KEY_MAIL, 0, "Mail button"),
185 INIT_KEY(ADDRESSBOOK, GPIO99_HX4700_KEY_CONTACTS,0, "Contacts button"),
186 INIT_KEY(RECORD, GPIOD6_nKEY_RECORD, 1, "Record button"),
187 INIT_KEY(CALENDAR, GPIOD1_nKEY_CALENDAR, 1, "Calendar button"),
188 INIT_KEY(HOMEPAGE, GPIOD3_nKEY_HOME, 1, "Home button"),
189};
190
191static struct gpio_keys_platform_data gpio_keys_data = {
192 .buttons = gpio_keys_buttons,
193 .nbuttons = ARRAY_SIZE(gpio_keys_buttons),
194};
195
196static struct platform_device gpio_keys = {
197 .name = "gpio-keys",
198 .dev = {
199 .platform_data = &gpio_keys_data,
200 },
201 .id = -1,
202};
203
204/*
Paul Parsonsb2596c62012-05-12 12:31:02 +0100205 * Synaptics NavPoint connected to SSP1
206 */
207
208static struct navpoint_platform_data navpoint_platform_data = {
209 .port = 1,
210 .gpio = GPIO102_HX4700_SYNAPTICS_POWER_ON,
211};
212
213static struct platform_device navpoint = {
214 .name = "navpoint",
215 .id = -1,
216 .dev = {
217 .platform_data = &navpoint_platform_data,
218 },
219};
220
221/*
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200222 * ASIC3
223 */
224
225static u16 asic3_gpio_config[] = {
226 /* ASIC3 GPIO banks A and B along with some of C and D
227 implement the buffering for the CF slot. */
228 ASIC3_CONFIG_GPIO(0, 1, 1, 0),
229 ASIC3_CONFIG_GPIO(1, 1, 1, 0),
230 ASIC3_CONFIG_GPIO(2, 1, 1, 0),
231 ASIC3_CONFIG_GPIO(3, 1, 1, 0),
232 ASIC3_CONFIG_GPIO(4, 1, 1, 0),
233 ASIC3_CONFIG_GPIO(5, 1, 1, 0),
234 ASIC3_CONFIG_GPIO(6, 1, 1, 0),
235 ASIC3_CONFIG_GPIO(7, 1, 1, 0),
236 ASIC3_CONFIG_GPIO(8, 1, 1, 0),
237 ASIC3_CONFIG_GPIO(9, 1, 1, 0),
238 ASIC3_CONFIG_GPIO(10, 1, 1, 0),
239 ASIC3_CONFIG_GPIO(11, 1, 1, 0),
240 ASIC3_CONFIG_GPIO(12, 1, 1, 0),
241 ASIC3_CONFIG_GPIO(13, 1, 1, 0),
242 ASIC3_CONFIG_GPIO(14, 1, 1, 0),
243 ASIC3_CONFIG_GPIO(15, 1, 1, 0),
244
245 ASIC3_CONFIG_GPIO(16, 1, 1, 0),
246 ASIC3_CONFIG_GPIO(17, 1, 1, 0),
247 ASIC3_CONFIG_GPIO(18, 1, 1, 0),
248 ASIC3_CONFIG_GPIO(19, 1, 1, 0),
249 ASIC3_CONFIG_GPIO(20, 1, 1, 0),
250 ASIC3_CONFIG_GPIO(21, 1, 1, 0),
251 ASIC3_CONFIG_GPIO(22, 1, 1, 0),
252 ASIC3_CONFIG_GPIO(23, 1, 1, 0),
253 ASIC3_CONFIG_GPIO(24, 1, 1, 0),
254 ASIC3_CONFIG_GPIO(25, 1, 1, 0),
255 ASIC3_CONFIG_GPIO(26, 1, 1, 0),
256 ASIC3_CONFIG_GPIO(27, 1, 1, 0),
257 ASIC3_CONFIG_GPIO(28, 1, 1, 0),
258 ASIC3_CONFIG_GPIO(29, 1, 1, 0),
259 ASIC3_CONFIG_GPIO(30, 1, 1, 0),
260 ASIC3_CONFIG_GPIO(31, 1, 1, 0),
261
262 /* GPIOC - CF, LEDs, SD */
263 ASIC3_GPIOC0_LED0, /* red */
264 ASIC3_GPIOC1_LED1, /* green */
265 ASIC3_GPIOC2_LED2, /* blue */
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200266 ASIC3_GPIOC5_nCIOW,
267 ASIC3_GPIOC6_nCIOR,
268 ASIC3_GPIOC7_nPCE_1,
269 ASIC3_GPIOC8_nPCE_2,
270 ASIC3_GPIOC9_nPOE,
271 ASIC3_GPIOC10_nPWE,
272 ASIC3_GPIOC11_PSKTSEL,
273 ASIC3_GPIOC12_nPREG,
274 ASIC3_GPIOC13_nPWAIT,
275 ASIC3_GPIOC14_nPIOIS16,
276 ASIC3_GPIOC15_nPIOR,
277
278 /* GPIOD: input GPIOs, CF */
Paul Parsons1334d862012-05-02 16:49:29 +0100279 ASIC3_GPIOD4_CF_nCD,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200280 ASIC3_GPIOD11_nCIOIS16,
281 ASIC3_GPIOD12_nCWAIT,
282 ASIC3_GPIOD15_nPIOW,
283};
284
Paul Parsons91cb8ee2011-06-22 19:31:49 +0000285static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
286 [0] = {
287 .name = "hx4700:amber",
288 .default_trigger = "ds2760-battery.0-charging-blink-full-solid",
289 },
290 [1] = {
291 .name = "hx4700:green",
292 .default_trigger = "unused",
293 },
294 [2] = {
295 .name = "hx4700:blue",
296 .default_trigger = "hx4700-radio",
297 },
298};
299
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200300static struct resource asic3_resources[] = {
301 /* GPIO part */
Paul Parsons759af172012-06-29 13:01:31 +0100302 [0] = DEFINE_RES_MEM(ASIC3_PHYS, ASIC3_MAP_SIZE_16BIT),
303 [1] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ)),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200304 /* SD part */
Paul Parsons759af172012-06-29 13:01:31 +0100305 [2] = DEFINE_RES_MEM(ASIC3_SD_PHYS, ASIC3_MAP_SIZE_16BIT),
306 [3] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ)),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200307};
308
309static struct asic3_platform_data asic3_platform_data = {
310 .gpio_config = asic3_gpio_config,
311 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
312 .irq_base = IRQ_BOARD_START,
313 .gpio_base = HX4700_ASIC3_GPIO_BASE,
Paul Parsons89619d42012-05-02 16:49:16 +0100314 .clock_rate = 4000000,
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[] = {
Paul Parsons759af172012-06-29 13:01:31 +0100333 [0] = DEFINE_RES_MEM(PXA_CS5_PHYS, 0x4),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200334};
335
336static struct htc_egpio_chip egpio_chips[] = {
337 [0] = {
338 .reg_start = 0,
339 .gpio_base = HX4700_EGPIO_BASE,
340 .num_gpios = 8,
341 .direction = HTC_EGPIO_OUTPUT,
342 },
343};
344
345static struct htc_egpio_platform_data egpio_info = {
346 .reg_width = 16,
347 .bus_width = 16,
348 .chip = egpio_chips,
349 .num_chips = ARRAY_SIZE(egpio_chips),
350};
351
352static struct platform_device egpio = {
353 .name = "htc-egpio",
354 .id = -1,
355 .resource = egpio_resources,
356 .num_resources = ARRAY_SIZE(egpio_resources),
357 .dev = {
358 .platform_data = &egpio_info,
359 },
360};
361
362/*
363 * LCD - Sony display connected to ATI Imageon w3220
364 */
365
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200366static void sony_lcd_init(void)
367{
368 gpio_set_value(GPIO84_HX4700_LCD_SQN, 1);
369 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
370 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
371 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 0);
372 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
373 mdelay(10);
374 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
375 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
376 mdelay(20);
377
378 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 1);
379 mdelay(5);
380 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 1);
381
382 /* FIXME: init w3220 registers here */
383
384 mdelay(5);
385 gpio_set_value(GPIO70_HX4700_LCD_SLIN1, 1);
386 mdelay(10);
387 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 1);
388 mdelay(10);
389 gpio_set_value(GPIO59_HX4700_LCD_PC1, 1);
390 mdelay(10);
391 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 1);
392}
393
394static void sony_lcd_off(void)
395{
396 gpio_set_value(GPIO59_HX4700_LCD_PC1, 0);
397 gpio_set_value(GPIO62_HX4700_LCD_nRESET, 0);
398 mdelay(10);
399 gpio_set_value(GPIO112_HX4700_LCD_N2V7_7V3_ON, 0);
400 mdelay(10);
401 gpio_set_value(GPIO111_HX4700_LCD_AVDD_3V3_ON, 0);
402 mdelay(10);
403 gpio_set_value(GPIO110_HX4700_LCD_LVDD_3V3_ON, 0);
404}
405
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200406#ifdef CONFIG_PM
407static void w3220_lcd_suspend(struct w100fb_par *wfb)
408{
409 sony_lcd_off();
410}
411
412static void w3220_lcd_resume(struct w100fb_par *wfb)
413{
414 sony_lcd_init();
415}
416#else
417#define w3220_lcd_resume NULL
418#define w3220_lcd_suspend NULL
419#endif
420
421static struct w100_tg_info w3220_tg_info = {
422 .suspend = w3220_lcd_suspend,
423 .resume = w3220_lcd_resume,
424};
425
426/* W3220_VGA QVGA */
427static struct w100_gen_regs w3220_regs = {
428 .lcd_format = 0x00000003,
429 .lcdd_cntl1 = 0x00000000,
430 .lcdd_cntl2 = 0x0003ffff,
431 .genlcd_cntl1 = 0x00abf003, /* 0x00fff003 */
432 .genlcd_cntl2 = 0x00000003,
433 .genlcd_cntl3 = 0x000102aa,
434};
435
436static struct w100_mode w3220_modes[] = {
437{
438 .xres = 480,
439 .yres = 640,
440 .left_margin = 15,
441 .right_margin = 16,
442 .upper_margin = 8,
443 .lower_margin = 7,
444 .crtc_ss = 0x00000000,
445 .crtc_ls = 0xa1ff01f9, /* 0x21ff01f9 */
446 .crtc_gs = 0xc0000000, /* 0x40000000 */
447 .crtc_vpos_gs = 0x0000028f,
448 .crtc_ps1_active = 0x00000000, /* 0x41060010 */
449 .crtc_rev = 0,
450 .crtc_dclk = 0x80000000,
451 .crtc_gclk = 0x040a0104,
452 .crtc_goe = 0,
453 .pll_freq = 95,
454 .pixclk_divider = 4,
455 .pixclk_divider_rotated = 4,
456 .pixclk_src = CLK_SRC_PLL,
457 .sysclk_divider = 0,
458 .sysclk_src = CLK_SRC_PLL,
459},
460{
461 .xres = 240,
462 .yres = 320,
463 .left_margin = 9,
464 .right_margin = 8,
465 .upper_margin = 5,
466 .lower_margin = 4,
467 .crtc_ss = 0x80150014,
468 .crtc_ls = 0xa0fb00f7,
469 .crtc_gs = 0xc0080007,
470 .crtc_vpos_gs = 0x00080007,
471 .crtc_rev = 0x0000000a,
472 .crtc_dclk = 0x81700030,
473 .crtc_gclk = 0x8015010f,
474 .crtc_goe = 0x00000000,
475 .pll_freq = 95,
476 .pixclk_divider = 4,
477 .pixclk_divider_rotated = 4,
478 .pixclk_src = CLK_SRC_PLL,
479 .sysclk_divider = 0,
480 .sysclk_src = CLK_SRC_PLL,
481},
482};
483
484struct w100_mem_info w3220_mem_info = {
485 .ext_cntl = 0x09640011,
486 .sdram_mode_reg = 0x00600021,
487 .ext_timing_cntl = 0x1a001545, /* 0x15001545 */
488 .io_cntl = 0x7ddd7333,
489 .size = 0x1fffff,
490};
491
492struct w100_bm_mem_info w3220_bm_mem_info = {
493 .ext_mem_bw = 0x50413e01,
494 .offset = 0,
495 .ext_timing_ctl = 0x00043f7f,
496 .ext_cntl = 0x00000010,
497 .mode_reg = 0x00250000,
498 .io_cntl = 0x0fff0000,
499 .config = 0x08301480,
500};
501
502static struct w100_gpio_regs w3220_gpio_info = {
503 .init_data1 = 0xdfe00100, /* GPIO_DATA */
504 .gpio_dir1 = 0xffff0000, /* GPIO_CNTL1 */
505 .gpio_oe1 = 0x00000000, /* GPIO_CNTL2 */
506 .init_data2 = 0x00000000, /* GPIO_DATA2 */
507 .gpio_dir2 = 0x00000000, /* GPIO_CNTL3 */
508 .gpio_oe2 = 0x00000000, /* GPIO_CNTL4 */
509};
510
511static struct w100fb_mach_info w3220_info = {
512 .tg = &w3220_tg_info,
513 .mem = &w3220_mem_info,
514 .bm_mem = &w3220_bm_mem_info,
515 .gpio = &w3220_gpio_info,
516 .regs = &w3220_regs,
517 .modelist = w3220_modes,
518 .num_modes = 2,
519 .xtal_freq = 16000000,
520};
521
522static struct resource w3220_resources[] = {
Paul Parsons759af172012-06-29 13:01:31 +0100523 [0] = DEFINE_RES_MEM(ATI_W3220_PHYS, SZ_16M),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200524};
525
526static struct platform_device w3220 = {
527 .name = "w100fb",
528 .id = -1,
529 .dev = {
530 .platform_data = &w3220_info,
531 },
532 .num_resources = ARRAY_SIZE(w3220_resources),
533 .resource = w3220_resources,
534};
535
Philipp Zabele2c509c2009-08-07 17:01:04 +0200536static void hx4700_lcd_set_power(struct plat_lcd_data *pd, unsigned int power)
537{
538 if (power)
539 sony_lcd_init();
540 else
541 sony_lcd_off();
542}
543
544static struct plat_lcd_data hx4700_lcd_data = {
545 .set_power = hx4700_lcd_set_power,
546};
547
548static struct platform_device hx4700_lcd = {
549 .name = "platform-lcd",
550 .id = -1,
551 .dev = {
552 .platform_data = &hx4700_lcd_data,
553 .parent = &w3220.dev,
554 },
555};
556
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200557/*
558 * Backlight
559 */
560
561static struct platform_pwm_backlight_data backlight_data = {
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200562 .max_brightness = 200,
563 .dft_brightness = 100,
Thierry Redingdb011202013-08-30 12:15:24 +0200564 .enable_gpio = -1,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200565};
566
567static struct platform_device backlight = {
568 .name = "pwm-backlight",
569 .id = -1,
570 .dev = {
571 .parent = &pxa27x_device_pwm1.dev,
572 .platform_data = &backlight_data,
573 },
574};
575
Paul Parsons8d6b00f2012-10-19 13:15:30 +0100576static struct pwm_lookup hx4700_pwm_lookup[] = {
Alexandre Belloni9becf502014-05-19 22:42:40 +0200577 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL,
578 30923, PWM_POLARITY_NORMAL),
Paul Parsons8d6b00f2012-10-19 13:15:30 +0100579};
580
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200581/*
582 * USB "Transceiver"
583 */
584
585static struct gpio_vbus_mach_info gpio_vbus_info = {
586 .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
587 .gpio_vbus = GPIOD14_nUSBC_DETECT,
588 .gpio_vbus_inverted = 1,
589};
590
591static struct platform_device gpio_vbus = {
592 .name = "gpio-vbus",
593 .id = -1,
594 .dev = {
595 .platform_data = &gpio_vbus_info,
596 },
597};
598
Robert Jarzmikf439b5c2018-05-26 11:38:34 +0200599static struct pxa2xx_udc_mach_info hx4700_udc_info;
600
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200601/*
602 * Touchscreen - TSC2046 connected to SSP2
603 */
604
605static const struct ads7846_platform_data tsc2046_info = {
606 .model = 7846,
607 .vref_delay_usecs = 100,
Paul Parsons10d5d992009-11-14 16:54:12 +0000608 .pressure_max = 1024,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200609 .debounce_max = 10,
610 .debounce_tol = 3,
611 .debounce_rep = 1,
612 .gpio_pendown = GPIO58_HX4700_TSC2046_nPENIRQ,
613};
614
615static struct pxa2xx_spi_chip tsc2046_chip = {
616 .tx_threshold = 1,
617 .rx_threshold = 2,
618 .timeout = 64,
619 .gpio_cs = GPIO88_HX4700_TSC2046_CS,
620};
621
622static struct spi_board_info tsc2046_board_info[] __initdata = {
623 {
624 .modalias = "ads7846",
625 .bus_num = 2,
626 .max_speed_hz = 2600000, /* 100 kHz sample rate */
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800627 .irq = PXA_GPIO_TO_IRQ(GPIO58_HX4700_TSC2046_nPENIRQ),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200628 .platform_data = &tsc2046_info,
629 .controller_data = &tsc2046_chip,
630 },
631};
632
Lubomir Rintel51eea522019-01-16 16:13:31 +0100633static struct pxa2xx_spi_controller pxa_ssp2_master_info = {
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200634 .num_chipselect = 1,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200635 .enable_dma = 1,
636};
637
638/*
639 * External power
640 */
641
642static int power_supply_init(struct device *dev)
643{
644 return gpio_request(GPIOD9_nAC_IN, "AC charger detect");
645}
646
647static int hx4700_is_ac_online(void)
648{
649 return !gpio_get_value(GPIOD9_nAC_IN);
650}
651
652static void power_supply_exit(struct device *dev)
653{
654 gpio_free(GPIOD9_nAC_IN);
655}
656
657static char *hx4700_supplicants[] = {
658 "ds2760-battery.0", "backup-battery"
659};
660
661static struct pda_power_pdata power_supply_info = {
662 .init = power_supply_init,
663 .is_ac_online = hx4700_is_ac_online,
664 .exit = power_supply_exit,
665 .supplied_to = hx4700_supplicants,
666 .num_supplicants = ARRAY_SIZE(hx4700_supplicants),
667};
668
669static struct resource power_supply_resources[] = {
Paul Parsons759af172012-06-29 13:01:31 +0100670 [0] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 1, "ac",
671 IORESOURCE_IRQ |
672 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
673 [1] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT), 1, "usb",
674 IORESOURCE_IRQ |
675 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200676};
677
678static struct platform_device power_supply = {
679 .name = "pda-power",
680 .id = -1,
681 .dev = {
682 .platform_data = &power_supply_info,
683 },
684 .resource = power_supply_resources,
685 .num_resources = ARRAY_SIZE(power_supply_resources),
686};
687
688/*
689 * Battery charger
690 */
691
692static struct regulator_consumer_supply bq24022_consumers[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800693 REGULATOR_SUPPLY("vbus_draw", NULL),
694 REGULATOR_SUPPLY("ac_draw", NULL),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200695};
696
697static struct regulator_init_data bq24022_init_data = {
698 .constraints = {
699 .max_uA = 500000,
Paul Parsons745b1f4f2011-04-15 14:39:27 +0000700 .valid_ops_mask = REGULATOR_CHANGE_CURRENT|REGULATOR_CHANGE_STATUS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200701 },
702 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
703 .consumer_supplies = bq24022_consumers,
704};
705
Linus Walleijd6cd33a2019-01-29 11:31:52 +0100706static enum gpiod_flags bq24022_gpiod_gflags[] = { GPIOD_OUT_LOW };
Heiko Stübner6967cca2012-03-02 13:56:38 +0100707
708static struct gpio_regulator_state bq24022_states[] = {
709 { .value = 100000, .gpios = (0 << 0) },
710 { .value = 500000, .gpios = (1 << 0) },
711};
712
713static struct gpio_regulator_config bq24022_info = {
714 .supply_name = "bq24022",
715
Heiko Stübner6967cca2012-03-02 13:56:38 +0100716 .enabled_at_boot = 0,
717
Linus Walleijd6cd33a2019-01-29 11:31:52 +0100718 .gflags = bq24022_gpiod_gflags,
719 .ngpios = ARRAY_SIZE(bq24022_gpiod_gflags),
Heiko Stübner6967cca2012-03-02 13:56:38 +0100720
721 .states = bq24022_states,
722 .nr_states = ARRAY_SIZE(bq24022_states),
723
724 .type = REGULATOR_CURRENT,
725 .init_data = &bq24022_init_data,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200726};
727
728static struct platform_device bq24022 = {
Heiko Stübner6967cca2012-03-02 13:56:38 +0100729 .name = "gpio-regulator",
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200730 .id = -1,
731 .dev = {
732 .platform_data = &bq24022_info,
733 },
734};
735
Linus Walleijd6cd33a2019-01-29 11:31:52 +0100736static struct gpiod_lookup_table bq24022_gpiod_table = {
737 .dev_id = "gpio-regulator",
738 .table = {
739 GPIO_LOOKUP("gpio-pxa", GPIO96_HX4700_BQ24022_ISET2,
740 NULL, GPIO_ACTIVE_HIGH),
741 GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN,
742 "enable", GPIO_ACTIVE_LOW),
743 { },
744 },
745};
746
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200747/*
748 * StrataFlash
749 */
750
Marc Zyngier667f3902011-05-18 10:51:55 +0100751static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200752{
753 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
754}
755
Paul Parsons11407e52012-02-27 01:17:19 +0000756static struct resource strataflash_resource[] = {
757 [0] = DEFINE_RES_MEM(PXA_CS0_PHYS, SZ_64M),
758 [1] = DEFINE_RES_MEM(PXA_CS0_PHYS + SZ_64M, SZ_64M),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200759};
760
761static struct physmap_flash_data strataflash_data = {
762 .width = 4,
763 .set_vpp = hx4700_set_vpp,
764};
765
766static struct platform_device strataflash = {
767 .name = "physmap-flash",
768 .id = -1,
Paul Parsons11407e52012-02-27 01:17:19 +0000769 .resource = strataflash_resource,
770 .num_resources = ARRAY_SIZE(strataflash_resource),
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200771 .dev = {
772 .platform_data = &strataflash_data,
773 },
774};
775
776/*
Philipp Zabel6ea04142009-05-28 07:15:18 +0200777 * Maxim MAX1587A on PI2C
778 */
779
Axel Lin0bf189a2012-05-08 16:25:10 +0800780static struct regulator_consumer_supply max1587a_consumer =
781 REGULATOR_SUPPLY("vcc_core", NULL);
Philipp Zabel6ea04142009-05-28 07:15:18 +0200782
783static struct regulator_init_data max1587a_v3_info = {
784 .constraints = {
785 .name = "vcc_core range",
786 .min_uV = 900000,
787 .max_uV = 1705000,
788 .always_on = 1,
789 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
790 },
791 .num_consumer_supplies = 1,
792 .consumer_supplies = &max1587a_consumer,
793};
794
795static struct max1586_subdev_data max1587a_subdev = {
796 .name = "vcc_core",
797 .id = MAX1586_V3,
798 .platform_data = &max1587a_v3_info,
799};
800
801static struct max1586_platform_data max1587a_info = {
802 .num_subdevs = 1,
803 .subdevs = &max1587a_subdev,
804 .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
805};
806
807static struct i2c_board_info __initdata pi2c_board_info[] = {
808 {
809 I2C_BOARD_INFO("max1586", 0x14),
810 .platform_data = &max1587a_info,
811 },
812};
813
814/*
Axel Lind87f6142011-12-30 12:06:11 +0800815 * Asahi Kasei AK4641 on I2C
816 */
817
818static struct ak4641_platform_data ak4641_info = {
819 .gpio_power = GPIO27_HX4700_CODEC_ON,
820 .gpio_npdn = GPIO109_HX4700_CODEC_nPDN,
821};
822
823static struct i2c_board_info i2c_board_info[] __initdata = {
824 {
825 I2C_BOARD_INFO("ak4641", 0x12),
826 .platform_data = &ak4641_info,
827 },
828};
829
830static struct platform_device audio = {
831 .name = "hx4700-audio",
832 .id = -1,
833};
834
835
836/*
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200837 * Platform devices
838 */
839
840static struct platform_device *devices[] __initdata = {
841 &asic3,
842 &gpio_keys,
Paul Parsonsb2596c62012-05-12 12:31:02 +0100843 &navpoint,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200844 &backlight,
845 &w3220,
Dmitry Artamonow19d6c132009-11-25 14:33:15 +0300846 &hx4700_lcd,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200847 &egpio,
848 &bq24022,
849 &gpio_vbus,
850 &power_supply,
851 &strataflash,
Axel Lind87f6142011-12-30 12:06:11 +0800852 &audio,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200853};
854
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200855static struct gpio global_gpios[] = {
856 { GPIO12_HX4700_ASIC3_IRQ, GPIOF_IN, "ASIC3_IRQ" },
857 { GPIO13_HX4700_W3220_IRQ, GPIOF_IN, "W3220_IRQ" },
858 { GPIO14_HX4700_nWLAN_IRQ, GPIOF_IN, "WLAN_IRQ" },
859 { GPIO59_HX4700_LCD_PC1, GPIOF_OUT_INIT_HIGH, "LCD_PC1" },
860 { GPIO62_HX4700_LCD_nRESET, GPIOF_OUT_INIT_HIGH, "LCD_RESET" },
861 { GPIO70_HX4700_LCD_SLIN1, GPIOF_OUT_INIT_HIGH, "LCD_SLIN1" },
862 { GPIO84_HX4700_LCD_SQN, GPIOF_OUT_INIT_HIGH, "LCD_SQN" },
863 { GPIO110_HX4700_LCD_LVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_LVDD" },
864 { GPIO111_HX4700_LCD_AVDD_3V3_ON, GPIOF_OUT_INIT_HIGH, "LCD_AVDD" },
865 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
Paul Parsons6416c042012-06-11 15:31:14 +0100866 { GPIO61_HX4700_W3220_nRESET, GPIOF_OUT_INIT_HIGH, "W3220_nRESET" },
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200867 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
Paul Parsons6416c042012-06-11 15:31:14 +0100868 { GPIO81_HX4700_CPU_GP_nRESET, GPIOF_OUT_INIT_HIGH, "CPU_GP_nRESET" },
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200869 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
Paul Parsons6416c042012-06-11 15:31:14 +0100870 { GPIO116_HX4700_CPU_HW_nRESET, GPIOF_OUT_INIT_HIGH, "CPU_HW_nRESET" },
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200871};
872
873static void __init hx4700_init(void)
874{
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200875 int ret;
876
Paul Parsons6416c042012-06-11 15:31:14 +0100877 PCFR = PCFR_GPR_EN | PCFR_OPDE;
878
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200879 pxa2xx_mfp_config(ARRAY_AND_SIZE(hx4700_pin_config));
Paul Parsonse949f932012-05-02 16:49:24 +0100880 gpio_set_wake(GPIO12_HX4700_ASIC3_IRQ, 1);
Philipp Zabel6d49e6c2011-04-27 20:50:19 +0200881 ret = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
882 if (ret)
883 pr_err ("hx4700: Failed to request GPIOs.\n");
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200884
Russell Kingcc155c62009-11-09 13:34:08 +0800885 pxa_set_ffuart_info(NULL);
886 pxa_set_btuart_info(NULL);
887 pxa_set_stuart_info(NULL);
888
Linus Walleijd6cd33a2019-01-29 11:31:52 +0100889 gpiod_add_lookup_table(&bq24022_gpiod_table);
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200890 platform_add_devices(devices, ARRAY_SIZE(devices));
Paul Parsons8d6b00f2012-10-19 13:15:30 +0100891 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200892
893 pxa_set_ficp_info(&ficp_info);
894 pxa27x_set_i2c_power_info(NULL);
895 pxa_set_i2c_info(NULL);
Axel Lind87f6142011-12-30 12:06:11 +0800896 i2c_register_board_info(0, ARRAY_AND_SIZE(i2c_board_info));
Philipp Zabel6ea04142009-05-28 07:15:18 +0200897 i2c_register_board_info(1, ARRAY_AND_SIZE(pi2c_board_info));
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200898 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
899 spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
900
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200901 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 0);
902 mdelay(10);
903 gpio_set_value(GPIO71_HX4700_ASIC3_nRESET, 1);
904 mdelay(10);
Martin Vajnara52d2092014-12-24 00:27:57 +0100905
Robert Jarzmikf439b5c2018-05-26 11:38:34 +0200906 pxa_set_udc_info(&hx4700_udc_info);
Martin Vajnara52d2092014-12-24 00:27:57 +0100907 regulator_has_full_constraints();
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200908}
909
910MACHINE_START(H4700, "HP iPAQ HX4700")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400911 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200912 .map_io = pxa27x_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800913 .nr_irqs = HX4700_NR_IRQS,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200914 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800915 .handle_irq = pxa27x_handle_irq,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200916 .init_machine = hx4700_init,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700917 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000918 .restart = pxa_restart,
Philipp Zabeld3ca1952009-05-28 07:05:18 +0200919MACHINE_END