Skip to contentSkip to conversation

Add pinctrl support to Broadcom Cygnus SoC

PATCH Superseded Ray Jui 3 participants 27 messages Mar 5, 2015 – Mar 9, 2015

Subsystems (6)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Ray Jui

author maintainer
#0 lore raw

v5 cover Add pinctrl support to Broadcom Cygnus SoC

This patchset contains the pinmux (IOMUX) and GPIO/PINCONF support for Broadcom Cygnus SoC.

The Cygnus IOMUX controller supports group based mux configuration and allows certain pins to be muxed to GPIO function individually. The IOMUX controller is supported by the pinctrl-cygnus-mux.c driver.

Cygnus has 3 GPIO controllers: 1) the ASIU GPIO; 2) the chipCommonG GPIO; and 3) the ALWAYS-ON GPIO. All 3 Cygnus GPIO controllers support basic PINCONF functions such as bias pull up, pull down, and drive strength configuration, when pins are muxed to GPIO. GPIO/PINCONF support is in the pinctrl-cygnus-gpio.c driver.

Note pins from the ASIU GPIO can be individually muxed to GPIO function, through interaction with the Cygnus IOMUX controller.

Changes from v4:
- Rebased to Linux 4.0-rc2
- Switched to use the newly available pinconf_generic_dt_node_to_map_group function for mapping DT mux properties in the IOMUX driver. This helps to get rid of customized device tree parsing code in the driver
- Consolidated the other Cygnus GPIO/PINCONF patchset into one single patchset
- Tuned up the GPIO/PINCONF driver a bit more, based on code review comments from Linus Walleij

Changes from v3:
- Fix the driver to have more proper use of "const" in various places
- Other minor improvements

