public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Jander <david@protonic.nl>
To: "Uwe Kleine-König" <ukleinek@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	Nuno Sa <nuno.sa@analog.com>, Jonathan Cameron <jic23@kernel.org>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	linux-pwm@vger.kernel.org
Subject: Re: [RFC PATCH 7/7] dt-bindings: motion: Add motion-simple-pwm bindings
Date: Mon, 3 Mar 2025 12:40:34 +0100	[thread overview]
Message-ID: <20250303124034.726ba698@erd003.prtnl> (raw)
In-Reply-To: <tm57fsmijq4t4y4dpmtss63ekzpm5oefir5tz4aioxq5dx4or6@lgoqjpxc3axh>


Dear Uwe,

Thanks for chiming in!

On Fri, 28 Feb 2025 16:18:05 +0100
Uwe Kleine-König <ukleinek@kernel.org> wrote:

> Hey David,
> 
> On Fri, Feb 28, 2025 at 11:09:31AM +0100, David Jander wrote:
> > On Fri, 28 Feb 2025 10:37:48 +0100
> > Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >   
> > > On 28/02/2025 10:22, David Jander wrote:  
> > > >     
> > > >>> +
> > > >>> +  motion,pwm-inverted:
> > > >>> +    $ref: /schemas/types.yaml#/definitions/flag      
> > > >>
> > > >> And PWM flag does not work?    
> > > > 
> > > > I have seen PWM controllers that don't seem to support the
> > > > PWM_POLARITY_INVERTED flag and those where it just doesn't work. Should all    
> > > 
> > > 
> > > Shouldn't the controllers be fixed? Or let's rephrase the question: why
> > > only this PWM consumer needs this property and none of others need it?  
> > 
> > CCing Uwe Kleine-Koenig and linux-pwm mailing list.
> > 
> > I know that at least in kernel 6.11 the pwm-stm32.c PWM driver doesn't
> > properly invert the PWM signal when specifying PWM_POLARITY_INVERTED. I agree
> > this is a probably bug that needs fixing if still present in 6.14-rc. Besides
> > that, if linux-pwm agrees that every single PWM driver _must_ properly support
> > this flag, I will drop this consumer flag an start fixing broken PWM drivers
> > that I encounter. I agree that it makes more sense this way, but I wanted to
> > be sure.  
> 
> Some hardwares cannot support PWM_POLARITY_INVERTED. Affected drivers
> include:
> 
> 	pwm-adp5585
> 	pwm-ntxec
> 	pwm-raspberrypi-poe
> 	pwm-rz-mtu3 (software limitation only)
> 	pwm-sunplus
> 	pwm-twl-led (not completely sure, that one is strange)
> 
> . ISTR that there is a driver that does only support inverted polarity,
> but I don't find it. For an overview I recommend reading through the
> output of:
> 
> 	for f in drivers/pwm/pwm-*; do
> 		echo $f;
> 		sed -rn '/Limitations:/,/\*\/?$/p' $f;
> 		echo;
> 	done | less
> 
> . (Note not all drivers have commentary in the right format to unveil
> their limitations.)
> 
> For most use-cases you can just do
> 
> 	.duty_cycle = .period - .duty_cycle

Yes, that is exactly what the relevant code in motion/simple-pwm.c does when
the "pwm-inverted" flag is present in the DT node.

> instead of inverting polarity, but there is no abstraction in the PWM
> bindings for that and also no helpers in the PWM framework. The problem
> is more or less ignored, so if you have a device with
> 
> 	pwms = <&pwm0 0 PWM_POLARITY_INVERTED>;
> 
> and the PWM chip in question doesn't support that, the pwm API functions
> will fail. So the system designer better makes sure that the PWM
> hardware can cope with the needed polarity.

Thanks for clarifying this!

@Krzysztof, do you think that given this situation it is acceptable to include
the "pwm-inverted" flag in the dt-schema of the simple PWM motor driver?

The need for an inverted PWM signal is something very common in the case of
H-bridge motor drivers, where the PWM signal represents the actual logical
output level of each of the two halves of the bridge. Often the high-side
switches are used as the free-wheel position, so that 100% duty-cycle on both
channels is actually standstill, while 0% duty-cycle on one channel is full
speed in either direction. This isn't always the case though, hence the
importance for this to be able to be selected.

