Skip to contentSkip to conversation

gpio: dwapb: Fix reference clocks usage

PATCH Superseded [email protected] 6 participants 32 messages Mar 6, 2020 – Apr 16, 2020

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover gpio: dwapb: Fix reference clocks usage

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>

Serge Semin (4):
dt-bindings: gpio: Replace DW APB GPIO legacy bindings with YAML-based
one
dt-bindings: gpio: Add DW GPIO debounce clocks bindings
gpio: dwapb: Use optional-clocks interface for APB ref-clocks
gpio: dwapb: Add debounce reference clock support

 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 140 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 --------
 drivers/gpio/gpio-dwapb.c                     |  41 +++--
 3 files changed, 166 insertions(+), 80 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Signature · 1 line
2.25.1
#1 lore raw
Quoted 29 lines · On Fri, Mar 6, 2020 at 2:25 PM <[email protected]> wrote:

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Quoted 8 lines
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>

I like these patches, once Rob is happy with the bindings I'll be happy to merge them. I haven't heard from Hoan Tran in a while, so if we don't hear from him this time either I would suggest you also add yourself as maintainer for this driver, if you don't mind.

Thanks,
Linus Walleij

#2 lore raw
Quoted 40 lines · Linus Walleij
Quoted 29 lines · On Fri, Mar 6, 2020 at 2:25 PM <[email protected]> wrote:

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Quoted 8 lines
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Quoted 7 lines

I like these patches, once Rob is happy with the bindings I'll be happy to merge them. I haven't heard from Hoan Tran in a while, so if we don't hear from him this time either I would suggest you also add yourself as maintainer for this driver, if you don't mind.

Thanks,
Linus Walleij

Hello Linus,
Thanks for positive response. I'll resend the patchset soon in the email-threaded form together with two extra patches, which will add me to the MAINTAINERS list and to the dt-schema of the driver. If Hoan Tran will show up before you merge them, just drop these two new patches.

Regards,
-Sergey

#3 lore raw

v2 cover gpio: dwapb: Fix reference clocks usage

In reply to [email protected]

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Changelog v2:
- Use a shorter summary describing the DT bindings conversion patch.
- Add myself to the MAINTAINERS file as a maintainer of the DW APB GPIO driver.
- Add myself to the maintainers list of the DW APB GPIO driver DT schema.
- Print error instead of info-message if APB/debounce clocks either failed to be acquired or couldn't be enabled.
- Rearrange the SoB tags.
- Make sure DT schema defines the lowercase hex numbers in the main dt-node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property of the DW APB GPIO DT schema.
- Discard "interrupts-extended" property from the DT schema.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.
- Our corporate email server doesn't change Message-Id anymore, so the patchset is resubmitted being in the cover-letter-threaded format.

Cc Alexey Malahov <[email protected]>
Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>

Serge Semin (6):
dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema
dt-bindings: gpio: Add DW GPIO debounce clock property
dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers
gpio: dwapb: Use optional-clocks interface for APB ref-clock
gpio: dwapb: Add debounce reference clock support
MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 134 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 MAINTAINERS                                   |   1 +
 drivers/gpio/gpio-dwapb.c                     |  41 ++++--
 4 files changed, 161 insertions(+), 80 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 1/6 dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema

From: Serge Semin <[email protected]>

Modern device tree bindings are supposed to be created as YAML-files in accordance with DT schema. This commit replaces Synopsys DW GPIO legacy bare text binding with YAML file. As before the binding file states that the corresponding dts node is supposed to be compatible with generic DW I2C controller indicated by the "snps,dw-apb-gpio" compatible string and to provide a mandatory registers memory range. It may also have an optional clock and reset phandle references.

There must be specified at least one subnode with "snps,dw-apb-gpio-port" compatible string indicating the GPIO port, which would actually export the GPIO controller functionality. Such nodes should have traditional GPIO controller properties together with optional interrupt-controller attributes if the corresponding controller was synthesized to detect and report the input values change to the parental IRQ controller.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>

---

Changelog v2:
- Use lowercase hex numbers in the main node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property.
- Discard "interrupts-extended" property.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.

The DT scheme provided by this patch will pass the dt_binding_check command after the next patches are merged to the dt-schema repo:

schemas/gpio/gpio.yaml +1 -1
@@ -34,7 +34,7 @@ properties:
       - $ref: "/schemas/types.yaml#/definitions/phandle-array"
 
 patternProperties:
-  ".*-gpios?$":
+  "(?<!,nr)-gpios?$":
     $ref: "/schemas/types.yaml#/definitions/phandle-array"
   "^gpios$":
     $ref: "/schemas/types.yaml#/definitions/phandle-array"
meta-schemas/gpios.yaml +1 -3
@@ -19,9 +19,7 @@
     $ref: "cell.yaml#array"
 
 patternProperties:
-  '.*-gpio$':
-    $ref: "cell.yaml#array"
-  '.*-gpios$':
+  '(?<!,nr)-gpios?$':
     $ref: "cell.yaml#array"
 
 dependencies:
