Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions drivers/platform/x86/intel/int3472/discrete.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/platform_data/x86/int3472.h>
#include <linux/platform_device.h>
#include <linux/string_choices.h>
#include <linux/time64.h>
#include <linux/uuid.h>

/*
Expand Down Expand Up @@ -143,6 +144,16 @@ static const char * const power_enable_hids_enable[] = {
NULL
};

static const char * const power_enable_hids_vdda[] = {
"INT347E", /* ov7251 */
NULL
};

static const char * const power1_hids_dvdd[] = {
"INT347A", /* ov8865 on Surface Pro 7+ */
NULL
};

/**
* struct int3472_gpio_map - Map GPIOs to whatever is expected by the
* sensor driver (as in DT bindings)
Expand Down Expand Up @@ -178,12 +189,12 @@ static const struct int3472_gpio_map int3472_gpio_map[] = {
.type_to = INT3472_GPIO_TYPE_RESET,
.con_id = "enable",
},
{ /* ov08x40's handshake pin needs a 45 ms delay on some HP laptops */
.hids = (const char * const[]) { "OVTI08F4", NULL },
.type_from = INT3472_GPIO_TYPE_HANDSHAKE,
.type_to = INT3472_GPIO_TYPE_HANDSHAKE,
.con_id = "dvdd",
.enable_time_us = 45 * USEC_PER_MSEC,
{ /* Sensors which expect "vdda" as con_id for power enable */
.hids = power_enable_hids_vdda,
.type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
.type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
.con_id = "vdda",
.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
},
{ /* Sensors which expect "vana" as con_id for power enable */
.hids = power_enable_hids_vana,
Expand All @@ -192,6 +203,13 @@ static const struct int3472_gpio_map int3472_gpio_map[] = {
.con_id = "vana",
.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
},
{ /* Sensors which expect "dvdd" for the 0x08 (POWER1) rail */
.hids = power1_hids_dvdd,
.type_from = 0x08,
.type_to = 0x08,
.con_id = "dvdd",
.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
},
};

static bool int3472_gpio_map_hids_match(struct acpi_device *adev,
Expand Down Expand Up @@ -273,8 +291,8 @@ static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3
case INT3472_GPIO_TYPE_HANDSHAKE:
*con_id = "dvdd";
*gpio_flags = GPIO_ACTIVE_HIGH;
/* Setups using a handshake pin need 25 ms enable delay */
*enable_time_us = 25 * USEC_PER_MSEC;
/* Powering up the sensor through the handshake pin takes up to 200 ms */
*enable_time_us = 200 * USEC_PER_MSEC;
break;
case 0x08: /* Surface Pro 9 - additional power rail */
*con_id = "pwr1";
Expand Down Expand Up @@ -333,7 +351,6 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
unsigned long gpio_flags;
union acpi_object *obj;
struct gpio_desc *gpio;
const char *err_msg;
const char *con_id;
int ret;

Expand Down Expand Up @@ -379,7 +396,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
case INT3472_GPIO_TYPE_HOTPLUG_DETECT:
ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, con_id, gpio_flags);
if (ret)
err_msg = "Failed to map GPIO pin to sensor\n";
dev_err_probe(int3472->dev, ret,
"Failed to map GPIO pin to sensor\n");

break;
case INT3472_GPIO_TYPE_CLK_ENABLE:
Expand All @@ -392,22 +410,24 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
gpio = skl_int3472_gpiod_get_from_temp_lookup(int3472, agpio, con_id, gpio_flags);
if (IS_ERR(gpio)) {
ret = PTR_ERR(gpio);
err_msg = "Failed to get GPIO\n";
dev_err_probe(int3472->dev, ret, "Failed to get GPIO\n");
break;
}

switch (type) {
case INT3472_GPIO_TYPE_CLK_ENABLE:
ret = skl_int3472_register_gpio_clock(int3472, gpio);
if (ret)
err_msg = "Failed to register clock\n";
dev_err_probe(int3472->dev, ret,
"Failed to register clock\n");

break;
case INT3472_GPIO_TYPE_PRIVACY_LED:
case INT3472_GPIO_TYPE_STROBE:
ret = skl_int3472_register_led(int3472, gpio, con_id);
if (ret)
err_msg = "Failed to register LED\n";
dev_err_probe(int3472->dev, ret,
"Failed to register LED\n");

break;
case INT3472_GPIO_TYPE_POWER_ENABLE:
Expand All @@ -418,7 +438,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
ret = skl_int3472_register_regulator(int3472, gpio, enable_time_us,
con_id, second_sensor);
if (ret)
err_msg = "Failed to register regulator\n";
dev_err_probe(int3472->dev, ret,
"Failed to register regulator\n");

break;
case 0x08: /* Surface Pro 9 - treat as power*/
Expand Down Expand Up @@ -452,11 +473,11 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
int3472->ngpios++;
ACPI_FREE(obj);

if (ret < 0)
return dev_err_probe(int3472->dev, ret, err_msg);

/* Tell acpi_dev_get_resources() to not make a copy of the resource */
return 1;
/*
* Either return an error or tell acpi_dev_get_resources() to not make a
* copy of the resource.
*/
return ret < 0 ? ret : 1;
}

int int3472_discrete_parse_crs(struct int3472_discrete_device *int3472)
Expand Down