blob: 2dd7ce28556b4962a241fbb5ea085a0cb5b0f297 [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 Vasut9845b6b2009-07-16 19:38:41 +0200132 .detect_delay = 20,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100133};
134
135/******************************************************************************
136 * GPIO keyboard
137 ******************************************************************************/
138static unsigned int palmt5_matrix_keys[] = {
139 KEY(0, 0, KEY_POWER),
140 KEY(0, 1, KEY_F1),
141 KEY(0, 2, KEY_ENTER),
142
143 KEY(1, 0, KEY_F2),
144 KEY(1, 1, KEY_F3),
145 KEY(1, 2, KEY_F4),
146
147 KEY(2, 0, KEY_UP),
148 KEY(2, 2, KEY_DOWN),
149
150 KEY(3, 0, KEY_RIGHT),
151 KEY(3, 2, KEY_LEFT),
152};
153
154static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
155 .matrix_key_rows = 4,
156 .matrix_key_cols = 3,
157 .matrix_key_map = palmt5_matrix_keys,
158 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
159
160 .debounce_interval = 30,
161};
162
163/******************************************************************************
164 * GPIO keys
165 ******************************************************************************/
166static struct gpio_keys_button palmt5_pxa_buttons[] = {
167 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
168};
169
170static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
171 .buttons = palmt5_pxa_buttons,
172 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
173};
174
175static struct platform_device palmt5_pxa_keys = {
176 .name = "gpio-keys",
177 .id = -1,
178 .dev = {
179 .platform_data = &palmt5_pxa_keys_data,
180 },
181};
182
183/******************************************************************************
184 * Backlight
185 ******************************************************************************/
186static int palmt5_backlight_init(struct device *dev)
187{
188 int ret;
189
190 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
191 if (ret)
192 goto err;
193 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
194 if (ret)
195 goto err2;
196 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
197 if (ret)
198 goto err2;
199 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
200 if (ret)
201 goto err3;
202
203 return 0;
204err3:
205 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
206err2:
207 gpio_free(GPIO_NR_PALMT5_BL_POWER);
208err:
209 return ret;
210}
211
212static int palmt5_backlight_notify(int brightness)
213{
214 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
215 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
216 return brightness;
217}
218
219static void palmt5_backlight_exit(struct device *dev)
220{
221 gpio_free(GPIO_NR_PALMT5_BL_POWER);
222 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
223}
224
225static struct platform_pwm_backlight_data palmt5_backlight_data = {
226 .pwm_id = 0,
227 .max_brightness = PALMT5_MAX_INTENSITY,
228 .dft_brightness = PALMT5_MAX_INTENSITY,
229 .pwm_period_ns = PALMT5_PERIOD_NS,
230 .init = palmt5_backlight_init,
231 .notify = palmt5_backlight_notify,
232 .exit = palmt5_backlight_exit,
233};
234
235static struct platform_device palmt5_backlight = {
236 .name = "pwm-backlight",
237 .dev = {
238 .parent = &pxa27x_device_pwm0.dev,
239 .platform_data = &palmt5_backlight_data,
240 },
241};
242
243/******************************************************************************
244 * IrDA
245 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100246static struct pxaficp_platform_data palmt5_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200247 .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
248 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100249};
250
251/******************************************************************************
252 * UDC
253 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200254static struct gpio_vbus_mach_info palmt5_udc_info = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100255 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
256 .gpio_vbus_inverted = 1,
Marek Vasutefb12cd2009-04-12 16:37:23 +0200257 .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200258};
259
260static struct platform_device palmt5_gpio_vbus = {
261 .name = "gpio-vbus",
262 .id = -1,
263 .dev = {
264 .platform_data = &palmt5_udc_info,
265 },
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100266};
267
268/******************************************************************************
269 * Power supply
270 ******************************************************************************/
271static int power_supply_init(struct device *dev)
272{
273 int ret;
274
275 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
276 if (ret)
277 goto err1;
278 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
279 if (ret)
280 goto err2;
281
282 return 0;
283err2:
284 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
285err1:
286 return ret;
287}
288
289static int palmt5_is_ac_online(void)
290{
291 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
292}
293
294static void power_supply_exit(struct device *dev)
295{
296 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
297}
298
299static char *palmt5_supplicants[] = {
300 "main-battery",
301};
302
303static struct pda_power_pdata power_supply_info = {
304 .init = power_supply_init,
305 .is_ac_online = palmt5_is_ac_online,
306 .exit = power_supply_exit,
307 .supplied_to = palmt5_supplicants,
308 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
309};
310
311static struct platform_device power_supply = {
312 .name = "pda-power",
313 .id = -1,
314 .dev = {
315 .platform_data = &power_supply_info,
316 },
317};
318
319/******************************************************************************
320 * WM97xx battery
321 ******************************************************************************/
322static struct wm97xx_batt_info wm97xx_batt_pdata = {
323 .batt_aux = WM97XX_AUX_ID3,
324 .temp_aux = WM97XX_AUX_ID2,
325 .charge_gpio = -1,
326 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
327 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
328 .batt_mult = 1000,
329 .batt_div = 414,
330 .temp_mult = 1,
331 .temp_div = 1,
332 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
333 .batt_name = "main-batt",
334};
335
336/******************************************************************************
337 * aSoC audio
338 ******************************************************************************/
Marek Vasute91fb912009-04-17 11:37:35 +0200339static struct palm27x_asoc_info palmt5_asoc_pdata = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100340 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
341};
342
Marek Vasute91fb912009-04-17 11:37:35 +0200343static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
344 .reset_gpio = 95,
345};
346
347static struct platform_device palmt5_asoc = {
348 .name = "palm27x-asoc",
349 .id = -1,
350 .dev = {
351 .platform_data = &palmt5_asoc_pdata,
352 },
353};
354
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100355/******************************************************************************
356 * Framebuffer
357 ******************************************************************************/
358static struct pxafb_mode_info palmt5_lcd_modes[] = {
359{
360 .pixclock = 57692,
361 .xres = 320,
362 .yres = 480,
363 .bpp = 16,
364
365 .left_margin = 32,
366 .right_margin = 1,
367 .upper_margin = 7,
368 .lower_margin = 1,
369
370 .hsync_len = 4,
371 .vsync_len = 1,
372},
373};
374
375static struct pxafb_mach_info palmt5_lcd_screen = {
376 .modes = palmt5_lcd_modes,
377 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
378 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
379};
380
381/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100382 * Power management - standby
383 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200384static void __init palmt5_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100385{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200386 static u32 resume[] = {
387 0xe3a00101, /* mov r0, #0x40000000 */
388 0xe380060f, /* orr r0, r0, #0x00f00000 */
389 0xe590f008, /* ldr pc, [r0, #0x08] */
390 };
Marek Vasut81854f82009-03-28 12:37:42 +0100391
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200392 /* copy the bootloader */
393 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100394}
395
Marek Vasut81854f82009-03-28 12:37:42 +0100396/******************************************************************************
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100397 * Machine init
398 ******************************************************************************/
399static struct platform_device *devices[] __initdata = {
400#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
401 &palmt5_pxa_keys,
402#endif
403 &palmt5_backlight,
404 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200405 &palmt5_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200406 &palmt5_gpio_vbus,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100407};
408
409/* setup udc GPIOs initial state */
410static void __init palmt5_udc_init(void)
411{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200412 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
413 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
414 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100415 }
416}
417
418static void __init palmt5_init(void)
419{
420 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
421
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200422 palmt5_pm_init();
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100423 set_pxa_fb_info(&palmt5_lcd_screen);
424 pxa_set_mci_info(&palmt5_mci_platform_data);
425 palmt5_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200426 pxa_set_ac97_info(&palmt5_ac97_pdata);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100427 pxa_set_ficp_info(&palmt5_ficp_platform_data);
428 pxa_set_keypad_info(&palmt5_keypad_platform_data);
429 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200430
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100431 platform_add_devices(devices, ARRAY_SIZE(devices));
432}
433
434MACHINE_START(PALMT5, "Palm Tungsten|T5")
435 .phys_io = PALMT5_PHYS_IO_START,
436 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
437 .boot_params = 0xa0000100,
438 .map_io = pxa_map_io,
439 .init_irq = pxa27x_init_irq,
440 .timer = &pxa_timer,
441 .init_machine = palmt5_init
442MACHINE_END