---
 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 129 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 2 files changed, 129 insertions(+), 65 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml new file +129 -0

129 lines not on this page · raw message

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt deleted +0 -65

65 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 2/6 dt-bindings: gpio: Add DW GPIO debounce clock property

In reply to [email protected]

From: Serge Semin <[email protected]>

Port A of the DW GPIO controller may optionally have a debounce logic enabled if it was synthesized with that functionality enabled. In this case a dedicated reference clock should be declared in the node with corresponding "db" name presented in the clock-names property.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
---
 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml +4 -0
index f84f92c4dd53..58a8df367623 100644
@@ -31,12 +31,16 @@ properties:
     maxItems: 1
 
   clocks:
+    minItems: 1
     items:
       - description: APB interface clock source
+      - description: DW GPIO debounce reference clock source
 
   clock-names:
+    minItems: 1
     items:
       - const: bus
+      - const: db
 
   resets:
     maxItems: 1
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 3/6 dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers

In reply to [email protected]

From: Serge Semin <[email protected]>

Seeing Hoan has been silent for a long time Linus suggested to me to be also maintaining the driver. This patch adds myself to the list of maintainers in the DT schema of the driver.

Cc Hoan Tran <[email protected]>
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
---
 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml +1 -0
index 58a8df367623..04a3c51e1dc1 100644
@@ -13,6 +13,7 @@ description: |
 
 maintainers:
   - Hoan Tran <[email protected]>
+  - Serge Semin <[email protected]>
 
 properties:
   $nodename:
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 4/6 gpio: dwapb: Use optional-clocks interface for APB ref-clock

In reply to [email protected]

From: Serge Semin <[email protected]>

The common clocks kernel framework provides a generic way to use an optional reference clock sources. If it's utilized there is no need in checking whether the clock descriptor pointer is actually a negative error at the moment of the prepare/unprepare clocks method calling. So if the corresponding clock source is provided, then getting an error shall actually terminate the device probe procedure. If it isn't specified then the driver shall proceed with further initializations.

We'll use the optional clocks getting method to handle the APB reference clock, which can be provided for instance in the device of-node with "bus" clock-name.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>

---

Changelog v2:
- Print error instead of info-message if APB clock either failed to be acquired or couldn't be enabled.

---
 drivers/gpio/gpio-dwapb.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpio/gpio-dwapb.c +11 -9
index 92e127e74813..0c5abfa361e6 100644
@@ -690,13 +690,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(gpio->regs);
 
 	/* Optional bus clock */
-	gpio->clk = devm_clk_get(&pdev->dev, "bus");
-	if (!IS_ERR(gpio->clk)) {
-		err = clk_prepare_enable(gpio->clk);
-		if (err) {
-			dev_info(&pdev->dev, "Cannot enable clock\n");
-			return err;
-		}
+	gpio->clk = devm_clk_get_optional(&pdev->dev, "bus");
+	if (IS_ERR(gpio->clk)) {
+		dev_err(&pdev->dev, "Cannot get APB clock\n");
+		return PTR_ERR(gpio->clk);
+	}
+
+	err = clk_prepare_enable(gpio->clk);
+	if (err) {
+		dev_err(&pdev->dev, "Cannot enable APB clock\n");
+		return err;
 	}
 
 	gpio->flags = 0;
@@ -793,8 +796,7 @@ static int dwapb_gpio_resume(struct device *dev)
 	unsigned long flags;
 	int i;
 
-	if (!IS_ERR(gpio->clk))
-		clk_prepare_enable(gpio->clk);
+	clk_prepare_enable(gpio->clk);
 
 	spin_lock_irqsave(&gc->bgpio_lock, flags);
 	for (i = 0; i < gpio->nr_ports; i++) {
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v2 4/6] gpio: dwapb: Use optional-clocks interface for APB ref-clock

Quoted 15 lines · On Mon, Mar 23, 2020 at 09:06:30PM +0300, [email protected]…

From: Serge Semin <[email protected]>

The common clocks kernel framework provides a generic way to use an optional reference clock sources. If it's utilized there is no need in checking whether the clock descriptor pointer is actually a negative error at the moment of the prepare/unprepare clocks method calling. So if the corresponding clock source is provided, then getting an error shall actually terminate the device probe procedure. If it isn't specified then the driver shall proceed with further initializations.

We'll use the optional clocks getting method to handle the APB reference clock, which can be provided for instance in the device of-node with "bus" clock-name.

drivers/gpio/gpio-dwapb.c static int dwapb_gpio_resume(struct device *dev) · line 799

Quoted 3 lines
drivers/gpio/gpio-dwapb.c +1 -2
-	if (!IS_ERR(gpio->clk))
-		clk_prepare_enable(gpio->clk);
+	clk_prepare_enable(gpio->clk);

Perhaps it makes sense now to consider error code returned by above. Maybe it's material for a separate patch (up to you).

The rest looks good.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

PATCH v2 5/6 gpio: dwapb: Add debounce reference clock support

In reply to [email protected]

From: Serge Semin <[email protected]>

Aside from the APB reference clock DW GPIO controller can have a dedicated clock connected to setup a debounce time interval for GPIO-based IRQs. Since this functionality is optional the corresponding clock source is also optional. Due to this lets handle the debounce clock in the same way as it has been developed for the APB reference clock, but using the bulk request/enable-disable methods.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>

---

Changelog v2:
- Print error instead of info-message if APB/debounce clocks either failed to be acquired or couldn't be enabled.

---
 drivers/gpio/gpio-dwapb.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
drivers/gpio/gpio-dwapb.c +22 -13
index 0c5abfa361e6..d2ed11510f3c 100644
@@ -62,6 +62,8 @@
 #define GPIO_INTSTATUS_V2	0x3c
 #define GPIO_PORTA_EOI_V2	0x40
 
+#define DWAPB_NR_CLOCKS		2
+
 struct dwapb_gpio;
 
 #ifdef CONFIG_PM_SLEEP
@@ -97,7 +99,7 @@ struct dwapb_gpio {
 	struct irq_domain	*domain;
 	unsigned int		flags;
 	struct reset_control	*rst;
-	struct clk		*clk;
+	struct clk_bulk_data	clks[DWAPB_NR_CLOCKS];
 };
 
 static inline u32 gpio_reg_v2_convert(unsigned int offset)
@@ -689,16 +691,19 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gpio->regs))
 		return PTR_ERR(gpio->regs);
 
