aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/magician.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/magician.c')
-rw-r--r--arch/arm/mach-pxa/magician.c118
1 files changed, 90 insertions, 28 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index badba064dc04..c9d274f0048f 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -17,31 +17,32 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/gpio.h>
20#include <linux/gpio_keys.h> 21#include <linux/gpio_keys.h>
21#include <linux/input.h> 22#include <linux/input.h>
22#include <linux/mfd/htc-egpio.h> 23#include <linux/mfd/htc-egpio.h>
23#include <linux/mfd/htc-pasic3.h> 24#include <linux/mfd/htc-pasic3.h>
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/map.h>
26#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
27#include <linux/pda_power.h> 26#include <linux/pda_power.h>
27#include <linux/pwm_backlight.h>
28 28
29#include <asm/gpio.h>
30#include <asm/hardware.h> 29#include <asm/hardware.h>
31#include <asm/mach-types.h> 30#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
33#include <asm/arch/magician.h> 32#include <asm/arch/magician.h>
34#include <asm/arch/mfp-pxa27x.h> 33#include <asm/arch/mfp-pxa27x.h>
35#include <asm/arch/pxa-regs.h> 34#include <asm/arch/pxa-regs.h>
35#include <asm/arch/pxa2xx-regs.h>
36#include <asm/arch/pxafb.h> 36#include <asm/arch/pxafb.h>
37#include <asm/arch/i2c.h> 37#include <asm/arch/i2c.h>
38#include <asm/arch/mmc.h> 38#include <asm/arch/mmc.h>
39#include <asm/arch/irda.h> 39#include <asm/arch/irda.h>
40#include <asm/arch/ohci.h> 40#include <asm/arch/ohci.h>
41 41
42#include "devices.h"
42#include "generic.h" 43#include "generic.h"
43 44
44static unsigned long magician_pin_config[] = { 45static unsigned long magician_pin_config[] __initdata = {
45 46
46 /* SDRAM and Static Memory I/O Signals */ 47 /* SDRAM and Static Memory I/O Signals */
47 GPIO20_nSDCS_2, 48 GPIO20_nSDCS_2,
@@ -131,6 +132,7 @@ static unsigned long magician_pin_config[] = {
131static void magician_irda_transceiver_mode(struct device *dev, int mode) 132static void magician_irda_transceiver_mode(struct device *dev, int mode)
132{ 133{
133 gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF); 134 gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
135 pxa2xx_transceiver_mode(dev, mode);
134} 136}
135 137
136static struct pxaficp_platform_data magician_ficp_info = { 138static struct pxaficp_platform_data magician_ficp_info = {
@@ -348,40 +350,59 @@ static struct pxafb_mach_info samsung_info = {
348 * Backlight 350 * Backlight
349 */ 351 */
350 352
351static void magician_set_bl_intensity(int intensity) 353static int magician_backlight_init(struct device *dev)
352{ 354{
353 if (intensity) { 355 int ret;
354 PWM_CTRL0 = 1; 356
355 PWM_PERVAL0 = 0xc8; 357 ret = gpio_request(EGPIO_MAGICIAN_BL_POWER, "BL_POWER");
356 if (intensity > 0xc7) { 358 if (ret)
357 PWM_PWDUTY0 = intensity - 0x48; 359 goto err;
358 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); 360 ret = gpio_request(EGPIO_MAGICIAN_BL_POWER2, "BL_POWER2");
359 } else { 361 if (ret)
360 PWM_PWDUTY0 = intensity; 362 goto err2;
361 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); 363 return 0;
362 } 364
363 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 1); 365err2:
364 pxa_set_cken(CKEN_PWM0, 1); 366 gpio_free(EGPIO_MAGICIAN_BL_POWER);
367err:
368 return ret;
369}
370
371static int magician_backlight_notify(int brightness)
372{
373 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
374 if (brightness >= 200) {
375 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
376 return brightness - 72;
365 } else { 377 } else {
366 /* PWM_PWDUTY0 = intensity; */ 378 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
367 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 0); 379 return brightness;
368 pxa_set_cken(CKEN_PWM0, 0);
369 } 380 }
370} 381}
371 382
372static struct generic_bl_info backlight_info = { 383static void magician_backlight_exit(struct device *dev)
373 .default_intensity = 0x64, 384{
374 .limit_mask = 0x0b, 385 gpio_free(EGPIO_MAGICIAN_BL_POWER);
375 .max_intensity = 0xc7+0x48, 386 gpio_free(EGPIO_MAGICIAN_BL_POWER2);
376 .set_bl_intensity = magician_set_bl_intensity, 387}
388
389static struct platform_pwm_backlight_data backlight_data = {
390 .pwm_id = 0,
391 .max_brightness = 272,
392 .dft_brightness = 100,
393 .pwm_period_ns = 30923,
394 .init = magician_backlight_init,
395 .notify = magician_backlight_notify,
396 .exit = magician_backlight_exit,
377}; 397};
378 398
379static struct platform_device backlight = { 399static struct platform_device backlight = {
380 .name = "generic-bl", 400 .name = "pwm-backlight",
401 .id = -1,
381 .dev = { 402 .dev = {
382 .platform_data = &backlight_info, 403 .parent = &pxa27x_device_pwm0.dev,
404 .platform_data = &backlight_data,
383 }, 405 },
384 .id = -1,
385}; 406};
386 407
387/* 408/*
@@ -490,6 +511,37 @@ static struct platform_device pasic3 = {
490 * External power 511 * External power
491 */ 512 */
492 513
514static int power_supply_init(struct device *dev)
515{
516 int ret;
517
518 ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC");
519 if (ret)
520 goto err_cs_ac;
521 ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_USB, "CABLE_STATE_USB");
522 if (ret)
523 goto err_cs_usb;
524 ret = gpio_request(EGPIO_MAGICIAN_CHARGE_EN, "CHARGE_EN");
525 if (ret)
526 goto err_chg_en;
527 ret = gpio_request(GPIO30_MAGICIAN_nCHARGE_EN, "nCHARGE_EN");
528 if (!ret)
529 ret = gpio_direction_output(GPIO30_MAGICIAN_nCHARGE_EN, 0);
530 if (ret)
531 goto err_nchg_en;
532
533 return 0;
534
535err_nchg_en:
536 gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
537err_chg_en:
538 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
539err_cs_usb:
540 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
541err_cs_ac:
542 return ret;
543}
544
493static int magician_is_ac_online(void) 545static int magician_is_ac_online(void)
494{ 546{
495 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); 547 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC);
@@ -506,14 +558,24 @@ static void magician_set_charge(int flags)
506 gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags); 558 gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags);
507} 559}
508 560
561static void power_supply_exit(struct device *dev)
562{
563 gpio_free(GPIO30_MAGICIAN_nCHARGE_EN);
564 gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
565 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
566 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
567}
568
509static char *magician_supplicants[] = { 569static char *magician_supplicants[] = {
510 "ds2760-battery.0", "backup-battery" 570 "ds2760-battery.0", "backup-battery"
511}; 571};
512 572
513static struct pda_power_pdata power_supply_info = { 573static struct pda_power_pdata power_supply_info = {
574 .init = power_supply_init,
514 .is_ac_online = magician_is_ac_online, 575 .is_ac_online = magician_is_ac_online,
515 .is_usb_online = magician_is_usb_online, 576 .is_usb_online = magician_is_usb_online,
516 .set_charge = magician_set_charge, 577 .set_charge = magician_set_charge,
578 .exit = power_supply_exit,
517 .supplied_to = magician_supplicants, 579 .supplied_to = magician_supplicants,
518 .num_supplicants = ARRAY_SIZE(magician_supplicants), 580 .num_supplicants = ARRAY_SIZE(magician_supplicants),
519}; 581};