blob: 5e92d84fe50d0805be94a07f583c40ee46f0e6c4 [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>
Russell King8d717a52010-05-22 19:47:18 +010024#include <linux/memblock.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010025#include <linux/pda_power.h>
26#include <linux/pwm_backlight.h>
27#include <linux/gpio.h>
28#include <linux/wm97xx_batt.h>
29#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020030#include <linux/usb/gpio_vbus.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010031
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
Eric Miao51c62982009-01-02 23:17:22 +080036#include <mach/pxa27x.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010037#include <mach/audio.h>
38#include <mach/palmt5.h>
39#include <mach/mmc.h>
40#include <mach/pxafb.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010041#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h>
43#include <mach/udc.h>
44#include <mach/palmasoc.h>
45
46#include "generic.h"
47#include "devices.h"
48
49/******************************************************************************
50 * Pin configuration
51 ******************************************************************************/
52static unsigned long palmt5_pin_config[] __initdata = {
53 /* MMC */
54 GPIO32_MMC_CLK,
55 GPIO92_MMC_DAT_0,
56 GPIO109_MMC_DAT_1,
57 GPIO110_MMC_DAT_2,
58 GPIO111_MMC_DAT_3,
59 GPIO112_MMC_CMD,
60 GPIO14_GPIO, /* SD detect */
61 GPIO114_GPIO, /* SD power */
62 GPIO115_GPIO, /* SD r/o switch */
63
64 /* AC97 */
65 GPIO28_AC97_BITCLK,
66 GPIO29_AC97_SDATA_IN_0,
67 GPIO30_AC97_SDATA_OUT,
68 GPIO31_AC97_SYNC,
Marek Vasut6ec04f42009-05-22 01:39:10 +020069 GPIO89_AC97_SYSCLK,
Marek Vasutefb12cd2009-04-12 16:37:23 +020070 GPIO95_AC97_nRESET,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010071
72 /* IrDA */
73 GPIO40_GPIO, /* ir disable */
74 GPIO46_FICP_RXD,
75 GPIO47_FICP_TXD,
76
77 /* USB */
78 GPIO15_GPIO, /* usb detect */
Marek Vasutefb12cd2009-04-12 16:37:23 +020079 GPIO93_GPIO, /* usb power */
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010080
81 /* MATRIX KEYPAD */
Marek Vasut81854f82009-03-28 12:37:42 +010082 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
83 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
84 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
85 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010086 GPIO103_KP_MKOUT_0,
87 GPIO104_KP_MKOUT_1,
88 GPIO105_KP_MKOUT_2,
89
90 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +080091 GPIOxx_LCD_TFT_16BPP,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010092
93 /* PWM */
94 GPIO16_PWM0_OUT,
95
Marek Vasutecf763c2009-07-16 19:37:29 +020096 /* FFUART */
97 GPIO34_FFUART_RXD,
98 GPIO39_FFUART_TXD,
99
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100100 /* MISC */
101 GPIO10_GPIO, /* hotsync button */
102 GPIO90_GPIO, /* power detect */
103 GPIO107_GPIO, /* earphone detect */
104};
105
106/******************************************************************************
107 * SD/MMC card controller
108 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100109static struct pxamci_platform_data palmt5_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200110 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
111 .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
112 .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
113 .gpio_power = GPIO_NR_PALMT5_SD_POWER,
Eric Miaof97cab22010-04-14 07:00:42 +0800114 .detect_delay_ms = 200,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100115};
116
117/******************************************************************************
118 * GPIO keyboard
119 ******************************************************************************/
120static unsigned int palmt5_matrix_keys[] = {
121 KEY(0, 0, KEY_POWER),
122 KEY(0, 1, KEY_F1),
123 KEY(0, 2, KEY_ENTER),
124
125 KEY(1, 0, KEY_F2),
126 KEY(1, 1, KEY_F3),
127 KEY(1, 2, KEY_F4),
128
129 KEY(2, 0, KEY_UP),
130 KEY(2, 2, KEY_DOWN),
131
132 KEY(3, 0, KEY_RIGHT),
133 KEY(3, 2, KEY_LEFT),
134};
135
136static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
137 .matrix_key_rows = 4,
138 .matrix_key_cols = 3,
139 .matrix_key_map = palmt5_matrix_keys,
140 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
141
142 .debounce_interval = 30,
143};
144
145/******************************************************************************
146 * GPIO keys
147 ******************************************************************************/
148static struct gpio_keys_button palmt5_pxa_buttons[] = {
149 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
150};
151
152static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
153 .buttons = palmt5_pxa_buttons,
154 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
155};
156
157static struct platform_device palmt5_pxa_keys = {
158 .name = "gpio-keys",
159 .id = -1,
160 .dev = {
161 .platform_data = &palmt5_pxa_keys_data,
162 },
163};
164
165/******************************************************************************
166 * Backlight
167 ******************************************************************************/
168static int palmt5_backlight_init(struct device *dev)
169{
170 int ret;
171
172 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
173 if (ret)
174 goto err;
175 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
176 if (ret)
177 goto err2;
178 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
179 if (ret)
180 goto err2;
181 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
182 if (ret)
183 goto err3;
184
185 return 0;
186err3:
187 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
188err2:
189 gpio_free(GPIO_NR_PALMT5_BL_POWER);
190err:
191 return ret;
192}
193
Eric Miao2d51a522010-01-04 11:42:01 +0800194static int palmt5_backlight_notify(struct device *dev, int brightness)
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100195{
196 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
197 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
198 return brightness;
199}
200
201static void palmt5_backlight_exit(struct device *dev)
202{
203 gpio_free(GPIO_NR_PALMT5_BL_POWER);
204 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
205}
206
207static struct platform_pwm_backlight_data palmt5_backlight_data = {
208 .pwm_id = 0,
209 .max_brightness = PALMT5_MAX_INTENSITY,
210 .dft_brightness = PALMT5_MAX_INTENSITY,
211 .pwm_period_ns = PALMT5_PERIOD_NS,
212 .init = palmt5_backlight_init,
213 .notify = palmt5_backlight_notify,
214 .exit = palmt5_backlight_exit,
215};
216
217static struct platform_device palmt5_backlight = {
218 .name = "pwm-backlight",
219 .dev = {
220 .parent = &pxa27x_device_pwm0.dev,
221 .platform_data = &palmt5_backlight_data,
222 },
223};
224
225/******************************************************************************
226 * IrDA
227 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100228static struct pxaficp_platform_data palmt5_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200229 .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
230 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100231};
232
233/******************************************************************************
234 * UDC
235 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200236static struct gpio_vbus_mach_info palmt5_udc_info = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100237 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
238 .gpio_vbus_inverted = 1,
Marek Vasutefb12cd2009-04-12 16:37:23 +0200239 .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200240};
241
242static struct platform_device palmt5_gpio_vbus = {
243 .name = "gpio-vbus",
244 .id = -1,
245 .dev = {
246 .platform_data = &palmt5_udc_info,
247 },
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100248};
249
250/******************************************************************************
251 * Power supply
252 ******************************************************************************/
253static int power_supply_init(struct device *dev)
254{
255 int ret;
256
257 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
258 if (ret)
259 goto err1;
260 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
261 if (ret)
262 goto err2;
263
264 return 0;
265err2:
266 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
267err1:
268 return ret;
269}
270
271static int palmt5_is_ac_online(void)
272{
273 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
274}
275
276static void power_supply_exit(struct device *dev)
277{
278 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
279}
280
281static char *palmt5_supplicants[] = {
282 "main-battery",
283};
284
285static struct pda_power_pdata power_supply_info = {
286 .init = power_supply_init,
287 .is_ac_online = palmt5_is_ac_online,
288 .exit = power_supply_exit,
289 .supplied_to = palmt5_supplicants,
290 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
291};
292
293static struct platform_device power_supply = {
294 .name = "pda-power",
295 .id = -1,
296 .dev = {
297 .platform_data = &power_supply_info,
298 },
299};
300
301/******************************************************************************
302 * WM97xx battery
303 ******************************************************************************/
304static struct wm97xx_batt_info wm97xx_batt_pdata = {
305 .batt_aux = WM97XX_AUX_ID3,
306 .temp_aux = WM97XX_AUX_ID2,
307 .charge_gpio = -1,
308 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
309 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
310 .batt_mult = 1000,
311 .batt_div = 414,
312 .temp_mult = 1,
313 .temp_div = 1,
314 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
315 .batt_name = "main-batt",
316};
317
318/******************************************************************************
319 * aSoC audio
320 ******************************************************************************/
Marek Vasute91fb912009-04-17 11:37:35 +0200321static struct palm27x_asoc_info palmt5_asoc_pdata = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100322 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
323};
324
Marek Vasute91fb912009-04-17 11:37:35 +0200325static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
326 .reset_gpio = 95,
327};
328
329static struct platform_device palmt5_asoc = {
330 .name = "palm27x-asoc",
331 .id = -1,
332 .dev = {
333 .platform_data = &palmt5_asoc_pdata,
334 },
335};
336
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100337/******************************************************************************
338 * Framebuffer
339 ******************************************************************************/
340static struct pxafb_mode_info palmt5_lcd_modes[] = {
341{
342 .pixclock = 57692,
343 .xres = 320,
344 .yres = 480,
345 .bpp = 16,
346
347 .left_margin = 32,
348 .right_margin = 1,
349 .upper_margin = 7,
350 .lower_margin = 1,
351
352 .hsync_len = 4,
353 .vsync_len = 1,
354},
355};
356
357static struct pxafb_mach_info palmt5_lcd_screen = {
358 .modes = palmt5_lcd_modes,
359 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
360 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
361};
362
363/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100364 * Power management - standby
365 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200366static void __init palmt5_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100367{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200368 static u32 resume[] = {
369 0xe3a00101, /* mov r0, #0x40000000 */
370 0xe380060f, /* orr r0, r0, #0x00f00000 */
371 0xe590f008, /* ldr pc, [r0, #0x08] */
372 };
Marek Vasut81854f82009-03-28 12:37:42 +0100373
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200374 /* copy the bootloader */
375 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100376}
377
Marek Vasut81854f82009-03-28 12:37:42 +0100378/******************************************************************************
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100379 * Machine init
380 ******************************************************************************/
381static struct platform_device *devices[] __initdata = {
382#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
383 &palmt5_pxa_keys,
384#endif
385 &palmt5_backlight,
386 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200387 &palmt5_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200388 &palmt5_gpio_vbus,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100389};
390
391/* setup udc GPIOs initial state */
392static void __init palmt5_udc_init(void)
393{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200394 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
395 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
396 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100397 }
398}
399
Russell King98c672c2010-05-22 18:18:57 +0100400static void __init palmt5_reserve(void)
401{
Russell King8d717a52010-05-22 19:47:18 +0100402 memblock_reserve(0xa0200000, 0x1000);
Russell King98c672c2010-05-22 18:18:57 +0100403}
404
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100405static void __init palmt5_init(void)
406{
407 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
408
Russell Kingcc155c62009-11-09 13:34:08 +0800409 pxa_set_ffuart_info(NULL);
410 pxa_set_btuart_info(NULL);
411 pxa_set_stuart_info(NULL);
412
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200413 palmt5_pm_init();
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100414 set_pxa_fb_info(&palmt5_lcd_screen);
415 pxa_set_mci_info(&palmt5_mci_platform_data);
416 palmt5_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200417 pxa_set_ac97_info(&palmt5_ac97_pdata);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100418 pxa_set_ficp_info(&palmt5_ficp_platform_data);
419 pxa_set_keypad_info(&palmt5_keypad_platform_data);
420 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200421
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100422 platform_add_devices(devices, ARRAY_SIZE(devices));
423}
424
425MACHINE_START(PALMT5, "Palm Tungsten|T5")
426 .phys_io = PALMT5_PHYS_IO_START,
427 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
428 .boot_params = 0xa0000100,
429 .map_io = pxa_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100430 .reserve = palmt5_reserve,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100431 .init_irq = pxa27x_init_irq,
432 .timer = &pxa_timer,
433 .init_machine = palmt5_init
434MACHINE_END