All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value
@ 2023-06-13 11:08 Hans de Goede
  2023-06-13 11:08 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
  0 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2023-06-13 11:08 UTC (permalink / raw)
  To: Ilpo Järvinen, Andy Shevchenko, Dan Scally
  Cc: Hans de Goede, platform-driver-x86, linux-media

Add defines for the various fields encoded in the GPIO _DSM integer
return value and then use FIELD_GET() to get field values.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index fc839a73e411..a31964076883 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -2,6 +2,7 @@
 /* Author: Dan Scally <djrscally@gmail.com> */
 
 #include <linux/acpi.h>
+#include <linux/bitfield.h>
 #include <linux/device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
@@ -25,6 +26,10 @@ static const guid_t int3472_gpio_guid =
 	GUID_INIT(0x79234640, 0x9e10, 0x4fea,
 		  0xa5, 0xc1, 0xb5, 0xaa, 0x8b, 0x19, 0x75, 0x6f);
 
+#define INT3472_GPIO_DSM_TYPE				GENMASK(7, 0)
+#define INT3472_GPIO_DSM_PIN				GENMASK(15, 8)
+#define INT3472_GPIO_DSM_SENSOR_ON_VAL			GENMASK(31, 24)
+
 /*
  * 822ace8f-2814-4174-a56b-5f029fe079ee
  * This _DSM GUID returns a string from the sensor device, which acts as a
@@ -174,12 +179,11 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 		return 1;
 	}
 
-	type = obj->integer.value & 0xff;
+	type = FIELD_GET(INT3472_GPIO_DSM_TYPE, obj->integer.value);
 
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
-	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
-	active_value = obj->integer.value >> 24;
+	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
 	if (!active_value)
 		polarity ^= GPIO_ACTIVE_LOW;
 
-- 
2.40.1


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

* [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-13 11:08 [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value Hans de Goede
@ 2023-06-13 11:08 ` Hans de Goede
  2023-06-13 11:17   ` Ilpo Järvinen
  0 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2023-06-13 11:08 UTC (permalink / raw)
  To: Ilpo Järvinen, Andy Shevchenko, Dan Scally
  Cc: Hans de Goede, platform-driver-x86, linux-media

The INT3472 discrete code assumes that the ACPI GPIO resources are
in the same order as the pin-info _DSM entries.

The returned pin-info includes the pin-number in bits 15-8. Add a check
that this matches with the ACPI GPIO resource pin-number in case
the assumption is not true with some ACPI tables.

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index a31964076883..850f306214c7 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -154,8 +154,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 {
 	struct int3472_discrete_device *int3472 = data;
 	struct acpi_resource_gpio *agpio;
+	u8 active_value, pin, type;
 	union acpi_object *obj;
-	u8 active_value, type;
 	const char *err_msg;
 	const char *func;
 	u32 polarity;
@@ -183,6 +183,12 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
+	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
+	if (pin != agpio->pin_table[0])
+		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
+			 func, agpio->resource_source.string_ptr, pin,
+			 agpio->pin_table[0]);
+
 	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
 	if (!active_value)
 		polarity ^= GPIO_ACTIVE_LOW;
-- 
2.40.1


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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-13 11:08 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
@ 2023-06-13 11:17   ` Ilpo Järvinen
  2023-06-15 12:38     ` Hans de Goede
  0 siblings, 1 reply; 12+ messages in thread
From: Ilpo Järvinen @ 2023-06-13 11:17 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Dan Scally, platform-driver-x86, linux-media

[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]

On Tue, 13 Jun 2023, Hans de Goede wrote:

> The INT3472 discrete code assumes that the ACPI GPIO resources are
> in the same order as the pin-info _DSM entries.
> 
> The returned pin-info includes the pin-number in bits 15-8. Add a check
> that this matches with the ACPI GPIO resource pin-number in case
> the assumption is not true with some ACPI tables.
> 
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
> index a31964076883..850f306214c7 100644
> --- a/drivers/platform/x86/intel/int3472/discrete.c
> +++ b/drivers/platform/x86/intel/int3472/discrete.c
> @@ -154,8 +154,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  {
>  	struct int3472_discrete_device *int3472 = data;
>  	struct acpi_resource_gpio *agpio;
> +	u8 active_value, pin, type;
>  	union acpi_object *obj;
> -	u8 active_value, type;
>  	const char *err_msg;
>  	const char *func;
>  	u32 polarity;
> @@ -183,6 +183,12 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  
>  	int3472_get_func_and_polarity(type, &func, &polarity);
>  
> +	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
> +	if (pin != agpio->pin_table[0])
> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
> +			 func, agpio->resource_source.string_ptr, pin,
> +			 agpio->pin_table[0]);
> +
>  	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
>  	if (!active_value)
>  		polarity ^= GPIO_ACTIVE_LOW;

For both 1 and 2,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


--
 i.

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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-13 11:17   ` Ilpo Järvinen
@ 2023-06-15 12:38     ` Hans de Goede
  0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2023-06-15 12:38 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Andy Shevchenko, Dan Scally, platform-driver-x86, linux-media

Hi,

On 6/13/23 13:17, Ilpo Järvinen wrote:
> On Tue, 13 Jun 2023, Hans de Goede wrote:
> 
>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>> in the same order as the pin-info _DSM entries.
>>
>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>> that this matches with the ACPI GPIO resource pin-number in case
>> the assumption is not true with some ACPI tables.
>>
>> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>> index a31964076883..850f306214c7 100644
>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>> @@ -154,8 +154,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  {
>>  	struct int3472_discrete_device *int3472 = data;
>>  	struct acpi_resource_gpio *agpio;
>> +	u8 active_value, pin, type;
>>  	union acpi_object *obj;
>> -	u8 active_value, type;
>>  	const char *err_msg;
>>  	const char *func;
>>  	u32 polarity;
>> @@ -183,6 +183,12 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  
>>  	int3472_get_func_and_polarity(type, &func, &polarity);
>>  
>> +	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
>> +	if (pin != agpio->pin_table[0])
>> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>> +			 func, agpio->resource_source.string_ptr, pin,
>> +			 agpio->pin_table[0]);
>> +
>>  	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
>>  	if (!active_value)
>>  		polarity ^= GPIO_ACTIVE_LOW;
> 
> For both 1 and 2,
> 
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Thank you.

I've added this to my review-hans (soon to be for-next) branch now.

Regards,

Hans




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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-13  8:10   ` Ilpo Järvinen
@ 2023-06-13 11:02     ` Hans de Goede
  0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2023-06-13 11:02 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Andy Shevchenko, Dan Scally, platform-driver-x86, linux-media

Hi,

On 6/13/23 10:10, Ilpo Järvinen wrote:
> On Mon, 12 Jun 2023, Hans de Goede wrote:
> 
>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>> in the same order as the pin-info _DSM entries.
>>
>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>> that this matches with the ACPI GPIO resource pin-number in case
>> the assumption is not true with some ACPI tables.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>> index 4ef60883154d..c1132bbbff41 100644
>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  {
>>  	struct int3472_discrete_device *int3472 = data;
>>  	struct acpi_resource_gpio *agpio;
>> +	u8 active_value, pin, type;
>>  	union acpi_object *obj;
>> -	u8 active_value, type;
>>  	const char *err_msg;
>>  	const char *func;
>>  	u32 polarity;
>> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  		return 1;
>>  	}
>>  
>> +	/* Bits 7-0 contain the type/function of the pin */
>>  	type = obj->integer.value & 0xff;
>>  
>>  	int3472_get_func_and_polarity(type, &func, &polarity);
>>  
>> +	/* Bits 15-8 contain the pin-number on the GPIO chip */
>> +	pin = (obj->integer.value >> 8) & 0xff;
>> +	if (pin != agpio->pin_table[0])
>> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>> +			 func, agpio->resource_source.string_ptr, pin,
>> +			 agpio->pin_table[0]);
>> +
>>  	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>>  	active_value = (obj->integer.value >> 24) & 0xff;
>>  	if (!active_value)
>>
> 
> These changes made me wonder why there aren't defines for the fields? 
> And then FIELD_GET() used to read the field. Most of those comments 
> would be documented by the define name itself.

