Re: [rfc] separate sharpsl_pm initialization from sysfs code

From: Pavel Machek
Date: Wed Mar 22 2006 - 04:35:28 EST


Hi!

> > /* Register interrupt handler. */
> > if ((err = request_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr, SA_INTERRUPT,
> > "ACIN", sharpsl_ac_isr))) {
> > printk("Could not get irq %d.\n", COLLIE_IRQ_GPIO_AC_IN);
> > return;
> > }
> > if ((err = request_irq(COLLIE_IRQ_GPIO_CO, sharpsl_chrg_full_isr, SA_INTERRUPT,
> > "CO", sharpsl_chrg_full_isr))) {
> > free_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr);
> > printk("Could not get irq %d.\n", COLLIE_IRQ_GPIO_CO);
> > return;
> > }
>
> Shouldn't these be ucb1x00_hook_irq()'s?
>
> Shouldn't you only enable the ADC when you need to use it?

Yes, I should.

> This driver makes no calls to ucb1x00_enable() and ucb1x00_disable().
> They're part of power management, and if your driver doesn't appear to
> require them to work, that means some other code is buggy (or you're
> keeping the ADC always enabled.)

Keeping ADC always enabled, which interferes with touchscreen,
badly. This fixes it, and allows touchscreen and battery to coexist.

(I'll clean it up and properly submit).
Pavel

Enable/disable adc as needed. Now battery and touchscreen code seems
to cooperate.

---
commit 4907317f98c84569eb6c3d9c24b5b177fe60981b
tree 2998b0eebdd138b56740575d98f02e1cecaf4c34
parent e89a9fd829a3cd639f93ec0291251f6a99916226
author <pavel@xxxxxxxxxx> Wed, 22 Mar 2006 10:22:10 +0100
committer <pavel@xxxxxxxxxx> Wed, 22 Mar 2006 10:22:10 +0100

arch/arm/mach-sa1100/collie_pm.c | 8 +++++++-
drivers/mfd/ucb1x00-ts.c | 4 +++-
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-sa1100/collie_pm.c b/arch/arm/mach-sa1100/collie_pm.c
index 1618ade..6a9f833 100644
--- a/arch/arm/mach-sa1100/collie_pm.c
+++ b/arch/arm/mach-sa1100/collie_pm.c
@@ -70,7 +70,6 @@ static void collie_charger_init(void)
ucb1x00_enable_irq(ucb, COLLIE_GPIO_AC_IN, UCB_RISING);
ucb1x00_enable_irq(ucb, COLLIE_GPIO_CO, UCB_RISING);

- ucb1x00_adc_enable(ucb);
ucb1x00_io_set_dir(ucb, 0, COLLIE_TC35143_GPIO_MBAT_ON | COLLIE_TC35143_GPIO_TMP_ON |
COLLIE_TC35143_GPIO_BBAT_ON);
return;
@@ -139,11 +138,14 @@ int collie_read_backup_battery(void)
{
int voltage;

+ ucb1x00_adc_enable(ucb);
+
/* Gives 75..130 */
ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_BBAT_ON, 0);
voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC);

ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON);
+ ucb1x00_adc_disable(ucb);

printk("Backup battery = %d(%d)\n", ADCtoPower(voltage), voltage);

@@ -158,6 +160,7 @@ int collie_read_main_battery(void)
collie_read_temp();
collie_read_backup_battery();
#endif
+ ucb1x00_adc_enable(ucb);
ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON);
ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_MBAT_ON, 0);
voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC);
@@ -170,6 +173,7 @@ int collie_read_main_battery(void)

On battery, it goes as low as 80.
*/
+ ucb1x00_adc_disable(ucb);

voltage_rev = voltage + ((ad_revise * voltage) / 652);
voltage_volts = ADCtoPower(voltage_rev);
@@ -190,9 +194,11 @@ int collie_read_temp(void)
/* temp must be > 973, main battery must be < 465 */
/* FIXME sharpsl_pm.c has both conditions negated? */

+ ucb1x00_adc_enable(ucb);
ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_TMP_ON, 0);
voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD0, UCB_SYNC);
ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_TMP_ON);
+ ucb1x00_adc_disable(ucb);

/* >1010 = battery removed.
460 = 22C ?

--
Picture of sleeping (Linux) penguin wanted...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/