Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8703dc8 authored by Richard Purdie's avatar Richard Purdie Committed by Russell King
Browse files

[ARM] 3564/1: sharpsl_pm: Abstract some machine specific parameters



Patch from Richard Purdie

Abstract some machine specific parameters from the sharpsl_pm core
into the machine specific drivers. This allows the core to support
tosa/poodle.

Signed-off-by: default avatarRichard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 88660351
Loading
Loading
Loading
Loading
+11 −17
Original line number Original line Diff line number Diff line
@@ -49,13 +49,6 @@
#define SHARPSL_CHARGE_CO_CHECK_TIME           5   /* 5 msec */
#define SHARPSL_CHARGE_CO_CHECK_TIME           5   /* 5 msec */
#define SHARPSL_CHARGE_RETRY_CNT               1   /* eqv. 10 min */
#define SHARPSL_CHARGE_RETRY_CNT               1   /* eqv. 10 min */


#define SHARPSL_CHARGE_ON_VOLT         0x99  /* 2.9V */
#define SHARPSL_CHARGE_ON_TEMP         0xe0  /* 2.9V */
#define SHARPSL_CHARGE_ON_ACIN_HIGH    0x9b  /* 6V */
#define SHARPSL_CHARGE_ON_ACIN_LOW     0x34  /* 2V */
#define SHARPSL_FATAL_ACIN_VOLT        182   /* 3.45V */
#define SHARPSL_FATAL_NOACIN_VOLT      170   /* 3.40V */

/*
/*
 * Prototypes
 * Prototypes
 */
 */
@@ -82,12 +75,13 @@ DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger);
static int get_percentage(int voltage)
static int get_percentage(int voltage)
{
{
	int i = sharpsl_pm.machinfo->bat_levels - 1;
	int i = sharpsl_pm.machinfo->bat_levels - 1;
	int bl_status = sharpsl_pm.machinfo->backlight_get_status ? sharpsl_pm.machinfo->backlight_get_status() : 0;
	struct battery_thresh *thresh;
	struct battery_thresh *thresh;


	if (sharpsl_pm.charge_mode == CHRG_ON)
	if (sharpsl_pm.charge_mode == CHRG_ON)
		thresh=sharpsl_pm.machinfo->bat_levels_acin;
		thresh = bl_status ? sharpsl_pm.machinfo->bat_levels_acin_bl : sharpsl_pm.machinfo->bat_levels_acin;
	else
	else
		thresh=sharpsl_pm.machinfo->bat_levels_noac;
		thresh = bl_status ? sharpsl_pm.machinfo->bat_levels_noac_bl : sharpsl_pm.machinfo->bat_levels_noac;


	while (i > 0 && (voltage > thresh[i].voltage))
	while (i > 0 && (voltage > thresh[i].voltage))
		i--;
		i--;
@@ -131,7 +125,7 @@ static void sharpsl_battery_thread(void *private_)
	sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE);
	sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE);


	/* Corgi cannot confirm when battery fully charged so periodically kick! */
	/* Corgi cannot confirm when battery fully charged so periodically kick! */
	if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON)
	if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON)
			&& time_after(jiffies, sharpsl_pm.charge_start_time +  SHARPSL_CHARGE_ON_TIME_INTERVAL))
			&& time_after(jiffies, sharpsl_pm.charge_start_time +  SHARPSL_CHARGE_ON_TIME_INTERVAL))
		schedule_work(&toggle_charger);
		schedule_work(&toggle_charger);


@@ -166,11 +160,11 @@ static void sharpsl_battery_thread(void *private_)
			&& ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
			&& ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
			(sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
			(sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
		if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) {
		if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) {
			corgibl_limit_intensity(1);
			sharpsl_pm.machinfo->backlight_limit(1);
			sharpsl_pm.flags |= SHARPSL_BL_LIMIT;
			sharpsl_pm.flags |= SHARPSL_BL_LIMIT;
		}
		}
	} else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) {
	} else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) {
		corgibl_limit_intensity(0);
		sharpsl_pm.machinfo->backlight_limit(0);
		sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT;
		sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT;
	}
	}


@@ -418,7 +412,7 @@ static int sharpsl_check_battery_temp(void)
	val = get_select_val(buff);
	val = get_select_val(buff);


	dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
	dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
	if (val > SHARPSL_CHARGE_ON_TEMP)
	if (val > sharpsl_pm.machinfo->charge_on_temp)
		return -1;
		return -1;


	return 0;
	return 0;
@@ -450,7 +444,7 @@ static int sharpsl_check_battery_voltage(void)
	val = get_select_val(buff);
	val = get_select_val(buff);
	dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val);
	dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val);


	if (val < SHARPSL_CHARGE_ON_VOLT)
	if (val < sharpsl_pm.machinfo->charge_on_volt)
		return -1;
		return -1;


	return 0;
	return 0;