Changes from v2:
- Consolidate all Broadcom pinctrl drivers into drivers/pinctrl/bcm/*
- Change the Cygnus IOMUX driver to use standard Linux pinctrl subnode
properties such as "function" and "groups" for pinmux configuration, instead of non-standard properties such as "brcm,function" and "brcm,group"
- Use real function names like "spi0", "lcd", "key", and etc. instead of HW
specific mux names like "alt1", "alt2", "alt3", and etc.
- Add suffix "grp" to all group names
- Add support to allow individual pins to be muxed to GPIO function through
subsystem callbacks "gpio_request_enable" and "gpio_disable_free", and get rid of all GPIO groups
- Other minor improvements in the driver

Changes from v1:
- Fix a typo in device tree binding document

Ray Jui (8):
pinctrl: bcm: consolidate Broadcom pinctrl drivers
pinctrl: Broadcom Cygnus pinctrl device tree binding
pinctrl: cygnus: add initial IOMUX driver support
ARM: dts: enable IOMUX for Broadcom Cygnus
pinctrl: Cygnus: define Broadcom Cygnus GPIO/PINCONF binding
pinctrl: cygnus: add gpio/pinconf driver
ARM: dts: enable GPIO for Broadcom Cygnus
ARM: dts: cygnus: enable GPIO based hook detection

 .../bindings/pinctrl/brcm,cygnus-gpio.txt          |  102 ++
 .../bindings/pinctrl/brcm,cygnus-pinmux.txt        |  132 +++
 arch/arm/boot/dts/bcm-cygnus.dtsi                  |   39 +
 arch/arm/boot/dts/bcm911360_entphn.dts             |   13 +
 drivers/pinctrl/Kconfig                            |   19 +-
 drivers/pinctrl/Makefile                           |    3 +-
 drivers/pinctrl/bcm/Kconfig                        |   56 ++
 drivers/pinctrl/bcm/Makefile                       |    6 +
 drivers/pinctrl/{ => bcm}/pinctrl-bcm281xx.c       |    4 +-
 drivers/pinctrl/{ => bcm}/pinctrl-bcm2835.c        |    0
 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c          |  884 +++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-cygnus-mux.c           | 1022 ++++++++++++++++++++
 12 files changed, 2258 insertions(+), 22 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,cygnus-gpio.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,cygnus-pinmux.txt
 create mode 100644 drivers/pinctrl/bcm/Kconfig
 create mode 100644 drivers/pinctrl/bcm/Makefile
 rename drivers/pinctrl/{ => bcm}/pinctrl-bcm281xx.c (99%)
 rename drivers/pinctrl/{ => bcm}/pinctrl-bcm2835.c (100%)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-cygnus-mux.c
Signature · 1 line
1.7.9.5
author maintainer
#1 lore raw

PATCH v5 1/8 pinctrl: bcm: consolidate Broadcom pinctrl drivers

Consolidate Broadcom pinctrl drivers into drivers/pinctrl/bcm/*

---
 drivers/pinctrl/Kconfig                      |   19 +------------------
 drivers/pinctrl/Makefile                     |    3 +--
 drivers/pinctrl/bcm/Kconfig                  |   21 +++++++++++++++++++++
 drivers/pinctrl/bcm/Makefile                 |    4 ++++
 drivers/pinctrl/{ => bcm}/pinctrl-bcm281xx.c |    4 ++--
 drivers/pinctrl/{ => bcm}/pinctrl-bcm2835.c  |    0
 6 files changed, 29 insertions(+), 22 deletions(-)
 create mode 100644 drivers/pinctrl/bcm/Kconfig
 create mode 100644 drivers/pinctrl/bcm/Makefile
 rename drivers/pinctrl/{ => bcm}/pinctrl-bcm281xx.c (99%)
 rename drivers/pinctrl/{ => bcm}/pinctrl-bcm2835.c (100%)
drivers/pinctrl/Kconfig +1 -18
index ee9f44a..1a9143d 100644
@@ -67,24 +67,6 @@ config PINCTRL_AT91
 	help
 	  Say Y here to enable the at91 pinctrl driver
 
-config PINCTRL_BCM2835
-	bool
-	select PINMUX
-	select PINCONF
-
-config PINCTRL_BCM281XX
-	bool "Broadcom BCM281xx pinctrl driver"
-	depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
-	select PINMUX
-	select PINCONF
-	select GENERIC_PINCONF
-	select REGMAP_MMIO
-	help
-	  Say Y here to support Broadcom BCM281xx pinctrl driver, which is used
-	  for the BCM281xx SoC family, including BCM11130, BCM11140, BCM11351,
-	  BCM28145, and BCM28155 SoCs.  This driver requires the pinctrl
-	  framework.  GPIO is provided by a separate GPIO driver.
-
 config PINCTRL_LANTIQ
 	bool
 	depends on LANTIQ
@@ -207,6 +189,7 @@ config PINCTRL_ZYNQ
 	help
 	  This selectes the pinctrl driver for Xilinx Zynq.
 
+source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
 source "drivers/pinctrl/freescale/Kconfig"
 source "drivers/pinctrl/intel/Kconfig"
drivers/pinctrl/Makefile +1 -2
index 0475206..c14ce05 100644
@@ -14,8 +14,6 @@ obj-$(CONFIG_PINCTRL_AS3722)	+= pinctrl-as3722.o
 obj-$(CONFIG_PINCTRL_BF54x)	+= pinctrl-adi2-bf54x.o
 obj-$(CONFIG_PINCTRL_BF60x)	+= pinctrl-adi2-bf60x.o
 obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
-obj-$(CONFIG_PINCTRL_BCM2835)	+= pinctrl-bcm2835.o
-obj-$(CONFIG_PINCTRL_BCM281XX)	+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_FALCON)	+= pinctrl-falcon.o
 obj-$(CONFIG_PINCTRL_MESON)	+= meson/
 obj-$(CONFIG_PINCTRL_PALMAS)	+= pinctrl-palmas.o
@@ -38,6 +36,7 @@ obj-$(CONFIG_PINCTRL_TB10X)	+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST) 	+= pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ)	+= pinctrl-zynq.o
 
+obj-$(CONFIG_ARCH_BCM)		+= bcm/
 obj-$(CONFIG_ARCH_BERLIN)	+= berlin/
 obj-y				+= freescale/
 obj-$(CONFIG_X86)		+= intel/
drivers/pinctrl/bcm/Kconfig new file +21 -0
new file mode 100644
index 0000000..bc6d048
@@ -0,0 +1,21 @@
+#
+# Broadcom pinctrl drivers
+#
+
+config PINCTRL_BCM281XX
+	bool "Broadcom BCM281xx pinctrl driver"
+	depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	select REGMAP_MMIO
+	help
+	  Say Y here to support Broadcom BCM281xx pinctrl driver, which is used
+	  for the BCM281xx SoC family, including BCM11130, BCM11140, BCM11351,
+	  BCM28145, and BCM28155 SoCs.  This driver requires the pinctrl
+	  framework.  GPIO is provided by a separate GPIO driver.
+
+config PINCTRL_BCM2835
+	bool
+	select PINMUX
+	select PINCONF
drivers/pinctrl/bcm/Makefile new file +4 -0
new file mode 100644
index 0000000..7ba80a3
@@ -0,0 +1,4 @@
+# Broadcom pinctrl support
+
+obj-$(CONFIG_PINCTRL_BCM281XX)	+= pinctrl-bcm281xx.o
+obj-$(CONFIG_PINCTRL_BCM2835)	+= pinctrl-bcm2835.o
drivers/pinctrl/bcm/pinctrl-bcm281xx.c renamed from drivers/pinctrl/pinctrl-bcm281xx.c +2 -2
similarity index 99%
rename from drivers/pinctrl/pinctrl-bcm281xx.c
rename to drivers/pinctrl/bcm/pinctrl-bcm281xx.c
index b88cfe5..9641f1c 100644
@@ -21,8 +21,8 @@
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
-#include "core.h"
-#include "pinctrl-utils.h"
+#include "../core.h"
+#include "../pinctrl-utils.h"
 
 /* BCM281XX Pin Control Registers Definitions */
 
drivers/pinctrl/bcm/pinctrl-bcm2835.c renamed from drivers/pinctrl/pinctrl-bcm2835.c +0 -0
similarity index 100%
rename from drivers/pinctrl/pinctrl-bcm2835.c
rename to drivers/pinctrl/bcm/pinctrl-bcm2835.c
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v5 1/8] pinctrl: bcm: consolidate Broadcom pinctrl drivers

Quoted 3 lines · Ray Jui

