aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/palmte2.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/palmte2.c')
-rw-r--r--arch/arm/mach-pxa/palmte2.c466
1 files changed, 466 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
new file mode 100644
index 000000000000..43fcf2e86887
--- /dev/null
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -0,0 +1,466 @@
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>
23#include <linux/pda_power.h>
24#include <linux/pwm_backlight.h>
25#include <linux/gpio.h>
26#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h>
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
33#include <mach/audio.h>
34#include <mach/palmte2.h>
35#include <mach/mmc.h>
36#include <mach/pxafb.h>
37#include <mach/mfp-pxa25x.h>
38#include <mach/irda.h>
39#include <mach/udc.h>
40
41#include "generic.h"
42#include "devices.h"
43
44/******************************************************************************
45 * Pin configuration
46 ******************************************************************************/
47static unsigned long palmte2_pin_config[] __initdata = {
48 /* MMC */
49 GPIO6_MMC_CLK,
50 GPIO8_MMC_CS0,
51 GPIO10_GPIO, /* SD detect */
52 GPIO55_GPIO, /* SD power */
53 GPIO51_GPIO, /* SD r/o switch */
54
55 /* AC97 */
56 GPIO28_AC97_BITCLK,
57 GPIO29_AC97_SDATA_IN_0,
58 GPIO30_AC97_SDATA_OUT,
59 GPIO31_AC97_SYNC,
60
61 /* PWM */
62 GPIO16_PWM0_OUT,
63
64 /* USB */
65 GPIO15_GPIO, /* usb detect */
66 GPIO53_GPIO, /* usb power */
67
68 /* IrDA */
69 GPIO48_GPIO, /* ir disable */
70 GPIO46_FICP_RXD,
71 GPIO47_FICP_TXD,
72
73 /* LCD */
74 GPIO58_LCD_LDD_0,
75 GPIO59_LCD_LDD_1,
76 GPIO60_LCD_LDD_2,
77 GPIO61_LCD_LDD_3,
78 GPIO62_LCD_LDD_4,
79 GPIO63_LCD_LDD_5,
80 GPIO64_LCD_LDD_6,
81 GPIO65_LCD_LDD_7,
82 GPIO66_LCD_LDD_8,
83 GPIO67_LCD_LDD_9,
84 GPIO68_LCD_LDD_10,
85 GPIO69_LCD_LDD_11,
86 GPIO70_LCD_LDD_12,
87 GPIO71_LCD_LDD_13,
88 GPIO72_LCD_LDD_14,
89 GPIO73_LCD_LDD_15,
90 GPIO74_LCD_FCLK,
91 GPIO75_LCD_LCLK,
92 GPIO76_LCD_PCLK,
93 GPIO77_LCD_BIAS,
94
95 /* GPIO KEYS */
96 GPIO5_GPIO, /* notes */
97 GPIO7_GPIO, /* tasks */
98 GPIO11_GPIO, /* calendar */
99 GPIO13_GPIO, /* contacts */
100 GPIO14_GPIO, /* center */
101 GPIO19_GPIO, /* left */
102 GPIO20_GPIO, /* right */
103 GPIO21_GPIO, /* down */
104 GPIO22_GPIO, /* up */
105
106 /* MISC */
107 GPIO1_RST, /* reset */
108 GPIO4_GPIO, /* Hotsync button */
109 GPIO9_GPIO, /* power detect */
110 GPIO37_GPIO, /* LCD power */
111 GPIO56_GPIO, /* Backlight power */
112};
113
114/******************************************************************************
115 * SD/MMC card controller
116 ******************************************************************************/
117static int palmte2_mci_init(struct device *dev,
118 irq_handler_t palmte2_detect_int, void *data)
119{
120 int err = 0;
121
122 /* Setup an interrupt for detecting card insert/remove events */
123 err = gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N, "SD IRQ");
124 if (err)
125 goto err;
126 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N);
127 if (err)
128 goto err2;
129 err = request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N),
130 palmte2_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
131 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
132 "SD/MMC card detect", data);
133 if (err) {
134 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
135 __func__);
136 goto err2;
137 }
138
139 err = gpio_request(GPIO_NR_PALMTE2_SD_POWER, "SD_POWER");
140 if (err)
141 goto err3;
142 err = gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER, 0);
143 if (err)
144 goto err4;
145
146 err = gpio_request(GPIO_NR_PALMTE2_SD_READONLY, "SD_READONLY");
147 if (err)
148 goto err4;
149 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY);
150 if (err)
151 goto err5;
152
153 printk(KERN_DEBUG "%s: irq registered\n", __func__);
154
155 return 0;
156
157err5:
158 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
159err4:
160 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
161err3:
162 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
163err2:
164 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
165err:
166 return err;
167}
168
169static void palmte2_mci_exit(struct device *dev, void *data)
170{
171 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
172 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
173 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
174 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
175}
176
177static void palmte2_mci_power(struct device *dev, unsigned int vdd)
178{
179 struct pxamci_platform_data *p_d = dev->platform_data;
180 gpio_set_value(GPIO_NR_PALMTE2_SD_POWER, p_d->ocr_mask & (1 << vdd));
181}
182
183static int palmte2_mci_get_ro(struct device *dev)
184{
185 return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY);
186}
187
188static struct pxamci_platform_data palmte2_mci_platform_data = {
189 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
190 .setpower = palmte2_mci_power,
191 .get_ro = palmte2_mci_get_ro,
192 .init = palmte2_mci_init,
193 .exit = palmte2_mci_exit,
194};
195
196/******************************************************************************
197 * GPIO keys
198 ******************************************************************************/
199static struct gpio_keys_button palmte2_pxa_buttons[] = {
200 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
201 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
202 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
203 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
204 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
205 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
206 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
207 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
208 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
209};
210
211static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
212 .buttons = palmte2_pxa_buttons,
213 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
214};
215
216static struct platform_device palmte2_pxa_keys = {
217 .name = "gpio-keys",
218 .id = -1,
219 .dev = {
220 .platform_data = &palmte2_pxa_keys_data,
221 },
222};
223
224/******************************************************************************
225 * Backlight
226 ******************************************************************************/
227static int palmte2_backlight_init(struct device *dev)
228{
229 int ret;
230
231 ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
232 if (ret)
233 goto err;
234 ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
235 if (ret)
236 goto err2;
237 ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
238 if (ret)
239 goto err2;
240 ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
241 if (ret)
242 goto err3;
243
244 return 0;
245err3:
246 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
247err2:
248 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
249err:
250 return ret;
251}
252
253static int palmte2_backlight_notify(int brightness)
254{
255 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
256 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
257 return brightness;
258}
259
260static void palmte2_backlight_exit(struct device *dev)
261{
262 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
263 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
264}
265
266static struct platform_pwm_backlight_data palmte2_backlight_data = {
267 .pwm_id = 0,
268 .max_brightness = PALMTE2_MAX_INTENSITY,
269 .dft_brightness = PALMTE2_MAX_INTENSITY,
270 .pwm_period_ns = PALMTE2_PERIOD_NS,
271 .init = palmte2_backlight_init,
272 .notify = palmte2_backlight_notify,
273 .exit = palmte2_backlight_exit,
274};
275
276static struct platform_device palmte2_backlight = {
277 .name = "pwm-backlight",
278 .dev = {
279 .parent = &pxa25x_device_pwm0.dev,
280 .platform_data = &palmte2_backlight_data,
281 },
282};
283
284/******************************************************************************
285 * IrDA
286 ******************************************************************************/
287static int palmte2_irda_startup(struct device *dev)
288{
289 int err;
290 err = gpio_request(GPIO_NR_PALMTE2_IR_DISABLE, "IR DISABLE");
291 if (err)
292 goto err;
293 err = gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE, 1);
294 if (err)
295 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
296err:
297 return err;
298}
299
300static void palmte2_irda_shutdown(struct device *dev)
301{
302 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
303}
304
305static void palmte2_irda_transceiver_mode(struct device *dev, int mode)
306{
307 gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE, mode & IR_OFF);
308 pxa2xx_transceiver_mode(dev, mode);
309}
310
311static struct pxaficp_platform_data palmte2_ficp_platform_data = {
312 .startup = palmte2_irda_startup,
313 .shutdown = palmte2_irda_shutdown,
314 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
315 .transceiver_mode = palmte2_irda_transceiver_mode,
316};
317
318/******************************************************************************
319 * UDC
320 ******************************************************************************/
321static struct pxa2xx_udc_mach_info palmte2_udc_info __initdata = {
322 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
323 .gpio_vbus_inverted = 1,
324 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
325 .gpio_pullup_inverted = 0,
326};
327
328/******************************************************************************
329 * Power supply
330 ******************************************************************************/
331static int power_supply_init(struct device *dev)
332{
333 int ret;
334
335 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
336 if (ret)
337 goto err1;
338 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
339 if (ret)
340 goto err2;
341
342 return 0;
343
344err2:
345 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
346err1:
347 return ret;
348}
349
350static int palmte2_is_ac_online(void)
351{
352 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
353}
354
355static void power_supply_exit(struct device *dev)
356{
357 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
358}
359
360static char *palmte2_supplicants[] = {
361 "main-battery",
362};
363
364static struct pda_power_pdata power_supply_info = {
365 .init = power_supply_init,
366 .is_ac_online = palmte2_is_ac_online,
367 .exit = power_supply_exit,
368 .supplied_to = palmte2_supplicants,
369 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
370};
371
372static struct platform_device power_supply = {
373 .name = "pda-power",
374 .id = -1,
375 .dev = {
376 .platform_data = &power_supply_info,
377 },
378};
379
380/******************************************************************************
381 * WM97xx battery
382 ******************************************************************************/
383static struct wm97xx_batt_info wm97xx_batt_pdata = {
384 .batt_aux = WM97XX_AUX_ID3,
385 .temp_aux = WM97XX_AUX_ID2,
386 .charge_gpio = -1,
387 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
388 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
389 .batt_mult = 1000,
390 .batt_div = 414,
391 .temp_mult = 1,
392 .temp_div = 1,
393 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
394 .batt_name = "main-batt",
395};
396
397/******************************************************************************
398 * Framebuffer
399 ******************************************************************************/
400static struct pxafb_mode_info palmte2_lcd_modes[] = {
401{
402 .pixclock = 77757,
403 .xres = 320,
404 .yres = 320,
405 .bpp = 16,
406
407 .left_margin = 28,
408 .right_margin = 7,
409 .upper_margin = 7,
410 .lower_margin = 5,
411
412 .hsync_len = 4,
413 .vsync_len = 1,
414},
415};
416
417static struct pxafb_mach_info palmte2_lcd_screen = {
418 .modes = palmte2_lcd_modes,
419 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
420 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
421};
422
423/******************************************************************************
424 * Machine init
425 ******************************************************************************/
426static struct platform_device *devices[] __initdata = {
427#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
428 &palmte2_pxa_keys,
429#endif
430 &palmte2_backlight,
431 &power_supply,
432};
433
434/* setup udc GPIOs initial state */
435static void __init palmte2_udc_init(void)
436{
437 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
438 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
439 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
440 }
441}
442
443static void __init palmte2_init(void)
444{
445 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
446
447 set_pxa_fb_info(&palmte2_lcd_screen);
448 pxa_set_mci_info(&palmte2_mci_platform_data);
449 palmte2_udc_init();
450 pxa_set_udc_info(&palmte2_udc_info);
451 pxa_set_ac97_info(NULL);
452 pxa_set_ficp_info(&palmte2_ficp_platform_data);
453 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
454
455 platform_add_devices(devices, ARRAY_SIZE(devices));
456}
457
458MACHINE_START(PALMTE2, "Palm Tungsten|E2")
459 .phys_io = 0x40000000,
460 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
461 .boot_params = 0xa0000100,
462 .map_io = pxa_map_io,
463 .init_irq = pxa25x_init_irq,
464 .timer = &pxa_timer,
465 .init_machine = palmte2_init
466MACHINE_END