Skip to contentSkip to conversation

Add gpio-keys-polled for fan presence

PATCH In review Christopher Bostic 5 participants 16 messages Jul 29, 2017 – Aug 3, 2017

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

v6 cover Add gpio-keys-polled for fan presence

Define pca955x fan presence pins as gpio-keys-polled pins in device tree.

Christopher Bostic (2):
ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence drivers/leds: pca955x count LED lines as GPIO

 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
 drivers/leds/pmbus/leds-pca955x.c | 2 ++
 2 files changed, 54 insertions(+)
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH v6 1/2 ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +52 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
 		};
 	};
 
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
@@ -277,6 +308,7 @@
 		reg = <0x60>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		#gpio-cells = <2>;
 
 		fan0: led@0 {
 			label = "fan0";
@@ -302,6 +334,26 @@
 			reg = <3>;
 			type = <PCA955X_TYPE_LED>;
 		};
+		fan0_pres_gpio: gpio@4 {
+			label = "fan0_presence";
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan1_pres_gpio: gpio@5 {
+			label = "fan1_presence";
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan2_pres_gpio: gpio@6 {
+			label = "fan2_presence";
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan3_pres_gpio: gpio@7 {
+			label = "fan3_presence";
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
 		front_fault: led@13 {
 			label = "front-fault";
 			default-state = "keep";
Signature · 1 line
1.8.2.2
#12 lore raw

PATCH v6 2/2 drivers/leds: pca955x count LED lines as GPIO

In reply to Christopher Bostic

In order for gpio-keys-polled driver to properly register pins connected to the pca955x chip it is necessary to count 'LED' lines as part of the total gpio count. The assocated gpio_chip struct for the pca955x is then set to all available I/O (LEDS and 'GPIO'). Failure to do so will cause any pin # > GPIO pin count to fail gpio-keys-polled probe/registration as it falls outside the bounds of what the gpio_chip struct indicates is available.

---
 drivers/leds/leds-pca955x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/leds-pca955x.c +2 -0
index 9216742..4fa58b9 100644
@@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
 			ngpios++;
 			break;
 		case PCA955X_TYPE_LED:
+			ngpios++;
+
 			/*
 			 * Platform data can specify LED names and
 			 * default triggers
Signature · 1 line
1.8.2.2
Tested-by on v6 2/2
#13 lore raw

Re: [PATCH linux dev-4.10 v6 2/2] drivers/leds: pca955x count LED lines as GPIO

Quoted 11 lines · Christopher Bostic

In order for gpio-keys-polled driver to properly register pins connected to the pca955x chip it is necessary to count 'LED' lines as part of the total gpio count. The assocated gpio_chip struct for the pca955x is then set to all available I/O (LEDS and 'GPIO'). Failure to do so will cause any pin # > GPIO pin count to fail gpio-keys-polled probe/registration as it falls outside the bounds of what the gpio_chip struct indicates is available.

Quoted 1 line
Quoted 19 lines

---
drivers/leds/leds-pca955x.c | 2 ++

1 file changed, 2 insertions(+)
drivers/leds/leds-pca955x.c +2 -0
index 9216742..4fa58b9 100644
@@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
 			ngpios++;
 			break;
 		case PCA955X_TYPE_LED:
+			ngpios++;
+
 			/*
 			 * Platform data can specify LED names and
 			 * default triggers
Signature · 1 line
1.8.2.2
Tested-by on v6 1/2
#2 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

In reply to Christopher Bostic
Quoted 11 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

Quoted 93 lines

---
v6 - Add gpio pin details for fan presence to pca955x node
v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message.
v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.
---
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++

1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +52 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
 		};
 	};
 
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
@@ -277,6 +308,7 @@
 		reg = <0x60>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		#gpio-cells = <2>;
 
 		fan0: led@0 {
 			label = "fan0";
@@ -302,6 +334,26 @@
 			reg = <3>;
 			type = <PCA955X_TYPE_LED>;
 		};
+		fan0_pres_gpio: gpio@4 {
+			label = "fan0_presence";
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan1_pres_gpio: gpio@5 {
+			label = "fan1_presence";
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan2_pres_gpio: gpio@6 {
+			label = "fan2_presence";
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan3_pres_gpio: gpio@7 {
+			label = "fan3_presence";
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
 		front_fault: led@13 {
 			label = "front-fault";
 			default-state = "keep";
Signature · 1 line
1.8.2.2
maintainer
#14 lore raw

Re: [PATCH linux dev-4.10 v6 2/2] drivers/leds: pca955x count LED lines as GPIO

In reply to Brad Bishop
Quoted 18 lines · Brad Bishop
Quoted 11 lines · Christopher Bostic

In order for gpio-keys-polled driver to properly register pins connected to the pca955x chip it is necessary to count 'LED' lines as part of the total gpio count. The assocated gpio_chip struct for the pca955x is then set to all available I/O (LEDS and 'GPIO'). Failure to do so will cause any pin # > GPIO pin count to fail gpio-keys-polled probe/registration as it falls outside the bounds of what the gpio_chip struct indicates is available.

Quoted 1 line
Quoted 4 lines

---
drivers/leds/leds-pca955x.c | 2 ++

1 file changed, 2 insertions(+)
Quoted 10 lines

drivers/leds/leds-pca955x.c static int pca955x_probe(struct i2c_client *client, · line 476

Quoted 10 lines
drivers/leds/leds-pca955x.c +2 -0
index 9216742..4fa58b9 100644
@@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
                      ngpios++;
                      break;
              case PCA955X_TYPE_LED:
+                     ngpios++;
+

Hey Cedric, does this look like the correct fix?

#3 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

In reply to Christopher Bostic
Quoted 65 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +31 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
 		};
 	};
 
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts line 311

Quoted 4 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +1 -0
@@ -277,6 +308,7 @@
 		reg = <0x60>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		#gpio-cells = <2>;

you should also add a :

		gpio-controller;

if you want to use the lines as GPIOs

C.

Quoted 31 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +20 -0
 		fan0: led@0 {
 			label = "fan0";
@@ -302,6 +334,26 @@
 			reg = <3>;
 			type = <PCA955X_TYPE_LED>;
 		};
+		fan0_pres_gpio: gpio@4 {
+			label = "fan0_presence";
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan1_pres_gpio: gpio@5 {
+			label = "fan1_presence";
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan2_pres_gpio: gpio@6 {
+			label = "fan2_presence";
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan3_pres_gpio: gpio@7 {
+			label = "fan3_presence";
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
 		front_fault: led@13 {
 			label = "front-fault";
 			default-state = "keep";
maintainer
#11 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

In reply to Christopher Bostic
Quoted 73 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +32 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
                };
        };
 
+       gpio-keys-polled {
+               compatible = "gpio-keys-polled";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               poll-interval = <1000>;
+
+               fan0-presence {
+                       label = "fan0-presence";
+                       gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+                       linux,code = <4>;
+               };
+
+               fan1-presence {
+                       label = "fan1-presence";
+                       gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+                       linux,code = <5>;
+               };
+
+               fan2-presence {
+                       label = "fan2-presence";
+                       gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+                       linux,code = <6>;
+               };
+
+               fan3-presence {
+                       label = "fan3-presence";
+                       gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+                       linux,code = <7>;
+               };
+       };
+
        leds {
                compatible = "gpio-leds";
 
@@ -277,6 +308,7 @@
                reg = <0x60>;
                #address-cells = <1>;
                #size-cells = <0>;
+               #gpio-cells = <2>;
 
                fan0: led@0 {
                        label = "fan0";

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts line 338

Quoted 5 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +2 -0
@@ -302,6 +334,26 @@
                        reg = <3>;
                        type = <PCA955X_TYPE_LED>;
                };
+               fan0_pres_gpio: gpio@4 {
+                       label = "fan0_presence";

These signals are all labled _N, so I would expect them to be marked as active low in the device tree. I am looking at the pass 4 schematic.

Cheers,

Joel

Quoted 24 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +18 -1
+                       reg = <4>;
+                       type = <PCA955X_TYPE_GPIO>;
+               };
+               fan1_pres_gpio: gpio@5 {
+                       label = "fan1_presence";
+                       reg = <5>;
+                       type = <PCA955X_TYPE_GPIO>;
+               };
+               fan2_pres_gpio: gpio@6 {
+                       label = "fan2_presence";
+                       reg = <6>;
+                       type = <PCA955X_TYPE_GPIO>;
+               };
+               fan3_pres_gpio: gpio@7 {
+                       label = "fan3_presence";
+                       reg = <7>;
+                       type = <PCA955X_TYPE_GPIO>;
+               };
                front_fault: led@13 {
                        label = "front-fault";
                        default-state = "keep";
--

1.8.2.2

#15 lore raw

Re: [PATCH linux dev-4.10 v6 2/2] drivers/leds: pca955x count LED lines as GPIO

In reply to Joel Stanley
Quoted 20 lines · Joel Stanley
Quoted 18 lines · Brad Bishop
Quoted 11 lines · Christopher Bostic

In order for gpio-keys-polled driver to properly register pins connected to the pca955x chip it is necessary to count 'LED' lines as part of the total gpio count. The assocated gpio_chip struct for the pca955x is then set to all available I/O (LEDS and 'GPIO'). Failure to do so will cause any pin # > GPIO pin count to fail gpio-keys-polled probe/registration as it falls outside the bounds of what the gpio_chip struct indicates is available.

Quoted 1 line
Quoted 4 lines

---
drivers/leds/leds-pca955x.c | 2 ++

1 file changed, 2 insertions(+)
Quoted 13 lines
Quoted 10 lines

drivers/leds/leds-pca955x.c static int pca955x_probe(struct i2c_client *client, · line 476

Quoted 10 lines
drivers/leds/leds-pca955x.c +2 -0
index 9216742..4fa58b9 100644
@@ -472,6 +472,8 @@ static int pca955x_probe(struct i2c_client *client,
                      ngpios++;
                      break;
              case PCA955X_TYPE_LED:
+                     ngpios++;
+

Hey Cedric, does this look like the correct fix?

At first glance, I would say no. I will take a look.

C.

#4 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

In reply to Cédric Le Goater
Quoted 72 lines · Cédric Le Goater
Quoted 65 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
  arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
  1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +31 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
  		};
  	};
 
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
  	leds {
  		compatible = "gpio-leds";
 

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts line 311

Quoted 4 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +1 -0
@@ -277,6 +308,7 @@
  		reg = <0x60>;
  		#address-cells = <1>;
  		#size-cells = <0>;
+		#gpio-cells = <2>;

you should also add a :

Quoted 5 lines
		gpio-controller;

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file? I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled device driver to properly probe the pca955x lines.

Thanks
Chris

Quoted 31 lines
Quoted 31 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +20 -0
  		fan0: led@0 {
  			label = "fan0";
@@ -302,6 +334,26 @@
  			reg = <3>;
  			type = <PCA955X_TYPE_LED>;
  		};
+		fan0_pres_gpio: gpio@4 {
+			label = "fan0_presence";
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan1_pres_gpio: gpio@5 {
+			label = "fan1_presence";
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan2_pres_gpio: gpio@6 {
+			label = "fan2_presence";
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		fan3_pres_gpio: gpio@7 {
+			label = "fan3_presence";
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
  		front_fault: led@13 {
  			label = "front-fault";
  			default-state = "keep";
#5 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Quoted 75 lines · Christopher Bostic
Quoted 72 lines · Cédric Le Goater
Quoted 57 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
  arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
  1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +27 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
          };
      };
  +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts

Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
+        };
+    };
+
      leds {
          compatible = "gpio-leds";
  @@ -277,6 +308,7 @@
          reg = <0x60>;
          #address-cells = <1>;
          #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

        gpio-controller;
Quoted 7 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled
device driver to properly probe the pca955x lines.

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

C.

Quoted 34 lines

Thanks
Chris

Quoted 30 lines
Quoted 30 lines
            fan0: led@0 {
              label = "fan0";
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +20 -0
@@ -302,6 +334,26 @@
              reg = <3>;
              type = <PCA955X_TYPE_LED>;
          };
+        fan0_pres_gpio: gpio@4 {
+            label = "fan0_presence";
+            reg = <4>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan1_pres_gpio: gpio@5 {
+            label = "fan1_presence";
+            reg = <5>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan2_pres_gpio: gpio@6 {
+            label = "fan2_presence";
+            reg = <6>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan3_pres_gpio: gpio@7 {
+            label = "fan3_presence";
+            reg = <7>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
          front_fault: led@13 {
              label = "front-fault";
              default-state = "keep";
#6 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Quoted 84 lines · Cédric Le Goater
Quoted 75 lines · Christopher Bostic
Quoted 72 lines · Cédric Le Goater
Quoted 57 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
  arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
  1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +27 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
          };
      };
  +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts

Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
+        };
+    };
+
      leds {
          compatible = "gpio-leds";
  @@ -277,6 +308,7 @@
          reg = <0x60>;
          #address-cells = <1>;
          #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

        gpio-controller;
Quoted 7 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

Quoted 8 lines

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled
device driver to properly probe the pca955x lines.

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

It fails indeed, but the fix you are proposing does not look right either.

Maybe we should fully define the pca9552 as a gpio controller and then define a gpio-leds and a gpio-keys-polled on top of it ?

Thanks,

C.

Quoted 38 lines

C.

Quoted 34 lines

Thanks
Chris

Quoted 30 lines
Quoted 30 lines
            fan0: led@0 {
              label = "fan0";
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +20 -0
@@ -302,6 +334,26 @@
              reg = <3>;
              type = <PCA955X_TYPE_LED>;
          };
+        fan0_pres_gpio: gpio@4 {
+            label = "fan0_presence";
+            reg = <4>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan1_pres_gpio: gpio@5 {
+            label = "fan1_presence";
+            reg = <5>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan2_pres_gpio: gpio@6 {
+            label = "fan2_presence";
+            reg = <6>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan3_pres_gpio: gpio@7 {
+            label = "fan3_presence";
+            reg = <7>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
          front_fault: led@13 {
              label = "front-fault";
              default-state = "keep";
#7 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Quoted 88 lines · Cédric Le Goater
Quoted 87 lines · Cédric Le Goater
Quoted 74 lines · Christopher Bostic
Quoted 72 lines · Cédric Le Goater
Quoted 57 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
   arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
   1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +27 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
           };
       };
   +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts

Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
+        };
+    };
+
       leds {
           compatible = "gpio-leds";
   @@ -277,6 +308,7 @@
           reg = <0x60>;
           #address-cells = <1>;
           #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

         gpio-controller;
Quoted 7 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled
device driver to properly probe the pca955x lines.

Quoted 7 lines
Quoted 2 lines

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

It fails indeed, but the fix you are proposing does not look right either.

Maybe we should fully define the pca9552 as a gpio controller and then define a gpio-leds and a gpio-keys-polled on top of it ?

Hi Cedric,

What would be entailed in fully defining the pca9552 as a gpio controller? Any other driver examples would help if you know of any.

Currently I see that it has a struct gpio_chip embedded in its 955x chip structure and that it defines its various properties, .direction_input, .direction_output, etc... The struct gpio_chip ngpio field is set to a subset of pins that are not labeled as LEDS. Hence my added change to count LEDS towards total ngpio's. Given that the pins I'm interested in are 4-7 this falls outside the bounds of what the gpio chip considers total gpio count. As a result gpio-keys-polled driver probe fails.

Maybe a quick conference call might be useful?

Thanks,
Chris

Quoted 40 lines

Thanks,

C.

Quoted 35 lines

C.

Quoted 33 lines

Thanks
Chris

Quoted 30 lines
Quoted 30 lines
             fan0: led@0 {
               label = "fan0";
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +20 -0
@@ -302,6 +334,26 @@
               reg = <3>;
               type = <PCA955X_TYPE_LED>;
           };
+        fan0_pres_gpio: gpio@4 {
+            label = "fan0_presence";
+            reg = <4>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan1_pres_gpio: gpio@5 {
+            label = "fan1_presence";
+            reg = <5>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan2_pres_gpio: gpio@6 {
+            label = "fan2_presence";
+            reg = <6>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
+        fan3_pres_gpio: gpio@7 {
+            label = "fan3_presence";
+            reg = <7>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
           front_fault: led@13 {
               label = "front-fault";
               default-state = "keep";
#8 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Quoted 108 lines · Christopher Bostic
Quoted 92 lines · Cédric Le Goater
Quoted 91 lines · Cédric Le Goater
Quoted 75 lines · Christopher Bostic
Quoted 73 lines · Cédric Le Goater
Quoted 62 lines · Christopher Bostic

Add gpio-keys-polled  node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node
v5 - Fix gpio-keys-polled driver probe errors.  Missing pca955x
       gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message.
v3 - Remove 'autorepeat'
     - Increase polling period to 1 second.
     - Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one for all the gpio-keys-polled devices.
---
   arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++

   1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +30 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
            };
        };
    +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;
+        };
+    };
+
        leds {
            compatible = "gpio-leds";
Quoted 5 lines

   @@ -277,6 +308,7 @@
           reg = <0x60>;
           #address-cells = <1>;
           #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

         gpio-controller;

Quoted 8 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled device driver to properly probe the pca955x lines.

Quoted 8 lines
Quoted 2 lines

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

It fails indeed, but the fix you are proposing does not look right either.

Maybe we should fully define the pca9552 as a gpio controller and then define a gpio-leds and a gpio-keys-polled on top of it ?

Hi Cedric,

What would be entailed in fully defining the pca9552 as a gpio controller?   Any other driver examples would help if you know of any.

Quoted 7 lines

Currently I see that it has a struct gpio_chip embedded in its 955x chip structure and that it defines its various properties, .direction_input, .direction_output, etc...   The struct gpio_chip ngpio field is set to a subset of pins that are not labeled as LEDS.  Hence my added change to count LEDS towards total ngpio's. Given that the pins I'm interested in are 4-7 this falls outside the bounds of what the gpio chip considers total gpio count.   As a result gpio-keys-polled driver probe fails.

I'm starting to think it's best to describe the device as a pin- controller, and "mux" the lines between GPIO and LED. This allows describing the all the lines as GPIO, or providing a map between the GPIO and LED line number spaces. This would resolve the "index is greater than the count" problem that you're running into.

See:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/gpio/gpio.txt?h=v4.12#n230

And

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/pinctrl.txt?h=v4.12#n282

Now I don't know whether there is a bit to describe the line as LED or GPIO, but even if there's not you can just stub-out the set_mux() and request_gpio_enable() callbacks. It shouldn't be too much effort. But I also haven't thought about it in great depth - it's a train-of-thought suggestion at the moment.

Cheers,

Andrew

Quoted 49 lines

Maybe a quick conference call might be useful?

Thanks,
Chris

Quoted 40 lines

Thanks,

C.

Quoted 35 lines

C.

Quoted 33 lines

Thanks
Chris

Quoted 30 lines
Quoted 30 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

             fan0: led@0 {

               label = "fan0";

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +12 -0
@@ -302,6 +334,26 @@
                reg = <3>;
                type = <PCA955X_TYPE_LED>;
            };
 > > > > > > +        fan0_pres_gpio: gpio@4 {
+            label = "fan0_presence";
+            reg = <4>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
 > > > > > > +        fan1_pres_gpio: gpio@5 {
+            label = "fan1_presence";
+            reg = <5>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
 > > > > > > +        fan2_pres_gpio: gpio@6 {
+            label = "fan2_presence";
+            reg = <6>;
+            type = <PCA955X_TYPE_GPIO>;
+        };
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+        fan3_pres_gpio: gpio@7 {

+            label = "fan3_presence";
+            reg = <7>;
+            type = <PCA955X_TYPE_GPIO>;
+        };

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

           front_fault: led@13 {

               label = "front-fault";
               default-state = "keep";

#9 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

In reply to Christopher Bostic
Quoted 96 lines · Christopher Bostic
Quoted 93 lines · Cédric Le Goater
Quoted 82 lines · Cédric Le Goater
Quoted 74 lines · Christopher Bostic
Quoted 72 lines · Cédric Le Goater
Quoted 57 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
   arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
   1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +27 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
           };
       };
   +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts

Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
+        };
+    };
+
       leds {
           compatible = "gpio-leds";
   @@ -277,6 +308,7 @@
           reg = <0x60>;
           #address-cells = <1>;
           #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

         gpio-controller;
Quoted 7 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

Quoted 7 lines

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled
device driver to properly probe the pca955x lines.

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

It fails indeed, but the fix you are proposing does not look right either.

Quoted 6 lines
Quoted 2 lines

Maybe we should fully define the pca9552 as a gpio controller and then define a gpio-leds and a gpio-keys-polled on top of it ?

Hi Cedric,

What would be entailed in fully defining the pca9552 as a gpio controller? Any other driver examples would help if you know of any.

See below for an example. Quickly tested on QEMU.

Quoted 9 lines

Currently I see that it has a struct gpio_chip embedded in its 955x chip structure and that it defines its various properties, .direction_input,
.direction_output, etc... The struct gpio_chip ngpio field is set to a
subset of pins that are not labeled as LEDS. Hence my added change to count LEDS towards total ngpio's. Given that the pins I'm interested in are 4-7 this falls outside the bounds of what the gpio chip considers total gpio
count. As a result gpio-keys-polled driver probe fails.

Maybe a quick conference call might be useful?

Sure if needed.

Thanks,

C.

From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ARM: dts: aspeed: witherspoon: add a gpio-keys-polled binding
Date: Fri, 05 May 2017 09:30:25 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change the current binding of the pca9552 device to be a GPIO expander and add on top of it a 'gpio-leds' binding to redefine the led pins of the pca9552. Finally add a 'gpio-keys-polled' binding.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  151 ++++++++++++++++++-----
 1 file changed, 123 insertions(+), 28 deletions(-)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +123 -28
Index: linux-openbmc-4.10.git/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
===================================================================
@@ -93,6 +93,77 @@
 		compatible = "iio-hwmon";
 		io-channels = <&bmp 1>;
 	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
+	pca_leds {
+		compatible = "gpio-leds";
+
+		fan0 {
+			label = "fan0";
+			default-state = "keep";
+			gpios = <&pca0 0 GPIO_ACTIVE_LOW>;
+		};
+		fan1 {
+			label = "fan1";
+			default-state = "keep";
+			gpios = <&pca0 1 GPIO_ACTIVE_LOW>;
+		};
+		fan2 {
+			label = "fan2";
+			default-state = "keep";
+			gpios = <&pca0 2 GPIO_ACTIVE_LOW>;
+		};
+		fan3 {
+			label = "fan3";
+			default-state = "keep";
+			gpios = <&pca0 3 GPIO_ACTIVE_LOW>;
+		};
+		front_fault {
+			label = "front-fault";
+			default-state = "keep";
+			gpios = <&pca0 13 GPIO_ACTIVE_LOW>;
+		};
+		front_power {
+			label = "front-power";
+			default-state = "keep";
+			gpios = <&pca0 14 GPIO_ACTIVE_LOW>;
+		};
+		front_id {
+			label = "front-id";
+			default-state = "keep";
+			gpios = <&pca0 15 GPIO_ACTIVE_LOW>;
+		};
+	};
 };
 
 #include "ibm-power9-cfam.dtsi"
@@ -280,48 +351,72 @@
 		reg = <0x60>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+                gpio-controller;
+		#gpio-cells = <2>;
 
-		fan0: led@0 {
-			label = "fan0";
-			default-state = "keep";
+		gpio@0 {
 			reg = <0>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		fan1: led@1 {
-			label = "fan1";
-			default-state = "keep";
+		gpio@1 {
 			reg = <1>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		fan2: led@2 {
-			label = "fan2";
-			default-state = "keep";
+		gpio@2 {
 			reg = <2>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		fan3: led@3 {
-			label = "fan3";
-			default-state = "keep";
+		gpio@3 {
 			reg = <3>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		front_fault: led@13 {
-			label = "front-fault";
-			default-state = "keep";
+		gpio@4 {
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@5 {
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@6 {
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@7 {
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@8 {
+			reg = <8>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@9 {
+			reg = <9>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@10 {
+			reg = <10>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@11 {
+			reg = <11>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@12 {
+			reg = <12>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@13 {
 			reg = <13>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		front_power: led@14 {
-			label = "front-power";
-			default-state = "keep";
+		gpio@14 {
 			reg = <14>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
-		front_id: led@15 {
-			label = "front-id";
-			default-state = "keep";
+		gpio@15 {
 			reg = <15>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
 		};
 	};
 };
#10 lore raw

Re: [PATCH linux dev-4.10 v6 1/2] ARM: dts: aspeed: Witherspoon add gpio-keys-polled for fan presence

Quoted 95 lines · Cédric Le Goater
Quoted 94 lines · Christopher Bostic
Quoted 92 lines · Cédric Le Goater
Quoted 81 lines · Cédric Le Goater
Quoted 73 lines · Christopher Bostic
Quoted 72 lines · Cédric Le Goater
Quoted 57 lines · Christopher Bostic

Add gpio-keys-polled node for pca955x fan presence lines. Add GPIO details to pca955x for the presence lines as well.

Polling period of 1 second determined to be the max acceptable value based on discussions with Brad Bishop and Matt Spinler. Tested with gpiomon program - verified.

---
v6 - Add gpio pin details for fan presence to pca955x node v5 - Fix gpio-keys-polled driver probe errors. Missing pca955x
gpio cells property and wrong format for poll-interval.
v4 - Add details regarding polling period to commit message. v3 - Remove 'autorepeat'
- Increase polling period to 1 second.
- Remove GPIO specifiers from pca955x in dev tree
v2 - Change 'linux,code' from a unique global value to a local one
for all the gpio-keys-polled devices.

---
    arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 52 ++++++++++++++++++++++++
    1 file changed, 52 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +27 -0
index 5afc03a..70328668 100644
@@ -56,6 +56,37 @@
            };
        };
    +    gpio-keys-polled {
+        compatible = "gpio-keys-polled";
+        #address-cells = <1>;
+        #size-cells = <0>;
+        poll-interval = <1000>;
+
+        fan0-presence {
+            label = "fan0-presence";
+            gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+            linux,code = <4>;
+        };
+
+        fan1-presence {
+            label = "fan1-presence";
+            gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+            linux,code = <5>;
+        };
+
+        fan2-presence {
+            label = "fan2-presence";
+            gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+            linux,code = <6>;
+        };
+
+        fan3-presence {
+            label = "fan3-presence";
+            gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+            linux,code = <7>;

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts

Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +4 -0
+        };
+    };
+
        leds {
            compatible = "gpio-leds";
    @@ -277,6 +308,7 @@
            reg = <0x60>;
            #address-cells = <1>;
            #size-cells = <0>;
+        #gpio-cells = <2>;

you should also add a :

          gpio-controller;
Quoted 7 lines
Quoted 3 lines

if you want to use the lines as GPIOs

C.

Hi Cedric,

If I add 'gpio-controller' here are you indicating that would not require any modifications I made to the leds-pca955x.c file?

Quoted 7 lines

yes.

Quoted 3 lines

I've tried that and found I still need that leds-pca955x.c change even if I add 'gpio-controller' attribute to get gpio-keys-polled
device driver to properly probe the pca955x lines.

OK. I will give it a try on a QEMU. Maybe there are some incompatibilities with the gpio-keys driver bindings

It fails indeed, but the fix you are proposing does not look right either.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Maybe we should fully define the pca9552 as a gpio controller and then define a gpio-leds and a gpio-keys-polled on top of it ?

Hi Cedric,

What would be entailed in fully defining the pca9552 as a gpio controller? Any other driver examples would help if you know of any.

See below for an example. Quickly tested on QEMU.

Hi Cedric

Thanks for the example. Will use this approach.

-Chris

Quoted 218 lines
Quoted 9 lines

Currently I see that it has a struct gpio_chip embedded in its 955x chip structure and that it defines its various properties, .direction_input,
.direction_output, etc... The struct gpio_chip ngpio field is set to a
subset of pins that are not labeled as LEDS. Hence my added change to count LEDS towards total ngpio's. Given that the pins I'm interested in are 4-7 this falls outside the bounds of what the gpio chip considers total gpio
count. As a result gpio-keys-polled driver probe fails.

Maybe a quick conference call might be useful?

Sure if needed.

Thanks,

C.

From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ARM: dts: aspeed: witherspoon: add a gpio-keys-polled binding
Date: Fri, 05 May 2017 09:30:25 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change the current binding of the pca9552 device to be a GPIO expander and add on top of it a 'gpio-leds' binding to redefine the led pins of the pca9552. Finally add a 'gpio-keys-polled' binding.

---
  arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  151 ++++++++++++++++++-----
  1 file changed, 123 insertions(+), 28 deletions(-)

Index: linux-openbmc-4.10.git/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
===================================================================

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +123 -28
@@ -93,6 +93,77 @@
  		compatible = "iio-hwmon";
  		io-channels = <&bmp 1>;
  	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <1000>;
+
+		fan0-presence {
+			label = "fan0-presence";
+			gpios = <&pca0 4 GPIO_ACTIVE_LOW>;
+			linux,code = <4>;
+		};
+
+		fan1-presence {
+			label = "fan1-presence";
+			gpios = <&pca0 5 GPIO_ACTIVE_LOW>;
+			linux,code = <5>;
+		};
+
+		fan2-presence {
+			label = "fan2-presence";
+			gpios = <&pca0 6 GPIO_ACTIVE_LOW>;
+			linux,code = <6>;
+		};
+
+		fan3-presence {
+			label = "fan3-presence";
+			gpios = <&pca0 7 GPIO_ACTIVE_LOW>;
+			linux,code = <7>;
+		};
+	};
+
+	pca_leds {
+		compatible = "gpio-leds";
+
+		fan0 {
+			label = "fan0";
+			default-state = "keep";
+			gpios = <&pca0 0 GPIO_ACTIVE_LOW>;
+		};
+		fan1 {
+			label = "fan1";
+			default-state = "keep";
+			gpios = <&pca0 1 GPIO_ACTIVE_LOW>;
+		};
+		fan2 {
+			label = "fan2";
+			default-state = "keep";
+			gpios = <&pca0 2 GPIO_ACTIVE_LOW>;
+		};
+		fan3 {
+			label = "fan3";
+			default-state = "keep";
+			gpios = <&pca0 3 GPIO_ACTIVE_LOW>;
+		};
+		front_fault {
+			label = "front-fault";
+			default-state = "keep";
+			gpios = <&pca0 13 GPIO_ACTIVE_LOW>;
+		};
+		front_power {
+			label = "front-power";
+			default-state = "keep";
+			gpios = <&pca0 14 GPIO_ACTIVE_LOW>;
+		};
+		front_id {
+			label = "front-id";
+			default-state = "keep";
+			gpios = <&pca0 15 GPIO_ACTIVE_LOW>;
+		};
+	};
  };
 
  #include "ibm-power9-cfam.dtsi"
@@ -280,48 +351,72 @@
  		reg = <0x60>;
  		#address-cells = <1>;
  		#size-cells = <0>;
+                gpio-controller;
+		#gpio-cells = <2>;
 
-		fan0: led@0 {
-			label = "fan0";
-			default-state = "keep";
+		gpio@0 {
  			reg = <0>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		fan1: led@1 {
-			label = "fan1";
-			default-state = "keep";
+		gpio@1 {
  			reg = <1>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		fan2: led@2 {
-			label = "fan2";
-			default-state = "keep";
+		gpio@2 {
  			reg = <2>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		fan3: led@3 {
-			label = "fan3";
-			default-state = "keep";
+		gpio@3 {
  			reg = <3>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		front_fault: led@13 {
-			label = "front-fault";
-			default-state = "keep";
+		gpio@4 {
+			reg = <4>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@5 {
+			reg = <5>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@6 {
+			reg = <6>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@7 {
+			reg = <7>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@8 {
+			reg = <8>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@9 {
+			reg = <9>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@10 {
+			reg = <10>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@11 {
+			reg = <11>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@12 {
+			reg = <12>;
+			type = <PCA955X_TYPE_GPIO>;
+		};
+		gpio@13 {
  			reg = <13>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		front_power: led@14 {
-			label = "front-power";
-			default-state = "keep";
+		gpio@14 {
  			reg = <14>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
-		front_id: led@15 {
-			label = "front-id";
-			default-state = "keep";
+		gpio@15 {
  			reg = <15>;
-			type = <PCA955X_TYPE_LED>;
+			type = <PCA955X_TYPE_GPIO>;
  		};
  	};
  };