-	/* Optional bus clock */
-	gpio->clk = devm_clk_get_optional(&pdev->dev, "bus");
-	if (IS_ERR(gpio->clk)) {
-		dev_err(&pdev->dev, "Cannot get APB clock\n");
-		return PTR_ERR(gpio->clk);
+	/* Optional bus and debounce clocks */
+	gpio->clks[0].id = "bus";
+	gpio->clks[1].id = "db";
+	err = devm_clk_bulk_get_optional(&pdev->dev, DWAPB_NR_CLOCKS,
+					 gpio->clks);
+	if (err) {
+		dev_err(&pdev->dev, "Cannot get APB/Debounce clocks\n");
+		return err;
 	}
 
-	err = clk_prepare_enable(gpio->clk);
+	err = clk_bulk_prepare_enable(DWAPB_NR_CLOCKS, gpio->clks);
 	if (err) {
-		dev_err(&pdev->dev, "Cannot enable APB clock\n");
+		dev_err(&pdev->dev, "Cannot enable APB/Debounce clocks\n");
 		return err;
 	}
 
@@ -727,7 +732,7 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 out_unregister:
 	dwapb_gpio_unregister(gpio);
 	dwapb_irq_teardown(gpio);
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return err;
 }
@@ -739,7 +744,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
 	dwapb_gpio_unregister(gpio);
 	dwapb_irq_teardown(gpio);
 	reset_control_assert(gpio->rst);
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return 0;
 }
@@ -784,7 +789,7 @@ static int dwapb_gpio_suspend(struct device *dev)
 	}
 	spin_unlock_irqrestore(&gc->bgpio_lock, flags);
 
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return 0;
 }
@@ -794,9 +799,13 @@ static int dwapb_gpio_resume(struct device *dev)
 	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
 	struct gpio_chip *gc	= &gpio->ports[0].gc;
 	unsigned long flags;
-	int i;
+	int i, err;
 
-	clk_prepare_enable(gpio->clk);
+	err = clk_bulk_prepare_enable(DWAPB_NR_CLOCKS, gpio->clks);
+	if (err) {
+		dev_err(gpio->dev, "Cannot reenable APB/Debounce clocks\n");
+		return err;
+	}
 
 	spin_lock_irqsave(&gc->bgpio_lock, flags);
 	for (i = 0; i < gpio->nr_ports; i++) {
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v2 5/6] gpio: dwapb: Add debounce reference clock support

drivers/gpio/gpio-dwapb.c static int dwapb_gpio_resume(struct device *dev) · line 808

Quoted 13 lines · On Mon, Mar 23, 2020 at 09:06:31PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Aside from the APB reference clock DW GPIO controller can have a dedicated clock connected to setup a debounce time interval for GPIO-based IRQs. Since this functionality is optional the corresponding clock source is also optional. Due to this lets handle the debounce clock in the same way as it has been developed for the APB reference clock, but using the bulk request/enable-disable methods.

drivers/gpio/gpio-dwapb.c +4 -0
+	if (err) {
+		dev_err(gpio->dev, "Cannot reenable APB/Debounce clocks\n");
+		return err;
+	}

Yeah, this should be a separate change.

Otherwise looks good.

Also, did I miss the documentation update (bindings)?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH v2 5/6] gpio: dwapb: Add debounce reference clock support

Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · On Mon, Mar 23, 2020 at 09:06:31PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Aside from the APB reference clock DW GPIO controller can have a dedicated clock connected to setup a debounce time interval for GPIO-based IRQs. Since this functionality is optional the corresponding clock source is also optional. Due to this lets handle the debounce clock in the same way as it has been developed for the APB reference clock, but using the bulk request/enable-disable methods.

