* [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode
@ 2024-10-12 2:56 Florian Fainelli
2024-10-12 2:56 ` [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Florian Fainelli @ 2024-10-12 2:56 UTC (permalink / raw)
To: linux-kernel
Cc: Florian Fainelli, Uwe Kleine-König, Rob Herring,
Krzysztof Kozlowski, Conor Dooley,
Broadcom internal kernel review list, Thierry Reding,
open list:PWM SUBSYSTEM,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen
This patch series updates the pwm-brcmstb driver to not assume an
open-drain mode, but instead get that sort of configuration from Device
Tree using the 'open-drain' property.
Florian Fainelli (2):
dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property
pwm: brcmstb: Do not assume open drain configuration
.../devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml | 6 ++++++
drivers/pwm/pwm-brcmstb.c | 7 +++++--
2 files changed, 11 insertions(+), 2 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-12 2:56 [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Florian Fainelli @ 2024-10-12 2:56 ` Florian Fainelli 2024-10-15 16:32 ` Rob Herring 2024-10-12 2:56 ` [PATCH 2/2] pwm: brcmstb: Do not assume open drain configuration Florian Fainelli 2024-10-14 20:05 ` [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Uwe Kleine-König 2 siblings, 1 reply; 10+ messages in thread From: Florian Fainelli @ 2024-10-12 2:56 UTC (permalink / raw) To: linux-kernel Cc: Florian Fainelli, Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen Document the 'open-drain' property that allows configuring the PWM controller outputs in open drain versus totem pole. Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> --- Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml index 119de3d7f9dd..12851c43a612 100644 --- a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml +++ b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml @@ -25,6 +25,12 @@ properties: clocks: maxItems: 1 + open-drain: + type: boolean + description: + Configure the outputs with open-drain structure, if omitted totem pole + structure is used. + required: - compatible - reg -- 2.34.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-12 2:56 ` [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property Florian Fainelli @ 2024-10-15 16:32 ` Rob Herring 2024-10-15 17:07 ` Florian Fainelli 0 siblings, 1 reply; 10+ messages in thread From: Rob Herring @ 2024-10-15 16:32 UTC (permalink / raw) To: Florian Fainelli Cc: linux-kernel, Uwe Kleine-König, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen On Fri, Oct 11, 2024 at 07:56:02PM -0700, Florian Fainelli wrote: > Document the 'open-drain' property that allows configuring the PWM > controller outputs in open drain versus totem pole. > > Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> > --- > Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml > index 119de3d7f9dd..12851c43a612 100644 > --- a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml > +++ b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml > @@ -25,6 +25,12 @@ properties: > clocks: > maxItems: 1 > > + open-drain: > + type: boolean > + description: > + Configure the outputs with open-drain structure, if omitted totem pole > + structure is used. > + There's one other PWM with 'open-drain' so move the definition to pwm.yaml. Alternatively, 'drive-open-drain' is a much more commonly used variation. Another thing to consider is for any PWM controller with more than 1 output, you might want this to be per output and therefore should be a flag in the cells. Rob ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-15 16:32 ` Rob Herring @ 2024-10-15 17:07 ` Florian Fainelli 2024-10-29 10:44 ` Uwe Kleine-König 0 siblings, 1 reply; 10+ messages in thread From: Florian Fainelli @ 2024-10-15 17:07 UTC (permalink / raw) To: Rob Herring, Florian Fainelli Cc: linux-kernel, Uwe Kleine-König, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen On 10/15/24 09:32, Rob Herring wrote: > On Fri, Oct 11, 2024 at 07:56:02PM -0700, Florian Fainelli wrote: >> Document the 'open-drain' property that allows configuring the PWM >> controller outputs in open drain versus totem pole. >> >> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> >> --- >> Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml >> index 119de3d7f9dd..12851c43a612 100644 >> --- a/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml >> +++ b/Documentation/devicetree/bindings/pwm/brcm,bcm7038-pwm.yaml >> @@ -25,6 +25,12 @@ properties: >> clocks: >> maxItems: 1 >> >> + open-drain: >> + type: boolean >> + description: >> + Configure the outputs with open-drain structure, if omitted totem pole >> + structure is used. >> + > > There's one other PWM with 'open-drain' so move the definition to > pwm.yaml. Ah indeed, there is one now, great. > > Alternatively, 'drive-open-drain' is a much more commonly used > variation. That name works just as well. > > Another thing to consider is for any PWM controller with more than > 1 output, you might want this to be per output and therefore should be > a flag in the cells. Yes, that is a good point, this controller has two channels, so it seems like increasing the #pwm-cells might be the way to go. Thanks! -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-15 17:07 ` Florian Fainelli @ 2024-10-29 10:44 ` Uwe Kleine-König 2024-10-29 16:03 ` Florian Fainelli 0 siblings, 1 reply; 10+ messages in thread From: Uwe Kleine-König @ 2024-10-29 10:44 UTC (permalink / raw) To: Florian Fainelli Cc: Rob Herring, Florian Fainelli, linux-kernel, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen [-- Attachment #1: Type: text/plain, Size: 1057 bytes --] Hello, On Tue, Oct 15, 2024 at 10:07:10AM -0700, Florian Fainelli wrote: > On 10/15/24 09:32, Rob Herring wrote: > > Another thing to consider is for any PWM controller with more than > > 1 output, you might want this to be per output and therefore should be > > a flag in the cells. > > Yes, that is a good point, this controller has two channels, so it seems > like increasing the #pwm-cells might be the way to go. So the idea is something like: diff --git a/include/dt-bindings/pwm/pwm.h b/include/dt-bindings/pwm/pwm.h index ab9a077e3c7d..d18b006a7399 100644 --- a/include/dt-bindings/pwm/pwm.h +++ b/include/dt-bindings/pwm/pwm.h @@ -11,5 +11,6 @@ #define _DT_BINDINGS_PWM_PWM_H #define PWM_POLARITY_INVERTED (1 << 0) +#define PWM_OUTPUT_OPEN_DRAIN (1 << 1) #endif and then add support for that to the core and drivers? There is some intersection with pinctrl (depending on hardware). I wonder if abstracting this somehow using the typical pinctrl properties would be a saner option?? Best regards Uwe [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-29 10:44 ` Uwe Kleine-König @ 2024-10-29 16:03 ` Florian Fainelli 2024-11-28 11:35 ` Uwe Kleine-König 0 siblings, 1 reply; 10+ messages in thread From: Florian Fainelli @ 2024-10-29 16:03 UTC (permalink / raw) To: Uwe Kleine-König, Florian Fainelli Cc: Rob Herring, linux-kernel, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen On 10/29/24 03:44, Uwe Kleine-König wrote: > Hello, > > On Tue, Oct 15, 2024 at 10:07:10AM -0700, Florian Fainelli wrote: >> On 10/15/24 09:32, Rob Herring wrote: >>> Another thing to consider is for any PWM controller with more than >>> 1 output, you might want this to be per output and therefore should be >>> a flag in the cells. >> >> Yes, that is a good point, this controller has two channels, so it seems >> like increasing the #pwm-cells might be the way to go. > > So the idea is something like: > > diff --git a/include/dt-bindings/pwm/pwm.h b/include/dt-bindings/pwm/pwm.h > index ab9a077e3c7d..d18b006a7399 100644 > --- a/include/dt-bindings/pwm/pwm.h > +++ b/include/dt-bindings/pwm/pwm.h > @@ -11,5 +11,6 @@ > #define _DT_BINDINGS_PWM_PWM_H > > #define PWM_POLARITY_INVERTED (1 << 0) > +#define PWM_OUTPUT_OPEN_DRAIN (1 << 1) > > #endif > > and then add support for that to the core and drivers? There is some > intersection with pinctrl (depending on hardware). I wonder if > abstracting this somehow using the typical pinctrl properties would be a > saner option?? But what if the pin is not managed by a pinctrl provider? I have started going the route of implementing the PWM_OUTPUT_OPEN_DRAIN bit as an additional specifier in the #pwm-cells, but I am not sure to what extent this should be allowed to be changed at runtime. -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property 2024-10-29 16:03 ` Florian Fainelli @ 2024-11-28 11:35 ` Uwe Kleine-König 0 siblings, 0 replies; 10+ messages in thread From: Uwe Kleine-König @ 2024-11-28 11:35 UTC (permalink / raw) To: Florian Fainelli Cc: Florian Fainelli, Rob Herring, linux-kernel, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen, Linus Walleij, linux-gpio [-- Attachment #1: Type: text/plain, Size: 2414 bytes --] Hello Florian, [adding Linus and linux-gpio to Cc:] On Tue, Oct 29, 2024 at 09:03:57AM -0700, Florian Fainelli wrote: > On 10/29/24 03:44, Uwe Kleine-König wrote: > > On Tue, Oct 15, 2024 at 10:07:10AM -0700, Florian Fainelli wrote: > > > On 10/15/24 09:32, Rob Herring wrote: > > > > Another thing to consider is for any PWM controller with more than > > > > 1 output, you might want this to be per output and therefore should be > > > > a flag in the cells. > > > > > > Yes, that is a good point, this controller has two channels, so it seems > > > like increasing the #pwm-cells might be the way to go. > > > > So the idea is something like: > > > > diff --git a/include/dt-bindings/pwm/pwm.h b/include/dt-bindings/pwm/pwm.h > > index ab9a077e3c7d..d18b006a7399 100644 > > --- a/include/dt-bindings/pwm/pwm.h > > +++ b/include/dt-bindings/pwm/pwm.h > > @@ -11,5 +11,6 @@ > > #define _DT_BINDINGS_PWM_PWM_H > > #define PWM_POLARITY_INVERTED (1 << 0) > > +#define PWM_OUTPUT_OPEN_DRAIN (1 << 1) > > #endif > > > > and then add support for that to the core and drivers? There is some > > intersection with pinctrl (depending on hardware). I wonder if > > abstracting this somehow using the typical pinctrl properties would be a > > saner option?? > > But what if the pin is not managed by a pinctrl provider? Then create one? If that's the PWM itself that is the pinctrl device it would look as follows: pwm@f0408000 { compatible = "brcm,bcm7038-pwm"; pinctrl-0 = <&pwm_pins>; reg = <0xf0408000 0x28>; #pwm-cells = <2>; #pinctrl-cells = <0>; clocks = <&upg_fixed>; pinctrl { pwm_pins: pwm-pins { pins = "A", "B"; drive-open-drain; }; }; }; Maybe this is difficult if there is a pinctrl that configures the output as "PWM" and then there is that additional register in the PWM IP to make this pin open drain? One could just use pinctrl-0 = <&pwm_pins>, <&system_pinctrl_pwm>; then. Not entirely sure this is overengineered, but the dt representation would be nice (IMHO). Thoughts? > I have started > going the route of implementing the PWM_OUTPUT_OPEN_DRAIN bit as an > additional specifier in the #pwm-cells, but I am not sure to what extent > this should be allowed to be changed at runtime. I would not expect that the open-drainness needs to change at runtime. Best regards Uwe [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] pwm: brcmstb: Do not assume open drain configuration 2024-10-12 2:56 [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Florian Fainelli 2024-10-12 2:56 ` [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property Florian Fainelli @ 2024-10-12 2:56 ` Florian Fainelli 2024-10-14 20:05 ` [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Uwe Kleine-König 2 siblings, 0 replies; 10+ messages in thread From: Florian Fainelli @ 2024-10-12 2:56 UTC (permalink / raw) To: linux-kernel Cc: Florian Fainelli, Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen Read the 'open-drain' property to determine whether the PWM controller output(s) should be configured in open-drain versus totem pole mode. Fixes: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support") Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> --- drivers/pwm/pwm-brcmstb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c index 0fdeb0b2dbf3..b7cecd36ed57 100644 --- a/drivers/pwm/pwm-brcmstb.c +++ b/drivers/pwm/pwm-brcmstb.c @@ -55,6 +55,7 @@ struct brcmstb_pwm { void __iomem *base; struct clk *clk; struct pwm_chip chip; + bool open_drain; }; static inline u32 brcmstb_pwm_readl(struct brcmstb_pwm *p, @@ -176,6 +177,7 @@ static int brcmstb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, static inline void brcmstb_pwm_enable_set(struct brcmstb_pwm *p, unsigned int channel, bool enable) { + u32 oe_mask = p->open_drain ? CTRL_OPENDRAIN : 0; unsigned int shift = channel * CTRL_CHAN_OFFS; u32 value; @@ -183,9 +185,9 @@ static inline void brcmstb_pwm_enable_set(struct brcmstb_pwm *p, if (enable) { value &= ~(CTRL_OEB << shift); - value |= (CTRL_START | CTRL_OPENDRAIN) << shift; + value |= (CTRL_START | oe_mask) << shift; } else { - value &= ~((CTRL_START | CTRL_OPENDRAIN) << shift); + value &= ~((CTRL_START | oe_mask) << shift); value |= CTRL_OEB << shift; } @@ -244,6 +246,7 @@ static int brcmstb_pwm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, p); + p->open_drain = device_property_read_bool(&pdev->dev, "open-drain"); p->chip.dev = &pdev->dev; p->chip.ops = &brcmstb_pwm_ops; p->chip.npwm = 2; -- 2.34.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode 2024-10-12 2:56 [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Florian Fainelli 2024-10-12 2:56 ` [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property Florian Fainelli 2024-10-12 2:56 ` [PATCH 2/2] pwm: brcmstb: Do not assume open drain configuration Florian Fainelli @ 2024-10-14 20:05 ` Uwe Kleine-König 2024-10-16 7:09 ` Krzysztof Kozlowski 2 siblings, 1 reply; 10+ messages in thread From: Uwe Kleine-König @ 2024-10-14 20:05 UTC (permalink / raw) To: Florian Fainelli Cc: linux-kernel, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen [-- Attachment #1: Type: text/plain, Size: 590 bytes --] Hello Florian, On Fri, Oct 11, 2024 at 07:56:01PM -0700, Florian Fainelli wrote: > This patch series updates the pwm-brcmstb driver to not assume an > open-drain mode, but instead get that sort of configuration from Device > Tree using the 'open-drain' property. Just for me to be sure to understand correctly: A kernel without your patch #2 behaves identical to a kernel with that patch if the open-drain property is present, right? It's not clear to me why totem-pole is the better default and the commit logs don't justify the updated default. Can you improve here? Best regards Uwe [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode 2024-10-14 20:05 ` [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Uwe Kleine-König @ 2024-10-16 7:09 ` Krzysztof Kozlowski 0 siblings, 0 replies; 10+ messages in thread From: Krzysztof Kozlowski @ 2024-10-16 7:09 UTC (permalink / raw) To: Uwe Kleine-König Cc: Florian Fainelli, linux-kernel, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Broadcom internal kernel review list, Thierry Reding, open list:PWM SUBSYSTEM, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE, justin.chen On Mon, Oct 14, 2024 at 10:05:40PM +0200, Uwe Kleine-König wrote: > Hello Florian, > > On Fri, Oct 11, 2024 at 07:56:01PM -0700, Florian Fainelli wrote: > > This patch series updates the pwm-brcmstb driver to not assume an > > open-drain mode, but instead get that sort of configuration from Device > > Tree using the 'open-drain' property. > > Just for me to be sure to understand correctly: A kernel without your > patch #2 behaves identical to a kernel with that patch if the open-drain > property is present, right? I don't think it does. Patch #2 breaks the ABI, IMO. > > It's not clear to me why totem-pole is the better default and the commit > logs don't justify the updated default. Can you improve here? > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-11-28 11:35 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-12 2:56 [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Florian Fainelli 2024-10-12 2:56 ` [PATCH 1/2] dt-bindings: pwm: brcm,bcm7038: Document the 'open-drain' property Florian Fainelli 2024-10-15 16:32 ` Rob Herring 2024-10-15 17:07 ` Florian Fainelli 2024-10-29 10:44 ` Uwe Kleine-König 2024-10-29 16:03 ` Florian Fainelli 2024-11-28 11:35 ` Uwe Kleine-König 2024-10-12 2:56 ` [PATCH 2/2] pwm: brcmstb: Do not assume open drain configuration Florian Fainelli 2024-10-14 20:05 ` [PATCH 0/2] pwm: brcmstb: Support configurable open-drain mode Uwe Kleine-König 2024-10-16 7:09 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).