pwm support incompatible with Armada 80x0/70x0 API is not only in
Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
platform. Fix check for pwm support appropriately.
Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
Signed-off-by: Pali Rohár <[email protected]>
---
drivers/gpio/gpio-mvebu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 2db19cd640a4..70a22b68c034 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -793,8 +793,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
u32 offset;
u32 set;
- if (of_device_is_compatible(mvchip->chip.of_node,
- "marvell,armada-370-gpio")) {
+ if (mvchip->soc_variant != MVEBU_GPIO_SOC_VARIANT_A8K) {
/*
* There are only two sets of PWM configuration registers for
* all the GPIO lines on those SoCs which this driver reserves
--
2.20.1
Armada 39x supports per CPU interrupts for gpios, like Armada XP.
So add compatible string "marvell,armadaxp-gpio" for Armada 39x GPIO nodes.
Driver gpio-mvebu.c which handles both pre-XP and XP variants already
provides support for per CPU interrupts on XP and newer variants.
Signed-off-by: Pali Rohár <[email protected]>
Fixes: d81a914fc630 ("ARM: dts: mvebu: armada-39x: add missing nodes describing GPIO's")
---
arch/arm/boot/dts/armada-39x.dtsi | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/armada-39x.dtsi b/arch/arm/boot/dts/armada-39x.dtsi
index e0b7c2099831..ef3a3859802c 100644
--- a/arch/arm/boot/dts/armada-39x.dtsi
+++ b/arch/arm/boot/dts/armada-39x.dtsi
@@ -213,7 +213,7 @@
};
gpio0: gpio@18100 {
- compatible = "marvell,orion-gpio";
+ compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
reg = <0x18100 0x40>;
ngpios = <32>;
gpio-controller;
@@ -227,7 +227,7 @@
};
gpio1: gpio@18140 {
- compatible = "marvell,orion-gpio";
+ compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
reg = <0x18140 0x40>;
ngpios = <28>;
gpio-controller;
--
2.20.1
On Thu, Jul 14, 2022 at 01:55:12PM +0200, Pali Roh?r wrote:
> pwm support incompatible with Armada 80x0/70x0 API is not only in
> Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
> platform. Fix check for pwm support appropriately.
>
> Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
> Signed-off-by: Pali Roh?r <[email protected]>
> ---
> drivers/gpio/gpio-mvebu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 2db19cd640a4..70a22b68c034 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -793,8 +793,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
> u32 offset;
> u32 set;
>
> - if (of_device_is_compatible(mvchip->chip.of_node,
> - "marvell,armada-370-gpio")) {
> + if (mvchip->soc_variant != MVEBU_GPIO_SOC_VARIANT_A8K) {
> /*
> * There are only two sets of PWM configuration registers for
> * all the GPIO lines on those SoCs which this driver reserves
The current code is:
if (of_device_is_compatible(mvchip->chip.of_node,
"marvell,armada-370-gpio")) {
/*
* There are only two sets of PWM configuration registers for
* all the GPIO lines on those SoCs which this driver reserves
* for the first two GPIO chips. So if the resource is missing
* we can't treat it as an error.
*/
if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
return 0;
offset = 0;
} else if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
int ret = of_property_read_u32(dev->of_node,
"marvell,pwm-offset", &offset);
if (ret < 0)
return 0;
} else {
return 0;
}
With your change, don't we end up with:
if (foo)
.....
else if (!foo)
.....
else
.....
The static analysers are going to complain about this.
Andrew
Hi Pali,
On Thu, Jul 14 2022, Pali Rohár wrote:
> pwm support incompatible with Armada 80x0/70x0 API is not only in
> Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
> platform. Fix check for pwm support appropriately.
>
> Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
> Signed-off-by: Pali Rohár <[email protected]>
> ---
> drivers/gpio/gpio-mvebu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 2db19cd640a4..70a22b68c034 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -793,8 +793,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
> u32 offset;
> u32 set;
>
> - if (of_device_is_compatible(mvchip->chip.of_node,
> - "marvell,armada-370-gpio")) {
> + if (mvchip->soc_variant != MVEBU_GPIO_SOC_VARIANT_A8K) {
The 'if' condition that follow the 'else' below become always true:
} else if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
I would suggest to keep the '== MVEBU_GPIO_SOC_VARIANT_A8K' condition,
and reverse the if/else order, because positive logic is more readable.
There is also another 'else' below that is dead code with this patch.
baruch
> /*
> * There are only two sets of PWM configuration registers for
> * all the GPIO lines on those SoCs which this driver reserves
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
pwm support incompatible with Armada 80x0/70x0 API is not only in
Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
platform. Fix check for pwm support appropriately.
Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
Signed-off-by: Pali Rohár <[email protected]>
---
Changes in v2:
* reverse the if/else order per Baruch request
---
drivers/gpio/gpio-mvebu.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 2db19cd640a4..de1e7a1a76f2 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -793,8 +793,12 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
u32 offset;
u32 set;
- if (of_device_is_compatible(mvchip->chip.of_node,
- "marvell,armada-370-gpio")) {
+ if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
+ int ret = of_property_read_u32(dev->of_node,
+ "marvell,pwm-offset", &offset);
+ if (ret < 0)
+ return 0;
+ } else {
/*
* There are only two sets of PWM configuration registers for
* all the GPIO lines on those SoCs which this driver reserves
@@ -804,13 +808,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
return 0;
offset = 0;
- } else if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
- int ret = of_property_read_u32(dev->of_node,
- "marvell,pwm-offset", &offset);
- if (ret < 0)
- return 0;
- } else {
- return 0;
}
if (IS_ERR(mvchip->clk))
--
2.20.1
Armada 39x supports per CPU interrupts for gpios, like Armada XP.
So add compatible string "marvell,armadaxp-gpio" for Armada 39x GPIO nodes.
Driver gpio-mvebu.c which handles both pre-XP and XP variants already
provides support for per CPU interrupts on XP and newer variants.
Signed-off-by: Pali Rohár <[email protected]>
Fixes: d81a914fc630 ("ARM: dts: mvebu: armada-39x: add missing nodes describing GPIO's")
---
arch/arm/boot/dts/armada-39x.dtsi | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/armada-39x.dtsi b/arch/arm/boot/dts/armada-39x.dtsi
index e0b7c2099831..ef3a3859802c 100644
--- a/arch/arm/boot/dts/armada-39x.dtsi
+++ b/arch/arm/boot/dts/armada-39x.dtsi
@@ -213,7 +213,7 @@
};
gpio0: gpio@18100 {
- compatible = "marvell,orion-gpio";
+ compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
reg = <0x18100 0x40>;
ngpios = <32>;
gpio-controller;
@@ -227,7 +227,7 @@
};
gpio1: gpio@18140 {
- compatible = "marvell,orion-gpio";
+ compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
reg = <0x18140 0x40>;
ngpios = <28>;
gpio-controller;
--
2.20.1
Armada 38x and Armada 39x should use compatible string "marvel,armadaxp-gpio".
Signed-off-by: Pali Rohár <[email protected]>
---
Documentation/devicetree/bindings/gpio/gpio-mvebu.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mvebu.txt b/Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
index 0fc6700ed800..3bc8f5caf328 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
@@ -10,7 +10,7 @@ Required properties:
should be used for the Discovery MV78200.
"marvel,armadaxp-gpio" should be used for all Armada XP SoCs
- (MV78230, MV78260, MV78460).
+ (MV78230, MV78260, MV78460), Armada 38x and Armada 39x.
"marvell,armada-8k-gpio" should be used for the Armada 7K and 8K
SoCs (either from AP or CP), see
--
2.20.1
On Thu, 14 Jul 2022 20:33:26 +0200, Pali Roh?r wrote:
> Armada 38x and Armada 39x should use compatible string "marvel,armadaxp-gpio".
>
> Signed-off-by: Pali Roh?r <[email protected]>
> ---
> Documentation/devicetree/bindings/gpio/gpio-mvebu.txt | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Acked-by: Rob Herring <[email protected]>
PING?
On Thursday 14 July 2022 20:33:25 Pali Rohár wrote:
> pwm support incompatible with Armada 80x0/70x0 API is not only in
> Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
> platform. Fix check for pwm support appropriately.
>
> Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
> Signed-off-by: Pali Rohár <[email protected]>
>
> ---
> Changes in v2:
> * reverse the if/else order per Baruch request
> ---
> drivers/gpio/gpio-mvebu.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 2db19cd640a4..de1e7a1a76f2 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -793,8 +793,12 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
> u32 offset;
> u32 set;
>
> - if (of_device_is_compatible(mvchip->chip.of_node,
> - "marvell,armada-370-gpio")) {
> + if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
> + int ret = of_property_read_u32(dev->of_node,
> + "marvell,pwm-offset", &offset);
> + if (ret < 0)
> + return 0;
> + } else {
> /*
> * There are only two sets of PWM configuration registers for
> * all the GPIO lines on those SoCs which this driver reserves
> @@ -804,13 +808,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
> if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
> return 0;
> offset = 0;
> - } else if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) {
> - int ret = of_property_read_u32(dev->of_node,
> - "marvell,pwm-offset", &offset);
> - if (ret < 0)
> - return 0;
> - } else {
> - return 0;
> }
>
> if (IS_ERR(mvchip->clk))
> --
> 2.20.1
>
On Thu, Jul 14, 2022 at 8:33 PM Pali Rohár <[email protected]> wrote:
>
> pwm support incompatible with Armada 80x0/70x0 API is not only in
> Armada 370, but also in Armada XP, 38x and 39x. So basically every non-A8K
> platform. Fix check for pwm support appropriately.
>
> Fixes: 85b7d8abfec7 ("gpio: mvebu: add pwm support for Armada 8K/7K")
> Signed-off-by: Pali Rohár <[email protected]>
>
> ---
> Changes in v2:
> * reverse the if/else order per Baruch request
Applied, thanks!
Bart
Pali Rohár <[email protected]> writes:
> Armada 39x supports per CPU interrupts for gpios, like Armada XP.
>
> So add compatible string "marvell,armadaxp-gpio" for Armada 39x GPIO nodes.
>
> Driver gpio-mvebu.c which handles both pre-XP and XP variants already
> provides support for per CPU interrupts on XP and newer variants.
>
> Signed-off-by: Pali Rohár <[email protected]>
> Fixes: d81a914fc630 ("ARM: dts: mvebu: armada-39x: add missing nodes describing GPIO's")
Applied on mvebu/dt
Thanks,
Gregory
> ---
> arch/arm/boot/dts/armada-39x.dtsi | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/dts/armada-39x.dtsi b/arch/arm/boot/dts/armada-39x.dtsi
> index e0b7c2099831..ef3a3859802c 100644
> --- a/arch/arm/boot/dts/armada-39x.dtsi
> +++ b/arch/arm/boot/dts/armada-39x.dtsi
> @@ -213,7 +213,7 @@
> };
>
> gpio0: gpio@18100 {
> - compatible = "marvell,orion-gpio";
> + compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
> reg = <0x18100 0x40>;
> ngpios = <32>;
> gpio-controller;
> @@ -227,7 +227,7 @@
> };
>
> gpio1: gpio@18140 {
> - compatible = "marvell,orion-gpio";
> + compatible = "marvell,armadaxp-gpio", "marvell,orion-gpio";
> reg = <0x18140 0x40>;
> ngpios = <28>;
> gpio-controller;
> --
> 2.20.1
>
--
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com