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.c188
1 files changed, 188 insertions, 0 deletions
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 ******************************************************************************/
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
208static struct platform_pwm_backlight_data palmte2_backlight_data = { 266static 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
215static struct platform_device palmte2_backlight = { 276static struct platform_device palmte2_backlight = {
@@ -221,6 +282,119 @@ static struct platform_device palmte2_backlight = {
221}; 282};
222 283
223/****************************************************************************** 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/******************************************************************************
224 * Framebuffer 398 * Framebuffer
225 ******************************************************************************/ 399 ******************************************************************************/
226static struct pxafb_mode_info palmte2_lcd_modes[] = { 400static 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 */
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
259static void __init palmte2_init(void) 443static 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}