Consolidate Broadcom pinctrl drivers into drivers/pinctrl/bcm/*

Patch applied.

Yours,
Linus Walleij

author maintainer
#3 lore raw

PATCH v5 2/8 pinctrl: Broadcom Cygnus pinctrl device tree binding

In reply to Ray Jui

Device tree binding documentation for Broadcom Cygnus IOMUX driver

---
 .../bindings/pinctrl/brcm,cygnus-pinmux.txt        |  132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,cygnus-pinmux.txt
Documentation/devicetree/bindings/pinctrl/brcm,cygnus-pinmux.txt new file +132 -0
new file mode 100644
index 0000000..3600d5c
@@ -0,0 +1,132 @@
+Broadcom Cygnus IOMUX Controller
+
+The Cygnus IOMUX controller supports group based mux configuration. In
+addition, certain pins can be muxed to GPIO function individually.
+
+Required properties:
+
+- compatible:
+    Must be "brcm,cygnus-pinmux"
+
+- reg:
+    Define the base and range of the I/O address space that contains the Cygnus
+IOMUX registers
+
+Properties in subnodes:
+
+- function:
+    The mux function to select
+
+- groups:
+    The list of groups to select with a given function
+
+For more details, refer to
+Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+
+For example:
+
+	pinmux: pinmux@0x0301d0c8 {
+		compatible = "brcm,cygnus-pinmux";
+		reg = <0x0301d0c8 0x1b0>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&i2s0_default>;
+
+		i2s0_default: i2s0_default {
+			mux {
+				function = "i2s0";
+				groups = "i2s0_0_grp", "i2s0_1_grp";
+			};
+		};
+	};
+
+List of supported functions and groups in Cygnus:
+
+"i2s0": "i2s0_0_grp", "i2s0_1_grp"
+
+"i2s1": "i2s1_0_grp", "i2s1_1_grp"
+
+"i2s2": "i2s2_0_grp", "i2s2_1_grp", "i2s2_2_grp", "i2s2_3_grp", "i2s2_4_grp"
+
+"spdif": "spdif_grp"
+
+"pwm0": "pwm0_grp"
+
+"pwm1": "pwm1_grp"
+
+"pwm2": "pwm2_grp"
+
+"pwm3": "pwm3_grp"
+
+"pwm4": "pwm4_grp"
+
+"pwm5": "pwm5_grp"
+
+"key": "key0_grp", "key1_grp", "key2_grp", "key3_grp", "key4_grp", "key5_grp",
+"key6_grp", "key7_grp", "key8_grp", "key9_grp", "key10_grp", "key11_grp",
+"key12_grp", "key13_grp", "key14_grp", "key15_grp"
+
+"audio_dte": "audio_dte0_grp", "audio_dte1_grp", "audio_dte2_grp", "audio_dte3_grp"
+
+"smart_card0": "smart_card0_grp", "smart_card0_fcb_grp"
+
+"smart_card1": "smart_card1_grp", "smart_card1_fcb_grp"
+
+"spi0": "spi0_grp"
+
+"spi1": "spi1_grp"
+
+"spi2": "spi2_grp"
+
+"spi3": "spi3_grp"
+
+"spi4": "spi4_0_grp", "spi4_1_grp"
+
+"spi5": "spi5_grp"
+
+"sw_led0": "sw_led0_0_grp", "sw_led0_1_grp"
+
+"sw_led1": "sw_led1_grp"
+
+"sw_led2": "sw_led2_0_grp", "sw_led2_1_grp"
+
+"d1w": "d1w_grp"
+
+"lcd": "lcd_grp"
+
+"sram": "sram_0_grp", "sram_1_grp"
+
+"uart0": "uart0_grp"
+
+"uart1": "uart1_grp", "uart1_dte_grp"
+
+"uart2": "uart2_grp"
+
+"uart3": "uart3_grp"
+
+"uart4": "uart4_grp"
+
+"qspi": "qspi_0_grp", "qspi_1_grp"
+
+"nand": "nand_grp"
+
+"sdio0": "sdio0_grp", "sdio0_cd_grp", "sdio0_mmc_grp"
+
+"sdio1": "sdio1_data_0_grp", "sdio1_data_1_grp", "sdio1_cd_grp",
+"sdio1_led_grp", "sdio1_mmc_grp"
+
+"can0": "can0_grp"
+
+"can1": "can1_grp"
+
+"cam": "cam_led_grp", "cam_0_grp", "cam_1_grp"
+
+"bsc1": "bsc1_grp"
+
+"pcie_clkreq": "pcie_clkreq_grp"
+
+"usb0_oc": "usb0_oc_grp"
+
+"usb1_oc": "usb1_oc_grp"
+
+"usb2_oc": "usb2_oc_grp"
Signature · 1 line
1.7.9.5
author maintainer
#5 lore raw

PATCH v5 3/8 pinctrl: cygnus: add initial IOMUX driver support

In reply to Ray Jui

This adds the initial driver support for the Broadcom Cygnus IOMUX controller. The Cygnus IOMUX controller supports group based mux configuration but allows certain pins to be muxed to GPIO individually

---
 drivers/pinctrl/bcm/Kconfig              |   13 +
 drivers/pinctrl/bcm/Makefile             |    5 +-
 drivers/pinctrl/bcm/pinctrl-cygnus-mux.c | 1022 ++++++++++++++++++++++++++++++
 3 files changed, 1038 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-cygnus-mux.c
drivers/pinctrl/bcm/Kconfig +13 -0
index bc6d048..eb13201 100644
@@ -19,3 +19,16 @@ config PINCTRL_BCM2835
 	bool
 	select PINMUX
 	select PINCONF
+
+config PINCTRL_CYGNUS_MUX
+	bool "Broadcom Cygnus IOMUX driver"
+	depends on (ARCH_BCM_CYGNUS || COMPILE_TEST)
+	select PINMUX
+	select GENERIC_PINCONF
+	default ARCH_BCM_CYGNUS
+	help
+	  Say yes here to enable the Broadcom Cygnus IOMUX driver.
+
+	  The Broadcom Cygnus IOMUX driver supports group based IOMUX
+	  configuration, with the exception that certain individual pins
+	  can be overrided to GPIO function
drivers/pinctrl/bcm/Makefile +3 -2
index 7ba80a3..bb6beb6 100644
@@ -1,4 +1,5 @@
 # Broadcom pinctrl support
 
-obj-$(CONFIG_PINCTRL_BCM281XX)	+= pinctrl-bcm281xx.o
-obj-$(CONFIG_PINCTRL_BCM2835)	+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
+obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
drivers/pinctrl/bcm/pinctrl-cygnus-mux.c new file +1022 -0

1,022 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

drivers/pinctrl/bcm/Kconfig config PINCTRL_BCM2835 · line 24

Quoted 11 lines · Ray Jui
drivers/pinctrl/bcm/Kconfig +3 -0
index bc6d048..eb13201 100644
@@ -19,3 +19,16 @@ config PINCTRL_BCM2835
 	bool
 	select PINMUX
 	select PINCONF
+
+config PINCTRL_CYGNUS_MUX
+	bool "Broadcom Cygnus IOMUX driver"

bool type.

Quoted 15 lines
drivers/pinctrl/bcm/Kconfig +10 -0
+	depends on (ARCH_BCM_CYGNUS || COMPILE_TEST)
+	select PINMUX
+	select GENERIC_PINCONF
+	default ARCH_BCM_CYGNUS
+	help
+	  Say yes here to enable the Broadcom Cygnus IOMUX driver.
+
+	  The Broadcom Cygnus IOMUX driver supports group based IOMUX
+	  configuration, with the exception that certain individual pins
+	  can be overrided to GPIO function
drivers/pinctrl/bcm/Makefile +0 -0
index 7ba80a3..bb6beb6 100644

drivers/pinctrl/bcm/Makefile line 5

Quoted 7 lines
drivers/pinctrl/bcm/Makefile +3 -2
@@ -1,4 +1,5 @@
 # Broadcom pinctrl support
 
-obj-$(CONFIG_PINCTRL_BCM281XX)	+= pinctrl-bcm281xx.o
-obj-$(CONFIG_PINCTRL_BCM2835)	+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
+obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o

So pinctrl-cygnus-mux.o will be built-in (or not built, of course).

drivers/pinctrl/bcm/pinctrl-cygnus-mux.c line 1022

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-cygnus-mux.c new file +3 -0
new file mode 100644
index 0000000..f9a9283
@@ -0,0 +1,1022 @@
[...]
+MODULE_AUTHOR("Ray Jui <[email protected]>");
+MODULE_DESCRIPTION("Broadcom Cygnus IOMUX driver");
+MODULE_LICENSE("GPL v2");

These three macros will be preprocessed away. (And I guess you could also drop the linux/module.h include, but I haven't actually tested that guess.)

Paul Bolle

#7 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Quoted 8 lines · Paul Bolle

drivers/pinctrl/bcm/pinctrl-cygnus-mux.c line 1022

Quoted 4 lines

[...]

drivers/pinctrl/bcm/pinctrl-cygnus-mux.c new file +3 -0
+MODULE_AUTHOR("Ray Jui <[email protected]>");
+MODULE_DESCRIPTION("Broadcom Cygnus IOMUX driver");
+MODULE_LICENSE("GPL v2");

These three macros will be preprocessed away. (And I guess you could also drop the linux/module.h include, but I haven't actually tested that guess.)

I think you're right. Or I fear you're right.

But this problem is present in so many drivers that a generic fixup needs to be done with a script and across an entire subsystem at once, and besides I'm not sure of these macros disturb so much.

They are documentation in a sense, albeit a kind of documentation we used before we had git to record the actual authors of the code.

Yours,
Linus Walleij

#8 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Linus Walleij schreef op ma 09-03-2015 om 17:28 [+0100]:

Quoted 5 lines

I think you're right. Or I fear you're right.

But this problem is present in so many drivers that a generic fixup needs to be done with a script and across an entire subsystem at once,

Why don't we start with checking for similar cases during review, like I'm now doing for only a week or two?

Quoted 1 line

and besides I'm not sure of these macros disturb so much.

I think they're confusing at best. Ie, when reading the code and the corresponding Kconfig file one has to wonder: should the Kconfig symbol actually be tristate or should it stay bool but did someone forget to delete the module-specific code?

Quoted 3 lines

They are documentation in a sense, albeit a kind of documentation we used before we had git to record the actual authors of the code.

They're useful, mostly, for module utilities. Outside that scope they add information that thousands of files (that can also only be built-in but do not have these macros) do not have and, apparently, do not need.

Thanks,

Paul Bolle

author maintainer
#9 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Quoted 17 lines · Paul Bolle

Linus Walleij schreef op ma 09-03-2015 om 17:28 [+0100]:

Quoted 5 lines

I think you're right. Or I fear you're right.

But this problem is present in so many drivers that a generic fixup needs to be done with a script and across an entire subsystem at once,

Why don't we start with checking for similar cases during review, like I'm now doing for only a week or two?

Quoted 1 line

and besides I'm not sure of these macros disturb so much.

I think they're confusing at best. Ie, when reading the code and the corresponding Kconfig file one has to wonder: should the Kconfig symbol actually be tristate or should it stay bool but did someone forget to delete the module-specific code?

Quoted 7 lines
Quoted 3 lines

They are documentation in a sense, albeit a kind of documentation we used before we had git to record the actual authors of the code.

They're useful, mostly, for module utilities. Outside that scope they add information that thousands of files (that can also only be built-in but do not have these macros) do not have and, apparently, do not need.

I think it depends on how you see it. Based on this logic, then one can also argue comments in the code will be pre-processed away and are not needed. They at least serve the same documentation purpose in a way. So far I haven't seen other people complaining that having these module based macros in the driver are confusing when the Kconfig has a bool.

Ray

Quoted 6 lines

Thanks,

Paul Bolle

#10 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Ray Jui schreef op ma 09-03-2015 om 12:00 [-0700]:

Quoted 3 lines

I think it depends on how you see it. Based on this logic, then one can also argue comments in the code will be pre-processed away and are not needed. They at least serve the same documentation purpose in a way.

So why not make them comments? And even that might not be needed:
- MODULE_LICENSE() only summarizes, in just a few words, what takes a few paragraphs in the customary comment at the top of a file;
- MODULE_DESCRIPTION() repeats what, in general, has been said in the Kconfig entry for that driver and in the git commit explanation;
- and I'm not sure what the benefit is of MODULE_AUTHOR() in the first place (even for actually modular drivers).

Quoted 3 lines

So
far I haven't seen other people complaining that having these module based macros in the driver are confusing when the Kconfig has a bool.

Perhaps that's just because review doesn't spot all issues. Patch bandwidth exceeding review bandwidth and all that.

Anyhow, right now there's another thread discussing the questions my review comments raise. Eg, "The Kconfig symbol is bool, there is module related code in the driver, why note make the Kconfig symbol tristate (and the driver modular)?". I think that is one of the questions mixing built-in and modular semantics raises.

Paul Bolle

author maintainer
#11 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Quoted 13 lines · Paul Bolle

Ray Jui schreef op ma 09-03-2015 om 12:00 [-0700]:

Quoted 3 lines

I think it depends on how you see it. Based on this logic, then one can also argue comments in the code will be pre-processed away and are not needed. They at least serve the same documentation purpose in a way.

So why not make them comments? And even that might not be needed:
- MODULE_LICENSE() only summarizes, in just a few words, what takes a few paragraphs in the customary comment at the top of a file;
- MODULE_DESCRIPTION() repeats what, in general, has been said in the Kconfig entry for that driver and in the git commit explanation;
- and I'm not sure what the benefit is of MODULE_AUTHOR() in the first place (even for actually modular drivers).

Quoted 6 lines
Quoted 3 lines

So
far I haven't seen other people complaining that having these module based macros in the driver are confusing when the Kconfig has a bool.

Perhaps that's just because review doesn't spot all issues. Patch bandwidth exceeding review bandwidth and all that.

I don't see this as an "issue" to be quite honest. By saying that, I at least agree with you that these are not information that's mandatory to be in the driver given what we already have. MODULE_LICENSE is covered by license header. MODULE_DESCRIPTION is covered by descriptions in Kconfig. MODULE_AUTHOR is much less important than what's in the MAINTAINERS list.

Since I have to submit a new patch series to address the "ngpios" issue that Linus mentioned in the other email, I don't mind removing all these MODULE_* macros in the driver all together.

Quoted 10 lines

Anyhow, right now there's another thread discussing the questions my review comments raise. Eg, "The Kconfig symbol is bool, there is module related code in the driver, why note make the Kconfig symbol tristate (and the driver modular)?". I think that is one of the questions mixing built-in and modular semantics raises.

Paul Bolle

Thanks,

Ray

#12 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

Ray Jui schreef op ma 09-03-2015 om 12:40 [-0700]:

Quoted 1 line

I don't see this as an "issue" to be quite honest.

(Off topic: is issue a, well, strong word? To my (non-English) mind it's rather neutral, carrying by itself less urgency than, say, problem. If I'm wrong I might have confused quite a few people by using it quite often. And that would be a real issue!)

Quoted 10 lines

By saying that, I at
least agree with you that these are not information that's mandatory to be in the driver given what we already have. MODULE_LICENSE is covered by license header. MODULE_DESCRIPTION is covered by descriptions in Kconfig. MODULE_AUTHOR is much less important than what's in the MAINTAINERS list.

Since I have to submit a new patch series to address the "ngpios" issue that Linus mentioned in the other email, I don't mind removing all these MODULE_* macros in the driver all together.

I see.

Thanks,

Paul Bolle

#13 lore raw

Re: [PATCH v5 3/8] pinctrl: cygnus: add initial IOMUX driver support

In reply to Ray Jui
Quoted 7 lines · Ray Jui

This adds the initial driver support for the Broadcom Cygnus IOMUX controller. The Cygnus IOMUX controller supports group based mux configuration but allows certain pins to be muxed to GPIO individually

Nice and clean.
Patch applied.

Yours,
Linus Walleij

author maintainer
#14 lore raw

PATCH v5 4/8 ARM: dts: enable IOMUX for Broadcom Cygnus

In reply to Ray Jui

This enables the IOMUX support for Broadcom Cygnus SoC

---
 arch/arm/boot/dts/bcm-cygnus.dtsi |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm-cygnus.dtsi +6 -0
index ff5fb6a..1cbae6a 100644
@@ -54,6 +54,12 @@
 
 	/include/ "bcm-cygnus-clock.dtsi"
 
+	pinctrl: pinctrl@0x0301d0c8 {
+		compatible = "brcm,cygnus-pinmux";
+		reg = <0x0301d0c8 0x30>,
+		      <0x0301d24c 0x2c>;
+	};
+
 	amba {
 		#address-cells = <1>;
 		#size-cells = <1>;
Signature · 1 line
1.7.9.5
author maintainer
#16 lore raw

PATCH v5 5/8 pinctrl: Cygnus: define Broadcom Cygnus GPIO/PINCONF binding

In reply to Ray Jui

Document the GPIO/PINCONF device tree binding for Broadcom Cygnus SoC

---
 .../bindings/pinctrl/brcm,cygnus-gpio.txt          |  102 ++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,cygnus-gpio.txt
Documentation/devicetree/bindings/pinctrl/brcm,cygnus-gpio.txt new file +102 -0
new file mode 100644
index 0000000..9b9196c
@@ -0,0 +1,102 @@
+Broadcom Cygnus GPIO/PINCONF Controller
+
+Required properties:
+
+- compatible:
+    Must be "brcm,cygnus-gpio"
+
+- reg:
+    Define the base and range of the I/O address space that contains the Cygnus
+GPIO/PINCONF controller registers
+
+- ngpios:
+    Total number of GPIOs the controller provides
+
+- #gpio-cells:
+    Must be two. The first cell is the GPIO pin number (within the
+controller's pin space) and the second cell is used for the following:
+    bit[0]: polarity (0 for active high and 1 for active low)
+
+- gpio-controller:
+    Specifies that the node is a GPIO controller
+
+Optional properties:
+
+- interrupts:
+    Interrupt ID
+
+- interrupt-controller:
+    Specifies that the node is an interrupt controller
+
+- pinmux:
+    Specifies the phandle to the IOMUX device, where pins can be individually
+muxed to GPIO
+
+Supported generic PINCONF properties in child nodes:
+
+- pins:
+    The list of pins (within the controller's own pin space) that properties
+in the node apply to. Pin names are "gpio-<pin>"
+
+- bias-disable:
+    Disable pin bias
+
+- bias-pull-up:
+    Enable internal pull up resistor
+
+- bias-pull-down:
+    Enable internal pull down resistor
+
+- drive-strength:
+    Valid drive strength values include 2, 4, 6, 8, 10, 12, 14, 16 (mA)
+
+Example:
+	gpio_ccm: gpio@1800a000 {
+		compatible = "brcm,cygnus-gpio";
+		reg = <0x1800a000 0x50>,
+		      <0x0301d164 0x20>;
+		ngpios = <24>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-controller;
+
+		touch_pins: touch_pins {
+			pwr: pwr {
+				pins = "gpio-0";
+				drive-strength = <16>;
+			};
+
+			event: event {
+				pins = "gpio-1";
+				bias-pull-up;
+			};
+		};
+	};
+
+	gpio_asiu: gpio@180a5000 {
+		compatible = "brcm,cygnus-gpio";
+		reg = <0x180a5000 0x668>;
+		ngpios = <146>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-controller;
+	};
+
+	/*
+	 * Touchscreen that uses the CCM GPIO 0 and 1
+	 */
+	tsc {
+		...
+		...
+		gpio-pwr = <&gpio_ccm 0 0>;
+		gpio-event = <&gpio_ccm 1 0>;
+	};
+
+	/* Bluetooth that uses the ASIU GPIO 5, with polarity inverted */
+	bluetooth {
+		...
+		...
+		bcm,rfkill-bank-sel = <&gpio_asiu 5 1>
+	}
Signature · 1 line
1.7.9.5
#17 lore raw

