linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: axp288: Override TS pin bias current for some models
@ 2019-09-15 18:53 Hans de Goede
  2019-10-05 10:02 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2019-09-15 18:53 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hans de Goede, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Chen-Yu Tsai, linux-iio, stable

Since commit 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling") we
preserve the bias current set by the firmware at boot.  This fixes issues
we were seeing on various models, but it seems our old hardcoded 80ųA bias
current was working around a firmware bug on at least one model laptop.

In order to both have our cake and eat it, this commit adds a dmi based
list of models where we need to override the firmware set bias current and
adds the one model we now know needs this to it: The Lenovo Ideapad 100S
(11 inch version).

Cc: stable@vger.kernel.org
Fixes: 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=203829
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/adc/axp288_adc.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 31d51bcc5f2c..85d08e68b34f 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -7,6 +7,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include <linux/dmi.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -25,6 +26,11 @@
 #define AXP288_ADC_EN_MASK				0xF0
 #define AXP288_ADC_TS_ENABLE				0x01
 
+#define AXP288_ADC_TS_BIAS_MASK				GENMASK(5, 4)
+#define AXP288_ADC_TS_BIAS_20UA				(0 << 4)
+#define AXP288_ADC_TS_BIAS_40UA				(1 << 4)
+#define AXP288_ADC_TS_BIAS_60UA				(2 << 4)
+#define AXP288_ADC_TS_BIAS_80UA				(3 << 4)
 #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK		GENMASK(1, 0)
 #define AXP288_ADC_TS_CURRENT_OFF			(0 << 0)
 #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING		(1 << 0)
@@ -177,10 +183,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
 	return ret;
 }
 
