All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 23:14:18 +0200	[thread overview]
Message-ID: <fc607b9a-baed-daf5-5b2a-3b69d36b8d17@gmail.com> (raw)
In-Reply-To: <20230327175027.z7as4fybzgx7zhuq@pengutronix.de>

On 27.03.2023 19:50, Uwe Kleine-König wrote:
> On Mon, Mar 27, 2023 at 07:00:35PM +0200, Heiner Kallweit wrote:
>> The best (for achieving best precision) input frequency is 0xffff / period.
>> So we should do our best to come as close as possible to this frequency.
>> By using set_rate() CCF will choose the optimal mux input and divider value.
> 
> Just for the record: Here might be a misconception. There is (AFAIK) no
> reason to believe that set_rate would pick an optimal configuration. And
> if it's only because there is no objective definition of "optimal". For
> example if a driver for an SD card requests 400MHz, it might not want
> anything faster and so probably prefers 202 MHz over 404 MHz. However a
> driver for a UART would prefer the 404 MHz in this case. IMHO we'd need
> something like
> 
Right, I wasn't precise enough. In my case optimal is "fastest rate <= requested rate".
This seems to be the behavior of clk core default implementations like
clk_mux_determine_rate_flags() an divider_determine_rate(), used by the meson
clock drivers.
However in general clock providers can provide their own determine_rate()
implementations. And, as a disclaimer, I have to admit that I'm no expert in CCF.

> 	clk_rounddown_rate();
> 	clk_roundnear_rate(); and maybe
> 	clk_roundup_rate()
> 
> to please all drivers. But that sounds like a bigger quest.
> 
> If your clk can provide (say) 1000000 Hz and 2000000 Hz (and nothing in
> between) there is no rule in the CCF that tells you which of the two to
> pick if you request 1000001 Hz or 1999999 Hz. (The only thing I would
> not expect is that you get 1000000 Hz when requesting 1999999 Hz *and*
> 2000000 Hz when requesting 1000001 Hz.)
> 
>> Not sure why we should restrict ourselves to one mux parent only.
>> E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.
>>
>> Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
>> as of today). So we need a set_rate() anyway to set the divider value.
>> What I can't say is whether the internal divider still exists (then external and internal
>> divider would be cascaded) or is removed or bypassed.
>> It seems like when adding the external PWM clock feature Amlogic forgot to update
>> the PWM block documentation, as there's no reference at all to the now external input clock
>> (except in the clocks section).
> 
> It would be great to test (or ask?) if the internal divider still exists
> and do the right thing then.
> 
> Having said that, I wonder if it would make sense to rework the driver
> for the variants with the internal mux to also abstract the divider as a
> proper clk.
> 
I think this would make sense. Then we could ignore the mux parent set in DT
and let CCF select the mux parent and divider value. And we could use one
pwm calc logic and get rid of most if(ext_clk).


> Best regards
> Uwe
> 


WARNING: multiple messages have this Message-ID (diff)
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 23:14:18 +0200	[thread overview]
Message-ID: <fc607b9a-baed-daf5-5b2a-3b69d36b8d17@gmail.com> (raw)
In-Reply-To: <20230327175027.z7as4fybzgx7zhuq@pengutronix.de>

On 27.03.2023 19:50, Uwe Kleine-König wrote:
> On Mon, Mar 27, 2023 at 07:00:35PM +0200, Heiner Kallweit wrote:
>> The best (for achieving best precision) input frequency is 0xffff / period.
>> So we should do our best to come as close as possible to this frequency.
>> By using set_rate() CCF will choose the optimal mux input and divider value.
> 
> Just for the record: Here might be a misconception. There is (AFAIK) no
> reason to believe that set_rate would pick an optimal configuration. And
> if it's only because there is no objective definition of "optimal". For
> example if a driver for an SD card requests 400MHz, it might not want
> anything faster and so probably prefers 202 MHz over 404 MHz. However a
> driver for a UART would prefer the 404 MHz in this case. IMHO we'd need
> something like
> 
Right, I wasn't precise enough. In my case optimal is "fastest rate <= requested rate".
This seems to be the behavior of clk core default implementations like
clk_mux_determine_rate_flags() an divider_determine_rate(), used by the meson
clock drivers.
However in general clock providers can provide their own determine_rate()
implementations. And, as a disclaimer, I have to admit that I'm no expert in CCF.

> 	clk_rounddown_rate();
> 	clk_roundnear_rate(); and maybe
> 	clk_roundup_rate()
> 
> to please all drivers. But that sounds like a bigger quest.
> 
> If your clk can provide (say) 1000000 Hz and 2000000 Hz (and nothing in
> between) there is no rule in the CCF that tells you which of the two to
> pick if you request 1000001 Hz or 1999999 Hz. (The only thing I would
> not expect is that you get 1000000 Hz when requesting 1999999 Hz *and*
> 2000000 Hz when requesting 1000001 Hz.)
> 
>> Not sure why we should restrict ourselves to one mux parent only.
>> E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.
>>
>> Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
>> as of today). So we need a set_rate() anyway to set the divider value.
>> What I can't say is whether the internal divider still exists (then external and internal
>> divider would be cascaded) or is removed or bypassed.
>> It seems like when adding the external PWM clock feature Amlogic forgot to update
>> the PWM block documentation, as there's no reference at all to the now external input clock
>> (except in the clocks section).
> 
> It would be great to test (or ask?) if the internal divider still exists
> and do the right thing then.
> 
> Having said that, I wonder if it would make sense to rework the driver
> for the variants with the internal mux to also abstract the divider as a
> proper clk.
> 
I think this would make sense. Then we could ignore the mux parent set in DT
and let CCF select the mux parent and divider value. And we could use one
pwm calc logic and get rid of most if(ext_clk).