@@ -468,7 +462,7 @@ static int sharpsl_ac_check(void)
	temp = get_select_val(buff);
	temp = get_select_val(buff);
	dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
	dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);


	if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) {
	if ((temp > sharpsl_pm.machinfo->charge_acin_high) || (temp < sharpsl_pm.machinfo->charge_acin_low)) {
		dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
		dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
		return -1;
		return -1;
	}
	}
@@ -627,8 +621,8 @@ static int sharpsl_fatal_check(void)
	temp = get_select_val(buff);
	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: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));


	if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) ||
	if ((acin && (temp < sharpsl_pm.machinfo->fatal_acin_volt)) ||
			(!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT)))
			(!acin && (temp < sharpsl_pm.machinfo->fatal_noacin_volt)))
		return -1;
		return -1;
	return 0;
	return 0;
}
}
+20 −3
Original line number Original line Diff line number Diff line
@@ -27,6 +27,13 @@
#include <asm/arch/pxa-regs.h>
#include <asm/arch/pxa-regs.h>
#include "sharpsl.h"
#include "sharpsl.h"


#define SHARPSL_CHARGE_ON_VOLT         0x99  /* 2.9V */
#define SHARPSL_CHARGE_ON_TEMP         0xe0  /* 2.9V */
#define SHARPSL_CHARGE_ON_ACIN_HIGH    0x9b  /* 6V */
#define SHARPSL_CHARGE_ON_ACIN_LOW     0x34  /* 2V */
#define SHARPSL_FATAL_ACIN_VOLT        182   /* 3.45V */
#define SHARPSL_FATAL_NOACIN_VOLT      170   /* 3.40V */

static void corgi_charger_init(void)
static void corgi_charger_init(void)
{
{
	pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT);
	pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT);
@@ -195,6 +202,13 @@ static struct sharpsl_charger_machinfo corgi_pm_machinfo = {
	.read_devdata    = corgipm_read_devdata,
	.read_devdata    = corgipm_read_devdata,
	.charger_wakeup  = corgi_charger_wakeup,
	.charger_wakeup  = corgi_charger_wakeup,
	.should_wakeup   = corgi_should_wakeup,
	.should_wakeup   = corgi_should_wakeup,
	.backlight_limit = corgibl_limit_intensity,
	.charge_on_volt	  = SHARPSL_CHARGE_ON_VOLT,
	.charge_on_temp	  = SHARPSL_CHARGE_ON_TEMP,
	.charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH,
	.charge_acin_low  = SHARPSL_CHARGE_ON_ACIN_LOW,
	.fatal_acin_volt  = SHARPSL_FATAL_ACIN_VOLT,
	.fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT,
	.bat_levels       = 40,
	.bat_levels       = 40,
	.bat_levels_noac  = spitz_battery_levels_noac,
	.bat_levels_noac  = spitz_battery_levels_noac,
	.bat_levels_acin  = spitz_battery_levels_acin,
	.bat_levels_acin  = spitz_battery_levels_acin,
@@ -214,6 +228,9 @@ static int __devinit corgipm_init(void)
	if (!corgipm_device)
	if (!corgipm_device)
		return -ENOMEM;
		return -ENOMEM;


	if (!machine_is_corgi())
	    corgi_pm_machinfo.batfull_irq = 1;

	corgipm_device->dev.platform_data = &corgi_pm_machinfo;
	corgipm_device->dev.platform_data = &corgi_pm_machinfo;
	ret = platform_device_add(corgipm_device);
	ret = platform_device_add(corgipm_device);


+5 −2
Original line number Original line Diff line number Diff line
@@ -128,6 +128,9 @@ struct battery_thresh spitz_battery_levels_noac[] = {
 */
 */
int sharpsl_pm_pxa_read_max1111(int channel)
int sharpsl_pm_pxa_read_max1111(int channel)
{
{
	if (machine_is_tosa()) // Ugly, better move this function into another module
	    return 0;

	return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1
	return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1
			| MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
			| MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
}
}
@@ -156,7 +159,7 @@ void sharpsl_pm_pxa_init(void)
		else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING);
		else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING);
	}
	}


	if (!machine_is_corgi())
	if (sharpsl_pm.machinfo->batfull_irq)
	{
	{
		/* Register interrupt handler. */
		/* Register interrupt handler. */
		if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) {
		if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) {
@@ -174,6 +177,6 @@ void sharpsl_pm_pxa_remove(void)
	if (sharpsl_pm.machinfo->gpio_fatal)
	if (sharpsl_pm.machinfo->gpio_fatal)
		free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr);
		free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr);


	if (!machine_is_corgi())
	if (sharpsl_pm.machinfo->batfull_irq)
		free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr);
		free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr);
}
}
+15 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,13 @@
#include <asm/arch/pxa-regs.h>
#include <asm/arch/pxa-regs.h>
#include "sharpsl.h"
#include "sharpsl.h"


