gpio: dwapb: Unify ACPI enumeration checks in get_irq() and configure_irqs()
PATCH v2 1/4 gpio: dwapb: Unify ACPI enumeration checks in get_irq() and configure_irqs()
Shared IRQ is only enabled for ACPI enumeration, there is no need to have a special flag for that, since we simple can test if device has been enumerated by ACPI. This unifies the checks in dwapb_get_irq() and dwapb_configure_irqs().
---
v2: added tags (Lee, Serge), rephrased comments near to for-loop (Serge)
drivers/gpio/gpio-dwapb.c | 24 ++++++++++++------------ drivers/mfd/intel_quark_i2c_gpio.c | 1 - include/linux/platform_data/gpio-dwapb.h | 1 - 3 files changed, 12 insertions(+), 14 deletions(-)
drivers/gpio/gpio-dwapb.c +12 -12
@@ -436,21 +436,17 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, pirq->irqchip.irq_set_wake = dwapb_irq_set_wake;#endif -if (!pp->irq_shared) { - girq->num_parents = pirq->nr_irqs; - girq->parents = pirq->irq; - girq->parent_handler_data = gpio; - girq->parent_handler = dwapb_irq_handler; - }else { -/* This will let us handle the parent IRQ in the driver */ +/* +* Intel ACPI-based platforms mostly have the DesignWare APB GPIO +* IRQ lane shared between several devices. In that case the parental +* IRQ has to be handled in the shared way so to be properly delivered +* to all the connected devices. +*/ +if (has_acpi_companion (gpio->dev)) { girq->num_parents =0 ; girq->parents =NULL ; girq->parent_handler =NULL ; -/* -* Request a shared IRQ since where MFD would have devices -* using the same irq pin -*/ err =devm_request_irq (gpio->dev, pp->irq[0 ], dwapb_irq_handler_mfd,IRQF_SHARED ,DWAPB_DRIVER_NAME , gpio);
@@ -458,6 +454,11 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,dev_err (gpio->dev,"error requesting IRQ\n" ); goto err_kfree_pirq; } + }else { + girq->num_parents = pirq->nr_irqs; + girq->parents = pirq->irq; + girq->parent_handler_data = gpio; + girq->parent_handler = dwapb_irq_handler; } girq->chip = &pirq->irqchip;
@@ -581,7 +582,6 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->ngpio =DWAPB_MAX_GPIOS ; } - pp->irq_shared = false; pp->gpio_base =-1 ;/*
drivers/mfd/intel_quark_i2c_gpio.c +0 -1
@@ -227,7 +227,6 @@ static int intel_quark_gpio_setup(struct pci_dev *pdev) pdata->properties->ngpio =INTEL_QUARK_MFD_NGPIO ; pdata->properties->gpio_base =INTEL_QUARK_MFD_GPIO_BASE ; pdata->properties->irq[0 ] =pci_irq_vector (pdev,0 ); - pdata->properties->irq_shared = true; cell->platform_data = pdata; cell->pdata_size =sizeof (*pdata);
include/linux/platform_data/gpio-dwapb.h +0 -1
@@ -14,7 +14,6 @@ struct dwapb_port_property {unsigned int ngpio;unsigned int gpio_base;int irq[DWAPB_MAX_GPIOS ]; -bool irq_shared; };struct dwapb_platform_data {
Signature · 1 line
2.30.2
PATCH v2 2/4 gpio: dwapb: Read GPIO base from gpio-base property
For backward compatibility with some legacy devices introduce a new (*) property gpio-base to read GPIO base. This will allow further cleaning up of the driver.
*) Note, it's not new for the GPIO library since the mockup driver
is using it already.
---
v2: added check to ensure that the property won't be used by FW (Serge)
drivers/gpio/gpio-dwapb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/gpio-dwapb.c +4 -0
@@ -584,6 +584,10 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->gpio_base =-1 ; +/* For internal use only, new platforms mustn't exercise this */ +if (is_software_node (fwnode)) +fwnode_property_read_u32 (fwnode,"gpio-base" , &pp->gpio_base); +/* * Only port A can provide interrupts in all configurations of * the IP.
Signature · 1 line
2.30.2
Re: [PATCH v2 2/4] gpio: dwapb: Read GPIO base from gpio-base property
Quoted 6 lines · Andy Shevchenko
For backward compatibility with some legacy devices introduce a new (*) property gpio-base to read GPIO base. This will allow further cleaning up of the driver.
*) Note, it's not new for the GPIO library since the mockup driver
is using it already.
Serge, I haven't put any tags here since the patch has been modified. It still works for my case. I hope that's what you wanted me to do.
Since Lee gave his ACKs, this is the last in the series to be reviewed.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/4] gpio: dwapb: Read GPIO base from gpio-base property
Hi Andy
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
For backward compatibility with some legacy devices introduce a new (*) property gpio-base to read GPIO base. This will allow further cleaning up of the driver.
*) Note, it's not new for the GPIO library since the mockup driver
is using it already.Serge, I haven't put any tags here since the patch has been modified. It still works for my case. I hope that's what you wanted me to do.
Thanks for the update. Yep, it works like a charm. No gpio-base is read from DT.
-Sergey
Quoted 8 lines
Since Lee gave his ACKs, this is the last in the series to be reviewed.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/4] gpio: dwapb: Read GPIO base from gpio-base property
In reply to Andy ShevchenkoQuoted 18 lines · Andy Shevchenko
For backward compatibility with some legacy devices introduce a new (*) property gpio-base to read GPIO base. This will allow further cleaning up of the driver.
*) Note, it's not new for the GPIO library since the mockup driver
is using it already.Signed-off-by Andy Shevchenko <[email protected]>---
v2: added check to ensure that the property won't be used by FW (Serge)drivers/gpio/gpio-dwapb.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpio-dwapb.c +0
-0
drivers/gpio/gpio-dwapb.c static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) · line 589
Quoted 6 lines
drivers/gpio/gpio-dwapb.c +3
-0@@ -584,6 +584,10 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->gpio_base =-1 ; +/* For internal use only, new platforms mustn't exercise this */ +if (is_software_node (fwnode)) +fwnode_property_read_u32 (fwnode,"gpio-base" , &pp->gpio_base);
You rewrite the code quicker than I can review :D
So this is elegant, I would prefer "linux,gpio-base" but the overall change is more important, with or without that change:
Yours,
Linus Walleij
Re: [PATCH v2 2/4] gpio: dwapb: Read GPIO base from gpio-base property
Quoted 22 lines · Linus Walleij
Quoted 19 lines · Andy Shevchenko
For backward compatibility with some legacy devices introduce a new (*) property gpio-base to read GPIO base. This will allow further cleaning up of the driver.
*) Note, it's not new for the GPIO library since the mockup driver
is using it already.Signed-off-by Andy Shevchenko <[email protected]>---
v2: added check to ensure that the property won't be used by FW (Serge)drivers/gpio/gpio-dwapb.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpio-dwapb.c +0
-0@@ -584,6 +584,10 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
Quoted 7 lines
drivers/gpio/gpio-dwapb.c static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) · line 589
Quoted 5 lines
drivers/gpio/gpio-dwapb.c +3
-0pp->gpio_base =-1 ; +/* For internal use only, new platforms mustn't exercise this */ +if (is_software_node (fwnode)) +fwnode_property_read_u32 (fwnode,"gpio-base" , &pp->gpio_base);You rewrite the code quicker than I can review :D
Sorry for that :-)
Quoted 2 lines
So this is elegant, I would prefer "linux,gpio-base" but the overall change is more important, with or without that change:
I'm okay with the either, but the thing is that gpio-base is already in use. Perhaps in the future somebody can change both (gpio-mockup and this driver) to use the proposed one (AFAIU we free to change it since it's not part of FW interface).
Quoted 1 line
Reviewed-by Linus Walleij <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 3/4 mfd: intel_quark_i2c_gpio: Convert GPIO to use software nodes
In reply to Andy ShevchenkoThe driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files.
---
v2: added tag (Serge)
drivers/mfd/intel_quark_i2c_gpio.c | 70 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-)
drivers/mfd/intel_quark_i2c_gpio.c +37 -33
@@ -17,7 +17,6 @@#include <linux/clk-provider.h> #include <linux/dmi.h> #include <linux/i2c.h> -#include <linux/platform_data/gpio-dwapb.h> #include <linux/property.h> /* PCI BAR for register base address */
@@ -28,15 +27,6 @@#define MFD_ACPI_MATCH_GPIO 0ULL#define MFD_ACPI_MATCH_I2C 1ULL -/* The base GPIO number under GPIOLIB framework */ -#define INTEL_QUARK_MFD_GPIO_BASE 8 - -/* The default number of South-Cluster GPIO on Quark. */ -#define INTEL_QUARK_MFD_NGPIO 8 - -/* The DesignWare GPIO ports on Quark. */ -#define INTEL_QUARK_GPIO_NPORTS 1 -#define INTEL_QUARK_IORES_MEM 0#define INTEL_QUARK_IORES_IRQ 1
@@ -111,12 +101,38 @@ static struct resource intel_quark_gpio_res[] = { [INTEL_QUARK_IORES_MEM ] = { .flags =IORESOURCE_MEM , }, + [INTEL_QUARK_IORES_IRQ ] = { + .flags =IORESOURCE_IRQ , + }, };static struct mfd_cell_acpi_match intel_quark_acpi_match_gpio = { .adr =MFD_ACPI_MATCH_GPIO , }; +static const struct software_node intel_quark_gpio_controller_node = { + .name ="intel-quark-gpio-controller" , +}; + +static const struct property_entry intel_quark_gpio_portA_properties[] = { +PROPERTY_ENTRY_U32 ("reg" ,0 ), +PROPERTY_ENTRY_U32 ("snps,nr-gpios" ,8 ), +PROPERTY_ENTRY_U32 ("gpio-base" ,8 ), + { } +}; + +static const struct software_node intel_quark_gpio_portA_node = { + .name ="portA" , + .parent = &intel_quark_gpio_controller_node, + .properties = intel_quark_gpio_portA_properties, +}; + +static const struct software_node *intel_quark_gpio_node_group[] = { + &intel_quark_gpio_controller_node, + &intel_quark_gpio_portA_node, +NULL +}; +static struct mfd_cell intel_quark_mfd_cells[] = { [MFD_I2C_BAR ] = { .id =MFD_I2C_BAR ,
@@ -203,34 +219,19 @@ static int intel_quark_gpio_setup(struct pci_dev *pdev) {struct mfd_cell *cell = &intel_quark_mfd_cells[MFD_GPIO_BAR ];struct resource *res = intel_quark_gpio_res; -struct dwapb_platform_data *pdata; -struct device *dev = &pdev->dev; +int ret; res[INTEL_QUARK_IORES_MEM ].start =pci_resource_start (pdev,MFD_GPIO_BAR ); res[INTEL_QUARK_IORES_MEM ].end =pci_resource_end (pdev,MFD_GPIO_BAR ); - pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; - -/* For intel quark x1000, it has only one port: portA */ - pdata->nports =INTEL_QUARK_GPIO_NPORTS ; - pdata->properties =devm_kcalloc (dev, pdata->nports, -sizeof (*pdata->properties), -GFP_KERNEL ); -if (!pdata->properties) -return -ENOMEM ; - -/* Set the properties for portA */ - pdata->properties->fwnode =NULL ; - pdata->properties->idx =0 ; - pdata->properties->ngpio =INTEL_QUARK_MFD_NGPIO ; - pdata->properties->gpio_base =INTEL_QUARK_MFD_GPIO_BASE ; - pdata->properties->irq[0 ] =pci_irq_vector (pdev,0 ); + res[INTEL_QUARK_IORES_IRQ ].start =pci_irq_vector (pdev,0 ); + res[INTEL_QUARK_IORES_IRQ ].end =pci_irq_vector (pdev,0 ); - cell->platform_data = pdata; - cell->pdata_size =sizeof (*pdata); + ret =software_node_register_node_group (intel_quark_gpio_node_group); +if (ret) +return ret; + cell->swnode = &intel_quark_gpio_controller_node;return 0 ; }
@@ -273,10 +274,12 @@ static int intel_quark_mfd_probe(struct pci_dev *pdev,ARRAY_SIZE (intel_quark_mfd_cells),NULL ,0 , NULL);if (ret) - goto err_free_irq_vectors; + goto err_unregister_gpio_node_group;return 0 ; +err_unregister_gpio_node_group: +software_node_unregister_node_group (intel_quark_gpio_node_group); err_free_irq_vectors:pci_free_irq_vectors (pdev); err_unregister_i2c_clk:
@@ -287,6 +290,7 @@ static int intel_quark_mfd_probe(struct pci_dev *pdev,static void intel_quark_mfd_remove (struct pci_dev *pdev) {mfd_remove_devices (&pdev->dev); +software_node_unregister_node_group (intel_quark_gpio_node_group);pci_free_irq_vectors (pdev);intel_quark_unregister_i2c_clk (&pdev->dev); }
Signature · 1 line
2.30.2
Re: [PATCH v2 3/4] mfd: intel_quark_i2c_gpio: Convert GPIO to use software nodes
Quoted 6 lines · Andy Shevchenko
The driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files.
Quoted 6 lines
Signed-off-by Andy Shevchenko <[email protected]>Tested-by Serge Semin <[email protected]>---
v2: added tag (Serge)drivers/mfd/intel_quark_i2c_gpio.c | 70 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 3/4] mfd: intel_quark_i2c_gpio: Convert GPIO to use software nodes
Quoted 15 lines · Lee Jones
Quoted 6 lines · Andy Shevchenko
The driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files.
Quoted 6 lines
Signed-off-by Andy Shevchenko <[email protected]>Tested-by Serge Semin <[email protected]>---
v2: added tag (Serge)drivers/mfd/intel_quark_i2c_gpio.c | 70 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-)
Quoted 3 lines
For my own reference (apply this as-is to your sign-off block):
Acked-for-MFD-by Lee Jones <[email protected]>
Thanks!
Just for your information. I think due to spaces in front of your tag the b4 tool can't catch this automatically.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/4] mfd: intel_quark_i2c_gpio: Convert GPIO to use software nodes
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Lee Jones
Quoted 12 lines · Andy Shevchenko
The driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files.
Signed-off-by Andy Shevchenko <[email protected]>Tested-by Serge Semin <[email protected]>---
v2: added tag (Serge)drivers/mfd/intel_quark_i2c_gpio.c | 70 ++++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-)
Quoted 8 lines
Quoted 3 lines
For my own reference (apply this as-is to your sign-off block):
Acked-for-MFD-by Lee Jones <[email protected]>Thanks!
Just for your information. I think due to spaces in front of your tag the
b4tool can't catch this automatically.
Why would it need to?
This tag is "for my reference", for when I merge it.
Please add it to your sign-off block when you resubmit.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 3/4] mfd: intel_quark_i2c_gpio: Convert GPIO to use software nodes
In reply to Andy ShevchenkoQuoted 8 lines · Andy Shevchenko
The driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files.
Signed-off-by Andy Shevchenko <[email protected]>Tested-by Serge Semin <[email protected]>
Yours,
Linus Walleij
PATCH v2 4/4 gpio: dwapb: Get rid of legacy platform data
In reply to Andy ShevchenkoPlatform data is a legacy interface to supply device properties to the driver. In this case we don't have anymore in-kernel users for it. Just remove it for good.
---
v2: added tags, put structures after forward declaration (Serge)
drivers/gpio/gpio-dwapb.c | 28 +++++++++++++++--------- include/linux/platform_data/gpio-dwapb.h | 24 -------------------- 2 files changed, 18 insertions(+), 34 deletions(-) delete mode 100644 include/linux/platform_data/gpio-dwapb.h
drivers/gpio/gpio-dwapb.c +18 -10
@@ -16,7 +16,6 @@#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/platform_data/gpio-dwapb.h> #include <linux/platform_device.h> #include <linux/property.h> #include <linux/reset.h>
@@ -48,6 +47,7 @@#define DWAPB_DRIVER_NAME "gpio-dwapb"#define DWAPB_MAX_PORTS 4 +#define DWAPB_MAX_GPIOS 32#define GPIO_EXT_PORT_STRIDE 0x04/* register stride 32 bits */ #define GPIO_SWPORT_DR_STRIDE 0x0c/* register stride 3*32 bits */
@@ -65,6 +65,19 @@struct dwapb_gpio ; +struct dwapb_port_property { +struct fwnode_handle *fwnode; +unsigned int idx; +unsigned int ngpio; +unsigned int gpio_base; +int irq[DWAPB_MAX_GPIOS ]; +}; + +struct dwapb_platform_data { +struct dwapb_port_property *properties; +unsigned int nports; +}; +#ifdef CONFIG_PM_SLEEP /* Store GPIO context across system-wide suspend/resume transitions */ struct dwapb_context {
@@ -674,17 +687,12 @@ static int dwapb_gpio_probe(struct platform_device *pdev)unsigned int i;struct dwapb_gpio *gpio;int err; +struct dwapb_platform_data *pdata;struct device *dev = &pdev->dev; -struct dwapb_platform_data *pdata =dev_get_platdata (dev); - -if (!pdata) { - pdata =dwapb_gpio_get_pdata (dev); -if (IS_ERR (pdata)) -return PTR_ERR (pdata); - } -if (!pdata->nports) -return -ENODEV ; + pdata =dwapb_gpio_get_pdata (dev); +if (IS_ERR (pdata)) +return PTR_ERR (pdata); gpio =devm_kzalloc (&pdev->dev,sizeof (*gpio),GFP_KERNEL );if (!gpio)
include/linux/platform_data/gpio-dwapb.h deleted +0 -24
@@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright(c) 2014 Intel Corporation. -*/ - -#ifndef GPIO_DW_APB_H -#define GPIO_DW_APB_H - -#define DWAPB_MAX_GPIOS 32 - -struct dwapb_port_property { -struct fwnode_handle *fwnode; -unsigned int idx; -unsigned int ngpio; -unsigned int gpio_base; -int irq[DWAPB_MAX_GPIOS ]; -}; - -struct dwapb_platform_data { -struct dwapb_port_property *properties; -unsigned int nports; -}; - -#endif
Signature · 1 line
2.30.2
Quoted 4 lines · Andy Shevchenko
Shared IRQ is only enabled for ACPI enumeration, there is no need to have a special flag for that, since we simple can test if device has been enumerated by ACPI. This unifies the checks in
dwapb_get_irq()anddwapb_configure_irqs().
Bart, are you okay with the series? Can it be applied, please?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Shared IRQ is only enabled for ACPI enumeration, there is no need to have a special flag for that, since we simple can test if device has been enumerated by ACPI. This unifies the checks in
dwapb_get_irq()anddwapb_configure_irqs().Bart, are you okay with the series? Can it be applied, please?
I can send it inside my PR if you prefer, btw. (I jest realized that I have already couple of patches in the queue.
Signature · 2 lines
With Best Regards, Andy Shevchenko