Re: [PATCH v5 5/8] pinctrl: Cygnus: define Broadcom Cygnus GPIO/PINCONF binding

Quoted 4 lines · Ray Jui

Document the GPIO/PINCONF device tree binding for Broadcom Cygnus SoC

(...)

Quoted 2 lines
+- ngpios:
+    Total number of GPIOs the controller provides

Remind me again. Why don't we know this from the compatible string?

(I paused applying the patches here waiting for the answer.)

Yours,
Linus Walleij

author maintainer
#18 lore raw

Re: [PATCH v5 5/8] pinctrl: Cygnus: define Broadcom Cygnus GPIO/PINCONF binding

Hi Linus,

Quoted 4 lines · Linus Walleij
Quoted 2 lines · Ray Jui

Document the GPIO/PINCONF device tree binding for Broadcom Cygnus SoC

Quoted 8 lines
Quoted 2 lines

(...)

Quoted 2 lines
+- ngpios:
+    Total number of GPIOs the controller provides

Remind me again. Why don't we know this from the compatible string?

Is hard coding the number of GPIO pins in the driver based on compatible string the preferred approach? If so, I can make the change. Note the current driver only has one compatible string "brcm,cygnus-gpio." To do this, I need to introduce 3 compatible strings "brcm,cygnus-asiu-gpio", "brcm,cygnus-ccm-gpio", "brcm,cygnus-aon-gpio", and assign hard coded ngpios to each of them during probe.

