blob: 265d62bae7de47133570df7bdfd429d28f665dea [file] [log] [blame]
Marek Vasut54088bf2009-03-24 00:29:29 +01001/*
2 * Hardware definitions for Palm Tungsten|E2
3 *
4 * Author:
5 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
6 *
7 * Rewrite for mainline:
8 * Marek Vasut <marek.vasut@gmail.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * (find more info at www.hackndev.com)
15 *
16 */
17
18#include <linux/platform_device.h>
19#include <linux/delay.h>
20#include <linux/irq.h>
21#include <linux/gpio_keys.h>
22#include <linux/input.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010023#include <linux/pda_power.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010024#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010026#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h>
Marek Vasut8768dc92009-04-23 11:12:37 +020028#include <linux/usb/gpio_vbus.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010029
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
34#include <mach/audio.h>
35#include <mach/palmte2.h>
36#include <mach/mmc.h>
37#include <mach/pxafb.h>
38#include <mach/mfp-pxa25x.h>
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010039#include <mach/irda.h>
40#include <mach/udc.h>
Marek Vasut37330ef2009-04-23 11:27:11 +020041#include <mach/palmasoc.h>
Marek Vasut54088bf2009-03-24 00:29:29 +010042
43#include "generic.h"
44#include "devices.h"
45
46/******************************************************************************
47 * Pin configuration
48 ******************************************************************************/
49static unsigned long palmte2_pin_config[] __initdata = {
50 /* MMC */
51 GPIO6_MMC_CLK,
52 GPIO8_MMC_CS0,
53 GPIO10_GPIO, /* SD detect */
54 GPIO55_GPIO, /* SD power */
55 GPIO51_GPIO, /* SD r/o switch */
56
57 /* AC97 */
58 GPIO28_AC97_BITCLK,
59 GPIO29_AC97_SDATA_IN_0,
60 GPIO30_AC97_SDATA_OUT,
61 GPIO31_AC97_SYNC,
62
63 /* PWM */
64 GPIO16_PWM0_OUT,
65
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010066 /* USB */
67 GPIO15_GPIO, /* usb detect */
68 GPIO53_GPIO, /* usb power */
69
70 /* IrDA */
71 GPIO48_GPIO, /* ir disable */
72 GPIO46_FICP_RXD,
73 GPIO47_FICP_TXD,
74
Marek Vasut54088bf2009-03-24 00:29:29 +010075 /* LCD */
76 GPIO58_LCD_LDD_0,
77 GPIO59_LCD_LDD_1,
78 GPIO60_LCD_LDD_2,
79 GPIO61_LCD_LDD_3,
80 GPIO62_LCD_LDD_4,
81 GPIO63_LCD_LDD_5,
82 GPIO64_LCD_LDD_6,
83 GPIO65_LCD_LDD_7,
84 GPIO66_LCD_LDD_8,
85 GPIO67_LCD_LDD_9,
86 GPIO68_LCD_LDD_10,
87 GPIO69_LCD_LDD_11,
88 GPIO70_LCD_LDD_12,
89 GPIO71_LCD_LDD_13,
90 GPIO72_LCD_LDD_14,
91 GPIO73_LCD_LDD_15,
92 GPIO74_LCD_FCLK,
93 GPIO75_LCD_LCLK,
94 GPIO76_LCD_PCLK,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +010095 GPIO77_LCD_BIAS,
Marek Vasut54088bf2009-03-24 00:29:29 +010096
97 /* GPIO KEYS */
98 GPIO5_GPIO, /* notes */
99 GPIO7_GPIO, /* tasks */
100 GPIO11_GPIO, /* calendar */
101 GPIO13_GPIO, /* contacts */
102 GPIO14_GPIO, /* center */
103 GPIO19_GPIO, /* left */
104 GPIO20_GPIO, /* right */
105 GPIO21_GPIO, /* down */
106 GPIO22_GPIO, /* up */
107
108 /* MISC */
109 GPIO1_RST, /* reset */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100110 GPIO4_GPIO, /* Hotsync button */
111 GPIO9_GPIO, /* power detect */
Marek Vasut37330ef2009-04-23 11:27:11 +0200112 GPIO15_GPIO, /* earphone detect */
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100113 GPIO37_GPIO, /* LCD power */
114 GPIO56_GPIO, /* Backlight power */
Marek Vasut54088bf2009-03-24 00:29:29 +0100115};
116
117/******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
Marek Vasut54088bf2009-03-24 00:29:29 +0100120static struct pxamci_platform_data palmte2_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200121 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
122 .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N,
123 .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY,
124 .gpio_power = GPIO_NR_PALMTE2_SD_POWER,
Marek Vasut54088bf2009-03-24 00:29:29 +0100125};
126
127/******************************************************************************
128 * GPIO keys
129 ******************************************************************************/
130static struct gpio_keys_button palmte2_pxa_buttons[] = {
131 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
132 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
133 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
134 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
135 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
136 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
137 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
138 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
139 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
140};
141
142static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
143 .buttons = palmte2_pxa_buttons,
144 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
145};
146
147static struct platform_device palmte2_pxa_keys = {
148 .name = "gpio-keys",
149 .id = -1,
150 .dev = {
151 .platform_data = &palmte2_pxa_keys_data,
152 },
153};
154
155/******************************************************************************
156 * Backlight
157 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100158static int palmte2_backlight_init(struct device *dev)
159{
160 int ret;
161
162 ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
163 if (ret)
164 goto err;
165 ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
166 if (ret)
167 goto err2;
168 ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
169 if (ret)
170 goto err2;
171 ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
172 if (ret)
173 goto err3;
174
175 return 0;
176err3:
177 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
178err2:
179 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
180err:
181 return ret;
182}
183
184static int palmte2_backlight_notify(int brightness)
185{
186 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
187 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
188 return brightness;
189}
190
191static void palmte2_backlight_exit(struct device *dev)
192{
193 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
194 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
195}
196
Marek Vasut54088bf2009-03-24 00:29:29 +0100197static struct platform_pwm_backlight_data palmte2_backlight_data = {
198 .pwm_id = 0,
199 .max_brightness = PALMTE2_MAX_INTENSITY,
200 .dft_brightness = PALMTE2_MAX_INTENSITY,
201 .pwm_period_ns = PALMTE2_PERIOD_NS,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100202 .init = palmte2_backlight_init,
203 .notify = palmte2_backlight_notify,
204 .exit = palmte2_backlight_exit,
Marek Vasut54088bf2009-03-24 00:29:29 +0100205};
206
207static struct platform_device palmte2_backlight = {
208 .name = "pwm-backlight",
209 .dev = {
210 .parent = &pxa25x_device_pwm0.dev,
211 .platform_data = &palmte2_backlight_data,
212 },
213};
214
215/******************************************************************************
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100216 * IrDA
217 ******************************************************************************/
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100218static struct pxaficp_platform_data palmte2_ficp_platform_data = {
Marek Vasutc4bd0172009-07-17 12:50:43 +0200219 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
220 .transceiver_cap = IR_SIRMODE | IR_OFF,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100221};
222
223/******************************************************************************
224 * UDC
225 ******************************************************************************/
Marek Vasut8768dc92009-04-23 11:12:37 +0200226static struct gpio_vbus_mach_info palmte2_udc_info = {
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100227 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
228 .gpio_vbus_inverted = 1,
229 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
Marek Vasut8768dc92009-04-23 11:12:37 +0200230};
231
232static struct platform_device palmte2_gpio_vbus = {
233 .name = "gpio-vbus",
234 .id = -1,
235 .dev = {
236 .platform_data = &palmte2_udc_info,
237 },
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100238};
239
240/******************************************************************************
241 * Power supply
242 ******************************************************************************/
243static int power_supply_init(struct device *dev)
244{
245 int ret;
246
247 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
248 if (ret)
249 goto err1;
250 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
251 if (ret)
252 goto err2;
253
254 return 0;
255
256err2:
257 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
258err1:
259 return ret;
260}
261
262static int palmte2_is_ac_online(void)
263{
264 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
265}
266
267static void power_supply_exit(struct device *dev)
268{
269 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
270}
271
272static char *palmte2_supplicants[] = {
273 "main-battery",
274};
275
276static struct pda_power_pdata power_supply_info = {
277 .init = power_supply_init,
278 .is_ac_online = palmte2_is_ac_online,
279 .exit = power_supply_exit,
280 .supplied_to = palmte2_supplicants,
281 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
282};
283
284static struct platform_device power_supply = {
285 .name = "pda-power",
286 .id = -1,
287 .dev = {
288 .platform_data = &power_supply_info,
289 },
290};
291
292/******************************************************************************
293 * WM97xx battery
294 ******************************************************************************/
295static struct wm97xx_batt_info wm97xx_batt_pdata = {
296 .batt_aux = WM97XX_AUX_ID3,
297 .temp_aux = WM97XX_AUX_ID2,
298 .charge_gpio = -1,
299 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
300 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
301 .batt_mult = 1000,
302 .batt_div = 414,
303 .temp_mult = 1,
304 .temp_div = 1,
305 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
306 .batt_name = "main-batt",
307};
308
309/******************************************************************************
Marek Vasut37330ef2009-04-23 11:27:11 +0200310 * aSoC audio
311 ******************************************************************************/
312static struct palm27x_asoc_info palmte2_asoc_pdata = {
313 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
314};
315
316static struct platform_device palmte2_asoc = {
317 .name = "palm27x-asoc",
318 .id = -1,
319 .dev = {
320 .platform_data = &palmte2_asoc_pdata,
321 },
322};
323
324/******************************************************************************
Marek Vasut54088bf2009-03-24 00:29:29 +0100325 * Framebuffer
326 ******************************************************************************/
327static struct pxafb_mode_info palmte2_lcd_modes[] = {
328{
329 .pixclock = 77757,
330 .xres = 320,
331 .yres = 320,
332 .bpp = 16,
333
334 .left_margin = 28,
335 .right_margin = 7,
336 .upper_margin = 7,
337 .lower_margin = 5,
338
339 .hsync_len = 4,
340 .vsync_len = 1,
341},
342};
343
344static struct pxafb_mach_info palmte2_lcd_screen = {
345 .modes = palmte2_lcd_modes,
346 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
347 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
348};
349
350/******************************************************************************
351 * Machine init
352 ******************************************************************************/
353static struct platform_device *devices[] __initdata = {
354#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
355 &palmte2_pxa_keys,
356#endif
357 &palmte2_backlight,
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100358 &power_supply,
Marek Vasut37330ef2009-04-23 11:27:11 +0200359 &palmte2_asoc,
Marek Vasut8768dc92009-04-23 11:12:37 +0200360 &palmte2_gpio_vbus,
Marek Vasut54088bf2009-03-24 00:29:29 +0100361};
362
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100363/* setup udc GPIOs initial state */
364static void __init palmte2_udc_init(void)
365{
366 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
367 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
368 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
369 }
370}
371
Marek Vasut54088bf2009-03-24 00:29:29 +0100372static void __init palmte2_init(void)
373{
374 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
375
Russell Kingcc155c62009-11-09 13:34:08 +0800376 pxa_set_ffuart_info(NULL);
377 pxa_set_btuart_info(NULL);
378 pxa_set_stuart_info(NULL);
379
Marek Vasut54088bf2009-03-24 00:29:29 +0100380 set_pxa_fb_info(&palmte2_lcd_screen);
381 pxa_set_mci_info(&palmte2_mci_platform_data);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100382 palmte2_udc_init();
Marek Vasut54088bf2009-03-24 00:29:29 +0100383 pxa_set_ac97_info(NULL);
Marek Vasut8c8aa5f2009-03-24 21:23:39 +0100384 pxa_set_ficp_info(&palmte2_ficp_platform_data);
385 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
Marek Vasut54088bf2009-03-24 00:29:29 +0100386
387 platform_add_devices(devices, ARRAY_SIZE(devices));
388}
389
390MACHINE_START(PALMTE2, "Palm Tungsten|E2")
391 .phys_io = 0x40000000,
392 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
393 .boot_params = 0xa0000100,
394 .map_io = pxa_map_io,
395 .init_irq = pxa25x_init_irq,
396 .timer = &pxa_timer,
397 .init_machine = palmte2_init
398MACHINE_END