That is a good idea for v2 I'll add a new 1/2 adding defines + switching
the existing cases to FIELD_GET() and I'll also switch to FIELD_GET()
here for v2.

Regards,

Hans





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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
  2023-06-12 14:20   ` Andy Shevchenko
  2023-06-12 14:20   ` Dan Scally
@ 2023-06-13  8:10   ` Ilpo Järvinen
  2023-06-13 11:02     ` Hans de Goede
  2 siblings, 1 reply; 12+ messages in thread
From: Ilpo Järvinen @ 2023-06-13  8:10 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Dan Scally, platform-driver-x86, linux-media

On Mon, 12 Jun 2023, Hans de Goede wrote:

> The INT3472 discrete code assumes that the ACPI GPIO resources are
> in the same order as the pin-info _DSM entries.
> 
> The returned pin-info includes the pin-number in bits 15-8. Add a check
> that this matches with the ACPI GPIO resource pin-number in case
> the assumption is not true with some ACPI tables.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
> index 4ef60883154d..c1132bbbff41 100644
> --- a/drivers/platform/x86/intel/int3472/discrete.c
> +++ b/drivers/platform/x86/intel/int3472/discrete.c
> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  {
>  	struct int3472_discrete_device *int3472 = data;
>  	struct acpi_resource_gpio *agpio;
> +	u8 active_value, pin, type;
>  	union acpi_object *obj;
> -	u8 active_value, type;
>  	const char *err_msg;
>  	const char *func;
>  	u32 polarity;
> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  		return 1;
>  	}
>  
> +	/* Bits 7-0 contain the type/function of the pin */
>  	type = obj->integer.value & 0xff;
>  
>  	int3472_get_func_and_polarity(type, &func, &polarity);
>  
> +	/* Bits 15-8 contain the pin-number on the GPIO chip */
> +	pin = (obj->integer.value >> 8) & 0xff;
> +	if (pin != agpio->pin_table[0])
> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
> +			 func, agpio->resource_source.string_ptr, pin,
> +			 agpio->pin_table[0]);
> +
>  	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>  	active_value = (obj->integer.value >> 24) & 0xff;
>  	if (!active_value)
> 

