Introduce intel_skl_int3472 module
Subsystems (12)
v4 cover Introduce intel_skl_int3472 module
Hello all
Apologies for the long delay since the last version of this series; the time I had free to work on it became somewhat restrained.
v1 for this series was originally 14-18 of this series:
https://lore.kernel.org/linux-media/[email protected]/T/#m91934e12e3d033da2e768e952ea3b4a125ee3e67
v2 was here:
https://lore.kernel.org/platform-driver-x86/[email protected]/
v3 was here:
https://lore.kernel.org/lkml/[email protected]/
Series level changelog:
- Added patch 5/8 to make clkdev_drop() NULL aware to simplify error handling.
- Added patch 6/8 to add acpi_gpio_get_io_resource().
This has been tested on a number of devices, but currently **not** on a device designed for ChromeOS, which we ideally need to do to ensure no regression caused by replacing the tps68470 MFD driver. Unfortunately, I don't have a device to test it on myself.
=========== Original Cover Letter ===========
At the moment in the kernel the ACPI _HID INT3472 is taken by the tps68470 MFD driver, but that driver can only handle some of the cases of that _HID that we see. There are at least these three possibilities:
1. INT3472 devices that provide GPIOs through the usual framework and run power and clocks through an operation region; this is the situation that the current module handles and is seen on ChromeOS devices
2. INT3472 devices that provide GPIOs, plus clocks and regulators that are meant to be driven through the usual frameworks, usually seen on devices designed to run Windows
3. INT3472 devices that don't actually represent a physical tps68470, but are being used as a convenient way of grouping a bunch of system GPIO lines that are intended to enable power and clocks for sensors which are called out as dependent on them. Also seen on devices designed to run Windows.
This series introduces a new module which registers:
1. An i2c driver that determines which scenario (#1 or #2) applies to the machine and registers platform devices to be bound to GPIO, OpRegion, clock and regulator drivers as appropriate.
2. A platform driver that binds to the dummy INT3472 devices described in #3
The platform driver for the dummy device registers the GPIO lines that enable the clocks and regulators to the sensors via those frameworks so that sensor drivers can consume them in the usual fashion. The existing GPIO and OpRegion tps68470 drivers will work with the i2c driver that's registered. Clock and regulator drivers are available but have not so far been tested, so aren't part of this series.
The existing mfd/tps68470.c driver being thus superseded, it is removed.
Thanks
Dan
Daniel Scally (8):
ACPI: scan: Extend acpi_walk_dep_device_list()
ACPI: scan: Add function to fetch dependent of acpi device
i2c: core: Add a format macro for I2C device names
gpiolib: acpi: Export acpi_get_gpiod()
clkdev: Make clkdev_drop() null aware
gpiolib: acpi: Add acpi_gpio_get_io_resource() platform/x86: Add intel_skl_int3472 driver
mfd: tps68470: Remove tps68470 MFD driver
MAINTAINERS | 5 + drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/Kconfig | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 107 ++++- drivers/clk/clkdev.c | 3 + drivers/gpio/Kconfig | 2 +- drivers/gpio/gpiolib-acpi.c | 61 ++- drivers/i2c/i2c-core-acpi.c | 8 +- drivers/i2c/i2c-core-base.c | 4 +- drivers/mfd/Kconfig | 18 - drivers/mfd/Makefile | 1 - drivers/mfd/tps68470.c | 97 ----- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +- .../platform/surface/surface_acpi_notify.c | 7 +- drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-int3472/Kconfig | 31 ++ drivers/platform/x86/intel-int3472/Makefile | 5 + .../intel_skl_int3472_clk_and_regulator.c | 195 +++++++++ .../intel-int3472/intel_skl_int3472_common.c | 106 +++++ .../intel-int3472/intel_skl_int3472_common.h | 113 +++++ .../intel_skl_int3472_discrete.c | 409 ++++++++++++++++++ .../intel_skl_int3472_tps68470.c | 109 +++++ include/acpi/acpi_bus.h | 8 + include/linux/acpi.h | 11 +- include/linux/gpio/consumer.h | 2 + include/linux/i2c.h | 3 + 29 files changed, 1175 insertions(+), 167 deletions(-) delete mode 100644 drivers/mfd/tps68470.c create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
Signature · 1 line
2.25.1
PATCH v4 1/8 ACPI: scan: Extend acpi_walk_dep_device_list()
The acpi_walk_dep_device_list() is not as generalisable as its name implies, serving only to decrement the dependency count for each dependent device of the input. Extend the function to instead accept a callback which can be applied to all the dependencies in acpi_dep_list. Replace all existing calls to the function with calls to a wrapper, passing a callback that applies the same dependency reduction.
---
changes since v3:
- Most of the functions got renamed
- acpi_dev_get_dependent_dev() was altered to take a struct acpi_device This had some repurcussions in the other files, mostly switching from ACPI_HANDLE() to ACPI_COMPANION().
- acpi_walk_dep_device_list() was altered to check the return value of the callback on each iteration of the loop, to allow for error handling of the callbacks or breaking the loop early to save time. Andy, Wolfram, I thought this change was significant enough to drop your R-b and Ack.
drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 69 ++++++++++++++----- drivers/gpio/gpiolib-acpi.c | 10 +-- drivers/i2c/i2c-core-acpi.c | 8 +-- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +++--- .../platform/surface/surface_acpi_notify.c | 7 +- include/acpi/acpi_bus.h | 7 ++ include/linux/acpi.h | 4 +- 10 files changed, 90 insertions(+), 47 deletions(-)
drivers/acpi/ec.c +1 -1
@@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)WARN (!ret,"Could not request EC cmd io port 0x%lx" , ec->command_addr);/* Reprobe devices depending on the EC */ -acpi_walk_dep_device_list (ec->handle); +acpi_dev_clear_dependencies (device);acpi_handle_debug (ec->handle,"enumerated.\n" );return 0 ;
drivers/acpi/pmic/intel_pmic_chtdc_ti.c +1 -1
@@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)return err;/* Re-enumerate devices depending on PMIC */ -acpi_walk_dep_device_list (ACPI_HANDLE (pdev->dev.parent)); +acpi_dev_clear_dependencies (ACPI_COMPANION (pdev->dev.parent));return 0 ; }
drivers/acpi/scan.c +51 -18
93 lines not on this page · raw message
drivers/gpio/gpiolib-acpi.c +5 -5
@@ -1233,14 +1233,14 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)void acpi_gpiochip_add (struct gpio_chip *chip) {struct acpi_gpio_chip *acpi_gpio; -acpi_handle handle; +struct acpi_device *adev;acpi_status status;if (!chip || !chip->parent)return ; - handle =ACPI_HANDLE (chip->parent); -if (!handle) + adev =ACPI_COMPANION (chip->parent); +if (!adev)return ; acpi_gpio =kzalloc (sizeof (*acpi_gpio),GFP_KERNEL );
@@ -1254,7 +1254,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)INIT_LIST_HEAD (&acpi_gpio->events);INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); - status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio); + status =acpi_attach_data (adev->handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {dev_err (chip->parent,"Failed to attach ACPI GPIO chip\n" );kfree (acpi_gpio);
@@ -1263,7 +1263,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio); -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }void acpi_gpiochip_remove (struct gpio_chip *chip)
drivers/i2c/i2c-core-acpi.c +4 -4
@@ -259,8 +259,8 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,*/ void i2c_acpi_register_devices (struct i2c_adapter *adap) { +struct acpi_device *adev;acpi_status status; -acpi_handle handle;if (!has_acpi_companion (&adap->dev))return ;
@@ -275,11 +275,11 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)if (!adap->dev.parent)return ; - handle =ACPI_HANDLE (adap->dev.parent); -if (!handle) + adev =ACPI_COMPANION (adap->dev.parent); +if (!adev)return ; -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {
drivers/platform/surface/aggregator/core.c +3 -3
@@ -621,8 +621,8 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {static int ssam_serial_hub_probe (struct serdev_device *serdev) { +struct acpi_device *ssh =ACPI_COMPANION (&serdev->dev);struct ssam_controller *ctrl; -acpi_handle *ssh =ACPI_HANDLE (&serdev->dev);acpi_status astatus;int status;
@@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)if (status) goto err_devopen; - astatus =ssam_serdev_setup_via_acpi (ssh, serdev); + astatus =ssam_serdev_setup_via_acpi (ssh->handle, serdev);if (ACPI_FAILURE (astatus)) { status = -ENXIO ; goto err_devinit;
@@ -706,7 +706,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)* For now let's thus default power/wakeup to false. */ device_set_wakeup_capable (&serdev->dev, true); -acpi_walk_dep_device_list (ssh); +acpi_dev_clear_dependencies (ssh);return 0 ;
drivers/platform/surface/surface3_power.c +11 -11
@@ -446,12 +446,12 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,static int mshw0011_install_space_handler (struct i2c_client *client) { -acpi_handle handle; +struct acpi_device *adev;struct mshw0011_handler_data *data;acpi_status status; - handle =ACPI_HANDLE (&client->dev); -if (!handle) + adev =ACPI_COMPANION (&client->dev); +if (!adev)return -ENODEV ; data = kzalloc(sizeof(struct mshw0011_handler_data),
@@ -460,25 +460,25 @@ static int mshw0011_install_space_handler(struct i2c_client *client)return -ENOMEM ; data->client = client; - status =acpi_bus_attach_private_data (handle, (void *)data); + status =acpi_bus_attach_private_data (adev->handle, (void *)data);if (ACPI_FAILURE (status)) {kfree (data);return -ENOMEM ; } - status =acpi_install_address_space_handler (handle, -ACPI_ADR_SPACE_GSBUS , - &mshw0011_space_handler, -NULL , - data); + status =acpi_install_address_space_handler (adev->handle, +ACPI_ADR_SPACE_GSBUS , + &mshw0011_space_handler, +NULL , + data);if (ACPI_FAILURE (status)) {dev_err (&client->dev,"Error installing i2c space handler\n" ); -acpi_bus_detach_private_data (handle); +acpi_bus_detach_private_data (adev->handle);kfree (data);return -ENOMEM ; } -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev);return 0 ; }
drivers/platform/surface/surface_acpi_notify.c +4 -3
@@ -798,7 +798,7 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -acpi_handle san =ACPI_HANDLE (&pdev->dev); +struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl;struct san_data *data;acpi_status astatus;
@@ -821,7 +821,8 @@ static int san_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); - astatus =acpi_install_address_space_handler (san,ACPI_ADR_SPACE_GSBUS , + astatus =acpi_install_address_space_handler (san->handle, +ACPI_ADR_SPACE_GSBUS , &san_opreg_handler,NULL , &data->info);if (ACPI_FAILURE (astatus))
@@ -835,7 +836,7 @@ static int san_probe(struct platform_device *pdev)if (status) goto err_install_dev; -acpi_walk_dep_device_list (san); +acpi_dev_clear_dependencies (san);return 0 ; err_install_dev:
include/acpi/acpi_bus.h +7 -0
@@ -280,6 +280,12 @@ struct acpi_device_power {struct acpi_device_power_state states[ACPI_D_STATE_COUNT ];/* Power states (D0-D3Cold) */ }; +struct acpi_dep_data { +struct list_head node; +acpi_handle supplier; +acpi_handle consumer; +}; +/* Performance Management */ struct acpi_device_perf_flags {
@@ -685,6 +691,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2); +void acpi_dev_clear_dependencies (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *
include/linux/acpi.h +3 -1
@@ -666,7 +666,9 @@ extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv);int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); -void acpi_walk_dep_device_list (acpi_handle handle); +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data);struct platform_device *acpi_create_platform_device (struct acpi_device *,struct property_entry *);
Signature · 1 line
2.25.1
PATCH v4 2/8 ACPI: scan: Add function to fetch dependent of acpi device
In reply to Daniel ScallyIn some ACPI tables we encounter, devices use the _DEP method to assert a dependence on other ACPI devices as opposed to the OpRegions that the specification intends. We need to be able to find those devices "from" the dependee, so add a callback and a wrapper to walk over the acpi_dep_list and return the dependent ACPI device.
---
Changes since v3:
Both new functions were renamed.
drivers/acpi/scan.c | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 39 insertions(+)
drivers/acpi/scan.c +38 -0
@@ -2105,6 +2105,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } +static int acpi_return_dep_dev (struct acpi_dep_data *dep,void *data) +{ +struct acpi_device *adev; +int ret; + + ret =acpi_bus_get_device (dep->consumer, &adev); +if (ret) +/* If we don't find an adev then we want to continue parsing */ +return 0 ; + + *(struct acpi_device **)data = adev; + +return 1 ; +} +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) {struct acpi_device *adev;
@@ -2168,6 +2183,29 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier) }EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** +* acpi_dev_get_dependent_dev - Return ACPI device dependent on @supplier +* @supplier: Pointer to the dependee device +* +* Returns the first &struct acpi_device which declares itself dependent on +* @supplier via the _DEP buffer, parsed from the acpi_dep_list. +* +* The caller is responsible for putting the reference to adev when it is no +* longer needed. +*/ +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier) +{ +struct acpi_device *adev =NULL ; + +acpi_walk_dep_device_list (supplier->handle, acpi_return_dep_dev, &adev); + +if (adev) +get_device (&adev->dev); + +return adev; +} +EXPORT_SYMBOL_GPL (acpi_dev_get_dependent_dev); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan.
include/acpi/acpi_bus.h +1 -0
@@ -692,6 +692,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2);void acpi_dev_clear_dependencies (struct acpi_device *supplier); +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *
Signature · 1 line
2.25.1
PATCH v4 3/8 i2c: core: Add a format macro for I2C device names
In reply to Daniel ScallySome places in the kernel allow users to map resources to a device using device name (for example, in the struct gpiod_lookup_table). Currently this involves waiting for the I2C client to have been registered so we can use dev_name(&client->dev). We want to add a function to allow users to refer to an I2C device by name before it has been instantiated, so create a macro for the format that's accessible outside the I2C layer and use it in i2c_dev_set_name().
---
Changes since v3:
- None
drivers/i2c/i2c-core-base.c | 4 ++-- include/linux/i2c.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/i2c/i2c-core-base.c +2 -2
@@ -852,12 +852,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap,struct acpi_device *adev =ACPI_COMPANION (&client->dev);if (info && info->dev_name) { -dev_set_name (&client->dev,"i2c-%s" , info->dev_name); +dev_set_name (&client->dev,I2C_DEV_NAME_FORMAT , info->dev_name);return ; }if (adev) { -dev_set_name (&client->dev,"i2c-%s" ,acpi_dev_name (adev)); +dev_set_name (&client->dev,I2C_DEV_NAME_FORMAT ,acpi_dev_name (adev));return ; }
include/linux/i2c.h +3 -0
@@ -39,6 +39,9 @@ enum i2c_slave_event;typedef int (*i2c_slave_cb_t )(struct i2c_client *client,enum i2c_slave_event event,u8 *val); +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ +#define I2C_DEV_NAME_FORMAT "i2c-%s" +/* I2C Frequency Modes */ #define I2C_MAX_STANDARD_MODE_FREQ 100000#define I2C_MAX_FAST_MODE_FREQ 400000
Signature · 1 line
2.25.1
PATCH v4 4/8 gpiolib: acpi: Export acpi_get_gpiod()
In reply to Daniel ScallyWe need to be able to translate GPIO resources in an ACPI device's _CRS into GPIO descriptor array. Those are represented in _CRS as a pathname to a GPIO device plus the pin's index number: the acpi_get_gpiod() function is perfect for that purpose.
As it's currently only used internally within the GPIO layer, provide and export a wrapper function that additionally holds a reference to the GPIO device.
---
Changes since v3:
- Renamed function to acpi_get_and_request_gpiod() - and no longer renaming acpi_get_gpiod()
drivers/gpio/gpiolib-acpi.c | 28 ++++++++++++++++++++++++++++ include/linux/gpio/consumer.h | 2 ++ 2 files changed, 30 insertions(+)
drivers/gpio/gpiolib-acpi.c +28 -0
@@ -128,6 +128,34 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)return gpiochip_get_desc (chip, pin); } +/** +* acpi_get_and_request_gpiod() - Translate ACPI GPIO pin to GPIO descriptor +* and hold a refcount to the GPIO device. +* @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1") +* @pin: ACPI GPIO pin number (0-based, controller-relative) +* @label: Label to pass to gpiod_request() +* +* This function is a simple pass-through to acpi_get_gpiod(), except that +* as it is intended for use outside of the GPIO layer (in a similar fashion to +* gpiod_get_index() for example) it also holds a reference to the GPIO device. +*/ +struct gpio_desc *acpi_get_and_request_gpiod (char *path,int pin,char *label) +{ +struct gpio_desc *gpio; +int ret; + + gpio =acpi_get_gpiod (path, pin); +if (IS_ERR (gpio)) +return gpio; + + ret =gpiod_request (gpio, label); +if (ret) +return ERR_PTR (ret); + +return gpio; +} +EXPORT_SYMBOL_GPL (acpi_get_and_request_gpiod); +static irqreturn_t acpi_gpio_irq_handler (int irq,void *data) {struct acpi_gpio_event *event = data;
include/linux/gpio/consumer.h +2 -0
@@ -692,6 +692,8 @@ int devm_acpi_dev_add_driver_gpios(struct device *dev, const struct acpi_gpio_mapping *gpios);void devm_acpi_dev_remove_driver_gpios (struct device *dev); +struct gpio_desc *acpi_get_and_request_gpiod (char *path,int pin,char *label); +#else /* CONFIG_GPIOLIB && CONFIG_ACPI */ struct acpi_device ;
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 5/8 clkdev: Make clkdev_drop() null aware
In reply to Daniel ScallyTo simplify error handling paths, many functions are no-ops when passed NULL pointers, for example gpiod_remove_lookup_table(). Mirror that behaviour for clkdev_drop().
---
Changes since v3:
- Patch introduced
drivers/clk/clkdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/clkdev.c +3 -0
@@ -286,6 +286,9 @@ EXPORT_SYMBOL(clk_add_alias);*/ void clkdev_drop (struct clk_lookup *cl) { +if (!cl) +return ; +mutex_lock (&clocks_mutex);list_del (&cl->node);mutex_unlock (&clocks_mutex);
Signature · 1 line
2.25.1
PATCH v4 6/8 gpiolib: acpi: Add acpi_gpio_get_io_resource()
In reply to Daniel ScallyAdd a function to verify that a given acpi_resource represents an IO type GPIO resource, and return it if so.
---
Changes since v3:
- Patch introduced
drivers/gpio/gpiolib-acpi.c | 23 +++++++++++++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 30 insertions(+)
drivers/gpio/gpiolib-acpi.c +23 -0
@@ -196,6 +196,29 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, }EXPORT_SYMBOL_GPL (acpi_gpio_get_irq_resource); +/** +* acpi_gpio_get_io_resource - Fetch details of an ACPI resource if it is a GPIO +* I/O resource or return False if not. +* @ares: Pointer to the ACPI resource to fetch +* @agpio: Pointer to a &struct acpi_resource_gpio to store the output pointer +*/ +bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio) +{ +struct acpi_resource_gpio *gpio; + +if (ares->type !=ACPI_RESOURCE_TYPE_GPIO ) +return false; + + gpio = &ares->data.gpio; +if (gpio->connection_type !=ACPI_RESOURCE_GPIO_TYPE_IO ) +return false; + + *agpio = gpio; +return true; +} +EXPORT_SYMBOL_GPL (acpi_gpio_get_io_resource); +static void acpi_gpiochip_request_irq (struct acpi_gpio_chip *acpi_gpio,struct acpi_gpio_event *event) {
include/linux/acpi.h +7 -0
@@ -1098,6 +1098,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c#if defined(CONFIG_ACPI ) && defined(CONFIG_GPIOLIB )bool acpi_gpio_get_irq_resource (struct acpi_resource *ares,struct acpi_resource_gpio **agpio); +bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio);int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name,int index);#else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
@@ -1105,6 +1107,11 @@ static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, {return false; } +static inline bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio) +{ +return false; +}static inline int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name,int index) {
Signature · 1 line
2.25.1
PATCH v4 7/8 platform/x86: Add intel_skl_int3472 driver
In reply to Daniel ScallyACPI devices with _HID INT3472 are currently matched to the tps68470 driver, however this does not cover all situations in which that _HID occurs. We've encountered three possibilities:
1. On Chrome OS devices, an ACPI device with _HID INT3472 (representing a physical TPS68470 device) that requires a GPIO and OpRegion driver
2. On devices designed for Windows, an ACPI device with _HID INT3472 (again representing a physical TPS68470 device) which requires GPIO, Clock and Regulator drivers.
3. On other devices designed for Windows, an ACPI device with _HID INT3472 which does **not** represent a physical TPS68470, and is instead used as a dummy device to group some system GPIO lines which are meant to be consumed by the sensor that is dependent on this entry.
This commit adds a new module, registering a platform driver to deal with the 3rd scenario plus an i2c driver to deal with #1 and #2, by querying the CLDB buffer found against INT3472 entries to determine which is most appropriate.
---
Changes since v3:
- Split clk and regulator parts to a separate file.
- Used ACPI error handling functions where appropriate
- Tidied skl_int3472_discrete_remove() a lot
- Used devm_*() APIs where appropriate
- Constified global variables and structs that were missing it before
- Lots of general tidy up
MAINTAINERS | 5 + drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-int3472/Kconfig | 31 ++ drivers/platform/x86/intel-int3472/Makefile | 5 + .../intel_skl_int3472_clk_and_regulator.c | 195 +++++++++ .../intel-int3472/intel_skl_int3472_common.c | 106 +++++ .../intel-int3472/intel_skl_int3472_common.h | 113 +++++ .../intel_skl_int3472_discrete.c | 409 ++++++++++++++++++ .../intel_skl_int3472_tps68470.c | 109 +++++ 10 files changed, 976 insertions(+) create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
MAINTAINERS +5 -0
@@ -9378,6 +9378,11 @@ S: Maintained F: arch/x86/include/asm/intel_scu_ipc.h F: drivers/platform/x86/intel_scu_* +INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER +M: Daniel Scally <[email protected]> +S: Maintained +F: drivers/platform/x86/intel-int3472/intel_skl_int3472_* + INTEL SPEED SELECT TECHNOLOGY M: Srinivas Pandruvada <[email protected]> L: [email protected]
drivers/platform/x86/Kconfig +2 -0
@@ -697,6 +697,8 @@ config INTEL_CHT_INT33FE device and CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m for Type-C device. +source "drivers/platform/x86/intel-int3472/Kconfig" + config INTEL_HID_EVENT tristate "INTEL HID Event" depends on ACPI
drivers/platform/x86/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_INTEL_HID_EVENT) += intel-hid.o obj-$(CONFIG_INTEL_INT0002_VGPIO) += intel_int0002_vgpio.o obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o +obj-$(CONFIG_INTEL_SKL_INT3472) += intel-int3472/ obj-$(CONFIG_INTEL_VBTN) += intel-vbtn.o # MSI
drivers/platform/x86/intel-int3472/Kconfig new file +31 -0
@@ -0,0 +1,31 @@ +config INTEL_SKL_INT3472 + tristate "Intel SkyLake ACPI INT3472 Driver" + depends on ACPI + depends on COMMON_CLK && CLKDEV_LOOKUP + depends on I2C + depends on GPIOLIB + depends on REGULATOR + select MFD_CORE + select REGMAP_I2C + help + This driver adds support for the INT3472 ACPI devices found on some + Intel SkyLake devices. + + The INT3472 is an Intel camera power controller, a logical device + found on some Skylake-based systems that can map to different + hardware devices depending on the platform. On machines + designed for Chrome OS, it maps to a TPS68470 camera PMIC. On + machines designed for Windows, it maps to either a TP68470 + camera PMIC, a uP6641Q sensor PMIC, or a set of discrete GPIOs + and power gates. + + If your device was designed for Chrome OS, this driver will provide + an ACPI OpRegion, which must be available before any of the devices + using it are probed. For this reason, you should select Y if your + device was designed for ChromeOS. For the same reason the + I2C_DESIGNWARE_PLATFORM option must be set to Y too. + + Say Y or M here if you have a SkyLake device designed for use + with Windows or ChromeOS. Say N here if you are not sure. + + The module will be named "intel-skl-int3472"
drivers/platform/x86/intel-int3472/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472.o +intel_skl_int3472-objs := intel_skl_int3472_common.o \ + intel_skl_int3472_discrete.o \ + intel_skl_int3472_tps68470.o \ + intel_skl_int3472_clk_and_regulator.o
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +195 -0
195 lines not on this page · raw message
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c new file +106 -0
106 lines not on this page · raw message
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h new file +113 -0
113 lines not on this page · raw message
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +409 -0
409 lines not on this page · raw message
drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 8/8 mfd: tps68470: Remove tps68470 MFD driver
In reply to Daniel ScallyThis driver only covered one scenario in which ACPI devices with _HID INT3472 are found, and its functionality has been taken over by the intel-skl-int3472 module, so remove it.
---
Changes since v3:
- None
drivers/acpi/pmic/Kconfig | 2 +- drivers/gpio/Kconfig | 2 +- drivers/mfd/Kconfig | 18 -------- drivers/mfd/Makefile | 1 - drivers/mfd/tps68470.c | 97 --------------------------------------- 5 files changed, 2 insertions(+), 118 deletions(-) delete mode 100644 drivers/mfd/tps68470.c
drivers/acpi/pmic/Kconfig +1 -1
@@ -52,7 +52,7 @@ endif # PMIC_OPREGION config TPS68470_PMIC_OPREGION bool "ACPI operation region support for TPS68470 PMIC" - depends on MFD_TPS68470 + depends on INTEL_SKL_INT3472 help This config adds ACPI operation region support for TI TPS68470 PMIC. TPS68470 device is an advanced power management unit that powers
drivers/gpio/Kconfig +1 -1
@@ -1367,7 +1367,7 @@ config GPIO_TPS65912 config GPIO_TPS68470 bool "TPS68470 GPIO" - depends on MFD_TPS68470 + depends on INTEL_SKL_INT3472 help Select this option to enable GPIO driver for the TPS68470 chip family.
drivers/mfd/Kconfig +0 -18
@@ -1499,24 +1499,6 @@ config MFD_TPS65217 This driver can also be built as a module. If so, the module will be called tps65217. -config MFD_TPS68470 - bool "TI TPS68470 Power Management / LED chips" - depends on ACPI && PCI && I2C=y - depends on I2C_DESIGNWARE_PLATFORM=y - select MFD_CORE - select REGMAP_I2C - help - If you say yes here you get support for the TPS68470 series of - Power Management / LED chips. - - These include voltage regulators, LEDs and other features - that are often used in portable devices. - - This option is a bool as it provides an ACPI operation - region, which must be available before any of the devices - using this are probed. This option also configures the - designware-i2c driver to be built-in, for the same reason. - config MFD_TI_LP873X tristate "TI LP873X Power Management IC" depends on I2C
drivers/mfd/Makefile +0 -1
@@ -105,7 +105,6 @@ obj-$(CONFIG_MFD_TPS65910) += tps65910.o obj-$(CONFIG_MFD_TPS65912) += tps65912-core.o obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o -obj-$(CONFIG_MFD_TPS68470) += tps68470.o obj-$(CONFIG_MFD_TPS80031) += tps80031.o obj-$(CONFIG_MENELAUS) += menelaus.o
drivers/mfd/tps68470.c deleted +0 -97
97 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v4 1/8] ACPI: scan: Extend acpi_walk_dep_device_list()
In reply to Daniel ScallyQuoted 8 lines · Daniel Scally
The
acpi_walk_dep_device_list()is not as generalisable as its name implies, serving only to decrement the dependency count for each dependent device of the input. Extend the function to instead accept a callback which can be applied to all the dependencies inacpi_dep_list. Replace all existing calls to the function with calls to a wrapper, passing a callback that applies the same dependency reduction.Signed-off-by Daniel Scally <[email protected]>
Quoted 377 lines
---
changes since v3:- Most of the functions got renamed
-acpi_dev_get_dependent_dev()was altered to take a structacpi_deviceThis had some repurcussions in the other files, mostly switching fromACPI_HANDLE()toACPI_COMPANION().
-acpi_walk_dep_device_list()was altered to check the return value of the callback on each iteration of the loop, to allow for error handling of the callbacks or breaking the loop early to save time. Andy, Wolfram, I thought this change was significant enough to drop your R-b and Ack.drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 69 ++++++++++++++----- drivers/gpio/gpiolib-acpi.c | 10 +-- drivers/i2c/i2c-core-acpi.c | 8 +-- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +++--- .../platform/surface/surface_acpi_notify.c | 7 +- include/acpi/acpi_bus.h | 7 ++ include/linux/acpi.h | 4 +- 10 files changed, 90 insertions(+), 47 deletions(-)drivers/acpi/ec.c +1
-1@@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)WARN (!ret,"Could not request EC cmd io port 0x%lx" , ec->command_addr);/* Reprobe devices depending on the EC */ -acpi_walk_dep_device_list (ec->handle); +acpi_dev_clear_dependencies (device);acpi_handle_debug (ec->handle,"enumerated.\n" );return 0 ;drivers/acpi/pmic/intel_pmic_chtdc_ti.c +1
-1@@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)return err;/* Re-enumerate devices depending on PMIC */ -acpi_walk_dep_device_list (ACPI_HANDLE (pdev->dev.parent)); +acpi_dev_clear_dependencies (ACPI_COMPANION (pdev->dev.parent));return 0 ; }drivers/acpi/scan.c +51
-18@@ -47,12 +47,6 @@ static DEFINE_MUTEX(acpi_hp_context_lock);*/ static u64 spcr_uart_addr; -struct acpi_dep_data { -struct list_head node; -acpi_handle supplier; -acpi_handle consumer; -}; -void acpi_scan_lock_acquire (void ) {mutex_lock (&acpi_scan_lock);@@ -2111,30 +2105,69 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } -void acpi_walk_dep_device_list (acpi_handle handle) +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) { -struct acpi_dep_data *dep, *tmp;struct acpi_device *adev; +acpi_bus_get_device (dep->consumer, &adev); + +if (adev) { + adev->dep_unmet--; +if (!adev->dep_unmet) +acpi_bus_attach (adev, true); + } + +list_del (&dep->node); +kfree (dep); + +return 0 ; +} + +/** +* acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list +* @handle: The ACPI handle of the supplier device +* @callback: Pointer to the callback function to apply +* @data: Pointer to some data to pass to the callback +* +* The return value of the callback determines this function's behaviour. If 0 +* is returned we continue to iterate over acpi_dep_list. If a positive value +* is returned then the loop is broken but this function returns 0. If a +* negative value is returned by the callback then the loop is broken and that +* value is returned as the final error. +*/ +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data) +{ +struct acpi_dep_data *dep, *tmp; +int ret; +mutex_lock (&acpi_dep_list_lock);list_for_each_entry_safe (dep, tmp, &acpi_dep_list, node) {if (dep->supplier == handle) { -acpi_bus_get_device (dep->consumer, &adev); - -if (adev) { - adev->dep_unmet--; -if (!adev->dep_unmet) -acpi_bus_attach (adev, true); - } - -list_del (&dep->node); -kfree (dep); + ret =callback (dep, data); +if (ret) +break ; } }mutex_unlock (&acpi_dep_list_lock); + +return ret >0 ?0 : ret; }EXPORT_SYMBOL_GPL (acpi_walk_dep_device_list); +/** +* acpi_dev_clear_dependencies - Inform consumers that the device is now active +* @supplier: Pointer to the supplier &struct acpi_device +* +* Clear dependencies on the given device. +*/ +void acpi_dev_clear_dependencies (struct acpi_device *supplier) +{ +acpi_walk_dep_device_list (supplier->handle, acpi_scan_clear_dep,NULL ); +} +EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. drivers/gpio/gpiolib-acpi.c +5
-5@@ -1233,14 +1233,14 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)void acpi_gpiochip_add (struct gpio_chip *chip) {struct acpi_gpio_chip *acpi_gpio; -acpi_handle handle; +struct acpi_device *adev;acpi_status status;if (!chip || !chip->parent)return ; - handle =ACPI_HANDLE (chip->parent); -if (!handle) + adev =ACPI_COMPANION (chip->parent); +if (!adev)return ; acpi_gpio =kzalloc (sizeof (*acpi_gpio),GFP_KERNEL );@@ -1254,7 +1254,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)INIT_LIST_HEAD (&acpi_gpio->events);INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); - status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio); + status =acpi_attach_data (adev->handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {dev_err (chip->parent,"Failed to attach ACPI GPIO chip\n" );kfree (acpi_gpio);@@ -1263,7 +1263,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio); -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }void acpi_gpiochip_remove (struct gpio_chip *chip)drivers/i2c/i2c-core-acpi.c +4
-4@@ -259,8 +259,8 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,*/ void i2c_acpi_register_devices (struct i2c_adapter *adap) { +struct acpi_device *adev;acpi_status status; -acpi_handle handle;if (!has_acpi_companion (&adap->dev))return ;@@ -275,11 +275,11 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)if (!adap->dev.parent)return ; - handle =ACPI_HANDLE (adap->dev.parent); -if (!handle) + adev =ACPI_COMPANION (adap->dev.parent); +if (!adev)return ; -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {drivers/platform/surface/aggregator/core.c +3
-3@@ -621,8 +621,8 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {static int ssam_serial_hub_probe (struct serdev_device *serdev) { +struct acpi_device *ssh =ACPI_COMPANION (&serdev->dev);struct ssam_controller *ctrl; -acpi_handle *ssh =ACPI_HANDLE (&serdev->dev);acpi_status astatus;int status;@@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)if (status) goto err_devopen; - astatus =ssam_serdev_setup_via_acpi (ssh, serdev); + astatus =ssam_serdev_setup_via_acpi (ssh->handle, serdev);if (ACPI_FAILURE (astatus)) { status = -ENXIO ; goto err_devinit;@@ -706,7 +706,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)* For now let's thus default power/wakeup to false. */ device_set_wakeup_capable (&serdev->dev, true); -acpi_walk_dep_device_list (ssh); +acpi_dev_clear_dependencies (ssh);return 0 ;drivers/platform/surface/surface3_power.c +11
-11@@ -446,12 +446,12 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,static int mshw0011_install_space_handler (struct i2c_client *client) { -acpi_handle handle; +struct acpi_device *adev;struct mshw0011_handler_data *data;acpi_status status; - handle =ACPI_HANDLE (&client->dev); -if (!handle) + adev =ACPI_COMPANION (&client->dev); +if (!adev)return -ENODEV ; data = kzalloc(sizeof(struct mshw0011_handler_data),@@ -460,25 +460,25 @@ static int mshw0011_install_space_handler(struct i2c_client *client)return -ENOMEM ; data->client = client; - status =acpi_bus_attach_private_data (handle, (void *)data); + status =acpi_bus_attach_private_data (adev->handle, (void *)data);if (ACPI_FAILURE (status)) {kfree (data);return -ENOMEM ; } - status =acpi_install_address_space_handler (handle, -ACPI_ADR_SPACE_GSBUS , - &mshw0011_space_handler, -NULL , - data); + status =acpi_install_address_space_handler (adev->handle, +ACPI_ADR_SPACE_GSBUS , + &mshw0011_space_handler, +NULL , + data);if (ACPI_FAILURE (status)) {dev_err (&client->dev,"Error installing i2c space handler\n" ); -acpi_bus_detach_private_data (handle); +acpi_bus_detach_private_data (adev->handle);kfree (data);return -ENOMEM ; } -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev);return 0 ; }drivers/platform/surface/surface_acpi_notify.c +4
-3@@ -798,7 +798,7 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -acpi_handle san =ACPI_HANDLE (&pdev->dev); +struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl;struct san_data *data;acpi_status astatus;@@ -821,7 +821,8 @@ static int san_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); - astatus =acpi_install_address_space_handler (san,ACPI_ADR_SPACE_GSBUS , + astatus =acpi_install_address_space_handler (san->handle, +ACPI_ADR_SPACE_GSBUS , &san_opreg_handler,NULL , &data->info);if (ACPI_FAILURE (astatus))@@ -835,7 +836,7 @@ static int san_probe(struct platform_device *pdev)if (status) goto err_install_dev; -acpi_walk_dep_device_list (san); +acpi_dev_clear_dependencies (san);return 0 ; err_install_dev:include/acpi/acpi_bus.h +7
-0@@ -280,6 +280,12 @@ struct acpi_device_power {struct acpi_device_power_state states[ACPI_D_STATE_COUNT ];/* Power states (D0-D3Cold) */ }; +struct acpi_dep_data { +struct list_head node; +acpi_handle supplier; +acpi_handle consumer; +}; +/* Performance Management */ struct acpi_device_perf_flags {@@ -685,6 +691,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2); +void acpi_dev_clear_dependencies (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *include/linux/acpi.h +3
-1@@ -666,7 +666,9 @@ extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv);int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); -void acpi_walk_dep_device_list (acpi_handle handle); +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data);struct platform_device *acpi_create_platform_device (struct acpi_device *,struct property_entry *);
Rafael J. Wysocki
maintainerRe: [PATCH v4 1/8] ACPI: scan: Extend acpi_walk_dep_device_list()
In reply to Daniel ScallyQuoted 9 lines · Daniel Scally
The
acpi_walk_dep_device_list()is not as generalisable as its name implies, serving only to decrement the dependency count for each dependent device of the input. Extend the function to instead accept a callback which can be applied to all the dependencies inacpi_dep_list. Replace all existing calls to the function with calls to a wrapper, passing a callback that applies the same dependency reduction.Signed-off-by Daniel Scally <djrscally(a)gmail.com>
LGTM, but I will have changes depending on it.
If that's fine by Hans, I'll take this one and expose it in a git branch that won't be rebased.
Quoted 379 lines
---
changes since v3:- Most of the functions got renamed
-acpi_dev_get_dependent_dev()was altered to take a structacpi_deviceThis had some repurcussions in the other files, mostly switching fromACPI_HANDLE()toACPI_COMPANION().
-acpi_walk_dep_device_list()was altered to check the return value of the callback on each iteration of the loop, to allow for error handling of the callbacks or breaking the loop early to save time. Andy, Wolfram, I thought this change was significant enough to drop your R-b and Ack.drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 69 ++++++++++++++----- drivers/gpio/gpiolib-acpi.c | 10 +-- drivers/i2c/i2c-core-acpi.c | 8 +-- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +++--- .../platform/surface/surface_acpi_notify.c | 7 +- include/acpi/acpi_bus.h | 7 ++ include/linux/acpi.h | 4 +- 10 files changed, 90 insertions(+), 47 deletions(-)drivers/acpi/ec.c +1
-1@@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)WARN (!ret,"Could not request EC cmd io port 0x%lx" , ec->command_addr);/* Reprobe devices depending on the EC */ -acpi_walk_dep_device_list (ec->handle); +acpi_dev_clear_dependencies (device);acpi_handle_debug (ec->handle,"enumerated.\n" );return 0 ;drivers/acpi/pmic/intel_pmic_chtdc_ti.c +1
-1@@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)return err;/* Re-enumerate devices depending on PMIC */ -acpi_walk_dep_device_list (ACPI_HANDLE (pdev->dev.parent)); +acpi_dev_clear_dependencies (ACPI_COMPANION (pdev->dev.parent));return 0 ; }drivers/acpi/scan.c +51
-18@@ -47,12 +47,6 @@ static DEFINE_MUTEX(acpi_hp_context_lock);*/ static u64 spcr_uart_addr; -struct acpi_dep_data { -struct list_head node; -acpi_handle supplier; -acpi_handle consumer; -}; -void acpi_scan_lock_acquire (void ) {mutex_lock (&acpi_scan_lock);@@ -2111,30 +2105,69 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } -void acpi_walk_dep_device_list (acpi_handle handle) +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) { -struct acpi_dep_data *dep, *tmp;struct acpi_device *adev; +acpi_bus_get_device (dep->consumer, &adev); + +if (adev) { + adev->dep_unmet--; +if (!adev->dep_unmet) +acpi_bus_attach (adev, true); + } + +list_del (&dep->node); +kfree (dep); + +return 0 ; +} + +/** +* acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list +* @handle: The ACPI handle of the supplier device +* @callback: Pointer to the callback function to apply +* @data: Pointer to some data to pass to the callback +* +* The return value of the callback determines this function's behaviour. If 0 +* is returned we continue to iterate over acpi_dep_list. If a positive value +* is returned then the loop is broken but this function returns 0. If a +* negative value is returned by the callback then the loop is broken and that +* value is returned as the final error. +*/ +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data) +{ +struct acpi_dep_data *dep, *tmp; +int ret; +mutex_lock (&acpi_dep_list_lock);list_for_each_entry_safe (dep, tmp, &acpi_dep_list, node) {if (dep->supplier == handle) { -acpi_bus_get_device (dep->consumer, &adev); - -if (adev) { - adev->dep_unmet--; -if (!adev->dep_unmet) -acpi_bus_attach (adev, true); - } - -list_del (&dep->node); -kfree (dep); + ret =callback (dep, data); +if (ret) +break ; } }mutex_unlock (&acpi_dep_list_lock); + +return ret >0 ?0 : ret; }EXPORT_SYMBOL_GPL (acpi_walk_dep_device_list); +/** +* acpi_dev_clear_dependencies - Inform consumers that the device is now active +* @supplier: Pointer to the supplier &struct acpi_device +* +* Clear dependencies on the given device. +*/ +void acpi_dev_clear_dependencies (struct acpi_device *supplier) +{ +acpi_walk_dep_device_list (supplier->handle, acpi_scan_clear_dep,NULL ); +} +EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. drivers/gpio/gpiolib-acpi.c +5
-5@@ -1233,14 +1233,14 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)void acpi_gpiochip_add (struct gpio_chip *chip) {struct acpi_gpio_chip *acpi_gpio; -acpi_handle handle; +struct acpi_device *adev;acpi_status status;if (!chip || !chip->parent)return ; - handle =ACPI_HANDLE (chip->parent); -if (!handle) + adev =ACPI_COMPANION (chip->parent); +if (!adev)return ; acpi_gpio =kzalloc (sizeof (*acpi_gpio),GFP_KERNEL );@@ -1254,7 +1254,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)INIT_LIST_HEAD (&acpi_gpio->events);INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); - status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio); + status =acpi_attach_data (adev->handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {dev_err (chip->parent,"Failed to attach ACPI GPIO chip\n" );kfree (acpi_gpio);@@ -1263,7 +1263,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio); -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }void acpi_gpiochip_remove (struct gpio_chip *chip)drivers/i2c/i2c-core-acpi.c +4
-4@@ -259,8 +259,8 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,*/ void i2c_acpi_register_devices (struct i2c_adapter *adap) { +struct acpi_device *adev;acpi_status status; -acpi_handle handle;if (!has_acpi_companion (&adap->dev))return ;@@ -275,11 +275,11 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)if (!adap->dev.parent)return ; - handle =ACPI_HANDLE (adap->dev.parent); -if (!handle) + adev =ACPI_COMPANION (adap->dev.parent); +if (!adev)return ; -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {drivers/platform/surface/aggregator/core.c +3
-3@@ -621,8 +621,8 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {static int ssam_serial_hub_probe (struct serdev_device *serdev) { +struct acpi_device *ssh =ACPI_COMPANION (&serdev->dev);struct ssam_controller *ctrl; -acpi_handle *ssh =ACPI_HANDLE (&serdev->dev);acpi_status astatus;int status;@@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)if (status) goto err_devopen; - astatus =ssam_serdev_setup_via_acpi (ssh, serdev); + astatus =ssam_serdev_setup_via_acpi (ssh->handle, serdev);if (ACPI_FAILURE (astatus)) { status = -ENXIO ; goto err_devinit;@@ -706,7 +706,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)* For now let's thus default power/wakeup to false. */ device_set_wakeup_capable (&serdev->dev, true); -acpi_walk_dep_device_list (ssh); +acpi_dev_clear_dependencies (ssh);return 0 ;drivers/platform/surface/surface3_power.c +11
-11@@ -446,12 +446,12 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,static int mshw0011_install_space_handler (struct i2c_client *client) { -acpi_handle handle; +struct acpi_device *adev;struct mshw0011_handler_data *data;acpi_status status; - handle =ACPI_HANDLE (&client->dev); -if (!handle) + adev =ACPI_COMPANION (&client->dev); +if (!adev)return -ENODEV ; data = kzalloc(sizeof(struct mshw0011_handler_data),@@ -460,25 +460,25 @@ static int mshw0011_install_space_handler(struct i2c_client *client)return -ENOMEM ; data->client = client; - status =acpi_bus_attach_private_data (handle, (void *)data); + status =acpi_bus_attach_private_data (adev->handle, (void *)data);if (ACPI_FAILURE (status)) {kfree (data);return -ENOMEM ; } - status =acpi_install_address_space_handler (handle, -ACPI_ADR_SPACE_GSBUS , - &mshw0011_space_handler, -NULL , - data); + status =acpi_install_address_space_handler (adev->handle, +ACPI_ADR_SPACE_GSBUS , + &mshw0011_space_handler, +NULL , + data);if (ACPI_FAILURE (status)) {dev_err (&client->dev,"Error installing i2c space handler\n" ); -acpi_bus_detach_private_data (handle); +acpi_bus_detach_private_data (adev->handle);kfree (data);return -ENOMEM ; } -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev);return 0 ; }drivers/platform/surface/surface_acpi_notify.c +4
-3@@ -798,7 +798,7 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -acpi_handle san =ACPI_HANDLE (&pdev->dev); +struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl;struct san_data *data;acpi_status astatus;@@ -821,7 +821,8 @@ static int san_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); - astatus =acpi_install_address_space_handler (san,ACPI_ADR_SPACE_GSBUS , + astatus =acpi_install_address_space_handler (san->handle, +ACPI_ADR_SPACE_GSBUS , &san_opreg_handler,NULL , &data->info);if (ACPI_FAILURE (astatus))@@ -835,7 +836,7 @@ static int san_probe(struct platform_device *pdev)if (status) goto err_install_dev; -acpi_walk_dep_device_list (san); +acpi_dev_clear_dependencies (san);return 0 ; err_install_dev:include/acpi/acpi_bus.h +7
-0@@ -280,6 +280,12 @@ struct acpi_device_power {struct acpi_device_power_state states[ACPI_D_STATE_COUNT ];/* Power states (D0-D3Cold) */ }; +struct acpi_dep_data { +struct list_head node; +acpi_handle supplier; +acpi_handle consumer; +}; +/* Performance Management */ struct acpi_device_perf_flags {@@ -685,6 +691,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2); +void acpi_dev_clear_dependencies (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *include/linux/acpi.h +3
-2@@ -666,7 +666,9 @@ extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv);int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); -void acpi_walk_dep_device_list (acpi_handle handle); +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data);struct platform_device *acpi_create_platform_device (struct acpi_device *,struct property_entry *); --2.25.1
Rafael J. Wysocki
maintainerRe: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device
In reply to Daniel ScallyQuoted 23 lines · Daniel Scally
In some ACPI tables we encounter, devices use the
_DEPmethod to assert a dependence on other ACPI devices as opposed to the OpRegions that the specification intends. We need to be able to find those devices "from" the dependee, so add a callback and a wrapper to walk over theacpi_dep_listand return the dependent ACPI device.Reviewed-by Andy Shevchenko <andy.shevchenko(a)gmail.com>Signed-off-by Daniel Scally <djrscally(a)gmail.com>---
Changes since v3:Both new functions were renamed.
drivers/acpi/scan.c | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 39 insertions(+)drivers/acpi/scan.c +0
-0
drivers/acpi/scan.c static void acpi_bus_attach(struct acpi_device *device, bool first_pass) · line 2108
Quoted 4 lines
drivers/acpi/scan.c +1
-0@@ -2105,6 +2105,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } +static int acpi_return_dep_dev (struct acpi_dep_data *dep,void *data)
What about calling this acpi_get_first_consumer_cb()?
drivers/acpi/scan.c static void acpi_bus_attach(struct acpi_device *device, bool first_pass) · line 2118
Quoted 10 lines
drivers/acpi/scan.c +10
-0+{ +struct acpi_device *adev; +int ret; + + ret =acpi_bus_get_device (dep->consumer, &adev); +if (ret) +/* If we don't find an adev then we want to continue parsing */ +return 0 ; + + *(struct acpi_device **)data = adev;
And it can do the get_device() here, can't it?
So maybe use acpi_bus_get_acpi_device() instead of acpi_bus_get_device()? Would be simpler.
drivers/acpi/scan.c void acpi_dev_clear_dependencies(struct acpi_device *supplier) · line 2187
Quoted 13 lines
drivers/acpi/scan.c +6
-0+ +return 1 ; +} +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) {struct acpi_device *adev;@@ -2168,6 +2183,29 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier) }EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** +* acpi_dev_get_dependent_dev - Return ACPI device dependent on @supplier
And what about calling this acpi_get_first_consumer() ?
Quoted 39 lines
drivers/acpi/scan.c +21
-0+* @supplier: Pointer to the dependee device +* +* Returns the first &struct acpi_device which declares itself dependent on +* @supplier via the _DEP buffer, parsed from the acpi_dep_list. +* +* The caller is responsible for putting the reference to adev when it is no +* longer needed. +*/ +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier) +{ +struct acpi_device *adev =NULL ; + +acpi_walk_dep_device_list (supplier->handle, acpi_return_dep_dev, &adev); + +if (adev) +get_device (&adev->dev); + +return adev; +} +EXPORT_SYMBOL_GPL (acpi_dev_get_dependent_dev); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. include/acpi/acpi_bus.h +1
-1@@ -692,6 +692,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2);void acpi_dev_clear_dependencies (struct acpi_device *supplier); +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device * --2.25.1
Rafael J. Wysocki
maintainerRe: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device
Quoted 28 lines · Rafael J. Wysocki
Quoted 26 lines · Daniel Scally
In some ACPI tables we encounter, devices use the
_DEPmethod to assert a dependence on other ACPI devices as opposed to the OpRegions that the specification intends. We need to be able to find those devices "from" the dependee, so add a callback and a wrapper to walk over theacpi_dep_listand return the dependent ACPI device.Reviewed-by Andy Shevchenko <andy.shevchenko(a)gmail.com>Signed-off-by Daniel Scally <djrscally(a)gmail.com>---
Changes since v3:Both new functions were renamed.
drivers/acpi/scan.c | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 39 insertions(+)drivers/acpi/scan.c +0
-0@@ -2105,6 +2105,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); }
Quoted 3 lines
drivers/acpi/scan.c static void acpi_bus_attach(struct acpi_device *device, bool first_pass) · line 2108
Quoted 1 line
drivers/acpi/scan.c +1
-0+static int acpi_return_dep_dev (struct acpi_dep_data *dep,void *data)What about calling this
acpi_get_first_consumer_cb()?
Or acpi_dev_get_first_consumer_dev_cb() if you want to be super-precise?
Quoted 28 lines
drivers/acpi/scan.c static void acpi_bus_attach(struct acpi_device *device, bool first_pass) · line 2118
Quoted 11 lines
drivers/acpi/scan.c +10
-0+{ +struct acpi_device *adev; +int ret; + + ret =acpi_bus_get_device (dep->consumer, &adev); +if (ret) +/* If we don't find an adev then we want to continue parsing */ +return 0 ; + + *(struct acpi_device **)data = adev;And it can do the
get_device()here, can't it?So maybe use
acpi_bus_get_acpi_device()instead ofacpi_bus_get_device()? Would be simpler.Quoted 11 lines
drivers/acpi/scan.c +4
-0+ +return 1 ; +} +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) {struct acpi_device *adev;@@ -2168,6 +2183,29 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier) }EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies);
Quoted 4 lines
drivers/acpi/scan.c void acpi_dev_clear_dependencies(struct acpi_device *supplier) · line 2187
Quoted 2 lines
drivers/acpi/scan.c +2
-0+/** +* acpi_dev_get_dependent_dev - Return ACPI device dependent on @supplier And what about calling this
acpi_get_first_consumer()?
Or acpi_dev_get_first_consumer_dev() (in analogy with the above)?
Quoted 39 lines
Quoted 39 lines
drivers/acpi/scan.c +21
-0+* @supplier: Pointer to the dependee device +* +* Returns the first &struct acpi_device which declares itself dependent on +* @supplier via the _DEP buffer, parsed from the acpi_dep_list. +* +* The caller is responsible for putting the reference to adev when it is no +* longer needed. +*/ +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier) +{ +struct acpi_device *adev =NULL ; + +acpi_walk_dep_device_list (supplier->handle, acpi_return_dep_dev, &adev); + +if (adev) +get_device (&adev->dev); + +return adev; +} +EXPORT_SYMBOL_GPL (acpi_dev_get_dependent_dev); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. include/acpi/acpi_bus.h +1
-1@@ -692,6 +692,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2);void acpi_dev_clear_dependencies (struct acpi_device *supplier); +struct acpi_device *acpi_dev_get_dependent_dev (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device * --2.25.1
Re: [PATCH v4 1/8] ACPI: scan: Extend acpi_walk_dep_device_list()
In reply to Rafael J. WysockiHi,
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Daniel Scally
The
acpi_walk_dep_device_list()is not as generalisable as its name implies, serving only to decrement the dependency count for each dependent device of the input. Extend the function to instead accept a callback which can be applied to all the dependencies inacpi_dep_list. Replace all existing calls to the function with calls to a wrapper, passing a callback that applies the same dependency reduction.
Quoted 6 lines
Quoted 1 line
Signed-off-by Daniel Scally <[email protected]>LGTM, but I will have changes depending on it.
If that's fine by Hans, I'll take this one and expose it in a git branch that won't be rebased.
Yes that is fine by me, just send me a pull-req when the branch is ready and I'll merge that into pdx86/for-next.
Regards,
Hans
Quoted 381 lines
Quoted 380 lines
---
changes since v3:- Most of the functions got renamed
-acpi_dev_get_dependent_dev()was altered to take a structacpi_deviceThis had some repurcussions in the other files, mostly switching fromACPI_HANDLE()toACPI_COMPANION().
-acpi_walk_dep_device_list()was altered to check the return value of the callback on each iteration of the loop, to allow for error handling of the callbacks or breaking the loop early to save time. Andy, Wolfram, I thought this change was significant enough to drop your R-b and Ack.drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 69 ++++++++++++++----- drivers/gpio/gpiolib-acpi.c | 10 +-- drivers/i2c/i2c-core-acpi.c | 8 +-- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +++--- .../platform/surface/surface_acpi_notify.c | 7 +- include/acpi/acpi_bus.h | 7 ++ include/linux/acpi.h | 4 +- 10 files changed, 90 insertions(+), 47 deletions(-)drivers/acpi/ec.c +1
-1@@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)WARN (!ret,"Could not request EC cmd io port 0x%lx" , ec->command_addr);/* Reprobe devices depending on the EC */ -acpi_walk_dep_device_list (ec->handle); +acpi_dev_clear_dependencies (device);acpi_handle_debug (ec->handle,"enumerated.\n" );return 0 ;drivers/acpi/pmic/intel_pmic_chtdc_ti.c +1
-1@@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)return err;/* Re-enumerate devices depending on PMIC */ -acpi_walk_dep_device_list (ACPI_HANDLE (pdev->dev.parent)); +acpi_dev_clear_dependencies (ACPI_COMPANION (pdev->dev.parent));return 0 ; }drivers/acpi/scan.c +51
-18@@ -47,12 +47,6 @@ static DEFINE_MUTEX(acpi_hp_context_lock);*/ static u64 spcr_uart_addr; -struct acpi_dep_data { -struct list_head node; -acpi_handle supplier; -acpi_handle consumer; -}; -void acpi_scan_lock_acquire (void ) {mutex_lock (&acpi_scan_lock);@@ -2111,30 +2105,69 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } -void acpi_walk_dep_device_list (acpi_handle handle) +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) { -struct acpi_dep_data *dep, *tmp;struct acpi_device *adev; +acpi_bus_get_device (dep->consumer, &adev); + +if (adev) { + adev->dep_unmet--; +if (!adev->dep_unmet) +acpi_bus_attach (adev, true); + } + +list_del (&dep->node); +kfree (dep); + +return 0 ; +} + +/** +* acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list +* @handle: The ACPI handle of the supplier device +* @callback: Pointer to the callback function to apply +* @data: Pointer to some data to pass to the callback +* +* The return value of the callback determines this function's behaviour. If 0 +* is returned we continue to iterate over acpi_dep_list. If a positive value +* is returned then the loop is broken but this function returns 0. If a +* negative value is returned by the callback then the loop is broken and that +* value is returned as the final error. +*/ +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data) +{ +struct acpi_dep_data *dep, *tmp; +int ret; +mutex_lock (&acpi_dep_list_lock);list_for_each_entry_safe (dep, tmp, &acpi_dep_list, node) {if (dep->supplier == handle) { -acpi_bus_get_device (dep->consumer, &adev); - -if (adev) { - adev->dep_unmet--; -if (!adev->dep_unmet) -acpi_bus_attach (adev, true); - } - -list_del (&dep->node); -kfree (dep); + ret =callback (dep, data); +if (ret) +break ; } }mutex_unlock (&acpi_dep_list_lock); + +return ret >0 ?0 : ret; }EXPORT_SYMBOL_GPL (acpi_walk_dep_device_list); +/** +* acpi_dev_clear_dependencies - Inform consumers that the device is now active +* @supplier: Pointer to the supplier &struct acpi_device +* +* Clear dependencies on the given device. +*/ +void acpi_dev_clear_dependencies (struct acpi_device *supplier) +{ +acpi_walk_dep_device_list (supplier->handle, acpi_scan_clear_dep,NULL ); +} +EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. drivers/gpio/gpiolib-acpi.c +5
-5@@ -1233,14 +1233,14 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)void acpi_gpiochip_add (struct gpio_chip *chip) {struct acpi_gpio_chip *acpi_gpio; -acpi_handle handle; +struct acpi_device *adev;acpi_status status;if (!chip || !chip->parent)return ; - handle =ACPI_HANDLE (chip->parent); -if (!handle) + adev =ACPI_COMPANION (chip->parent); +if (!adev)return ; acpi_gpio =kzalloc (sizeof (*acpi_gpio),GFP_KERNEL );@@ -1254,7 +1254,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)INIT_LIST_HEAD (&acpi_gpio->events);INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); - status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio); + status =acpi_attach_data (adev->handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {dev_err (chip->parent,"Failed to attach ACPI GPIO chip\n" );kfree (acpi_gpio);@@ -1263,7 +1263,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio); -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }void acpi_gpiochip_remove (struct gpio_chip *chip)drivers/i2c/i2c-core-acpi.c +4
-4@@ -259,8 +259,8 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,*/ void i2c_acpi_register_devices (struct i2c_adapter *adap) { +struct acpi_device *adev;acpi_status status; -acpi_handle handle;if (!has_acpi_companion (&adap->dev))return ;@@ -275,11 +275,11 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)if (!adap->dev.parent)return ; - handle =ACPI_HANDLE (adap->dev.parent); -if (!handle) + adev =ACPI_COMPANION (adap->dev.parent); +if (!adev)return ; -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {drivers/platform/surface/aggregator/core.c +3
-3@@ -621,8 +621,8 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {static int ssam_serial_hub_probe (struct serdev_device *serdev) { +struct acpi_device *ssh =ACPI_COMPANION (&serdev->dev);struct ssam_controller *ctrl; -acpi_handle *ssh =ACPI_HANDLE (&serdev->dev);acpi_status astatus;int status;@@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)if (status) goto err_devopen; - astatus =ssam_serdev_setup_via_acpi (ssh, serdev); + astatus =ssam_serdev_setup_via_acpi (ssh->handle, serdev);if (ACPI_FAILURE (astatus)) { status = -ENXIO ; goto err_devinit;@@ -706,7 +706,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)* For now let's thus default power/wakeup to false. */ device_set_wakeup_capable (&serdev->dev, true); -acpi_walk_dep_device_list (ssh); +acpi_dev_clear_dependencies (ssh);return 0 ;drivers/platform/surface/surface3_power.c +11
-11@@ -446,12 +446,12 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,static int mshw0011_install_space_handler (struct i2c_client *client) { -acpi_handle handle; +struct acpi_device *adev;struct mshw0011_handler_data *data;acpi_status status; - handle =ACPI_HANDLE (&client->dev); -if (!handle) + adev =ACPI_COMPANION (&client->dev); +if (!adev)return -ENODEV ; data = kzalloc(sizeof(struct mshw0011_handler_data),@@ -460,25 +460,25 @@ static int mshw0011_install_space_handler(struct i2c_client *client)return -ENOMEM ; data->client = client; - status =acpi_bus_attach_private_data (handle, (void *)data); + status =acpi_bus_attach_private_data (adev->handle, (void *)data);if (ACPI_FAILURE (status)) {kfree (data);return -ENOMEM ; } - status =acpi_install_address_space_handler (handle, -ACPI_ADR_SPACE_GSBUS , - &mshw0011_space_handler, -NULL , - data); + status =acpi_install_address_space_handler (adev->handle, +ACPI_ADR_SPACE_GSBUS , + &mshw0011_space_handler, +NULL , + data);if (ACPI_FAILURE (status)) {dev_err (&client->dev,"Error installing i2c space handler\n" ); -acpi_bus_detach_private_data (handle); +acpi_bus_detach_private_data (adev->handle);kfree (data);return -ENOMEM ; } -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev);return 0 ; }drivers/platform/surface/surface_acpi_notify.c +4
-3@@ -798,7 +798,7 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -acpi_handle san =ACPI_HANDLE (&pdev->dev); +struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl;struct san_data *data;acpi_status astatus;@@ -821,7 +821,8 @@ static int san_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); - astatus =acpi_install_address_space_handler (san,ACPI_ADR_SPACE_GSBUS , + astatus =acpi_install_address_space_handler (san->handle, +ACPI_ADR_SPACE_GSBUS , &san_opreg_handler,NULL , &data->info);if (ACPI_FAILURE (astatus))@@ -835,7 +836,7 @@ static int san_probe(struct platform_device *pdev)if (status) goto err_install_dev; -acpi_walk_dep_device_list (san); +acpi_dev_clear_dependencies (san);return 0 ; err_install_dev:include/acpi/acpi_bus.h +7
-0@@ -280,6 +280,12 @@ struct acpi_device_power {struct acpi_device_power_state states[ACPI_D_STATE_COUNT ];/* Power states (D0-D3Cold) */ }; +struct acpi_dep_data { +struct list_head node; +acpi_handle supplier; +acpi_handle consumer; +}; +/* Performance Management */ struct acpi_device_perf_flags {@@ -685,6 +691,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2); +void acpi_dev_clear_dependencies (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *include/linux/acpi.h +3
-2@@ -666,7 +666,9 @@ extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv);int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); -void acpi_walk_dep_device_list (acpi_handle handle); +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data);struct platform_device *acpi_create_platform_device (struct acpi_device *,struct property_entry *); --2.25.1
Re: [PATCH v4 6/8] gpiolib: acpi: Add acpi_gpio_get_io_resource()
In reply to Daniel ScallyQuoted 2 lines · Daniel Scally
Add a function to verify that a given
acpi_resourcerepresents an IO type GPIO resource, and return it if so.
Quoted 71 lines
Signed-off-by Daniel Scally <[email protected]>---
Changes since v3:
- Patch introduceddrivers/gpio/gpiolib-acpi.c | 23 +++++++++++++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 30 insertions(+)drivers/gpio/gpiolib-acpi.c +23
-0@@ -196,6 +196,29 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, }EXPORT_SYMBOL_GPL (acpi_gpio_get_irq_resource); +/** +* acpi_gpio_get_io_resource - Fetch details of an ACPI resource if it is a GPIO +* I/O resource or return False if not. +* @ares: Pointer to the ACPI resource to fetch +* @agpio: Pointer to a &struct acpi_resource_gpio to store the output pointer +*/ +bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio) +{ +struct acpi_resource_gpio *gpio; + +if (ares->type !=ACPI_RESOURCE_TYPE_GPIO ) +return false; + + gpio = &ares->data.gpio; +if (gpio->connection_type !=ACPI_RESOURCE_GPIO_TYPE_IO ) +return false; + + *agpio = gpio; +return true; +} +EXPORT_SYMBOL_GPL (acpi_gpio_get_io_resource); +static void acpi_gpiochip_request_irq (struct acpi_gpio_chip *acpi_gpio,struct acpi_gpio_event *event) {include/linux/acpi.h +7
-0@@ -1098,6 +1098,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c#if defined(CONFIG_ACPI ) && defined(CONFIG_GPIOLIB )bool acpi_gpio_get_irq_resource (struct acpi_resource *ares,struct acpi_resource_gpio **agpio); +bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio);int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name,int index);#else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,@@ -1105,6 +1107,11 @@ static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, {return false; } +static inline bool acpi_gpio_get_io_resource (struct acpi_resource *ares, +struct acpi_resource_gpio **agpio) +{ +return false; +}static inline int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name,int index) {Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 7/8] platform/x86: Add intel_skl_int3472 driver
In reply to Daniel ScallyQuoted 18 lines · Daniel Scally
ACPI devices with
_HIDINT3472 are currently matched to the tps68470 driver, however this does not cover all situations in which that_HIDoccurs. We've encountered three possibilities:1. On Chrome OS devices, an ACPI device with
_HIDINT3472 (representing a physical TPS68470 device) that requires a GPIO and OpRegion driver
2. On devices designed for Windows, an ACPI device with_HIDINT3472 (again representing a physical TPS68470 device) which requires GPIO, Clock and Regulator drivers.
3. On other devices designed for Windows, an ACPI device with_HIDINT3472 which does **not** represent a physical TPS68470, and is instead used as a dummy device to group some system GPIO lines which are meant to be consumed by the sensor that is dependent on this entry.This commit adds a new module, registering a platform driver to deal with the 3rd scenario plus an i2c driver to deal with #1 and #2, by querying the CLDB buffer found against INT3472 entries to determine which is most appropriate.
...
Quoted 7 lines
create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
I would rather see this under .../intel/int3472/ but this we may do later on.
...
MAINTAINERS S: Maintained · line 9384
Quoted 4 lines
MAINTAINERS +4
-0+INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER +M: Daniel Scally <[email protected]> +S: Maintained +F: drivers/platform/x86/intel-int3472/intel_skl_int3472_*
F: drivers/platform/x86/intel-int3472/
Should be sufficient.
...
drivers/platform/x86/intel-int3472/Kconfig line 12
Quoted 3 lines
drivers/platform/x86/intel-int3472/Kconfig new file +3
-0+ help + This driver adds support for the INT3472 ACPI devices found on some + Intel SkyLake devices.
I would rephrase this
"This driver adds power controller support for the Intel SkyCam devices found on the Intel SkyLake platforms."
(Technically speaking this IP is in the entire CPU family, but may be switched
off)
It's also possible to google for better text based on what Windows says about it.
drivers/platform/x86/intel-int3472/Kconfig line 15
Quoted 2 lines
drivers/platform/x86/intel-int3472/Kconfig new file +2
-0+ The INT3472 is an Intel camera power controller, a logical device + found on some Skylake-based systems that can map to different
"The INT3472 is a camera power controller, a logical device found on some Intel Skylake-based systems that can map to different..."
Quoted 6 lines
drivers/platform/x86/intel-int3472/Kconfig new file +6
-0+ hardware devices depending on the platform. On machines + designed for Chrome OS, it maps to a TPS68470 camera PMIC. On + machines designed for Windows, it maps to either a TP68470 + camera PMIC, a uP6641Q sensor PMIC, or a set of discrete GPIOs + and power gates. +
drivers/platform/x86/intel-int3472/Kconfig line 31
Quoted 10 lines
drivers/platform/x86/intel-int3472/Kconfig new file +10
-0+ If your device was designed for Chrome OS, this driver will provide + an ACPI OpRegion, which must be available before any of the devices + using it are probed. For this reason, you should select Y if your + device was designed for ChromeOS. For the same reason the + I2C_DESIGNWARE_PLATFORM option must be set to Y too. + + Say Y or M here if you have a SkyLake device designed for use + with Windows or ChromeOS. Say N here if you are not sure. + + The module will be named "intel-skl-int3472"
Period missed.
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 19
Quoted 6 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +6
-0+/* +* The regulators have to have .ops to be valid, but the only ops we actually +* support are .enable and .disable which are handled via .ena_gpiod. Pass an +* empty struct to clear the check without lying about capabilities. +*/ +static const struct regulator_ops int3472_gpio_regulator_ops;
Hmm... Can you use 'reg-fixed-voltage' platform device instead?
One example, although gone from upstream, but available in the tree, I can point to is this:
git log -p -- arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
It uses constant structures, but I think you may dynamically generate the necessary ones.
...
Quoted 16 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +16
-0+static int skl_int3472_clk_prepare (struct clk_hw *hw) +{ +struct int3472_gpio_clock *clk =to_int3472_clk (hw); + +gpiod_set_value (clk->ena_gpio,1 ); +gpiod_set_value (clk->led_gpio,1 ); + +return 0 ; +} + +static void skl_int3472_clk_unprepare (struct clk_hw *hw) +{ +struct int3472_gpio_clock *clk =to_int3472_clk (hw); + +gpiod_set_value (clk->ena_gpio,0 ); +gpiod_set_value (clk->led_gpio,0 );
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 46
Quoted 10 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +10
-0+} + +static int skl_int3472_clk_enable (struct clk_hw *hw) +{ +/* +* We're just turning a GPIO on to enable the clock, which operation +* has the potential to sleep. Given .enable() cannot sleep, but +* .prepare() can, we toggle the GPIO in .prepare() instead. Thus, +* nothing to do here. +*/
It's a nice comment, but you are using non-sleeping GPIO value setters. Perhaps you need to replace them with gpiod_set_value_cansleep()?
Quoted 2 lines
(quoted diff) +2
-0+ return 0; +}
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 66
Quoted 13 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +12
-0+static unsigned int skl_int3472_get_clk_frequency (struct int3472_discrete_device *int3472) +{ +union acpi_object *obj; +unsigned int freq; + + obj =skl_int3472_get_acpi_buffer (int3472->sensor,"SSDB" ); +if (IS_ERR (obj)) +return 0 ;/* report rate as 0 on error */ + +if (obj->buffer.length <CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET +sizeof (u32)) { +dev_err (int3472->dev,"The buffer is too small\n" ); + goto out_free_buff;
First of all, freq will be uninitialized here.
I'm wondering if you can simple drop the goto and replace it with direct steps, i.e.
kfree(obj); return 0;
Quoted 8 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +8
-0+ } + + freq = *(u32 *)(obj->buffer.pointer +CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET ); + +out_free_buff: +kfree (obj); +return freq; +}
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 98
Quoted 8 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +7
-0+int skl_int3472_register_clock (struct int3472_discrete_device *int3472) +{ +struct clk_init_data init = { + .ops = &skl_int3472_clock_ops, + .flags =CLK_GET_RATE_NOCACHE , + }; +int ret =0 ;
I would not assign it here. See below.
Quoted 13 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +13
-0+ init.name =kasprintf (GFP_KERNEL ,"%s-clk" , +acpi_dev_name (int3472->adev)); +if (!init.name) +return -ENOMEM ; + + int3472->clock.frequency =skl_int3472_get_clk_frequency (int3472); + + int3472->clock.clk_hw.init = &init; + int3472->clock.clk =clk_register (&int3472->adev->dev, + &int3472->clock.clk_hw); +if (IS_ERR (int3472->clock.clk)) { + ret =PTR_ERR (int3472->clock.clk); + goto out_free_init_name;
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 122
Quoted 10 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +9
-0+ } + + int3472->clock.cl =clkdev_create (int3472->clock.clk,NULL , + int3472->sensor_name); +if (!int3472->clock.cl) { + ret = -ENOMEM ; + goto err_unregister_clk; + } + goto out_free_init_name;
Better pattern is
kfree(init.name); return 0;
directly here.
Quoted 7 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +7
-0+err_unregister_clk: +clk_unregister (int3472->clock.clk); +out_free_init_name: +kfree (init.name); + +return ret; +}
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c line 12
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c new file +2
-0+union acpi_object *skl_int3472_get_acpi_buffer (struct acpi_device *adev, +char *id)
One line?
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c line 39
Quoted 5 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c new file +4
-0+int skl_int3472_fill_cldb (struct acpi_device *adev,struct int3472_cldb *cldb) +{ +union acpi_object *obj; +int ret =0 ;
I would assign it closer to the real use, see below.
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c line 51
Quoted 11 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c new file +11
-0+ obj =skl_int3472_get_acpi_buffer (adev,"CLDB" ); +if (IS_ERR (obj)) +return PTR_ERR (obj); + +if (obj->buffer.length >sizeof (*cldb)) { +acpi_handle_err (adev->handle,"The CLDB buffer is too large\n" ); + ret = -EINVAL ; + goto out_free_obj; + } + +memcpy (cldb, obj->buffer.pointer, obj->buffer.length);
ret = 0;
Quoted 4 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c new file +4
-0+out_free_obj: +kfree (obj); +return ret; +}
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h line 107
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h new file +2
-0+union acpi_object *skl_int3472_get_acpi_buffer (struct acpi_device *adev, +char *id);
One line?
...
Quoted 22 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +22
-0+static const struct int3472_sensor_config * +skl_int3472_get_sensor_module_config (struct int3472_discrete_device *int3472) +{ +const struct int3472_sensor_config *ret; +union acpi_object *obj; +unsigned int i; + + obj =acpi_evaluate_dsm_typed (int3472->sensor->handle, + &cio2_sensor_module_guid,0x00 , +0x01 ,NULL ,ACPI_TYPE_STRING ); + +if (!obj) { +dev_err (int3472->dev, +"Failed to get sensor module string from _DSM\n" ); +return ERR_PTR (-ENODEV ); + } + +if (obj->string.type !=ACPI_TYPE_STRING ) { +dev_err (int3472->dev, +"Sensor _DSM returned a non-string value\n" ); + ret =ERR_PTR (-EINVAL ); + goto out_free_obj;
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 98
Quoted 10 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +9
-0+ } + ret =ERR_PTR (-EINVAL ); +for (i =0 ; i <ARRAY_SIZE (int3472_sensor_configs); i++) { +if (!strcmp (int3472_sensor_configs[i].sensor_module_name, + obj->string.pointer)) { + ret = &int3472_sensor_configs[i]; +break ; + } + }
Can be refactored like this:
for (i = 0; i < ARRAY_SIZE(int3472_sensor_configs); i++) {
if (!strcmp(int3472_sensor_configs[i].sensor_module_name,
obj->string.pointer))
break;
}
ACPI_FREE(obj);
if (i >= ARRAY_SIZE(int3472_sensor_configs))
return ERR_PTR(-EINVAL);
return &int3472_sensor_configs[i];drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 102
Quoted 3 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +3
-0+out_free_obj: +ACPI_FREE (obj); +return ret;
And this moved to the one user above.
Quoted 1 line
+}
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 183
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +2
-0+dev_err (int3472->dev,"Invalid GPIO type 0x%02x for clock\n" , + type);
One line?
...
Quoted 2 lines
+ * Return:
+ * * 0 - When all resources found are handled properly.
Positive number ... ?
Quoted 3 lines
+ * *
-EINVAL- If the resource is not a GPIO IO resource
+ * *-ENODEV- If the resource has no corresponding_DSMentry
+ * * -Other - Errors propagated from one of the sub-functions.
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 232
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +2
-0+if (!acpi_gpio_get_io_resource (ares, &agpio)) +return 1 ;/* Deliberately positive so parsing continues */
Move it to description above?
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 241
Quoted 8 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +8
-0+/* +* n_gpios + 2 because the index of this _DSM function is 1-based and +* the first function is just a count. +*/ + obj =acpi_evaluate_dsm_typed (int3472->adev->handle, + &int3472_gpio_guid,0x00 , + int3472->n_gpios +2 , +NULL ,ACPI_TYPE_INTEGER );
can we rename n_gpios -> ngpios?
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 318
Quoted 5 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +5
-0+if (int3472->clock.ena_gpio) { + ret =skl_int3472_register_clock (int3472); +if (ret) + goto out_free_res_list; + }else {
Hmm... Have I got it correctly that we can't have ena_gpio && led_gpio together?
Quoted 4 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +4
-0+if (int3472->clock.led_gpio) +dev_warn (int3472->dev, +"No clk GPIO. The privacy LED won't work\n" ); + }
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c line 60
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c new file +2
-0+dev_err (&client->dev,"Failed to create regmap: %ld\n" , +PTR_ERR (regmap));
One line?
...
drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c line 95
Quoted 9 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c new file +8
-0+ ret =skl_int3472_fill_cldb (adev, &cldb); +if (!ret && cldb.control_logic_type !=2 ) { +dev_err (&client->dev,"Unsupported control logic type %u\n" , + cldb.control_logic_type); +return -EINVAL ; + } +if (ret) + ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
This I don't like. Since we get a returned variable with different meaning, can we use a specific variable name for it? On top of that, I would rather see something like this:
whatever = skl_...(...);
switch (whatever) {
case WHATEVER_ONE_CASE:
if (cldb.control_logic_type != 2) {
dev_err(&client->dev, "Unsupported control logic type %u\n",
cldb.control_logic_type);
return -EINVAL;
}
cells_data = tps68470_win;
cells_size = ARRAY_SIZE(tps68470_win);
break;
case WHATEVER_ANOTHER_CASE:
...
break;
default:
...Oops...
break; // or return -ERRNO
}
return devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
cells_data, cells_size, NULL, 0, NULL);Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 1/8] ACPI: scan: Extend acpi_walk_dep_device_list()
In reply to Daniel ScallyQuoted 6 lines · Daniel Scally
The
acpi_walk_dep_device_list()is not as generalisable as its name implies, serving only to decrement the dependency count for each dependent device of the input. Extend the function to instead accept a callback which can be applied to all the dependencies inacpi_dep_list. Replace all existing calls to the function with calls to a wrapper, passing a callback that applies the same dependency reduction.
Good for me as well.
Quoted 380 lines
Signed-off-by Daniel Scally <[email protected]>---
changes since v3:- Most of the functions got renamed
-acpi_dev_get_dependent_dev()was altered to take a structacpi_deviceThis had some repurcussions in the other files, mostly switching fromACPI_HANDLE()toACPI_COMPANION().
-acpi_walk_dep_device_list()was altered to check the return value of the callback on each iteration of the loop, to allow for error handling of the callbacks or breaking the loop early to save time. Andy, Wolfram, I thought this change was significant enough to drop your R-b and Ack.drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 69 ++++++++++++++----- drivers/gpio/gpiolib-acpi.c | 10 +-- drivers/i2c/i2c-core-acpi.c | 8 +-- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +++--- .../platform/surface/surface_acpi_notify.c | 7 +- include/acpi/acpi_bus.h | 7 ++ include/linux/acpi.h | 4 +- 10 files changed, 90 insertions(+), 47 deletions(-)drivers/acpi/ec.c +1
-1@@ -1627,7 +1627,7 @@ static int acpi_ec_add(struct acpi_device *device)WARN (!ret,"Could not request EC cmd io port 0x%lx" , ec->command_addr);/* Reprobe devices depending on the EC */ -acpi_walk_dep_device_list (ec->handle); +acpi_dev_clear_dependencies (device);acpi_handle_debug (ec->handle,"enumerated.\n" );return 0 ;drivers/acpi/pmic/intel_pmic_chtdc_ti.c +1
-1@@ -117,7 +117,7 @@ static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)return err;/* Re-enumerate devices depending on PMIC */ -acpi_walk_dep_device_list (ACPI_HANDLE (pdev->dev.parent)); +acpi_dev_clear_dependencies (ACPI_COMPANION (pdev->dev.parent));return 0 ; }drivers/acpi/scan.c +51
-18@@ -47,12 +47,6 @@ static DEFINE_MUTEX(acpi_hp_context_lock);*/ static u64 spcr_uart_addr; -struct acpi_dep_data { -struct list_head node; -acpi_handle supplier; -acpi_handle consumer; -}; -void acpi_scan_lock_acquire (void ) {mutex_lock (&acpi_scan_lock);@@ -2111,30 +2105,69 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); } -void acpi_walk_dep_device_list (acpi_handle handle) +static int acpi_scan_clear_dep (struct acpi_dep_data *dep,void *data) { -struct acpi_dep_data *dep, *tmp;struct acpi_device *adev; +acpi_bus_get_device (dep->consumer, &adev); + +if (adev) { + adev->dep_unmet--; +if (!adev->dep_unmet) +acpi_bus_attach (adev, true); + } + +list_del (&dep->node); +kfree (dep); + +return 0 ; +} + +/** +* acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list +* @handle: The ACPI handle of the supplier device +* @callback: Pointer to the callback function to apply +* @data: Pointer to some data to pass to the callback +* +* The return value of the callback determines this function's behaviour. If 0 +* is returned we continue to iterate over acpi_dep_list. If a positive value +* is returned then the loop is broken but this function returns 0. If a +* negative value is returned by the callback then the loop is broken and that +* value is returned as the final error. +*/ +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data) +{ +struct acpi_dep_data *dep, *tmp; +int ret; +mutex_lock (&acpi_dep_list_lock);list_for_each_entry_safe (dep, tmp, &acpi_dep_list, node) {if (dep->supplier == handle) { -acpi_bus_get_device (dep->consumer, &adev); - -if (adev) { - adev->dep_unmet--; -if (!adev->dep_unmet) -acpi_bus_attach (adev, true); - } - -list_del (&dep->node); -kfree (dep); + ret =callback (dep, data); +if (ret) +break ; } }mutex_unlock (&acpi_dep_list_lock); + +return ret >0 ?0 : ret; }EXPORT_SYMBOL_GPL (acpi_walk_dep_device_list); +/** +* acpi_dev_clear_dependencies - Inform consumers that the device is now active +* @supplier: Pointer to the supplier &struct acpi_device +* +* Clear dependencies on the given device. +*/ +void acpi_dev_clear_dependencies (struct acpi_device *supplier) +{ +acpi_walk_dep_device_list (supplier->handle, acpi_scan_clear_dep,NULL ); +} +EXPORT_SYMBOL_GPL (acpi_dev_clear_dependencies); +/** * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. * @handle: Root of the namespace scope to scan. drivers/gpio/gpiolib-acpi.c +5
-5@@ -1233,14 +1233,14 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip)void acpi_gpiochip_add (struct gpio_chip *chip) {struct acpi_gpio_chip *acpi_gpio; -acpi_handle handle; +struct acpi_device *adev;acpi_status status;if (!chip || !chip->parent)return ; - handle =ACPI_HANDLE (chip->parent); -if (!handle) + adev =ACPI_COMPANION (chip->parent); +if (!adev)return ; acpi_gpio =kzalloc (sizeof (*acpi_gpio),GFP_KERNEL );@@ -1254,7 +1254,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)INIT_LIST_HEAD (&acpi_gpio->events);INIT_LIST_HEAD (&acpi_gpio->deferred_req_irqs_list_entry); - status =acpi_attach_data (handle, acpi_gpio_chip_dh, acpi_gpio); + status =acpi_attach_data (adev->handle, acpi_gpio_chip_dh, acpi_gpio);if (ACPI_FAILURE (status)) {dev_err (chip->parent,"Failed to attach ACPI GPIO chip\n" );kfree (acpi_gpio);@@ -1263,7 +1263,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)acpi_gpiochip_request_regions (acpi_gpio);acpi_gpiochip_scan_gpios (acpi_gpio); -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }void acpi_gpiochip_remove (struct gpio_chip *chip)drivers/i2c/i2c-core-acpi.c +4
-4@@ -259,8 +259,8 @@ static acpi_status i2c_acpi_add_device(acpi_handle handle, u32 level,*/ void i2c_acpi_register_devices (struct i2c_adapter *adap) { +struct acpi_device *adev;acpi_status status; -acpi_handle handle;if (!has_acpi_companion (&adap->dev))return ;@@ -275,11 +275,11 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)if (!adap->dev.parent)return ; - handle =ACPI_HANDLE (adap->dev.parent); -if (!handle) + adev =ACPI_COMPANION (adap->dev.parent); +if (!adev)return ; -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev); }static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {drivers/platform/surface/aggregator/core.c +3
-3@@ -621,8 +621,8 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {static int ssam_serial_hub_probe (struct serdev_device *serdev) { +struct acpi_device *ssh =ACPI_COMPANION (&serdev->dev);struct ssam_controller *ctrl; -acpi_handle *ssh =ACPI_HANDLE (&serdev->dev);acpi_status astatus;int status;@@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)if (status) goto err_devopen; - astatus =ssam_serdev_setup_via_acpi (ssh, serdev); + astatus =ssam_serdev_setup_via_acpi (ssh->handle, serdev);if (ACPI_FAILURE (astatus)) { status = -ENXIO ; goto err_devinit;@@ -706,7 +706,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)* For now let's thus default power/wakeup to false. */ device_set_wakeup_capable (&serdev->dev, true); -acpi_walk_dep_device_list (ssh); +acpi_dev_clear_dependencies (ssh);return 0 ;drivers/platform/surface/surface3_power.c +11
-11@@ -446,12 +446,12 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,static int mshw0011_install_space_handler (struct i2c_client *client) { -acpi_handle handle; +struct acpi_device *adev;struct mshw0011_handler_data *data;acpi_status status; - handle =ACPI_HANDLE (&client->dev); -if (!handle) + adev =ACPI_COMPANION (&client->dev); +if (!adev)return -ENODEV ; data = kzalloc(sizeof(struct mshw0011_handler_data),@@ -460,25 +460,25 @@ static int mshw0011_install_space_handler(struct i2c_client *client)return -ENOMEM ; data->client = client; - status =acpi_bus_attach_private_data (handle, (void *)data); + status =acpi_bus_attach_private_data (adev->handle, (void *)data);if (ACPI_FAILURE (status)) {kfree (data);return -ENOMEM ; } - status =acpi_install_address_space_handler (handle, -ACPI_ADR_SPACE_GSBUS , - &mshw0011_space_handler, -NULL , - data); + status =acpi_install_address_space_handler (adev->handle, +ACPI_ADR_SPACE_GSBUS , + &mshw0011_space_handler, +NULL , + data);if (ACPI_FAILURE (status)) {dev_err (&client->dev,"Error installing i2c space handler\n" ); -acpi_bus_detach_private_data (handle); +acpi_bus_detach_private_data (adev->handle);kfree (data);return -ENOMEM ; } -acpi_walk_dep_device_list (handle); +acpi_dev_clear_dependencies (adev);return 0 ; }drivers/platform/surface/surface_acpi_notify.c +4
-3@@ -798,7 +798,7 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -acpi_handle san =ACPI_HANDLE (&pdev->dev); +struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl;struct san_data *data;acpi_status astatus;@@ -821,7 +821,8 @@ static int san_probe(struct platform_device *pdev)platform_set_drvdata (pdev, data); - astatus =acpi_install_address_space_handler (san,ACPI_ADR_SPACE_GSBUS , + astatus =acpi_install_address_space_handler (san->handle, +ACPI_ADR_SPACE_GSBUS , &san_opreg_handler,NULL , &data->info);if (ACPI_FAILURE (astatus))@@ -835,7 +836,7 @@ static int san_probe(struct platform_device *pdev)if (status) goto err_install_dev; -acpi_walk_dep_device_list (san); +acpi_dev_clear_dependencies (san);return 0 ; err_install_dev:include/acpi/acpi_bus.h +7
-0@@ -280,6 +280,12 @@ struct acpi_device_power {struct acpi_device_power_state states[ACPI_D_STATE_COUNT ];/* Power states (D0-D3Cold) */ }; +struct acpi_dep_data { +struct list_head node; +acpi_handle supplier; +acpi_handle consumer; +}; +/* Performance Management */ struct acpi_device_perf_flags {@@ -685,6 +691,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)bool acpi_dev_hid_uid_match (struct acpi_device *adev,const char *hid2,const char *uid2); +void acpi_dev_clear_dependencies (struct acpi_device *supplier);struct acpi_device *acpi_dev_get_next_match_dev (struct acpi_device *adev,const char *hid,const char *uid,s64 hrv); struct acpi_device *include/linux/acpi.h +3
-1@@ -666,7 +666,9 @@ extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv);int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); -void acpi_walk_dep_device_list (acpi_handle handle); +int acpi_walk_dep_device_list (acpi_handle handle, +int (*callback)(struct acpi_dep_data *,void *), +void *data);struct platform_device *acpi_create_platform_device (struct acpi_device *,struct property_entry *);Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device
In reply to Rafael J. WysockiHi Rafael
Quoted 27 lines · Rafael J. Wysocki
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · Daniel Scally
In some ACPI tables we encounter, devices use the
_DEPmethod to assert a dependence on other ACPI devices as opposed to the OpRegions that the specification intends. We need to be able to find those devices "from" the dependee, so add a callback and a wrapper to walk over theacpi_dep_listand return the dependent ACPI device.Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Daniel Scally <[email protected]>---
Changes since v3:Both new functions were renamed.
drivers/acpi/scan.c | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 39 insertions(+)drivers/acpi/scan.c +0
-0@@ -2105,6 +2105,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) device->handler->hotplug.notify_online (device); }
Quoted 3 lines
Quoted 2 lines
drivers/acpi/scan.c static void acpi_bus_attach(struct acpi_device *device, bool first_pass) · line 2108
Quoted 1 line
drivers/acpi/scan.c +1
-0+static int acpi_return_dep_dev (struct acpi_dep_data *dep,void *data)What about calling this
acpi_get_first_consumer_cb()?Or
acpi_dev_get_first_consumer_dev_cb()if you want to be super-precise?
Sure; fine by me, and same for the other function
Hi Daniel,
Quoted 4 lines · Daniel Scally
Hello all
Apologies for the long delay since the last version of this series; the time I had free to work on it became somewhat restrained.
No worries, thank you for all the work you are putting into this.
I have not taken a close look at the code yet, but I see that Andy has and the amount of remarks which he has on patch 7/8 which is the big one seems to be limited, so I believe that we are getting close to this being ready for merging.
This touches a lot of subsystems, so we need to come up with a plan to merge this. Here is my proposal for how to do this:
1/8 ACPI: scan: Extend acpi_walk_dep_device_list() 2/8 ACPI: scan: Add function to fetch dependent of acpi device 3/8 i2c: core: Add a format macro for I2C device names 4/8 gpiolib: acpi: Export acpi_get_gpiod() 5/8 clkdev: Make clkdev_drop() null aware 6/8 gpiolib: acpi: Add acpi_gpio_get_io_resource() 7/8 platform/x86: Add intel_skl_int3472 driver 8/8 mfd: tps68470: Remove tps68470 MFD driver
Rafael already indicated that he wants to merge 1/8 (and presumably also 2/8) through his tree and that he will provide an immutable branch with those for merging into the pdx86 tree.
4/8 and 6/8 are both gpiolib-acpi patches and seem to be ready for merging now, perhaps the gpiolib-acpi maintainers can already merge these and also provide an immutable branch ? Andy/Mika ?
3/8 and 5/8 seem to be nice cleanups, but not really necessary. IMHO it would be best to park these cleanups for later and for 3/8 add the following where necessary for now:
/* FIXME drop this once the I2C_DEV_NAME_FORMAT macro has been added to include/linux/i2c.h */ #ifndef I2C_DEV_NAME_FORMAT
#define I2C_DEV_NAME_FORMAT "i2c-%s"
#endif
This is not the prettiest but it reduces all the subsys cross-deps and things like this have been done before for similar reasons.
Likewise it would be good if you can add if (foo) as condition before any clkdev_drop(foo) calls in this patch-set and then merge
5/8 "clkdev: Make clkdev_drop() null aware" independently of this and then once both are in Linux tree follow-up with a cleanup patch dropping the if (foo) guards.
So this would leave as deps for 7/8 just the 2 ACPI and 2 gpiolib-acpi patches which I can hopefully pull-in via immutable branches and then we are good.
AFAICT patch 8/8 can be merged independently once 7/8 hits for-next (IOW once we are sure the next kernel will have 7/8).
Or alternatively one of the involved subsys maintainers just merges the entire set (once it is ready) and then provides an immutable branch with the entire set on top of 5.13-rc1 (or 5.14-rc1). But that requires acks from all the other subsys maintainers. Note I'm fine with either approach.
Regards,
Hans
Quoted 107 lines
v1 for this series was originally 14-18 of this series:
https://lore.kernel.org/linux-media/[email protected]/T/#m91934e12e3d033da2e768e952ea3b4a125ee3e67v2 was here:
https://lore.kernel.org/platform-driver-x86/[email protected]/v3 was here:
https://lore.kernel.org/lkml/[email protected]/Series level changelog:
- Added patch 5/8 to make
clkdev_drop()NULL aware to simplify error handling.
- Added patch 6/8 to addacpi_gpio_get_io_resource().This has been tested on a number of devices, but currently **not** on a device designed for ChromeOS, which we ideally need to do to ensure no regression caused by replacing the tps68470 MFD driver. Unfortunately, I don't have a device to test it on myself.
=========== Original Cover Letter ===========
At the moment in the kernel the ACPI
_HIDINT3472 is taken by the tps68470 MFD driver, but that driver can only handle some of the cases of that_HIDthat we see. There are at least these three possibilities:1. INT3472 devices that provide GPIOs through the usual framework and run power and clocks through an operation region; this is the situation that the current module handles and is seen on ChromeOS devices
2. INT3472 devices that provide GPIOs, plus clocks and regulators that are meant to be driven through the usual frameworks, usually seen on devices designed to run Windows
3. INT3472 devices that don't actually represent a physical tps68470, but are being used as a convenient way of grouping a bunch of system GPIO lines that are intended to enable power and clocks for sensors which are called out as dependent on them. Also seen on devices designed to run Windows.This series introduces a new module which registers:
1. An i2c driver that determines which scenario (#1 or #2) applies to the machine and registers platform devices to be bound to GPIO, OpRegion, clock and regulator drivers as appropriate.
2. A platform driver that binds to the dummy INT3472 devices described in #3The platform driver for the dummy device registers the GPIO lines that enable the clocks and regulators to the sensors via those frameworks so that sensor drivers can consume them in the usual fashion. The existing GPIO and OpRegion tps68470 drivers will work with the i2c driver that's registered. Clock and regulator drivers are available but have not so far been tested, so aren't part of this series.
The existing
mfd/tps68470.cdriver being thus superseded, it is removed.Thanks
DanDaniel Scally (8):
ACPI: scan: Extendacpi_walk_dep_device_list()
ACPI: scan: Add function to fetch dependent of acpi device
i2c: core: Add a format macro for I2C device names
gpiolib: acpi: Exportacpi_get_gpiod()
clkdev: Makeclkdev_drop()null aware
gpiolib: acpi: Addacpi_gpio_get_io_resource()platform/x86: Addintel_skl_int3472driver
mfd: tps68470: Remove tps68470 MFD driverMAINTAINERS | 5 + drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/Kconfig | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 107 ++++- drivers/clk/clkdev.c | 3 + drivers/gpio/Kconfig | 2 +- drivers/gpio/gpiolib-acpi.c | 61 ++- drivers/i2c/i2c-core-acpi.c | 8 +- drivers/i2c/i2c-core-base.c | 4 +- drivers/mfd/Kconfig | 18 - drivers/mfd/Makefile | 1 - drivers/mfd/tps68470.c | 97 ----- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +- .../platform/surface/surface_acpi_notify.c | 7 +- drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-int3472/Kconfig | 31 ++ drivers/platform/x86/intel-int3472/Makefile | 5 + .../intel_skl_int3472_clk_and_regulator.c | 195 +++++++++ .../intel-int3472/intel_skl_int3472_common.c | 106 +++++ .../intel-int3472/intel_skl_int3472_common.h | 113 +++++ .../intel_skl_int3472_discrete.c | 409 ++++++++++++++++++ .../intel_skl_int3472_tps68470.c | 109 +++++ include/acpi/acpi_bus.h | 8 + include/linux/acpi.h | 11 +- include/linux/gpio/consumer.h | 2 + include/linux/i2c.h | 3 + 29 files changed, 1175 insertions(+), 167 deletions(-) delete mode 100644 drivers/mfd/tps68470.c create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
Hi again,
Quoted 27 lines · Hans de Goede
Hi Daniel,
Quoted 4 lines · Daniel Scally
Hello all
Apologies for the long delay since the last version of this series; the time I had free to work on it became somewhat restrained.
No worries, thank you for all the work you are putting into this.
I have not taken a close look at the code yet, but I see that Andy has and the amount of remarks which he has on patch 7/8 which is the big one seems to be limited, so I believe that we are getting close to this being ready for merging.
This touches a lot of subsystems, so we need to come up with a plan to merge this. Here is my proposal for how to do this:
1/8 ACPI: scan: Extend acpi_walk_dep_device_list() 2/8 ACPI: scan: Add function to fetch dependent of acpi device 3/8 i2c: core: Add a format macro for I2C device names 4/8 gpiolib: acpi: Export acpi_get_gpiod() 5/8 clkdev: Make clkdev_drop() null aware 6/8 gpiolib: acpi: Add acpi_gpio_get_io_resource() 7/8 platform/x86: Add intel_skl_int3472 driver 8/8 mfd: tps68470: Remove tps68470 MFD driver
Quoted 3 lines
Rafael already indicated that he wants to merge 1/8 (and presumably also 2/8) through his tree and that he will provide an immutable branch with those for merging into the pdx86 tree.
p.s.
Daniel it would be good if you can at least send a v5 of patch 2/8 with the suggested renames, then Rafael can merge 1/8 + 2/8 and we are down to 6 patches (4 if we also merge the i2c + clk patches independently).
Regards,
Hans
Quoted 150 lines
4/8 and 6/8 are both gpiolib-acpi patches and seem to be ready for merging now, perhaps the gpiolib-acpi maintainers can already merge these and also provide an immutable branch ? Andy/Mika ?
3/8 and 5/8 seem to be nice cleanups, but not really necessary. IMHO it would be best to park these cleanups for later and for 3/8 add the following where necessary for now:
/* FIXME drop this once the
I2C_DEV_NAME_FORMATmacro has been added toinclude/linux/i2c.h*/ #ifndefI2C_DEV_NAME_FORMAT
#defineI2C_DEV_NAME_FORMAT"i2c-%s"
#endifThis is not the prettiest but it reduces all the subsys cross-deps and things like this have been done before for similar reasons.
Likewise it would be good if you can add if (foo) as condition before any
clkdev_drop(foo)calls in this patch-set and then merge
5/8 "clkdev: Makeclkdev_drop()null aware" independently of this and then once both are in Linux tree follow-up with a cleanup patch dropping the if (foo) guards.So this would leave as deps for 7/8 just the 2 ACPI and 2 gpiolib-acpi patches which I can hopefully pull-in via immutable branches and then we are good.
AFAICT patch 8/8 can be merged independently once 7/8 hits for-next (IOW once we are sure the next kernel will have 7/8).
Or alternatively one of the involved subsys maintainers just merges the entire set (once it is ready) and then provides an immutable branch with the entire set on top of 5.13-rc1 (or 5.14-rc1). But that requires acks from all the other subsys maintainers. Note I'm fine with either approach.
Regards,
Hans
Quoted 107 lines
v1 for this series was originally 14-18 of this series:
https://lore.kernel.org/linux-media/[email protected]/T/#m91934e12e3d033da2e768e952ea3b4a125ee3e67v2 was here:
https://lore.kernel.org/platform-driver-x86/[email protected]/v3 was here:
https://lore.kernel.org/lkml/[email protected]/Series level changelog:
- Added patch 5/8 to make
clkdev_drop()NULL aware to simplify error handling.
- Added patch 6/8 to addacpi_gpio_get_io_resource().This has been tested on a number of devices, but currently **not** on a device designed for ChromeOS, which we ideally need to do to ensure no regression caused by replacing the tps68470 MFD driver. Unfortunately, I don't have a device to test it on myself.
=========== Original Cover Letter ===========
At the moment in the kernel the ACPI
_HIDINT3472 is taken by the tps68470 MFD driver, but that driver can only handle some of the cases of that_HIDthat we see. There are at least these three possibilities:1. INT3472 devices that provide GPIOs through the usual framework and run power and clocks through an operation region; this is the situation that the current module handles and is seen on ChromeOS devices
2. INT3472 devices that provide GPIOs, plus clocks and regulators that are meant to be driven through the usual frameworks, usually seen on devices designed to run Windows
3. INT3472 devices that don't actually represent a physical tps68470, but are being used as a convenient way of grouping a bunch of system GPIO lines that are intended to enable power and clocks for sensors which are called out as dependent on them. Also seen on devices designed to run Windows.This series introduces a new module which registers:
1. An i2c driver that determines which scenario (#1 or #2) applies to the machine and registers platform devices to be bound to GPIO, OpRegion, clock and regulator drivers as appropriate.
2. A platform driver that binds to the dummy INT3472 devices described in #3The platform driver for the dummy device registers the GPIO lines that enable the clocks and regulators to the sensors via those frameworks so that sensor drivers can consume them in the usual fashion. The existing GPIO and OpRegion tps68470 drivers will work with the i2c driver that's registered. Clock and regulator drivers are available but have not so far been tested, so aren't part of this series.
The existing
mfd/tps68470.cdriver being thus superseded, it is removed.Thanks
DanDaniel Scally (8):
ACPI: scan: Extendacpi_walk_dep_device_list()
ACPI: scan: Add function to fetch dependent of acpi device
i2c: core: Add a format macro for I2C device names
gpiolib: acpi: Exportacpi_get_gpiod()
clkdev: Makeclkdev_drop()null aware
gpiolib: acpi: Addacpi_gpio_get_io_resource()platform/x86: Addintel_skl_int3472driver
mfd: tps68470: Remove tps68470 MFD driverMAINTAINERS | 5 + drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/Kconfig | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 107 ++++- drivers/clk/clkdev.c | 3 + drivers/gpio/Kconfig | 2 +- drivers/gpio/gpiolib-acpi.c | 61 ++- drivers/i2c/i2c-core-acpi.c | 8 +- drivers/i2c/i2c-core-base.c | 4 +- drivers/mfd/Kconfig | 18 - drivers/mfd/Makefile | 1 - drivers/mfd/tps68470.c | 97 ----- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +- .../platform/surface/surface_acpi_notify.c | 7 +- drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-int3472/Kconfig | 31 ++ drivers/platform/x86/intel-int3472/Makefile | 5 + .../intel_skl_int3472_clk_and_regulator.c | 195 +++++++++ .../intel-int3472/intel_skl_int3472_common.c | 106 +++++ .../intel-int3472/intel_skl_int3472_common.h | 113 +++++ .../intel_skl_int3472_discrete.c | 409 ++++++++++++++++++ .../intel_skl_int3472_tps68470.c | 109 +++++ include/acpi/acpi_bus.h | 8 + include/linux/acpi.h | 11 +- include/linux/gpio/consumer.h | 2 + include/linux/i2c.h | 3 + 29 files changed, 1175 insertions(+), 167 deletions(-) delete mode 100644 drivers/mfd/tps68470.c create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
Quoted 28 lines · Hans de Goede
Quoted 23 lines · Hans de Goede
Quoted 2 lines · Daniel Scally
Apologies for the long delay since the last version of this series; the time I had free to work on it became somewhat restrained.
No worries, thank you for all the work you are putting into this.
I have not taken a close look at the code yet, but I see that Andy has and the amount of remarks which he has on patch 7/8 which is the big one seems to be limited, so I believe that we are getting close to this being ready for merging.
This touches a lot of subsystems, so we need to come up with a plan to merge this. Here is my proposal for how to do this:
1/8 ACPI: scan: Extend acpi_walk_dep_device_list() 2/8 ACPI: scan: Add function to fetch dependent of acpi device 3/8 i2c: core: Add a format macro for I2C device names 4/8 gpiolib: acpi: Export acpi_get_gpiod() 5/8 clkdev: Make clkdev_drop() null aware 6/8 gpiolib: acpi: Add acpi_gpio_get_io_resource() 7/8 platform/x86: Add intel_skl_int3472 driver 8/8 mfd: tps68470: Remove tps68470 MFD driverQuoted 3 lines
Rafael already indicated that he wants to merge 1/8 (and presumably also 2/8) through his tree and that he will provide an immutable branch with those for merging into the pdx86 tree.
Quoted 5 lines
p.s.
Daniel it would be good if you can at least send a v5 of patch 2/8 with the suggested renames, then Rafael can merge 1/8 + 2/8 and we are down to 6 patches (4 if we also merge the i2c + clk patches independently).
I would also prefer GPIO ACPI patches to be grouped together, so I can simply take them in a row.
Quoted 3 lines
Quoted 3 lines
4/8 and 6/8 are both gpiolib-acpi patches and seem to be ready for merging now, perhaps the gpiolib-acpi maintainers can already merge these and also provide an immutable branch ? Andy/Mika ?
Fine with me. Just need Mika's Ack / Rb tag.
Quoted 137 lines
Quoted 136 lines
3/8 and 5/8 seem to be nice cleanups, but not really necessary. IMHO it would be best to park these cleanups for later and for 3/8 add the following where necessary for now:
/* FIXME drop this once the
I2C_DEV_NAME_FORMATmacro has been added toinclude/linux/i2c.h*/ #ifndefI2C_DEV_NAME_FORMAT
#defineI2C_DEV_NAME_FORMAT"i2c-%s"
#endifThis is not the prettiest but it reduces all the subsys cross-deps and things like this have been done before for similar reasons.
Likewise it would be good if you can add if (foo) as condition before any
clkdev_drop(foo)calls in this patch-set and then merge
5/8 "clkdev: Makeclkdev_drop()null aware" independently of this and then once both are in Linux tree follow-up with a cleanup patch dropping the if (foo) guards.So this would leave as deps for 7/8 just the 2 ACPI and 2 gpiolib-acpi patches which I can hopefully pull-in via immutable branches and then we are good.
AFAICT patch 8/8 can be merged independently once 7/8 hits for-next (IOW once we are sure the next kernel will have 7/8).
Or alternatively one of the involved subsys maintainers just merges the entire set (once it is ready) and then provides an immutable branch with the entire set on top of 5.13-rc1 (or 5.14-rc1). But that requires acks from all the other subsys maintainers. Note I'm fine with either approach.
Quoted 107 lines
v1 for this series was originally 14-18 of this series:
https://lore.kernel.org/linux-media/[email protected]/T/#m91934e12e3d033da2e768e952ea3b4a125ee3e67v2 was here:
https://lore.kernel.org/platform-driver-x86/[email protected]/v3 was here:
https://lore.kernel.org/lkml/[email protected]/Series level changelog:
- Added patch 5/8 to make
clkdev_drop()NULL aware to simplify error handling.
- Added patch 6/8 to addacpi_gpio_get_io_resource().This has been tested on a number of devices, but currently **not** on a device designed for ChromeOS, which we ideally need to do to ensure no regression caused by replacing the tps68470 MFD driver. Unfortunately, I don't have a device to test it on myself.
=========== Original Cover Letter ===========
At the moment in the kernel the ACPI
_HIDINT3472 is taken by the tps68470 MFD driver, but that driver can only handle some of the cases of that_HIDthat we see. There are at least these three possibilities:1. INT3472 devices that provide GPIOs through the usual framework and run power and clocks through an operation region; this is the situation that the current module handles and is seen on ChromeOS devices
2. INT3472 devices that provide GPIOs, plus clocks and regulators that are meant to be driven through the usual frameworks, usually seen on devices designed to run Windows
3. INT3472 devices that don't actually represent a physical tps68470, but are being used as a convenient way of grouping a bunch of system GPIO lines that are intended to enable power and clocks for sensors which are called out as dependent on them. Also seen on devices designed to run Windows.This series introduces a new module which registers:
1. An i2c driver that determines which scenario (#1 or #2) applies to the machine and registers platform devices to be bound to GPIO, OpRegion, clock and regulator drivers as appropriate.
2. A platform driver that binds to the dummy INT3472 devices described in #3The platform driver for the dummy device registers the GPIO lines that enable the clocks and regulators to the sensors via those frameworks so that sensor drivers can consume them in the usual fashion. The existing GPIO and OpRegion tps68470 drivers will work with the i2c driver that's registered. Clock and regulator drivers are available but have not so far been tested, so aren't part of this series.
The existing
mfd/tps68470.cdriver being thus superseded, it is removed.Thanks
DanDaniel Scally (8):
ACPI: scan: Extendacpi_walk_dep_device_list()
ACPI: scan: Add function to fetch dependent of acpi device
i2c: core: Add a format macro for I2C device names
gpiolib: acpi: Exportacpi_get_gpiod()
clkdev: Makeclkdev_drop()null aware
gpiolib: acpi: Addacpi_gpio_get_io_resource()platform/x86: Addintel_skl_int3472driver
mfd: tps68470: Remove tps68470 MFD driverMAINTAINERS | 5 + drivers/acpi/ec.c | 2 +- drivers/acpi/pmic/Kconfig | 2 +- drivers/acpi/pmic/intel_pmic_chtdc_ti.c | 2 +- drivers/acpi/scan.c | 107 ++++- drivers/clk/clkdev.c | 3 + drivers/gpio/Kconfig | 2 +- drivers/gpio/gpiolib-acpi.c | 61 ++- drivers/i2c/i2c-core-acpi.c | 8 +- drivers/i2c/i2c-core-base.c | 4 +- drivers/mfd/Kconfig | 18 - drivers/mfd/Makefile | 1 - drivers/mfd/tps68470.c | 97 ----- drivers/platform/surface/aggregator/core.c | 6 +- drivers/platform/surface/surface3_power.c | 22 +- .../platform/surface/surface_acpi_notify.c | 7 +- drivers/platform/x86/Kconfig | 2 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-int3472/Kconfig | 31 ++ drivers/platform/x86/intel-int3472/Makefile | 5 + .../intel_skl_int3472_clk_and_regulator.c | 195 +++++++++ .../intel-int3472/intel_skl_int3472_common.c | 106 +++++ .../intel-int3472/intel_skl_int3472_common.h | 113 +++++ .../intel_skl_int3472_discrete.c | 409 ++++++++++++++++++ .../intel_skl_int3472_tps68470.c | 109 +++++ include/acpi/acpi_bus.h | 8 + include/linux/acpi.h | 11 +- include/linux/gpio/consumer.h | 2 + include/linux/i2c.h | 3 + 29 files changed, 1175 insertions(+), 167 deletions(-) delete mode 100644 drivers/mfd/tps68470.c create mode 100644 drivers/platform/x86/intel-int3472/Kconfig create mode 100644 drivers/platform/x86/intel-int3472/Makefile create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_common.h create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c create mode 100644 drivers/platform/x86/intel-int3472/intel_skl_int3472_tps68470.c
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 6/8] gpiolib: acpi: Add acpi_gpio_get_io_resource()
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Quoted 2 lines · Daniel Scally
Add a function to verify that a given
acpi_resourcerepresents an IO type GPIO resource, and return it if so.Reviewed-by Andy Shevchenko <[email protected]>
Thanks Andy, and same for 1/8
Re: [PATCH v4 7/8] platform/x86: Add intel_skl_int3472 driver
In reply to Andy ShevchenkoHi Andy - thanks for comments
Quoted 8 lines · Andy Shevchenko
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 19
Quoted 6 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +6
-0+/* +* The regulators have to have .ops to be valid, but the only ops we actually +* support are .enable and .disable which are handled via .ena_gpiod. Pass an +* empty struct to clear the check without lying about capabilities. +*/ +static const struct regulator_ops int3472_gpio_regulator_ops;Hmm... Can you use 'reg-fixed-voltage' platform device instead?
Quoted 8 lines
One example, although gone from upstream, but available in the tree, I can point to is this:
git log -p --
arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.cIt uses constant structures, but I think you may dynamically generate the necessary ones.
I can experiment with this, though one thing is we have no actual idea what voltages these are supplying...it doesn't look like that matters from drivers/regulator/fixed.c, but I'd have to try it to be sure.
Quoted 11 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +9
-0+ +static int skl_int3472_clk_enable (struct clk_hw *hw) +{ +/* +* We're just turning a GPIO on to enable the clock, which operation +* has the potential to sleep. Given .enable() cannot sleep, but +* .prepare() can, we toggle the GPIO in .prepare() instead. Thus, +* nothing to do here. +*/ It's a nice comment, but you are using non-sleeping GPIO value setters. Perhaps you need to replace them with
gpiod_set_value_cansleep()?
That would make sense!
Quoted 14 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c line 66
Quoted 12 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_clk_and_regulator.c new file +12
-0+static unsigned int skl_int3472_get_clk_frequency (struct int3472_discrete_device *int3472) +{ +union acpi_object *obj; +unsigned int freq; + + obj =skl_int3472_get_acpi_buffer (int3472->sensor,"SSDB" ); +if (IS_ERR (obj)) +return 0 ;/* report rate as 0 on error */ + +if (obj->buffer.length <CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET +sizeof (u32)) { +dev_err (int3472->dev,"The buffer is too small\n" ); + goto out_free_buff;First of all, freq will be uninitialized here.
Quoted 3 lines
I'm wondering if you can simple drop the goto and replace it with direct steps, i.e.
kfree(obj); return 0;
Sure, I have no real preference; I'll do that instead.
Quoted 33 lines
Quoted 21 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +21
-0+static const struct int3472_sensor_config * +skl_int3472_get_sensor_module_config (struct int3472_discrete_device *int3472) +{ +const struct int3472_sensor_config *ret; +union acpi_object *obj; +unsigned int i; + + obj =acpi_evaluate_dsm_typed (int3472->sensor->handle, + &cio2_sensor_module_guid,0x00 , +0x01 ,NULL ,ACPI_TYPE_STRING ); + +if (!obj) { +dev_err (int3472->dev, +"Failed to get sensor module string from _DSM\n" ); +return ERR_PTR (-ENODEV ); + } + +if (obj->string.type !=ACPI_TYPE_STRING ) { +dev_err (int3472->dev, +"Sensor _DSM returned a non-string value\n" ); + ret =ERR_PTR (-EINVAL );drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 98
Quoted 10 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +10
-0+ goto out_free_obj; + } + ret =ERR_PTR (-EINVAL ); +for (i =0 ; i <ARRAY_SIZE (int3472_sensor_configs); i++) { +if (!strcmp (int3472_sensor_configs[i].sensor_module_name, + obj->string.pointer)) { + ret = &int3472_sensor_configs[i]; +break ; + } + }Can be refactored like this:
Quoted 12 lines
for (i = 0; i < ARRAY_SIZE(int3472_sensor_configs); i++) {
if (!strcmp(int3472_sensor_configs[i].sensor_module_name,
obj->string.pointer))
break;
}
ACPI_FREE(obj);
if (i >= ARRAY_SIZE(int3472_sensor_configs))
return ERR_PTR(-EINVAL);
return &int3472_sensor_configs[i];Yeah ok, I like this better than the ret = ERR_PTR(-EINVAL) before the loop; thank you.
Quoted 6 lines
Quoted 2 lines
+ * Return:
+ * * 0 - When all resources found are handled properly.Positive number ... ?
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 232
Quoted 2 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +2
-0+if (!acpi_gpio_get_io_resource (ares, &agpio)) +return 1 ;/* Deliberately positive so parsing continues */ Move it to description above?
oops, yes, I'll add those to the comment.
Quoted 6 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 318
Quoted 5 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +5
-0+if (int3472->clock.ena_gpio) { + ret =skl_int3472_register_clock (int3472); +if (ret) + goto out_free_res_list; + }else {Hmm... Have I got it correctly that we can't have
ena_gpio&&led_gpiotogether?
No, just that we can only have led_gpio if we also have ena_gpio (at least that's the intention...)
Quoted 19 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (ret) + ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,This I don't like. Since we get a returned variable with different meaning, can we use a specific variable name for it? On top of that, I would rather see something like this:
whatever = skl_...(...); switch (whatever) { case WHATEVER_ONE_CASE: if (cldb.control_logic_type != 2) { dev_err(&client->dev, "Unsupported control logic type %u\n", cldb.control_logic_type); return -EINVAL; } cells_data = tps68470_win; cells_size = ARRAY_SIZE(tps68470_win); break; case WHATEVER_ANOTHER_CASE: ...
Quoted 9 lines
break; default: ...Oops... break; // or return -ERRNO } return devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, cells_data, cells_size, NULL, 0, NULL);
Yeah I guess that's a bit obscure at first glance; alright, I'll follow this to make it clearer what's happening there.
Hi Hans
Quoted 8 lines · Hans de Goede
Hi Daniel,
Quoted 4 lines · Daniel Scally
Hello all
Apologies for the long delay since the last version of this series; the time I had free to work on it became somewhat restrained.
No worries, thank you for all the work you are putting into this.
My pleasure
Quoted 17 lines
I have not taken a close look at the code yet, but I see that Andy has and the amount of remarks which he has on patch 7/8 which is the big one seems to be limited, so I believe that we are getting close to this being ready for merging.
This touches a lot of subsystems, so we need to come up with a plan to merge this. Here is my proposal for how to do this:
1/8 ACPI: scan: Extend acpi_walk_dep_device_list() 2/8 ACPI: scan: Add function to fetch dependent of acpi device 3/8 i2c: core: Add a format macro for I2C device names 4/8 gpiolib: acpi: Export acpi_get_gpiod() 5/8 clkdev: Make clkdev_drop() null aware 6/8 gpiolib: acpi: Add acpi_gpio_get_io_resource() 7/8 platform/x86: Add intel_skl_int3472 driver 8/8 mfd: tps68470: Remove tps68470 MFD driver
Quoted 3 lines
Rafael already indicated that he wants to merge 1/8 (and presumably also 2/8) through his tree and that he will provide an immutable branch with those for merging into the pdx86 tree.
I'll send a v5 with the renames asap, might try and do the other changes and send the whole series, depends how much time I get to work on it over the next few days...
Quoted 3 lines
4/8 and 6/8 are both gpiolib-acpi patches and seem to be ready for merging now, perhaps the gpiolib-acpi maintainers can already merge these and also provide an immutable branch ? Andy/Mika ?
So, Andy, you'd prefer I re-order these so they're consecutive...did I understand that right?
Quoted 9 lines
3/8 and 5/8 seem to be nice cleanups, but not really necessary. IMHO it would be best to park these cleanups for later and for 3/8 add the following where necessary for now:
/* FIXME drop this once the
I2C_DEV_NAME_FORMATmacro has been added toinclude/linux/i2c.h*/ #ifndefI2C_DEV_NAME_FORMAT
#defineI2C_DEV_NAME_FORMAT"i2c-%s"
#endif
Quoted 8 lines
This is not the prettiest but it reduces all the subsys cross-deps and things like this have been done before for similar reasons.
Likewise it would be good if you can add if (foo) as condition before any
clkdev_drop(foo)calls in this patch-set and then merge
5/8 "clkdev: Makeclkdev_drop()null aware" independently of this and then once both are in Linux tree follow-up with a cleanup patch dropping the if (foo) guards.
This is fine by me if people are happy for it to go in like that; I'll just fix it up later.
Quoted 12 lines
So this would leave as deps for 7/8 just the 2 ACPI and 2 gpiolib-acpi patches which I can hopefully pull-in via immutable branches and then we are good.
AFAICT patch 8/8 can be merged independently once 7/8 hits for-next (IOW once we are sure the next kernel will have 7/8).
Or alternatively one of the involved subsys maintainers just merges the entire set (once it is ready) and then provides an immutable branch with the entire set on top of 5.13-rc1 (or 5.14-rc1). But that requires acks from all the other subsys maintainers. Note I'm fine with either approach.
Re: [PATCH v4 7/8] platform/x86: Add intel_skl_int3472 driver
In reply to Daniel ScallyQuoted 1 line · Daniel Scally
On 21/05/2021 13:57, Andy Shevchenko wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
+static const struct
regulator_opsint3472_gpio_regulator_ops;Hmm... Can you use 'reg-fixed-voltage' platform device instead?
One example, although gone from upstream, but available in the tree, I can point to is this:
git log -p --
arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
Quoted 7 lines
Quoted 3 lines
It uses constant structures, but I think you may dynamically generate the necessary ones.
I can experiment with this, though one thing is we have no actual idea what voltages these are supplying...it doesn't look like that matters from
drivers/regulator/fixed.c, but I'd have to try it to be sure.
I believe it is likely 1.8v. But I can check if I have the schematics of a reference design for something like this.
...
Quoted 10 lines
Quoted 6 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c line 318
Quoted 5 lines
drivers/platform/x86/intel-int3472/intel_skl_int3472_discrete.c new file +5
-0+if (int3472->clock.ena_gpio) { + ret =skl_int3472_register_clock (int3472); +if (ret) + goto out_free_res_list; + }else {Hmm... Have I got it correctly that we can't have
ena_gpio&&led_gpiotogether?No, just that we can only have
led_gpioif we also haveena_gpio(at least that's the intention...)
Okay, perhaps then a comment above?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 2 lines · Daniel Scally
Quoted 1 line · Hans de Goede
On 5/20/21 4:09 PM, Daniel Scally wrote:
...
Quoted 7 lines
Quoted 3 lines
4/8 and 6/8 are both gpiolib-acpi patches and seem to be ready for merging now, perhaps the gpiolib-acpi maintainers can already merge these and also provide an immutable branch ? Andy/Mika ?
So, Andy, you'd prefer I re-order these so they're consecutive...did I understand that right?
Yes.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
On 5/26/21 1:03 AM, Daniel Scally wrote:
<snip>
Quoted 19 lines
Quoted 9 lines
3/8 and 5/8 seem to be nice cleanups, but not really necessary. IMHO it would be best to park these cleanups for later and for 3/8 add the following where necessary for now:
/* FIXME drop this once the
I2C_DEV_NAME_FORMATmacro has been added toinclude/linux/i2c.h*/ #ifndefI2C_DEV_NAME_FORMAT
#defineI2C_DEV_NAME_FORMAT"i2c-%s"
#endifQuoted 8 lines
This is not the prettiest but it reduces all the subsys cross-deps and things like this have been done before for similar reasons.
Likewise it would be good if you can add if (foo) as condition before any
clkdev_drop(foo)calls in this patch-set and then merge
5/8 "clkdev: Makeclkdev_drop()null aware" independently of this and then once both are in Linux tree follow-up with a cleanup patch dropping the if (foo) guards.
Quoted 2 lines
This is fine by me if people are happy for it to go in like that; I'll just fix it up later.
I don't expect anyone to object against these 2 small fixes going in later, if you can drop these 2 for v5 that would greatly help with untangling all the subsys dependencies. Then I can just merge an ACPI + a gpiolib-acpi immutable branch and then merge the big drivers/platform/x86 patch.
Regards,
Hans