Quoted 7 lines

drivers/gpio/gpio-dwapb.c static int dwapb_gpio_resume(struct device *dev) · line 808

Quoted 4 lines
drivers/gpio/gpio-dwapb.c +4 -0
+	if (err) {
+		dev_err(gpio->dev, "Cannot reenable APB/Debounce clocks\n");
+		return err;
+	}

Yeah, this should be a separate change.

Linus didn't think it was necessary in v1.

Quoted 4 lines

Otherwise looks good.

Also, did I miss the documentation update (bindings)?

No, it's there: https://www.spinics.net/lists/devicetree/msg342655.html
You just haven't been in Cc there.

-Sergey

Quoted 5 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH v2 5/6] gpio: dwapb: Add debounce reference clock support

Quoted 16 lines · Sergey Semin
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · On Mon, Mar 23, 2020 at 09:06:31PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Aside from the APB reference clock DW GPIO controller can have a dedicated clock connected to setup a debounce time interval for GPIO-based IRQs. Since this functionality is optional the corresponding clock source is also optional. Due to this lets handle the debounce clock in the same way as it has been developed for the APB reference clock, but using the bulk request/enable-disable methods.

drivers/gpio/gpio-dwapb.c +4 -0
+   if (err) {
+           dev_err(gpio->dev, "Cannot reenable APB/Debounce clocks\n");
+           return err;
+   }
Quoted 4 lines
Quoted 2 lines

Yeah, this should be a separate change.

Linus didn't think it was necessary in v1.

Ah, okay!

Quoted 1 line
Quoted 1 line

Otherwise looks good.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw

PATCH v2 6/6 MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

In reply to [email protected]

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

Cc Hoan Tran <[email protected]>
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 6158a143a13e..1940862de204 100644
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
+S:	Serge Semin <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Signature · 1 line
2.25.1
#14 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

Quoted 3 lines · On Mon, Mar 23, 2020 at 09:06:32PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

I see neither cover letter, nor first three patches. What's going on?

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16088

Quoted 8 lines
MAINTAINERS +1 -0
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
 
+S:	Serge Semin <[email protected]>

Are you sure you used a correct letter?

Quoted 3 lines
MAINTAINERS +0 -0
 L:	[email protected]
 S:	Maintained

F: Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt

Had you chance to run parse-maintainers.pl to see if other fields are in order?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · On Mon, Mar 23, 2020 at 09:06:32PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

I see neither cover letter, nor first three patches. What's going on?

Automatic "cc-cmd" is added you to the Cc list. You've been referenced as a patch submitter, that's why you are in Cc to this and some another patch.

Regards,
-Sergey

Quoted 22 lines

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16088

Quoted 8 lines
MAINTAINERS +1 -0
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
 
+S:	Serge Semin <[email protected]>

Are you sure you used a correct letter?

Quoted 3 lines
MAINTAINERS +0 -0
 L:	[email protected]
 S:	Maintained

F: Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt

Had you chance to run parse-maintainers.pl to see if other fields are in order?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

In reply to [email protected]
Quoted 3 lines · On Mon, 2020-03-23 at 21:06 +0300, [email protected] wrote:

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

[]

MAINTAINERS

Quoted 1 line
MAINTAINERS +0 -0

[]

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16087

Quoted 5 lines
MAINTAINERS +1 -0
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
+S:	Serge Semin <[email protected]>

nack - S: is not the right line type prefix

You need to use an M: type line not an S:.

The S: line is for subsystem status which should be one of:

S: *Status*, one of the following:
Supported: Someone is actually paid to look after this.
Maintained: Someone actually looks after it.
Odd Fixes: It has a maintainer but they don't have time to do
much other than throw the odd patch in. See below..
Orphan: No current maintainer [but maybe you could take the
role as you write your new code].
Obsolete: Old code. Something tagged obsolete generally means
it has been replaced by a better system and you should be using that.

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16089

Quoted 2 lines
MAINTAINERS +0 -0
 L:	[email protected]
 S:	Maintained

like this...

Quoted 1 line
MAINTAINERS +0 -0
 F:	Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
#17 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

Quoted 10 lines · Joe Perches
Quoted 3 lines · On Mon, 2020-03-23 at 21:06 +0300, [email protected] wrote:

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

[]

MAINTAINERS

Quoted 1 line
MAINTAINERS +0 -0

[]

Quoted 2 lines
MAINTAINERS +0 -0
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
Quoted 8 lines

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16087

Quoted 3 lines
MAINTAINERS +1 -0
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
+S:	Serge Semin <[email protected]>

nack - S: is not the right line type prefix

You need to use an M: type line not an S:.

Ah, yeah. Will fix it in v3.

Regards,
-Sergey

Quoted 22 lines

The S: line is for subsystem status which should be one of:

