[ARM] pxa: separate out power manager and clock registers
[deliverable/linux.git] / arch / arm / common / sharpsl_pm.c
index 5972df2b9af479a6f54f770baddca6419ad5f3bd..8822b684d474ad322b71bbcf3fe457316fdba775 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/leds.h>
 #include <linux/apm-emulation.h>
+#include <linux/suspend.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/irq.h>
 #include <asm/arch/pm.h>
 #include <asm/arch/pxa-regs.h>
+#include <asm/arch/pxa2xx-regs.h>
 #include <asm/arch/sharpsl.h>
 #include <asm/hardware/sharpsl_pm.h>
 
@@ -153,9 +155,10 @@ static void sharpsl_battery_thread(struct work_struct *private_)
                sharpsl_pm.battstat.mainbat_percent = percent;
        }
 
-       dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage,
+       dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %ld\n", voltage,
                        sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies);
 
+#ifdef CONFIG_BACKLIGHT_CORGI
        /* If battery is low. limit backlight intensity to save power. */
        if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
                        && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
@@ -168,6 +171,7 @@ static void sharpsl_battery_thread(struct work_struct *private_)
                sharpsl_pm.machinfo->backlight_limit(0);
                sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT;
        }
+#endif
 
        /* Suspend if critical battery level */
        if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
@@ -291,7 +295,7 @@ static void sharpsl_chrg_full_timer(unsigned long data)
 }
 
 /* Charging Finished Interrupt (Not present on Corgi) */
-/* Can trigger at the same time as an AC staus change so
+/* Can trigger at the same time as an AC status change so
    delay until after that has been processed */
 irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id)
 {
@@ -625,7 +629,7 @@ static int sharpsl_fatal_check(void)
        }
 
        temp = get_select_val(buff);
-       dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));
+       dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %ld\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));
 
        if ((acin && (temp < sharpsl_pm.machinfo->fatal_acin_volt)) ||
                        (!acin && (temp < sharpsl_pm.machinfo->fatal_noacin_volt)))
@@ -635,7 +639,7 @@ static int sharpsl_fatal_check(void)
 
 static int sharpsl_off_charge_error(void)
 {
-       dev_err(sharpsl_pm.dev, "Offline Charger: Error occured.\n");
+       dev_err(sharpsl_pm.dev, "Offline Charger: Error occurred.\n");
        sharpsl_pm.machinfo->charge(0);
        sharpsl_pm_led(SHARPSL_LED_ERROR);
        sharpsl_pm.charge_mode = CHRG_ERROR;
@@ -691,14 +695,14 @@ static int sharpsl_off_charge_battery(void)
 
                time = RCNR;
                while(1) {
-                       /* Check if any wakeup event had occured */
+                       /* Check if any wakeup event had occurred */
                        if (sharpsl_pm.machinfo->charger_wakeup() != 0)
                                return 0;
                        /* Check for timeout */
                        if ((RCNR - time) > SHARPSL_WAIT_CO_TIME)
                                return 1;
                        if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL)) {
-                               dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n");
+                               dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occurred. Retrying to check\n");
                                sharpsl_pm.full_count++;
                                sharpsl_pm.machinfo->charge(0);
                                mdelay(SHARPSL_CHARGE_WAIT_TIME);
@@ -714,7 +718,7 @@ static int sharpsl_off_charge_battery(void)
 
        time = RCNR;
        while(1) {
-               /* Check if any wakeup event had occured */
+               /* Check if any wakeup event had occurred */
                if (sharpsl_pm.machinfo->charger_wakeup() != 0)
                        return 0;
                /* Check for timeout */
@@ -765,15 +769,15 @@ static void sharpsl_apm_get_power_status(struct apm_power_info *info)
        info->battery_life = sharpsl_pm.battstat.mainbat_percent;
 }
 
-static struct pm_ops sharpsl_pm_ops = {
-       .prepare        = pxa_pm_prepare,
+static struct platform_suspend_ops sharpsl_pm_ops = {
        .enter          = corgi_pxa_pm_enter,
-       .finish         = pxa_pm_finish,
-       .valid          = pm_valid_only_mem,
+       .valid          = suspend_valid_only_mem,
 };
 
 static int __init sharpsl_pm_probe(struct platform_device *pdev)
 {
+       int ret;
+
        if (!pdev->dev.platform_data)
                return -EINVAL;
 
@@ -792,12 +796,14 @@ static int __init sharpsl_pm_probe(struct platform_device *pdev)
 
        sharpsl_pm.machinfo->init();
 
-       device_create_file(&pdev->dev, &dev_attr_battery_percentage);
-       device_create_file(&pdev->dev, &dev_attr_battery_voltage);
+       ret = device_create_file(&pdev->dev, &dev_attr_battery_percentage);
+       ret |= device_create_file(&pdev->dev, &dev_attr_battery_voltage);
+       if (ret != 0)
+               dev_warn(&pdev->dev, "Failed to register attributes (%d)\n", ret);
 
        apm_get_power_status = sharpsl_apm_get_power_status;
 
-       pm_set_ops(&sharpsl_pm_ops);
+       suspend_set_ops(&sharpsl_pm_ops);
 
        mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
 
@@ -806,7 +812,7 @@ static int __init sharpsl_pm_probe(struct platform_device *pdev)
 
 static int sharpsl_pm_remove(struct platform_device *pdev)
 {
-       pm_set_ops(NULL);
+       suspend_set_ops(NULL);
 
        device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
        device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
This page took 0.026657 seconds and 5 git commands to generate.