Quoted 6 lines

(I paused applying the patches here waiting for the answer.)

Yours,
Linus Walleij

author maintainer
#19 lore raw

PATCH v5 6/8 pinctrl: cygnus: add gpio/pinconf driver

In reply to Ray Jui

This adds the initial support of the Broadcom Cygnus GPIO/PINCONF driver that supports all 3 GPIO controllers on Cygnus including the ASIU GPIO controller, the chipCommonG GPIO controller, and the always-on GPIO controller. Basic PINCONF configurations such as bias pull up/down, and drive strength are also supported in this driver.

Pins from the ASIU GPIO controller can be individually muxed to GPIO function, through interaction with the Cygnus IOMUX controller

---
 drivers/pinctrl/bcm/Kconfig               |   22 +
 drivers/pinctrl/bcm/Makefile              |    1 +
 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c |  884 +++++++++++++++++++++++++++++
 3 files changed, 907 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
drivers/pinctrl/bcm/Kconfig +22 -0
index eb13201..cd11d4d 100644
@@ -20,6 +20,28 @@ config PINCTRL_BCM2835
 	select PINMUX
 	select PINCONF
 
+config PINCTRL_CYGNUS_GPIO
+	bool "Broadcom Cygnus GPIO (with PINCONF) driver"
+	depends on OF_GPIO && ARCH_BCM_CYGNUS
+	select GPIOLIB_IRQCHIP
+	select PINCONF
+	select GENERIC_PINCONF
+	default ARCH_BCM_CYGNUS
+	help
+	  Say yes here to enable the Broadcom Cygnus GPIO driver.
+
+	  The Broadcom Cygnus SoC has 3 GPIO controllers including the ASIU
+	  GPIO controller (ASIU), the chipCommonG GPIO controller (CCM), and
+	  the always-ON GPIO controller (CRMU/AON). All 3 GPIO controllers are
+	  supported by this driver.
+
+	  All 3 Cygnus GPIO controllers support basic PINCONF functions such
+	  as bias pull up, pull down, and drive strength configurations, when
+	  these pins are muxed to GPIO.
+
+	  Pins from the ASIU GPIO can be individually muxed to GPIO function,
+	  through interaction with the Cygnus IOMUX controller.
+
 config PINCTRL_CYGNUS_MUX
 	bool "Broadcom Cygnus IOMUX driver"
 	depends on (ARCH_BCM_CYGNUS || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index bb6beb6..2b2f70e 100644
@@ -2,4 +2,5 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_CYGNUS_GPIO)	+= pinctrl-cygnus-gpio.o
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c new file +884 -0