These changes made me wonder why there aren't defines for the fields? 
And then FIELD_GET() used to read the field. Most of those comments 
would be documented by the define name itself.

-- 
 i.


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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 15:30       ` Dan Scally
@ 2023-06-12 15:36         ` Hans de Goede
  0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2023-06-12 15:36 UTC (permalink / raw)
  To: Dan Scally, Andy Shevchenko, Ilpo Järvinen
  Cc: platform-driver-x86, linux-media

Hi,

On 6/12/23 17:30, Dan Scally wrote:
> Hi Hans
> 
> On 12/06/2023 16:26, Hans de Goede wrote:
>> Hi,
>>
>> On 6/12/23 16:20, Dan Scally wrote:
>>> Hi Hans
>>>
>>> On 12/06/2023 15:16, Hans de Goede wrote:
>>>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>>>> in the same order as the pin-info _DSM entries.
>>>>
>>>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>>>> that this matches with the ACPI GPIO resource pin-number in case
>>>> the assumption is not true with some ACPI tables.
>>>>
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>
>>> That seems like a good idea to me:
>>>
>>>
>>> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
>> Thanks. Did you also see my:
>> "[PATCH 0/4] platform/x86: int3472: discrete: Regulator rework / Lenovo Miix 510 support"
>>
>> series ? It would be great if I can get your input on that.
>>
>> Personally I'm not entirely happy with patch 3/4 there,
>> but I don't really see any other way of solving
>> the issue on the mix 510 that 3/4 fixes.
> 
> 
> I did; I was hoping to go through the ov2680 set and that set today but I've been a bit busy; I'll try to look at and test both asap.

Ok, thank you.

Note the ov2680 set does not work with the IPU3 yet. I've tried with
the ipu3-capture.sh script after first testing the script with
the ov5693 and my current ov2680 set is missing the link-rate /
pixel-rate v4l2 ctrls.

I plan to continue working on this, adding those ctrls tomorrow.

Regards,

Hans






>>>> ---
>>>>    drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>>>>    1 file changed, 9 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>>>> index 4ef60883154d..c1132bbbff41 100644
>>>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>>>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>>>> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>>>    {
>>>>        struct int3472_discrete_device *int3472 = data;
>>>>        struct acpi_resource_gpio *agpio;
>>>> +    u8 active_value, pin, type;
>>>>        union acpi_object *obj;
>>>> -    u8 active_value, type;
>>>>        const char *err_msg;
>>>>        const char *func;
>>>>        u32 polarity;
>>>> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>>>            return 1;
>>>>        }
>>>>    +    /* Bits 7-0 contain the type/function of the pin */
>>>>        type = obj->integer.value & 0xff;
>>>>          int3472_get_func_and_polarity(type, &func, &polarity);
>>>>    +    /* Bits 15-8 contain the pin-number on the GPIO chip */
>>>> +    pin = (obj->integer.value >> 8) & 0xff;
>>>> +    if (pin != agpio->pin_table[0])
>>>> +        dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>>>> +             func, agpio->resource_source.string_ptr, pin,
>>>> +             agpio->pin_table[0]);
>>>> +
>>>>        /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>>>>        active_value = (obj->integer.value >> 24) & 0xff;
>>>>        if (!active_value)
> 


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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 15:26     ` Hans de Goede
@ 2023-06-12 15:30       ` Dan Scally
  2023-06-12 15:36         ` Hans de Goede
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Scally @ 2023-06-12 15:30 UTC (permalink / raw)
  To: Hans de Goede, Andy Shevchenko, Ilpo Järvinen
  Cc: platform-driver-x86, linux-media

Hi Hans

On 12/06/2023 16:26, Hans de Goede wrote:
> Hi,
>
> On 6/12/23 16:20, Dan Scally wrote:
>> Hi Hans
>>
>> On 12/06/2023 15:16, Hans de Goede wrote:
>>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>>> in the same order as the pin-info _DSM entries.
>>>
>>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>>> that this matches with the ACPI GPIO resource pin-number in case
>>> the assumption is not true with some ACPI tables.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>
>> That seems like a good idea to me:
>>
>>
>> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Thanks. Did you also see my:
> "[PATCH 0/4] platform/x86: int3472: discrete: Regulator rework / Lenovo Miix 510 support"
>
> series ? It would be great if I can get your input on that.
>
> Personally I'm not entirely happy with patch 3/4 there,
> but I don't really see any other way of solving
> the issue on the mix 510 that 3/4 fixes.


I did; I was hoping to go through the ov2680 set and that set today but I've been a bit busy; I'll 
try to look at and test both asap.

>
> Regards,
>
> Hans
>
>
>>> ---
>>>    drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>>>    1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>>> index 4ef60883154d..c1132bbbff41 100644
>>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>>> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>>    {
>>>        struct int3472_discrete_device *int3472 = data;
>>>        struct acpi_resource_gpio *agpio;
>>> +    u8 active_value, pin, type;
>>>        union acpi_object *obj;
>>> -    u8 active_value, type;
>>>        const char *err_msg;
>>>        const char *func;
>>>        u32 polarity;
>>> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>>            return 1;
>>>        }
>>>    +    /* Bits 7-0 contain the type/function of the pin */
>>>        type = obj->integer.value & 0xff;
>>>          int3472_get_func_and_polarity(type, &func, &polarity);
>>>    +    /* Bits 15-8 contain the pin-number on the GPIO chip */
>>> +    pin = (obj->integer.value >> 8) & 0xff;
>>> +    if (pin != agpio->pin_table[0])
>>> +        dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>>> +             func, agpio->resource_source.string_ptr, pin,
>>> +             agpio->pin_table[0]);
>>> +
>>>        /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>>>        active_value = (obj->integer.value >> 24) & 0xff;
>>>        if (!active_value)

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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 14:20   ` Dan Scally
@ 2023-06-12 15:26     ` Hans de Goede
  2023-06-12 15:30       ` Dan Scally
  0 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2023-06-12 15:26 UTC (permalink / raw)
  To: Dan Scally, Andy Shevchenko, Ilpo Järvinen
  Cc: platform-driver-x86, linux-media

