platform/x86: int3472: discrete: Fix getting active_value
PATCH 1/2 platform/x86: int3472: discrete: Fix getting active_value
acpi_object.integer.value is 64 bit, so to get bits 31-24 the value not only needs to be shifted but also masked.
--- drivers/platform/x86/intel/int3472/discrete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel/int3472/discrete.c +1 -1
@@ -179,7 +179,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,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 = (obj->integer.value >>24 ) &0xff ;if (!active_value) polarity ^=GPIO_ACTIVE_LOW ;
Signature · 1 line
2.40.1
Quoted 3 lines · Hans de Goede
acpi_object.integer.value is 64 bit, so to get bits 31-24 the value not only needs to be shifted but also masked.
Why? The type of active_value is u8. How does this make any difference?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Hans de Goede
acpi_object.integer.value is 64 bit, so to get bits 31-24 the value not only needs to be shifted but also masked.
Why? The type of
active_valueis u8. How does this make any difference?
Ah right I forgot about that, I'll drop this patch and drop the & 0xff for the second patch.
Regards,
Hans
PATCH 2/2 platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
In reply to Hans de GoedeThe 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.
--- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/int3472/discrete.c +9 -1
@@ -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)
Signature · 1 line
2.40.1
Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
Hi Hans
Quoted 8 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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 <[email protected]>
That seems like a good idea to me:
Quoted 37 lines
--- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +9
-1@@ -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)
Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
Hi,
Quoted 10 lines · Dan Scally
Hi Hans
Quoted 7 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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.
Quoted 7 lines
Quoted 1 line
Signed-off-by Hans de Goede <[email protected]>That seems like a good idea to me:
Reviewed-by Daniel Scally <[email protected]>
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
Quoted 36 lines
Quoted 35 lines
---
drivers/platform/x86/intel/int3472/discrete.c| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +1
-1@@ -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_DSMentry are all 0 then the signal is inverted */active_value= (obj->integer.value>> 24) &0xff;
if (!active_value)
Dan Scally
maintainerRe: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
Hi Hans
Quoted 19 lines · Hans de Goede
Hi,
Quoted 10 lines · Dan Scally
Hi Hans
Quoted 7 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Hans de Goede <[email protected]>That seems like a good idea to me:
Reviewed-by Daniel Scally <[email protected]>
Quoted 8 lines
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.
Quoted 40 lines
Regards,
Hans
Quoted 34 lines
Quoted 34 lines
--- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +7
-1@@ -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)
Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
Hi,
Quoted 25 lines · Dan Scally
Hi Hans
Quoted 22 lines · Hans de Goede
Hi,
Quoted 10 lines · Dan Scally
Hi Hans
Quoted 7 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Hans de Goede <[email protected]>That seems like a good idea to me:
Reviewed-by Daniel Scally <[email protected]>Thanks. Did you also see my:
"[PATCH 0/4] platform/x86: int3472: discrete: Regulator rework / Lenovo Miix 510 support"
Quoted 8 lines
Quoted 5 lines
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
Quoted 35 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
---
drivers/platform/x86/intel/int3472/discrete.c| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +1
-1@@ -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_DSMentry are all 0 then the signal is inverted */active_value= (obj->integer.value>> 24) &0xff;
if (!active_value)
Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
In reply to Hans de GoedeQuoted 7 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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.
...
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 183
Quoted 4 lines
drivers/platform/x86/intel/int3472/discrete.c +3
-0+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.
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 185
Quoted 2 lines
drivers/platform/x86/intel/int3472/discrete.c +2
-0+if (pin != agpio->pin_table[0 ]) + dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
%u
%u
Quoted 2 lines
drivers/platform/x86/intel/int3472/discrete.c +2
-0+ func, agpio->resource_source.string_ptr, pin, + agpio->pin_table[0]);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Ilpo Järvinen
maintainerRe: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
In reply to Hans de GoedeQuoted 36 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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 <[email protected]>--- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +2
-1@@ -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);
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 191
Quoted 10 lines
drivers/platform/x86/intel/int3472/discrete.c +7
-0+/* 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.
Signature · 1 line
i.
Re: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match
Hi,
Quoted 37 lines · Ilpo Järvinen
Quoted 35 lines · Hans de Goede
The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info
_DSMentries.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 <[email protected]>--- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/platform/x86/intel/int3472/discrete.c +2
-1@@ -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);
Quoted 15 lines
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 191
Quoted 11 lines
drivers/platform/x86/intel/int3472/discrete.c +7
-0+/* 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