Lines Matching +full:powerdown +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/clk-provider.h>
20 * 79234640-9e10-4fea-a5c1-b5aa8b19756f
31 * 822ace8f-2814-4174-a56b-5f029fe079ee
46 * specific deviations from the documented behaviour of GPIOs.
54 { "powerdown", "reset" },
59 /* Lenovo Miix 510-12ISK - OV2680, Front */
61 /* Lenovo Miix 510-12ISK - OV5648, Rear */
63 /* Surface Go 1&2 - OV5693, Front */
73 obj = acpi_evaluate_dsm_typed(int3472->sensor->handle, in skl_int3472_get_sensor_module_config()
78 dev_err(int3472->dev, in skl_int3472_get_sensor_module_config()
80 return ERR_PTR(-ENODEV); in skl_int3472_get_sensor_module_config()
83 if (obj->string.type != ACPI_TYPE_STRING) { in skl_int3472_get_sensor_module_config()
84 dev_err(int3472->dev, in skl_int3472_get_sensor_module_config()
85 "Sensor _DSM returned a non-string value\n"); in skl_int3472_get_sensor_module_config()
88 return ERR_PTR(-EINVAL); in skl_int3472_get_sensor_module_config()
93 obj->string.pointer)) in skl_int3472_get_sensor_module_config()
100 return ERR_PTR(-EINVAL); in skl_int3472_get_sensor_module_config()
110 char *path = agpio->resource_source.string_ptr; in skl_int3472_map_gpio_to_sensor()
116 if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) { in skl_int3472_map_gpio_to_sensor()
117 dev_warn(int3472->dev, "Too many GPIOs mapped\n"); in skl_int3472_map_gpio_to_sensor()
118 return -EINVAL; in skl_int3472_map_gpio_to_sensor()
121 sensor_config = int3472->sensor_config; in skl_int3472_map_gpio_to_sensor()
122 if (!IS_ERR(sensor_config) && sensor_config->function_maps) { in skl_int3472_map_gpio_to_sensor()
125 for (remap = sensor_config->function_maps; remap->documented; remap++) { in skl_int3472_map_gpio_to_sensor()
126 if (!strcmp(func, remap->documented)) { in skl_int3472_map_gpio_to_sensor()
127 func = remap->actual; in skl_int3472_map_gpio_to_sensor()
139 return -EINVAL; in skl_int3472_map_gpio_to_sensor()
143 return -ENODEV; in skl_int3472_map_gpio_to_sensor()
145 table_entry = &int3472->gpios.table[int3472->n_sensor_gpios]; in skl_int3472_map_gpio_to_sensor()
146 table_entry->key = acpi_dev_name(adev); in skl_int3472_map_gpio_to_sensor()
147 table_entry->chip_hwnum = agpio->pin_table[0]; in skl_int3472_map_gpio_to_sensor()
148 table_entry->con_id = func; in skl_int3472_map_gpio_to_sensor()
149 table_entry->idx = 0; in skl_int3472_map_gpio_to_sensor()
150 table_entry->flags = polarity; in skl_int3472_map_gpio_to_sensor()
152 int3472->n_sensor_gpios++; in skl_int3472_map_gpio_to_sensor()
160 char *path = agpio->resource_source.string_ptr; in skl_int3472_map_gpio_to_clk()
161 u16 pin = agpio->pin_table[0]; in skl_int3472_map_gpio_to_clk()
166 gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable"); in skl_int3472_map_gpio_to_clk()
170 int3472->clock.ena_gpio = gpio; in skl_int3472_map_gpio_to_clk()
173 gpio = acpi_get_and_request_gpiod(path, pin, "int3472,privacy-led"); in skl_int3472_map_gpio_to_clk()
177 int3472->clock.led_gpio = gpio; in skl_int3472_map_gpio_to_clk()
180 dev_err(int3472->dev, "Invalid GPIO type 0x%02x for clock\n", type); in skl_int3472_map_gpio_to_clk()
207 * by the mapping sub-functions.
209 * GPIOs will either be mapped directly to the sensor device or else used
213 * * 1 - To continue the loop
214 * * 0 - When all resources found are handled properly.
215 * * -EINVAL - If the resource is not a GPIO IO resource
216 * * -ENODEV - If the resource has no corresponding _DSM entry
217 * * -Other - Errors propagated from one of the sub-functions.
233 * ngpios + 2 because the index of this _DSM function is 1-based and in skl_int3472_handle_gpio_resources()
236 obj = acpi_evaluate_dsm_typed(int3472->adev->handle, in skl_int3472_handle_gpio_resources()
238 int3472->ngpios + 2, in skl_int3472_handle_gpio_resources()
242 dev_warn(int3472->dev, "No _DSM entry for GPIO pin %u\n", in skl_int3472_handle_gpio_resources()
243 agpio->pin_table[0]); in skl_int3472_handle_gpio_resources()
247 type = obj->integer.value & 0xff; in skl_int3472_handle_gpio_resources()
258 ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown", in skl_int3472_handle_gpio_resources()
261 err_msg = "Failed to map powerdown pin to sensor\n"; in skl_int3472_handle_gpio_resources()
278 dev_warn(int3472->dev, in skl_int3472_handle_gpio_resources()
285 int3472->ngpios++; in skl_int3472_handle_gpio_resources()
289 return dev_err_probe(int3472->dev, ret, err_msg); in skl_int3472_handle_gpio_resources()
303 int3472->sensor_config = skl_int3472_get_sensor_module_config(int3472); in skl_int3472_parse_crs()
305 ret = acpi_dev_get_resources(int3472->adev, &resource_list, in skl_int3472_parse_crs()
318 if (int3472->clock.ena_gpio) { in skl_int3472_parse_crs()
323 if (int3472->clock.led_gpio) in skl_int3472_parse_crs()
324 dev_warn(int3472->dev, in skl_int3472_parse_crs()
328 int3472->gpios.dev_id = int3472->sensor_name; in skl_int3472_parse_crs()
329 gpiod_add_lookup_table(&int3472->gpios); in skl_int3472_parse_crs()
338 gpiod_remove_lookup_table(&int3472->gpios); in skl_int3472_discrete_remove()
340 if (int3472->clock.cl) in skl_int3472_discrete_remove()
343 gpiod_put(int3472->clock.ena_gpio); in skl_int3472_discrete_remove()
344 gpiod_put(int3472->clock.led_gpio); in skl_int3472_discrete_remove()
353 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); in skl_int3472_discrete_probe()
360 dev_err(&pdev->dev, "Couldn't fill CLDB structure\n"); in skl_int3472_discrete_probe()
365 dev_err(&pdev->dev, "Unsupported control logic type %u\n", in skl_int3472_discrete_probe()
367 return -EINVAL; in skl_int3472_discrete_probe()
370 /* Max num GPIOs we've seen plus a terminator */ in skl_int3472_discrete_probe()
371 int3472 = devm_kzalloc(&pdev->dev, struct_size(int3472, gpios.table, in skl_int3472_discrete_probe()
374 return -ENOMEM; in skl_int3472_discrete_probe()
376 int3472->adev = adev; in skl_int3472_discrete_probe()
377 int3472->dev = &pdev->dev; in skl_int3472_discrete_probe()
380 ret = skl_int3472_get_sensor_adev_and_name(&pdev->dev, &int3472->sensor, in skl_int3472_discrete_probe()
381 &int3472->sensor_name); in skl_int3472_discrete_probe()
389 INIT_LIST_HEAD(&int3472->gpios.list); in skl_int3472_discrete_probe()
409 .name = "int3472-discrete",