Skip to content

Commit 569617d

Browse files
Sakari Ailusij-intel
authored andcommitted
platform/x86: int3472: Call "reset" GPIO "enable" for INT347E
The DT bindings for ov7251 specify "enable" GPIO (xshutdown in documentation) but the int3472 indiscriminately provides this as a "reset" GPIO to sensor drivers. Take this into account by assigning it as "enable" with active high polarity for INT347E devices, i.e. ov7251. "reset" with active low polarity remains the default GPIO name for other devices. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250211072841.7713-3-sakari.ailus@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent fc22b06 commit 569617d

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

drivers/platform/x86/intel/int3472/discrete.c

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Author: Dan Scally <djrscally@gmail.com> */
33

44
#include <linux/acpi.h>
5+
#include <linux/array_size.h>
56
#include <linux/bitfield.h>
67
#include <linux/device.h>
78
#include <linux/gpio/consumer.h>
@@ -122,10 +123,53 @@ skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472,
122123
return desc;
123124
}
124125

125-
static void int3472_get_func_and_polarity(u8 type, const char **func,
126-
unsigned long *gpio_flags)
126+
/**
127+
* struct int3472_gpio_map - Map GPIOs to whatever is expected by the
128+
* sensor driver (as in DT bindings)
129+
* @hid: The ACPI HID of the device without the instance number e.g. INT347E
130+
* @type_from: The GPIO type from ACPI ?SDT
131+
* @type_to: The assigned GPIO type, typically same as @type_from
132+
* @func: The function, e.g. "enable"
133+
* @polarity_low: GPIO_ACTIVE_LOW true if the @polarity_low is true,
134+
* GPIO_ACTIVE_HIGH otherwise
135+
*/
136+
struct int3472_gpio_map {
137+
const char *hid;
138+
u8 type_from;
139+
u8 type_to;
140+
bool polarity_low;
141+
const char *func;
142+
};
143+
144+
static const struct int3472_gpio_map int3472_gpio_map[] = {
145+
{ "INT347E", INT3472_GPIO_TYPE_RESET, INT3472_GPIO_TYPE_RESET, false, "enable" },
146+
};
147+
148+
static void int3472_get_func_and_polarity(struct acpi_device *adev, u8 *type,
149+
const char **func, unsigned long *gpio_flags)
127150
{
128-
switch (type) {
151+
unsigned int i;
152+
153+
for (i = 0; i < ARRAY_SIZE(int3472_gpio_map); i++) {
154+
/*
155+
* Map the firmware-provided GPIO to whatever a driver expects
156+
* (as in DT bindings). First check if the type matches with the
157+
* GPIO map, then further check that the device _HID matches.
158+
*/
159+
if (*type != int3472_gpio_map[i].type_from)
160+
continue;
161+
162+
if (!acpi_dev_hid_uid_match(adev, int3472_gpio_map[i].hid, NULL))
163+
continue;
164+
165+
*type = int3472_gpio_map[i].type_to;
166+
*gpio_flags = int3472_gpio_map[i].polarity_low ?
167+
GPIO_ACTIVE_LOW : GPIO_ACTIVE_HIGH;
168+
*func = int3472_gpio_map[i].func;
169+
return;
170+
}
171+
172+
switch (*type) {
129173
case INT3472_GPIO_TYPE_RESET:
130174
*func = "reset";
131175
*gpio_flags = GPIO_ACTIVE_LOW;
@@ -218,7 +262,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
218262

219263
type = FIELD_GET(INT3472_GPIO_DSM_TYPE, obj->integer.value);
220264

221-
int3472_get_func_and_polarity(type, &func, &gpio_flags);
265+
int3472_get_func_and_polarity(int3472->sensor, &type, &func, &gpio_flags);
222266

223267
pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
224268
/* Pin field is not really used under Windows and wraps around at 8 bits */

0 commit comments

Comments
 (0)