Best regards,

-- 
David Jander

  parent reply	other threads:[~2025-03-03 11:40 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 16:28 [RFC PATCH 0/7] Add Linux Motion Control subsystem David Jander
2025-02-27 16:28 ` [RFC PATCH 1/7] drivers: Add motion control subsystem David Jander
2025-02-28 16:44   ` Uwe Kleine-König
2025-03-05 15:40     ` David Jander
2025-03-05 23:21       ` Uwe Kleine-König
2025-03-06  7:18         ` Greg Kroah-Hartman
2025-03-06  8:20           ` David Jander
2025-03-06  9:03             ` Greg Kroah-Hartman
2025-03-06  9:34               ` David Jander
2025-03-06 13:39                 ` Greg Kroah-Hartman
2025-03-06 14:25                   ` David Jander
2025-03-06 14:54                     ` Greg Kroah-Hartman
2025-03-06  9:25         ` David Jander
2025-03-09 17:32           ` Jonathan Cameron
2025-03-10  8:45             ` David Jander
2025-02-28 22:36   ` David Lechner
2025-03-03  8:36     ` David Jander
2025-03-03 11:01       ` Pavel Pisa
2025-03-03 16:04         ` David Jander
2025-02-27 16:28 ` [RFC PATCH 2/7] motion: Add ADI/Trinamic TMC5240 stepper motor controller David Jander
2025-02-27 16:28 ` [RFC PATCH 3/7] motion: Add simple-pwm.c PWM based DC motor controller driver David Jander
2025-02-27 16:28 ` [RFC PATCH 4/7] Documentation: Add Linux Motion Control documentation David Jander
2025-02-27 16:37   ` Jonathan Corbet
2025-02-28 13:02     ` David Jander
2025-02-28 14:42       ` Jonathan Corbet
2025-02-28 15:06         ` David Jander
2025-02-27 16:28 ` [RFC PATCH 5/7] dt-bindings: motion: Add common motion device properties David Jander
2025-02-28  7:06   ` Krzysztof Kozlowski
2025-02-28  7:13   ` Krzysztof Kozlowski
2025-02-27 16:28 ` [RFC PATCH 6/7] dt-bindings: motion: Add adi,tmc5240 bindings David Jander
2025-02-28  7:11   ` Krzysztof Kozlowski
2025-02-28  8:48     ` David Jander
2025-02-28  9:35       ` Krzysztof Kozlowski
2025-02-28  9:51         ` David Jander
2025-02-28 14:01           ` Krzysztof Kozlowski
2025-02-28 22:38   ` David Lechner
2025-03-03 11:22     ` David Jander
2025-03-03 12:28       ` David Lechner
2025-03-03 13:18         ` David Jander
2025-02-27 16:28 ` [RFC PATCH 7/7] dt-bindings: motion: Add motion-simple-pwm bindings David Jander
2025-02-27 17:38   ` Rob Herring (Arm)
2025-02-28  7:12   ` Krzysztof Kozlowski
2025-02-28  9:22     ` David Jander
2025-02-28  9:37       ` Krzysztof Kozlowski
2025-02-28 10:09         ` David Jander
2025-02-28 15:18           ` Uwe Kleine-König
2025-03-03 10:53             ` Maud Spierings
2025-03-03 11:40             ` David Jander [this message]
2025-03-03 14:18               ` Krzysztof Kozlowski
2025-03-03 16:09                 ` David Jander
2025-02-28 22:41   ` David Lechner
2025-03-03 12:54     ` David Jander
2025-02-28  9:34 ` [RFC PATCH 0/7] Add Linux Motion Control subsystem Pavel Pisa
2025-02-28  9:35 ` Pavel Pisa
2025-02-28 11:57   ` David Jander
2025-02-28 15:23     ` Pavel Pisa
2025-03-03 10:45       ` David Jander
2025-02-28 22:36 ` David Lechner
2025-03-03  8:28   ` David Jander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250303124034.726ba698@erd003.prtnl \
    --to=david@protonic.nl \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=ukleinek@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox