Re: [PATCH 0/7] add support for clocksource/clockevent DT selection

From: Daniel Lezcano
Date: Mon Oct 21 2019 - 10:17:46 EST


On 21/10/2019 10:58, Claudiu.Beznea@xxxxxxxxxxxxx wrote:
> Hi Daniel,
>
> On 18.10.2019 23:24, Daniel Lezcano wrote:
>> Hi Claudiu,
>>
>> On 15/10/2019 11:23, Claudiu.Beznea@xxxxxxxxxxxxx wrote:
>>
>> [ ... ]
>>
>>> The timer clock source could be divided by MR.PRES + 1.
>>>
>>> So, I used the clock-frequency DT binding to let user choose the timer's
>>> frequency. Based on the value provided via this DT binding the best clock
>>> source and prescaler is chosen via mchp_pit64b_pres_prepare() function.
>>
>> I'm willing to take the driver but I doubt the purpose of the
>> clock-frequency is to let the user choose the frequency.
>>
>
> I found this approach in the following already integrated drivers:
> drivers/clocksource/armv7m_systick.c
> drivers/clocksource/bcm2835_timer.c
> drivers/clocksource/bcm_kona_timer.c
> drivers/clocksource/mips-gic-timer.c
> drivers/clocksource/mps2-timer.c
> drivers/clocksource/timer-qcom.c
> drivers/clocksource/arm_arch_timer.c
>
> Looking through the documentation of these, most of them document this DT
> property as the frequency of the clock that drivers the timer, but none of
> them seems to have some IP internal dividers so that the timer to tick at
> different frequency than the clock that feeds the IP. From the
> documentation of the above drivers;
> drivers/clocksource/armv7m_systick.c
> - clock-frequency : The rate in HZ in input of the ARM SysTick
>
> drivers/clocksource/bcm2835_timer.c
> - clock-frequency : The frequency of the clock that drives the counter, in
> Hz.
> drivers/clocksource/bcm_kona_timer.c
> - clock-frequency: frequency that the clock operates
>
> drivers/clocksource/mips-gic-timer.c
> clock-frequency : Clock frequency at which the GIC timers operate.
> drivers/clocksource/mps2-timer.c
> - clock-frequency : The rate in HZ in input of the ARM MPS2 timer
>
> drivers/clocksource/timer-qcom.c
> - clock-frequency : The frequency of the debug timer and the general
> purpose
> timer(s) in Hz in that order.
>
>
> This is why I also chose this DT bindings.
>
> If you want I can stick to a fixed frequency hard coded in the driver.
> Please let me know if this would be OK for you.

Yes, the clock-frequency is used to specify the frequency when the
information can not be retrieved from the clock. The goal is not to
specify a frequency and compute from there a prescalar value.

Hardcoding the frequency is fine or hardcode the divider and compute the
frequency from the clock rate.



--
<http://www.linaro.org/> Linaro.org â Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog