Skip to contentSkip to conversation

gpio: Increase ARCH_NR_GPIOs to 512

PATCH In review Mika Westerberg 3 participants 9 messages Sep 15, 2014 – Sep 24, 2014

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

PATCH v2 1/2 gpio: Increase ARCH_NR_GPIOs to 512

Some newer Intel SoCs, like Braswell already have more than 256 GPIOs available so the default limit is exceeded. Instead of adding more architecture specific gpio.h files with custom ARCH_NR_GPIOs we increase the gpiolib default limit to be twice the current.

---
Changes to previous version is that now we increase the common limit instead of adding x86 specific gpio.h

 include/asm-generic/gpio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/gpio.h +1 -1
index c1d4105e1c1d..383ade1a211b 100644
@@ -27,7 +27,7 @@
  */
 
 #ifndef ARCH_NR_GPIOS
-#define ARCH_NR_GPIOS		256
+#define ARCH_NR_GPIOS		512
 #endif
 
 /*
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 2/2 gpio: Add support for Intel Cherryview/Braswell GPIO controller

From: Ning Li <[email protected]>

This driver supports the GPIO controllers found in newer Intel SoCs like Cherryview and Braswell.

---
 drivers/gpio/Kconfig           |   8 +
 drivers/gpio/Makefile          |   1 +
 drivers/gpio/gpio-cherryview.c | 947 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 956 insertions(+)
 create mode 100644 drivers/gpio/gpio-cherryview.c
drivers/gpio/Kconfig +8 -0
index 9de1515e5808..73a317d7b7bf 100644
@@ -736,6 +736,14 @@ config GPIO_INTEL_MID
 	help
 	  Say Y here to support Intel Mid GPIO.
 
+config GPIO_CHERRYVIEW
+	tristate "Intel CherryView/Braswell GPIO support"
+	depends on ACPI
+	select GPIOLIB_IRQCHIP
+	help
+	  Enable support for GPIO host controllers found on Intel SoCs
+	  such as CherryView and Braswell.
+
 config GPIO_PCH
 	tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7223/ML7831) GPIO"
 	depends on PCI && (X86_32 || COMPILE_TEST)
drivers/gpio/Makefile +1 -0
index 5d024e396622..1162b08564a7 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_AMD8111)	+= gpio-amd8111.o
 obj-$(CONFIG_GPIO_ARIZONA)	+= gpio-arizona.o
 obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BT8XX)	+= gpio-bt8xx.o
+obj-$(CONFIG_GPIO_CHERRYVIEW)	+= gpio-cherryview.o
 obj-$(CONFIG_GPIO_CLPS711X)	+= gpio-clps711x.o
 obj-$(CONFIG_GPIO_CS5535)	+= gpio-cs5535.o
 obj-$(CONFIG_GPIO_CRYSTAL_COVE)	+= gpio-crystalcove.o
drivers/gpio/gpio-cherryview.c new file +947 -0

947 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH v2 2/2] gpio: Add support for Intel Cherryview/Braswell GPIO controller

Quoted 8 lines · Mika Westerberg

From: Ning Li <[email protected]>

This driver supports the GPIO controllers found in newer Intel SoCs like Cherryview and Braswell.

Quoted 6 lines
---
 drivers/gpio/Kconfig           |   8 +
 drivers/gpio/Makefile          |   1 +
 drivers/gpio/gpio-cherryview.c | 947 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 956 insertions(+)
 create mode 100644 drivers/gpio/gpio-cherryview.c

Hi GPIO maintainers,

Just checking if there is any comments to this driver?

If the ARCH_NR_GPIOS patch is not accepted as is (or we are even getting rid of the limit), could you consider taking this driver patch to the GPIO tree separately?

#3 lore raw

Re: [PATCH v2 2/2] gpio: Add support for Intel Cherryview/Braswell GPIO controller

In reply to Mika Westerberg
Quoted 8 lines · Mika Westerberg

From: Ning Li <[email protected]>

This driver supports the GPIO controllers found in newer Intel SoCs like Cherryview and Braswell.

(...)

drivers/gpio/gpio-cherryview.c line 25

Quoted 3 lines
drivers/gpio/gpio-cherryview.c new file +3 -0
+#define FAMILY0_PAD_REGS_OFF   0x4400
+#define FAMILY_PAD_REGS_SIZE   0x400
+#define MAX_FAMILY_PAD_GPIO_NO 15

Pad registers...

drivers/gpio/gpio-cherryview.c line 81

Quoted 10 lines
drivers/gpio/gpio-cherryview.c new file +10 -0
+static const char * const north_pads[] = {
+       "GPIO_DFX_0",
+       "GPIO_DFX_3",
+       "GPIO_DFX_7",
+       "GPIO_DFX_1",
+       "GPIO_DFX_5",
+       "GPIO_DFX_4",
+       "GPIO_DFX_8",
+       "GPIO_DFX_2",
+       "GPIO_DFX_6",

And then even naming them and stuff.

This is almost a schoolbook definition of stuff that pertains to the pin control subsystem rather than GPIO, and this info in particular shall be encoded in the .pins field of the struct pinctrl_desc. Which is where we name pins.

drivers/gpio/gpio-cherryview.c line 668

Quoted 13 lines
drivers/gpio/gpio-cherryview.c new file +13 -0
+               switch ((ctrl0 & CV_GPIO_CFG_MASK) >> 8) {
+               case 0:
+                       dir = "in out";
+                       break;
+               case 1:
+                       dir = "   out";
+                       break;
+               case 2:
+                       dir = "in";
+                       break;
+               case 3:
+                       dir = "HiZ";
+                       break;

And here there is even pin config like HiZ, which is in the kernel called PIN_CONFIG_BIAS_HIGH_IMPEDANCE with generic
pin config.

In short it seems the driver is written by someone who has never heard of pin control or doesn't realize that this is exactly what pin control is about.

Read Documentation/pinctrl.txt and rewrite the entire driver to use pin control, and generic pin config like everyone else.

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH v2 2/2] gpio: Add support for Intel Cherryview/Braswell GPIO controller

Quoted 2 lines · Linus Walleij

Read Documentation/pinctrl.txt and rewrite the entire driver to use pin control, and generic pin config like everyone else.

NB: this will be a dual-mode driver exposing *both* a pin control *and* a gpiochip interface. Look at other drivers in drivers/pinctrl for examples, e.g. drivers/pinctrl/qcom/*

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH v2 2/2] gpio: Add support for Intel Cherryview/Braswell GPIO controller

In reply to Linus Walleij
Quoted 50 lines · Linus Walleij
Quoted 8 lines · Mika Westerberg

From: Ning Li <[email protected]>

This driver supports the GPIO controllers found in newer Intel SoCs like Cherryview and Braswell.

(...)

drivers/gpio/gpio-cherryview.c line 25

Quoted 3 lines
drivers/gpio/gpio-cherryview.c new file +3 -0
+#define FAMILY0_PAD_REGS_OFF   0x4400
+#define FAMILY_PAD_REGS_SIZE   0x400
+#define MAX_FAMILY_PAD_GPIO_NO 15

Pad registers...

drivers/gpio/gpio-cherryview.c line 81

Quoted 10 lines
drivers/gpio/gpio-cherryview.c new file +10 -0
+static const char * const north_pads[] = {
+       "GPIO_DFX_0",
+       "GPIO_DFX_3",
+       "GPIO_DFX_7",
+       "GPIO_DFX_1",
+       "GPIO_DFX_5",
+       "GPIO_DFX_4",
+       "GPIO_DFX_8",
+       "GPIO_DFX_2",
+       "GPIO_DFX_6",

And then even naming them and stuff.

This is almost a schoolbook definition of stuff that pertains to the pin control subsystem rather than GPIO, and this info in particular shall be encoded in the .pins field of the struct pinctrl_desc. Which is where we name pins.

drivers/gpio/gpio-cherryview.c line 668

Quoted 13 lines
drivers/gpio/gpio-cherryview.c new file +13 -0
+               switch ((ctrl0 & CV_GPIO_CFG_MASK) >> 8) {
+               case 0:
+                       dir = "in out";
+                       break;
+               case 1:
+                       dir = "   out";
+                       break;
+               case 2:
+                       dir = "in";
+                       break;
+               case 3:
+                       dir = "HiZ";
+                       break;
Quoted 7 lines

And here there is even pin config like HiZ, which is in the kernel called PIN_CONFIG_BIAS_HIGH_IMPEDANCE with generic
pin config.

In short it seems the driver is written by someone who has never heard of pin control or doesn't realize that this is exactly what pin control is about.

Heh, I actually looked into pinctrl but somehow couldn't find any fit there.

Quoted 2 lines

Read Documentation/pinctrl.txt and rewrite the entire driver to use pin control, and generic pin config like everyone else.

Will do, thanks.

maintainer
#6 lore raw
In reply to Mika Westerberg
Quoted 9 lines · Mika Westerberg

Some newer Intel SoCs, like Braswell already have more than 256 GPIOs available so the default limit is exceeded. Instead of adding more architecture specific gpio.h files with custom ARCH_NR_GPIOs we increase the gpiolib default limit to be twice the current.

---
Changes to previous version is that now we increase the common limit instead of adding x86 specific gpio.h

Can you please include the reasoning for this decision in the changeset description? I'm sure you have your reasons, but from the text above, it sounds like a rather bad idea. What other architectures are impacted by this, and what is the kernel size cost for it on those architectures?

Arnd

#7 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Mika Westerberg

Some newer Intel SoCs, like Braswell already have more than 256 GPIOs available so the default limit is exceeded. Instead of adding more architecture specific gpio.h files with custom ARCH_NR_GPIOs we increase the gpiolib default limit to be twice the current.

---
Changes to previous version is that now we increase the common limit instead of adding x86 specific gpio.h

Quoted 5 lines

Can you please include the reasoning for this decision in the changeset description? I'm sure you have your reasons, but from the text above, it sounds like a rather bad idea. What other architectures are impacted by this, and what is the kernel size cost for it on those architectures?

How about,

Current generic ARCH_NR_GPIOS limit is 256 which starts to be too small for newer Intel SoCs like Braswell. In order to support GPIO controllers on these SoCs we increase ARCH_NR_GPIOS to be 512 which should be sufficient for now.

The kernel size increases a bit with this change. Below is an example of x86_64 kernel image.

ARCH_NR_GPIOS=256
text data bss dec hex filename
11476173 1971328 1265664 14713165 e0814d vmlinux

ARCH_NR_GPIOS=512
text data bss dec hex filename
11476173 1971328 1269760 14717261 e0914d vmlinux

So the BSS size and this the kernel image size increases by 4k.

#8 lore raw
In reply to Mika Westerberg
Quoted 6 lines · Mika Westerberg

Some newer Intel SoCs, like Braswell already have more than 256 GPIOs available so the default limit is exceeded. Instead of adding more architecture specific gpio.h files with custom ARCH_NR_GPIOs we increase the gpiolib default limit to be twice the current.

Patch applied with the extended blurb in the commit message.

Yours,
Linus Walleij