+/*
+ * We rely on the machine's firmware to correctly setup the TS pin bias current
+ * at boot. This lists systems with broken fw where we need to set it ourselves.
+ */
+static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
+	{
+		/* Lenovo Ideapad 100S (11 inch) */
+		.matches = {
+		  DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+		  DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"),
+		},
+		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
+	},
+	{}
+};
+
 static int axp288_adc_initialize(struct axp288_adc_info *info)
 {
+	const struct dmi_system_id *bias_override;
 	int ret, adc_enable_val;
 
+	bias_override = dmi_first_match(axp288_adc_ts_bias_override);
+	if (bias_override) {
+		ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL,
+					 AXP288_ADC_TS_BIAS_MASK,
+					 (uintptr_t)bias_override->driver_data);
+		if (ret)
+			return ret;
+	}
+
 	/*
 	 * Determine if the TS pin is enabled and set the TS current-source
 	 * accordingly.
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: adc: axp288: Override TS pin bias current for some models
  2019-09-15 18:53 [PATCH] iio: adc: axp288: Override TS pin bias current for some models Hans de Goede
@ 2019-10-05 10:02 ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2019-10-05 10:02 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Chen-Yu Tsai, linux-iio, stable

On Sun, 15 Sep 2019 20:53:42 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> Since commit 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling") we
> preserve the bias current set by the firmware at boot.  This fixes issues
> we were seeing on various models, but it seems our old hardcoded 80ųA bias
> current was working around a firmware bug on at least one model laptop.
> 
> In order to both have our cake and eat it, this commit adds a dmi based
> list of models where we need to override the firmware set bias current and
> adds the one model we now know needs this to it: The Lenovo Ideapad 100S
> (11 inch version).

Ouch.

> 
> Cc: stable@vger.kernel.org
> Fixes: 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling")
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=203829
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/axp288_adc.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
> index 31d51bcc5f2c..85d08e68b34f 100644
> --- a/drivers/iio/adc/axp288_adc.c
> +++ b/drivers/iio/adc/axp288_adc.c
> @@ -7,6 +7,7 @@
>   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   */
>  
> +#include <linux/dmi.h>
>  #include <linux/module.h>
>  #include <linux/kernel.h>
>  #include <linux/device.h>
> @@ -25,6 +26,11 @@
>  #define AXP288_ADC_EN_MASK				0xF0
>  #define AXP288_ADC_TS_ENABLE				0x01
>  
> +#define AXP288_ADC_TS_BIAS_MASK				GENMASK(5, 4)
> +#define AXP288_ADC_TS_BIAS_20UA				(0 << 4)
> +#define AXP288_ADC_TS_BIAS_40UA				(1 << 4)
> +#define AXP288_ADC_TS_BIAS_60UA				(2 << 4)
> +#define AXP288_ADC_TS_BIAS_80UA				(3 << 4)
>  #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK		GENMASK(1, 0)
>  #define AXP288_ADC_TS_CURRENT_OFF			(0 << 0)
>  #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING		(1 << 0)
> @@ -177,10 +183,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> +/*
> + * We rely on the machine's firmware to correctly setup the TS pin bias current
> + * at boot. This lists systems with broken fw where we need to set it ourselves.
> + */
> +static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
> +	{
> +		/* Lenovo Ideapad 100S (11 inch) */
> +		.matches = {
> +		  DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
> +		  DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"),
> +		},
> +		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
> +	},
> +	{}
> +};
> +
>  static int axp288_adc_initialize(struct axp288_adc_info *info)
>  {
> +	const struct dmi_system_id *bias_override;
>  	int ret, adc_enable_val;
>  
> +	bias_override = dmi_first_match(axp288_adc_ts_bias_override);
> +	if (bias_override) {
> +		ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL,
> +					 AXP288_ADC_TS_BIAS_MASK,
> +					 (uintptr_t)bias_override->driver_data);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	/*
>  	 * Determine if the TS pin is enabled and set the TS current-source
>  	 * accordingly.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: adc: axp288: Override TS pin bias current for some models
  2022-05-06  9:50 Hans de Goede
@ 2022-05-07 14:22 ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-05-07 14:22 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Lars-Peter Clausen, linux-iio

On Fri,  6 May 2022 11:50:40 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> Since commit 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling") we
> preserve the bias current set by the firmware at boot. This fixes issues
> we were seeing on various models.
> 
> Some models like the Nuvision Solo 10 Draw tablet actually need the
> old hardcoded 80ųA bias current for battery temperature monitoring
> to work properly.
> 
> Add a quirk entry for the Nuvision Solo 10 Draw to the DMI quirk table
> to restore setting the bias current to 80ųA on this model.
> 
> Fixes: 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling")
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215882
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/axp288_adc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
> index a4b8be5b8f88..580361bd9849 100644
> --- a/drivers/iio/adc/axp288_adc.c
> +++ b/drivers/iio/adc/axp288_adc.c
> @@ -196,6 +196,14 @@ static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
>  		},
>  		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
>  	},
> +	{
> +		/* Nuvision Solo 10 Draw */
> +		.matches = {
> +		  DMI_MATCH(DMI_SYS_VENDOR, "TMAX"),
> +		  DMI_MATCH(DMI_PRODUCT_NAME, "TM101W610L"),
> +		},
> +		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
> +	},
>  	{}
>  };
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] iio: adc: axp288: Override TS pin bias current for some models
@ 2022-05-06  9:50 Hans de Goede
  2022-05-07 14:22 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2022-05-06  9:50 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Hans de Goede, Lars-Peter Clausen, linux-iio

Since commit 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling") we
preserve the bias current set by the firmware at boot. This fixes issues
we were seeing on various models.

Some models like the Nuvision Solo 10 Draw tablet actually need the
old hardcoded 80ųA bias current for battery temperature monitoring
to work properly.

Add a quirk entry for the Nuvision Solo 10 Draw to the DMI quirk table
to restore setting the bias current to 80ųA on this model.

Fixes: 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215882
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/adc/axp288_adc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index a4b8be5b8f88..580361bd9849 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -196,6 +196,14 @@ static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
 		},
 		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
 	},
+	{
+		/* Nuvision Solo 10 Draw */
+		.matches = {
+		  DMI_MATCH(DMI_SYS_VENDOR, "TMAX"),
+		  DMI_MATCH(DMI_PRODUCT_NAME, "TM101W610L"),
+		},
+		.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
+	},
 	{}
 };
 
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-07 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-15 18:53 [PATCH] iio: adc: axp288: Override TS pin bias current for some models Hans de Goede
2019-10-05 10:02 ` Jonathan Cameron
2022-05-06  9:50 Hans de Goede
2022-05-07 14:22 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).