Improve IRQ wake capability reporting and update the cros_ec driver to use it
Subsystems (19)
v3 cover Improve IRQ wake capability reporting and update the cros_ec driver to use it
Currently the cros_ec driver assumes that its associated interrupt is wake capable. This is an incorrect assumption as some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. This patch train updates the driver to query the underlying ACPI/DT data to determine whether or not the IRQ should be enabled for wake.
Both the device tree and ACPI systems have methods for reporting IRQ wake capability. In device tree based systems, a node can advertise itself as a 'wakeup-source'. In ACPI based systems, GpioInt and Interrupt resource descriptors can use the 'SharedAndWake' or 'ExclusiveAndWake' share types.
Some logic is added to the platform, ACPI, and DT subsystems to more easily pipe wakeirq information up to the driver.
Changes in v3:
-Rebase on linux-next
-See each patch for patch specific changes
Changes in v2:
-Rebase on linux-next
-Add cover letter
-See each patch for patch specific changes
Mark Hasemeyer (24):
resource: Add DEFINE_RES_*_NAMED_FLAGS macro
gpiolib: acpi: Modify acpi_dev_irq_wake_get_by() to use resource
i2c: acpi: Modify i2c_acpi_get_irq() to use resource
dt-bindings: power: Clarify wording for wakeup-source property
ARM: dts: tegra: Enable cros-ec-spi as wake source
ARM: dts: rockchip: rk3288: Enable cros-ec-spi as wake source
ARM: dts: samsung: exynos5420: Enable cros-ec-spi as wake source
ARM: dts: samsung: exynos5800: Enable cros-ec-spi as wake source
arm64: dts: mediatek: mt8173: Enable cros-ec-spi as wake source
arm64: dts: mediatek: mt8183: Enable cros-ec-spi as wake source
arm64: dts: mediatek: mt8192: Enable cros-ec-spi as wake source
arm64: dts: mediatek: mt8195: Enable cros-ec-spi as wake source
arm64: dts: tegra: Enable cros-ec-spi as wake source
arm64: dts: qcom: sc7180: Enable cros-ec-spi as wake source
arm64: dts: qcom: sc7280: Enable cros-ec-spi as wake source
arm64: dts: qcom: sdm845: Enable cros-ec-spi as wake source
arm64: dts: rockchip: rk3399: Enable cros-ec-spi as wake source
of: irq: add wake capable bit to of_irq_resource()
of: irq: Add default implementation for of_irq_to_resource()
of: irq: Remove extern from function declarations device property: Modify fwnode irq_get() to use resource device property: Update functions to use EXPORT_SYMBOL_GPL
platform: Modify platform_get_irq_optional() to use resource platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
.../bindings/power/wakeup-source.txt | 18 +++-- arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi | 1 + arch/arm/boot/dts/nvidia/tegra124-venice2.dts | 1 + .../rockchip/rk3288-veyron-chromebook.dtsi | 1 + .../boot/dts/samsung/exynos5420-peach-pit.dts | 1 + .../boot/dts/samsung/exynos5800-peach-pi.dts | 1 + arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 1 + .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + .../boot/dts/mediatek/mt8192-asurada.dtsi | 1 + .../boot/dts/mediatek/mt8195-cherry.dtsi | 1 + .../arm64/boot/dts/nvidia/tegra132-norrin.dts | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 1 + .../arm64/boot/dts/qcom/sc7280-herobrine.dtsi | 1 + .../arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi | 1 + arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi | 1 + arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 1 + drivers/acpi/property.c | 11 ++- drivers/base/platform.c | 70 +++++++++++++------ drivers/base/property.c | 32 +++++++-- drivers/gpio/gpiolib-acpi.c | 27 ++++--- drivers/i2c/i2c-core-acpi.c | 37 +++++----- drivers/i2c/i2c-core-base.c | 6 +- drivers/i2c/i2c-core.h | 4 +- drivers/of/irq.c | 39 +++++++++-- drivers/of/property.c | 8 +-- drivers/platform/chrome/cros_ec.c | 48 ++++++++++--- drivers/platform/chrome/cros_ec_lpc.c | 32 ++++++++- drivers/platform/chrome/cros_ec_spi.c | 15 ++-- drivers/platform/chrome/cros_ec_uart.c | 22 ++++-- include/linux/acpi.h | 23 +++--- include/linux/fwnode.h | 8 ++- include/linux/ioport.h | 20 ++++-- include/linux/of_irq.h | 41 ++++++----- include/linux/platform_data/cros_ec_proto.h | 4 +- include/linux/platform_device.h | 3 + include/linux/property.h | 2 + 36 files changed, 336 insertions(+), 149 deletions(-)
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 1/24 resource: Add DEFINE_RES_*_NAMED_FLAGS macro
In some cases, it would be nice to instantiate a struct resource with custom flags. For example, creating an IRQ resource with a flag that marks the interrupt as wake capable.
Add a set of macros to provide custom flag arguments.
---
Changes in v3:
-New patch
include/linux/ioport.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
include/linux/ioport.h +15 -5
@@ -163,28 +163,38 @@ enum { .desc = IORES_DESC_NONE, \ } +#define DEFINE_RES_IO_NAMED_FLAGS (_start, _size, _name, _flags) \ + DEFINE_RES_NAMED((_start), (_size), (_name), (_flags) | IORESOURCE_IO)#define DEFINE_RES_IO_NAMED (_start, _size, _name) \ - DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO) + DEFINE_RES_IO_NAMED_FLAGS((_start), (_size), (_name), 0)#define DEFINE_RES_IO (_start, _size) \ DEFINE_RES_IO_NAMED((_start), (_size), NULL) +#define DEFINE_RES_MEM_NAMED_FLAGS (_start, _size, _name, _flags) \ + DEFINE_RES_NAMED((_start), (_size), (_name), (_flags) | IORESOURCE_MEM)#define DEFINE_RES_MEM_NAMED (_start, _size, _name) \ - DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_MEM) + DEFINE_RES_MEM_NAMED_FLAGS((_start), (_size), (_name), 0)#define DEFINE_RES_MEM (_start, _size) \ DEFINE_RES_MEM_NAMED((_start), (_size), NULL) +#define DEFINE_RES_REG_NAMED_FLAGS (_start, _size, _name, _flags) \ + DEFINE_RES_NAMED((_start), (_size), (_name), (_flags) | IORESOURCE_REG)#define DEFINE_RES_REG_NAMED (_start, _size, _name) \ - DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_REG) + DEFINE_RES_REG_NAMED_FLAGS((_start), (_size), (_name), 0)#define DEFINE_RES_REG (_start, _size) \ DEFINE_RES_REG_NAMED((_start), (_size), NULL) +#define DEFINE_RES_IRQ_NAMED_FLAGS (_irq, _name, _flags) \ + DEFINE_RES_NAMED((_irq), 1, (_name), (_flags) | IORESOURCE_IRQ)#define DEFINE_RES_IRQ_NAMED (_irq, _name) \ - DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) + DEFINE_RES_IRQ_NAMED_FLAGS((_irq), (_name), 0)#define DEFINE_RES_IRQ (_irq) \ DEFINE_RES_IRQ_NAMED((_irq), NULL) +#define DEFINE_RES_DMA_NAMED_FLAGS (_dma, _name, _flags) \ + DEFINE_RES_NAMED((_dma), 1, (_name), (_flags) | IORESOURCE_DMA)#define DEFINE_RES_DMA_NAMED (_dma, _name) \ - DEFINE_RES_NAMED((_dma), 1, (_name), IORESOURCE_DMA) + DEFINE_RES_DMA_NAMED_FLAGS((_dma), (_name), 0)#define DEFINE_RES_DMA (_dma) \ DEFINE_RES_DMA_NAMED((_dma), NULL)
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 01/24] resource: Add DEFINE_RES_*_NAMED_FLAGS macro
Quoted 7 lines · Mark Hasemeyer
In some cases, it would be nice to instantiate a struct resource with custom flags. For example, creating an IRQ resource with a flag that marks the interrupt as wake capable.
Add a set of macros to provide custom flag arguments.
Suggested-by Andy Shevchenko <[email protected]>
Was it @intel.com? Please, use @linux.intel.com anyway.
Quoted 1 line
Signed-off-by Mark Hasemeyer <[email protected]>
Tag block must _not_ have any blank line(s).
Otherwise LGTM,
While we will have user only for IRQ case, the rest are added for symmetry's sake, I think it's okay and we might even have more (existing) users to convert to new macros (at least it rings a bell to me for a few places).
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 2/24 gpiolib: acpi: Modify acpi_dev_irq_wake_get_by() to use resource
In reply to Mark HasemeyerOther information besides wake capability can be provided about GPIO IRQs such as triggering, polarity, and sharability. Use resource flags to provide this information to the caller if they want it.
This should keep the API more robust over time as flags are added, modified, or removed. It also more closely matches acpi_irq_get() which take a resource as an argument.
Rename the function to acpi_dev_get_gpio_irq_resource() to better describe the function's new behavior.
---
Changes in v3:
-Use DEFINE_RES_NAMED macro
-Add acpi_gpio_info.shareable doc
Changes in v2:
-Remove explicit cast to struct resource
-irq -> IRQ
drivers/gpio/gpiolib-acpi.c | 27 ++++++++++++++++++--------- drivers/i2c/i2c-core-acpi.c | 10 ++++++++-- include/linux/acpi.h | 23 ++++++++++------------- 3 files changed, 36 insertions(+), 24 deletions(-)
drivers/gpio/gpiolib-acpi.c +18 -9
@@ -99,6 +99,7 @@ struct acpi_gpio_chip {* @pin_config: pin bias as provided by ACPI * @polarity: interrupt polarity as provided by ACPI * @triggering: triggering type as provided by ACPI +* @shareable: share type as provided by ACPI (shared vs exclusive). * @wake_capable: wake capability as provided by ACPI * @debounce: debounce timeout as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
@@ -111,6 +112,7 @@ struct acpi_gpio_info {int polarity;int triggering;bool wake_capable; +bool shareable;unsigned int debounce;unsigned int quirks; };
@@ -760,6 +762,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; lookup->info.wake_capable =acpi_gpio_irq_is_wake (&lookup->info.adev->dev, agpio); + lookup->info.shareable = agpio->shareable ==ACPI_SHARED ;/* * Polarity and triggering are only specified for GpioInt
@@ -1004,11 +1007,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, }/** -* acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ number +* acpi_dev_get_gpio_irq_resource() - Find GpioInt and populate resource struct * @adev: pointer to a ACPI device to get IRQ from * @name: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) -* @wake_capable: Set to true if the IRQ is wake capable +* @r: pointer to resource to populate with IRQ information. * * If the device has one or more GpioInt resources, this function can be * used to translate from the GPIO offset in the resource to the Linux IRQ
@@ -1023,10 +1026,12 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,* The GPIO is considered wake capable if the GpioInt resource specifies * SharedAndWake or ExclusiveAndWake. * -* Return: Linux IRQ number (> %0) on success, negative errno on failure. +* IRQ number will be available in the resource structure. +* +* Return: 0 on success, negative errno on failure. */ -int acpi_dev_gpio_irq_wake_get_by (struct acpi_device *adev,const char *name,int index, -bool *wake_capable) +int acpi_dev_get_gpio_irq_resource (struct acpi_device *adev,const char *name,int index, +struct resource *r) {int idx, i;unsigned int irq_flags;
@@ -1045,6 +1050,7 @@ int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, inif (info.gpioint && idx++ == index) {unsigned long lflags =GPIO_LOOKUP_FLAGS_DEFAULT ;enum gpiod_flags dflags =GPIOD_ASIS ; +unsigned long res_flags;char label[32 ];int irq;
@@ -1084,16 +1090,19 @@ int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, in }/* avoid suspend issues with GPIOs when systems are using S3 */ -if (wake_capable && acpi_gbl_FADT.flags &ACPI_FADT_LOW_POWER_S0 ) - *wake_capable = info.wake_capable; +if (info.wake_capable && !(acpi_gbl_FADT.flags &ACPI_FADT_LOW_POWER_S0 )) + info.wake_capable = false; -return irq; + res_flags =acpi_dev_irq_flags (info.triggering, info.polarity, + info.shareable, info.wake_capable); + *r =DEFINE_RES_NAMED (irq,1 ,NULL , res_flags); +return 0 ; } }return -ENOENT ; } -EXPORT_SYMBOL_GPL (acpi_dev_gpio_irq_wake_get_by); +EXPORT_SYMBOL_GPL (acpi_dev_get_gpio_irq_resource); static acpi_status acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
drivers/i2c/i2c-core-acpi.c +8 -2
@@ -203,6 +203,7 @@ int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable) {struct acpi_device *adev =ACPI_COMPANION (&client->dev);struct list_head resource_list; +struct resource irqres;struct i2c_acpi_irq_context irq_ctx = { .irq = -ENOENT , };
@@ -217,8 +218,13 @@ int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable)acpi_dev_free_resource_list (&resource_list); -if (irq_ctx.irq == -ENOENT ) - irq_ctx.irq =acpi_dev_gpio_irq_wake_get (adev,0 , &irq_ctx.wake_capable); +if (irq_ctx.irq == -ENOENT ) { + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres); +if (ret) +return ret; + irq_ctx.irq = irqres.start; + irq_ctx.wake_capable = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; + }if (irq_ctx.irq <0 )return irq_ctx.irq;
include/linux/acpi.h +10 -13
@@ -1221,8 +1221,8 @@ 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_wake_get_by (struct acpi_device *adev,const char *name,int index, -bool *wake_capable); +int acpi_dev_get_gpio_irq_resource (struct acpi_device *adev,const char *name,int index, +struct resource *r);#else static inline bool acpi_gpio_get_irq_resource (struct acpi_resource *ares,struct acpi_resource_gpio **agpio)
@@ -1234,28 +1234,25 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, {return false; } -static inline int acpi_dev_gpio_irq_wake_get_by (struct acpi_device *adev,const char *name, -int index,bool *wake_capable) +static inline int acpi_dev_get_gpio_irq_resource (struct acpi_device *adev,const char *name, +int index,struct resource *r) {return -ENXIO ; }#endif -static inline int acpi_dev_gpio_irq_wake_get (struct acpi_device *adev,int index, -bool *wake_capable) +static inline int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name,int index) { -return acpi_dev_gpio_irq_wake_get_by (adev,NULL , index, wake_capable); -} +struct resource r; +int ret; -static inline int acpi_dev_gpio_irq_get_by (struct acpi_device *adev,const char *name, -int index) -{ -return acpi_dev_gpio_irq_wake_get_by (adev, name, index,NULL ); + ret =acpi_dev_get_gpio_irq_resource (adev, name, index, &r); +return ret ?: r.start; }static inline int acpi_dev_gpio_irq_get (struct acpi_device *adev,int index) { -return acpi_dev_gpio_irq_wake_get_by (adev,NULL , index,NULL ); +return acpi_dev_gpio_irq_get_by (adev,NULL , index); }/* Device properties */
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 02/24] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by() to use resource
Quoted 10 lines · Mark Hasemeyer
Other information besides wake capability can be provided about GPIO IRQs such as triggering, polarity, and sharability. Use resource flags to provide this information to the caller if they want it.
This should keep the API more robust over time as flags are added, modified, or removed. It also more closely matches
acpi_irq_get()which take a resource as an argument.Rename the function to
acpi_dev_get_gpio_irq_resource()to better describe the function's new behavior.
...
drivers/gpio/gpiolib-acpi.c int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, in · line 1097
Quoted 2 lines
drivers/gpio/gpiolib-acpi.c +2
-0+ res_flags =acpi_dev_irq_flags (info.triggering, info.polarity, + info.shareable, info.wake_capable);
Broken indentation of the second line.
...
drivers/gpio/gpiolib-acpi.c int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, in · line 1098
Quoted 1 line
drivers/gpio/gpiolib-acpi.c +1
-0+ *r =DEFINE_RES_NAMED (irq,1 ,NULL , res_flags);
So? The whole exercise with the first patch is to have here:
*r = DEFINE_RES_IRQ_NAMED_FLAGS(irq, NULL, res_flags);
...
include/linux/acpi.h static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, · line 1246
Quoted 1 line
include/linux/acpi.h +1
-0+struct resource r;
I prefer to see
struct resource r = {};even if it makes no difference. This allows to have robust code.
include/linux/acpi.h static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, · line 1250
Quoted 2 lines
include/linux/acpi.h +2
-0+ ret =acpi_dev_get_gpio_irq_resource (adev, name, index, &r); +return ret ?: r.start;
Btw, this function requires header to include ioport.h. I'm not sure if it's good for ACPI. I would prefer safest approach, i.e. exporting this from a C code, i.e. gpiolib-acpi.c.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 02/24] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by() to use resource
Quoted 6 lines
Quoted 2 lines
+ *r =
DEFINE_RES_NAMED(irq, 1, NULL, res_flags);So? The whole exercise with the first patch is to have here:
*r = DEFINE_RES_IRQ_NAMED_FLAGS(irq, NULL, res_flags);
Thanks. I was staring at the macro changes in ioport.h for too long...
Quoted 7 lines
include/linux/acpi.h static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, · line 1250
Quoted 3 lines
include/linux/acpi.h +2
-0+ ret =acpi_dev_get_gpio_irq_resource (adev, name, index, &r); +return ret ?: r.start;Btw, this function requires header to include
ioport.h. I'm not sure if it's good for ACPI. I would prefer safest approach, i.e. exporting this from a C code, i.e.gpiolib-acpi.c.
It actually just needs 'struct resource' declared. I removed the dependency on ioport.h, but it may make sense to leave the definition of 'acpi_dev_gpio_irq_get_by()' here because non ACPI based systems need a default implementation anyway.
PATCH v3 3/24 i2c: acpi: Modify i2c_acpi_get_irq() to use resource
In reply to Mark HasemeyerThe i2c_acpi_irq_context structure provides redundant information that can be provided with struct resource.
Refactor i2c_acpi_get_irq() to use struct resource instead of struct i2c_acpi_irq_context.
---
Changes in v3:
-Add Suggested-by
-Check resource flags for valid irq
-Drop error pointer check
-Invert error checking logic in i2c_acpi_get_irq() -Drop redundant 0 in struct resource init
-Drop unnecessary check for irq > 0 when setting I2C_CLIENT_WAKE
Changes in v2:
-New patch
drivers/i2c/i2c-core-acpi.c | 43 ++++++++++++++----------------------- drivers/i2c/i2c-core-base.c | 6 +++--- drivers/i2c/i2c-core.h | 4 ++-- 3 files changed, 21 insertions(+), 32 deletions(-)
drivers/i2c/i2c-core-acpi.c +16 -27
@@ -175,64 +175,53 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev,static int i2c_acpi_add_irq_resource (struct acpi_resource *ares,void *data) { -struct i2c_acpi_irq_context *irq_ctx = data; -struct resource r; +struct resource *r = data; -if (irq_ctx->irq >0 ) +if (r->flags)return 1 ; -if (!acpi_dev_resource_interrupt (ares,0 , &r)) +if (!acpi_dev_resource_interrupt (ares,0 , r))return 1 ; - irq_ctx->irq =i2c_dev_irq_from_resources (&r,1 ); - irq_ctx->wake_capable = r.flags &IORESOURCE_IRQ_WAKECAPABLE ; +i2c_dev_irq_from_resources (r,1 );return 1 ;/* No need to add resource to the list */ }/** -* i2c_acpi_get_irq - get device IRQ number from ACPI +* i2c_acpi_get_irq - get device IRQ number from ACPI and populate resource * @client: Pointer to the I2C client device -* @wake_capable: Set to true if the IRQ is wake capable +* @r: resource with populated IRQ information * * Find the IRQ number used by a specific client device. * * Return: The IRQ number or an error code. */ -int i2c_acpi_get_irq (struct i2c_client *client,bool *wake_capable) +int i2c_acpi_get_irq (struct i2c_client *client,struct resource *r) {struct acpi_device *adev =ACPI_COMPANION (&client->dev);struct list_head resource_list; -struct resource irqres; -struct i2c_acpi_irq_context irq_ctx = { - .irq = -ENOENT , - };int ret; +if (!r) +return -EINVAL ; +INIT_LIST_HEAD (&resource_list); ret =acpi_dev_get_resources (adev, &resource_list, - i2c_acpi_add_irq_resource, &irq_ctx); + i2c_acpi_add_irq_resource, r);if (ret <0 )return ret;acpi_dev_free_resource_list (&resource_list); -if (irq_ctx.irq == -ENOENT ) { - ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres); -if (ret) -return ret; - irq_ctx.irq = irqres.start; - irq_ctx.wake_capable = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; - } - -if (irq_ctx.irq <0 ) -return irq_ctx.irq; +if (!r->flags) + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , r); -if (wake_capable) - *wake_capable = irq_ctx.wake_capable; +if (!r->flags) +return ret; -return irq_ctx.irq; +return r->start; } static int i2c_acpi_get_info(struct acpi_device *adev,
drivers/i2c/i2c-core-base.c +3 -3
@@ -513,10 +513,10 @@ static int i2c_device_probe(struct device *dev)if (irq == -EINVAL || irq == -ENODATA ) irq =of_irq_get (dev->of_node,0 ); }else if (ACPI_COMPANION (dev)) { -bool wake_capable; +struct resource r = {}; - irq =i2c_acpi_get_irq (client, &wake_capable); -if (irq >0 && wake_capable) + irq =i2c_acpi_get_irq (client, &r); +if (r.flags &IORESOURCE_IRQ_WAKECAPABLE ) client->flags |=I2C_CLIENT_WAKE ; }if (irq == -EPROBE_DEFER ) {
drivers/i2c/i2c-core.h +2 -2
@@ -61,11 +61,11 @@ static inline int __i2c_check_suspended(struct i2c_adapter *adap)#ifdef CONFIG_ACPI void i2c_acpi_register_devices (struct i2c_adapter *adap); -int i2c_acpi_get_irq (struct i2c_client *client,bool *wake_capable); +int i2c_acpi_get_irq (struct i2c_client *client,struct resource *r);#else /* CONFIG_ACPI */ static inline void i2c_acpi_register_devices (struct i2c_adapter *adap) { } -static inline int i2c_acpi_get_irq (struct i2c_client *client,bool *wake_capable) +static inline int i2c_acpi_get_irq (struct i2c_client *client,struct resource *r) {return 0 ; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 03/24] i2c: acpi: Modify i2c_acpi_get_irq() to use resource
Quoted 5 lines · Mark Hasemeyer
The
i2c_acpi_irq_contextstructure provides redundant information that can be provided with struct resource.Refactor
i2c_acpi_get_irq()to use struct resource instead of structi2c_acpi_irq_context.
...
Quoted 3 lines
Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Mark Hasemeyer <[email protected]>
No blank line.
...
Quoted 18 lines
drivers/i2c/i2c-core-acpi.c +1
-11ret =acpi_dev_get_resources (adev, &resource_list, - i2c_acpi_add_irq_resource, &irq_ctx); + i2c_acpi_add_irq_resource, r);if (ret <0 )return ret;acpi_dev_free_resource_list (&resource_list); -if (irq_ctx.irq == -ENOENT ) { - ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres); -if (ret) -return ret; - irq_ctx.irq = irqres.start; - irq_ctx.wake_capable = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; - } - -if (irq_ctx.irq <0 ) -return irq_ctx.irq;
drivers/i2c/i2c-core-acpi.c static int i2c_acpi_do_lookup(struct acpi_device *adev, · line 224
Quoted 10 lines
drivers/i2c/i2c-core-acpi.c +5
-3+if (!r->flags) + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , r); -if (wake_capable) - *wake_capable = irq_ctx.wake_capable; +if (!r->flags) +return ret; -return irq_ctx.irq; +return r->start;
Wondering if we can refactor above as
if (r->flags) return r->start; ret = acpi_dev_get_gpio_irq_resource(adev, NULL, 0, r); if (ret) return ret; return r->start;
Note also the 'if (ret)' check, the check for flags to return ret seems counter intuitive and possible prone to errors in the future.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 4/24 dt-bindings: power: Clarify wording for wakeup-source property
In reply to Mark HasemeyerThe wording in the current documentation is a little strong. The intention was not to fix any particular interrupt as wakeup capable but leave those details to the device. It wasn't intended to enforce any rules as what can be or can't be a wakeup interrupt.
Soften the wording to not mandate that the 'wakeup-source' property be used, and clarify what it means when an interrupt is marked (or not marked) for wakeup.
---
Changes in v3:
-Update commit title prefixes
Changes in v2:
-New patch
.../bindings/power/wakeup-source.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/power/wakeup-source.txt +11 -7
@@ -3,16 +3,20 @@ Specifying wakeup capability for devices Any device nodes ---------------- -Nodes that describe devices which has wakeup capability must contain an +Nodes that describe devices which have wakeup capability may contain a "wakeup-source" boolean property. -Also, if device is marked as a wakeup source, then all the primary -interrupt(s) can be used as wakeup interrupt(s). +If the device is marked as a wakeup-source, interrupt wake capability depends +on the device specific "interrupt-names" property. If no interrupts are labeled +as wake capable, then it is up to the device to determine which interrupts can +wake the system. -However if the devices have dedicated interrupt as the wakeup source -then they need to specify/identify the same using device specific -interrupt name. In such cases only that interrupt can be used as wakeup -interrupt. +However if a device has a dedicated interrupt as the wakeup source, then it +needs to specify/identify it using a device specific interrupt name. In such +cases only that interrupt can be used as a wakeup interrupt. + +While various legacy interrupt names exist, new devices should use "wakeup" as +the canonical interrupt name. List of legacy properties and respective binding document ---------------------------------------------------------
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 5/24 ARM: dts: tegra: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi | 1 + arch/arm/boot/dts/nvidia/tegra124-venice2.dts | 1 + 2 files changed, 2 insertions(+)
arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi +1 -0
@@ -338,6 +338,7 @@ cros_ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = <TEGRA_GPIO(C, 7) IRQ_TYPE_LEVEL_LOW>; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>;
arch/arm/boot/dts/nvidia/tegra124-venice2.dts +1 -0
@@ -857,6 +857,7 @@ cros_ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = <TEGRA_GPIO(C, 7) IRQ_TYPE_LEVEL_LOW>; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 6/24 ARM: dts: rockchip: rk3288: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi +1 -0
@@ -112,6 +112,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_int>; spi-max-frequency = <3000000>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 7/24 ARM: dts: samsung: exynos5420: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts +1 -0
@@ -967,6 +967,7 @@ cros_ec: cros-ec@0 { reg = <0>; spi-max-frequency = <3125000>; google,has-vbc-nvram; + wakeup-source; controller-data { samsung,spi-feedback-delay = <1>;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 07/24] ARM: dts: samsung: exynos5420: Enable cros-ec-spi as wake source
Quoted 10 lines · Mark Hasemeyer
The
cros_ecdriver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Quoted 5 lines
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
This looks like changelog, although a bit confusing. If it is changelog, then please keep it under ---.
I can fix it while applying, but this will be after the merge window.
Best regards,
Krzysztof
PATCH v3 8/24 ARM: dts: samsung: exynos5800: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts +1 -0
@@ -949,6 +949,7 @@ cros_ec: cros-ec@0 { reg = <0>; spi-max-frequency = <3125000>; google,has-vbc-nvram; + wakeup-source; controller-data { samsung,spi-feedback-delay = <1>;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 9/24 arm64: dts: mediatek: mt8173: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi +1 -0
@@ -1155,6 +1155,7 @@ cros_ec: ec@0 { spi-max-frequency = <12000000>; interrupts-extended = <&pio 0 IRQ_TYPE_LEVEL_LOW>; google,cros-ec-spi-msg-delay = <500>; + wakeup-source; i2c_tunnel: i2c-tunnel0 { compatible = "google,cros-ec-i2c-tunnel";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 10/24 arm64: dts: mediatek: mt8183: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +1 -0
@@ -924,6 +924,7 @@ cros_ec: cros-ec@0 { interrupts-extended = <&pio 151 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_odl>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 11/24 arm64: dts: mediatek: mt8192: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi +1 -0
@@ -1332,6 +1332,7 @@ cros_ec: ec@0 { spi-max-frequency = <3000000>; pinctrl-names = "default"; pinctrl-0 = <&cros_ec_int>; + wakeup-source; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 12/24 arm64: dts: mediatek: mt8195: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +1 -0
@@ -1149,6 +1149,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&cros_ec_int>; spi-max-frequency = <3000000>; + wakeup-source; keyboard-backlight { compatible = "google,cros-kbd-led-backlight";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 13/24 arm64: dts: tegra: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/nvidia/tegra132-norrin.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/nvidia/tegra132-norrin.dts +1 -0
@@ -762,6 +762,7 @@ ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = <TEGRA_GPIO(C, 7) IRQ_TYPE_LEVEL_LOW>; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 14/24 arm64: dts: qcom: sc7180: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi +1 -0
@@ -649,6 +649,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 15/24 arm64: dts: qcom: sc7280: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi | 1 + 2 files changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi +1 -0
@@ -548,6 +548,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm";
arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi +1 -0
@@ -19,6 +19,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 16/24 arm64: dts: qcom: sdm845: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi +1 -0
@@ -852,6 +852,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 17/24 arm64: dts: rockchip: rk3399: Enable cros-ec-spi as wake source
In reply to Mark HasemeyerThe cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined.
Some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. With the current assumption, spurious wakes can occur on systems that use a separate wake pin. It is planned to update the driver to no longer assume that the EC interrupt pin should be enabled for wake.
Add the wakeup-source property to all cros-ec-spi compatible device nodes to signify to the driver that they should still be a valid wakeup source.
-Commit-changes: 3
-Update commit message to provide details of the motivation behind the change
---
(no changes since v2)
Changes in v2:
-Split by arch/soc
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +1 -0
@@ -603,6 +603,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_l>; spi-max-frequency = <3000000>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel";
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 18/24 of: irq: add wake capable bit to of_irq_resource()
In reply to Mark HasemeyerAdd wake capability information to the IRQ resource. Wake capability is assumed based on conventions provided in the devicetree wakeup-source binding documentation. An interrupt is considered wake capable if the following are true:
1. A wakeup-source property exits in the same device node as the interrupt.
2. The IRQ is marked as dedicated by setting its interrupt-name to "wakeup".
The wakeup-source documentation states that dedicated interrupts can use device specific interrupt names and device drivers are still welcome to use their own naming schemes. This API is provided as a helper if one is willing to conform to the above conventions.
The ACPI subsystems already provides similar APIs that allow one to query the wake capability of an IRQ. This brings closer feature parity to the devicetree.
---
Changes in v3:
-Use DEFINE_RES_IRQ_NAMED_FLAGS macro
Changes in v2:
-Update logic to return true only if wakeup-source property and
"wakeup" interrupt-name are defined
-irq->IRQ, api->API
drivers/of/irq.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
drivers/of/irq.c +35 -4
@@ -383,11 +383,39 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar }EXPORT_SYMBOL_GPL (of_irq_parse_one); +/** +* __of_irq_wake_capable - Determine whether a given IRQ index is wake capable +* +* The IRQ is considered wake capable if the following are true: +* 1. wakeup-source property exists +* 2. provided IRQ index is labelled as a dedicated wakeirq +* +* This logic assumes the provided IRQ index is valid. +* +* @dev: pointer to device tree node +* @index: zero-based index of the IRQ +* Return: True if provided IRQ index for #dev is wake capable. False otherwise. +*/ +static bool __of_irq_wake_capable (const struct device_node *dev,int index) +{ +int wakeindex; + +if (!of_property_read_bool (dev,"wakeup-source" )) +return false; + + wakeindex =of_property_match_string (dev,"interrupt-names" ,"wakeup" ); +return wakeindex >=0 && wakeindex == index; +} +/** * of_irq_to_resource - Decode a node's IRQ and return it as a resource * @dev: pointer to device tree node -* @index: zero-based index of the irq +* @index: zero-based index of the IRQ * @r: pointer to resource structure to return result into. +* +* Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or +* -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case +* of any other failure. */ int of_irq_to_resource (struct device_node *dev,int index,struct resource *r) {
@@ -399,6 +427,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)/* Only dereference the resource if both the * resource and the irq are valid. */ if (r && irq) { +u32 irq_flags;const char *name =NULL ;memset (r,0 ,sizeof (*r));
@@ -409,9 +438,11 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)of_property_read_string_index (dev,"interrupt-names" , index, &name); - r->start = r->end = irq; - r->flags =IORESOURCE_IRQ |irqd_get_trigger_type (irq_get_irq_data (irq)); - r->name = name ? name :of_node_full_name (dev); + irq_flags =irqd_get_trigger_type (irq_get_irq_data (irq)); +if (__of_irq_wake_capable (dev, index)) + irq_flags |=IORESOURCE_IRQ_WAKECAPABLE ; + + *r =DEFINE_RES_IRQ_NAMED_FLAGS (irq, name ?:of_node_full_name (dev), irq_flags); }return irq;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 18/24] of: irq: add wake capable bit to of_irq_resource()
Quoted 17 lines · Mark Hasemeyer
Add wake capability information to the IRQ resource. Wake capability is assumed based on conventions provided in the devicetree wakeup-source binding documentation. An interrupt is considered wake capable if the following are true:
1. A wakeup-source property exits in the same device node as the interrupt.
2. The IRQ is marked as dedicated by setting its interrupt-name to "wakeup".The wakeup-source documentation states that dedicated interrupts can use device specific interrupt names and device drivers are still welcome to use their own naming schemes. This API is provided as a helper if one is willing to conform to the above conventions.
The ACPI subsystems already provides similar APIs that allow one to query the wake capability of an IRQ. This brings closer feature parity to the devicetree.
...
drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 431
Quoted 2 lines
drivers/of/irq.c +1
-0+u32 irq_flags;const char *name =NULL ;
Don't know if OF style requires reversed xmas tree order. If so, this should be
const char *name = NULL; u32 irq_flags;
Otherwise looks good to me, FWIW,
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 18/24] of: irq: add wake capable bit to of_irq_resource()
Quoted 9 lines
Quoted 3 lines
+ u32 irq_flags; const char *name = NULL;Don't know if OF style requires reversed xmas tree order. If so, this should be
const char *name = NULL; u32 irq_flags;
I see both methods used. For example, of_irq_init() uses normal xmas tree order. I'll leave it unless Rob says otherwise.
It is Christmas time, so I do want to honor the Christmas trees appropriately!
Rob Herring
maintainerRe: [PATCH v3 18/24] of: irq: add wake capable bit to of_irq_resource()
Quoted 6 lines · Mark Hasemeyer
Quoted 6 lines
Quoted 3 lines
+ u32 irq_flags; const char *name = NULL;Don't know if OF style requires reversed xmas tree order. If so, this should be
Quoted 7 lines
Quoted 3 lines
const char *name = NULL; u32 irq_flags;I see both methods used. For example,
of_irq_init()uses normal xmas tree order. I'll leave it unless Rob says otherwise.
It is Christmas time, so I do want to honor the Christmas trees appropriately!
DT requires sideways Christmas tree because we're special. You'll have to add a 3rd variable. ;)
Rob
Re: [PATCH v3 18/24] of: irq: add wake capable bit to of_irq_resource()
In reply to Mark HasemeyerQuoted 26 lines · Mark Hasemeyer
Add wake capability information to the IRQ resource. Wake capability is assumed based on conventions provided in the devicetree wakeup-source binding documentation. An interrupt is considered wake capable if the following are true:
1. A wakeup-source property exits in the same device node as the interrupt.
2. The IRQ is marked as dedicated by setting its interrupt-name to "wakeup".The wakeup-source documentation states that dedicated interrupts can use device specific interrupt names and device drivers are still welcome to use their own naming schemes. This API is provided as a helper if one is willing to conform to the above conventions.
The ACPI subsystems already provides similar APIs that allow one to query the wake capability of an IRQ. This brings closer feature parity to the devicetree.
Signed-off-by Mark Hasemeyer <[email protected]>---
Changes in v3:
-UseDEFINE_RES_IRQ_NAMED_FLAGSmacroChanges in v2:
Review
Quoted 6 lines
(quoted diff) +0
-2-Update logic to return true only if wakeup-source property and "wakeup" interrupt-name are defined -irq->IRQ, api->API drivers/of/irq.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
PATCH v3 19/24 of: irq: Add default implementation for of_irq_to_resource()
In reply to Mark HasemeyerSimilar to of_irq_to_resource_table(), add a default implementation of of_irq_to_resource() for systems that don't have CONFIG_OF_IRQ defined.
---
(no changes since v2)
Changes in v2:
-None
include/linux/of_irq.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/of_irq.h +6 -2
@@ -34,8 +34,6 @@ static inline int of_irq_parse_oldworld(const struct device_node *device, int inextern int of_irq_parse_raw (const __be32 *addr,struct of_phandle_args *out_irq);extern unsigned int irq_create_of_mapping (struct of_phandle_args *irq_data); -extern int of_irq_to_resource (struct device_node *dev,int index, -struct resource *r);#ifdef CONFIG_OF_IRQ extern void of_irq_init (const struct of_device_id *matches);
@@ -44,6 +42,7 @@ extern int of_irq_parse_one(struct device_node *device, int index,extern int of_irq_count (struct device_node *dev);extern int of_irq_get (struct device_node *dev,int index);extern int of_irq_get_byname (struct device_node *dev,const char *name); +extern int of_irq_to_resource (struct device_node *dev,int index,struct resource *r);extern int of_irq_to_resource_table (struct device_node *dev,struct resource *res,int nr_irqs);extern struct device_node *of_irq_find_parent (struct device_node *child);
@@ -76,6 +75,11 @@ static inline int of_irq_get_byname(struct device_node *dev, const char *name) {return 0 ; } +static inline int of_irq_to_resource (struct device_node *dev,int index, +struct resource *r) +{ +return 0 ; +}static inline int of_irq_to_resource_table (struct device_node *dev,struct resource *res,int nr_irqs) {
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 19/24] of: irq: Add default implementation for of_irq_to_resource()
Quoted 6 lines · Mark Hasemeyer
Similar to
of_irq_to_resource_table(), add a default implementation ofof_irq_to_resource()for systems that don't haveCONFIG_OF_IRQdefined.Signed-off-by Mark Hasemeyer <[email protected]>---
Quoted 8 lines
(no changes since v2)
Changes in v2:
-Noneinclude/linux/of_irq.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Missing tags:
Re: [PATCH v3 19/24] of: irq: Add default implementation for of_irq_to_resource()
Quoted 9 lines
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Missing tags:
Acked-by Rob Herring <[email protected]>
Thanks Rob. They were not excluded on purpose. I just forgot to add them on a few patches. I have a new version coming, and will make sure to include them.
PATCH v3 20/24 of: irq: Remove extern from function declarations
In reply to Mark HasemeyerThe extern keyword is implicit for function declarations. Remove it where possible and adjust the line wrapping accordingly.
---
(no changes since v2)
Changes in v2:
-New patch
include/linux/of_irq.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
include/linux/of_irq.h +17 -18
@@ -32,27 +32,26 @@ static inline int of_irq_parse_oldworld(const struct device_node *device, int in }#endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ -extern int of_irq_parse_raw (const __be32 *addr,struct of_phandle_args *out_irq); -extern unsigned int irq_create_of_mapping (struct of_phandle_args *irq_data); +int of_irq_parse_raw (const __be32 *addr,struct of_phandle_args *out_irq); +unsigned int irq_create_of_mapping (struct of_phandle_args *irq_data);#ifdef CONFIG_OF_IRQ -extern void of_irq_init (const struct of_device_id *matches); -extern int of_irq_parse_one (struct device_node *device,int index, -struct of_phandle_args *out_irq); -extern int of_irq_count (struct device_node *dev); -extern int of_irq_get (struct device_node *dev,int index); -extern int of_irq_get_byname (struct device_node *dev,const char *name); -extern int of_irq_to_resource (struct device_node *dev,int index,struct resource *r); -extern int of_irq_to_resource_table (struct device_node *dev, -struct resource *res,int nr_irqs); -extern struct device_node *of_irq_find_parent (struct device_node *child); -extern struct irq_domain *of_msi_get_domain (struct device *dev, +void of_irq_init (const struct of_device_id *matches); +int of_irq_parse_one (struct device_node *device,int index, +struct of_phandle_args *out_irq); +int of_irq_count (struct device_node *dev); +int of_irq_get (struct device_node *dev,int index); +int of_irq_get_byname (struct device_node *dev,const char *name); +int of_irq_to_resource (struct device_node *dev,int index,struct resource *r); +int of_irq_to_resource_table (struct device_node *dev,struct resource *res, +int nr_irqs); +struct device_node *of_irq_find_parent (struct device_node *child); +struct irq_domain *of_msi_get_domain (struct device *dev,struct device_node *np,enum irq_domain_bus_token token); -extern struct irq_domain *of_msi_map_get_device_domain (struct device *dev, -u32 id, -u32 bus_token); -extern void of_msi_configure (struct device *dev,struct device_node *np); +struct irq_domain *of_msi_map_get_device_domain (struct device *dev,u32 id, +u32 bus_token); +void of_msi_configure (struct device *dev,struct device_node *np);u32 of_msi_map_id (struct device *dev,struct device_node *msi_np,u32 id_in);#else static inline void of_irq_init (const struct of_device_id *matches)
@@ -117,7 +116,7 @@ static inline u32 of_msi_map_id(struct device *dev,* implements it differently. However, the prototype is the same for all, * so declare it here regardless of the CONFIG_OF_IRQ setting. */ -extern unsigned int irq_of_parse_and_map (struct device_node *node,int index); +unsigned int irq_of_parse_and_map (struct device_node *node,int index);#else /* !CONFIG_OF && !CONFIG_SPARC */ static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 20/24] of: irq: Remove extern from function declarations
Quoted 6 lines · Mark Hasemeyer
The extern keyword is implicit for function declarations. Remove it where possible and adjust the line wrapping accordingly.
Signed-off-by Mark Hasemeyer <[email protected]>---
Quoted 8 lines
(no changes since v2)
Changes in v2:
-New patchinclude/linux/of_irq.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Missing tags:
PATCH v3 21/24 device property: Modify fwnode irq_get() to use resource
In reply to Mark HasemeyerThe underlying ACPI and OF subsystems provide their own APIs which provide IRQ information as a struct resource. This allows callers to get more information about the IRQ by looking at the resource flags. For example, whether or not an IRQ is wake capable.
---
Changes in v3:
-Add Suggested-by tag
-Initialize struct resource to 0 on stack
-EXPORT_SYMBOL()->EXPORT_SYMBOL_GPL()
-Remove extra space in commit message
-Reformat fwnode_irq_get_resource() declaration
Changes in v2:
-New patch
drivers/acpi/property.c | 11 +++++------ drivers/base/property.c | 24 +++++++++++++++++++++--- drivers/of/property.c | 8 ++++---- include/linux/fwnode.h | 8 +++++--- include/linux/property.h | 2 ++ 5 files changed, 37 insertions(+), 16 deletions(-)
drivers/acpi/property.c +5 -6
@@ -1627,17 +1627,16 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,return 0 ; } -static int acpi_fwnode_irq_get (const struct fwnode_handle *fwnode, -unsigned int index) +static int acpi_fwnode_irq_get_resource (const struct fwnode_handle *fwnode,unsigned int index, +struct resource *r) { -struct resource res;int ret; - ret =acpi_irq_get (ACPI_HANDLE_FWNODE (fwnode), index, &res); + ret =acpi_irq_get (ACPI_HANDLE_FWNODE (fwnode), index, r);if (ret)return ret; -return res.start; +return r->start; }#define DECLARE_ACPI_FWNODE_OPS (ops) \
@@ -1664,7 +1663,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, acpi_graph_get_remote_endpoint, \ .graph_get_port_parent = acpi_fwnode_get_parent, \ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ - .irq_get = acpi_fwnode_irq_get, \ + .irq_get_resource = acpi_fwnode_irq_get_resource, \ }; \EXPORT_SYMBOL_GPL (ops)
drivers/base/property.c +21 -3
@@ -1047,23 +1047,41 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index)EXPORT_SYMBOL (fwnode_iomap);/** -* fwnode_irq_get - Get IRQ directly from a fwnode +* fwnode_irq_get_resource - Get IRQ directly from a fwnode and populate +* the resource struct * @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ +* @r: Pointer to resource to populate with IRQ information. * * Return: Linux IRQ number on success. Negative errno on failure. */ -int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index) +int fwnode_irq_get_resource (const struct fwnode_handle *fwnode,unsigned int index, +struct resource *r) {int ret; - ret =fwnode_call_int_op (fwnode, irq_get, index); + ret =fwnode_call_int_op (fwnode, irq_get_resource, index, r);/* We treat mapping errors as invalid case */ if (ret ==0 )return -EINVAL ;return ret; } +EXPORT_SYMBOL_GPL (fwnode_irq_get_resource); + +/** +* fwnode_irq_get - Get IRQ directly from a fwnode +* @fwnode: Pointer to the firmware node +* @index: Zero-based index of the IRQ +* +* Return: Linux IRQ number on success. Negative errno on failure. +*/ +int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index) +{ +struct resource r = {}; + +return fwnode_irq_get_resource (fwnode, index, &r); +}EXPORT_SYMBOL (fwnode_irq_get);/**
drivers/of/property.c +4 -4
@@ -1425,10 +1425,10 @@ static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index)#endif } -static int of_fwnode_irq_get (const struct fwnode_handle *fwnode, -unsigned int index) +static int of_fwnode_irq_get_resource (const struct fwnode_handle *fwnode, +unsigned int index,struct resource *r) { -return of_irq_get (to_of_node (fwnode), index); +return of_irq_to_resource (to_of_node (fwnode), index, r); }static int of_fwnode_add_links (struct fwnode_handle *fwnode)
@@ -1469,7 +1469,7 @@ const struct fwnode_operations of_fwnode_ops = { .graph_get_port_parent = of_fwnode_graph_get_port_parent, .graph_parse_endpoint = of_fwnode_graph_parse_endpoint, .iomap = of_fwnode_iomap, - .irq_get = of_fwnode_irq_get, + .irq_get_resource = of_fwnode_irq_get_resource, .add_links = of_fwnode_add_links, };EXPORT_SYMBOL_GPL (of_fwnode_ops);
include/linux/fwnode.h +5 -3
@@ -9,10 +9,11 @@#ifndef _LINUX_FWNODE_H_#define _LINUX_FWNODE_H_ -#include <linux/types.h> -#include <linux/list.h> #include <linux/bits.h> #include <linux/err.h> +#include <linux/ioport.h> +#include <linux/list.h> +#include <linux/types.h> struct fwnode_operations ;struct device ;
@@ -164,7 +165,8 @@ struct fwnode_operations {int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,struct fwnode_endpoint *endpoint);void __iomem *(*iomap)(struct fwnode_handle *fwnode,int index); -int (*irq_get)(const struct fwnode_handle *fwnode,unsigned int index); +int (*irq_get_resource)(const struct fwnode_handle *fwnode, +unsigned int index,struct resource *r);int (*add_links)(struct fwnode_handle *fwnode); };
include/linux/property.h +2 -0
@@ -190,6 +190,8 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);void fwnode_handle_put (struct fwnode_handle *fwnode);int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index); +int fwnode_irq_get_resource (const struct fwnode_handle *fwnode, +unsigned int index,struct resource *r);int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name);unsigned int device_get_child_node_count (const struct device *dev);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 21/24] device property: Modify fwnode irq_get() to use resource
Quoted 4 lines · Mark Hasemeyer
The underlying ACPI and OF subsystems provide their own APIs which provide IRQ information as a struct resource. This allows callers to get more information about the IRQ by looking at the resource flags. For example, whether or not an IRQ is wake capable.
...
Quoted 3 lines
Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Mark Hasemeyer <[email protected]>
No blank line.
...
A side note: in all files where you use ioport.h check if you actually included it.
...
include/linux/fwnode.h line 16
Quoted 7 lines
include/linux/fwnode.h +3
-2-#include <linux/types.h> -#include <linux/list.h> #include <linux/bits.h> #include <linux/err.h> +#include <linux/ioport.h> +#include <linux/list.h> +#include <linux/types.h>
Fine, but no. This file is still not using the iopoll.h. See the forward declarations below? It should be there.
Quoted 2 lines
struct
fwnode_operations;
struct device;
...
include/linux/property.h
Quoted 2 lines
include/linux/property.h +0
-0
Same comment(s) here.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 21/24] device property: Modify fwnode irq_get() to use resource
Quoted 18 lines
A side note: in all files where you use
ioport.hcheck if you actually included it....
include/linux/fwnode.h line 16
Quoted 7 lines
include/linux/fwnode.h +3
-2-#include <linux/types.h> -#include <linux/list.h> #include <linux/bits.h> #include <linux/err.h> +#include <linux/ioport.h> +#include <linux/list.h> +#include <linux/types.h> Fine, but no. This file is still not using the
iopoll.h. See the forward declarations below? It should be there.Quoted 2 lines
struct
fwnode_operations;
struct device;
Quoted 6 lines
...
include/linux/property.h
Quoted 2 lines
include/linux/property.h +0
-0Same comment(s) here.
I don't fully follow. Are you suggesting adding an explicit 'struct resource' declaration as opposed to including ioport.h? If so, why? To reduce scope?
Re: [PATCH v3 21/24] device property: Modify fwnode irq_get() to use resource
Quoted 1 line · Mark Hasemeyer
Quoted 1 line
A side note: in all files where you use
ioport.hcheck if you actually included it.
...
Quoted 13 lines
Quoted 13 lines
include/linux/fwnode.h line 16
Quoted 7 lines
include/linux/fwnode.h +3
-2-#include <linux/types.h> -#include <linux/list.h> #include <linux/bits.h> #include <linux/err.h> +#include <linux/ioport.h> +#include <linux/list.h> +#include <linux/types.h> Fine, but no. This file is still not using the
iopoll.h. See the forward declarations below? It should be there.Quoted 2 lines
struct
fwnode_operations;
struct device;
...
Quoted 7 lines
Quoted 4 lines
include/linux/property.h
Quoted 2 lines
include/linux/property.h +0
-0Same comment(s) here.
I don't fully follow. Are you suggesting adding an explicit 'struct resource' declaration as opposed to including
ioport.h?
Yes.
Quoted 1 line
If so, why? To reduce scope?
Build time, better granularity, less include hellness.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 22/24 device property: Update functions to use EXPORT_SYMBOL_GPL
In reply to Mark HasemeyerSome of the exported functions use EXPORT_SYMBOL instead of EXPORT_SYMBOL_GPL and are inconsistent with the other exported functions in the module. The underlying APCI/OF struct fwnode_operations implementations are also exported via EXPORT_SYMBOL_GPL.
Update them to use the EXPORT_SYMBOL_GPL macro.
---
Changes in v3:
-New patch
drivers/base/property.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/base/property.c +4 -4
@@ -1044,7 +1044,7 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index) {return fwnode_call_ptr_op (fwnode, iomap, index); } -EXPORT_SYMBOL (fwnode_iomap); +EXPORT_SYMBOL_GPL (fwnode_iomap);/** * fwnode_irq_get_resource - Get IRQ directly from a fwnode and populate
@@ -1082,7 +1082,7 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)return fwnode_irq_get_resource (fwnode, index, &r); } -EXPORT_SYMBOL (fwnode_irq_get); +EXPORT_SYMBOL_GPL (fwnode_irq_get);/** * fwnode_irq_get_byname - Get IRQ from a fwnode using its name
@@ -1110,7 +1110,7 @@ int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name)return fwnode_irq_get (fwnode, index); } -EXPORT_SYMBOL (fwnode_irq_get_byname); +EXPORT_SYMBOL_GPL (fwnode_irq_get_byname);/** * fwnode_graph_get_next_endpoint - Get next endpoint firmware node
@@ -1355,7 +1355,7 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,return fwnode_call_int_op (fwnode, graph_parse_endpoint, endpoint); } -EXPORT_SYMBOL (fwnode_graph_parse_endpoint); +EXPORT_SYMBOL_GPL (fwnode_graph_parse_endpoint);const void *device_get_match_data (const struct device *dev) {
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 22/24] device property: Update functions to use EXPORT_SYMBOL_GPL
Quoted 1 line · Mark Hasemeyer
Some of the exported functions use
EXPORT_SYMBOLinstead of
EXPORT_SYMBOL()
Quoted 1 line
EXPORT_SYMBOL_GPLand are inconsistent with the other exported functions
EXPORT_SYMBOL_GPL()
Quoted 2 lines
in the module. The underlying APCI/OF struct
fwnode_operationsimplementations are also exported viaEXPORT_SYMBOL_GPL.
EXPORT_SYMBOL_GPL()
Quoted 1 line
Update them to use the
EXPORT_SYMBOL_GPLmacro.
EXPORT_SYMBOL_GPL()
...
With the above fixed,
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 23/24 platform: Modify platform_get_irq_optional() to use resource
In reply to Mark HasemeyerUnify handling of ACPI, GPIO, devictree, and platform resource interrupts in platform_get_irq_optional(). Each of these subsystems provide their own APIs which provide IRQ information as a struct resource. This simplifies the logic of the function and allows callers to get more information about the IRQ by looking at the resource flags. For example, whether or not an IRQ is wake capable.
---
Changes in v3:
-Remove PTR_ERR check
-Move platform_res assignment
-Check for irq == 0 to trigger WARN msg
-Refactor error handling of acpi_dev_get_gpio_irq_resource() to be consistent with fwnode_irq_get_resource()
-Remove extra blank lines
-Initialize struct resource on stack
Changes in v2:
-irq->IRQ
-Remove cast to struct resource
-Conform to get_optional() function naming
-Revert move of irq_get_irq_data()
-Add NULL check on struct resource*
-Use fwnode to retrieve IRQ for DT/ACPI
drivers/base/platform.c | 70 ++++++++++++++++++++++----------- include/linux/platform_device.h | 3 ++ 2 files changed, 51 insertions(+), 22 deletions(-)
drivers/base/platform.c +48 -22
@@ -151,9 +151,11 @@ EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);#endif /* CONFIG_HAS_IOMEM */ /** -* platform_get_irq_optional - get an optional IRQ for a device +* platform_get_irq_resource_optional - get an optional IRQ for a device and +* populate the resource struct * @dev: platform device * @num: IRQ number index +* @r: pointer to resource to populate with IRQ information. * * Gets an IRQ for a platform device. Device drivers should check the return * value for errors so as to not pass a negative integer value to the
@@ -162,39 +164,33 @@ EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);* * For example:: * -* int irq = platform_get_irq_optional(pdev, 0); +* int irq = platform_get_irq_resource_optional(pdev, 0, &res); * if (irq < 0) * return irq; * * Return: non-zero IRQ number on success, negative error number on failure. */ -int platform_get_irq_optional (struct platform_device *dev,unsigned int num) +int platform_get_irq_resource_optional (struct platform_device *dev, +unsigned int num,struct resource *r) {int ret; + +if (!r) +return -EINVAL ;#ifdef CONFIG_SPARC /* sparc does not have irqs represented as IORESOURCE_IRQ resources */ if (!dev || num >= dev->archdata.num_irqs) goto out_not_found; ret = dev->archdata.irqs[num]; +if (ret >0 ) + *r =DEFINE_RES_IRQ (ret); goto out;#else struct fwnode_handle *fwnode =dev_fwnode (&dev->dev); -struct resource *r; - -if (is_of_node (fwnode)) { - ret =of_irq_get (to_of_node (fwnode), num); -if (ret >0 || ret == -EPROBE_DEFER ) - goto out; - } - r =platform_get_resource (dev,IORESOURCE_IRQ , num); -if (is_acpi_device_node (fwnode)) { -if (r && r->flags &IORESOURCE_DISABLED ) { - ret =acpi_irq_get (ACPI_HANDLE_FWNODE (fwnode), num, r); -if (ret) - goto out; - } - } + ret =fwnode_irq_get_resource (fwnode, num, r); +if (ret >=0 || ret == -EPROBE_DEFER ) + goto out;/* * The resources may pass trigger flags to the irqs that need
@@ -202,7 +198,9 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)* IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER* * settings. */ -if (r && r->flags &IORESOURCE_BITS ) { +struct resource *platform_res =platform_get_resource (dev,IORESOURCE_IRQ , num); + +if (platform_res && platform_res->flags &IORESOURCE_BITS ) {struct irq_data *irqd; irqd =irq_get_irq_data (r->start);
@@ -211,7 +209,8 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)irqd_set_trigger_type (irqd, r->flags &IORESOURCE_BITS ); } -if (r) { +if (platform_res) { + *r = *platform_res; ret = r->start; goto out; }
@@ -224,7 +223,8 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)* allows a common code path across either kind of resource. */ if (num ==0 &&is_acpi_device_node (fwnode)) { - ret =acpi_dev_gpio_irq_get (to_acpi_device_node (fwnode), num); + ret =acpi_dev_get_gpio_irq_resource (to_acpi_device_node (fwnode),NULL , num, r); + ret = ret ?: r->start;/* Our callers expect -ENXIO for missing IRQs. */ if (ret >=0 || ret == -EPROBE_DEFER ) goto out;
@@ -238,7 +238,7 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)return -EINVAL ;return ret; } -EXPORT_SYMBOL_GPL (platform_get_irq_optional); +EXPORT_SYMBOL_GPL (platform_get_irq_resource_optional);/** * platform_get_irq - get an IRQ for a device
@@ -270,6 +270,32 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) }EXPORT_SYMBOL_GPL (platform_get_irq); +/** +* platform_get_irq_optional - get an optional IRQ for a device +* @dev: platform device +* @num: IRQ number index +* +* Gets an IRQ for a platform device. Device drivers should check the return +* value for errors so as to not pass a negative integer value to the +* request_irq() APIs. This is the same as platform_get_irq(), except that it +* does not print an error message if an IRQ can not be obtained. +* +* For example:: +* +* int irq = platform_get_irq_optional(pdev, 0); +* if (irq < 0) +* return irq; +* +* Return: non-zero IRQ number on success, negative error number on failure. +*/ +int platform_get_irq_optional (struct platform_device *dev,unsigned int num) +{ +struct resource r = {}; + +return platform_get_irq_resource_optional (dev, num, &r); +} +EXPORT_SYMBOL_GPL (platform_get_irq_optional); +/** * platform_irq_count - Count the number of IRQs a platform device uses * @dev: platform device
include/linux/platform_device.h +3 -0
@@ -102,6 +102,9 @@ devm_platform_ioremap_resource_byname(struct platform_device *pdev,extern int platform_get_irq (struct platform_device *,unsigned int );extern int platform_get_irq_optional (struct platform_device *,unsigned int ); +extern int platform_get_irq_resource_optional (struct platform_device *dev, +unsigned int num, +struct resource *r);extern int platform_irq_count (struct platform_device *); extern int devm_platform_get_irqs_affinity(struct platform_device *dev, struct irq_affinity *affd,
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 23/24] platform: Modify platform_get_irq_optional() to use resource
Quoted 6 lines · Mark Hasemeyer
Unify handling of ACPI, GPIO, devictree, and platform resource interrupts in
platform_get_irq_optional(). Each of these subsystems provide their own APIs which provide IRQ information as a struct resource. This simplifies the logic of the function and allows callers to get more information about the IRQ by looking at the resource flags. For example, whether or not an IRQ is wake capable.
...
drivers/base/platform.c EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); · line 182
Quoted 1 line
drivers/base/platform.c +0
-1-struct resource *r;
...
drivers/base/platform.c int platform_get_irq_optional(struct platform_device *dev, unsigned int num) · line 201
Quoted 1 line
drivers/base/platform.c +1
-0+struct resource *platform_res =platform_get_resource (dev,IORESOURCE_IRQ , num);
This is quite unusual (as far as cleanup.h is not used and there is no place for it here).
Quoted 1 line
+
Unneeded blank line after fixing the above.
drivers/base/platform.c int platform_get_irq_optional(struct platform_device *dev, unsigned int num) · line 204
Quoted 2 lines
drivers/base/platform.c +1
-0+if (platform_res && platform_res->flags &IORESOURCE_BITS ) {struct irq_data *irqd;
Otherwise LGTM,
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 23/24] platform: Modify platform_get_irq_optional() to use resource
Quoted 6 lines
Quoted 1 line
- struct resource *r;
...Quoted 1 line
+ struct resource
*platform_res=platform_get_resource(dev, IORESOURCE_IRQ, num);This is quite unusual (as far as
cleanup.his not used and there is no place for it here).
Sorry, what's unusual? The declaration of a separate 'platform_res'? If so, I introduced it because I wanted to avoid setting 'r' if 'irq_get_irq_data()' fails below.
Andy Shevchenko
reviewerRe: [PATCH v3 23/24] platform: Modify platform_get_irq_optional() to use resource
Quoted 10 lines · Mark Hasemeyer
Quoted 6 lines
Quoted 1 line
- struct resource *r;
...Quoted 1 line
+ struct resource
*platform_res=platform_get_resource(dev, IORESOURCE_IRQ, num);This is quite unusual (as far as
cleanup.his not used and there is no place for it here).Sorry, what's unusual? The declaration of a separate '
platform_res'? If so, I introduced it because I wanted to avoid setting 'r' if 'irq_get_irq_data()' fails below.
Defining the variable in the depth of the code.
There are exceptions, but usually we follow the style that definitions are grouped at the top of the {} scope(s).
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 24/24 platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
In reply to Mark HasemeyerThe cros ec driver is manually managing the wake IRQ by calling enable_irq_wake()/disable_irq_wake() during suspend/resume.
Modify the driver to use the power management subsystem to manage the wakeirq.
Rather than assuming that the IRQ is wake capable, use the underlying firmware/device tree to determine whether or not to enable it as a wake source. Some Chromebooks rely solely on the ec_sync pin to wake the AP but do not specify the interrupt as wake capable in the ACPI _CRS. For LPC/ACPI based systems a DMI quirk is introduced listing boards whose firmware should not be trusted to provide correct wake capable values. For device tree base systems, it is not an issue as the relevant device tree entries have been updated and DTS is built from source for each ChromeOS update.
---
Changes in v3:
-Rebase on linux-next
-See each patch for patch specific changes
-Remove MODULE_DEVICE_TABLE
-Drop "cros_ec _" prefix from should_force_irq_wake_capable() -Drop use of dev_err_probe() to be consistent with existing conventions in the driver
-Drop *spi argument from cros_ec_spi_dt_probe()
-Drop null device_node check from cros_ec_spi_dt_probe() -Add trailing commas to DMI table
-Drop redundant "!= NULL" in should_force_irq_wake_capable() -Use str_yes_no() to print irq wake capability
-Move irqwake handling from the interface specific modules to cros_ec.c
Changes in v2:
-Rebase on linux-next
-Add cover letter
-See each patch for patch specific changes -Look for 'wakeup-source' property in cros_ec_spi.c
drivers/platform/chrome/cros_ec.c | 48 +++++++++++++++++---- drivers/platform/chrome/cros_ec_lpc.c | 32 ++++++++++++-- drivers/platform/chrome/cros_ec_spi.c | 15 ++++--- drivers/platform/chrome/cros_ec_uart.c | 22 +++++++--- include/linux/platform_data/cros_ec_proto.h | 4 +- 5 files changed, 97 insertions(+), 24 deletions(-)
drivers/platform/chrome/cros_ec.c +39 -9
@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/platform_data/cros_ec_commands.h> #include <linux/platform_data/cros_ec_proto.h> +#include <linux/pm_wakeirq.h> #include <linux/slab.h> #include <linux/suspend.h>
@@ -168,6 +169,35 @@ static int cros_ec_ready_event(struct notifier_block *nb,return NOTIFY_DONE ; } +static int enable_irq_for_wake (struct cros_ec_device *ec_dev) +{ +struct device *dev = ec_dev->dev; +int ret =device_init_wakeup (dev, true); + +if (ret) { +dev_err (dev,"Failed to enable device for wakeup" ); +return ret; + } + ret =dev_pm_set_wake_irq (dev, ec_dev->irq); +if (ret) +device_init_wakeup (dev, false); + +return ret; +} + +static int disable_irq_for_wake (struct cros_ec_device *ec_dev) +{ +int ret; +struct device *dev = ec_dev->dev; + +dev_pm_clear_wake_irq (dev); + ret =device_init_wakeup (dev, false); +if (ret) +dev_err (dev,"Failed to disable device for wakeup" ); + +return ret; +} +/** * cros_ec_register() - Register a new ChromeOS EC, using the provided info. * @ec_dev: Device to register.
@@ -221,6 +251,13 @@ int cros_ec_register(struct cros_ec_device *ec_dev) ec_dev->irq, err); goto exit; } +dev_dbg (dev,"IRQ: %i, wake_capable: %s\n" , ec_dev->irq, +str_yes_no (ec_dev->irq_wake)); +if (ec_dev->irq_wake) { + err =enable_irq_for_wake (ec_dev); +if (err) + goto exit; + } }/* Register a platform device for the main EC instance */
@@ -313,6 +350,8 @@ EXPORT_SYMBOL(cros_ec_register);*/ void cros_ec_unregister (struct cros_ec_device *ec_dev) { +if (ec_dev->irq_wake) +disable_irq_for_wake (ec_dev);platform_device_unregister (ec_dev->pd);platform_device_unregister (ec_dev->ec);mutex_destroy (&ec_dev->lock);
@@ -353,12 +392,6 @@ EXPORT_SYMBOL(cros_ec_suspend_prepare);static void cros_ec_disable_irq (struct cros_ec_device *ec_dev) { -struct device *dev = ec_dev->dev; -if (device_may_wakeup (dev)) - ec_dev->wake_enabled = !enable_irq_wake (ec_dev->irq); -else - ec_dev->wake_enabled = false; -disable_irq (ec_dev->irq); ec_dev->suspended = true; }
@@ -440,9 +473,6 @@ static void cros_ec_enable_irq(struct cros_ec_device *ec_dev) ec_dev->suspended = false;enable_irq (ec_dev->irq); -if (ec_dev->wake_enabled) -disable_irq_wake (ec_dev->irq); -/* * Let the mfd devices know about events that occur during * suspend. This way the clients know what to do with them.
drivers/platform/chrome/cros_ec_lpc.c +29 -3
@@ -48,6 +48,27 @@ struct lpc_driver_ops {static struct lpc_driver_ops cros_ec_lpc_ops = { }; +static const struct dmi_system_id untrusted_fw_irq_wake_capable[] = { + { + .ident ="Brya" , + .matches = { +DMI_MATCH (DMI_PRODUCT_FAMILY ,"Google_Brya" ), + }, + }, + { + .ident ="Brask" , + .matches = { +DMI_MATCH (DMI_PRODUCT_FAMILY ,"Google_Brask" ), + }, + }, + { } +}; + +static bool should_force_irq_wake_capable (void ) +{ +return dmi_first_match (untrusted_fw_irq_wake_capable); +} +/* * A generic instance of the read function of struct lpc_driver_ops, used for * the LPC EC.
@@ -353,6 +374,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)struct acpi_device *adev;acpi_status status;struct cros_ec_device *ec_dev; +struct resource irqres;u8 buf[2 ] = {};int irq, ret;
@@ -428,10 +450,14 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)* Some boards do not have an IRQ allotted for cros_ec_lpc, * which makes ENXIO an expected (and safe) scenario. */ - irq =platform_get_irq_optional (pdev,0 ); -if (irq >0 ) + irq =platform_get_irq_resource_optional (pdev,0 , &irqres); +if (irq >0 ) { ec_dev->irq = irq; -else if (irq != -ENXIO ) { +if (should_force_irq_wake_capable ()) + ec_dev->irq_wake = true; +else + ec_dev->irq_wake = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; + }else if (irq != -ENXIO ) {dev_err (dev,"couldn't retrieve IRQ number (%d)\n" , irq);return irq; }
drivers/platform/chrome/cros_ec_spi.c +10 -5
@@ -7,6 +7,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_irq.h> #include <linux/platform_data/cros_ec_commands.h> #include <linux/platform_data/cros_ec_proto.h> #include <linux/platform_device.h>
@@ -70,6 +71,7 @@* @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that * is sent when we want to turn off CS at the end of a transaction. * @high_pri_worker: Used to schedule high priority work. +* @irq_wake: Whether or not irq assertion should wake the system. */ struct cros_ec_spi {struct spi_device *spi;
@@ -77,6 +79,7 @@ struct cros_ec_spi {unsigned int start_of_msg_delay;unsigned int end_of_msg_delay;struct kthread_worker *high_pri_worker; +bool irq_wake; }; typedef int (*cros_ec_xfer_fn_t) (struct cros_ec_device *ec_dev,
@@ -689,9 +692,10 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev,return cros_ec_xfer_high_pri (ec_dev, ec_msg, do_cros_ec_cmd_xfer_spi); } -static void cros_ec_spi_dt_probe (struct cros_ec_spi *ec_spi,struct device *dev) +static void cros_ec_spi_dt_probe (struct cros_ec_spi *ec_spi) { -struct device_node *np = dev->of_node; +struct spi_device *spi = ec_spi->spi; +struct device_node *np = spi->dev.of_node;u32 val;int ret;
@@ -702,6 +706,8 @@ static void cros_ec_spi_dt_probe(struct cros_ec_spi *ec_spi, struct device *dev) ret =of_property_read_u32 (np,"google,cros-ec-spi-msg-delay" , &val);if (!ret) ec_spi->end_of_msg_delay = val; + + ec_spi->irq_wake = spi->irq >0 &&of_property_present (np,"wakeup-source" ); }static void cros_ec_spi_high_pri_release (void *worker)
@@ -754,12 +760,13 @@ static int cros_ec_spi_probe(struct spi_device *spi)return -ENOMEM ;/* Check for any DT properties */ -cros_ec_spi_dt_probe (ec_spi, dev); +cros_ec_spi_dt_probe (ec_spi);spi_set_drvdata (spi, ec_dev); ec_dev->dev = dev; ec_dev->priv = ec_spi; ec_dev->irq = spi->irq; + ec_dev->irq_wake = ec_spi->irq_wake; ec_dev->cmd_xfer = cros_ec_cmd_xfer_spi; ec_dev->pkt_xfer = cros_ec_pkt_xfer_spi; ec_dev->phys_name =dev_name (&ec_spi->spi->dev);
@@ -780,8 +787,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)return err; } -device_init_wakeup (&spi->dev, true); -return 0 ; }
drivers/platform/chrome/cros_ec_uart.c +17 -5
@@ -69,6 +69,7 @@ struct response_info {* @serdev: serdev uart device we are connected to. * @baudrate: UART baudrate of attached EC device. * @flowcontrol: UART flowcontrol of attached device. +* @irq_wake: Whether or not irq assertion should wake the system. * @irq: Linux IRQ number of associated serial device. * @response: Response info passing between cros_ec_uart_pkt_xfer() * and cros_ec_uart_rx_bytes()
@@ -77,6 +78,7 @@ struct cros_ec_uart {struct serdev_device *serdev;u32 baudrate;u8 flowcontrol; +bool irq_wake;u32 irq;struct response_info response; };
@@ -224,8 +226,10 @@ static int cros_ec_uart_resource(struct acpi_resource *ares, void *data)static int cros_ec_uart_acpi_probe (struct cros_ec_uart *ec_uart) {int ret; +struct resource irqres;LIST_HEAD (resources); -struct acpi_device *adev =ACPI_COMPANION (&ec_uart->serdev->dev); +struct device *dev = &ec_uart->serdev->dev; +struct acpi_device *adev =ACPI_COMPANION (dev); ret =acpi_dev_get_resources (adev, &resources, cros_ec_uart_resource, ec_uart);if (ret <0 )
@@ -234,12 +238,12 @@ static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart)acpi_dev_free_resource_list (&resources);/* Retrieve GpioInt and translate it to Linux IRQ number */ - ret =acpi_dev_gpio_irq_get (adev,0 ); + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres);if (ret <0 )return ret; - ec_uart->irq = ret; -dev_dbg (&ec_uart->serdev->dev,"IRQ number %d\n" , ec_uart->irq); + ec_uart->irq = irqres.start; + ec_uart->irq_wake = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ;return 0 ; }
@@ -293,6 +297,7 @@ static int cros_ec_uart_probe(struct serdev_device *serdev) ec_dev->dev = dev; ec_dev->priv = ec_uart; ec_dev->irq = ec_uart->irq; + ec_dev->irq_wake = ec_uart->irq_wake; ec_dev->cmd_xfer =NULL ; ec_dev->pkt_xfer = cros_ec_uart_pkt_xfer; ec_dev->din_size = sizeof(struct ec_host_response) +
@@ -301,7 +306,14 @@ static int cros_ec_uart_probe(struct serdev_device *serdev)serdev_device_set_client_ops (serdev, &cros_ec_uart_client_ops); -return cros_ec_register (ec_dev); +/* Register a new cros_ec device */ + ret =cros_ec_register (ec_dev); +if (ret) { +dev_err (dev,"Couldn't register ec_dev (%d)\n" , ret); +return ret; + } + +return 0 ; }static void cros_ec_uart_remove (struct serdev_device *serdev)
include/linux/platform_data/cros_ec_proto.h +2 -2
@@ -100,6 +100,7 @@ struct cros_ec_command {* @proto_version: The protocol version used for this device. * @priv: Private data. * @irq: Interrupt to use. +* @irq_wake: Whether or not irq assertion should wake the system. * @id: Device id. * @din: Input buffer (for data from EC). This buffer will always be * dword-aligned and include enough space for up to 7 word-alignment
@@ -115,7 +116,6 @@ struct cros_ec_command {* performance advantage to using dword. * @din_size: Size of din buffer to allocate (zero to use static din). * @dout_size: Size of dout buffer to allocate (zero to use static dout). -* @wake_enabled: True if this device can wake the system from sleep. * @suspended: True if this device had been suspended. * @cmd_xfer: Send command to EC and get response. * Returns the number of bytes received if the communication
@@ -169,11 +169,11 @@ struct cros_ec_device {u16 proto_version;void *priv;int irq; +bool irq_wake;u8 *din;u8 *dout;int din_size;int dout_size; -bool wake_enabled;bool suspended;int (*cmd_xfer)(struct cros_ec_device *ec,struct cros_ec_command *msg);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 24/24] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
Quoted 16 lines · Mark Hasemeyer
The cros ec driver is manually managing the wake IRQ by calling enable_irq_wake()/disable_irq_wake() during suspend/resume.
Modify the driver to use the power management subsystem to manage the wakeirq.
Rather than assuming that the IRQ is wake capable, use the underlying
firmware/devicetree to determine whether or not to enable it as a wake source. Some Chromebooks rely solely on theec_syncpin to wake the AP but do not specify the interrupt as wake capable in the ACPI_CRS. For LPC/ACPI based systems a DMI quirk is introduced listing boards whose firmware should not be trusted to provide correct wake capable values. For device tree base systems, it is not an issue as the relevant device tree entries have been updated and DTS is built from source for each ChromeOS update.
Quoted 1 line
Signed-off-by Mark Hasemeyer <[email protected]>
The patch overall looks good to me.
With some minor comments:
Quoted 1 line
drivers/platform/chrome/cros_ec_uart.c +0
-0
[...]
Quoted 2 lines
static int
cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart){
[...]
drivers/platform/chrome/cros_ec_uart.c static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) · line 245
Quoted 9 lines
drivers/platform/chrome/cros_ec_uart.c +2
-3/* Retrieve GpioInt and translate it to Linux IRQ number */ - ret =acpi_dev_gpio_irq_get (adev,0 ); + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres);if (ret <0 )return ret; - ec_uart->irq = ret; -dev_dbg (&ec_uart->serdev->dev,"IRQ number %d\n" , ec_uart->irq); + ec_uart->irq = irqres.start;
How about keep using ret?
drivers/platform/chrome/cros_ec_uart.c static int cros_ec_uart_probe(struct serdev_device *serdev) · line 314
Quoted 11 lines
drivers/platform/chrome/cros_ec_uart.c +6
-1@@ -301,7 +306,14 @@ static int cros_ec_uart_probe(struct serdev_device *serdev)serdev_device_set_client_ops (serdev, &cros_ec_uart_client_ops); -return cros_ec_register (ec_dev); +/* Register a new cros_ec device */ + ret =cros_ec_register (ec_dev); +if (ret) { +dev_err (dev,"Couldn't register ec_dev (%d)\n" , ret); +return ret; + }
It doesn't need the change after moving device_init_wakeup() and dev_pm_set_wake_irq() into cros_ec_register().
Drop it?
Re: [PATCH v3 24/24] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
Quoted 11 lines
drivers/platform/chrome/cros_ec_uart.c static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) · line 245
Quoted 9 lines
/* Retrieve GpioInt and translate it to Linux IRQ number */drivers/platform/chrome/cros_ec_uart.c +2
-3- ret =acpi_dev_gpio_irq_get (adev,0 ); + ret =acpi_dev_get_gpio_irq_resource (adev,NULL ,0 , &irqres);if (ret <0 )return ret; - ec_uart->irq = ret; -dev_dbg (&ec_uart->serdev->dev,"IRQ number %d\n" , ec_uart->irq); + ec_uart->irq = irqres.start;How about keep using
ret?
The return value for 'acpi_dev_get_gpio_irq_resource' is different: 0 on success, negative errno on failure.
Quoted 15 lines
drivers/platform/chrome/cros_ec_uart.c static int cros_ec_uart_probe(struct serdev_device *serdev) · line 314
Quoted 11 lines
drivers/platform/chrome/cros_ec_uart.c +6
-1@@ -301,7 +306,14 @@ static int cros_ec_uart_probe(struct serdev_device *serdev)serdev_device_set_client_ops (serdev, &cros_ec_uart_client_ops); -return cros_ec_register (ec_dev); +/* Register a new cros_ec device */ + ret =cros_ec_register (ec_dev); +if (ret) { +dev_err (dev,"Couldn't register ec_dev (%d)\n" , ret); +return ret; + }It doesn't need the change after moving
device_init_wakeup()anddev_pm_set_wake_irq()intocros_ec_register().
Quoted 1 line
Drop it?
Will do.
Re: [PATCH v3 24/24] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
In reply to Mark HasemeyerQuoted 15 lines · Mark Hasemeyer
The cros ec driver is manually managing the wake IRQ by calling enable_irq_wake()/disable_irq_wake() during suspend/resume.
Modify the driver to use the power management subsystem to manage the wakeirq.
Rather than assuming that the IRQ is wake capable, use the underlying
firmware/devicetree to determine whether or not to enable it as a wake source. Some Chromebooks rely solely on theec_syncpin to wake the AP but do not specify the interrupt as wake capable in the ACPI_CRS. For LPC/ACPI based systems a DMI quirk is introduced listing boards whose firmware should not be trusted to provide correct wake capable values. For device tree base systems, it is not an issue as the relevant device tree entries have been updated and DTS is built from source for each ChromeOS update.
...
drivers/platform/chrome/cros_ec_lpc.c static int cros_ec_lpc_probe(struct platform_device *pdev) · line 377
Quoted 3 lines
drivers/platform/chrome/cros_ec_lpc.c +1
-0acpi_status status;struct cros_ec_device *ec_dev; +struct resource irqres;
struct resource irqres = {};?
Quoted 2 lines
drivers/platform/chrome/cros_ec_lpc.c +0
-0u8 buf[2 ] = {};int irq, ret;
...
Quoted 4 lines
drivers/platform/chrome/cros_ec_lpc.c +2
-2- irq =platform_get_irq_optional (pdev,0 ); -if (irq >0 ) + irq =platform_get_irq_resource_optional (pdev,0 , &irqres); +if (irq >0 ) {
drivers/platform/chrome/cros_ec_lpc.c static int cros_ec_lpc_probe(struct platform_device *pdev) · line 463
Quoted 10 lines
drivers/platform/chrome/cros_ec_lpc.c +5
-1ec_dev->irq = irq; - else if (irq != -ENXIO) { +if (should_force_irq_wake_capable ()) + ec_dev->irq_wake = true; +else + ec_dev->irq_wake = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; + }else if (irq != -ENXIO ) {dev_err (dev,"couldn't retrieve IRQ number (%d)\n" , irq);return irq; }
Still I do not like ambiguity behind irq > 0 vs. irqres.start.
For this, and if needed others, return plain error. Seems I gave the tag for the previous patch, consider that tag conditional (it seems I missed this).
...
include/linux/platform_data/cros_ec_proto.h struct cros_ec_device { · line 179
Quoted 12 lines
include/linux/platform_data/cros_ec_proto.h +1
-1u16 proto_version;void *priv;int irq; +bool irq_wake;u8 *din;u8 *dout;int din_size;int dout_size; -bool wake_enabled;bool suspended;int (*cmd_xfer)(struct cros_ec_device *ec,struct cros_ec_command *msg);
Have you run pahole on this (before and after)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 24/24] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
Quoted 15 lines
Quoted 4 lines
drivers/platform/chrome/cros_ec_lpc.c +2
-2- irq =platform_get_irq_optional (pdev,0 ); -if (irq >0 ) + irq =platform_get_irq_resource_optional (pdev,0 , &irqres); +if (irq >0 ) {drivers/platform/chrome/cros_ec_lpc.c static int cros_ec_lpc_probe(struct platform_device *pdev) · line 463
Quoted 10 lines
drivers/platform/chrome/cros_ec_lpc.c +5
-1ec_dev->irq = irq; - else if (irq != -ENXIO) { +if (should_force_irq_wake_capable ()) + ec_dev->irq_wake = true; +else + ec_dev->irq_wake = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; + }else if (irq != -ENXIO ) {dev_err (dev,"couldn't retrieve IRQ number (%d)\n" , irq);return irq; }
Quoted 5 lines
Still I do not like ambiguity behind irq > 0 vs. irqres.start.
For this, and if needed others, return plain error. Seems I gave the tag for the previous patch, consider that tag conditional (it seems I missed this).
What "others" do you mean? Modify platform_get_irq_resource_optional() to return success/err? Or do you mean to modify all irq resource based functions? of_irq_to_resource() already existed and returns the irq number on success. Modifying it would mean updating all references to it, in addition to modifying the fwnode abstraction layer (and its references). I'm open to modifying platform_get_irq_resource_optional(), but would like to avoid blowing up this patch train any further.
Quoted 15 lines
...
include/linux/platform_data/cros_ec_proto.h struct cros_ec_device { · line 179
Quoted 12 lines
u16 proto_version; void *priv; int irq;include/linux/platform_data/cros_ec_proto.h +1
-1+bool irq_wake;u8 *din;u8 *dout;int din_size;int dout_size; -bool wake_enabled;bool suspended;int (*cmd_xfer)(struct cros_ec_device *ec,struct cros_ec_command *msg);
Quoted 1 line
Have you run pahole on this (before and after)?
Yes I did. The structure is not fully optimized, but this change keps the overall size unchanged (328 bytes).
Tzung-Bi Shih
maintainerRe: [PATCH v3 24/24] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq
In reply to Andy ShevchenkoQuoted 18 lines · Andy Shevchenko
Quoted 4 lines · Mark Hasemeyer
drivers/platform/chrome/cros_ec_lpc.c +2
-2- irq =platform_get_irq_optional (pdev,0 ); -if (irq >0 ) + irq =platform_get_irq_resource_optional (pdev,0 , &irqres); +if (irq >0 ) {drivers/platform/chrome/cros_ec_lpc.c static int cros_ec_lpc_probe(struct platform_device *pdev) · line 463
Quoted 10 lines
drivers/platform/chrome/cros_ec_lpc.c +5
-1ec_dev->irq = irq; - else if (irq != -ENXIO) { +if (should_force_irq_wake_capable ()) + ec_dev->irq_wake = true; +else + ec_dev->irq_wake = irqres.flags &IORESOURCE_IRQ_WAKECAPABLE ; + }else if (irq != -ENXIO ) {dev_err (dev,"couldn't retrieve IRQ number (%d)\n" , irq);return irq; }Still I do not like ambiguity behind irq > 0 vs. irqres.start.
Quoted 3 lines
For this, and if needed others, return plain error. Seems I gave the tag for the previous patch, consider that tag conditional (it seems I missed this).
On a related note, I was confusing a while because of the differences:
platform_get_irq_optional() and platform_get_irq_resource_optional():
Return: non-zero IRQ number on success, negative error number on failure.
acpi_dev_get_gpio_irq_resource():
Return: 0 on success, negative errno on failure.
acpi_dev_gpio_irq_get():
Return: Linux IRQ number (> %0) on success, negative errno on failure.
How about let platform_get_irq_resource_optional():
- Return 0 on success and negative errno on failure.
- The callee needs to retrieve the IRQ number from irqres.start. ?
Re: (subset) [PATCH v3 00/24] Improve IRQ wake capability reporting and update the cros_ec driver to use it
In reply to Mark HasemeyerQuoted 6 lines · Mark Hasemeyer
Currently the
cros_ecdriver assumes that its associated interrupt is wake capable. This is an incorrect assumption as some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. This patch train updates the driver to query the underlying ACPI/DT data to determine whether or not the IRQ should be enabled for wake.
Quoted 7 lines
Both the device tree and ACPI systems have methods for reporting IRQ wake capability. In device tree based systems, a node can advertise itself as a 'wakeup-source'. In ACPI based systems, GpioInt and Interrupt resource descriptors can use the 'SharedAndWake' or 'ExclusiveAndWake' share types.
[...]
Applied, thanks!
[14/24] arm64: dts: qcom: sc7180: Enable cros-ec-spi as wake source
commit: f172a341ec1f66bac2866720931594e81f02ad4d
[15/24] arm64: dts: qcom: sc7280: Enable cros-ec-spi as wake source
commit: a4b28b9ecc99673da875e214b1a06f1e0f0a24fa
[16/24] arm64: dts: qcom: sdm845: Enable cros-ec-spi as wake source
commit: a7baa25bfbfdcd4e76414f29ab43317ded8d3e6eBest regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Quoted 25 lines · Mark Hasemeyer
Currently the
cros_ecdriver assumes that its associated interrupt is wake capable. This is an incorrect assumption as some Chromebooks use a separate wake pin, while others overload the interrupt for wake and IO. This patch train updates the driver to query the underlying ACPI/DT data to determine whether or not the IRQ should be enabled for wake.Both the device tree and ACPI systems have methods for reporting IRQ wake capability. In device tree based systems, a node can advertise itself as a 'wakeup-source'. In ACPI based systems, GpioInt and Interrupt resource descriptors can use the 'SharedAndWake' or 'ExclusiveAndWake' share types.
Some logic is added to the platform, ACPI, and DT subsystems to more easily pipe wakeirq information up to the driver.
Changes in v3:
(quoted diff) +0
-2-Rebase on linux-next -See each patch for patch specific changesChanges in v2:
(quoted diff) +0
-3-Rebase on linux-next -Add cover letter -See each patch for patch specific changesMark Hasemeyer (24):
[...]
Quoted 1 line
ARM: dts: tegra: Enable cros-ec-spi as wake source
[...]
Quoted 1 line
arm64: dts: tegra: Enable cros-ec-spi as wake source
[...]
Both patches applied, thanks.
Thierry