Skip to contentSkip to conversation

preferable method for pinctrl driver

PATCH Superseded Oleksij Rempel 3 participants 35 messages Oct 10, 2014 – Sep 25, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello all,

based on previous experience with clk driver, i know that own research can be not enough. Before starting to writ pinctrl driver, i would like to ask your suggestions.

Looks like there is at least two pinctrl driver types:
- imx23 which makes function description insight of DT;
- tegra with function descrption in the source code. which way is preferable?

Other question, i didn't found exact same HW, do it make sense to merge this driver with existing one? Are there some similarities with this one?:
http://pastebin.com/hW82Xupq

Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141010/686d4c1a/attachment.sig>
#1 lore raw
Quoted 4 lines · Oleksij Rempel

Looks like there is at least two pinctrl driver types:
- imx23 which makes function description insight of DT;
- tegra with function descrption in the source code. which way is preferable?

The Tegra way. The driver should know about all groups and functions, the DT should just configure the functions to groups relation.

The i.MX driver happened before the DT use for pin controllers was thought through.

Quoted 3 lines

Other question, i didn't found exact same HW, do it make sense to merge this driver with existing one? Are there some similarities with this one?:
http://pastebin.com/hW82Xupq

No idea, that's very little HW information. However silicon vendors often du their I/O cell layout themselves so many pin controllers are very unique.

Yours,
Linus Walleij

#2 lore raw

Am 13.10.2014 um 11:05 schrieb Linus Walleij:

Quoted 18 lines · Oleksij Rempel
Quoted 5 lines

Looks like there is at least two pinctrl driver types:
- imx23 which makes function description insight of DT;
- tegra with function descrption in the source code. which way is preferable?

The Tegra way. The driver should know about all groups and functions, the DT should just configure the functions to groups relation.

The i.MX driver happened before the DT use for pin controllers was thought through.

Quoted 3 lines

Other question, i didn't found exact same HW, do it make sense to merge this driver with existing one? Are there some similarities with this one?:
http://pastebin.com/hW82Xupq

Quoted 6 lines

No idea, that's very little HW information. However silicon vendors often du their I/O cell layout themselves so many pin controllers are very unique.

Yours,
Linus Walleij

Hi,
thank you for your previous response. One more question: how pins should be numbered? Continuous or register offsets can be used? Documentations for this soc use pin names encoded like this #NAME_#BANK_#PIN. Register offset can be calculated by ((bank) * 32 + (pin) * 4)
In this case i need to have extra array to convert pin number to offset, or use offset as pin number.

Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141107/30aa5c73/attachment.sig>
#3 lore raw

Am 07.11.2014 um 09:35 schrieb Oleksij Rempel:

Quoted 26 lines

Am 13.10.2014 um 11:05 schrieb Linus Walleij:

Quoted 18 lines · Oleksij Rempel
Quoted 5 lines

Looks like there is at least two pinctrl driver types:
- imx23 which makes function description insight of DT;
- tegra with function descrption in the source code. which way is preferable?

The Tegra way. The driver should know about all groups and functions, the DT should just configure the functions to groups relation.

The i.MX driver happened before the DT use for pin controllers was thought through.

Quoted 3 lines

Other question, i didn't found exact same HW, do it make sense to merge this driver with existing one? Are there some similarities with this one?:
http://pastebin.com/hW82Xupq

Quoted 6 lines

No idea, that's very little HW information. However silicon vendors often du their I/O cell layout themselves so many pin controllers are very unique.

Yours,
Linus Walleij

Quoted 8 lines

Hi,
thank you for your previous response. One more question: how pins should be numbered? Continuous or register offsets can be used? Documentations for this soc use pin names encoded like this #NAME_#BANK_#PIN. Register offset can be calculated by ((bank) * 32 + (pin) * 4)
In this case i need to have extra array to convert pin number to offset, or use offset as pin number.

Never mind, i think i found the answer:
This enumeration was arbitrarily chosen, in practice you need to think through your numbering system so that it matches the layout of registers and such things in your driver, or the code may become complicated. You must also consider matching of offsets to the GPIO ranges that may be handled by the pin controller.

Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141107/9b3e5c31/attachment.sig>
#4 lore raw
Quoted 8 lines · Oleksij Rempel
Quoted 7 lines

thank you for your previous response. One more question: how pins should be numbered? Continuous or register offsets can be used? Documentations for this soc use pin names encoded like this #NAME_#BANK_#PIN. Register offset can be calculated by ((bank) * 32 + (pin) * 4)
In this case i need to have extra array to convert pin number to offset, or use offset as pin number.

Quoted 6 lines

Never mind, i think i found the answer:
This enumeration was arbitrarily chosen, in practice you need to think through your numbering system so that it matches the layout of registers and such things in your driver, or the code may become complicated. You must also consider matching of offsets to the GPIO ranges that may be handled by the pin controller.

Yeah you're right :)

There is some resoning in Documentation/pinctrl.txt but it needs some intuition etc.

Yours,
Linus Walleij

#5 lore raw

Am 14.11.2014 um 11:01 schrieb Linus Walleij:

Quoted 17 lines · Oleksij Rempel
Quoted 9 lines
Quoted 8 lines

thank you for your previous response. One more question: how pins should be numbered? Continuous or register offsets can be used? Documentations for this soc use pin names encoded like this #NAME_#BANK_#PIN. Register offset can be calculated by ((bank) * 32 + (pin) * 4)
In this case i need to have extra array to convert pin number to offset, or use offset as pin number.

Quoted 6 lines

Never mind, i think i found the answer:
This enumeration was arbitrarily chosen, in practice you need to think through your numbering system so that it matches the layout of registers and such things in your driver, or the code may become complicated. You must also consider matching of offsets to the GPIO ranges that may be handled by the pin controller.

Quoted 8 lines

Yeah you're right :)

There is some resoning in Documentation/pinctrl.txt but it needs some intuition etc.

Yours,
Linus Walleij

What is preferred method of handling gpio_request_enable in pinctrl driver? My hw provide GPIO as one of mux variants for each controlled pin. if i see it correctly, pin subsystem will not prevent using one pin as gpio and request for some other functionality? Should it be prevented by driver?

Here is my current pinctrl driver, in case it help understand my point:
https://github.com/olerem/linux-2.6/commit/5d8963e24493db445207c29dec00a6a848d8e781

Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150209/d679592d/attachment.sig>
#7 lore raw

PATCH 1/1 pinctrl: Add initial driver data for Alphascale asm9260

In reply to Linus Walleij

This patch adds initial driver data for Alphascale asm9260 pinctrl support.

---
 .../pinctrl/alphascale,asm9260-pinctrl.txt         |  76 +++
 drivers/pinctrl/Kconfig                            |   8 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-asm9260.c                  | 733 +++++++++++++++++++++
 4 files changed, 818 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +76 -0
