mbox series

[v3,0/5] clk: samsung: Introduce Exynos850 SoC clock driver

Message ID 20211008154352.19519-1-semen.protsenko@linaro.org
Headers show
Series clk: samsung: Introduce Exynos850 SoC clock driver | expand

Message

Sam Protsenko Oct. 8, 2021, 3:43 p.m. UTC
This patch series provides the implementation for Exynos850 clock
driver, its documentation and corresponding changes for Samsung clock
infrastructure (adds new PLL types used in Exynos850 SoC, following
TRM).

I tried to follow already established design for Samsung clock drivers
(getting most insights from Exynos5433 clock driver), and integrate the
driver into existing infrastructure. The whole driver was implemented
from scratch, using mostly TRM and downstream kernel for clock
dependencies/hierarchy info.

For now only basic clocks are implemented, including next blocks:
  - CMU_TOP
  - CMU_PERI
  - CMU_CORE
  - CMU_HSI
  - CMU_DPU

Some CMUs are still not implemented, but that can be added in future,
when the need arises. The driver also lacks CLKOUT support, PM ops and
automatic clocks control (using Q-Channel protocol). All that can be
added independently later.

Implemented clock tree was tested via UART and MMC drivers, and using
DebugFS clk support (e.g. using 'clk_summary' file). In order to keep
all clocks running I added 'clk_ignore_unused' kernel param in my local
tree, and defined CLOCK_ALLOW_WRITE_DEBUGFS in clk.c for actually
testing the clocks via DebugFS.

Changes in v3:
  - Changed the licence for bindings header to GPL+BSD
  - Added R-b tag by Krzysztof Kozlowski to patches 4/5 and 5/5

Changes in v2:
  - Added CMU_DPU implementation
  - Moved bus clock enablement to clk-exynos850.c
  - See also "v2 changes" list in each particular patch

Sam Protsenko (5):
  clk: samsung: clk-pll: Implement pll0822x PLL type
  clk: samsung: clk-pll: Implement pll0831x PLL type
  dt-bindings: clock: Add bindings definitions for Exynos850 CMU
  dt-bindings: clock: Document Exynos850 CMU bindings
  clk: samsung: Introduce Exynos850 clock driver

 .../clock/samsung,exynos850-clock.yaml        | 185 ++++
 drivers/clk/samsung/Makefile                  |   1 +
 drivers/clk/samsung/clk-exynos850.c           | 835 ++++++++++++++++++
 drivers/clk/samsung/clk-pll.c                 | 196 ++++
 drivers/clk/samsung/clk-pll.h                 |   2 +
 include/dt-bindings/clock/exynos850.h         | 141 +++
 6 files changed, 1360 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml
 create mode 100644 drivers/clk/samsung/clk-exynos850.c
 create mode 100644 include/dt-bindings/clock/exynos850.h

-- 
2.30.2

Comments

Sylwester Nawrocki Oct. 9, 2021, 8:24 p.m. UTC | #1
On 08.10.2021 17:43, Sam Protsenko wrote:
> pll0822x PLL is used in Exynos850 SoC for top-level integer PLLs. The

> code was derived from very similar pll35xx type, with next differences:

> 

> 1. Lock time for pll0822x is 150*P_DIV, when for pll35xx it's 270*P_DIV

> 2. It's not suggested in Exynos850 TRM that S_DIV change doesn't require

>     performing PLL lock procedure (which is done in pll35xx

>     implementation)

> 

> When defining pll0822x type, CON3 register offset should be provided as

> a "con" parameter of PLL() macro, like this:

> 

>      PLL(pll_0822x, 0, "fout_shared0_pll", "oscclk",

>          PLL_LOCKTIME_PLL_SHARED0, PLL_CON3_PLL_SHARED0,

>          exynos850_shared0_pll_rates),

> 

> To define PLL rates table, one can use PLL_35XX_RATE() macro, e.g.:

> 

>      PLL_35XX_RATE(26 * MHZ, 1600 * MHZ, 800, 13, 0)

> 

> as it's completely appropriate for pl0822x type and there is no sense in

> duplicating that.

> 

> If bit #1 (MANUAL_PLL_CTRL) is not set in CON1 register, it won't be

> possible to set new rate, with next error showing in kernel log:

> 

>      Could not lock PLL fout_shared1_pll

> 

> That can happen for example if bootloader clears that bit beforehand.

> PLL driver doesn't account for that, so if MANUAL_PLL_CTRL bit was

> cleared, it's assumed it was done for a reason and it shouldn't be

> possible to change that PLL's rate at all.

> 

> Signed-off-by: Sam Protsenko<semen.protsenko@linaro.org>

> Reviewed-by: Krzysztof Kozlowski<krzysztof.kozlowski@canonical.com>

> Acked-by: Chanwoo Choi<cw00.choi@samsung.com>


Applied, thanks.
Sylwester Nawrocki Oct. 9, 2021, 8:28 p.m. UTC | #2
On 08.10.2021 17:43, Sam Protsenko wrote:
> Clock controller driver is designed to have separate instances for each

