Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1966481ima; Thu, 25 Oct 2018 07:41:32 -0700 (PDT) X-Google-Smtp-Source: AJdET5e2zxfVRgt4tVia1DvYH3nZnMAxv/APpxjyve6lO0YTmeRUpgbeV8HIIYvbWaD9u3nBQSGP X-Received: by 2002:aa7:814f:: with SMTP id d15-v6mr1859912pfn.78.1540478492891; Thu, 25 Oct 2018 07:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478492; cv=none; d=google.com; s=arc-20160816; b=FTp2xRr7/BzG6bf8ZpgdbGiB4Tk+hwc7yb/obrwRda4hb2bJ25O837smTJlMP7DPvL M1POE7hYAK/IiN5Z0XyVd8Qy1G+/d9h2StnyaNBdi2PBUmmdmC2Ya9zXIiq48epqVWlt vIKq9cn+P7SPfIBBORuvUtdOz3e4aYhK4m7gape3JczRydUuqe3Gdkijfuq7ovSs2GAH vi2y8CfzchTHUhpeqjdgNznAHN2c1CwUPA5UXheG7G7RzYFaKekEyd9bPApATZ+axwKF KjRTZAEmv1HqhB2LBdS4mRPkqT8KINSjsk/5E/PT50NT9dC3XxsfifkuRCejv3OdW8DC 52+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PwdKgq8zhmcZojPdF/Q2oKRlOeUEuyQUJ8dPGruLRo8=; b=kXPPVywk4ZxFnb7ebHS84VawimK8vXDOHQbhjGXe85a6IIsiwigcdnLdyODp5kCO8Z IX8b+VLT05AIlI6amsy11GbAt/9bnLSJg6ZeEggIvuw17cGOj5WDTV0I5WvIvZtd+iOg TVt+W1g61T/1EEiuu4C+c6lpx84wCl17SXIZH8Pa7/MqLbJeFKamDAaqMnjTcg8A669n ogvokncTAvd8ZN/keVGe7GmMAtD0fwQaex54LIS9f9s4/wsu6b2ElwZl8/OIR4WG827Q TTnNkfKcntZnBvIBEw/ZxxqctpbQE8gVq1fFLCqHjq6mVfGJyd+gpMA1MOjxNMUIbTvg E8YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kOXkfNy5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33-v6si7954331pld.151.2018.10.25.07.41.16; Thu, 25 Oct 2018 07:41:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kOXkfNy5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729142AbeJYWsq (ORCPT + 99 others); Thu, 25 Oct 2018 18:48:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:57520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbeJYWsn (ORCPT ); Thu, 25 Oct 2018 18:48:43 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB6C52085B; Thu, 25 Oct 2018 14:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476946; bh=I2qOR67k4oYVOLRtXMXNqI+Gj5Jz3wU5UJ5s2gl2uss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kOXkfNy5F+kOgYRmCEwxz0RHaqPu3YwiJjnV0Aa5iMlo3rayf+Ll4jxuGqBnEH2s/ r7dW3WskrJ5SjT6/2xcw704BmcdUR5agmiaCpfJ2OsFhItQeFVTRcLNAMaoh1nZLcC jhlumbHMxByFDVxy3Q0t/ARPinzg0tLOKkT8l03Y= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans de Goede , Jonathan Cameron , Sasha Levin Subject: [PATCH AUTOSEL 4.9 56/98] iio: adc: Revert "axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications" Date: Thu, 25 Oct 2018 10:13:41 -0400 Message-Id: <20181025141423.213774-56-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit 631b010abc5b57009c6a8328f51492665f6ef310 ] Inheriting the ADC BIAS current settings from the BIOS instead of hardcoding then causes the AXP288 to disable charging (I think it mis-detects an overheated battery) on at least one model tablet. So lets go back to hard coding the values, this reverts commit fa2849e9649b ("iio: adc: axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications"), fixing charging not working on the model tablet in question. The exact cause is not fully understood, hence the revert to a known working state. Cc: stable@vger.kernel.org Reported-by: Umberto Ixxo Signed-off-by: Hans de Goede Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/axp288_adc.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 64799ad7ebad..7fd24949c0c1 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -28,6 +28,8 @@ #include #define AXP288_ADC_EN_MASK 0xF1 +#define AXP288_ADC_TS_PIN_GPADC 0xF2 +#define AXP288_ADC_TS_PIN_ON 0xF3 enum axp288_adc_id { AXP288_ADC_TS, @@ -121,6 +123,16 @@ static int axp288_adc_read_channel(int *val, unsigned long address, return IIO_VAL_INT; } +static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode, + unsigned long address) +{ + /* channels other than GPADC do not need to switch TS pin */ + if (address != AXP288_GP_ADC_H) + return 0; + + return regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode); +} + static int axp288_adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -131,7 +143,16 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, mutex_lock(&indio_dev->mlock); switch (mask) { case IIO_CHAN_INFO_RAW: + if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC, + chan->address)) { + dev_err(&indio_dev->dev, "GPADC mode\n"); + ret = -EINVAL; + break; + } ret = axp288_adc_read_channel(val, chan->address, info->regmap); + if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON, + chan->address)) + dev_err(&indio_dev->dev, "TS pin restore\n"); break; default: ret = -EINVAL; @@ -141,6 +162,15 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, return ret; } +static int axp288_adc_set_state(struct regmap *regmap) +{ + /* ADC should be always enabled for internal FG to function */ + if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON)) + return -EIO; + + return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK); +} + static const struct iio_info axp288_adc_iio_info = { .read_raw = &axp288_adc_read_raw, .driver_module = THIS_MODULE, @@ -169,7 +199,7 @@ static int axp288_adc_probe(struct platform_device *pdev) * Set ADC to enabled state at all time, including system suspend. * otherwise internal fuel gauge functionality may be affected. */ - ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK); + ret = axp288_adc_set_state(axp20x->regmap); if (ret) { dev_err(&pdev->dev, "unable to enable ADC device\n"); return ret; -- 2.17.1