drivers/leds: Add GPIO keys for PCA955x and ast24/2500 gpio
Subsystems (3)
PATCH 1/1 drivers/leds: Add GPIO keys for PCA955x and ast24/2500 gpio
Define gpio keys for power supply presence, ucd alert, and fan presence.
Link pca955x to parent i2c interrupt controller so that new pca955x gpio keys for fan presence haning off of pca955x can be defined.
--- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 77 ++++++++++++++++++++++++ drivers/leds/leds-pca955x.c | 64 ++++++++++++++++++++ 2 files changed, 141 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +77 -0
@@ -46,6 +46,48 @@ gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_LOW>; linux,code = <ASPEED_GPIO(J, 2)>; }; + + ps0-presence { + label = "ps0-presence"; + gpios = <&gpio ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(P, 7)>; + }; + + ps1-presence { + label = "ps1-presence"; + gpios = <&gpio ASPEED_GPIO(N, 0) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(N, 0)>; + }; + + ucd-alert { + label = "ucd-alert"; + gpios = <&gpio ASPEED_GPIO(I, 2) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(I, 2)>; + }; + + fan0-presence { + label = "fan0-presence"; + gpios = <&pca0 0 GPIO_ACTIVE_LOW>; + linux,code = <0>; + }; + + fan1-presence { + label = "fan1-presence"; + gpios = <&pca0 1 GPIO_ACTIVE_LOW>; + linux,code = <1>; + }; + + fan2-presence { + label = "fan2-presence"; + gpios = <&pca0 2 GPIO_ACTIVE_LOW>; + linux,code = <2>; + }; + + fan3-presence { + label = "fan3-presence"; + gpios = <&pca0 3 GPIO_ACTIVE_LOW>; + linux,code = <3>; + }; }; leds {
@@ -203,6 +245,41 @@ compatible = "infineon,dps310"; reg = <0x76>; }; + + pca0: pca9552@60 { + compatible = "nxp,pca9552"; + reg = <0x60>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + interrupt-parent = <&i2c_ic>; + interrupts = <3>; + + gpio-line-names = "FAN0_PRESENSE_N", "FAN1_PRESENSE_N", + "FAN2_PRESENSE_N", "FAN3_PRESENSE_N"; + + 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>; + }; + }; }; &i2c4 {
drivers/leds/leds-pca955x.c +64 -0
82 lines not on this page · raw message
Signature · 1 line
1.8.2.2
Joel Stanley
maintainerQuoted 9 lines · Christopher Bostic
Define gpio keys for power supply presence, ucd alert, and fan presence.
Link pca955x to parent i2c interrupt controller so that new pca955x gpio keys for fan presence haning off of pca955x can be defined.
Signed-off-by Christopher Bostic <[email protected]>--- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 77 ++++++++++++++++++++++++ drivers/leds/leds-pca955x.c | 64 ++++++++++++++++++++
The change to the source file and the .dts should be in separate patches.
Quoted 18 lines
2 files changed, 141 insertions(+)arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +8
-0@@ -46,6 +46,48 @@ gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_LOW>; linux,code = <ASPEED_GPIO(J, 2)>; }; + + ps0-presence { + label = "ps0-presence"; + gpios = <&gpio ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(P, 7)>; + }; + + ps1-presence {
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts line 66
Quoted 10 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +10
-0+ label = "ps1-presence"; + gpios = <&gpio ASPEED_GPIO(N, 0) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(N, 0)>; + }; + + ucd-alert { + label = "ucd-alert"; + gpios = <&gpio ASPEED_GPIO(I, 2) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(I, 2)>; + };
I don't think this is correct. Isn't the alert line part of the sbmus device?
Quoted 90 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +59
-0+ + fan0-presence { + label = "fan0-presence"; + gpios = <&pca0 0 GPIO_ACTIVE_LOW>; + linux,code = <0>; + }; + + fan1-presence { + label = "fan1-presence"; + gpios = <&pca0 1 GPIO_ACTIVE_LOW>; + linux,code = <1>; + }; + + fan2-presence { + label = "fan2-presence"; + gpios = <&pca0 2 GPIO_ACTIVE_LOW>; + linux,code = <2>; + }; + + fan3-presence { + label = "fan3-presence"; + gpios = <&pca0 3 GPIO_ACTIVE_LOW>; + linux,code = <3>; + }; }; leds {@@ -203,6 +245,41 @@ compatible = "infineon,dps310"; reg = <0x76>; }; + + pca0: pca9552@60 { + compatible = "nxp,pca9552"; + reg = <0x60>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + interrupt-parent = <&i2c_ic>; + interrupts = <3>; + + gpio-line-names = "FAN0_PRESENSE_N", "FAN1_PRESENSE_N", + "FAN2_PRESENSE_N", "FAN3_PRESENSE_N"; + + 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>; + }; + }; }; &i2c4 {drivers/leds/leds-pca955x.c +6
-0@@ -52,6 +52,7 @@#include <linux/of.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/interrupt.h> #include <dt-bindings/leds/leds-pca955x.h> @@ -389,6 +390,66 @@ static int pca955x_gpio_direction_output(struct gpio_chip *gc, }#endif +static void pca955x_irq_mask (struct irq_data *d) +{ +} + +static void pca955x_irq_unmask (struct irq_data *d)
drivers/leds/leds-pca955x.c static int pca955x_gpio_direction_output(struct gpio_chip *gc, · line 407
Quoted 10 lines
drivers/leds/leds-pca955x.c +10
-0+{ +} + +static void pca955x_irq_bus_lock (struct irq_data *d) +{ +} + +static void pca955x_irq_bus_sync_unlock (struct irq_data *d) +{ +}
It looks like you sent a half-finished version.
Quoted 61 lines
drivers/leds/leds-pca955x.c +48
-1+ +static int pca955x_irq_set_type (struct irq_data *d,unsigned int type) +{ +return 0 ; +} + +static struct irq_chip pca955x_irq_chip = { + .name ="pca955x" , + .irq_mask = pca955x_irq_mask, + .irq_unmask = pca955x_irq_unmask, + .irq_bus_lock = pca955x_irq_bus_lock, + .irq_bus_sync_unlock = pca955x_irq_bus_sync_unlock, + .irq_set_type = pca955x_irq_set_type, +}; + +static int pca955x_irq_setup (struct pca955x *chip,int irq_base) +{ +struct i2c_client *client; +int ret; + +if (!chip) +return 0 ; + + client = chip->client; +if (!client) +return 0 ; + +if (client->irq && irq_base >=0 ) { + ret =gpiochip_irqchip_add_nested (&chip->gpio, + &pca955x_irq_chip, + irq_base, + handle_simple_irq, +IRQ_TYPE_NONE ); +if (ret) { +dev_err (&client->dev, +"could not connect irqchip to gpiochip\n" ); +return ret; + } +gpiochip_set_nested_irqchip (&chip->gpio, + &pca955x_irq_chip, + client->irq); + } +return 0 ; +} +static int pca955x_probe (struct i2c_client *client,const struct i2c_device_id *id) {@@ -543,6 +604,9 @@ static int pca955x_probe(struct i2c_client *client, } }#endif + err =pca955x_irq_setup (pca955x,0 ); +if (err) +return err;return 0 ; } --1.8.2.2
Quoted 4 lines · Joel Stanley
Quoted 2 lines · Christopher Bostic
Define gpio keys for power supply presence, ucd alert, and fan presence.
Quoted 8 lines
Quoted 7 lines
Link pca955x to parent i2c interrupt controller so that new pca955x gpio keys for fan presence haning off of pca955x can be defined.
Signed-off-by Christopher Bostic <[email protected]>--- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 77 ++++++++++++++++++++++++ drivers/leds/leds-pca955x.c | 64 ++++++++++++++++++++The change to the source file and the .dts should be in separate patches.
Will separate them.
Quoted 22 lines
Quoted 22 lines
2 files changed, 141 insertions(+)arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +11
-0@@ -46,6 +46,48 @@ gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_LOW>; linux,code = <ASPEED_GPIO(J, 2)>; }; + + ps0-presence { + label = "ps0-presence"; + gpios = <&gpio ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(P, 7)>; + }; + + ps1-presence { + label = "ps1-presence"; + gpios = <&gpio ASPEED_GPIO(N, 0) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(N, 0)>;
Quoted 8 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts line 66
Quoted 7 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +7
-0+ }; + + ucd-alert { + label = "ucd-alert"; + gpios = <&gpio ASPEED_GPIO(I, 2) GPIO_ACTIVE_LOW>; + linux,code = <ASPEED_GPIO(I, 2)>; + };I don't think this is correct. Isn't the alert line part of the sbmus device?
According to the Box Elder schematic revision 03232017 page 24 there is a line listed as 'BMC_UCD_ALERT_N' Connected to ast2500 GPIO I2 as an input. It appears this net is also connected to the smbus device. Maybe I'm referencing the wrong signal?
Quoted 85 lines
Quoted 85 lines
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +59
-0+ + fan0-presence { + label = "fan0-presence"; + gpios = <&pca0 0 GPIO_ACTIVE_LOW>; + linux,code = <0>; + }; + + fan1-presence { + label = "fan1-presence"; + gpios = <&pca0 1 GPIO_ACTIVE_LOW>; + linux,code = <1>; + }; + + fan2-presence { + label = "fan2-presence"; + gpios = <&pca0 2 GPIO_ACTIVE_LOW>; + linux,code = <2>; + }; + + fan3-presence { + label = "fan3-presence"; + gpios = <&pca0 3 GPIO_ACTIVE_LOW>; + linux,code = <3>; + }; }; leds {@@ -203,6 +245,41 @@ compatible = "infineon,dps310"; reg = <0x76>; }; + + pca0: pca9552@60 { + compatible = "nxp,pca9552"; + reg = <0x60>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + interrupt-parent = <&i2c_ic>; + interrupts = <3>; + + gpio-line-names = "FAN0_PRESENSE_N", "FAN1_PRESENSE_N", + "FAN2_PRESENSE_N", "FAN3_PRESENSE_N"; + + 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>; + }; + }; }; &i2c4 {drivers/leds/leds-pca955x.c +1
-0@@ -52,6 +52,7 @@#include <linux/of.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/interrupt.h> #include <dt-bindings/leds/leds-pca955x.h> @@ -389,6 +390,66 @@ static int pca955x_gpio_direction_output(struct gpio_chip *gc, }#endif
Quoted 16 lines
Quoted 5 lines
drivers/leds/leds-pca955x.c +5
-0+static void pca955x_irq_mask (struct irq_data *d) +{ +} + +static void pca955x_irq_unmask (struct irq_data *d)drivers/leds/leds-pca955x.c static int pca955x_gpio_direction_output(struct gpio_chip *gc, · line 407
Quoted 10 lines
drivers/leds/leds-pca955x.c +10
-0+{ +} + +static void pca955x_irq_bus_lock (struct irq_data *d) +{ +} + +static void pca955x_irq_bus_sync_unlock (struct irq_data *d) +{ +}It looks like you sent a half-finished version.
I added the basic capability required to register the GPIO key with interrupt support. The intent was to use the 'generic' interrupt support provided by the kernel, handle_simple_irq( ) etc... These functions were left undefined since its not clear what need there will be for them. Maybe the best choice is to not define them in that case?
Thanks,
Chris
Quoted 61 lines
Quoted 61 lines
drivers/leds/leds-pca955x.c +48
-1+ +static int pca955x_irq_set_type (struct irq_data *d,unsigned int type) +{ +return 0 ; +} + +static struct irq_chip pca955x_irq_chip = { + .name ="pca955x" , + .irq_mask = pca955x_irq_mask, + .irq_unmask = pca955x_irq_unmask, + .irq_bus_lock = pca955x_irq_bus_lock, + .irq_bus_sync_unlock = pca955x_irq_bus_sync_unlock, + .irq_set_type = pca955x_irq_set_type, +}; + +static int pca955x_irq_setup (struct pca955x *chip,int irq_base) +{ +struct i2c_client *client; +int ret; + +if (!chip) +return 0 ; + + client = chip->client; +if (!client) +return 0 ; + +if (client->irq && irq_base >=0 ) { + ret =gpiochip_irqchip_add_nested (&chip->gpio, + &pca955x_irq_chip, + irq_base, + handle_simple_irq, +IRQ_TYPE_NONE ); +if (ret) { +dev_err (&client->dev, +"could not connect irqchip to gpiochip\n" ); +return ret; + } +gpiochip_set_nested_irqchip (&chip->gpio, + &pca955x_irq_chip, + client->irq); + } +return 0 ; +} +static int pca955x_probe (struct i2c_client *client,const struct i2c_device_id *id) {@@ -543,6 +604,9 @@ static int pca955x_probe(struct i2c_client *client, } }#endif + err =pca955x_irq_setup (pca955x,0 ); +if (err) +return err;return 0 ; } --1.8.2.2