public inbox for linux-pwm@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Binbin Zhou <zhoubb.aaron@gmail.com>,
	Binbin Zhou <zhoubinbin@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Juxin Gao <gaojuxin@loongson.cn>,
	Huacai Chen <chenhuacai@kernel.org>,
	loongson-kernel@lists.loongnix.cn, linux-pwm@vger.kernel.org,
	devicetree@vger.kernel.org, Xuerui Wang <kernel@xen0n.name>,
	loongarch@lists.linux.dev
Subject: Re: [PATCH v2 1/2] dt-bindings: pwm: Add Loongson PWM controller
Date: Thu, 11 Apr 2024 21:10:51 +0200	[thread overview]
Message-ID: <bb250368-d1d2-41dd-abef-ae505a4a5d33@linaro.org> (raw)
In-Reply-To: <k2v7ibfc5vjprfw6gvrcelbknhxqf7mnybsnbb2avj6qblkmqz@graeaj372hcg>

On 11/04/2024 17:21, Uwe Kleine-König wrote:
> Hello,
> 
> On Thu, Apr 11, 2024 at 04:44:37PM +0200, Krzysztof Kozlowski wrote:
>> On 11/04/2024 16:35, Binbin Zhou wrote:
>>> On Thu, Apr 11, 2024 at 5:07 PM Krzysztof Kozlowski
>>> <krzysztof.kozlowski@linaro.org> wrote:
>>>>
>>>> On 11/04/2024 13:01, Binbin Zhou wrote:
>>>>> On Thu, Apr 11, 2024 at 4:26 PM Krzysztof Kozlowski
>>>>> <krzysztof.kozlowski@linaro.org> wrote:
>>>>>>
>>>>>> On 11/04/2024 11:16, Binbin Zhou wrote:
>>>>>>> Add Loongson PWM controller binding with DT schema format using
>>>>>>> json-schema.
>>>>>>>
>>>>>>> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
>>>>>>
>>>>>>
>>>>>>> +properties:
>>>>>>> +  compatible:
>>>>>>> +    oneOf:
>>>>>>> +      - const: loongson,ls7a-pwm
>>>>>>> +      - items:
>>>>>>> +          - enum:
>>>>>>> +              - loongson,ls2k0500-pwm
>>>>>>> +              - loongson,ls2k1000-pwm
>>>>>>> +              - loongson,ls2k2000-pwm
>>>>>>> +          - const: loongson,ls7a-pwm
>>>>>>> +
>>>>>>> +  reg:
>>>>>>> +    maxItems: 1
>>>>>>> +
>>>>>>> +  interrupts:
>>>>>>> +    maxItems: 1
>>>>>>> +
>>>>>>> +  clocks:
>>>>>>> +    maxItems: 1
>>>>>>> +
>>>>>>> +  '#pwm-cells':
>>>>>>> +    description:
>>>>>>> +      The first cell must have a value of 0, which specifies the PWM output signal;
>>>>>>
>>>>>> If you have always the same value in PWM phandle, why encoding it in the
>>>>>> phandle in the first place? What's the benefit of passing 0?
>>>>>
>>>>> Hi Krzysztof:
>>>>>
>>>>> My thoughts are:
>>>>> First of all, our pwm has only one output signal, so it can only be 0.
>>>>> Also, as you know from the pwm xlate function, the first cell is the
>>>>> pwm index, so I fixed it to be 0 here.
>>>>>
>>>>> The xlate function:
>>>>> https://elixir.bootlin.com/linux/v6.8/source/drivers/pwm/core.c#L106
>>>>
>>>> You refer for xlate for PWM with three cells. You do not have three
>>>> cells, as you have only on signal, so why insisting on using other
>>>> xlate? Do you do the same for clocks? Or resets?
>>>>
>>>> I don't think you use appropriate argument in this discussion. We talk
>>>> about hardware and your argument "I don't want to use my own xlate in
>>>> the driver" is about driver.
>>>>
>>> Hi Krzysztof:
>>>
>>> Thanks for your comments.
>>>
>>> Emm... Indeed, I used to think about it from the driver's perspective.
>>> From the binding perspective, two cells really should be more appropriate.
>>> I try to make the following changes in the next version patchset:
>>>
>>>   '#pwm-cells':
>>>     description:
>>>       The first cell is the period in nanoseconds;
>>>       The second cell flag supported by this binding is PWM_POLARITY_INVERTED.
>>>     const: 2
>>>
>>> Accordingly, the custom xlate function will be used in the driver.
>>
>> If your other, upcoming variants had more PWM outputs, then I would find
>> reasonable keeping cells=3 to have one approach for all of them. But I
>> guess that's not the case here.
> 
> There is an easy way to get rid of the 0, just use chip->of_xlate =
> of_pwm_single_xlate; Having said that, I don't particularily like that.
> If it wasn't for dt bindings being stable I'd argue for all PWM chips to
> use #pwm-cells = <3>; and accept that the 2nd field is zero for
> consistency.
> 
> Some statistics:
> 
> There are only two drivers that use of_pwm_single_xlate:
>  - drivers/pwm/pwm-pxa.c
>  - drivers/gpu/drm/bridge/ti-sn65dsi86.c
> 
> There is one driver that uses a completely custom xlate function (and
> #pwm-cells = <1>, to specify the pwmid; the period is fixed):
>  - drivers/pwm/pwm-cros-ec.c
> 
> All 65 other drivers use #pwm-cells = <3> with the "usual" semantic. At
> least 21 among them only have a single output and so always use 0 in the
> 2nd cell.
> 
> So I'm all in favour to stick to the approach used in this binding for
> the sake of consistency among the drivers^Wbindings.

Seems fine, thanks for the explanation.

Best regards,
Krzysztof


  reply	other threads:[~2024-04-11 19:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  9:16 [PATCH v2 0/2] pwm: Introduce pwm driver for the Loongson family chips Binbin Zhou
2024-04-11  9:16 ` [PATCH v2 1/2] dt-bindings: pwm: Add Loongson PWM controller Binbin Zhou
2024-04-11 10:26   ` Krzysztof Kozlowski
2024-04-11 11:01     ` Binbin Zhou
2024-04-11 11:07       ` Krzysztof Kozlowski
2024-04-11 14:35         ` Binbin Zhou
2024-04-11 14:44           ` Krzysztof Kozlowski
2024-04-11 15:21             ` Uwe Kleine-König
2024-04-11 19:10               ` Krzysztof Kozlowski [this message]
2024-04-11 19:12   ` Krzysztof Kozlowski
2024-04-11  9:16 ` [PATCH v2 2/2] pwm: Add Loongson PWM controller support Binbin Zhou
2024-04-12  6:47   ` Huacai Chen
2024-04-12  7:30     ` Binbin Zhou

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=bb250368-d1d2-41dd-abef-ae505a4a5d33@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gaojuxin@loongson.cn \
    --cc=kernel@xen0n.name \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.cn \
    --cc=robh+dt@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=zhoubb.aaron@gmail.com \
    --cc=zhoubinbin@loongson.cn \
    /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