diff options
author | Marek Vasut <marek.vasut@gmail.com> | 2009-03-24 16:23:39 -0400 |
---|---|---|
committer | Eric Miao <eric.miao@marvell.com> | 2009-04-03 22:26:33 -0400 |
commit | 8c8aa5fa3060abc17e8a07d15f575485f6a0c0b8 (patch) | |
tree | 258ac3006a157c48d91e05d12bc2ce1790766547 /arch | |
parent | 54088bf50f31e5f20e005922dae8948f9f856b79 (diff) |
[ARM] pxa: PalmTE2 support for battery, UDC, IrDA and backlight
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-pxa/include/mach/palmte2.h | 25 | ||||
-rw-r--r-- | arch/arm/mach-pxa/palmte2.c | 188 |
2 files changed, 213 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/include/mach/palmte2.h b/arch/arm/mach-pxa/include/mach/palmte2.h index 808ee7faf5ba..12361341f9d8 100644 --- a/arch/arm/mach-pxa/include/mach/palmte2.h +++ b/arch/arm/mach-pxa/include/mach/palmte2.h | |||
@@ -16,10 +16,26 @@ | |||
16 | /** HERE ARE GPIOs **/ | 16 | /** HERE ARE GPIOs **/ |
17 | 17 | ||
18 | /* GPIOs */ | 18 | /* GPIOs */ |
19 | #define GPIO_NR_PALMTE2_POWER_DETECT 9 | ||
20 | #define GPIO_NR_PALMTE2_HOTSYNC_BUTTON_N 4 | ||
21 | #define GPIO_NR_PALMTE2_EARPHONE_DETECT 15 | ||
22 | |||
23 | /* SD/MMC */ | ||
19 | #define GPIO_NR_PALMTE2_SD_DETECT_N 10 | 24 | #define GPIO_NR_PALMTE2_SD_DETECT_N 10 |
20 | #define GPIO_NR_PALMTE2_SD_POWER 55 | 25 | #define GPIO_NR_PALMTE2_SD_POWER 55 |
21 | #define GPIO_NR_PALMTE2_SD_READONLY 51 | 26 | #define GPIO_NR_PALMTE2_SD_READONLY 51 |
22 | 27 | ||
28 | /* IRDA - disable GPIO connected to SD pin of tranceiver (TFBS4710?) ? */ | ||
29 | #define GPIO_NR_PALMTE2_IR_DISABLE 48 | ||
30 | |||
31 | /* USB */ | ||
32 | #define GPIO_NR_PALMTE2_USB_DETECT_N 35 | ||
33 | #define GPIO_NR_PALMTE2_USB_PULLUP 53 | ||
34 | |||
35 | /* LCD/BACKLIGHT */ | ||
36 | #define GPIO_NR_PALMTE2_BL_POWER 56 | ||
37 | #define GPIO_NR_PALMTE2_LCD_POWER 37 | ||
38 | |||
23 | /* KEYS */ | 39 | /* KEYS */ |
24 | #define GPIO_NR_PALMTE2_KEY_NOTES 5 | 40 | #define GPIO_NR_PALMTE2_KEY_NOTES 5 |
25 | #define GPIO_NR_PALMTE2_KEY_TASKS 7 | 41 | #define GPIO_NR_PALMTE2_KEY_TASKS 7 |
@@ -40,4 +56,13 @@ | |||
40 | #define PALMTE2_PRESCALER 0x3F | 56 | #define PALMTE2_PRESCALER 0x3F |
41 | #define PALMTE2_PERIOD_NS 3500 | 57 | #define PALMTE2_PERIOD_NS 3500 |
42 | 58 | ||
59 | /* BATTERY */ | ||
60 | #define PALMTE2_BAT_MAX_VOLTAGE 4000 /* 4.00v current voltage */ | ||
61 | #define PALMTE2_BAT_MIN_VOLTAGE 3550 /* 3.55v critical voltage */ | ||
62 | #define PALMTE2_BAT_MAX_CURRENT 0 /* unknokn */ | ||
63 | #define PALMTE2_BAT_MIN_CURRENT 0 /* unknown */ | ||
64 | #define PALMTE2_BAT_MAX_CHARGE 1 /* unknown */ | ||
65 | #define PALMTE2_BAT_MIN_CHARGE 1 /* unknown */ | ||
66 | #define PALMTE2_MAX_LIFE_MINS 360 /* on-life in minutes */ | ||
67 | |||
43 | #endif | 68 | #endif |
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c index e0dc655ae83a..43fcf2e86887 100644 --- a/arch/arm/mach-pxa/palmte2.c +++ b/arch/arm/mach-pxa/palmte2.c | |||
@@ -20,8 +20,11 @@ | |||
20 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
21 | #include <linux/gpio_keys.h> | 21 | #include <linux/gpio_keys.h> |
22 | #include <linux/input.h> | 22 | #include <linux/input.h> |
23 | #include <linux/pda_power.h> | ||
23 | #include <linux/pwm_backlight.h> | 24 | #include <linux/pwm_backlight.h> |
24 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
26 | #include <linux/wm97xx_batt.h> | ||
27 | #include <linux/power_supply.h> | ||
25 | 28 | ||
26 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
27 | #include <asm/mach/arch.h> | 30 | #include <asm/mach/arch.h> |
@@ -32,6 +35,8 @@ | |||
32 | #include <mach/mmc.h> | 35 | #include <mach/mmc.h> |
33 | #include <mach/pxafb.h> | 36 | #include <mach/pxafb.h> |
34 | #include <mach/mfp-pxa25x.h> | 37 | #include <mach/mfp-pxa25x.h> |
38 | #include <mach/irda.h> | ||
39 | #include <mach/udc.h> | ||
35 | 40 | ||
36 | #include "generic.h" | 41 | #include "generic.h" |
37 | #include "devices.h" | 42 | #include "devices.h" |
@@ -56,6 +61,15 @@ static unsigned long palmte2_pin_config[] __initdata = { | |||
56 | /* PWM */ | 61 | /* PWM */ |
57 | GPIO16_PWM0_OUT, | 62 | GPIO16_PWM0_OUT, |
58 | 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 | |||
59 | /* LCD */ | 73 | /* LCD */ |
60 | GPIO58_LCD_LDD_0, | 74 | GPIO58_LCD_LDD_0, |
61 | GPIO59_LCD_LDD_1, | 75 | GPIO59_LCD_LDD_1, |
@@ -76,6 +90,7 @@ static unsigned long palmte2_pin_config[] __initdata = { | |||
76 | GPIO74_LCD_FCLK, | 90 | GPIO74_LCD_FCLK, |
77 | GPIO75_LCD_LCLK, | 91 | GPIO75_LCD_LCLK, |
78 | GPIO76_LCD_PCLK, | 92 | GPIO76_LCD_PCLK, |
93 | GPIO77_LCD_BIAS, | ||
79 | 94 | ||
80 | /* GPIO KEYS */ | 95 | /* GPIO KEYS */ |
81 | GPIO5_GPIO, /* notes */ | 96 | GPIO5_GPIO, /* notes */ |
@@ -90,6 +105,10 @@ static unsigned long palmte2_pin_config[] __initdata = { | |||
90 | 105 | ||
91 | /* MISC */ | 106 | /* MISC */ |
92 | GPIO1_RST, /* reset */ | 107 | GPIO1_RST, /* reset */ |
108 | GPIO4_GPIO, /* Hotsync button */ | ||
109 | GPIO9_GPIO, /* power detect */ | ||
110 | GPIO37_GPIO, /* LCD power */ | ||
111 | GPIO56_GPIO, /* Backlight power */ | ||
93 | }; | 112 | }; |
94 | 113 | ||
95 | /****************************************************************************** | 114 | /****************************************************************************** |
@@ -205,11 +224,53 @@ static struct platform_device palmte2_pxa_keys = { | |||
205 | /****************************************************************************** | 224 | /****************************************************************************** |
206 | * Backlight | 225 | * Backlight |
207 | ******************************************************************************/ | 226 | ******************************************************************************/ |
227 | static 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; | ||
245 | err3: | ||
246 | gpio_free(GPIO_NR_PALMTE2_LCD_POWER); | ||
247 | err2: | ||
248 | gpio_free(GPIO_NR_PALMTE2_BL_POWER); | ||
249 | err: | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | static 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 | |||
260 | static 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 | |||
208 | static struct platform_pwm_backlight_data palmte2_backlight_data = { | 266 | static struct platform_pwm_backlight_data palmte2_backlight_data = { |
209 | .pwm_id = 0, | 267 | .pwm_id = 0, |
210 | .max_brightness = PALMTE2_MAX_INTENSITY, | 268 | .max_brightness = PALMTE2_MAX_INTENSITY, |
211 | .dft_brightness = PALMTE2_MAX_INTENSITY, | 269 | .dft_brightness = PALMTE2_MAX_INTENSITY, |
212 | .pwm_period_ns = PALMTE2_PERIOD_NS, | 270 | .pwm_period_ns = PALMTE2_PERIOD_NS, |
271 | .init = palmte2_backlight_init, | ||
272 | .notify = palmte2_backlight_notify, | ||
273 | .exit = palmte2_backlight_exit, | ||
213 | }; | 274 | }; |
214 | 275 | ||
215 | static struct platform_device palmte2_backlight = { | 276 | static struct platform_device palmte2_backlight = { |
@@ -221,6 +282,119 @@ static struct platform_device palmte2_backlight = { | |||
221 | }; | 282 | }; |
222 | 283 | ||
223 | /****************************************************************************** | 284 | /****************************************************************************** |
285 | * IrDA | ||
286 | ******************************************************************************/ | ||
287 | static 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); | ||
296 | err: | ||
297 | return err; | ||
298 | } | ||
299 | |||
300 | static void palmte2_irda_shutdown(struct device *dev) | ||
301 | { | ||
302 | gpio_free(GPIO_NR_PALMTE2_IR_DISABLE); | ||
303 | } | ||
304 | |||
305 | static 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 | |||
311 | static 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 | ******************************************************************************/ | ||
321 | static 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 | ******************************************************************************/ | ||
331 | static 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 | |||
344 | err2: | ||
345 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | ||
346 | err1: | ||
347 | return ret; | ||
348 | } | ||
349 | |||
350 | static int palmte2_is_ac_online(void) | ||
351 | { | ||
352 | return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT); | ||
353 | } | ||
354 | |||
355 | static void power_supply_exit(struct device *dev) | ||
356 | { | ||
357 | gpio_free(GPIO_NR_PALMTE2_POWER_DETECT); | ||
358 | } | ||
359 | |||
360 | static char *palmte2_supplicants[] = { | ||
361 | "main-battery", | ||
362 | }; | ||
363 | |||
364 | static 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 | |||
372 | static 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 | ******************************************************************************/ | ||
383 | static 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 | /****************************************************************************** | ||
224 | * Framebuffer | 398 | * Framebuffer |
225 | ******************************************************************************/ | 399 | ******************************************************************************/ |
226 | static struct pxafb_mode_info palmte2_lcd_modes[] = { | 400 | static struct pxafb_mode_info palmte2_lcd_modes[] = { |
@@ -254,15 +428,29 @@ static struct platform_device *devices[] __initdata = { | |||
254 | &palmte2_pxa_keys, | 428 | &palmte2_pxa_keys, |
255 | #endif | 429 | #endif |
256 | &palmte2_backlight, | 430 | &palmte2_backlight, |
431 | &power_supply, | ||
257 | }; | 432 | }; |
258 | 433 | ||
434 | /* setup udc GPIOs initial state */ | ||
435 | static 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 | |||
259 | static void __init palmte2_init(void) | 443 | static void __init palmte2_init(void) |
260 | { | 444 | { |
261 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config)); | 445 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config)); |
262 | 446 | ||
263 | set_pxa_fb_info(&palmte2_lcd_screen); | 447 | set_pxa_fb_info(&palmte2_lcd_screen); |
264 | pxa_set_mci_info(&palmte2_mci_platform_data); | 448 | pxa_set_mci_info(&palmte2_mci_platform_data); |
449 | palmte2_udc_init(); | ||
450 | pxa_set_udc_info(&palmte2_udc_info); | ||
265 | pxa_set_ac97_info(NULL); | 451 | pxa_set_ac97_info(NULL); |
452 | pxa_set_ficp_info(&palmte2_ficp_platform_data); | ||
453 | wm97xx_bat_set_pdata(&wm97xx_batt_pdata); | ||
266 | 454 | ||
267 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 455 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
268 | } | 456 | } |