Skip to content

Commit f1a5825

Browse files
committed
platform/x86: int3472: discrete: Add support for 1 GPIO regulator shared between 2 sensors
On the Lenovo Miix 510-12IKB there is 1 GPIO regulator, with its GPIO listed in the INT3472 device belonging to the OV5648 back sensor. But this regulator also needs to be enabled for the OV2680 front sensor to work. Add support to skl_int3472_register_regulator() to add supply map entries pointing to both sensors based on a DMI quirk table which gives the dev_name part of the supply map for the second sensor (the sensor without the GPIO listed in its matching INT3472 ACPI device). Tested-by: Hao Yao <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d4381dc commit f1a5825

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

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

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/clkdev.h>
66
#include <linux/clk-provider.h>
77
#include <linux/device.h>
8+
#include <linux/dmi.h>
89
#include <linux/gpio/consumer.h>
910
#include <linux/regulator/driver.h>
1011
#include <linux/slab.h>
@@ -250,22 +251,54 @@ static const char * const skl_int3472_regulator_map_supplies[] = {
250251
static_assert(ARRAY_SIZE(skl_int3472_regulator_map_supplies) ==
251252
GPIO_REGULATOR_SUPPLY_MAP_COUNT);
252253

254+
/*
255+
* On some models there is a single GPIO regulator which is shared between
256+
* sensors and only listed in the ACPI resources of one sensor.
257+
* This DMI table contains the name of the second sensor. This is used to add
258+
* entries for the second sensor to the supply_map.
259+
*/
260+
const struct dmi_system_id skl_int3472_regulator_second_sensor[] = {
261+
{
262+
/* Lenovo Miix 510-12IKB */
263+
.matches = {
264+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
265+
DMI_MATCH(DMI_PRODUCT_VERSION, "MIIX 510-12IKB"),
266+
},
267+
.driver_data = "i2c-OVTI2680:00",
268+
},
269+
{ }
270+
};
271+
253272
int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
254273
struct acpi_resource_gpio *agpio)
255274
{
256275
char *path = agpio->resource_source.string_ptr;
257276
struct regulator_init_data init_data = { };
258277
struct regulator_config cfg = { };
259-
int i, ret;
260-
261-
for (i = 0; i < ARRAY_SIZE(skl_int3472_regulator_map_supplies); i++) {
262-
int3472->regulator.supply_map[i].supply = skl_int3472_regulator_map_supplies[i];
263-
int3472->regulator.supply_map[i].dev_name = int3472->sensor_name;
278+
const char *second_sensor = NULL;
279+
const struct dmi_system_id *id;
280+
int i, j, ret;
281+
282+
id = dmi_first_match(skl_int3472_regulator_second_sensor);
283+
if (id)
284+
second_sensor = id->driver_data;
285+
286+
for (i = 0, j = 0; i < ARRAY_SIZE(skl_int3472_regulator_map_supplies); i++) {
287+
int3472->regulator.supply_map[j].supply = skl_int3472_regulator_map_supplies[i];
288+
int3472->regulator.supply_map[j].dev_name = int3472->sensor_name;
289+
j++;
290+
291+
if (second_sensor) {
292+
int3472->regulator.supply_map[j].supply =
293+
skl_int3472_regulator_map_supplies[i];
294+
int3472->regulator.supply_map[j].dev_name = second_sensor;
295+
j++;
296+
}
264297
}
265298

266299
init_data.constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS;
267300
init_data.consumer_supplies = int3472->regulator.supply_map;
268-
init_data.num_consumer_supplies = GPIO_REGULATOR_SUPPLY_MAP_COUNT;
301+
init_data.num_consumer_supplies = j;
269302

270303
snprintf(int3472->regulator.regulator_name,
271304
sizeof(int3472->regulator.regulator_name), "%s-regulator",

drivers/platform/x86/intel/int3472/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ struct int3472_discrete_device {
7979
const struct int3472_sensor_config *sensor_config;
8080

8181
struct int3472_gpio_regulator {
82-
struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT];
82+
/* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */
83+
struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2];
8384
char regulator_name[GPIO_REGULATOR_NAME_LENGTH];
8485
char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH];
8586
struct gpio_desc *gpio;

0 commit comments

Comments
 (0)