#define SHARPSL_CHARGE_ON_VOLT         0x99  /* 2.9V */
#define SHARPSL_CHARGE_ON_TEMP         0xe0  /* 2.9V */
#define SHARPSL_CHARGE_ON_ACIN_HIGH    0x9b  /* 6V */
#define SHARPSL_CHARGE_ON_ACIN_LOW     0x34  /* 2V */
#define SHARPSL_FATAL_ACIN_VOLT        182   /* 3.45V */
#define SHARPSL_FATAL_NOACIN_VOLT      170   /* 3.40V */

static int spitz_last_ac_status;
static int spitz_last_ac_status;


static void spitz_charger_init(void)
static void spitz_charger_init(void)
@@ -190,6 +197,7 @@ struct sharpsl_charger_machinfo spitz_pm_machinfo = {
	.gpio_batlock     = SPITZ_GPIO_BAT_COVER,
	.gpio_batlock     = SPITZ_GPIO_BAT_COVER,
	.gpio_acin        = SPITZ_GPIO_AC_IN,
	.gpio_acin        = SPITZ_GPIO_AC_IN,
	.gpio_batfull     = SPITZ_GPIO_CHRG_FULL,
	.gpio_batfull     = SPITZ_GPIO_CHRG_FULL,
	.batfull_irq	  = 1,
	.gpio_fatal       = SPITZ_GPIO_FATAL_BAT,
	.gpio_fatal       = SPITZ_GPIO_FATAL_BAT,
	.discharge        = spitz_discharge,
	.discharge        = spitz_discharge,
	.discharge1       = spitz_discharge1,
	.discharge1       = spitz_discharge1,
@@ -200,6 +208,13 @@ struct sharpsl_charger_machinfo spitz_pm_machinfo = {
	.read_devdata     = spitzpm_read_devdata,
	.read_devdata     = spitzpm_read_devdata,
	.charger_wakeup   = spitz_charger_wakeup,
	.charger_wakeup   = spitz_charger_wakeup,
	.should_wakeup    = spitz_should_wakeup,
	.should_wakeup    = spitz_should_wakeup,
        .backlight_limit  = corgibl_limit_intensity,
	.charge_on_volt	  = SHARPSL_CHARGE_ON_VOLT,
	.charge_on_temp	  = SHARPSL_CHARGE_ON_TEMP,
	.charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH,
	.charge_acin_low  = SHARPSL_CHARGE_ON_ACIN_LOW,
	.fatal_acin_volt  = SHARPSL_FATAL_ACIN_VOLT,
	.fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT,
	.bat_levels       = 40,
	.bat_levels       = 40,
	.bat_levels_noac  = spitz_battery_levels_noac,
	.bat_levels_noac  = spitz_battery_levels_noac,
	.bat_levels_acin  = spitz_battery_levels_acin,
	.bat_levels_acin  = spitz_battery_levels_acin,
+11 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ struct sharpsl_charger_machinfo {
	void (*exit)(void);
	void (*exit)(void);
	int gpio_acin;
	int gpio_acin;
	int gpio_batfull;
	int gpio_batfull;
	int batfull_irq;
	int gpio_batlock;
	int gpio_batlock;
	int gpio_fatal;
	int gpio_fatal;
	void (*discharge)(int);
	void (*discharge)(int);
@@ -34,9 +35,19 @@ struct sharpsl_charger_machinfo {
#define SHARPSL_STATUS_FATAL    7
#define SHARPSL_STATUS_FATAL    7
	unsigned long (*charger_wakeup)(void);
	unsigned long (*charger_wakeup)(void);
	int (*should_wakeup)(unsigned int resume_on_alarm);
	int (*should_wakeup)(unsigned int resume_on_alarm);
	void (*backlight_limit)(int);
	int (*backlight_get_status) (void);
	int charge_on_volt;
	int charge_on_temp;
	int charge_acin_high;
	int charge_acin_low;
	int fatal_acin_volt;
	int fatal_noacin_volt;
	int bat_levels;
	int bat_levels;
	struct battery_thresh *bat_levels_noac;
	struct battery_thresh *bat_levels_noac;
	struct battery_thresh *bat_levels_acin;
	struct battery_thresh *bat_levels_acin;
	struct battery_thresh *bat_levels_noac_bl;
	struct battery_thresh *bat_levels_acin_bl;
	int status_high_acin;
	int status_high_acin;
	int status_low_acin;
	int status_low_acin;
	int status_high_noac;
	int status_high_noac;