S: *Status*, one of the following:
Supported: Someone is actually paid to look after this.
Maintained: Someone actually looks after it.
Odd Fixes: It has a maintainer but they don't have time to do
much other than throw the odd patch in. See below..
Orphan: No current maintainer [but maybe you could take the
role as you write your new code].
Obsolete: Old code. Something tagged obsolete generally means
it has been replaced by a better system and you should be using that.

MAINTAINERS F: drivers/tty/serial/8250/8250_dw.c · line 16089

Quoted 2 lines
MAINTAINERS +0 -0
 L:	[email protected]
 S:	Maintained

like this...

Quoted 1 line
MAINTAINERS +0 -0
 F:	Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
#18 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

In reply to [email protected]

Drop unneeded Cc's.

Quoted 3 lines · On Mon, Mar 23, 2020 at 09:06:32PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

By the way, if you are really wanting to maintain the driver, I may give you (for free) Intel Galileo board where this IP is being used.

Send me private mail where we can discuss how to deliver.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#19 lore raw

Re: [PATCH v2 6/6] MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

Quoted 12 lines · Andy Shevchenko

Drop unneeded Cc's.

Quoted 3 lines · On Mon, Mar 23, 2020 at 09:06:32PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

By the way, if you are really wanting to maintain the driver, I may give you (for free) Intel Galileo board where this IP is being used.

Send me private mail where we can discuss how to deliver.

You can communicate with me via this email: fancer.lancer (at) gmail.com

-Sergey

Quoted 5 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#20 lore raw

v3 cover gpio: dwapb: Fix reference clocks usage

In reply to [email protected]

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Changelog v2:
- Use a shorter summary describing the DT bindings conversion patch.
- Add myself to the MAINTAINERS file as a maintainer of the DW APB GPIO driver.
- Add myself to the maintainers list of the DW APB GPIO driver DT schema.
- Print error instead of info-message if APB/debounce clocks either failed to be acquired or couldn't be enabled.
- Rearrange the SoB tags.
- Make sure DT schema defines the lowercase hex numbers in the main dt-node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property of the DW APB GPIO DT schema.
- Discard "interrupts-extended" property from the DT schema.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.
- Our corporate email server doesn't change Message-Id anymore, so the patchset is resubmitted being in the cover-letter-threaded format.

Changelog v3:
- Replace S: with M: section entry in the MAINTAINERS file.
- Cc Andy to all patches he isn't added by the auto "cc-cmd" command.

Cc Alexey Malahov <[email protected]>
Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Andy Shevchenko <[email protected]>,

Serge Semin (6):
dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema
dt-bindings: gpio: Add DW GPIO debounce clock property
dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers
gpio: dwapb: Use optional-clocks interface for APB ref-clock
gpio: dwapb: Add debounce reference clock support
MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 134 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 MAINTAINERS                                   |   1 +
 drivers/gpio/gpio-dwapb.c                     |  41 ++++--
 4 files changed, 161 insertions(+), 80 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Signature · 1 line
2.25.1
#21 lore raw

PATCH v3 1/6 dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema

From: Serge Semin <[email protected]>

Modern device tree bindings are supposed to be created as YAML-files in accordance with DT schema. This commit replaces Synopsys DW GPIO legacy bare text binding with YAML file. As before the binding file states that the corresponding dts node is supposed to be compatible with generic DW I2C controller indicated by the "snps,dw-apb-gpio" compatible string and to provide a mandatory registers memory range. It may also have an optional clock and reset phandle references.

There must be specified at least one subnode with "snps,dw-apb-gpio-port" compatible string indicating the GPIO port, which would actually export the GPIO controller functionality. Such nodes should have traditional GPIO controller properties together with optional interrupt-controller attributes if the corresponding controller was synthesized to detect and report the input values change to the parental IRQ controller.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>

---

Changelog v2:
- Use lowercase hex numbers in the main node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property.
- Discard "interrupts-extended" property.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.

The DT scheme provided by this patch will pass the dt_binding_check command after the next patches are merged to the dt-schema repo:

schemas/gpio/gpio.yaml +1 -1
@@ -34,7 +34,7 @@ properties:
       - $ref: "/schemas/types.yaml#/definitions/phandle-array"
 
 patternProperties:
-  ".*-gpios?$":
+  "(?<!,nr)-gpios?$":
     $ref: "/schemas/types.yaml#/definitions/phandle-array"
   "^gpios$":
     $ref: "/schemas/types.yaml#/definitions/phandle-array"
meta-schemas/gpios.yaml +1 -3
@@ -19,9 +19,7 @@
     $ref: "cell.yaml#array"
 
 patternProperties:
-  '.*-gpio$':
-    $ref: "cell.yaml#array"
-  '.*-gpios$':
+  '(?<!,nr)-gpios?$':
     $ref: "cell.yaml#array"
 
 dependencies:
---
 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 129 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 2 files changed, 129 insertions(+), 65 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml new file +129 -0

129 lines not on this page · raw message

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt deleted +0 -65

