|
5 | 5 | #include <linux/clkdev.h>
|
6 | 6 | #include <linux/clk-provider.h>
|
7 | 7 | #include <linux/device.h>
|
| 8 | +#include <linux/dmi.h> |
8 | 9 | #include <linux/gpio/consumer.h>
|
9 | 10 | #include <linux/regulator/driver.h>
|
10 | 11 | #include <linux/slab.h>
|
@@ -250,22 +251,54 @@ static const char * const skl_int3472_regulator_map_supplies[] = {
|
250 | 251 | static_assert(ARRAY_SIZE(skl_int3472_regulator_map_supplies) ==
|
251 | 252 | GPIO_REGULATOR_SUPPLY_MAP_COUNT);
|
252 | 253 |
|
| 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 | + |
253 | 272 | int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
|
254 | 273 | struct acpi_resource_gpio *agpio)
|
255 | 274 | {
|
256 | 275 | char *path = agpio->resource_source.string_ptr;
|
257 | 276 | struct regulator_init_data init_data = { };
|
258 | 277 | 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 | + } |
264 | 297 | }
|
265 | 298 |
|
266 | 299 | init_data.constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS;
|
267 | 300 | 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; |
269 | 302 |
|
270 | 303 | snprintf(int3472->regulator.regulator_name,
|
271 | 304 | sizeof(int3472->regulator.regulator_name), "%s-regulator",
|
|
0 commit comments