blob: 42d0528d3e9eadca991780b4a9e7955af2f3d0a9 [file] [log] [blame]
Marek Vasut0f6ff0f2008-11-20 00:58:38 +01001/*
2 * Hardware definitions for Palm Tungsten|T5
3 *
4 * Author: Marek Vasut <marek.vasut@gmail.com>
5 *
6 * Based on work of:
7 * Ales Snuparek <snuparek@atlas.cz>
8 * Justin Kendrick <twilightsentry@gmail.com>
9 * RichardT5 <richard_t5@users.sourceforge.net>
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 * (find more info at www.hackndev.com)
16 *
17 */
18
19#include <linux/platform_device.h>
20#include <linux/delay.h>
21#include <linux/irq.h>
22#include <linux/gpio_keys.h>
23#include <linux/input.h>
24#include <linux/pda_power.h>
25#include <linux/pwm_backlight.h>
26#include <linux/gpio.h>
27#include <linux/wm97xx_batt.h>
28#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020029#include <linux/usb/gpio_vbus.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010030
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
Eric Miao51c62982009-01-02 23:17:22 +080035#include <mach/pxa27x.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010036#include <mach/audio.h>
37#include <mach/palmt5.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010040#include <mach/irda.h>
41#include <mach/pxa27x_keypad.h>
42#include <mach/udc.h>
43#include <mach/palmasoc.h>
44
45#include "generic.h"
46#include "devices.h"
47
48/******************************************************************************
49 * Pin configuration
50 ******************************************************************************/
51static unsigned long palmt5_pin_config[] __initdata = {
52 /* MMC */
53 GPIO32_MMC_CLK,
54 GPIO92_MMC_DAT_0,
55 GPIO109_MMC_DAT_1,
56 GPIO110_MMC_DAT_2,
57 GPIO111_MMC_DAT_3,
58 GPIO112_MMC_CMD,
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
62
63 /* AC97 */
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020068 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020069 GPIO95_AC97_nRESET,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010070
71 /* IrDA */
72 GPIO40_GPIO, /* ir disable */
73 GPIO46_FICP_RXD,
74 GPIO47_FICP_TXD,
75
76 /* USB */
77 GPIO15_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020078 GPIO93_GPIO, /* usb power */
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010079
80 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +010081 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
82 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
83 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
84 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010085 GPIO103_KP_MKOUT_0,
86 GPIO104_KP_MKOUT_1,
87 GPIO105_KP_MKOUT_2,
88
89 /* LCD */
90 GPIO58_LCD_LDD_0,
91 GPIO59_LCD_LDD_1,
92 GPIO60_LCD_LDD_2,
93 GPIO61_LCD_LDD_3,
94 GPIO62_LCD_LDD_4,
95 GPIO63_LCD_LDD_5,
96 GPIO64_LCD_LDD_6,
97 GPIO65_LCD_LDD_7,
98 GPIO66_LCD_LDD_8,
99 GPIO67_LCD_LDD_9,
100 GPIO68_LCD_LDD_10,
101 GPIO69_LCD_LDD_11,
102 GPIO70_LCD_LDD_12,
103 GPIO71_LCD_LDD_13,
104 GPIO72_LCD_LDD_14,
105 GPIO73_LCD_LDD_15,
106 GPIO74_LCD_FCLK,
107 GPIO75_LCD_LCLK,
108 GPIO76_LCD_PCLK,
109 GPIO77_LCD_BIAS,
110
111 /* PWM */
112 GPIO16_PWM0_OUT,
113
Marek Vasutecf763c2009-07-16 19:37:29 +0200114 /* FFUART */
115 GPIO34_FFUART_RXD,
116 GPIO39_FFUART_TXD,
117
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100118 /* MISC */
119 GPIO10_GPIO, /* hotsync button */
120 GPIO90_GPIO, /* power detect */
121 GPIO107_GPIO, /* earphone detect */
122};
123
124/******************************************************************************
125 * SD/MMC card controller
126 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100127static struct pxamci_platform_data palmt5_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200128 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
129 .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
130 .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
131 .gpio_power = GPIO_NR_PALMT5_SD_POWER,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100132};
133
134/******************************************************************************
135 * GPIO keyboard
136 ******************************************************************************/
137static unsigned int palmt5_matrix_keys[] = {
138 KEY(0, 0, KEY_POWER),
139 KEY(0, 1, KEY_F1),
140 KEY(0, 2, KEY_ENTER),
141
142 KEY(1, 0, KEY_F2),
143 KEY(1, 1, KEY_F3),
144 KEY(1, 2, KEY_F4),
145
146 KEY(2, 0, KEY_UP),
147 KEY(2, 2, KEY_DOWN),
148
149 KEY(3, 0, KEY_RIGHT),
150 KEY(3, 2, KEY_LEFT),
151};
152
153static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
154 .matrix_key_rows = 4,
155 .matrix_key_cols = 3,
156 .matrix_key_map = palmt5_matrix_keys,
157 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
158
159 .debounce_interval = 30,
160};
161
162/******************************************************************************
163 * GPIO keys
164 ******************************************************************************/
165static struct gpio_keys_button palmt5_pxa_buttons[] = {
166 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
167};
168
169static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
170 .buttons = palmt5_pxa_buttons,
171 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
172};
173
174static struct platform_device palmt5_pxa_keys = {
175 .name = "gpio-keys",
176 .id = -1,
177 .dev = {
178 .platform_data = &palmt5_pxa_keys_data,
179 },
180};
181
182/******************************************************************************
183 * Backlight
184 ******************************************************************************/
185static int palmt5_backlight_init(struct device *dev)
186{
187 int ret;
188
189 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
190 if (ret)
191 goto err;
192 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
193 if (ret)
194 goto err2;
195 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
196 if (ret)
197 goto err2;
198 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
199 if (ret)
200 goto err3;
201
202 return 0;
203err3:
204 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
205err2:
206 gpio_free(GPIO_NR_PALMT5_BL_POWER);
207err:
208 return ret;
209}
210
211static int palmt5_backlight_notify(int brightness)
212{
213 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
214 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
215 return brightness;
216}
217
218static void palmt5_backlight_exit(struct device *dev)
219{
220 gpio_free(GPIO_NR_PALMT5_BL_POWER);
221 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
222}
223
224static struct platform_pwm_backlight_data palmt5_backlight_data = {
225 .pwm_id = 0,
226 .max_brightness = PALMT5_MAX_INTENSITY,
227 .dft_brightness = PALMT5_MAX_INTENSITY,
228 .pwm_period_ns = PALMT5_PERIOD_NS,
229 .init = palmt5_backlight_init,
230 .notify = palmt5_backlight_notify,
231 .exit = palmt5_backlight_exit,
232};
233
234static struct platform_device palmt5_backlight = {
235 .name = "pwm-backlight",
236 .dev = {
237 .parent = &pxa27x_device_pwm0.dev,
238 .platform_data = &palmt5_backlight_data,
239 },
240};
241
242/******************************************************************************
243 * IrDA
244 ******************************************************************************/
245static int palmt5_irda_startup(struct device *dev)
246{
247 int err;
248 err = gpio_request(GPIO_NR_PALMT5_IR_DISABLE, "IR DISABLE");
249 if (err)
250 goto err;
251 err = gpio_direction_output(GPIO_NR_PALMT5_IR_DISABLE, 1);
252 if (err)
253 gpio_free(GPIO_NR_PALMT5_IR_DISABLE);
254err:
255 return err;
256}
257
258static void palmt5_irda_shutdown(struct device *dev)
259{
260 gpio_free(GPIO_NR_PALMT5_IR_DISABLE);
261}
262
263static void palmt5_irda_transceiver_mode(struct device *dev, int mode)
264{
265 gpio_set_value(GPIO_NR_PALMT5_IR_DISABLE, mode & IR_OFF);
266 pxa2xx_transceiver_mode(dev, mode);
267}
268
269static struct pxaficp_platform_data palmt5_ficp_platform_data = {
270 .startup = palmt5_irda_startup,
271 .shutdown = palmt5_irda_shutdown,
272 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
273 .transceiver_mode = palmt5_irda_transceiver_mode,
274};
275
276/******************************************************************************
277 * UDC
278 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200279static struct gpio_vbus_mach_info palmt5_udc_info = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100280 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
281 .gpio_vbus_inverted = 1,
Marek Vasutefb12cd2009-04-12 16:37:23 +0200282 .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200283};
284
285static struct platform_device palmt5_gpio_vbus = {
286 .name = "gpio-vbus",
287 .id = -1,
288 .dev = {
289 .platform_data = &palmt5_udc_info,
290 },
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100291};
292
293/******************************************************************************
294 * Power supply
295 ******************************************************************************/
296static int power_supply_init(struct device *dev)
297{
298 int ret;
299
300 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
301 if (ret)
302 goto err1;
303 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
304 if (ret)
305 goto err2;
306
307 return 0;
308err2:
309 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
310err1:
311 return ret;
312}
313
314static int palmt5_is_ac_online(void)
315{
316 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
317}
318
319static void power_supply_exit(struct device *dev)
320{
321 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
322}
323
324static char *palmt5_supplicants[] = {
325 "main-battery",
326};
327
328static struct pda_power_pdata power_supply_info = {
329 .init = power_supply_init,
330 .is_ac_online = palmt5_is_ac_online,
331 .exit = power_supply_exit,
332 .supplied_to = palmt5_supplicants,
333 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
334};
335
336static struct platform_device power_supply = {
337 .name = "pda-power",
338 .id = -1,
339 .dev = {
340 .platform_data = &power_supply_info,
341 },
342};
343
344/******************************************************************************
345 * WM97xx battery
346 ******************************************************************************/
347static struct wm97xx_batt_info wm97xx_batt_pdata = {
348 .batt_aux = WM97XX_AUX_ID3,
349 .temp_aux = WM97XX_AUX_ID2,
350 .charge_gpio = -1,
351 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
352 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
353 .batt_mult = 1000,
354 .batt_div = 414,
355 .temp_mult = 1,
356 .temp_div = 1,
357 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
358 .batt_name = "main-batt",
359};
360
361/******************************************************************************
362 * aSoC audio
363 ******************************************************************************/
Marek Vasute91fb912009-04-17 11:37:35 +0200364static struct palm27x_asoc_info palmt5_asoc_pdata = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100365 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
366};
367
Marek Vasute91fb912009-04-17 11:37:35 +0200368static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
369 .reset_gpio = 95,
370};
371
372static struct platform_device palmt5_asoc = {
373 .name = "palm27x-asoc",
374 .id = -1,
375 .dev = {
376 .platform_data = &palmt5_asoc_pdata,
377 },
378};
379
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100380/******************************************************************************
381 * Framebuffer
382 ******************************************************************************/
383static struct pxafb_mode_info palmt5_lcd_modes[] = {
384{
385 .pixclock = 57692,
386 .xres = 320,
387 .yres = 480,
388 .bpp = 16,
389
390 .left_margin = 32,
391 .right_margin = 1,
392 .upper_margin = 7,
393 .lower_margin = 1,
394
395 .hsync_len = 4,
396 .vsync_len = 1,
397},
398};
399
400static struct pxafb_mach_info palmt5_lcd_screen = {
401 .modes = palmt5_lcd_modes,
402 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
403 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
404};
405
406/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100407 * Power management - standby
408 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200409static void __init palmt5_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100410{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200411 static u32 resume[] = {
412 0xe3a00101, /* mov r0, #0x40000000 */
413 0xe380060f, /* orr r0, r0, #0x00f00000 */
414 0xe590f008, /* ldr pc, [r0, #0x08] */
415 };
Marek Vasut81854f82009-03-28 12:37:42 +0100416
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200417 /* copy the bootloader */
418 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100419}
420
Marek Vasut81854f82009-03-28 12:37:42 +0100421/******************************************************************************
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100422 * Machine init
423 ******************************************************************************/
424static struct platform_device *devices[] __initdata = {
425#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
426 &palmt5_pxa_keys,
427#endif
428 &palmt5_backlight,
429 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200430 &palmt5_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200431 &palmt5_gpio_vbus,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100432};
433
434/* setup udc GPIOs initial state */
435static void __init palmt5_udc_init(void)
436{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200437 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
438 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
439 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100440 }
441}
442
443static void __init palmt5_init(void)
444{
445 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
446
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200447 palmt5_pm_init();
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100448 set_pxa_fb_info(&palmt5_lcd_screen);
449 pxa_set_mci_info(&palmt5_mci_platform_data);
450 palmt5_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200451 pxa_set_ac97_info(&palmt5_ac97_pdata);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100452 pxa_set_ficp_info(&palmt5_ficp_platform_data);
453 pxa_set_keypad_info(&palmt5_keypad_platform_data);
454 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200455
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100456 platform_add_devices(devices, ARRAY_SIZE(devices));
457}
458
459MACHINE_START(PALMT5, "Palm Tungsten|T5")
460 .phys_io = PALMT5_PHYS_IO_START,
461 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
462 .boot_params = 0xa0000100,
463 .map_io = pxa_map_io,
464 .init_irq = pxa27x_init_irq,
465 .timer = &pxa_timer,
466 .init_machine = palmt5_init
467MACHINE_END