65 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer Reviewed-by on v3 1/6
#22 lore raw

Re: [PATCH v3 1/6] dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema

Quoted 35 lines · On Mon, Mar 23, 2020 at 10:53:56PM +0300, [email protected]…

From: Serge Semin <[email protected]>

Modern device tree bindings are supposed to be created as YAML-files in accordance with DT schema. This commit replaces Synopsys DW GPIO legacy bare text binding with YAML file. As before the binding file states that the corresponding dts node is supposed to be compatible with generic DW I2C controller indicated by the "snps,dw-apb-gpio" compatible string and to provide a mandatory registers memory range. It may also have an optional clock and reset phandle references.

There must be specified at least one subnode with "snps,dw-apb-gpio-port" compatible string indicating the GPIO port, which would actually export the GPIO controller functionality. Such nodes should have traditional GPIO controller properties together with optional interrupt-controller attributes if the corresponding controller was synthesized to detect and report the input values change to the parental IRQ controller.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>

---

Changelog v2:
- Use lowercase hex numbers in the main node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property.
- Discard "interrupts-extended" property.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.

Quoted 2 lines

The DT scheme provided by this patch will pass the dt_binding_check command after the next patches are merged to the dt-schema repo:

Merged now.

Quoted 6 lines
---
 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 129 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 2 files changed, 129 insertions(+), 65 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
#23 lore raw

PATCH v3 2/6 dt-bindings: gpio: Add DW GPIO debounce clock property

In reply to [email protected]

From: Serge Semin <[email protected]>

Port A of the DW GPIO controller may optionally have a debounce logic enabled if it was synthesized with that functionality enabled. In this case a dedicated reference clock should be declared in the node with corresponding "db" name presented in the clock-names property.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>
---
 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml +4 -0
index f84f92c4dd53..58a8df367623 100644
@@ -31,12 +31,16 @@ properties:
     maxItems: 1
 
   clocks:
+    minItems: 1
     items:
       - description: APB interface clock source
+      - description: DW GPIO debounce reference clock source
 
   clock-names:
+    minItems: 1
     items:
       - const: bus
+      - const: db
 
   resets:
     maxItems: 1
Signature · 1 line
2.25.1
#24 lore raw

PATCH v3 3/6 dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers

In reply to [email protected]

From: Serge Semin <[email protected]>

Seeing Hoan has been silent for a long time Linus suggested to me to be also maintaining the driver. This patch adds myself to the list of maintainers in the DT schema of the driver.

Cc Hoan Tran <[email protected]>
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>
---
 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml +1 -0
index 58a8df367623..04a3c51e1dc1 100644
@@ -13,6 +13,7 @@ description: |
 
 maintainers:
   - Hoan Tran <[email protected]>
+  - Serge Semin <[email protected]>
 
 properties:
   $nodename:
Signature · 1 line
2.25.1
maintainer Acked-by on v3 3/6
#25 lore raw

Re: [PATCH v3 3/6] dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers

Quoted 14 lines · On Mon, 23 Mar 2020 22:53:58 +0300, <[email protected]> wrote:

From: Serge Semin <[email protected]>

Seeing Hoan has been silent for a long time Linus suggested to me to be also maintaining the driver. This patch adds myself to the list of maintainers in the DT schema of the driver.

Cc Hoan Tran <[email protected]>
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>
Quoted 4 lines
---
 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 1 +
 1 file changed, 1 insertion(+)
#26 lore raw

PATCH v3 4/6 gpio: dwapb: Use optional-clocks interface for APB ref-clock

In reply to [email protected]

From: Serge Semin <[email protected]>

The common clocks kernel framework provides a generic way to use an optional reference clock sources. If it's utilized there is no need in checking whether the clock descriptor pointer is actually a negative error at the moment of the prepare/unprepare clocks method calling. So if the corresponding clock source is provided, then getting an error shall actually terminate the device probe procedure. If it isn't specified then the driver shall proceed with further initializations.

We'll use the optional clocks getting method to handle the APB reference clock, which can be provided for instance in the device of-node with "bus" clock-name.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>

---

Changelog v2:
- Print error instead of info-message if APB clock either failed to be acquired or couldn't be enabled.

---
 drivers/gpio/gpio-dwapb.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpio/gpio-dwapb.c +11 -9
index 92e127e74813..0c5abfa361e6 100644
@@ -690,13 +690,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(gpio->regs);
 
 	/* Optional bus clock */
