From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D57D13BAF1; Mon, 3 Mar 2025 14:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741011528; cv=none; b=gzE0vgoaH0oF/NOeUs88XzGQFq1UNLk6BrGIgNQkvM9X28qs8qivFcun9jsfFIXFy/COLgpHW+KJxXr/NVVgZ1P0vr93FfXOajmuT3SjSEgS+lYVHlbNo81kJHCrZp/gBErgg6i83jkIudSKIRkLg/hYQJKFYWqtxuGFuXXHKkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741011528; c=relaxed/simple; bh=lqjp7LIjDhQxWqewy5mV5ckok6buZoX+dvARhvXCRko=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=obnB6j1bvY6MEIvdpRKKo5EPnz2LYIkl5EPy6EVSLncLTLmrYcjkPZdwzqlcd6VGQIkksz6jn/rpA4fetO1RkToGZ03s7E1Mljo6sdPtKsA+42pOgKHA3Jg58wzWeNtYbaIQ2Du7sHCsTarbQ72885YhltqqvLeYCp5+EYqIbGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PuEyftF6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PuEyftF6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DCA2C4CED6; Mon, 3 Mar 2025 14:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741011528; bh=lqjp7LIjDhQxWqewy5mV5ckok6buZoX+dvARhvXCRko=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PuEyftF6/98P2YSoT/4dx5CwnIWkCdDWHwsSHGPpVCQdI7A/Qz4YSX+WX/Kc/luQU rCpXhhOGWAizvCQE+iTUEyI/y1ZTX00Oyj2kGjCxNawQwjg2Cr5Eq+BMG9JV29dwsn N4EvxuaxfaVRYdC5lQUFhX4TAs/cVp1tXbWpRrkSw+SJUb9IftzGhb4jgtP/XKoX4Y acPXTU8ONuYyS6hUZBbqxcXtj26VxkXj+rUttuRoPG5mzo4JWh8/hhEhUzQaDAq9oM i46OI85zxt/voI71Jw6MiSdGgiFvM0Ad4BhfJVkQNf0hPimHMme+Q3kbvisBOLMsz/ 2L8vFxvrgC9Tw== Message-ID: Date: Mon, 3 Mar 2025 15:18:40 +0100 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 7/7] dt-bindings: motion: Add motion-simple-pwm bindings To: David Jander , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, Nuno Sa , Jonathan Cameron , Oleksij Rempel , linux-pwm@vger.kernel.org References: <20250227162823.3585810-1-david@protonic.nl> <20250227162823.3585810-8-david@protonic.nl> <20250228-wonderful-python-of-resistance-d5b662@krzk-bin> <20250228102201.590b4be6@erd003.prtnl> <9a1d75a2-66c0-46b6-91a1-4922b892dfb1@kernel.org> <20250228110931.7bdae7fd@erd003.prtnl> <20250303124034.726ba698@erd003.prtnl> From: Krzysztof Kozlowski Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xs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v0oDcsQWXqY+NaFahT0lRPjYtrTa1v3tem/ JoFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20250303124034.726ba698@erd003.prtnl> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 03/03/2025 12:40, David Jander wrote: >> >> 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? No, because that flag is already supported via PWM_POLARITY_INVERTED. Do not tie bindings to specific implementation. If PWM core is changed to always handle PWM_POLARITY_INVERTED even if controller does not support it, would the binding became outdated? > > 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. Sure and use existing bindings for that. If implementation has problems, fix implementation. Best regards, Krzysztof