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
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
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
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
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
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
© 2016 - 2026 Red Hat, Inc.