new file mode 100644
index 0000000..c8b9a21
@@ -0,0 +1,76 @@
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure the multi-purpose pins
+(MPP) to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+	* 1 "ahb" : AHB gating clock.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+SUBNODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins			- the list of pins that properties in the node
+			  apply to (either this or "group" has to be
+			  specified)
+function		- the mux function to select
+bias-disable		- disable any pin bias
+bias-pull-up		- pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down		- pull down the pin. Supported on all pins except of GPIO0_*.
+
+Examples:
+
+pinctrl: pinctrl@80044000 {
+	compatible = "alphascale,asm9260-pinctrl";
+	reg = <0x80044000 0x400>;
+	clocks = <&acc CLKID_AHB_IOCONFIG>;
+	clock-names = "ahb";
+
+        nand_fc0_pins_a: nand_fc0 {
+                nand_main_gr {
+                        pins = "GPIO11_0", "GPIO11_1", "GPIO11_2",
+                               "GPIO11_3", "GPIO11_4", "GPIO11_6",
+                               "GPIO12_0", "GPIO12_1", "GPIO12_2",
+                               "GPIO12_3", "GPIO12_4", "GPIO12_5",
+                               "GPIO12_6", "GPIO12_7";
+                        function = "nand0";
+                        bias-disable;
+                };
+        };
+};
+
+nand_controller0 {
+        status = "okay";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nand-ecc-strength = <4>;
+        nand-ecc-step-size = <512>;
+        nand-max-chips = <1>;
+        nand-on-flash-bbt;
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&nand_fc0_pins_a>;
+};
drivers/pinctrl/Kconfig +8 -0
index d014f22..19cd287 100644
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	bool "Pinctrl driver for Alphascale asm9260"
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
drivers/pinctrl/Makefile +1 -0
index c030b3d..46ba7d1c 100644
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
drivers/pinctrl/pinctrl-asm9260.c new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw
In reply to Oleksij Rempel
Quoted 5 lines · Oleksij Rempel

What is preferred method of handling gpio_request_enable in pinctrl driver? My hw provide GPIO as one of mux variants for each controlled pin. if i see it correctly, pin subsystem will not prevent using one pin as gpio and request for some other functionality? Should it be prevented by driver?

That is up to the driver writer. We have contemplated adding an option to pinctrl_desc enforcing "exclusive GPIO" meaning that GPIO and another mux setting cannot be used at the same time, but noone got around to implementing that.

Some pin controllers can do GPIO and another function at the same time, see illustrations and text in Documentation/pinctrl.txt

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH] pinctrl: Add initial driver data for Alphascale asm9260

In reply to Oleksij Rempel

Hi Oleksij,

Thanks for your patch.

On Thu, Feb 12, 2015 at 12:32 PM, Oleksij Rempel <[email protected]> wrote:

Also send the patch to [email protected] as that is the default pin control mailing list.

Split off Device Tree bindings in its own file and send that also to [email protected] for review.

Quoted 3 lines

This patch adds initial driver data for Alphascale asm9260 pinctrl support.

A bit terse description, tell us a bit more about the system in the initial commit, and what silicon it lives in etc.

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 4

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +2 -0
+The pinctrl driver enables Alphascale ASM9260 to configure the multi-purpose pins
+(MPP) to a specific function.

MPP? That is a new name again for pin multiplexing, alternate function, mission mode etc... apparently people have a problem with what to call this.

(...)

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 15

Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +3 -0
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".

Nice. Good that you use generic bindings.

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 38

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +5 -0
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins                   - the list of pins that properties in the node
+                         apply to (either this or "group" has to be
+                         specified)

Should be "groups" not "group". Several groups can map to one function.

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 42

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +4 -0
+function               - the mux function to select
+bias-disable           - disable any pin bias
+bias-pull-up           - pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down         - pull down the pin. Supported on all pins except of GPIO0_*.

Nice, good details.

(...)

drivers/pinctrl/pinctrl-asm9260.c line 81

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+struct asm9260_function {
+       const char              *name;
+       const char              **groups;
+       unsigned int            ngroups;
+};

Yes, see one function, many groups.

The driver looks simple and nice.

Yours,
Linus Walleij

#9 lore raw

v2 cover Add driver and documentation for Alphascale asm9260 pinctrl

Oleksij Rempel (2):
pinctrl: Add driver for Alphascale asm9260 pinctrl
pinctrl: asm9260: add pinctrl add device tree bindings documentation

 .../pinctrl/alphascale,asm9260-pinctrl.txt         |  76 +++
 drivers/pinctrl/Kconfig                            |   8 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-asm9260.c                  | 733 +++++++++++++++++++++
 4 files changed, 818 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 1/2 pinctrl: Add driver for Alphascale asm9260 pinctrl

This patch adds driver for Alphascale asm9260 pinctrl support. Alphascale asm9260t is SoC based on ARM926EJ (240MHz) in LQFP176 package. On silicon are:
- 32MB SDRAM
- USB2.0 HS/OTG
- 2x CAN
- SD/MMC
- 5x Times/PWM
- 10x USART
- 24-channel DMA
- 2x i2c
- 2x SPI
- Quad SPI
- 10/100 Ethernet MAC
- Camera IF
- WD
- RTC
- i2s
- GPIO
- 12-bit A/D
- LCD IF
- 8-channel 12-bit ADC
- NAND

---
 drivers/pinctrl/Kconfig           |   8 +
 drivers/pinctrl/Makefile          |   1 +
 drivers/pinctrl/pinctrl-asm9260.c | 733 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 742 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
drivers/pinctrl/Kconfig +8 -0
index d014f22..19cd287 100644
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	bool "Pinctrl driver for Alphascale asm9260"
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
drivers/pinctrl/Makefile +1 -0
index c030b3d..46ba7d1c 100644
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
drivers/pinctrl/pinctrl-asm9260.c new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
1.9.1
#34 lore raw

PATCH v2 2/2 pinctrl: asm9260: add pinctrl add device tree bindings documentation

In reply to Oleksij Rempel

Add device tree bindings documentation for Alphascale asm9260 pin controller

---
 .../pinctrl/alphascale,asm9260-pinctrl.txt         | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +76 -0
new file mode 100644
index 0000000..dbeea4d
@@ -0,0 +1,76 @@
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure pin multiplexing
+to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+	* 1 "ahb" : AHB gating clock.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+SUBNODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins			- the list of pins that properties in the node
+			  apply to (either this or "groups" has to be
+			  specified)
+function		- the mux function to select
+bias-disable		- disable any pin bias
+bias-pull-up		- pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down		- pull down the pin. Supported on all pins except of GPIO0_*.
+
+Examples:
+
+pinctrl: pinctrl@80044000 {
+	compatible = "alphascale,asm9260-pinctrl";
+	reg = <0x80044000 0x400>;
+	clocks = <&acc CLKID_AHB_IOCONFIG>;
+	clock-names = "ahb";
+
+        nand_fc0_pins_a: nand_fc0 {
+                nand_main_gr {
+                        pins = "GPIO11_0", "GPIO11_1", "GPIO11_2",
+                               "GPIO11_3", "GPIO11_4", "GPIO11_6",
+                               "GPIO12_0", "GPIO12_1", "GPIO12_2",
+                               "GPIO12_3", "GPIO12_4", "GPIO12_5",
+                               "GPIO12_6", "GPIO12_7";
+                        function = "nand0";
+                        bias-disable;
+                };
+        };
+};
+
+nand_controller0 {
+        status = "okay";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nand-ecc-strength = <4>;
+        nand-ecc-step-size = <512>;
+        nand-max-chips = <1>;
+        nand-on-flash-bbt;
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&nand_fc0_pins_a>;
+};
Signature · 1 line
1.9.1
#11 lore raw

