blob: d902a813aae398273c5b1e118b162128f55552f6 [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 */
Eric Miaobedbda92010-01-04 11:37:14 +080090 GPIOxx_LCD_TFT_16BPP,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010091
92 /* PWM */
93 GPIO16_PWM0_OUT,
94
Marek Vasutecf763c2009-07-16 19:37:29 +020095 /* FFUART */
96 GPIO34_FFUART_RXD,
97 GPIO39_FFUART_TXD,
98
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010099 /* MISC */
100 GPIO10_GPIO, /* hotsync button */
101 GPIO90_GPIO, /* power detect */
102 GPIO107_GPIO, /* earphone detect */
103};
104
105/******************************************************************************
106 * SD/MMC card controller
107 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100108static struct pxamci_platform_data palmt5_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200109 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
110 .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
111 .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
112 .gpio_power = GPIO_NR_PALMT5_SD_POWER,
Marek Vasut9845b6b2009-07-16 19:38:41 +0200113 .detect_delay = 20,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100114};
115
116/******************************************************************************
117 * GPIO keyboard
118 ******************************************************************************/
119static unsigned int palmt5_matrix_keys[] = {
120 KEY(0, 0, KEY_POWER),
121 KEY(0, 1, KEY_F1),
122 KEY(0, 2, KEY_ENTER),
123
124 KEY(1, 0, KEY_F2),
125 KEY(1, 1, KEY_F3),
126 KEY(1, 2, KEY_F4),
127
128 KEY(2, 0, KEY_UP),
129 KEY(2, 2, KEY_DOWN),
130
131 KEY(3, 0, KEY_RIGHT),
132 KEY(3, 2, KEY_LEFT),
133};
134
135static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
136 .matrix_key_rows = 4,
137 .matrix_key_cols = 3,
138 .matrix_key_map = palmt5_matrix_keys,
139 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
140
141 .debounce_interval = 30,
142};
143
144/******************************************************************************
145 * GPIO keys
146 ******************************************************************************/
147static struct gpio_keys_button palmt5_pxa_buttons[] = {
148 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
149};
150
151static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
152 .buttons = palmt5_pxa_buttons,
153 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
154};
155
156static struct platform_device palmt5_pxa_keys = {
157 .name = "gpio-keys",
158 .id = -1,
159 .dev = {
160 .platform_data = &palmt5_pxa_keys_data,
161 },
162};
163
164/******************************************************************************
165 * Backlight
166 ******************************************************************************/
167static int palmt5_backlight_init(struct device *dev)
168{
169 int ret;
170
171 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
172 if (ret)
173 goto err;
174 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
175 if (ret)
176 goto err2;
177 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
178 if (ret)
179 goto err2;
180 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
181 if (ret)
182 goto err3;
183
184 return 0;
185err3:
186 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
187err2:
188 gpio_free(GPIO_NR_PALMT5_BL_POWER);
189err:
190 return ret;
191}
192
Eric Miao2d51a522010-01-04 11:42:01 +0800193static int palmt5_backlight_notify(struct device *dev, int brightness)
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100194{
195 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
196 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
197 return brightness;
198}
199
200static void palmt5_backlight_exit(struct device *dev)
201{
202 gpio_free(GPIO_NR_PALMT5_BL_POWER);
203 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
204}
205
206static struct platform_pwm_backlight_data palmt5_backlight_data = {
207 .pwm_id = 0,
208 .max_brightness = PALMT5_MAX_INTENSITY,
209 .dft_brightness = PALMT5_MAX_INTENSITY,
210 .pwm_period_ns = PALMT5_PERIOD_NS,
211 .init = palmt5_backlight_init,
212 .notify = palmt5_backlight_notify,
213 .exit = palmt5_backlight_exit,
214};
215
216static struct platform_device palmt5_backlight = {
217 .name = "pwm-backlight",
218 .dev = {
219 .parent = &pxa27x_device_pwm0.dev,
220 .platform_data = &palmt5_backlight_data,
221 },
222};
223
224/******************************************************************************
225 * IrDA
226 ******************************************************************************/
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100227static struct pxaficp_platform_data palmt5_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200228 .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
229 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100230};
231
232/******************************************************************************
233 * UDC
234 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200235static struct gpio_vbus_mach_info palmt5_udc_info = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100236 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
237 .gpio_vbus_inverted = 1,
Marek Vasutefb12cd2009-04-12 16:37:23 +0200238 .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200239};
240
241static struct platform_device palmt5_gpio_vbus = {
242 .name = "gpio-vbus",
243 .id = -1,
244 .dev = {
245 .platform_data = &palmt5_udc_info,
246 },
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100247};
248
249/******************************************************************************
250 * Power supply
251 ******************************************************************************/
252static int power_supply_init(struct device *dev)
253{
254 int ret;
255
256 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
257 if (ret)
258 goto err1;
259 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
260 if (ret)
261 goto err2;
262
263 return 0;
264err2:
265 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
266err1:
267 return ret;
268}
269
270static int palmt5_is_ac_online(void)
271{
272 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
273}
274
275static void power_supply_exit(struct device *dev)
276{
277 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
278}
279
280static char *palmt5_supplicants[] = {
281 "main-battery",
282};
283
284static struct pda_power_pdata power_supply_info = {
285 .init = power_supply_init,
286 .is_ac_online = palmt5_is_ac_online,
287 .exit = power_supply_exit,
288 .supplied_to = palmt5_supplicants,
289 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
290};
291
292static struct platform_device power_supply = {
293 .name = "pda-power",
294 .id = -1,
295 .dev = {
296 .platform_data = &power_supply_info,
297 },
298};
299
300/******************************************************************************
301 * WM97xx battery
302 ******************************************************************************/
303static struct wm97xx_batt_info wm97xx_batt_pdata = {
304 .batt_aux = WM97XX_AUX_ID3,
305 .temp_aux = WM97XX_AUX_ID2,
306 .charge_gpio = -1,
307 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
308 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
309 .batt_mult = 1000,
310 .batt_div = 414,
311 .temp_mult = 1,
312 .temp_div = 1,
313 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
314 .batt_name = "main-batt",
315};
316
317/******************************************************************************
318 * aSoC audio
319 ******************************************************************************/
Marek Vasute91fb912009-04-17 11:37:35 +0200320static struct palm27x_asoc_info palmt5_asoc_pdata = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100321 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
322};
323
Marek Vasute91fb912009-04-17 11:37:35 +0200324static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
325 .reset_gpio = 95,
326};
327
328static struct platform_device palmt5_asoc = {
329 .name = "palm27x-asoc",
330 .id = -1,
331 .dev = {
332 .platform_data = &palmt5_asoc_pdata,
333 },
334};
335
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100336/******************************************************************************
337 * Framebuffer
338 ******************************************************************************/
339static struct pxafb_mode_info palmt5_lcd_modes[] = {
340{
341 .pixclock = 57692,
342 .xres = 320,
343 .yres = 480,
344 .bpp = 16,
345
346 .left_margin = 32,
347 .right_margin = 1,
348 .upper_margin = 7,
349 .lower_margin = 1,
350
351 .hsync_len = 4,
352 .vsync_len = 1,
353},
354};
355
356static struct pxafb_mach_info palmt5_lcd_screen = {
357 .modes = palmt5_lcd_modes,
358 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
359 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
360};
361
362/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100363 * Power management - standby
364 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200365static void __init palmt5_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100366{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200367 static u32 resume[] = {
368 0xe3a00101, /* mov r0, #0x40000000 */
369 0xe380060f, /* orr r0, r0, #0x00f00000 */
370 0xe590f008, /* ldr pc, [r0, #0x08] */
371 };
Marek Vasut81854f82009-03-28 12:37:42 +0100372
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200373 /* copy the bootloader */
374 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100375}
376
Marek Vasut81854f82009-03-28 12:37:42 +0100377/******************************************************************************
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100378 * Machine init
379 ******************************************************************************/
380static struct platform_device *devices[] __initdata = {
381#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
382 &palmt5_pxa_keys,
383#endif
384 &palmt5_backlight,
385 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200386 &palmt5_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200387 &palmt5_gpio_vbus,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100388};
389
390/* setup udc GPIOs initial state */
391static void __init palmt5_udc_init(void)
392{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200393 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
394 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
395 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100396 }
397}
398
399static void __init palmt5_init(void)
400{
401 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
402
Russell Kingcc155c62009-11-09 13:34:08 +0800403 pxa_set_ffuart_info(NULL);
404 pxa_set_btuart_info(NULL);
405 pxa_set_stuart_info(NULL);
406
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200407 palmt5_pm_init();
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100408 set_pxa_fb_info(&palmt5_lcd_screen);
409 pxa_set_mci_info(&palmt5_mci_platform_data);
410 palmt5_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200411 pxa_set_ac97_info(&palmt5_ac97_pdata);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100412 pxa_set_ficp_info(&palmt5_ficp_platform_data);
413 pxa_set_keypad_info(&palmt5_keypad_platform_data);
414 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200415
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100416 platform_add_devices(devices, ARRAY_SIZE(devices));
417}
418
419MACHINE_START(PALMT5, "Palm Tungsten|T5")
420 .phys_io = PALMT5_PHYS_IO_START,
421 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
422 .boot_params = 0xa0000100,
423 .map_io = pxa_map_io,
424 .init_irq = pxa27x_init_irq,
425 .timer = &pxa_timer,
426 .init_machine = palmt5_init
427MACHINE_END