> particular CMU. So clock IDs in this bindings header also start from 1

> for each CMU.

> 

> Signed-off-by: Sam Protsenko<semen.protsenko@linaro.org>

> Reviewed-by: Krzysztof Kozlowski<krzysztof.kozlowski@canonical.com>

> Acked-by: Rob Herring<robh@kernel.org>


Applied, thanks.
Sam Protsenko Oct. 11, 2021, 10:13 a.m. UTC | #3
On Sat, 9 Oct 2021 at 23:41, Sylwester Nawrocki <snawrocki@kernel.org> wrote:
>

> On 08.10.2021 17:43, Sam Protsenko wrote:

> > Provide dt-schema documentation for Exynos850 SoC clock controller.

> >

> > Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

> > Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

>

> > diff --git a/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml b/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml

> > new file mode 100644

> > index 000000000000..79202e6e6402

> > --- /dev/null

> > +++ b/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml

> > @@ -0,0 +1,185 @@

> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

> > +%YAML 1.2

> > +---

> > +$id: http://devicetree.org/schemas/clock/samsung,exynos850-clock.yaml#

> > +$schema: http://devicetree.org/meta-schemas/core.yaml#

> > +

> > +title: Samsung Exynos850 SoC clock controller

> > +

> > +maintainers:

> > +  - Sam Protsenko <semen.protsenko@linaro.org>

> > +  - Chanwoo Choi <cw00.choi@samsung.com>

> > +  - Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

> > +  - Sylwester Nawrocki <s.nawrocki@samsung.com>

> > +  - Tomasz Figa <tomasz.figa@gmail.com>

> > +

> > +description: |

> > +  Exynos850 clock controller is comprised of several CMU units, generating

> > +  clocks for different domains. Those CMU units are modeled as separate device

> > +  tree nodes, and might depend on each other. Root clocks in that clock tree are

> > +  two external clocks:: OSCCLK (26 MHz) and RTCCLK (32768 Hz). Those external

> > +  clocks must be defined as fixed-rate clocks in dts.

> > +

> > +  CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and

> > +  dividers; all other leaf clocks (other CMUs) are usually derived from CMU_TOP.

> > +

> > +  Each clock is assigned an identifier and client nodes can use this identifier

> > +  to specify the clock which they consume. All clocks that available for usage

>

> s/All clocks that available/All clocks available ?

> No need to resend, I can amend it when applying.

>


Yeah, not a native speaker, I tend to do such mistakes sometimes :)
Please fix when applying.

Btw, I can see that you already applied 3 out of 5 patches from this
patch series here: [1]. Can you please also apply the rest, or is
there any outstanding comments that I missed?

[1] https://git.kernel.org/pub/scm/linux/kernel/git/snawrocki/clk.git/log/?h=for-v5.16/next
On 11.10.2021 12:13, Sam Protsenko wrote:
> On Sat, 9 Oct 2021 at 23:41, Sylwester Nawrocki <snawrocki@kernel.org> wrote:

>>

>> On 08.10.2021 17:43, Sam Protsenko wrote:

>>> Provide dt-schema documentation for Exynos850 SoC clock controller.

>>>

>>> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

>>> Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

[...]
>>> +++ b/Documentation/devicetree/bindings/clock/samsung,exynos850-clock.yaml

>>> @@ -0,0 +1,185 @@

[...]
>>> +

>>> +title: Samsung Exynos850 SoC clock controller

>>> +

>>> +maintainers:

>>> +  - Sam Protsenko <semen.protsenko@linaro.org>

>>> +  - Chanwoo Choi <cw00.choi@samsung.com>

>>> +  - Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

>>> +  - Sylwester Nawrocki <s.nawrocki@samsung.com>

>>> +  - Tomasz Figa <tomasz.figa@gmail.com>

>>> +

>>> +description: |

>>> +  Exynos850 clock controller is comprised of several CMU units, generating

>>> +  clocks for different domains. Those CMU units are modeled as separate device

>>> +  tree nodes, and might depend on each other. Root clocks in that clock tree are

>>> +  two external clocks:: OSCCLK (26 MHz) and RTCCLK (32768 Hz). Those external

>>> +  clocks must be defined as fixed-rate clocks in dts.

>>> +

>>> +  CMU_TOP is a top-level CMU, where all base clocks are prepared using PLLs and

>>> +  dividers; all other leaf clocks (other CMUs) are usually derived from CMU_TOP.

>>> +

>>> +  Each clock is assigned an identifier and client nodes can use this identifier

>>> +  to specify the clock which they consume. All clocks that available for usage

>>

>> s/All clocks that available/All clocks available ?

>> No need to resend, I can amend it when applying.

>>

> 

> Yeah, not a native speaker, I tend to do such mistakes sometimes :)

> Please fix when applying.

> 

> Btw, I can see that you already applied 3 out of 5 patches from this

> patch series here: [1]. Can you please also apply the rest, or is

> there any outstanding comments that I missed?


The patches look good to me, I just wanted to allow some for Rob to have
a look and provide an Ack.

Regards,
-- 
Sylwester Nawrocki
Samsung R&D Institute Poland