-	gpio->clk = devm_clk_get(&pdev->dev, "bus");
-	if (!IS_ERR(gpio->clk)) {
-		err = clk_prepare_enable(gpio->clk);
-		if (err) {
-			dev_info(&pdev->dev, "Cannot enable clock\n");
-			return err;
-		}
+	gpio->clk = devm_clk_get_optional(&pdev->dev, "bus");
+	if (IS_ERR(gpio->clk)) {
+		dev_err(&pdev->dev, "Cannot get APB clock\n");
+		return PTR_ERR(gpio->clk);
+	}
+
+	err = clk_prepare_enable(gpio->clk);
+	if (err) {
+		dev_err(&pdev->dev, "Cannot enable APB clock\n");
+		return err;
 	}
 
 	gpio->flags = 0;
@@ -793,8 +796,7 @@ static int dwapb_gpio_resume(struct device *dev)
 	unsigned long flags;
 	int i;
 
-	if (!IS_ERR(gpio->clk))
-		clk_prepare_enable(gpio->clk);
+	clk_prepare_enable(gpio->clk);
 
 	spin_lock_irqsave(&gc->bgpio_lock, flags);
 	for (i = 0; i < gpio->nr_ports; i++) {
Signature · 1 line
2.25.1
#27 lore raw

PATCH v3 5/6 gpio: dwapb: Add debounce reference clock support

In reply to [email protected]

From: Serge Semin <[email protected]>

Aside from the APB reference clock DW GPIO controller can have a dedicated clock connected to setup a debounce time interval for GPIO-based IRQs. Since this functionality is optional the corresponding clock source is also optional. Due to this lets handle the debounce clock in the same way as it has been developed for the APB reference clock, but using the bulk request/enable-disable methods.

Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>

---

Changelog v2:
- Print error instead of info-message if APB/debounce clocks either failed to be acquired or couldn't be enabled.

---
 drivers/gpio/gpio-dwapb.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
drivers/gpio/gpio-dwapb.c +22 -13
index 0c5abfa361e6..d2ed11510f3c 100644
@@ -62,6 +62,8 @@
 #define GPIO_INTSTATUS_V2	0x3c
 #define GPIO_PORTA_EOI_V2	0x40
 
+#define DWAPB_NR_CLOCKS		2
+
 struct dwapb_gpio;
 
 #ifdef CONFIG_PM_SLEEP
@@ -97,7 +99,7 @@ struct dwapb_gpio {
 	struct irq_domain	*domain;
 	unsigned int		flags;
 	struct reset_control	*rst;
-	struct clk		*clk;
+	struct clk_bulk_data	clks[DWAPB_NR_CLOCKS];
 };
 
 static inline u32 gpio_reg_v2_convert(unsigned int offset)
@@ -689,16 +691,19 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gpio->regs))
 		return PTR_ERR(gpio->regs);
 
-	/* Optional bus clock */
-	gpio->clk = devm_clk_get_optional(&pdev->dev, "bus");
-	if (IS_ERR(gpio->clk)) {
-		dev_err(&pdev->dev, "Cannot get APB clock\n");
-		return PTR_ERR(gpio->clk);
+	/* Optional bus and debounce clocks */
+	gpio->clks[0].id = "bus";
+	gpio->clks[1].id = "db";
+	err = devm_clk_bulk_get_optional(&pdev->dev, DWAPB_NR_CLOCKS,
+					 gpio->clks);
+	if (err) {
+		dev_err(&pdev->dev, "Cannot get APB/Debounce clocks\n");
+		return err;
 	}
 
-	err = clk_prepare_enable(gpio->clk);
+	err = clk_bulk_prepare_enable(DWAPB_NR_CLOCKS, gpio->clks);
 	if (err) {
-		dev_err(&pdev->dev, "Cannot enable APB clock\n");
+		dev_err(&pdev->dev, "Cannot enable APB/Debounce clocks\n");
 		return err;
 	}
 
@@ -727,7 +732,7 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 out_unregister:
 	dwapb_gpio_unregister(gpio);
 	dwapb_irq_teardown(gpio);
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return err;
 }
@@ -739,7 +744,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
 	dwapb_gpio_unregister(gpio);
 	dwapb_irq_teardown(gpio);
 	reset_control_assert(gpio->rst);
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return 0;
 }
@@ -784,7 +789,7 @@ static int dwapb_gpio_suspend(struct device *dev)
 	}
 	spin_unlock_irqrestore(&gc->bgpio_lock, flags);
 
-	clk_disable_unprepare(gpio->clk);
+	clk_bulk_disable_unprepare(DWAPB_NR_CLOCKS, gpio->clks);
 
 	return 0;
 }
@@ -794,9 +799,13 @@ static int dwapb_gpio_resume(struct device *dev)
 	struct dwapb_gpio *gpio = dev_get_drvdata(dev);
 	struct gpio_chip *gc	= &gpio->ports[0].gc;
 	unsigned long flags;
-	int i;
+	int i, err;
 
