// SPDX-License-Identifier: GPL-2.0 /* Author: Dan Scally <[email protected]> */ #include <linux/acpi.h> #include <linux/bitfield.h> #include <linux/device.h> #include <linux/gpio/consumer.h> #include <linux/gpio/machine.h> #include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/overflow.h> #include <linux/platform_device.h> #include <linux/uuid.h> #include "common.h" /* * 79234640-9e10-4fea-a5c1-b5aa8b19756f * This _DSM GUID returns information about the GPIO lines mapped to a * discrete INT3472 device. Function number 1 returns a count of the GPIO * lines that are mapped. Subsequent functions return 32 bit ints encoding * information about the GPIO line, including its purpose. */ static const guid_t int3472_gpio_guid = …; #define INT3472_GPIO_DSM_TYPE … #define INT3472_GPIO_DSM_PIN … #define INT3472_GPIO_DSM_SENSOR_ON_VAL … /* * 822ace8f-2814-4174-a56b-5f029fe079ee * This _DSM GUID returns a string from the sensor device, which acts as a * module identifier. */ static const guid_t cio2_sensor_module_guid = …; static void skl_int3472_log_sensor_module_name(struct int3472_discrete_device *int3472) { … } static int skl_int3472_fill_gpiod_lookup(struct gpiod_lookup *table_entry, struct acpi_resource_gpio *agpio, const char *func, u32 polarity) { … } static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472, struct acpi_resource_gpio *agpio, const char *func, u32 polarity) { … } /* This should *really* only be used when there's no other way... */ static struct gpio_desc * skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472, struct acpi_resource_gpio *agpio, const char *func, u32 polarity) { … } static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity) { … } /** * skl_int3472_handle_gpio_resources: Map PMIC resources to consuming sensor * @ares: A pointer to a &struct acpi_resource * @data: A pointer to a &struct int3472_discrete_device * * This function handles GPIO resources that are against an INT3472 * ACPI device, by checking the value of the corresponding _DSM entry. * This will return a 32bit int, where the lowest byte represents the * function of the GPIO pin: * * 0x00 Reset * 0x01 Power down * 0x0b Power enable * 0x0c Clock enable * 0x0d Privacy LED * * There are some known platform specific quirks where that does not quite * hold up; for example where a pin with type 0x01 (Power down) is mapped to * a sensor pin that performs a reset function or entries in _CRS and _DSM that * do not actually correspond to a physical connection. These will be handled * by the mapping sub-functions. * * GPIOs will either be mapped directly to the sensor device or else used * to create clocks and regulators via the usual frameworks. * * Return: * * 1 - To continue the loop * * 0 - When all resources found are handled properly. * * -EINVAL - If the resource is not a GPIO IO resource * * -ENODEV - If the resource has no corresponding _DSM entry * * -Other - Errors propagated from one of the sub-functions. */ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, void *data) { … } static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472) { … } static void skl_int3472_discrete_remove(struct platform_device *pdev) { … } static int skl_int3472_discrete_probe(struct platform_device *pdev) { … } static const struct acpi_device_id int3472_device_id[] = …; MODULE_DEVICE_TABLE(acpi, int3472_device_id); static struct platform_driver int3472_discrete = …; module_platform_driver(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;