mbox series

[0/3] cpufreq: sama7g5: add support for sama7g5

Message ID 1609842147-8161-1-git-send-email-claudiu.beznea@microchip.com
Headers show
Series cpufreq: sama7g5: add support for sama7g5 | expand

Message

Claudiu Beznea Jan. 5, 2021, 10:22 a.m. UTC
Hi,

SAMA7G5 supports run-time changes of CPU frequency. This is done by
changing CPU's PLL. The block diagram explaining the relation b/w
CPU clock and its PLL is as follows:

                         +--------------> cpuck
                         |
               +------+  |    +-----+
  cpupllck --> | pres |--+--> | div |---> mck
               +------+       +-----+

where cpuck is the CPU's clock and mck is the system master clock 0
that feeds some other IPs. All the IPs feed by mck are glich free 
aware.

Because MCK is also feed by cpuplllk the CPUFreq driver needs also
to handle this clock to avoid its under/over clocking: every
time the CPUFreq's .target_index API is called:
- the mck frequency is adjusted to avoid its overclocking/underclocking
- then the cpuck frequency is increased/lowered
- then mck frequency is adjusted to keep the initial 200MHz frequency

Thank you,
Claudiu Beznea

Claudiu Beznea (3):
  dt-bindings: cpufreq: sama7g5-cpufreq: add dt bindings documentation
  cpufreq: sama7g5: add cpufreq driver
  MAINTAINERS: add sama7g5 cpufreq

 .../bindings/cpufreq/cpufreq-sama7g5.yaml          |  80 +++++
 MAINTAINERS                                        |   6 +
 drivers/cpufreq/Kconfig.arm                        |   9 +
 drivers/cpufreq/Makefile                           |   1 +
 drivers/cpufreq/cpufreq-dt-platdev.c               |   2 +
 drivers/cpufreq/sama7g5-cpufreq.c                  | 371 +++++++++++++++++++++
 6 files changed, 469 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-sama7g5.yaml
 create mode 100644 drivers/cpufreq/sama7g5-cpufreq.c

Comments

Viresh Kumar Jan. 5, 2021, 10:44 a.m. UTC | #1
On 05-01-21, 12:22, Claudiu Beznea wrote:
> Microchip SAMA7G5 devices supports runtime changes of CPU frequency.
> This is doable by changing CPUPLL frequency along with MCK0 frequency.
> Along with this CPU's regulator must be changed to accommodate new
> frequencies.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>  drivers/cpufreq/Kconfig.arm          |   9 +
>  drivers/cpufreq/Makefile             |   1 +
>  drivers/cpufreq/cpufreq-dt-platdev.c |   2 +
>  drivers/cpufreq/sama7g5-cpufreq.c    | 371 +++++++++++++++++++++++++++++++++++
>  4 files changed, 383 insertions(+)
>  create mode 100644 drivers/cpufreq/sama7g5-cpufreq.c

Did you try to reuse cpufreq-dt driver? It already handles most of
this stuff, the only thing you need to do is to make sure
clk_set_rate() for a CPU needs to handle all the clk stuff behind the
scene.

We haven't been accepting new implementations of the drivers which can
work just fine with cpufreq-dt, please try to adapt to it.

Thanks.
Claudiu Beznea Jan. 5, 2021, 11:31 a.m. UTC | #2
On 05.01.2021 12:44, Viresh Kumar wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 05-01-21, 12:22, Claudiu Beznea wrote:
>> Microchip SAMA7G5 devices supports runtime changes of CPU frequency.
>> This is doable by changing CPUPLL frequency along with MCK0 frequency.
>> Along with this CPU's regulator must be changed to accommodate new
>> frequencies.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>> ---
>>  drivers/cpufreq/Kconfig.arm          |   9 +
>>  drivers/cpufreq/Makefile             |   1 +
>>  drivers/cpufreq/cpufreq-dt-platdev.c |   2 +
>>  drivers/cpufreq/sama7g5-cpufreq.c    | 371 +++++++++++++++++++++++++++++++++++
>>  4 files changed, 383 insertions(+)
>>  create mode 100644 drivers/cpufreq/sama7g5-cpufreq.c
> 
> Did you try to reuse cpufreq-dt driver? It already handles most of
> this stuff, the only thing you need to do is to make sure
> clk_set_rate() for a CPU needs to handle all the clk stuff behind the
> scene.

No, I haven't tried it due to the fact that there are 2 clocks that needs
to be handled and though isn't the proper way to do this behind the scene
in clock drivers.

> 
> We haven't been accepting new implementations of the drivers which can
> work just fine with cpufreq-dt, please try to adapt to it.

I'll try it.

Thank you,
Claudiu

> 
> Thanks.
> 
> --
> viresh
>