-	clk_prepare_enable(gpio->clk);
+	err = clk_bulk_prepare_enable(DWAPB_NR_CLOCKS, gpio->clks);
+	if (err) {
+		dev_err(gpio->dev, "Cannot reenable APB/Debounce clocks\n");
+		return err;
+	}
 
 	spin_lock_irqsave(&gc->bgpio_lock, flags);
 	for (i = 0; i < gpio->nr_ports; i++) {
Signature · 1 line
2.25.1
#28 lore raw

PATCH v3 6/6 MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

In reply to [email protected]

From: Serge Semin <[email protected]>

Add myself as a co-maintainer of the Synopsis DesignWare APB GPIO driver.

Cc Hoan Tran <[email protected]>
Cc Alexey Malahov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Andy Shevchenko <[email protected]>

---

Changelog v3:
- Replace S: with M: section entry.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 6158a143a13e..de46d94d70f7 100644
@@ -16084,6 +16084,7 @@ F:	drivers/tty/serial/8250/8250_dw.c
 
 SYNOPSYS DESIGNWARE APB GPIO DRIVER
 M:	Hoan Tran <[email protected]>
+M:	Serge Semin <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
Signature · 1 line
2.25.1
Reviewed-by on the v3 series
#29 lore raw
In reply to [email protected]
Quoted 16 lines · On Mon, Mar 23, 2020 at 9:55 PM <[email protected]> wrote:

From: Serge Semin <[email protected]>

There is no need in any fixes to have the Baikal-T1 SoC DW GPIO controllers supported by the kernel DW APB GPIO driver. It works for them just fine with no modifications. But still there is a room for optimizations there.

First of all as it tends to be traditional for all Baikal-T1 SoC related patchset we replaced the legacy plain text-based dt-binding file with yaml-based one. Baikal-T1 DW GPIO port A supports a debounce functionality, but in order to use it the corresponding reference clock must be enabled. We added support of that clock in the driver and made sure the dt-bindings had its declaration. In addition seeing both APB and debounce reference clocks are optional, we replaced the standard devm_clk_get() usage with the function of optional clocks acquisition.

Quoted 2 lines

This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
commit 98d54f81e36b ("Linux 5.6-rc4").

Thank you!
FWIW,

Quoted 62 lines

Changelog v2:
- Use a shorter summary describing the DT bindings conversion patch.
- Add myself to the MAINTAINERS file as a maintainer of the DW APB GPIO driver.
- Add myself to the maintainers list of the DW APB GPIO driver DT schema.
- Print error instead of info-message if APB/debounce clocks either failed to be acquired or couldn't be enabled.
- Rearrange the SoB tags.
- Make sure DT schema defines the lowercase hex numbers in the main dt-node name and in the sub-node names.
- Use "allOf:" statement to apply uint32 and "minimum/maximum" limitations on the "snps,nr-gpios" property of the DW APB GPIO DT schema.
- Discard "interrupts-extended" property from the DT schema.
- Make sure the sub-nodes have names with either 'gpio-port' or 'gpio-controller' prefixes.
- Our corporate email server doesn't change Message-Id anymore, so the patchset is resubmitted being in the cover-letter-threaded format.

Changelog v3:
- Replace S: with M: section entry in the MAINTAINERS file.
- Cc Andy to all patches he isn't added by the auto "cc-cmd" command.

Cc Alexey Malahov <[email protected]>
Cc Maxim Kaurkin <[email protected]>
Cc Pavel Parkhomenko <[email protected]>
Cc Ramil Zaripov <[email protected]>
Cc Ekaterina Skachko <[email protected]>
Cc Vadim Vlasov <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Paul Burton <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Hoan Tran <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Rob Herring <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Andy Shevchenko <[email protected]>,

Serge Semin (6):
dt-bindings: gpio: Convert snps,dw-apb-gpio to DT schema
dt-bindings: gpio: Add DW GPIO debounce clock property
dt-bindings: gpio: Add Sergey Semin to DW APB GPIO driver maintainers
gpio: dwapb: Use optional-clocks interface for APB ref-clock
gpio: dwapb: Add debounce reference clock support
MAINTAINERS: Add Segey Semin to maintainers of DW APB GPIO driver

 .../bindings/gpio/snps,dw-apb-gpio.yaml       | 134 ++++++++++++++++++
 .../bindings/gpio/snps-dwapb-gpio.txt         |  65 ---------
 MAINTAINERS                                   |   1 +
 drivers/gpio/gpio-dwapb.c                     |  41 ++++--
 4 files changed, 161 insertions(+), 80 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
 delete mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt

--
2.25.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#30 lore raw
In reply to [email protected]

I have applied the v3 version of the patch set after some tinkering with the b4 tool.

For some reason some patches are missing in my inbox and also on som mailing lists, they are not in my spamfolder even.

Anyways with some help from Konstantin I managed to get the series out using the b4 tool and applied it.

Thanks!
Linus Walleij

#31 lore raw
Quoted 8 lines · Linus Walleij

I have applied the v3 version of the patch set after some tinkering with the b4 tool.

For some reason some patches are missing in my inbox and also on som mailing lists, they are not in my spamfolder even.

Anyways with some help from Konstantin I managed to get the series out using the b4 tool and applied it.

Thanks Linus.
Regarding missing the messages in your inbox. It's weird. I double checked. All messages were sent to your email. Regarding missing them in the devicetree mailing list. It's my mistake. Forgot to add it to Cc'es. Next time I'll keep in mind that this is necessary.

Regards,
-Sergey

Quoted 3 lines

Thanks!
Linus Walleij