add SAMA5D2 PIOBU GPIO driver
Subsystems (3)
v2 cover add SAMA5D2 PIOBU GPIO driver
On SAMA5D2 SoC the PIOBU pins do not lose their voltage during Backup/Self-refresh mode. This can be useful, for example, when the voltage must remain positive for a peripheral during Backup/Self-refresh mode (suspend-to ram is the Linux equivalent state).
v2:
- make driver be a subnode of the syscon node
- change Kconfig to depend on MFD_SYSCON and select GPIO_SYSCON
- change include header from linux/gpio.h to linux/gpio/driver.h
- include linux/bits.h header
- change intrusion in comment to tamper
- fix kerneldoc of functions
- replace GPIOF_DIR_* flags with 0/1
- replace ?: statement with if-else
- remove the use of sama5d2_piobu_template_chip
- retrieve syscon via syscon_node_to_regmap(pdev->dev.parent->of_node);
Note that PIOBU_REG_SIZE is used to determine the register to write to with regmap:
reg = PIOBU_BASE + pin * PIOBU_REG_SIZE;
Also, no irq capability implemented.
Andrei Stefanescu (2):
dt-bindings: gpio: add SAMA5D2 PIOBU support
gpio: add driver for SAMA5D2 PIOBU pins
.../bindings/gpio/gpio-sama5d2-piobu.txt | 31 +++ MAINTAINERS | 7 + drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-sama5d2-piobu.c | 253 +++++++++++++++++++++ 5 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt create mode 100644 drivers/gpio/gpio-sama5d2-piobu.c
Signature · 1 line
2.7.4
PATCH v2 1/2 dt-bindings: gpio: add SAMA5D2 PIOBU support
This patch describes the compatible and the device tree bindings necessary for the SAMA5D2 PIOBU GPIO.
--- .../bindings/gpio/gpio-sama5d2-piobu.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +31 -0
@@ -0,0 +1,31 @@ +GPIO controller for SAMA5D2 PIOBU pins. + +These pins have the property of not losing their voltage +during Backup/Self-refresh mode. + +These bindings should be set to a node in the dtsi file. + +Required properties: +- compatible: "syscon", "microchip,sama5d2-piobu" +- #gpio-cells: There are 2. The pin number is the + first, the second represents additional + parameters such as GPIO_ACTIVE_HIGH/LOW. +- gpio-controller: Marks the port as GPIO controller. + +Note that the driver uses syscon and should be the child of +the syscon node. + +Example: + + secumod at fc040000 { + compatible = "atmel,sama5d2-secumod", "syscon", "simple-mfd"; + status = "okay"; + reg = <0xfc040000 0x100>; + + pioBU: piobu { + status = "okay"; + compatible = "microchip,sama5d2-piobu"; + gpio-controller; + #gpio-cells = <2>; + }; + };
Signature · 1 line
2.7.4
Re: [PATCH v2 1/2] dt-bindings: gpio: add SAMA5D2 PIOBU support
Hello Rob,
Could you please tell me if there are any improvements to be made to the patch?
Best regards,
Andrei
Quoted 46 lines · On 20.11.2018 10:08, Andrei Stefanescu - M50506 wrote:
This patch describes the compatible and the device tree bindings necessary for the SAMA5D2 PIOBU GPIO.
Signed-off-by Andrei Stefanescu <[email protected]>--- .../bindings/gpio/gpio-sama5d2-piobu.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+)create mode 100644
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txtDocumentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +31
-0@@ -0,0 +1,31 @@ +GPIO controller for SAMA5D2 PIOBU pins. + +These pins have the property of not losing their voltage +during Backup/Self-refresh mode. + +These bindings should be set to a node in the dtsi file. + +Required properties: +- compatible: "syscon", "microchip,sama5d2-piobu" +- #gpio-cells: There are 2. The pin number is the + first, the second represents additional + parameters such as GPIO_ACTIVE_HIGH/LOW. +- gpio-controller: Marks the port as GPIO controller. + +Note that the driver uses syscon and should be the child of +the syscon node. + +Example: + + secumod@fc040000 { + compatible = "atmel,sama5d2-secumod", "syscon", "simple-mfd"; + status = "okay"; + reg = <0xfc040000 0x100>; + + pioBU: piobu { + status = "okay"; + compatible = "microchip,sama5d2-piobu"; + gpio-controller; + #gpio-cells = <2>; + }; + };
Rob Herring
maintainerRe: [PATCH v2 1/2] dt-bindings: gpio: add SAMA5D2 PIOBU support
In reply to [email protected]Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt
Quoted 14 lines · On Tue, Nov 20, 2018 at 08:08:36AM +0000, [email protected] wrote:
This patch describes the compatible and the device tree bindings necessary for the SAMA5D2 PIOBU GPIO.
Signed-off-by Andrei Stefanescu <[email protected]>--- .../bindings/gpio/gpio-sama5d2-piobu.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txtDocumentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +0
-0
microchip,sama5d2-piobu.txt for the file name.
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt line 9
Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +9
-0@@ -0,0 +1,31 @@ +GPIO controller for SAMA5D2 PIOBU pins. + +These pins have the property of not losing their voltage +during Backup/Self-refresh mode. + +These bindings should be set to a node in the dtsi file. + +Required properties: +- compatible: "syscon", "microchip,sama5d2-piobu"
syscon should be removed.
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt line 16
Quoted 7 lines
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +7
-0+- #gpio-cells: There are 2. The pin number is the + first, the second represents additional + parameters such as GPIO_ACTIVE_HIGH/LOW. +- gpio-controller: Marks the port as GPIO controller. + +Note that the driver uses syscon and should be the child of +the syscon node.
child of the "atmel,sama5d2-secumod" node to be more specific.
But why do you need a child node? The parent can be a gpio provider. What other nodes does this need?
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt line 21
Quoted 5 lines
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +5
-0+ +Example: + + secumod@fc040000 { + compatible = "atmel,sama5d2-secumod", "syscon", "simple-mfd";
This is not documented as being a simple-mfd.
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt line 25
Quoted 4 lines
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +4
-0+ status = "okay"; + reg = <0xfc040000 0x100>; + + pioBU: piobu {
gpio {
Is there not a register range you can put here?
Quoted 9 lines
Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt new file +6
-0+ status = "okay"; + compatible = "microchip,sama5d2-piobu"; + gpio-controller; + #gpio-cells = <2>; + }; + };Signature · 1 line
2.7.4
Re: [PATCH v2 1/2] dt-bindings: gpio: add SAMA5D2 PIOBU support
Hello Rob,
Thank you for your feedback.
I will add a bit of context regarding the secumod. The "atmel,sama5d2-secumod"
compatible string is not used for loading a driver. It is used by atmel securam
driver (drivers/misc/sram.c) which has access to secumod's registers via:
syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod")
So the secumod exports multiple hardware functions, eg: the securam, the PIOBU
pins which can be used as GPIO pins.
My initial patch had the "microchip,sama5d2-piobu" compatible appended to the
secumod's compatible e.g.:
secumod@fc040000 {
compatible = "syscon", "microchip,sama5d2-piobu";
...
Taking into consideration Linus Walleij's advice I arrived to the current version. I thought this was a good idea because it separates the secumod node
from the GPIO controller node. Please notice that securam node is already separated from secumod node (it is a separate node in the device tree).
I have a few questions because I am not sure of the best approach:
1. Is it ok to have the GPIO controller as a child node?
2. I used simple-mfd because it was the only way I could think of in order to
get the driver probed.
3. Should I add a register range? I thought that because the driver uses syscon
it is not necessary to add the register range. Also, the register
range would
have been a subset of the secumod's register range.
Rob Herring
maintainerRe: [PATCH v2 1/2] dt-bindings: gpio: add SAMA5D2 PIOBU support
Quoted 11 lines · On Wed, Dec 5, 2018 at 5:06 AM <[email protected]> wrote:
Hello Rob,
Thank you for your feedback.
I will add a bit of context regarding the secumod. The "atmel,sama5d2-secumod"
compatible string is not used for loading a driver. It is used by atmel securam
driver (drivers/misc/sram.c) which has access to secumod's registers via:
Quoted 5 lines
syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod")So the secumod exports multiple hardware functions, eg: the securam, the PIOBU
pins which can be used as GPIO pins.
Yes, I understand why you want to design it this way, but don't design your bindings around how 1 OS happens to currently work.
Quoted 7 lines
My initial patch had the "microchip,sama5d2-piobu" compatible appended to the
secumod's compatible e.g.:secumod@fc040000 { compatible = "syscon", "microchip,sama5d2-piobu";
That doesn't look appended to me. The documentation says it should look like this:
compatible = "atmel,sama5d2-secumod", "syscon";
Quoted 11 lines
...
Taking into consideration Linus Walleij's advice I arrived to the current version. I thought this was a good idea because it separates the secumod node
from the GPIO controller node. Please notice that securam node is already separated from secumod node (it is a separate node in the device tree).I have a few questions because I am not sure of the best approach:
1. Is it ok to have the GPIO controller as a child node?
Is it a separate h/w block and do you have other child nodes that need their own resources in DT (interrupts, clocks, etc.)? If these aren't the case, then no you shouldn't. As it stands, you don't have any other child nodes, so no you shouldn't have a child node here. Just add to properties to the existing binding:
secumod@fc040000 {
compatible = "atmel,sama5d2-secumod", "syscon";
reg = <0xfc040000 0x100>;
#gpio-cells = <2>;
gpio-controller;
};Now perhaps you have 10 other functions in this block like pinctrl, clocks, phys, power domains, etc. Then child nodes would be warranted. But if that's the case, then please write a complete binding for the secumod block.
Quoted 3 lines
2. I used simple-mfd because it was the only way I could think of in order to
get the driver probed.
Sounds like an OS problem that has little to do with the binding. In any case, if you change a binding which you have, then it needs to be documented.
Quoted 5 lines
3. Should I add a register range? I thought that because the driver uses syscon
it is not necessary to add the register range. Also, the register
range would
have been a subset of the secumod's register range.
If it has one, then yes you should. If it doesn't then it is probably not a separate h/w block and shouldn't have a child node to begin with.
Rob
PATCH v2 2/2 gpio: add driver for SAMA5D2 PIOBU pins
In reply to [email protected]PIOBU pins do not lose their voltage during Backup/Self-refresh. This patch adds a simple GPIO controller for them and a maintainer for the driver.
This driver adds support for using the pins as GPIO offering the possibility to read/set the voltage.
--- MAINTAINERS | 7 ++ drivers/gpio/Kconfig | 11 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-sama5d2-piobu.c | 253 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 272 insertions(+) create mode 100644 drivers/gpio/gpio-sama5d2-piobu.c
MAINTAINERS +7 -0
@@ -9760,6 +9760,13 @@ M: Nicolas Ferre <[email protected]> S: Supported F: drivers/power/reset/at91-sama5d2_shdwc.c +MICROCHIP SAMA5D2-COMPATIBLE PIOBU GPIO +M: Andrei Stefanescu <[email protected]> +L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) +L: linux-gpio at vger.kernel.org +F: drivers/gpio/gpio-sama5d2-piobu.c +F: Documentation/devicetree/bindings/gpio/gpio-sama5d2-piobu.txt + MICROCHIP SPI DRIVER M: Nicolas Ferre <[email protected]> S: Supported
drivers/gpio/Kconfig +11 -0
@@ -429,6 +429,17 @@ config GPIO_REG A 32-bit single register GPIO fixed in/out implementation. This can be used to represent any register as a set of GPIO signals. +config GPIO_SAMA5D2_PIOBU + tristate "SAMA5D2 PIOBU GPIO support" + depends on MFD_SYSCON + select GPIO_SYSCON + help + Say yes here to use the PIOBU pins as GPIOs. + + PIOBU pins on the SAMA5D2 can be used as GPIOs. + The difference from regular GPIOs is that they + maintain their value during backup/self-refresh. + config GPIO_SIOX tristate "SIOX GPIO support" depends on SIOX
drivers/gpio/Makefile +1 -0
@@ -108,6 +108,7 @@ obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o obj-$(CONFIG_GPIO_REG) += gpio-reg.o obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o +obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o obj-$(CONFIG_GPIO_SCH) += gpio-sch.o obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o obj-$(CONFIG_GPIO_SNPS_CREG) += gpio-creg-snps.o
drivers/gpio/gpio-sama5d2-piobu.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.7.4
Hi Andrei,
Quoted 7 lines · On Tue, Nov 20, 2018 at 9:08 AM <[email protected]> wrote:
On SAMA5D2 SoC the PIOBU pins do not lose their voltage during Backup/Self-refresh mode. This can be useful, for example, when the voltage must remain positive for a peripheral during Backup/Self-refresh mode (suspend-to ram is the Linux equivalent state).
v2:
This version looks good to me, I'm just waiting for a DT binding review.
Yours,
Linus Walleij