aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2005-11-12 13:53:48 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-12 13:53:48 -0500
commitc5e1ae9729d97d3c543cc70d7865df1e724da0d0 (patch)
treec10757499cdc717b4b06166cb6dae2aa196239ce /arch/arm/mach-pxa
parent94cabd003e989556d8bf84027d96284dc2d99c76 (diff)
[ARM] 3154/1: SharpSL PM Driver updates
Patch from Richard Purdie Updates to the SharpSL PM driver including cleanups from both Pavel Machek and myself and updates after the platform device changes to make it compile again. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa')
-rw-r--r--arch/arm/mach-pxa/sharpsl.h8
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c109
2 files changed, 61 insertions, 56 deletions
diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h
index 4879c0f7da72..b0c40a1d6671 100644
--- a/arch/arm/mach-pxa/sharpsl.h
+++ b/arch/arm/mach-pxa/sharpsl.h
@@ -115,7 +115,7 @@ extern struct battery_thresh spitz_battery_levels_noac[];
115#define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR) 115#define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR)
116#define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1) 116#define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1)
117#define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0) 117#define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0)
118#define STATUS_AC_IN sharpsl_pm.machinfo->status_acin() 118#define STATUS_AC_IN() sharpsl_pm.machinfo->status_acin()
119#define STATUS_BATT_LOCKED READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock) 119#define STATUS_BATT_LOCKED() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock)
120#define STATUS_CHRG_FULL READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull) 120#define STATUS_CHRG_FULL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull)
121#define STATUS_FATAL READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal) 121#define STATUS_FATAL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal)
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 6c9e871c53d8..c10be00fb526 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -21,7 +21,7 @@
21#include <linux/apm_bios.h> 21#include <linux/apm_bios.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/device.h> 24#include <linux/platform_device.h>
25 25
26#include <asm/hardware.h> 26#include <asm/hardware.h>
27#include <asm/hardware/scoop.h> 27#include <asm/hardware/scoop.h>
@@ -45,15 +45,15 @@
45#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */ 45#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */
46#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */ 46#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */
47#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */ 47#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */
48#define SHARPSL_CHECK_BATTERY_WAIT_TIME_JKVAD 10 /* 10 msec */ 48#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */
49#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */ 49#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */
50#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ 50#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */
51#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ 51#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */
52 52
53#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ 53#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */
54#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ 54#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */
55#define SHARPSL_CHARGE_ON_JKVAD_HIGH 0x9b /* 6V */ 55#define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */
56#define SHARPSL_CHARGE_ON_JKVAD_LOW 0x34 /* 2V */ 56#define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */
57#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ 57#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */
58#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ 58#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */
59 59
@@ -160,9 +160,10 @@ struct battery_thresh spitz_battery_levels_noac[] = {
160/* 160/*
161 * Prototypes 161 * Prototypes
162 */ 162 */
163static int sharpsl_read_MainBattery(void); 163static int sharpsl_read_main_battery(void);
164static int sharpsl_off_charge_battery(void); 164static int sharpsl_off_charge_battery(void);
165static int sharpsl_check_battery(int mode); 165static int sharpsl_check_battery_temp(void);
166static int sharpsl_check_battery_voltage(void);
166static int sharpsl_ac_check(void); 167static int sharpsl_ac_check(void);
167static int sharpsl_fatal_check(void); 168static int sharpsl_fatal_check(void);
168static int sharpsl_average_value(int ad); 169static int sharpsl_average_value(int ad);
@@ -228,7 +229,7 @@ static void sharpsl_battery_thread(void *private_)
228 if (!sharpsl_pm.machinfo) 229 if (!sharpsl_pm.machinfo)
229 return; 230 return;
230 231
231 sharpsl_pm.battstat.ac_status = (!(STATUS_AC_IN) ? APM_AC_OFFLINE : APM_AC_ONLINE); 232 sharpsl_pm.battstat.ac_status = (STATUS_AC_IN() ? APM_AC_ONLINE : APM_AC_OFFLINE);
232 233
233 /* Corgi cannot confirm when battery fully charged so periodically kick! */ 234 /* Corgi cannot confirm when battery fully charged so periodically kick! */
234 if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON) 235 if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON)
@@ -236,7 +237,7 @@ static void sharpsl_battery_thread(void *private_)
236 schedule_work(&toggle_charger); 237 schedule_work(&toggle_charger);
237 238
238 while(1) { 239 while(1) {
239 voltage = sharpsl_read_MainBattery(); 240 voltage = sharpsl_read_main_battery();
240 if (voltage > 0) break; 241 if (voltage > 0) break;
241 if (i++ > 5) { 242 if (i++ > 5) {
242 voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage; 243 voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
@@ -317,10 +318,10 @@ static void sharpsl_charge_toggle(void *private_)
317{ 318{
318 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); 319 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
319 320
320 if (STATUS_AC_IN == 0) { 321 if (STATUS_AC_IN() == 0) {
321 sharpsl_charge_off(); 322 sharpsl_charge_off();
322 return; 323 return;
323 } else if ((sharpsl_check_battery(1) < 0) || (sharpsl_ac_check() < 0)) { 324 } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) {
324 sharpsl_charge_error(); 325 sharpsl_charge_error();
325 return; 326 return;
326 } 327 }
@@ -335,7 +336,7 @@ static void sharpsl_charge_toggle(void *private_)
335 336
336static void sharpsl_ac_timer(unsigned long data) 337static void sharpsl_ac_timer(unsigned long data)
337{ 338{
338 int acin = STATUS_AC_IN; 339 int acin = STATUS_AC_IN();
339 340
340 dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin); 341 dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin);
341 342
@@ -364,7 +365,7 @@ static void sharpsl_chrg_full_timer(unsigned long data)
364 365
365 sharpsl_pm.full_count++; 366 sharpsl_pm.full_count++;
366 367
367 if (STATUS_AC_IN == 0) { 368 if (STATUS_AC_IN() == 0) {
368 dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n"); 369 dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n");
369 if (sharpsl_pm.charge_mode == CHRG_ON) 370 if (sharpsl_pm.charge_mode == CHRG_ON)
370 sharpsl_charge_off(); 371 sharpsl_charge_off();
@@ -399,12 +400,12 @@ static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp)
399{ 400{
400 int is_fatal = 0; 401 int is_fatal = 0;
401 402
402 if (STATUS_BATT_LOCKED == 0) { 403 if (STATUS_BATT_LOCKED() == 0) {
403 dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n"); 404 dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n");
404 is_fatal = 1; 405 is_fatal = 1;
405 } 406 }
406 407
407 if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL == 0)) { 408 if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL() == 0)) {
408 dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n"); 409 dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n");
409 is_fatal = 1; 410 is_fatal = 1;
410 } 411 }
@@ -461,12 +462,12 @@ static int read_max1111(int channel)
461 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); 462 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
462} 463}
463 464
464static int sharpsl_read_MainBattery(void) 465static int sharpsl_read_main_battery(void)
465{ 466{
466 return read_max1111(BATT_AD); 467 return read_max1111(BATT_AD);
467} 468}
468 469
469static int sharpsl_read_Temp(void) 470static int sharpsl_read_temp(void)
470{ 471{
471 int temp; 472 int temp;
472 473
@@ -480,7 +481,7 @@ static int sharpsl_read_Temp(void)
480 return temp; 481 return temp;
481} 482}
482 483
483static int sharpsl_read_jkvad(void) 484static int sharpsl_read_acin(void)
484{ 485{
485 return read_max1111(JK_VAD); 486 return read_max1111(JK_VAD);
486} 487}
@@ -522,16 +523,14 @@ static int get_select_val(int *val)
522 return (sum/3); 523 return (sum/3);
523} 524}
524 525
525/* mode 0 - Check temperature and voltage 526static int sharpsl_check_battery_temp(void)
526 * 1 - Check temperature only */
527static int sharpsl_check_battery(int mode)
528{ 527{
529 int val, i, buff[5]; 528 int val, i, buff[5];
530 529
531 /* Check battery temperature */ 530 /* Check battery temperature */
532 for (i=0; i<5; i++) { 531 for (i=0; i<5; i++) {
533 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); 532 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
534 buff[i] = sharpsl_read_Temp(); 533 buff[i] = sharpsl_read_temp();
535 } 534 }
536 535
537 val = get_select_val(buff); 536 val = get_select_val(buff);
@@ -539,8 +538,13 @@ static int sharpsl_check_battery(int mode)
539 dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); 538 dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
540 if (val > SHARPSL_CHARGE_ON_TEMP) 539 if (val > SHARPSL_CHARGE_ON_TEMP)
541 return -1; 540 return -1;
542 if (mode == 1) 541
543 return 0; 542 return 0;
543}
544
545static int sharpsl_check_battery_voltage(void)
546{
547 int val, i, buff[5];
544 548
545 /* disable charge, enable discharge */ 549 /* disable charge, enable discharge */
546 CHARGE_OFF(); 550 CHARGE_OFF();
@@ -552,7 +556,7 @@ static int sharpsl_check_battery(int mode)
552 556
553 /* Check battery voltage */ 557 /* Check battery voltage */
554 for (i=0; i<5; i++) { 558 for (i=0; i<5; i++) {
555 buff[i] = sharpsl_read_MainBattery(); 559 buff[i] = sharpsl_read_main_battery();
556 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); 560 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
557 } 561 }
558 562
@@ -575,14 +579,14 @@ static int sharpsl_ac_check(void)
575 int temp, i, buff[5]; 579 int temp, i, buff[5];
576 580
577 for (i=0; i<5; i++) { 581 for (i=0; i<5; i++) {
578 buff[i] = sharpsl_read_jkvad(); 582 buff[i] = sharpsl_read_acin();
579 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_JKVAD); 583 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN);
580 } 584 }
581 585
582 temp = get_select_val(buff); 586 temp = get_select_val(buff);
583 dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); 587 dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
584 588
585 if ((temp > SHARPSL_CHARGE_ON_JKVAD_HIGH) || (temp < SHARPSL_CHARGE_ON_JKVAD_LOW)) { 589 if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) {
586 dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); 590 dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
587 return -1; 591 return -1;
588 } 592 }
@@ -591,7 +595,7 @@ static int sharpsl_ac_check(void)
591} 595}
592 596
593#ifdef CONFIG_PM 597#ifdef CONFIG_PM
594static int sharpsl_pm_suspend(struct device *dev, pm_message_t state) 598static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state)
595{ 599{
596 sharpsl_pm.flags |= SHARPSL_SUSPENDED; 600 sharpsl_pm.flags |= SHARPSL_SUSPENDED;
597 flush_scheduled_work(); 601 flush_scheduled_work();
@@ -604,7 +608,7 @@ static int sharpsl_pm_suspend(struct device *dev, pm_message_t state)
604 return 0; 608 return 0;
605} 609}
606 610
607static int sharpsl_pm_resume(struct device *dev) 611static int sharpsl_pm_resume(struct platform_device *pdev)
608{ 612{
609 /* Clear the reset source indicators as they break the bootloader upon reboot */ 613 /* Clear the reset source indicators as they break the bootloader upon reboot */
610 RCSR = 0x0f; 614 RCSR = 0x0f;
@@ -622,7 +626,7 @@ static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable
622 dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG); 626 dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
623 /* not charging and AC-IN! */ 627 /* not charging and AC-IN! */
624 628
625 if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN != 0)) { 629 if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN() != 0)) {
626 dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n"); 630 dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n");
627 sharpsl_pm.charge_mode = CHRG_OFF; 631 sharpsl_pm.charge_mode = CHRG_OFF;
628 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; 632 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
@@ -671,7 +675,7 @@ static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enab
671 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); 675 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n");
672 } 676 }
673 677
674 if ((STATUS_BATT_LOCKED == 0) || (sharpsl_fatal_check() < 0) ) 678 if ((STATUS_BATT_LOCKED() == 0) || (sharpsl_fatal_check() < 0) )
675 { 679 {
676 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); 680 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n");
677 corgi_goto_sleep(alarm_time, alarm_enable, state); 681 corgi_goto_sleep(alarm_time, alarm_enable, state);
@@ -711,7 +715,7 @@ static int sharpsl_fatal_check(void)
711 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n"); 715 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n");
712 716
713 /* Check AC-Adapter */ 717 /* Check AC-Adapter */
714 acin = STATUS_AC_IN; 718 acin = STATUS_AC_IN();
715 719
716 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { 720 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
717 CHARGE_OFF(); 721 CHARGE_OFF();
@@ -725,7 +729,7 @@ static int sharpsl_fatal_check(void)
725 729
726 /* Check battery : check inserting battery ? */ 730 /* Check battery : check inserting battery ? */
727 for (i=0; i<5; i++) { 731 for (i=0; i<5; i++) {
728 buff[i] = sharpsl_read_MainBattery(); 732 buff[i] = sharpsl_read_main_battery();
729 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); 733 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
730 } 734 }
731 735
@@ -739,7 +743,7 @@ static int sharpsl_fatal_check(void)
739 } 743 }
740 744
741 temp = get_select_val(buff); 745 temp = get_select_val(buff);
742 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_MainBattery()); 746 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_main_battery());
743 747
744 if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) || 748 if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) ||
745 (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT))) 749 (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT)))
@@ -771,7 +775,7 @@ static int sharpsl_off_charge_battery(void)
771 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n"); 775 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n");
772 776
773 /* AC Check */ 777 /* AC Check */
774 if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery(1) < 0)) 778 if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0))
775 return sharpsl_off_charge_error(); 779 return sharpsl_off_charge_error();
776 780
777 /* Start Charging */ 781 /* Start Charging */
@@ -793,7 +797,7 @@ static int sharpsl_off_charge_battery(void)
793 797
794 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n"); 798 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n");
795 799
796 if (sharpsl_check_battery(0) < 0) 800 if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0))
797 return sharpsl_off_charge_error(); 801 return sharpsl_off_charge_error();
798 802
799 CHARGE_OFF(); 803 CHARGE_OFF();
@@ -811,7 +815,7 @@ static int sharpsl_off_charge_battery(void)
811 /* Check for timeout */ 815 /* Check for timeout */
812 if ((RCNR - time) > SHARPSL_WAIT_CO_TIME) 816 if ((RCNR - time) > SHARPSL_WAIT_CO_TIME)
813 return 1; 817 return 1;
814 if (STATUS_CHRG_FULL) { 818 if (STATUS_CHRG_FULL()) {
815 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n"); 819 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n");
816 sharpsl_pm.full_count++; 820 sharpsl_pm.full_count++;
817 CHARGE_OFF(); 821 CHARGE_OFF();
@@ -840,7 +844,7 @@ static int sharpsl_off_charge_battery(void)
840 sharpsl_pm.full_count++; 844 sharpsl_pm.full_count++;
841 return 1; 845 return 1;
842 } 846 }
843 if (STATUS_CHRG_FULL) { 847 if (STATUS_CHRG_FULL()) {
844 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n"); 848 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n");
845 CHARGE_LED_OFF(); 849 CHARGE_LED_OFF();
846 CHARGE_OFF(); 850 CHARGE_OFF();
@@ -886,13 +890,13 @@ static struct pm_ops sharpsl_pm_ops = {
886 .finish = pxa_pm_finish, 890 .finish = pxa_pm_finish,
887}; 891};
888 892
889static int __init sharpsl_pm_probe(struct device *dev) 893static int __init sharpsl_pm_probe(struct platform_device *pdev)
890{ 894{
891 if (!dev->platform_data) 895 if (!pdev->dev.platform_data)
892 return -EINVAL; 896 return -EINVAL;
893 897
894 sharpsl_pm.dev = dev; 898 sharpsl_pm.dev = &pdev->dev;
895 sharpsl_pm.machinfo = dev->platform_data; 899 sharpsl_pm.machinfo = pdev->dev.platform_data;
896 sharpsl_pm.charge_mode = CHRG_OFF; 900 sharpsl_pm.charge_mode = CHRG_OFF;
897 sharpsl_pm.flags = 0; 901 sharpsl_pm.flags = 0;
898 902
@@ -935,8 +939,8 @@ static int __init sharpsl_pm_probe(struct device *dev)
935 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); 939 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING);
936 } 940 }
937 941
938 device_create_file(dev, &dev_attr_battery_percentage); 942 device_create_file(&pdev->dev, &dev_attr_battery_percentage);
939 device_create_file(dev, &dev_attr_battery_voltage); 943 device_create_file(&pdev->dev, &dev_attr_battery_voltage);
940 944
941 apm_get_power_status = sharpsl_apm_get_power_status; 945 apm_get_power_status = sharpsl_apm_get_power_status;
942 946
@@ -947,12 +951,12 @@ static int __init sharpsl_pm_probe(struct device *dev)
947 return 0; 951 return 0;
948} 952}
949 953
950static int sharpsl_pm_remove(struct device *dev) 954static int sharpsl_pm_remove(struct platform_device *pdev)
951{ 955{
952 pm_set_ops(NULL); 956 pm_set_ops(NULL);
953 957
954 device_remove_file(dev, &dev_attr_battery_percentage); 958 device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
955 device_remove_file(dev, &dev_attr_battery_voltage); 959 device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
956 960
957 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); 961 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr);
958 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); 962 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr);
@@ -969,23 +973,24 @@ static int sharpsl_pm_remove(struct device *dev)
969 return 0; 973 return 0;
970} 974}
971 975
972static struct device_driver sharpsl_pm_driver = { 976static struct platform_driver sharpsl_pm_driver = {
973 .name = "sharpsl-pm",
974 .bus = &platform_bus_type,
975 .probe = sharpsl_pm_probe, 977 .probe = sharpsl_pm_probe,
976 .remove = sharpsl_pm_remove, 978 .remove = sharpsl_pm_remove,
977 .suspend = sharpsl_pm_suspend, 979 .suspend = sharpsl_pm_suspend,
978 .resume = sharpsl_pm_resume, 980 .resume = sharpsl_pm_resume,
981 .driver = {
982 .name = "sharpsl-pm",
983 },
979}; 984};
980 985
981static int __devinit sharpsl_pm_init(void) 986static int __devinit sharpsl_pm_init(void)
982{ 987{
983 return driver_register(&sharpsl_pm_driver); 988 return platform_driver_register(&sharpsl_pm_driver);
984} 989}
985 990
986static void sharpsl_pm_exit(void) 991static void sharpsl_pm_exit(void)
987{ 992{
988 driver_unregister(&sharpsl_pm_driver); 993 platform_driver_unregister(&sharpsl_pm_driver);
989} 994}
990 995
991late_initcall(sharpsl_pm_init); 996late_initcall(sharpsl_pm_init);