blob: 0b36d7ddff25e6ced7c8d585f7ff28c784bd78a9 [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>
Marek Vasut241cf472010-06-04 03:07:33 +020027#include <linux/wm97xx.h>
Marek Vasut0f6ff0f2008-11-20 00:58:38 +010028#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,
Eric Miaof97cab22010-04-14 07:00:42 +0800113 .detect_delay_ms = 200,
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/******************************************************************************
Marek Vasut241cf472010-06-04 03:07:33 +0200301 * WM97xx audio, battery
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100302 ******************************************************************************/
Marek Vasut241cf472010-06-04 03:07:33 +0200303static struct wm97xx_batt_pdata palmt5_batt_pdata = {
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100304 .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
Marek Vasut241cf472010-06-04 03:07:33 +0200317static struct wm97xx_pdata palmt5_wm97xx_pdata = {
318 .batt_pdata = &palmt5_batt_pdata,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100319};
320
Marek Vasute91fb912009-04-17 11:37:35 +0200321static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
322 .reset_gpio = 95,
Marek Vasut241cf472010-06-04 03:07:33 +0200323 .codec_pdata = { &palmt5_wm97xx_pdata, },
324};
325
326static struct palm27x_asoc_info palmt5_asoc_pdata = {
327 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
Marek Vasute91fb912009-04-17 11:37:35 +0200328};
329
330static struct platform_device palmt5_asoc = {
331 .name = "palm27x-asoc",
332 .id = -1,
333 .dev = {
334 .platform_data = &palmt5_asoc_pdata,
335 },
336};
337
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100338/******************************************************************************
339 * Framebuffer
340 ******************************************************************************/
341static struct pxafb_mode_info palmt5_lcd_modes[] = {
342{
343 .pixclock = 57692,
344 .xres = 320,
345 .yres = 480,
346 .bpp = 16,
347
348 .left_margin = 32,
349 .right_margin = 1,
350 .upper_margin = 7,
351 .lower_margin = 1,
352
353 .hsync_len = 4,
354 .vsync_len = 1,
355},
356};
357
358static struct pxafb_mach_info palmt5_lcd_screen = {
359 .modes = palmt5_lcd_modes,
360 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
361 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
362};
363
364/******************************************************************************
Marek Vasut81854f82009-03-28 12:37:42 +0100365 * Power management - standby
366 ******************************************************************************/
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200367static void __init palmt5_pm_init(void)
Marek Vasut81854f82009-03-28 12:37:42 +0100368{
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200369 static u32 resume[] = {
370 0xe3a00101, /* mov r0, #0x40000000 */
371 0xe380060f, /* orr r0, r0, #0x00f00000 */
372 0xe590f008, /* ldr pc, [r0, #0x08] */
373 };
Marek Vasut81854f82009-03-28 12:37:42 +0100374
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200375 /* copy the bootloader */
376 memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
Marek Vasut81854f82009-03-28 12:37:42 +0100377}
378
Marek Vasut81854f82009-03-28 12:37:42 +0100379/******************************************************************************
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100380 * Machine init
381 ******************************************************************************/
382static struct platform_device *devices[] __initdata = {
383#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
384 &palmt5_pxa_keys,
385#endif
386 &palmt5_backlight,
387 &power_supply,
Marek Vasute91fb912009-04-17 11:37:35 +0200388 &palmt5_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200389 &palmt5_gpio_vbus,
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100390};
391
392/* setup udc GPIOs initial state */
393static void __init palmt5_udc_init(void)
394{
Marek Vasutefb12cd2009-04-12 16:37:23 +0200395 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
396 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
397 gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100398 }
399}
400
401static void __init palmt5_init(void)
402{
403 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
404
Russell Kingcc155c62009-11-09 13:34:08 +0800405 pxa_set_ffuart_info(NULL);
406 pxa_set_btuart_info(NULL);
407 pxa_set_stuart_info(NULL);
408
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200409 palmt5_pm_init();
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100410 set_pxa_fb_info(&palmt5_lcd_screen);
411 pxa_set_mci_info(&palmt5_mci_platform_data);
412 palmt5_udc_init();
Marek Vasute91fb912009-04-17 11:37:35 +0200413 pxa_set_ac97_info(&palmt5_ac97_pdata);
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100414 pxa_set_ficp_info(&palmt5_ficp_platform_data);
415 pxa_set_keypad_info(&palmt5_keypad_platform_data);
Marek Vasutfc9c1b62009-05-14 11:27:00 +0200416
Marek Vasut0f6ff0f2008-11-20 00:58:38 +0100417 platform_add_devices(devices, ARRAY_SIZE(devices));
418}
419
420MACHINE_START(PALMT5, "Palm Tungsten|T5")
421 .phys_io = PALMT5_PHYS_IO_START,
422 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
423 .boot_params = 0xa0000100,
424 .map_io = pxa_map_io,
425 .init_irq = pxa27x_init_irq,
426 .timer = &pxa_timer,
427 .init_machine = palmt5_init
428MACHINE_END