linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler
@ 2017-05-14 21:35 Hans de Goede
  2017-05-15  8:58 ` Andy Shevchenko
  2017-06-21 13:27 ` [v3] " Hans de Goede
  0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2017-05-14 21:35 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown
  Cc: Hans de Goede, Andy Shevchenko, Srinivas Pandruvada, linux-acpi

Some Bay Trail devices use a GPI1 regulator field (address 0x4c) in
their 0x8d power OpRegion, add support for this.

This fixes AE_BAD_PARAMETER errors getting thrown on these devices and
fixes these errors causing these devices to not suspend.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Simplify reg == 0x92 handling (suggested by Andy Shevchenko)
-Add special handling for reg == 0x92 to intel_xpower_pmic_get_power() too
Changes in v3:
-Use defines for GPI1 reg and bits, rather then hardcoded hex values
---
 drivers/acpi/pmic/intel_pmic_xpower.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
index 1a76c784cd4c..3b7d5be5b7ed 100644
--- a/drivers/acpi/pmic/intel_pmic_xpower.c
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -21,6 +21,11 @@
 #include "intel_pmic.h"
 
 #define XPOWER_GPADC_LOW	0x5b
+#define XPOWER_GPI1_CTRL	0x92
+
+#define GPI1_LDO_MASK		GENMASK(2, 0)
+#define GPI1_LDO_ON		(3 << 0)
+#define GPI1_LDO_OFF		(4 << 0)
 
 static struct pmic_table power_table[] = {
 	{
@@ -118,6 +123,10 @@ static struct pmic_table power_table[] = {
 		.reg = 0x10,
 		.bit = 0x00
 	}, /* BUC6 */
+	{
+		.address = 0x4c,
+		.reg = 0x92,
+	}, /* GPI1 */
 };
 
 /* TMP0 - TMP5 are the same, all from GPADC */
@@ -156,7 +165,12 @@ static int intel_xpower_pmic_get_power(struct regmap *regmap, int reg,
 	if (regmap_read(regmap, reg, &data))
 		return -EIO;
 
-	*value = (data & BIT(bit)) ? 1 : 0;
+	/* GPIO1 LDO regulator needs special handling */
+	if (reg == XPOWER_GPI1_CTRL)
+		*value = ((data & GPI1_LDO_MASK) == GPI1_LDO_ON);
+	else
+		*value = (data & BIT(bit)) ? 1 : 0;
+
 	return 0;
 }
 
@@ -165,6 +179,11 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
 {
 	int data;
 
+	/* GPIO1 LDO regulator needs special handling */
+	if (reg == XPOWER_GPI1_CTRL)
+		return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
+					  on ? GPI1_LDO_ON : GPI1_LDO_OFF);
+
 	if (regmap_read(regmap, reg, &data))
 		return -EIO;
 
-- 
2.12.2


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

* Re: [PATCH v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler
  2017-05-14 21:35 [PATCH v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler Hans de Goede
@ 2017-05-15  8:58 ` Andy Shevchenko
  2017-06-21 13:27 ` [v3] " Hans de Goede
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-05-15  8:58 UTC (permalink / raw)
  To: Hans de Goede, Rafael J . Wysocki, Len Brown
  Cc: Srinivas Pandruvada, linux-acpi

On Sun, 2017-05-14 at 23:35 +0200, Hans de Goede wrote:
> Some Bay Trail devices use a GPI1 regulator field (address 0x4c) in
> their 0x8d power OpRegion, add support for this.
> 
> This fixes AE_BAD_PARAMETER errors getting thrown on these devices and
> fixes these errors causing these devices to not suspend.

FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Simplify reg == 0x92 handling (suggested by Andy Shevchenko)
> -Add special handling for reg == 0x92 to intel_xpower_pmic_get_power()
> too
> Changes in v3:
> -Use defines for GPI1 reg and bits, rather then hardcoded hex values
> ---
>  drivers/acpi/pmic/intel_pmic_xpower.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c
> b/drivers/acpi/pmic/intel_pmic_xpower.c
> index 1a76c784cd4c..3b7d5be5b7ed 100644
> --- a/drivers/acpi/pmic/intel_pmic_xpower.c
> +++ b/drivers/acpi/pmic/intel_pmic_xpower.c
> @@ -21,6 +21,11 @@
>  #include "intel_pmic.h"
>  
>  #define XPOWER_GPADC_LOW	0x5b
> +#define XPOWER_GPI1_CTRL	0x92
> +
> +#define GPI1_LDO_MASK		GENMASK(2, 0)
> +#define GPI1_LDO_ON		(3 << 0)
> +#define GPI1_LDO_OFF		(4 << 0)
>  
>  static struct pmic_table power_table[] = {
>  	{
> @@ -118,6 +123,10 @@ static struct pmic_table power_table[] = {
>  		.reg = 0x10,
>  		.bit = 0x00
>  	}, /* BUC6 */
> +	{
> +		.address = 0x4c,
> +		.reg = 0x92,
> +	}, /* GPI1 */
>  };
>  
>  /* TMP0 - TMP5 are the same, all from GPADC */
> @@ -156,7 +165,12 @@ static int intel_xpower_pmic_get_power(struct
> regmap *regmap, int reg,
>  	if (regmap_read(regmap, reg, &data))
>  		return -EIO;
>  
> -	*value = (data & BIT(bit)) ? 1 : 0;
> +	/* GPIO1 LDO regulator needs special handling */
> +	if (reg == XPOWER_GPI1_CTRL)
> +		*value = ((data & GPI1_LDO_MASK) == GPI1_LDO_ON);
> +	else
> +		*value = (data & BIT(bit)) ? 1 : 0;
> +
>  	return 0;
>  }
>  
> @@ -165,6 +179,11 @@ static int intel_xpower_pmic_update_power(struct
> regmap *regmap, int reg,
>  {
>  	int data;
>  
> +	/* GPIO1 LDO regulator needs special handling */
> +	if (reg == XPOWER_GPI1_CTRL)
> +		return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
> +					  on ? GPI1_LDO_ON :
> GPI1_LDO_OFF);
> +
>  	if (regmap_read(regmap, reg, &data))
>  		return -EIO;
>  

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler
  2017-05-14 21:35 [PATCH v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler Hans de Goede
  2017-05-15  8:58 ` Andy Shevchenko
@ 2017-06-21 13:27 ` Hans de Goede
  2017-06-21 15:27   ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2017-06-21 13:27 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown
  Cc: Andy Shevchenko, Srinivas Pandruvada, linux-acpi

Hi,

On 14-05-17 23:35, Hans de Goede wrote:
> Some Bay Trail devices use a GPI1 regulator field (address 0x4c) in
> their 0x8d power OpRegion, add support for this.
> 
> This fixes AE_BAD_PARAMETER errors getting thrown on these devices and
> fixes these errors causing these devices to not suspend.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> Changes in v2:
> -Simplify reg == 0x92 handling (suggested by Andy Shevchenko)
> -Add special handling for reg == 0x92 to intel_xpower_pmic_get_power() too
> Changes in v3:
> -Use defines for GPI1 reg and bits, rather then hardcoded hex values

What is the status of this patch ? AFAICT this patch has not been
merged yet, even though it has a Reviewe-by.

Note this patch is necessary to fix suspend/resume on some devices,
as such it would be nic if we can get this merged soon.

Regards,

Hans



> ---
>   drivers/acpi/pmic/intel_pmic_xpower.c | 21 ++++++++++++++++++++-
>   1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
> index 1a76c784cd4c..3b7d5be5b7ed 100644
> --- a/drivers/acpi/pmic/intel_pmic_xpower.c
> +++ b/drivers/acpi/pmic/intel_pmic_xpower.c
> @@ -21,6 +21,11 @@
>   #include "intel_pmic.h"
>   
>   #define XPOWER_GPADC_LOW	0x5b
> +#define XPOWER_GPI1_CTRL	0x92
> +
> +#define GPI1_LDO_MASK		GENMASK(2, 0)
> +#define GPI1_LDO_ON		(3 << 0)
> +#define GPI1_LDO_OFF		(4 << 0)
>   
>   static struct pmic_table power_table[] = {
>   	{
> @@ -118,6 +123,10 @@ static struct pmic_table power_table[] = {
>   		.reg = 0x10,
>   		.bit = 0x00
>   	}, /* BUC6 */
> +	{
> +		.address = 0x4c,
> +		.reg = 0x92,
> +	}, /* GPI1 */
>   };
>   
>   /* TMP0 - TMP5 are the same, all from GPADC */
> @@ -156,7 +165,12 @@ static int intel_xpower_pmic_get_power(struct regmap *regmap, int reg,
>   	if (regmap_read(regmap, reg, &data))
>   		return -EIO;
>   
> -	*value = (data & BIT(bit)) ? 1 : 0;
> +	/* GPIO1 LDO regulator needs special handling */
> +	if (reg == XPOWER_GPI1_CTRL)
> +		*value = ((data & GPI1_LDO_MASK) == GPI1_LDO_ON);
> +	else
> +		*value = (data & BIT(bit)) ? 1 : 0;
> +
>   	return 0;
>   }
>   
> @@ -165,6 +179,11 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
>   {
>   	int data;
>   
> +	/* GPIO1 LDO regulator needs special handling */
> +	if (reg == XPOWER_GPI1_CTRL)
> +		return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
> +					  on ? GPI1_LDO_ON : GPI1_LDO_OFF);
> +
>   	if (regmap_read(regmap, reg, &data))
>   		return -EIO;
>   
> 

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

* Re: [v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler
  2017-06-21 13:27 ` [v3] " Hans de Goede
@ 2017-06-21 15:27   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2017-06-21 15:27 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Len Brown, Andy Shevchenko,
	Srinivas Pandruvada, ACPI Devel Maling List

On Wed, Jun 21, 2017 at 3:27 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 14-05-17 23:35, Hans de Goede wrote:
>>
>> Some Bay Trail devices use a GPI1 regulator field (address 0x4c) in
>> their 0x8d power OpRegion, add support for this.
>>
>> This fixes AE_BAD_PARAMETER errors getting thrown on these devices and
>> fixes these errors causing these devices to not suspend.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>> Changes in v2:
>> -Simplify reg == 0x92 handling (suggested by Andy Shevchenko)
>> -Add special handling for reg == 0x92 to intel_xpower_pmic_get_power() too
>> Changes in v3:
>> -Use defines for GPI1 reg and bits, rather then hardcoded hex values
>
>
> What is the status of this patch ? AFAICT this patch has not been
> merged yet, even though it has a Reviewe-by.
>
> Note this patch is necessary to fix suspend/resume on some devices,
> as such it would be nic if we can get this merged soon.

It will go into 4.13, sorry for the delay.

Thanks,
Rafael

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

end of thread, other threads:[~2017-06-21 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-14 21:35 [PATCH v3] ACPI / PMIC: xpower: Add support for the GPI1 regulator to the OpRegion handler Hans de Goede
2017-05-15  8:58 ` Andy Shevchenko
2017-06-21 13:27 ` [v3] " Hans de Goede
2017-06-21 15:27   ` Rafael J. Wysocki

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).