From patchwork Sat Mar 5 10:46:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 388 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:42:06 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs43947qah; Sat, 5 Mar 2011 02:49:00 -0800 (PST) Received: by 10.213.106.14 with SMTP id v14mr134377ebo.45.1299322139331; Sat, 05 Mar 2011 02:48:59 -0800 (PST) Received: from eu1sys200aog110.obsmtp.com (eu1sys200aog110.obsmtp.com [207.126.144.129]) by mx.google.com with SMTP id r3si743227eeh.99.2011.03.05.02.48.54 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Mar 2011 02:48:58 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.129 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.129; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.129 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob110.postini.com ([207.126.147.11]) with SMTP ID DSNKTXIVFnsjnE6GmQSV8EhwYFyPnCVUITAV@postini.com; Sat, 05 Mar 2011 10:48:58 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E64E35B5; Sat, 5 Mar 2011 10:47:18 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B79471CBE; Sat, 5 Mar 2011 10:47:18 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 72BF7A8065; Sat, 5 Mar 2011 11:46:44 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.2.254.0; Sat, 5 Mar 2011 11:46:48 +0100 From: Linus Walleij To: Samuel Ortiz , Cc: Lee Jones , Karl Komierowski , Linus Walleij Subject: [PATCH 5/5] mfd: fix ab8500-gpadc to measure charger current Date: Sat, 5 Mar 2011 11:46:45 +0100 Message-ID: <1299322005-6898-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Karl Komierowski The GPADC in the AB8500 was incorrectly configured when a charger current channel was selected. Signed-off-by: Karl Komierowski Signed-off-by: Linus Walleij --- drivers/mfd/ab8500-gpadc.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c index a70201a..2ad3115 100644 --- a/drivers/mfd/ab8500-gpadc.c +++ b/drivers/mfd/ab8500-gpadc.c @@ -56,6 +56,7 @@ #define DIS_GPADC 0x00 #define SW_AVG_16 0x60 #define ADC_SW_CONV 0x04 +#define EN_ICHAR 0x80 #define EN_BUF 0x40 #define DIS_ZERO 0x00 #define GPADC_BUSY 0x01 @@ -281,9 +282,23 @@ int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input) "gpadc_conversion: set avg samples failed\n"); goto out; } - /* Enable ADC, Buffering and select rising edge, start Conversion */ - ret = abx500_mask_and_set_register_interruptible(gpadc->dev, - AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF); + /* + * Enable ADC, buffering, select rising edge and enable ADC path + * charging current sense if it needed + */ + switch (input) { + case MAIN_CHARGER_C: + case USB_CHARGER_C: + ret = abx500_mask_and_set_register_interruptible(gpadc->dev, + AB8500_GPADC, AB8500_GPADC_CTRL1_REG, + EN_BUF | EN_ICHAR, + EN_BUF | EN_ICHAR); + break; + default: + ret = abx500_mask_and_set_register_interruptible(gpadc->dev, + AB8500_GPADC, AB8500_GPADC_CTRL1_REG, EN_BUF, EN_BUF); + break; + } if (ret < 0) { dev_err(gpadc->dev, "gpadc_conversion: select falling edge failed\n");