Lines Matching +full:int +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0
21 * 79234640-9e10-4fea-a5c1-b5aa8b19756f
36 * 822ace8f-2814-4174-a56b-5f029fe079ee
48 obj = acpi_evaluate_dsm_typed(int3472->sensor->handle, in skl_int3472_log_sensor_module_name()
52 dev_dbg(int3472->dev, "Sensor module id: '%s'\n", obj->string.pointer); in skl_int3472_log_sensor_module_name()
57 static int skl_int3472_fill_gpiod_lookup(struct gpiod_lookup *table_entry, in skl_int3472_fill_gpiod_lookup()
61 char *path = agpio->resource_source.string_ptr; in skl_int3472_fill_gpiod_lookup()
68 return -EINVAL; in skl_int3472_fill_gpiod_lookup()
72 return -ENODEV; in skl_int3472_fill_gpiod_lookup()
74 *table_entry = GPIO_LOOKUP(acpi_dev_name(adev), agpio->pin_table[0], con_id, gpio_flags); in skl_int3472_fill_gpiod_lookup()
79 static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472, in skl_int3472_map_gpio_to_sensor()
83 int ret; in skl_int3472_map_gpio_to_sensor()
85 if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) { in skl_int3472_map_gpio_to_sensor()
86 dev_warn(int3472->dev, "Too many GPIOs mapped\n"); in skl_int3472_map_gpio_to_sensor()
87 return -EINVAL; in skl_int3472_map_gpio_to_sensor()
90 ret = skl_int3472_fill_gpiod_lookup(&int3472->gpios.table[int3472->n_sensor_gpios], in skl_int3472_map_gpio_to_sensor()
95 int3472->n_sensor_gpios++; in skl_int3472_map_gpio_to_sensor()
107 int ret; in skl_int3472_gpiod_get_from_temp_lookup()
112 return ERR_PTR(-ENOMEM); in skl_int3472_gpiod_get_from_temp_lookup()
114 lookup->dev_id = dev_name(int3472->dev); in skl_int3472_gpiod_get_from_temp_lookup()
115 ret = skl_int3472_fill_gpiod_lookup(&lookup->table[0], agpio, con_id, gpio_flags); in skl_int3472_gpiod_get_from_temp_lookup()
120 desc = gpiod_get(int3472->dev, con_id, GPIOD_OUT_LOW); in skl_int3472_gpiod_get_from_temp_lookup()
127 * struct int3472_gpio_map - Map GPIOs to whatever is expected by the
147 /* ov7251 driver / DT-bindings expect "enable" as con_id for reset */
154 struct acpi_device *adev = int3472->sensor; in int3472_get_con_id_and_polarity()
155 unsigned int i; in int3472_get_con_id_and_polarity()
159 * Map the firmware-provided GPIO to whatever a driver expects in int3472_get_con_id_and_polarity()
169 dev_dbg(int3472->dev, "mapping type 0x%02x pin to 0x%02x %s\n", in int3472_get_con_id_and_polarity()
189 *con_id = "clk-enable"; in int3472_get_con_id_and_polarity()
193 *con_id = "privacy-led"; in int3472_get_con_id_and_polarity()
218 * This will return a 32bit int, where the lowest byte represents the
231 * by the mapping sub-functions.
233 * GPIOs will either be mapped directly to the sensor device or else used
237 * * 1 - Continue the loop without adding a copy of the resource to
239 * * 0 - Continue the loop after adding a copy of the resource to
241 * * -errno - Error, break loop
243 static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, in skl_int3472_handle_gpio_resources()
254 int ret; in skl_int3472_handle_gpio_resources()
260 * ngpios + 2 because the index of this _DSM function is 1-based and in skl_int3472_handle_gpio_resources()
263 obj = acpi_evaluate_dsm_typed(int3472->adev->handle, in skl_int3472_handle_gpio_resources()
265 int3472->ngpios + 2, in skl_int3472_handle_gpio_resources()
269 dev_warn(int3472->dev, "No _DSM entry for GPIO pin %u\n", in skl_int3472_handle_gpio_resources()
270 agpio->pin_table[0]); in skl_int3472_handle_gpio_resources()
274 type = FIELD_GET(INT3472_GPIO_DSM_TYPE, obj->integer.value); in skl_int3472_handle_gpio_resources()
278 pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value); in skl_int3472_handle_gpio_resources()
280 if (pin != (agpio->pin_table[0] & 0xff)) in skl_int3472_handle_gpio_resources()
281 dev_dbg(int3472->dev, FW_BUG "%s %s pin number mismatch _DSM %d resource %d\n", in skl_int3472_handle_gpio_resources()
282 con_id, agpio->resource_source.string_ptr, pin, agpio->pin_table[0]); in skl_int3472_handle_gpio_resources()
284 active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value); in skl_int3472_handle_gpio_resources()
288 dev_dbg(int3472->dev, "%s %s pin %d active-%s\n", con_id, in skl_int3472_handle_gpio_resources()
289 agpio->resource_source.string_ptr, agpio->pin_table[0], in skl_int3472_handle_gpio_resources()
328 int3472->quirks.avdd_second_sensor); in skl_int3472_handle_gpio_resources()
330 err_msg = "Failed to map power-enable to sensor\n"; in skl_int3472_handle_gpio_resources()
343 ret = -EINVAL; in skl_int3472_handle_gpio_resources()
352 dev_warn(int3472->dev, in skl_int3472_handle_gpio_resources()
359 int3472->ngpios++; in skl_int3472_handle_gpio_resources()
363 return dev_err_probe(int3472->dev, ret, err_msg); in skl_int3472_handle_gpio_resources()
369 int int3472_discrete_parse_crs(struct int3472_discrete_device *int3472) in int3472_discrete_parse_crs()
372 int ret; in int3472_discrete_parse_crs()
376 ret = acpi_dev_get_resources(int3472->adev, &resource_list, in int3472_discrete_parse_crs()
384 /* Register _DSM based clock (no-op if a GPIO clock was already registered) */ in int3472_discrete_parse_crs()
389 int3472->gpios.dev_id = int3472->sensor_name; in int3472_discrete_parse_crs()
390 gpiod_add_lookup_table(&int3472->gpios); in int3472_discrete_parse_crs()
398 gpiod_remove_lookup_table(&int3472->gpios); in int3472_discrete_cleanup()
411 static int skl_int3472_discrete_probe(struct platform_device *pdev) in skl_int3472_discrete_probe()
413 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); in skl_int3472_discrete_probe()
418 int ret; in skl_int3472_discrete_probe()
421 return -ENODEV; in skl_int3472_discrete_probe()
425 quirks = id->driver_data; in skl_int3472_discrete_probe()
429 dev_err(&pdev->dev, "Couldn't fill CLDB structure\n"); in skl_int3472_discrete_probe()
434 dev_err(&pdev->dev, "Unsupported control logic type %u\n", in skl_int3472_discrete_probe()
436 return -EINVAL; in skl_int3472_discrete_probe()
439 /* Max num GPIOs we've seen plus a terminator */ in skl_int3472_discrete_probe()
440 int3472 = devm_kzalloc(&pdev->dev, struct_size(int3472, gpios.table, in skl_int3472_discrete_probe()
443 return -ENOMEM; in skl_int3472_discrete_probe()
445 int3472->adev = adev; in skl_int3472_discrete_probe()
446 int3472->dev = &pdev->dev; in skl_int3472_discrete_probe()
448 int3472->clock.imgclk_index = cldb.clock_source; in skl_int3472_discrete_probe()
451 int3472->quirks = *quirks; in skl_int3472_discrete_probe()
453 ret = skl_int3472_get_sensor_adev_and_name(&pdev->dev, &int3472->sensor, in skl_int3472_discrete_probe()
454 &int3472->sensor_name); in skl_int3472_discrete_probe()
462 INIT_LIST_HEAD(&int3472->gpios.list); in skl_int3472_discrete_probe()
482 .name = "int3472-discrete",