From 2d46b9c984d1c862f2525b4d0cabcb092f77ac64 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Mon, 30 Jun 2008 16:28:17 +0300 Subject: [PATCH] CBUS: A workaround for ADC S/H HW bug: always keep ch 8 selected when S/H is used Signed-off-by: Mikko Ylinen Signed-off-by: Tony Lindgren --- drivers/cbus/retu.c | 12 ++++++++++++ drivers/cbus/retu.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c index 417273a67a4..ebb86b363de 100644 --- a/drivers/cbus/retu.c +++ b/drivers/cbus/retu.c @@ -114,9 +114,21 @@ int retu_read_adc(int channel) return -EINVAL; spin_lock_irqsave(&retu_lock, flags); + + if ((channel == 8) && retu_is_vilma) { + int scr = retu_read_reg(RETU_REG_ADCSCR); + int ch = (retu_read_reg(RETU_REG_ADCR) >> 10) & 0xf; + if (((scr & 0xff) != 0) && (ch != 8)) + retu_write_reg (RETU_REG_ADCSCR, (scr & ~0xff)); + } + /* Select the channel and read result */ retu_write_reg(RETU_REG_ADCR, channel << 10); res = retu_read_reg(RETU_REG_ADCR) & 0x3ff; + + if (retu_is_vilma) + retu_write_reg(RETU_REG_ADCR, (1 << 13)); + /* Unlock retu */ spin_unlock_irqrestore(&retu_lock, flags); diff --git a/drivers/cbus/retu.h b/drivers/cbus/retu.h index 49f23e664dc..c9e044c1494 100644 --- a/drivers/cbus/retu.h +++ b/drivers/cbus/retu.h @@ -34,6 +34,7 @@ #define RETU_REG_RTCHMAR 0x05 /* RTC hours and minutes alarm and time set register */ #define RETU_REG_RTCCALR 0x06 /* RTC calibration register */ #define RETU_REG_ADCR 0x08 /* ADC result */ +#define RETU_REG_ADCSCR 0x09 /* ADC sample ctrl */ #define RETU_REG_CC1 0x0d /* Common control register 1 */ #define RETU_REG_CC2 0x0e /* Common control register 2 */ #define RETU_REG_CTRL_CLR 0x0f /* Regulator clear register */ -- 2.41.1