[U-Boot] [PATCH v3 00/11] clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)

Lukasz Majewski lukma at denx.de
Wed May 8 07:25:17 UTC 2019


Dear All,

> This patch series brings the files from Linux kernel to provide
> clocks support as it is used on the Linux kernel with common clock
> framework [CCF] setup.
> 
> This series also fixes several problems with current clocks and
> provides sandbox tests for functions addded to clk-uclass.c file.
> 
> Design decisions/issues:
> =========================
> 
> - U-boot's DM for clk differs from Linux CCF. The most notably
> difference is the lack of support for hierarchical clocks and "clock
> as a manager driver" (single clock DTS node acts as a starting point
> for all other clocks).
> 
> - The clk_get_rate() now caches the previously read data (no need for
> recursive access.
> 
> - On purpose the "manager" clk driver (clk-imx6q.c) is not using large
> table to store pointers to clocks - e.g. clk[IMX6QDL_CLK_USDHC2_SEL]
> = .... Instead we use udevice's linked list for the same class
> (UCLASS_CLK). The rationale - when porting the code as is from Linux,
> one would need ~1KiB of RAM to store it. This is way too much if we
> do plan to use this driver in SPL.
> 
> - The "central" structure of this patch series is struct udevice and
> its driver_data field contains the struct clk pointer (to the
> originally created one).
> 
> - Up till now U-boot's driver model's CLK operates on udevice (main
> access to clock is by udevice ops)
>   In the CCF the access to struct clk (comprising pointer to *dev) is
>   possible via dev_get_driver_data()
> 
>   Storing back pointer (from udevice to struct clk) as driver_data is
> a convention for CCF.
> 
> - I could use *private_alloc_size to allocate driver's 'private"
>   structures (dev->priv) for e.g. divider (struct clk_divider
> *divider) for IMX6Q clock, but this would change the original
> structure of the CCF code.
> 
> The question is if it would be better to use private_alloc_size (and
> dev->private) or stay with driver_data.
> The former requires some rewritting in CCF original code (to remove
> (c)malloc, etc), but comply with u-boot DM. The latter allows
> re-using the CCF code as is, but introduces some convention special
> for CCF (I'm not sure thought if dev->priv is NOT another convention
> as well).
> 
> - I've added the clk_get_parent(), which reads parent's
> dev->driver_data to provide parent's struct clk pointer. This seems
> the easiest way to get child/parent relationship for struct clk in
> U-boot's udevice based clocks.
> 
> - For tests I had to "emulate" CCF code structure to test
> functionality of clk_get_parent_rate() and clk_get_by_id(). Those
> functions will not work properly with "standard" (i.e. non CCF) clock
> setup(with not set dev->driver_data to struct clk).
> 

I would be very grateful for comments regarding described above design
decisions.

Thanks in advance.

> Repository:
> https://github.com/lmajewski/u-boot-dfu/commits/CCF-v3
> 
> 
> Changes in v3:
> - New patch
> - The rate information is now cached into struct clk field
> - The clk_get_parent() is used to get pointer to the parent struct clk
> - Replace -ENODEV with -ENOENT
> - Use **clkp instead of **c
> - New patch
> - New patch
> 
> Lukasz Majewski (11):
>   dm: Fix documentation entry as there is no UCLASS_CLOCK uclass
>   cmd: Do not show frequency for clocks which .get_rate() return error
>   clk: Remove clock ID check in .get_rate() of clk_fixed_*
>   clk: Extend struct clk to provide information regarding clock rate
>   clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
>   dm: clk: Define clk_get_parent() for clk operations
>   dm: clk: Define clk_get_parent_rate() for clk operations
>   dm: clk: Define clk_get_by_id() for clk operations
>   clk: test: Provide unit test for clk_get_by_id() method
>   clk: test: Provide unit test for clk_get_parent_rate() method
>   clk: Port Linux common clock framework [CCF] for imx6q to U-boot
> (tag: 5.0-rc3)
> 
>  arch/sandbox/include/asm/clk.h |  16 ++++
>  cmd/clk.c                      |   5 +-
>  drivers/clk/Kconfig            |  14 ++++
>  drivers/clk/Makefile           |   2 +
>  drivers/clk/clk-divider.c      | 148
> ++++++++++++++++++++++++++++++++++ drivers/clk/clk-fixed-factor.c |
> 87 ++++++++++++++++++++ drivers/clk/clk-mux.c          | 164
> +++++++++++++++++++++++++++++++++++++ drivers/clk/clk-uclass.c
> |  59 ++++++++++++++ drivers/clk/clk.c              |  56
> +++++++++++++ drivers/clk/clk_fixed_factor.c |   3 -
>  drivers/clk/clk_fixed_rate.c   |   8 +-
>  drivers/clk/clk_sandbox_test.c |  49 +++++++++++
>  drivers/clk/imx/Kconfig        |   9 +++
>  drivers/clk/imx/Makefile       |   2 +
>  drivers/clk/imx/clk-gate2.c    | 113 ++++++++++++++++++++++++++
>  drivers/clk/imx/clk-imx6q.c    | 179
> +++++++++++++++++++++++++++++++++++++++++
> drivers/clk/imx/clk-pfd.c      |  91 +++++++++++++++++++++
> drivers/clk/imx/clk-pllv3.c    |  83 +++++++++++++++++++
> drivers/clk/imx/clk.h          |  75 +++++++++++++++++
> include/clk.h                  |  33 +++++++-
> include/linux/clk-provider.h   |  94 ++++++++++++++++++++++
> test/dm/clk.c                  |   4 +- 22 files changed, 1285
> insertions(+), 9 deletions(-) create mode 100644
> drivers/clk/clk-divider.c create mode 100644
> drivers/clk/clk-fixed-factor.c create mode 100644
> drivers/clk/clk-mux.c create mode 100644 drivers/clk/clk.c
>  create mode 100644 drivers/clk/imx/clk-gate2.c
>  create mode 100644 drivers/clk/imx/clk-imx6q.c
>  create mode 100644 drivers/clk/imx/clk-pfd.c
>  create mode 100644 drivers/clk/imx/clk-pllv3.c
>  create mode 100644 drivers/clk/imx/clk.h
>  create mode 100644 include/linux/clk-provider.h
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190508/78f67312/attachment.sig>


More information about the U-Boot mailing list