> Best regards
> Uwe
> 


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

WARNING: multiple messages have this Message-ID (diff)
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: neil.armstrong@linaro.org,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	linux-pwm@vger.kernel.org,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] pwm: meson: add support for S4 chip family
Date: Mon, 27 Mar 2023 23:14:18 +0200	[thread overview]
Message-ID: <fc607b9a-baed-daf5-5b2a-3b69d36b8d17@gmail.com> (raw)
In-Reply-To: <20230327175027.z7as4fybzgx7zhuq@pengutronix.de>

On 27.03.2023 19:50, Uwe Kleine-König wrote:
> On Mon, Mar 27, 2023 at 07:00:35PM +0200, Heiner Kallweit wrote:
>> The best (for achieving best precision) input frequency is 0xffff / period.
>> So we should do our best to come as close as possible to this frequency.
>> By using set_rate() CCF will choose the optimal mux input and divider value.
> 
> Just for the record: Here might be a misconception. There is (AFAIK) no
> reason to believe that set_rate would pick an optimal configuration. And
> if it's only because there is no objective definition of "optimal". For
> example if a driver for an SD card requests 400MHz, it might not want
> anything faster and so probably prefers 202 MHz over 404 MHz. However a
> driver for a UART would prefer the 404 MHz in this case. IMHO we'd need
> something like
> 
Right, I wasn't precise enough. In my case optimal is "fastest rate <= requested rate".
This seems to be the behavior of clk core default implementations like
clk_mux_determine_rate_flags() an divider_determine_rate(), used by the meson
clock drivers.
However in general clock providers can provide their own determine_rate()
implementations. And, as a disclaimer, I have to admit that I'm no expert in CCF.

> 	clk_rounddown_rate();
> 	clk_roundnear_rate(); and maybe
> 	clk_roundup_rate()
> 
> to please all drivers. But that sounds like a bigger quest.
> 
> If your clk can provide (say) 1000000 Hz and 2000000 Hz (and nothing in
> between) there is no rule in the CCF that tells you which of the two to
> pick if you request 1000001 Hz or 1999999 Hz. (The only thing I would
> not expect is that you get 1000000 Hz when requesting 1999999 Hz *and*
> 2000000 Hz when requesting 1000001 Hz.)
> 
>> Not sure why we should restrict ourselves to one mux parent only.
>> E.g. for a very low duty cycle a higher input frequency than the xtal 24MHz may be preferable.
>>
>> Not only the mux is outside the PWM block now, also the divider (8 bit wide instead of 7 bit
>> as of today). So we need a set_rate() anyway to set the divider value.
>> What I can't say is whether the internal divider still exists (then external and internal
>> divider would be cascaded) or is removed or bypassed.
>> It seems like when adding the external PWM clock feature Amlogic forgot to update
>> the PWM block documentation, as there's no reference at all to the now external input clock
>> (except in the clocks section).
> 
> It would be great to test (or ask?) if the internal divider still exists
> and do the right thing then.
> 
> Having said that, I wonder if it would make sense to rework the driver
> for the variants with the internal mux to also abstract the divider as a
> proper clk.
> 
I think this would make sense. Then we could ignore the mux parent set in DT
and let CCF select the mux parent and divider value. And we could use one
pwm calc logic and get rid of most if(ext_clk).


> Best regards
> Uwe
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-27 21:14 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 22:23 [PATCH] pwm: meson: add support for S4 chip family Heiner Kallweit
2023-03-24 22:23 ` Heiner Kallweit
2023-03-24 22:23 ` Heiner Kallweit
2023-03-25  8:20 ` Uwe Kleine-König
2023-03-25  8:20   ` Uwe Kleine-König
2023-03-25  8:20   ` Uwe Kleine-König
2023-03-25  9:43   ` Heiner Kallweit
2023-03-25  9:43     ` Heiner Kallweit
2023-03-25  9:43     ` Heiner Kallweit
2023-03-25 13:24 ` Jerome Brunet
2023-03-25 13:24   ` Jerome Brunet
2023-03-25 13:24   ` Jerome Brunet
2023-03-25 22:58   ` Heiner Kallweit
2023-03-25 22:58     ` Heiner Kallweit
2023-03-25 22:58     ` Heiner Kallweit
2023-03-26 10:02     ` Heiner Kallweit
2023-03-26 10:02       ` Heiner Kallweit
2023-03-26 10:02       ` Heiner Kallweit
2023-03-27 12:13     ` Jerome Brunet
2023-03-27 12:13       ` Jerome Brunet
2023-03-27 12:13       ` Jerome Brunet
2023-03-27  7:33 ` Neil Armstrong
2023-03-27  7:33   ` Neil Armstrong
2023-03-27  7:33   ` Neil Armstrong
2023-03-27 17:00   ` Heiner Kallweit
2023-03-27 17:00     ` Heiner Kallweit
2023-03-27 17:00     ` Heiner Kallweit
2023-03-27 17:50     ` Uwe Kleine-König
2023-03-27 17:50       ` Uwe Kleine-König
2023-03-27 17:50       ` Uwe Kleine-König
2023-03-27 21:14       ` Heiner Kallweit [this message]
2023-03-27 21:14         ` Heiner Kallweit
2023-03-27 21:14         ` Heiner Kallweit
2023-03-27 18:11     ` neil.armstrong
2023-03-27 18:11       ` neil.armstrong
2023-03-27 18:11       ` neil.armstrong

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=fc607b9a-baed-daf5-5b2a-3b69d36b8d17@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.