884 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#20 lore raw

Re: [PATCH v5 6/8] pinctrl: cygnus: add gpio/pinconf driver

drivers/pinctrl/bcm/Kconfig config PINCTRL_BCM2835 · line 24

Quoted 8 lines · Ray Jui
drivers/pinctrl/bcm/Kconfig +2 -0
@@ -20,6 +20,28 @@ config PINCTRL_BCM2835
 	select PINMUX
 	select PINCONF
 
+config PINCTRL_CYGNUS_GPIO
+	bool "Broadcom Cygnus GPIO (with PINCONF) driver"

bool type.

Quoted 28 lines
drivers/pinctrl/bcm/Kconfig +20 -0
+	depends on OF_GPIO && ARCH_BCM_CYGNUS
+	select GPIOLIB_IRQCHIP
+	select PINCONF
+	select GENERIC_PINCONF
+	default ARCH_BCM_CYGNUS
+	help
+	  Say yes here to enable the Broadcom Cygnus GPIO driver.
+
+	  The Broadcom Cygnus SoC has 3 GPIO controllers including the ASIU
+	  GPIO controller (ASIU), the chipCommonG GPIO controller (CCM), and
+	  the always-ON GPIO controller (CRMU/AON). All 3 GPIO controllers are
+	  supported by this driver.
+
+	  All 3 Cygnus GPIO controllers support basic PINCONF functions such
+	  as bias pull up, pull down, and drive strength configurations, when
+	  these pins are muxed to GPIO.
+
+	  Pins from the ASIU GPIO can be individually muxed to GPIO function,
+	  through interaction with the Cygnus IOMUX controller.
+
 config PINCTRL_CYGNUS_MUX
 	bool "Broadcom Cygnus IOMUX driver"
 	depends on (ARCH_BCM_CYGNUS || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +0 -0
index bb6beb6..2b2f70e 100644

drivers/pinctrl/bcm/Makefile line 5

Quoted 4 lines
drivers/pinctrl/bcm/Makefile +1 -0
@@ -2,4 +2,5 @@
 
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
+obj-$(CONFIG_PINCTRL_CYGNUS_GPIO)	+= pinctrl-cygnus-gpio.o

So pinctrl-cygnus-gpio. will be built-in or not built at all.

Quoted 7 lines
drivers/pinctrl/bcm/Makefile +0 -0
 obj-$(CONFIG_PINCTRL_CYGNUS_MUX)	+= pinctrl-cygnus-mux.o
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c new file +0 -0
new file mode 100644
index 0000000..4687284
@@ -0,0 +1,884 @@

[...]

drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c line 884

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c new file +3 -0
+MODULE_AUTHOR("Ray Jui <[email protected]>");
+MODULE_DESCRIPTION("Broadcom Cygnus GPIO Driver");
+MODULE_LICENSE("GPL v2");

These three macros will be preprocessed away. (There's also MODULE_DEVICE_TABLE. I don't yet know how that is handled in a non-modular build, sorry.)

Paul Bolle

#21 lore raw

Re: [PATCH v5 6/8] pinctrl: cygnus: add gpio/pinconf driver

Quoted 8 lines · Paul Bolle

drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c line 884

Quoted 3 lines · Ray Jui
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c new file +3 -0
+MODULE_AUTHOR("Ray Jui <[email protected]>");
+MODULE_DESCRIPTION("Broadcom Cygnus GPIO Driver");
+MODULE_LICENSE("GPL v2");

These three macros will be preprocessed away. (There's also MODULE_DEVICE_TABLE. I don't yet know how that is handled in a non-modular build, sorry.)

It turns out MODULE_DEVICE_TABLE is _really_ preprocessed away. See include/linux/module.h:

    #ifdef MODULE
    /* Creates an alias so file2alias.c can find device table. */
    #define MODULE_DEVICE_TABLE(type, name)                                 \
    extern const typeof(name) __mod_##type##__##name##_device_table         \
      __attribute__ ((unused, alias(__stringify(name))))
    #else  /* !MODULE */
    #define MODULE_DEVICE_TABLE(type, name)
    #endif

Did I get that right?

(I knew the other three MODULE_* macros are handled in slightly more complicated way, but the effect is basically that they are preprocessed away.)

Paul Bolle

author maintainer
#22 lore raw

Re: [PATCH v5 6/8] pinctrl: cygnus: add gpio/pinconf driver

Hi Paul,

Quoted 22 lines · Paul Bolle
Quoted 8 lines · Paul Bolle

drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c line 884

Quoted 3 lines · Ray Jui
drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c new file +3 -0
+MODULE_AUTHOR("Ray Jui <[email protected]>");
+MODULE_DESCRIPTION("Broadcom Cygnus GPIO Driver");
+MODULE_LICENSE("GPL v2");

These three macros will be preprocessed away. (There's also MODULE_DEVICE_TABLE. I don't yet know how that is handled in a non-modular build, sorry.)

It turns out MODULE_DEVICE_TABLE is _really_ preprocessed away. See include/linux/module.h:

    #ifdef MODULE
    /* Creates an alias so file2alias.c can find device table. */
    #define MODULE_DEVICE_TABLE(type, name)                                 \
    extern const typeof(name) __mod_##type##__##name##_device_table         \
      __attribute__ ((unused, alias(__stringify(name))))
    #else  /* !MODULE */
    #define MODULE_DEVICE_TABLE(type, name)
    #endif
Quoted 9 lines

Did I get that right?

(I knew the other three MODULE_* macros are handled in slightly more complicated way, but the effect is basically that they are preprocessed away.)

Paul Bolle

Even these module macros will be pre-processed away when the driver is statically linked (and yes, I'm not planning to ever make these driver built as module), I'm not too sure about the convention here. I thought that they are still good to be in the driver for information purpose. I'm seeing other pinctrl drivers doing this as well.

Maybe Linus can help to clarify this?

Thanks,

Ray

#23 lore raw

Re: [PATCH v5 6/8] pinctrl: cygnus: add gpio/pinconf driver

Quoted 6 lines · Ray Jui
Quoted 5 lines

(I knew the other three MODULE_* macros are handled in slightly more complicated way, but the effect is basically that they are preprocessed away.)

Paul Bolle

Quoted 7 lines

Even these module macros will be pre-processed away when the driver is statically linked (and yes, I'm not planning to ever make these driver built as module), I'm not too sure about the convention here. I thought that they are still good to be in the driver for information purpose. I'm seeing other pinctrl drivers doing this as well.

Maybe Linus can help to clarify this?

As pointed out in another mail on similar subject, I think these macros are a kind of obsolete documentation and if they should be dropped we need to go over an entire subsystem at a time and remove all boolean users in a big patch.

Yours,
Linus Walleij

#24 lore raw

Re: [PATCH v5 6/8] pinctrl: cygnus: add gpio/pinconf driver

Linus Walleij schreef op ma 09-03-2015 om 17:41 [+0100]:

Quoted 4 lines

As pointed out in another mail on similar subject, I think these macros are a kind of obsolete documentation and if they should be dropped we need to go over an entire subsystem at a time and remove all boolean users in a big patch.

And, as I stated in that other thread, we could start by first checking for things like this during review. (And if people were to do clean up patches I'd suggest to do them one driver at a time. Just to keep things manageable.)

Paul Bolle

author maintainer
#25 lore raw

PATCH v5 7/8 ARM: dts: enable GPIO for Broadcom Cygnus

In reply to Ray Jui

This enables all 3 GPIO controllers including the ASIU GPIO, the chipcommonG GPIO, and the ALWAYS-ON GPIO, for Broadcom Cygnus SoC

---
 arch/arm/boot/dts/bcm-cygnus.dtsi |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/boot/dts/bcm-cygnus.dtsi +33 -0
index 1cbae6a..8d247d2 100644
@@ -60,6 +60,39 @@
 		      <0x0301d24c 0x2c>;
 	};
 
+	gpio_crmu: gpio@03024800 {
+		compatible = "brcm,cygnus-gpio";
+		reg = <0x03024800 0x50>,
+		      <0x03024008 0x18>;
+		ngpios = <6>;
+		#gpio-cells = <2>;
+		gpio-controller;
+	};
+
+	gpio_ccm: gpio@1800a000 {
+		compatible = "brcm,cygnus-gpio";
+		reg = <0x1800a000 0x50>,
+		      <0x0301d164 0x20>;
+		ngpios = <24>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-controller;
+	};
+
+	gpio_asiu: gpio@180a5000 {
+		compatible = "brcm,cygnus-gpio";
+		reg = <0x180a5000 0x668>;
+		ngpios = <146>;
+		#gpio-cells = <2>;
+		gpio-controller;
+
+		pinmux = <&pinctrl>;
+
+		interrupt-controller;
+		interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+	};
+
 	amba {
 		#address-cells = <1>;
 		#size-cells = <1>;
Signature · 1 line
1.7.9.5
author maintainer
#26 lore raw

PATCH v5 8/8 ARM: dts: cygnus: enable GPIO based hook detection

In reply to Ray Jui

This enables GPIO based phone hook detection for Broadcom BCM911360 phone factor board (bcm911360_entphn)

---
 arch/arm/boot/dts/bcm911360_entphn.dts |   13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/boot/dts/bcm911360_entphn.dts +13 -0
index d2ee952..7db4843 100644
@@ -33,6 +33,7 @@
 /dts-v1/;
 
 #include "bcm-cygnus.dtsi"
+#include "dt-bindings/input/input.h"
 
 / {
 	model = "Cygnus Enterprise Phone (BCM911360_ENTPHN)";
@@ -50,4 +51,16 @@
 	uart3: serial@18023000 {
 		status = "okay";
 	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		hook {
+			label = "HOOK";
+			linux,code = <KEY_O>;
+			gpios = <&gpio_asiu 48 0>;
+		};
+	};
 };
Signature · 1 line
1.7.9.5