[ARM] pxa: balloon3 (http://balloonboard.org/) base machine support
[deliverable/linux.git] / arch / arm / mach-pxa / palmte2.c
CommitLineData
54088bf5
MV
1/*
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>
8c8aa5fa 23#include <linux/pda_power.h>
54088bf5
MV
24#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
8c8aa5fa
MV
26#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h>
8768dc9b 28#include <linux/usb/gpio_vbus.h>
54088bf5
MV
29
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>
8c8aa5fa
MV
39#include <mach/irda.h>
40#include <mach/udc.h>
37330efd 41#include <mach/palmasoc.h>
54088bf5
MV
42
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
8c8aa5fa
MV
66 /* 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
54088bf5
MV
75 /* 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,
8c8aa5fa 95 GPIO77_LCD_BIAS,
54088bf5
MV
96
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 */
8c8aa5fa
MV
110 GPIO4_GPIO, /* Hotsync button */
111 GPIO9_GPIO, /* power detect */
37330efd 112 GPIO15_GPIO, /* earphone detect */
8c8aa5fa
MV
113 GPIO37_GPIO, /* LCD power */
114 GPIO56_GPIO, /* Backlight power */
54088bf5
MV
115};
116
117/******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
54088bf5 120static struct pxamci_platform_data palmte2_mci_platform_data = {
7a648256
RJ
121 .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,
54088bf5
MV
125};
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 ******************************************************************************/
8c8aa5fa
MV
158static 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
54088bf5
MV
197static 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,
8c8aa5fa
MV
202 .init = palmte2_backlight_init,
203 .notify = palmte2_backlight_notify,
204 .exit = palmte2_backlight_exit,
54088bf5
MV
205};
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
8c8aa5fa
MV
215/******************************************************************************
216 * IrDA
217 ******************************************************************************/
218static int palmte2_irda_startup(struct device *dev)
219{
220 int err;
221 err = gpio_request(GPIO_NR_PALMTE2_IR_DISABLE, "IR DISABLE");
222 if (err)
223 goto err;
224 err = gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE, 1);
225 if (err)
226 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
227err:
228 return err;
229}
230
231static void palmte2_irda_shutdown(struct device *dev)
232{
233 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
234}
235
236static void palmte2_irda_transceiver_mode(struct device *dev, int mode)
237{
238 gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE, mode & IR_OFF);
239 pxa2xx_transceiver_mode(dev, mode);
240}
241
242static struct pxaficp_platform_data palmte2_ficp_platform_data = {
243 .startup = palmte2_irda_startup,
244 .shutdown = palmte2_irda_shutdown,
245 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
246 .transceiver_mode = palmte2_irda_transceiver_mode,
247};
248
249/******************************************************************************
250 * UDC
251 ******************************************************************************/
8768dc9b 252static struct gpio_vbus_mach_info palmte2_udc_info = {
8c8aa5fa
MV
253 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
254 .gpio_vbus_inverted = 1,
255 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
8768dc9b
MV
256};
257
258static struct platform_device palmte2_gpio_vbus = {
259 .name = "gpio-vbus",
260 .id = -1,
261 .dev = {
262 .platform_data = &palmte2_udc_info,
263 },
8c8aa5fa
MV
264};
265
266/******************************************************************************
267 * Power supply
268 ******************************************************************************/
269static int power_supply_init(struct device *dev)
270{
271 int ret;
272
273 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
274 if (ret)
275 goto err1;
276 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
277 if (ret)
278 goto err2;
279
280 return 0;
281
282err2:
283 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
284err1:
285 return ret;
286}
287
288static int palmte2_is_ac_online(void)
289{
290 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
291}
292
293static void power_supply_exit(struct device *dev)
294{
295 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
296}
297
298static char *palmte2_supplicants[] = {
299 "main-battery",
300};
301
302static struct pda_power_pdata power_supply_info = {
303 .init = power_supply_init,
304 .is_ac_online = palmte2_is_ac_online,
305 .exit = power_supply_exit,
306 .supplied_to = palmte2_supplicants,
307 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
308};
309
310static struct platform_device power_supply = {
311 .name = "pda-power",
312 .id = -1,
313 .dev = {
314 .platform_data = &power_supply_info,
315 },
316};
317
318/******************************************************************************
319 * WM97xx battery
320 ******************************************************************************/
321static struct wm97xx_batt_info wm97xx_batt_pdata = {
322 .batt_aux = WM97XX_AUX_ID3,
323 .temp_aux = WM97XX_AUX_ID2,
324 .charge_gpio = -1,
325 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
326 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
327 .batt_mult = 1000,
328 .batt_div = 414,
329 .temp_mult = 1,
330 .temp_div = 1,
331 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
332 .batt_name = "main-batt",
333};
334
37330efd
MV
335/******************************************************************************
336 * aSoC audio
337 ******************************************************************************/
338static struct palm27x_asoc_info palmte2_asoc_pdata = {
339 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
340};
341
342static struct platform_device palmte2_asoc = {
343 .name = "palm27x-asoc",
344 .id = -1,
345 .dev = {
346 .platform_data = &palmte2_asoc_pdata,
347 },
348};
349
54088bf5
MV
350/******************************************************************************
351 * Framebuffer
352 ******************************************************************************/
353static struct pxafb_mode_info palmte2_lcd_modes[] = {
354{
355 .pixclock = 77757,
356 .xres = 320,
357 .yres = 320,
358 .bpp = 16,
359
360 .left_margin = 28,
361 .right_margin = 7,
362 .upper_margin = 7,
363 .lower_margin = 5,
364
365 .hsync_len = 4,
366 .vsync_len = 1,
367},
368};
369
370static struct pxafb_mach_info palmte2_lcd_screen = {
371 .modes = palmte2_lcd_modes,
372 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
373 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
374};
375
376/******************************************************************************
377 * Machine init
378 ******************************************************************************/
379static struct platform_device *devices[] __initdata = {
380#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
381 &palmte2_pxa_keys,
382#endif
383 &palmte2_backlight,
8c8aa5fa 384 &power_supply,
37330efd 385 &palmte2_asoc,
8768dc9b 386 &palmte2_gpio_vbus,
54088bf5
MV
387};
388
8c8aa5fa
MV
389/* setup udc GPIOs initial state */
390static void __init palmte2_udc_init(void)
391{
392 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
393 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
394 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
395 }
396}
397
54088bf5
MV
398static void __init palmte2_init(void)
399{
400 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
401
402 set_pxa_fb_info(&palmte2_lcd_screen);
403 pxa_set_mci_info(&palmte2_mci_platform_data);
8c8aa5fa 404 palmte2_udc_init();
54088bf5 405 pxa_set_ac97_info(NULL);
8c8aa5fa
MV
406 pxa_set_ficp_info(&palmte2_ficp_platform_data);
407 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
54088bf5
MV
408
409 platform_add_devices(devices, ARRAY_SIZE(devices));
410}
411
412MACHINE_START(PALMTE2, "Palm Tungsten|E2")
413 .phys_io = 0x40000000,
414 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
415 .boot_params = 0xa0000100,
416 .map_io = pxa_map_io,
417 .init_irq = pxa25x_init_irq,
418 .timer = &pxa_timer,
419 .init_machine = palmte2_init
420MACHINE_END
This page took 0.065117 seconds and 5 git commands to generate.