Hi,

On 6/12/23 16:20, Dan Scally wrote:
> Hi Hans
> 
> On 12/06/2023 15:16, Hans de Goede wrote:
>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>> in the same order as the pin-info _DSM entries.
>>
>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>> that this matches with the ACPI GPIO resource pin-number in case
>> the assumption is not true with some ACPI tables.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> 
> That seems like a good idea to me:
> 
> 
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

Thanks. Did you also see my:
"[PATCH 0/4] platform/x86: int3472: discrete: Regulator rework / Lenovo Miix 510 support"

series ? It would be great if I can get your input on that.

Personally I'm not entirely happy with patch 3/4 there,
but I don't really see any other way of solving
the issue on the mix 510 that 3/4 fixes.

Regards,

Hans


> 
>> ---
>>   drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>> index 4ef60883154d..c1132bbbff41 100644
>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>   {
>>       struct int3472_discrete_device *int3472 = data;
>>       struct acpi_resource_gpio *agpio;
>> +    u8 active_value, pin, type;
>>       union acpi_object *obj;
>> -    u8 active_value, type;
>>       const char *err_msg;
>>       const char *func;
>>       u32 polarity;
>> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>           return 1;
>>       }
>>   +    /* Bits 7-0 contain the type/function of the pin */
>>       type = obj->integer.value & 0xff;
>>         int3472_get_func_and_polarity(type, &func, &polarity);
>>   +    /* Bits 15-8 contain the pin-number on the GPIO chip */
>> +    pin = (obj->integer.value >> 8) & 0xff;
>> +    if (pin != agpio->pin_table[0])
>> +        dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>> +             func, agpio->resource_source.string_ptr, pin,
>> +             agpio->pin_table[0]);
>> +
>>       /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>>       active_value = (obj->integer.value >> 24) & 0xff;
>>       if (!active_value)
> 


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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
  2023-06-12 14:20   ` Andy Shevchenko
@ 2023-06-12 14:20   ` Dan Scally
  2023-06-12 15:26     ` Hans de Goede
  2023-06-13  8:10   ` Ilpo Järvinen
  2 siblings, 1 reply; 12+ messages in thread
From: Dan Scally @ 2023-06-12 14:20 UTC (permalink / raw)
  To: Hans de Goede, Andy Shevchenko, Ilpo Järvinen
  Cc: platform-driver-x86, linux-media

Hi Hans

On 12/06/2023 15:16, Hans de Goede wrote:
> The INT3472 discrete code assumes that the ACPI GPIO resources are
> in the same order as the pin-info _DSM entries.
>
> The returned pin-info includes the pin-number in bits 15-8. Add a check
> that this matches with the ACPI GPIO resource pin-number in case
> the assumption is not true with some ACPI tables.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>


That seems like a good idea to me:


Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

> ---
>   drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
> index 4ef60883154d..c1132bbbff41 100644
> --- a/drivers/platform/x86/intel/int3472/discrete.c
> +++ b/drivers/platform/x86/intel/int3472/discrete.c
> @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>   {
>   	struct int3472_discrete_device *int3472 = data;
>   	struct acpi_resource_gpio *agpio;
> +	u8 active_value, pin, type;
>   	union acpi_object *obj;
> -	u8 active_value, type;
>   	const char *err_msg;
>   	const char *func;
>   	u32 polarity;
> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>   		return 1;
>   	}
>   
> +	/* Bits 7-0 contain the type/function of the pin */
>   	type = obj->integer.value & 0xff;
>   
>   	int3472_get_func_and_polarity(type, &func, &polarity);
>   
> +	/* Bits 15-8 contain the pin-number on the GPIO chip */
> +	pin = (obj->integer.value >> 8) & 0xff;
> +	if (pin != agpio->pin_table[0])
> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
> +			 func, agpio->resource_source.string_ptr, pin,
> +			 agpio->pin_table[0]);
> +
>   	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>   	active_value = (obj->integer.value >> 24) & 0xff;
>   	if (!active_value)

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

* Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
@ 2023-06-12 14:20   ` Andy Shevchenko
  2023-06-12 14:20   ` Dan Scally
  2023-06-13  8:10   ` Ilpo Järvinen
  2 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2023-06-12 14:20 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Ilpo Järvinen, Dan Scally,
	platform-driver-x86, linux-media

On Mon, Jun 12, 2023 at 5:16 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> The INT3472 discrete code assumes that the ACPI GPIO resources are
> in the same order as the pin-info _DSM entries.
>
> The returned pin-info includes the pin-number in bits 15-8. Add a check
> that this matches with the ACPI GPIO resource pin-number in case
> the assumption is not true with some ACPI tables.

...

> +       u8 active_value, pin, type;

> +       /* Bits 15-8 contain the pin-number on the GPIO chip */
> +       pin = (obj->integer.value >> 8) & 0xff;

All the same here, as long as the pin is u8, the ' & 0xff' is no-op as
it's already implied.

> +       if (pin != agpio->pin_table[0])
> +               dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",

%u
%u

> +                        func, agpio->resource_source.string_ptr, pin,
> +                        agpio->pin_table[0]);


-- 
With Best Regards,
Andy Shevchenko

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

* [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
  2023-06-12 14:16 [PATCH 1/2] platform/x86: int3472: discrete: Fix getting active_value Hans de Goede
@ 2023-06-12 14:16 ` Hans de Goede
  2023-06-12 14:20   ` Andy Shevchenko
                     ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hans de Goede @ 2023-06-12 14:16 UTC (permalink / raw)
  To: Andy Shevchenko, Ilpo Järvinen, Dan Scally
  Cc: Hans de Goede, platform-driver-x86, linux-media

The INT3472 discrete code assumes that the ACPI GPIO resources are
in the same order as the pin-info _DSM entries.

The returned pin-info includes the pin-number in bits 15-8. Add a check
that this matches with the ACPI GPIO resource pin-number in case
the assumption is not true with some ACPI tables.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 4ef60883154d..c1132bbbff41 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 {
 	struct int3472_discrete_device *int3472 = data;
 	struct acpi_resource_gpio *agpio;
+	u8 active_value, pin, type;
 	union acpi_object *obj;
-	u8 active_value, type;
 	const char *err_msg;
 	const char *func;
 	u32 polarity;
@@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 		return 1;
 	}
 
+	/* Bits 7-0 contain the type/function of the pin */
 	type = obj->integer.value & 0xff;
 
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
+	/* Bits 15-8 contain the pin-number on the GPIO chip */
+	pin = (obj->integer.value >> 8) & 0xff;
+	if (pin != agpio->pin_table[0])
+		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
+			 func, agpio->resource_source.string_ptr, pin,
+			 agpio->pin_table[0]);
+
 	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
 	active_value = (obj->integer.value >> 24) & 0xff;
 	if (!active_value)
-- 
2.40.1


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

end of thread, other threads:[~2023-06-15 12:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 11:08 [PATCH 1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value Hans de Goede
2023-06-13 11:08 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
2023-06-13 11:17   ` Ilpo Järvinen
2023-06-15 12:38     ` Hans de Goede
  -- strict thread matches above, loose matches on Subject: below --
2023-06-12 14:16 [PATCH 1/2] platform/x86: int3472: discrete: Fix getting active_value Hans de Goede
2023-06-12 14:16 ` [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Hans de Goede
2023-06-12 14:20   ` Andy Shevchenko
2023-06-12 14:20   ` Dan Scally
2023-06-12 15:26     ` Hans de Goede
2023-06-12 15:30       ` Dan Scally
2023-06-12 15:36         ` Hans de Goede
2023-06-13  8:10   ` Ilpo Järvinen
2023-06-13 11:02     ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.