Re: [PATCH v2 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Oleksij Rempel

This patch adds a mismatch between the Kconfig symbol (bool) and the code (which assumes a modular built too).

drivers/pinctrl/Kconfig config PINCTRL_AS3722 · line 51

Quoted 8 lines · Oleksij Rempel
drivers/pinctrl/Kconfig +2 -0
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	bool "Pinctrl driver for Alphascale asm9260"

This adds a bool symbol.

drivers/pinctrl/Kconfig config PINCTRL_AS3722

Quoted 11 lines
drivers/pinctrl/Kconfig +8 -1
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 
-- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
 
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o

So this object can now only be built-in.

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
@@ -0,0 +1,733 @@
+/*
+ * Pinctrl driver for the Alphascale ASM9260 SoC
+ *

drivers/pinctrl/pinctrl-asm9260.c line 13

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +10 -0
+ * Copyright (c) 2014, Oleksij Rempel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/module.h>

This include is probably not needed.

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_device.h>
+
+#include "core.h"

drivers/pinctrl/pinctrl-asm9260.c

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
+#include "pinctrl-utils.h"
 
+/*
+ * Pin control driver setup
+ */
+static struct pinctrl_desc asm9260_pinctrl_desc = {
+	.pctlops	= &asm9260_pinctrl_ops,
+	.pmxops		= &asm9260_pinmux_ops,
+	.confops	= &asm9260_pinconf_ops,
+	.owner		= THIS_MODULE,

THIS_MODULE is, basically, equivalent to NULL for built-in code.

drivers/pinctrl/pinctrl-asm9260.c line 718

Quoted 4 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+};
+
 
+MODULE_DEVICE_TABLE(of, asm9260_pinctrl_of_match);

This will be preprocessed away for built-in code.

Quoted 1 line

+module_platform_driver(asm9260_pinctrl_driver);

The built-in equivalent of this seems to be a wrapper that only does

    platform_driver_register(&asm9260_pinctrl_driver);

and mark that wrapper as a device_initcall(). There appears to be no macro that does all that in one line.

drivers/pinctrl/pinctrl-asm9260.c line 733

Quoted 3 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+MODULE_AUTHOR("Oleksij Rempel <[email protected]>");
+MODULE_DESCRIPTION("Alphascale ASM9260 pinctrl driver");
+MODULE_LICENSE("GPL");

These three macros will be, effectively, preprocessed away for built-in code. (By the way, you probably want to use "GPL v2" as the license ident if it would be possible to build this code modular.)

Paul Bolle

#12 lore raw

Re: [PATCH v2 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

Hi Paul,

thank you for your review.

Am 27.03.2015 um 18:10 schrieb Paul Bolle:

Quoted 39 lines

This patch adds a mismatch between the Kconfig symbol (bool) and the code (which assumes a modular built too).

drivers/pinctrl/Kconfig config PINCTRL_AS3722 · line 51

Quoted 8 lines · Oleksij Rempel
drivers/pinctrl/Kconfig +2 -0
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	bool "Pinctrl driver for Alphascale asm9260"

This adds a bool symbol.

drivers/pinctrl/Kconfig config PINCTRL_AS3722

Quoted 11 lines
drivers/pinctrl/Kconfig +8 -1
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 
-- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
 
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o

So this object can now only be built-in.

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +7 -0
@@ -0,0 +1,733 @@
+/*
+ * Pinctrl driver for the Alphascale ASM9260 SoC
+ *
+ * Copyright (c) 2014, Oleksij Rempel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
Quoted 8 lines

drivers/pinctrl/pinctrl-asm9260.c line 13

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/module.h>

This include is probably not needed.

This include is still needed for MODULE_DEVICE_TABLE.

Quoted 34 lines
Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_device.h>
+
+#include "core.h"

drivers/pinctrl/pinctrl-asm9260.c

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
+#include "pinctrl-utils.h"
 
+/*
+ * Pin control driver setup
+ */
+static struct pinctrl_desc asm9260_pinctrl_desc = {
+	.pctlops	= &asm9260_pinctrl_ops,
+	.pmxops		= &asm9260_pinmux_ops,
+	.confops	= &asm9260_pinconf_ops,
+	.owner		= THIS_MODULE,

THIS_MODULE is, basically, equivalent to NULL for built-in code.

drivers/pinctrl/pinctrl-asm9260.c line 718

Quoted 4 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+};
+
 
+MODULE_DEVICE_TABLE(of, asm9260_pinctrl_of_match);

This will be preprocessed away for built-in code.

Quoted 1 line

+module_platform_driver(asm9260_pinctrl_driver);

The built-in equivalent of this seems to be a wrapper that only does

    platform_driver_register(&asm9260_pinctrl_driver);

and mark that wrapper as a device_initcall(). There appears to be no macro that does all that in one line.

Quoted 8 lines

drivers/pinctrl/pinctrl-asm9260.c line 733

Quoted 3 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+MODULE_AUTHOR("Oleksij Rempel <[email protected]>");
+MODULE_DESCRIPTION("Alphascale ASM9260 pinctrl driver");
+MODULE_LICENSE("GPL");

These three macros will be, effectively, preprocessed away for built-in code. (By the way, you probably want to use "GPL v2" as the license ident if it would be possible to build this code modular.)

According to:
http://lxr.free-electrons.com/source/include/linux/module.h#L100
"GPL" [GNU Public License v2 or later]

which reflects statement provided in the header :)

I assume all this changes are in the grey zone between: "make it pretty" and "it won't make any difference" :D

Are you ok if we leave it as is?

Signature · 2 lines
Regards,
Oleksij
#13 lore raw

Re: [PATCH v2 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Paul Bolle

Am 27.03.2015 um 18:10 schrieb Paul Bolle:

Quoted 82 lines

This patch adds a mismatch between the Kconfig symbol (bool) and the code (which assumes a modular built too).

drivers/pinctrl/Kconfig config PINCTRL_AS3722 · line 51

Quoted 8 lines · Oleksij Rempel
drivers/pinctrl/Kconfig +2 -0
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	bool "Pinctrl driver for Alphascale asm9260"

This adds a bool symbol.

drivers/pinctrl/Kconfig config PINCTRL_AS3722

Quoted 11 lines
drivers/pinctrl/Kconfig +8 -1
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 
-- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
 
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o

So this object can now only be built-in.

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
@@ -0,0 +1,733 @@
+/*
+ * Pinctrl driver for the Alphascale ASM9260 SoC
+ *

drivers/pinctrl/pinctrl-asm9260.c line 13

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +10 -0
+ * Copyright (c) 2014, Oleksij Rempel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/module.h>

This include is probably not needed.

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_device.h>
+
+#include "core.h"

drivers/pinctrl/pinctrl-asm9260.c

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
+#include "pinctrl-utils.h"
 
+/*
+ * Pin control driver setup
+ */
+static struct pinctrl_desc asm9260_pinctrl_desc = {
+	.pctlops	= &asm9260_pinctrl_ops,
+	.pmxops		= &asm9260_pinmux_ops,
+	.confops	= &asm9260_pinconf_ops,
+	.owner		= THIS_MODULE,

THIS_MODULE is, basically, equivalent to NULL for built-in code.

drivers/pinctrl/pinctrl-asm9260.c line 718

Quoted 4 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+};
+
 
+MODULE_DEVICE_TABLE(of, asm9260_pinctrl_of_match);

This will be preprocessed away for built-in code.

Quoted 1 line

+module_platform_driver(asm9260_pinctrl_driver);

The built-in equivalent of this seems to be a wrapper that only does

    platform_driver_register(&asm9260_pinctrl_driver);

and mark that wrapper as a device_initcall(). There appears to be no macro that does all that in one line.

Quoted 7 lines

drivers/pinctrl/pinctrl-asm9260.c line 733

Quoted 3 lines
drivers/pinctrl/pinctrl-asm9260.c new file +3 -0
+MODULE_AUTHOR("Oleksij Rempel <[email protected]>");
+MODULE_DESCRIPTION("Alphascale ASM9260 pinctrl driver");
+MODULE_LICENSE("GPL");

These three macros will be, effectively, preprocessed away for built-in code. (By the way, you probably want to use "GPL v2" as the license ident if it would be possible to build this code modular.)

Or, i'll just make a tristate from it.

Signature · 2 lines
Regards,
Oleksij
#14 lore raw

v3 cover Add driver and documentation for Alphascale asm9260 pinctrl

In reply to Paul Bolle

Oleksij Rempel (2):
pinctrl: Add driver for Alphascale asm9260 pinctrl
pinctrl: asm9260: add pinctrl add device tree bindings documentation

 .../pinctrl/alphascale,asm9260-pinctrl.txt         |  76 +++
 drivers/pinctrl/Kconfig                            |   8 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-asm9260.c                  | 733 +++++++++++++++++++++
 4 files changed, 818 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
Signature · 1 line
1.9.1
#15 lore raw

PATCH v3 1/2 pinctrl: Add driver for Alphascale asm9260 pinctrl

This patch adds driver for Alphascale asm9260 pinctrl support. Alphascale asm9260t is SoC based on ARM926EJ (240MHz) in LQFP176 package. On silicon are:
- 32MB SDRAM
- USB2.0 HS/OTG
- 2x CAN
- SD/MMC
- 5x Times/PWM
- 10x USART
- 24-channel DMA
- 2x i2c
- 2x SPI
- Quad SPI
- 10/100 Ethernet MAC
- Camera IF
- WD
- RTC
- i2s
- GPIO
- 12-bit A/D
- LCD IF
- 8-channel 12-bit ADC
- NAND

---
 drivers/pinctrl/Kconfig           |   8 +
 drivers/pinctrl/Makefile          |   1 +
 drivers/pinctrl/pinctrl-asm9260.c | 733 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 742 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
drivers/pinctrl/Kconfig +8 -0
index d014f22..054ecbc 100644
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	tristate "Pinctrl driver for Alphascale asm9260"
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
drivers/pinctrl/Makefile +1 -0
index c030b3d..46ba7d1c 100644
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
drivers/pinctrl/pinctrl-asm9260.c new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
1.9.1
#33 lore raw

PATCH v3 2/2 pinctrl: asm9260: add pinctrl add device tree bindings documentation

In reply to Oleksij Rempel

Add device tree bindings documentation for Alphascale asm9260 pin controller

---
 .../pinctrl/alphascale,asm9260-pinctrl.txt         | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +76 -0
new file mode 100644
index 0000000..dbeea4d
@@ -0,0 +1,76 @@
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure pin multiplexing
+to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+	* 1 "ahb" : AHB gating clock.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+SUBNODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins			- the list of pins that properties in the node
+			  apply to (either this or "groups" has to be
+			  specified)
+function		- the mux function to select
+bias-disable		- disable any pin bias
+bias-pull-up		- pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down		- pull down the pin. Supported on all pins except of GPIO0_*.
+
+Examples:
+
+pinctrl: pinctrl@80044000 {
+	compatible = "alphascale,asm9260-pinctrl";
+	reg = <0x80044000 0x400>;
+	clocks = <&acc CLKID_AHB_IOCONFIG>;
+	clock-names = "ahb";
+
+        nand_fc0_pins_a: nand_fc0 {
+                nand_main_gr {
+                        pins = "GPIO11_0", "GPIO11_1", "GPIO11_2",
+                               "GPIO11_3", "GPIO11_4", "GPIO11_6",
+                               "GPIO12_0", "GPIO12_1", "GPIO12_2",
+                               "GPIO12_3", "GPIO12_4", "GPIO12_5",
+                               "GPIO12_6", "GPIO12_7";
+                        function = "nand0";
+                        bias-disable;
+                };
+        };
+};
+
+nand_controller0 {
+        status = "okay";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nand-ecc-strength = <4>;
+        nand-ecc-step-size = <512>;
+        nand-max-chips = <1>;
+        nand-on-flash-bbt;
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&nand_fc0_pins_a>;
+};
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw

Re: [PATCH v3 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Oleksij Rempel

A license nit follows.

drivers/pinctrl/pinctrl-asm9260.c line 9

Quoted 12 lines · Oleksij Rempel
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
@@ -0,0 +1,733 @@
+/*
+ * Pinctrl driver for the Alphascale ASM9260 SoC
+ *
+ * Copyright (c) 2014, Oleksij Rempel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */

This states the license of this file is GPL v2.

drivers/pinctrl/pinctrl-asm9260.c line 733

Quoted 1 line
drivers/pinctrl/pinctrl-asm9260.c new file +1 -0
+MODULE_LICENSE("GPL");

Your reading of include/linux/module.h (see
https://lkml.org/lkml/2015/4/5/7 ) is incorrect. Because according to that header "GPL" means
GNU Public License v2 or later

while "GPL v2" means
GNU Public License v2

So only "GPL v2" matches what's found in the comment at top of this file.

Thanks,

Paul Bolle

#17 lore raw

Re: [PATCH v3 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

A suggestion to your correction.

If you won't to say: "You have a mismatch between header and MODULE_LICENSE, please make sure it will match."
You saying some thing like this: "I was right last time. Make module License like I saying."

I'm confuse, what is your actual point? Do you trying to prove some thing?

Am 06.04.2015 um 09:42 schrieb Paul Bolle:

Quoted 36 lines

A license nit follows.

drivers/pinctrl/pinctrl-asm9260.c line 9

Quoted 12 lines · Oleksij Rempel
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
@@ -0,0 +1,733 @@
+/*
+ * Pinctrl driver for the Alphascale ASM9260 SoC
+ *
+ * Copyright (c) 2014, Oleksij Rempel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */

This states the license of this file is GPL v2.

drivers/pinctrl/pinctrl-asm9260.c line 733

Quoted 1 line
drivers/pinctrl/pinctrl-asm9260.c new file +1 -0
+MODULE_LICENSE("GPL");

Your reading of include/linux/module.h (see
https://lkml.org/lkml/2015/4/5/7 ) is incorrect. Because according to that header "GPL" means
GNU Public License v2 or later

while "GPL v2" means
GNU Public License v2

So only "GPL v2" matches what's found in the comment at top of this file.

Thanks,

Paul Bolle

Signature · 2 lines
Regards,
Oleksij
#20 lore raw

v4 cover Add driver and documentation for Alphascale asm9260 pinctrl

In reply to Paul Bolle

changes:
- v4. As Paul Bolle sugested, fixing License in the header.

Oleksij Rempel (2):
pinctrl: Add driver for Alphascale asm9260 pinctrl
pinctrl: asm9260: add pinctrl add device tree bindings documentation

 .../pinctrl/alphascale,asm9260-pinctrl.txt         |  76 +++
 drivers/pinctrl/Kconfig                            |   8 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-asm9260.c                  | 733 +++++++++++++++++++++
 4 files changed, 818 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
Signature · 1 line
1.9.1
#21 lore raw

PATCH v4 1/2 pinctrl: Add driver for Alphascale asm9260 pinctrl

This patch adds driver for Alphascale asm9260 pinctrl support. Alphascale asm9260t is SoC based on ARM926EJ (240MHz) in LQFP176 package. On silicon are:
- 32MB SDRAM
- USB2.0 HS/OTG
- 2x CAN
- SD/MMC
- 5x Times/PWM
- 10x USART
- 24-channel DMA
- 2x i2c
- 2x SPI
- Quad SPI
- 10/100 Ethernet MAC
- Camera IF
- WD
- RTC
- i2s
- GPIO
- 12-bit A/D
- LCD IF
- 8-channel 12-bit ADC
- NAND

---
 drivers/pinctrl/Kconfig           |   8 +
 drivers/pinctrl/Makefile          |   1 +
 drivers/pinctrl/pinctrl-asm9260.c | 733 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 742 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
drivers/pinctrl/Kconfig +8 -0
index d014f22..054ecbc 100644
@@ -47,6 +47,14 @@ config PINCTRL_AS3722
 	  open drain configuration for the GPIO pins of AS3722 devices. It also
 	  supports the GPIO functionality through gpiolib.
 
+config PINCTRL_ASM9260
+	tristate "Pinctrl driver for Alphascale asm9260"
+	depends on MACH_ASM9260
+	select PINMUX
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Alphascale asm9260 pinctrl driver
+
 config PINCTRL_BF54x
 	def_bool y if BF54x
 	select PINCTRL_ADI2
drivers/pinctrl/Makefile +1 -0
index c030b3d..46ba7d1c 100644
@@ -11,6 +11,7 @@ endif
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_PINCTRL_ADI2)	+= pinctrl-adi2.o
 obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
+obj-$(CONFIG_PINCTRL_ASM9260)	+= pinctrl-asm9260.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
drivers/pinctrl/pinctrl-asm9260.c new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
1.9.1
#28 lore raw

PATCH v4 2/2 pinctrl: asm9260: add pinctrl add device tree bindings documentation

In reply to Oleksij Rempel

Add device tree bindings documentation for Alphascale asm9260 pin controller

---
 .../pinctrl/alphascale,asm9260-pinctrl.txt         | 76 ++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +76 -0
new file mode 100644
index 0000000..dbeea4d
@@ -0,0 +1,76 @@
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure pin multiplexing
+to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+	* 1 "ahb" : AHB gating clock.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+SUBNODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins			- the list of pins that properties in the node
+			  apply to (either this or "groups" has to be
+			  specified)
+function		- the mux function to select
+bias-disable		- disable any pin bias
+bias-pull-up		- pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down		- pull down the pin. Supported on all pins except of GPIO0_*.
+
+Examples:
+
+pinctrl: pinctrl@80044000 {
+	compatible = "alphascale,asm9260-pinctrl";
+	reg = <0x80044000 0x400>;
+	clocks = <&acc CLKID_AHB_IOCONFIG>;
+	clock-names = "ahb";
+
+        nand_fc0_pins_a: nand_fc0 {
+                nand_main_gr {
+                        pins = "GPIO11_0", "GPIO11_1", "GPIO11_2",
+                               "GPIO11_3", "GPIO11_4", "GPIO11_6",
+                               "GPIO12_0", "GPIO12_1", "GPIO12_2",
+                               "GPIO12_3", "GPIO12_4", "GPIO12_5",
+                               "GPIO12_6", "GPIO12_7";
+                        function = "nand0";
+                        bias-disable;
+                };
+        };
+};
+
+nand_controller0 {
+        status = "okay";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        nand-ecc-strength = <4>;
+        nand-ecc-step-size = <512>;
+        nand-max-chips = <1>;
+        nand-on-flash-bbt;
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&nand_fc0_pins_a>;
+};
Signature · 1 line
1.9.1
#18 lore raw

Re: [PATCH v3 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Oleksij Rempel
Quoted 4 lines · Oleksij Rempel

If you won't to say: "You have a mismatch between header and MODULE_LICENSE, please make sure it will match."
You saying some thing like this: "I was right last time. Make module License like I saying."

No, that's not what I wrote.

Quoted 1 line

I'm confuse, what is your actual point? Do you trying to prove some thing?

My point is that there's a mismatch between the license described in the comment at the top of this file and the ident used in the MODULE_LICENSE() macro. In my comments on v2 I wrote:
By the way, you probably want to use "GPL v2" as the license ident [...].

In this v3 I noticed the same mismatch (which was not surprising because you already stated that "GPL" actually did match what's stated at the comment in the top of this file). Therefor I wrote:
So only "GPL v2" matches what's found in the comment at top of this file.

There now seem to be a few options:
- change either the comment at the top of this file or the license ident used in MODULE_LICENSE() to make them actually match;
- show that I misread the comment at top of this file;
- or show that my reading of module.h is incorrect.

(Another option would be a patch that somehow merges the "GPL" and "GPL v2" license idents. That patch would put an end to discussions like the one we're having here. I'm _not_ volunteering to submit it.)

Thanks,

Paul Bolle

#19 lore raw

Re: [PATCH v3 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

Am 06.04.2015 um 11:41 schrieb Paul Bolle:

Quoted 22 lines · Oleksij Rempel
Quoted 4 lines

If you won't to say: "You have a mismatch between header and MODULE_LICENSE, please make sure it will match."
You saying some thing like this: "I was right last time. Make module License like I saying."

No, that's not what I wrote.

Quoted 1 line

I'm confuse, what is your actual point? Do you trying to prove some thing?

My point is that there's a mismatch between the license described in the comment at the top of this file and the ident used in the MODULE_LICENSE() macro. In my comments on v2 I wrote:
By the way, you probably want to use "GPL v2" as the license ident [...].

In this v3 I noticed the same mismatch (which was not surprising because you already stated that "GPL" actually did match what's stated at the comment in the top of this file). Therefor I wrote:
So only "GPL v2" matches what's found in the comment at top of this file.

Quoted 5 lines

There now seem to be a few options:
- change either the comment at the top of this file or the license ident used in MODULE_LICENSE() to make them actually match;
- show that I misread the comment at top of this file;
- or show that my reading of module.h is incorrect.

Ok, thank you for your review.

i send new version of patch with fixing header license to "v2 and later".

Quoted 9 lines

(Another option would be a patch that somehow merges the "GPL" and "GPL v2" license idents. That patch would put an end to discussions like the one we're having here. I'm _not_ volunteering to submit it.)

Thanks,

Paul Bolle

Signature · 2 lines
Regards,
Oleksij
#31 lore raw

Re: [PATCH v4 0/2] Add driver and documentation for Alphascale asm9260 pinctrl

In reply to Oleksij Rempel

Hallo all,

any updates here? :D

Am 06.04.2015 um 11:04 schrieb Oleksij Rempel:

Quoted 15 lines

changes:
- v4. As Paul Bolle sugested, fixing License in the header.

Oleksij Rempel (2):
pinctrl: Add driver for Alphascale asm9260 pinctrl
pinctrl: asm9260: add pinctrl add device tree bindings documentation

 .../pinctrl/alphascale,asm9260-pinctrl.txt         |  76 +++
 drivers/pinctrl/Kconfig                            |   8 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-asm9260.c                  | 733 +++++++++++++++++++++
 4 files changed, 818 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-asm9260.c
Signature · 2 lines
Regards,
Oleksij
#32 lore raw

Re: [PATCH v4 0/2] Add driver and documentation for Alphascale asm9260 pinctrl

Quoted 3 lines · Oleksij Rempel

Hallo all,

any updates here? :D

Sorry for the delay. Merge window you know.

Looking at it now.

Yours,
Linus Walleij

#29 lore raw

Re: [PATCH v4 2/2] pinctrl: asm9260: add pinctrl add device tree bindings documentation

In reply to Oleksij Rempel
Quoted 3 lines · Oleksij Rempel

Add device tree bindings documentation for Alphascale asm9260 pin controller

(...)

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 11

Quoted 11 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +11 -0
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure pin multiplexing
+to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+       * 1 "ahb" : AHB gating clock.

This clock is usually called pclock, "apb_pclk" (amba peripheral bus p clock, don't know what P is...) what name does this have on your data sheet?

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 42

Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +9 -0
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins                   - the list of pins that properties in the node
+                         apply to (either this or "groups" has to be
+                         specified)
+function               - the mux function to select
+bias-disable           - disable any pin bias
+bias-pull-up           - pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down         - pull down the pin. Supported on all pins except of GPIO0_*.

Generic bindings, nice. Put a reference to the file pinctrl-bindings.txt to point this out.

Yours,
Linus Walleij

#22 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Oleksij Rempel
Quoted 24 lines · Oleksij Rempel

This patch adds driver for Alphascale asm9260 pinctrl support. Alphascale asm9260t is SoC based on ARM926EJ (240MHz) in LQFP176 package. On silicon are:
- 32MB SDRAM
- USB2.0 HS/OTG
- 2x CAN
- SD/MMC
- 5x Times/PWM
- 10x USART
- 24-channel DMA
- 2x i2c
- 2x SPI
- Quad SPI
- 10/100 Ethernet MAC
- Camera IF
- WD
- RTC
- i2s
- GPIO
- 12-bit A/D
- LCD IF
- 8-channel 12-bit ADC
- NAND

Quoted 1 line

Nice.

Quoted 11 lines
drivers/pinctrl/pinctrl-asm9260.c new file +11 -0
+#define MUX_TABLE_SIZE         ARRAY_SIZE(asm9260_mux_table)
+struct asm9260_pmx_priv {
+       struct device           *dev;
+       struct pinctrl_dev      *pctl;
+       void __iomem            *iobase;
+
+       struct clk              *clk;
+       spinlock_t              lock;
+
+       struct pinctrl_pin_desc pin_desc[MUX_TABLE_SIZE];
+};

drivers/pinctrl/pinctrl-asm9260.c line 398

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +10 -0
+
+static void __init asm9260_init_mux_pins(struct asm9260_pmx_priv *priv)
+{
+       unsigned int i;
+
+       for (i = 0; i < MUX_TABLE_SIZE; i++) {
+               priv->pin_desc[i].name = asm9260_mux_table[i].name;
+               priv->pin_desc[i].number = asm9260_mux_table[i].number;
+       }
+}

What is the point of copying this data from one array to the other?

Just reference the statically defined array by a pointer instead, this just takes up a lot o memory for no reason.

drivers/pinctrl/pinctrl-asm9260.c line 408

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+/* each GPIO pin has it's own pseudo pingroup containing only itself */
+static int asm9260_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
+{
+       return MUX_TABLE_SIZE;
+}

Use return ARRAY_SIZE(foo) to return the size of a static table.

drivers/pinctrl/pinctrl-asm9260.c line 426

Quoted 9 lines
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
+static int asm9260_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
+                                        unsigned int group,
+                                        const unsigned int **pins,
+                                        unsigned int *num_pins)
+{
+       struct asm9260_pmx_priv *priv = pinctrl_dev_get_drvdata(pctldev);
+
+       *pins = &priv->pin_desc[group].number;
+       *num_pins = 1;

So I see you are using groups with one pin each. Is this how the hardware works?

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+static int asm9260_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
+                                         unsigned int function,
+                                         const char * const **groups,
+                                         unsigned int * const num_groups)
+{

(...)

drivers/pinctrl/pinctrl-asm9260.c line 483

Quoted 12 lines
drivers/pinctrl/pinctrl-asm9260.c new file +12 -0
+       for (a = 0; a < MUX_TABLE_SIZE; a++) {
+               table = &asm9260_mux_table[a];
+
+               for (b = 0; b < MAX_FUNCS_PER_PIN; b++) {
+                       if (table->funcs[b] == function) {
+                               tmp[count] = a;
+                               count++;
+                       }
+
+               }
+
+       }

Mory copying. I don't see why this is necessary at all.

drivers/pinctrl/pinctrl-asm9260.c line 494

Quoted 2 lines
drivers/pinctrl/pinctrl-asm9260.c new file +2 -0
+       for (a = 0; a < count; a++)
+               gr[a] = asm9260_mux_table[tmp[a]].name;

And more copying.

Try to just reference static tables.

drivers/pinctrl/pinctrl-asm9260.c line 500

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+
+       asm9260_functions[function].groups = gr;
+       asm9260_functions[function].ngroups = count;
+done:
+       *groups = asm9260_functions[function].groups;
+       *num_groups = asm9260_functions[function].ngroups;

Same comment.

drivers/pinctrl/pinctrl-asm9260.c line 538

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+static struct pinmux_ops asm9260_pinmux_ops = {
+       .get_functions_count    = asm9260_pinctrl_get_funcs_count,
+       .get_function_name      = asm9260_pinctrl_get_func_name,
+       .get_function_groups    = asm9260_pinctrl_get_func_groups,
+       .set_mux                = asm9260_pinctrl_set_mux,
+       /* TODO: should we care about gpios here? gpio_request_enable? */

I think you should, if you also have a matching GPIO driver.

Quoted 4 lines
drivers/pinctrl/pinctrl-asm9260.c new file +4 -0
+static int asm9260_pinconf_reg(struct pinctrl_dev *pctldev,
+                             unsigned int pin,
+                             enum pin_config_param param,
+                             void __iomem **reg, u32 *val)

drivers/pinctrl/pinctrl-asm9260.c line 554

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +10 -0
+{
+       struct asm9260_pmx_priv *priv = pinctrl_dev_get_drvdata(pctldev);
+       struct asm9260_pingroup *table;
+       int a;
+
+       for (a = 0; a < MUX_TABLE_SIZE; a++) {
+               table = &asm9260_mux_table[a];
+               if (table->number == pin)
+                       break;
+       }

No error check here. What if pin is not in table? We will never know for that case...

Apart from that it looks OK.

BTW this is a review of v3, I didn't find your v4 of this patch :/

Yours,
Linus Walleij

#30 lore raw

Re: [PATCH v4 2/2] pinctrl: asm9260: add pinctrl add device tree bindings documentation

In reply to Linus Walleij

Am 05.05.2015 um 16:46 schrieb Linus Walleij:

Quoted 7 lines · Oleksij Rempel
Quoted 4 lines

Add device tree bindings documentation for Alphascale asm9260 pin controller

(...)

Quoted 15 lines

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 11

Quoted 11 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +11 -0
+* Alphascale ASM9260 SoC pinctrl core driver
+
+The pinctrl driver enables Alphascale ASM9260 to configure pin multiplexing
+to a specific function.
+
+Required properties for pinctrl driver:
+- compatible: "alphascale,asm9260-pinctrl"
+- reg: Register base of the MPP block and length.
+- clocks: clock ids.
+- clock-names:
+       * 1 "ahb" : AHB gating clock.

This clock is usually called pclock, "apb_pclk" (amba peripheral bus p clock, don't know what P is...) what name does this have on your data sheet?

the datasheet uses only "AHB" or "ahb_clk".
Since i use in other modules same name i would prefer to use one style :)

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +4 -0
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+pins                   - the list of pins that properties in the node
+                         apply to (either this or "groups" has to be
Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt line 42

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/alphascale,asm9260-pinctrl.txt new file +5 -0
+                         specified)
+function               - the mux function to select
+bias-disable           - disable any pin bias
+bias-pull-up           - pull up the pin. Supported only on GPIO0_* pins.
+bias-pull-down         - pull down the pin. Supported on all pins except of GPIO0_*.

Generic bindings, nice. Put a reference to the file pinctrl-bindings.txt to point this out.

Yea, it was already done, see ^^ - "The following generic properties as defined in pinctrl-bindings.txt" :)

Signature · 2 lines
Regards,
Oleksij
#23 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Linus Walleij

Am 05.05.2015 um 17:12 schrieb Linus Walleij:

Quoted 54 lines · Oleksij Rempel
Quoted 25 lines

This patch adds driver for Alphascale asm9260 pinctrl support. Alphascale asm9260t is SoC based on ARM926EJ (240MHz) in LQFP176 package. On silicon are:
- 32MB SDRAM
- USB2.0 HS/OTG
- 2x CAN
- SD/MMC
- 5x Times/PWM
- 10x USART
- 24-channel DMA
- 2x i2c
- 2x SPI
- Quad SPI
- 10/100 Ethernet MAC
- Camera IF
- WD
- RTC
- i2s
- GPIO
- 12-bit A/D
- LCD IF
- 8-channel 12-bit ADC
- NAND

Quoted 1 line

Nice.

Quoted 11 lines
drivers/pinctrl/pinctrl-asm9260.c new file +11 -0
+#define MUX_TABLE_SIZE         ARRAY_SIZE(asm9260_mux_table)
+struct asm9260_pmx_priv {
+       struct device           *dev;
+       struct pinctrl_dev      *pctl;
+       void __iomem            *iobase;
+
+       struct clk              *clk;
+       spinlock_t              lock;
+
+       struct pinctrl_pin_desc pin_desc[MUX_TABLE_SIZE];
+};

drivers/pinctrl/pinctrl-asm9260.c line 398

Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +10 -0
+
+static void __init asm9260_init_mux_pins(struct asm9260_pmx_priv *priv)
+{
+       unsigned int i;
+
+       for (i = 0; i < MUX_TABLE_SIZE; i++) {
+               priv->pin_desc[i].name = asm9260_mux_table[i].name;
+               priv->pin_desc[i].number = asm9260_mux_table[i].number;
+       }
+}

What is the point of copying this data from one array to the other?

Quoted 2 lines

Just reference the statically defined array by a pointer instead, this just takes up a lot o memory for no reason.

This two arrays have different types this is why i convert it. priv->pin_desc[i].name - here i copy pointer any ways, and priv->pin_desc[i].number can be smaller then pointer.

Quoted 7 lines

drivers/pinctrl/pinctrl-asm9260.c line 408

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+/* each GPIO pin has it's own pseudo pingroup containing only itself */
+static int asm9260_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
+{
+       return MUX_TABLE_SIZE;
+}

Use return ARRAY_SIZE(foo) to return the size of a static table.

see #define MUX_TABLE_SIZE ARRAY_SIZE(asm9260_mux_table

Quoted 4 lines
Quoted 4 lines
drivers/pinctrl/pinctrl-asm9260.c new file +4 -0
+static int asm9260_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
+                                        unsigned int group,
+                                        const unsigned int **pins,
+                                        unsigned int *num_pins)
Quoted 8 lines

drivers/pinctrl/pinctrl-asm9260.c line 426

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+{
+       struct asm9260_pmx_priv *priv = pinctrl_dev_get_drvdata(pctldev);
+
+       *pins = &priv->pin_desc[group].number;
+       *num_pins = 1;

So I see you are using groups with one pin each. Is this how the hardware works?

Yes, each pin can be configured separately.

Quoted 7 lines
Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+static int asm9260_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
+                                         unsigned int function,
+                                         const char * const **groups,
+                                         unsigned int * const num_groups)
+{

(...)

Quoted 14 lines

drivers/pinctrl/pinctrl-asm9260.c line 483

Quoted 12 lines
drivers/pinctrl/pinctrl-asm9260.c new file +12 -0
+       for (a = 0; a < MUX_TABLE_SIZE; a++) {
+               table = &asm9260_mux_table[a];
+
+               for (b = 0; b < MAX_FUNCS_PER_PIN; b++) {
+                       if (table->funcs[b] == function) {
+                               tmp[count] = a;
+                               count++;
+                       }
+
+               }
+
+       }

Mory copying. I don't see why this is necessary at all.

I hadn't seen the point to define groups statically, especially because they are used only to make curious user happy. So, memory will be used only if you request the list over sysfs. Or miss some thing?

Quoted 16 lines

drivers/pinctrl/pinctrl-asm9260.c line 494

Quoted 2 lines
drivers/pinctrl/pinctrl-asm9260.c new file +2 -0
+       for (a = 0; a < count; a++)
+               gr[a] = asm9260_mux_table[tmp[a]].name;

And more copying.

Try to just reference static tables.

drivers/pinctrl/pinctrl-asm9260.c line 500

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+
+       asm9260_functions[function].groups = gr;
+       asm9260_functions[function].ngroups = count;
+done:
+       *groups = asm9260_functions[function].groups;
+       *num_groups = asm9260_functions[function].ngroups;

Same comment.

Quoted 8 lines

drivers/pinctrl/pinctrl-asm9260.c line 538

Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+static struct pinmux_ops asm9260_pinmux_ops = {
+       .get_functions_count    = asm9260_pinctrl_get_funcs_count,
+       .get_function_name      = asm9260_pinctrl_get_func_name,
+       .get_function_groups    = asm9260_pinctrl_get_func_groups,
+       .set_mux                = asm9260_pinctrl_set_mux,
+       /* TODO: should we care about gpios here? gpio_request_enable? */

I think you should, if you also have a matching GPIO driver.

I fear it would cause unpredictable bugs. GPIO mode is just one of mux modes. If some one will request gpio some busy or dangerous line it would do more harm then use. So, i assume limiting this only to device tree would be better.

Quoted 10 lines
Quoted 10 lines
drivers/pinctrl/pinctrl-asm9260.c new file +9 -0
+static int asm9260_pinconf_reg(struct pinctrl_dev *pctldev,
+                             unsigned int pin,
+                             enum pin_config_param param,
+                             void __iomem **reg, u32 *val)
+{
+       struct asm9260_pmx_priv *priv = pinctrl_dev_get_drvdata(pctldev);
+       struct asm9260_pingroup *table;
+       int a;
+
Quoted 8 lines

drivers/pinctrl/pinctrl-asm9260.c line 554

Quoted 5 lines
drivers/pinctrl/pinctrl-asm9260.c new file +5 -0
+       for (a = 0; a < MUX_TABLE_SIZE; a++) {
+               table = &asm9260_mux_table[a];
+               if (table->number == pin)
+                       break;
+       }

No error check here. What if pin is not in table? We will never know for that case...

Ok, i agree.

Quoted 3 lines

Apart from that it looks OK.

BTW this is a review of v3, I didn't find your v4 of this patch :/

I'll wait for answers first, then provide next version. Thank you for review :)

Signature · 2 lines
Regards,
Oleksij
#24 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

Quoted 8 lines · Oleksij Rempel

Am 05.05.2015 um 17:12 schrieb Linus Walleij:

Quoted 2 lines

Just reference the statically defined array by a pointer instead, this just takes up a lot o memory for no reason.

This two arrays have different types this is why i convert it. priv->pin_desc[i].name - here i copy pointer any ways, and priv->pin_desc[i].number can be smaller then pointer.

I probably do not understand what you're trying to do, sorry :(

Why is it necessary for the driver to copy one description of the pin into another?

Quoted 5 lines
Quoted 1 line

Mory copying. I don't see why this is necessary at all.

I hadn't seen the point to define groups statically, especially because they are used only to make curious user happy. So, memory will be used only if you request the list over sysfs. Or miss some thing?

pinctrl does not even use sysfs.

The group names are usually there for matching with a function, it is part of the core functionality. The group name + function name matching is even more obvious in the dt case.

They also make things easier to read in debugfs yes, but the core of the crux is to make it easy to config function+groups states with e.g. DT or board files.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+static struct pinmux_ops asm9260_pinmux_ops = {
+       .get_functions_count    = asm9260_pinctrl_get_funcs_count,
+       .get_function_name      = asm9260_pinctrl_get_func_name,
+       .get_function_groups    = asm9260_pinctrl_get_func_groups,
+       .set_mux                = asm9260_pinctrl_set_mux,
+       /* TODO: should we care about gpios here? gpio_request_enable? */
Quoted 6 lines
Quoted 1 line

I think you should, if you also have a matching GPIO driver.

I fear it would cause unpredictable bugs. GPIO mode is just one of mux modes. If some one will request gpio some busy or dangerous line it would do more harm then use. So, i assume limiting this only to device tree would be better.

Device tree or not doesn't matter, .gpio_request_enable() is used as a shortcut to mux in GPIO pins.

If the simultaneous use of a pin for a device and GPIO bothers you there is nowadays (linux-next or my devel branch) a .strict option in pinmux_ops that you can set to disallow simultaneous use by devices and GPIO of the same pin.

Yours,
Linus Walleij

#25 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

Am 13.05.2015 um 13:00 schrieb Linus Walleij:

Quoted 48 lines · Oleksij Rempel
Quoted 8 lines

Am 05.05.2015 um 17:12 schrieb Linus Walleij:

Quoted 2 lines

Just reference the statically defined array by a pointer instead, this just takes up a lot o memory for no reason.

This two arrays have different types this is why i convert it. priv->pin_desc[i].name - here i copy pointer any ways, and priv->pin_desc[i].number can be smaller then pointer.

I probably do not understand what you're trying to do, sorry :(

Why is it necessary for the driver to copy one description of the pin into another?

Quoted 5 lines
Quoted 1 line

Mory copying. I don't see why this is necessary at all.

I hadn't seen the point to define groups statically, especially because they are used only to make curious user happy. So, memory will be used only if you request the list over sysfs. Or miss some thing?

pinctrl does not even use sysfs.

The group names are usually there for matching with a function, it is part of the core functionality. The group name + function name matching is even more obvious in the dt case.

They also make things easier to read in debugfs yes, but the core of the crux is to make it easy to config function+groups states with e.g. DT or board files.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+static struct pinmux_ops asm9260_pinmux_ops = {
+       .get_functions_count    = asm9260_pinctrl_get_funcs_count,
+       .get_function_name      = asm9260_pinctrl_get_func_name,
+       .get_function_groups    = asm9260_pinctrl_get_func_groups,
+       .set_mux                = asm9260_pinctrl_set_mux,
+       /* TODO: should we care about gpios here? gpio_request_enable? */
Quoted 6 lines
Quoted 1 line

I think you should, if you also have a matching GPIO driver.

I fear it would cause unpredictable bugs. GPIO mode is just one of mux modes. If some one will request gpio some busy or dangerous line it would do more harm then use. So, i assume limiting this only to device tree would be better.

Device tree or not doesn't matter, .gpio_request_enable() is used as a shortcut to mux in GPIO pins.

Quoted 8 lines

If the simultaneous use of a pin for a device and GPIO bothers you there is nowadays (linux-next or my devel branch) a .strict option in pinmux_ops that you can set to disallow simultaneous use by devices and GPIO of the same pin.

Yours,
Linus Walleij

Hi, you was right, i was blind. Will redo some parts with your suggestions.

Signature · 2 lines
Regards,
Oleksij
#26 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

In reply to Linus Walleij

Hi, finally i'm able to continue to work on it.

Am 13.05.2015 um 13:00 schrieb Linus Walleij:

Quoted 6 lines · Oleksij Rempel
Quoted 5 lines

Am 05.05.2015 um 17:12 schrieb Linus Walleij:

Quoted 2 lines

Just reference the statically defined array by a pointer instead, this just takes up a lot o memory for no reason.

Quoted 8 lines
Quoted 3 lines

This two arrays have different types this is why i convert it. priv->pin_desc[i].name - here i copy pointer any ways, and priv->pin_desc[i].number can be smaller then pointer.

I probably do not understand what you're trying to do, sorry :(

Why is it necessary for the driver to copy one description of the pin into another?

If i understand it correctly, pinctrl_pin_desc is essential part of pinmux framework. Theoretically i should define just statical array of this struct, but by this number of pins and functions it hard to keep it readable and error free. So i decided to create asm9260_mux_table which contains every thing i need. The side effect is higher memory usage since i need to create pinctrl_pin_desc on fly.

May be i miss some thing?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Mory copying. I don't see why this is necessary at all.

I hadn't seen the point to define groups statically, especially because they are used only to make curious user happy. So, memory will be used only if you request the list over sysfs. Or miss some thing?

pinctrl does not even use sysfs.

please read debugfs.

Quoted 33 lines

The group names are usually there for matching with a function, it is part of the core functionality. The group name + function name matching is even more obvious in the dt case.

They also make things easier to read in debugfs yes, but the core of the crux is to make it easy to config function+groups states with e.g. DT or board files.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/pinctrl/pinctrl-asm9260.c new file +6 -0
+static struct pinmux_ops asm9260_pinmux_ops = {
+       .get_functions_count    = asm9260_pinctrl_get_funcs_count,
+       .get_function_name      = asm9260_pinctrl_get_func_name,
+       .get_function_groups    = asm9260_pinctrl_get_func_groups,
+       .set_mux                = asm9260_pinctrl_set_mux,
+       /* TODO: should we care about gpios here? gpio_request_enable? */
Quoted 6 lines
Quoted 1 line

I think you should, if you also have a matching GPIO driver.

I fear it would cause unpredictable bugs. GPIO mode is just one of mux modes. If some one will request gpio some busy or dangerous line it would do more harm then use. So, i assume limiting this only to device tree would be better.

Device tree or not doesn't matter, .gpio_request_enable() is used as a shortcut to mux in GPIO pins.

If the simultaneous use of a pin for a device and GPIO bothers you there is nowadays (linux-next or my devel branch) a .strict option in pinmux_ops that you can set to disallow simultaneous use by devices and GPIO of the same pin.

Yours,
Linus Walleij

Signature · 2 lines
Regards,
Oleksij
#27 lore raw

Re: [PATCH v4 1/2] pinctrl: Add driver for Alphascale asm9260 pinctrl

Quoted 4 lines · Oleksij Rempel

[Me]

Quoted 2 lines

Why is it necessary for the driver to copy one description of the pin into another?

Quoted 8 lines

If i understand it correctly, pinctrl_pin_desc is essential part of pinmux framework. Theoretically i should define just statical array of this struct, but by this number of pins and functions it hard to keep it readable and error free. So i decided to create asm9260_mux_table which contains every thing i need. The side effect is higher memory usage since i need to create pinctrl_pin_desc on fly.

May be i miss some thing?

I don't see how having code copying data from one data container to another makes things "more readable and error free". Go for *one* static definition. Also the memory waste is a total no-no.

Yours,
Linus Walleij