clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
Subsystems (3)
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
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.
Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4
Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly use container_of() based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patch
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 (13):
clk: doc: Add documentation entry for Common Clock Framework [CCF]
(i.MX)
dm: Fix documentation entry as there is no UCLASS_CLOCK uclass
clk: Remove clock ID check in .get_rate() of clk_fixed_*
clk: Extend struct clk to provide information regarding clock rate
clk: Extend struct clk to provide clock type agnostic flags
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) dm: clk: Extend clk_get_parent_rate() to support CLK_GET_RATE_NOCACHE
flag
arch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390 insertions(+), 8 deletions(-) create mode 100644 doc/imx/clk/ccf.txt 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
Signature · 1 line
2.11.0
PATCH v4 1/13 clk: doc: Add documentation entry for Common Clock Framework [CCF] (i.MX)
This patch describes the design decisions considerations and taken approach for porting in a separate documentation entry.
---
Changes in v4:
- New patch
Changes in v3: None
doc/imx/clk/ccf.txt | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 doc/imx/clk/ccf.txt
doc/imx/clk/ccf.txt new file +83 -0
@@ -0,0 +1,83 @@ +Introduction: +============= + +This documentation entry describes the Common Clock Framework [CCF] +port from Linux kernel (5.0-rc3) to U-Boot. + +This code is supposed to bring CCF to IMX based devices (imx6q, imx7 +imx8). Moreover, it also provides some common clock code, which would +allow easy porting of CCF Linux code to other platforms. + +Design decisions: +================= + +* 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() caches the previously read data if CLK_GET_RATE_NOCACHE + is not set (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). + + 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. + + Question: + --------- + + Would it be better to use private_alloc_size (and dev->private) or stay with + driver_data to store struct clk pointer? + + 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). + + This port uses the former approach with driver_data storing pointer to + struct clk. + +* 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). + +* Linux's CCF 'struct clk_core' corresponds to u-boot's udevice in 'struct clk'. + Clock IP block agnostic flags from 'struct clk_core' (e.g. NOCACHE) have been + moved from this struct one level up to 'struct clk'. + +To do: +------ + +* Use of OF_PLATDATA in the SPL setup for CCF - as it is now - the SPL grows + considerably and using CCF in boards with tiny resources (OCRAM) is + problematic. + +* On demand port other parts of CCF to U-Boot - as now only features _really_ + needed by DM/DTS converted drivers are used.
Signature · 1 line
2.11.0
PATCH v4 1/13 clk: doc: Add documentation entry for Common Clock Framework [CCF] (i.MX)
Quoted 22 lines · Lukasz Majewski
This patch describes the design decisions considerations and taken approach for porting in a separate documentation entry.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- New patchChanges in v3: None
doc/imx/clk/ccf.txt | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 doc/imx/clk/ccf.txtdoc/imx/clk/ccf.txt new file +0
-0
doc/imx/clk/ccf.txt line 5
Quoted 5 lines
doc/imx/clk/ccf.txt new file +5
-0@@ -0,0 +1,83 @@ +Introduction: +============= + +This documentation entry describes the Common Clock Framework [CCF] +port from Linux kernel (5.0-rc3) to U-Boot.
Can we upgrade this to 5.1.y ?
Signature · 2 lines
Best regards, Marek Vasut
Peng Fan
reviewerPATCH v4 1/13 clk: doc: Add documentation entry for Common Clock Framework [CCF] (i.MX)
In reply to Lukasz MajewskiQuoted 84 lines
Subject: [PATCH v4 01/13] clk: doc: Add documentation entry for Common Clock Framework [CCF] (i.MX)
This patch describes the design decisions considerations and taken approach for porting in a separate documentation entry.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- New patchChanges in v3: None
doc/imx/clk/ccf.txt | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 doc/imx/clk/ccf.txtdoc/imx/clk/ccf.txt new file +26
-0@@ -0,0 +1,83 @@ +Introduction: +============= + +This documentation entry describes the Common Clock Framework [CCF] +port from Linux kernel (5.0-rc3) to U-Boot. + +This code is supposed to bring CCF to IMX based devices (imx6q, imx7 +imx8). Moreover, it also provides some common clock code, which would +allow easy porting of CCF Linux code to other platforms. + +Design decisions: +================= + +* 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() caches the previously read data if +CLK_GET_RATE_NOCACHE + is not set (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]= ....
doc/imx/clk/ccf.txt new file +5
-0+ Instead we use udevice's linked list for the same class (UCLASS_CLK). + + Rationale: + ---------- + When porting the code as is from Linux, one would need ~1KiB of RAMto
doc/imx/clk/ccf.txt new file +20
-0+ 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 CCFcode.
doc/imx/clk/ccf.txt new file +5
-0+ + Question: + --------- + + Would it be better to use private_alloc_size (and dev->private) or stay
Quoted 2 lines
with
+driver_datato store struct clk pointer?
I prefer to use driver_data. Not want to bother with malloc failure.
Regards,
Peng
Quoted 42 lines
doc/imx/clk/ccf.txt new file +3
-0+ + The former requires some rewritting in CCF original code (to remove + (c)malloc, etc), but comply with u-boot DM. The latter allows re-usingthe
doc/imx/clk/ccf.txt new file +36
-1+ 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). + + This port uses the former approach with driver_data storing pointer to + struct clk. + +* 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). + +* Linux's CCF 'struct clk_core' corresponds to u-boot's udevice in 'struct clk'. + Clock IP block agnostic flags from 'struct clk_core' (e.g. NOCACHE) +have been + moved from this struct one level up to 'struct clk'. + +To do: +------ + +* Use of OF_PLATDATA in the SPL setup for CCF - as it is now - the SPL +grows + considerably and using CCF in boards with tiny resources (OCRAM) is + problematic. + +* On demand port other parts of CCF to U-Boot - as now only features +_really_ + needed by DM/DTS converted drivers are used. --2.11.0
PATCH v4 1/13 clk: doc: Add documentation entry for
In reply to Lukasz MajewskiQuoted 3 lines
This patch describes the design decisions considerations and taken approach for porting in a separate documentation entry.
Signed-off-by Lukasz Majewski <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 2/13 dm: Fix documentation entry as there is no UCLASS_CLOCK uclass
In reply to Lukasz MajewskiThere is no UCLASS_CLOCK uclass defined. Instead we do use the UCLASS_CLK.
---
Changes in v4:
- None
Changes in v3: None
include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/clk.h +1 -1
@@ -20,7 +20,7 @@* clock provider. This API provides a standard means for drivers to enable and * disable clocks, and to set the rate at which they oscillate. * -* A driver that implements UCLASS_CLOCK is a clock provider. A provider will +* A driver that implements UCLASS_CLK is a clock provider. A provider will * often implement multiple separate clocks, since the hardware it manages * often has this capability. clk-uclass.h describes the interface which * clock providers must implement.
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 2/13 dm: Fix documentation entry as there is no UCLASS_CLOCK uclass
Quoted 26 lines
Subject: [PATCH v4 02/13] dm: Fix documentation entry as there is no
UCLASS_CLOCKuclassThere is no
UCLASS_CLOCKuclass defined. Instead we do use theUCLASS_CLK.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/clk.h index d24e99713a..a909b71f1a renamed from include/clk.h +0
-0100644
include/clk.h +0
-0@@ -20,7 +20,7 @@* clock provider. This API provides a standard means for drivers to enable and
Quoted 8 lines
* disable clocks, and to set the rate at which they oscillate. *
- * A driver that implementsUCLASS_CLOCKis a clock provider. A provider will
+ * A driver that implementsUCLASS_CLKis a clock provider. A provider
+ will
* often implement multiple separate clocks, since the hardware it manages
* often has this capability.clk-uclass.hdescribes the interface which
* clock providers must implement.
Quoted 2 lines
--
2.11.0
PATCH v4 2/13 dm: Fix documentation entry as there is
In reply to Lukasz MajewskiQuoted 4 lines
There is no
UCLASS_CLOCKuclass defined. Instead we do use theUCLASS_CLK.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 3/13 clk: Remove clock ID check in .get_rate() of clk_fixed_*
In reply to Lukasz MajewskiThis check requires the struct clk passed to .get_rate() to be always cleared out as any clock with valid ID causes -EINVAL return value.
The return code of fixed clocks shall always be returned.
---
Changes in v4:
- None
Changes in v3: None
drivers/clk/clk_fixed_factor.c | 3 --- drivers/clk/clk_fixed_rate.c | 3 --- 2 files changed, 6 deletions(-)
drivers/clk/clk_fixed_factor.c +0 -3
@@ -24,9 +24,6 @@ static ulong clk_fixed_factor_get_rate(struct clk *clk)uint64_t rate;struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); -if (clk->id !=0 ) -return -EINVAL ; - rate =clk_get_rate (&ff->parent);if (IS_ERR_VALUE (rate))return rate;
drivers/clk/clk_fixed_rate.c +0 -3
@@ -15,9 +15,6 @@ struct clk_fixed_rate {static ulong clk_fixed_rate_get_rate (struct clk *clk) { -if (clk->id !=0 ) -return -EINVAL ; -return to_clk_fixed_rate (clk->dev)->fixed_rate; }
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 3/13 clk: Remove clock ID check in .get_rate() of clk_fixed_*
Quoted 40 lines
Subject: [PATCH v4 03/13] clk: Remove clock ID check in .get_rate() of clk_fixed_*
This check requires the struct clk passed to .get_rate() to be always cleared out as any clock with valid ID causes
-EINVALreturn value.The return code of fixed clocks shall always be returned.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
drivers/clk/clk_fixed_factor.c | 3 --- drivers/clk/clk_fixed_rate.c | 3 --- 2 files changed, 6 deletions(-)drivers/clk/clk_fixed_factor.c index renamed from drivers/clk/clk_fixed_factor.c +0
-0
5fa20a84db..dcdb6ddf5c100644drivers/clk/clk_fixed_factor.c +0
-3@@ -24,9 +24,6 @@ static ulong clk_fixed_factor_get_rate(struct clk *clk)uint64_t rate;struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); -if (clk->id !=0 ) -return -EINVAL ; - rate =clk_get_rate (&ff->parent);if (IS_ERR_VALUE (rate))return rate;drivers/clk/clk_fixed_rate.c index renamed from drivers/clk/clk_fixed_rate.c +0
-0
d8d9f86c86..50dbb13655100644
drivers/clk/clk_fixed_rate.c struct clk_fixed_rate { · line 19
Quoted 8 lines
drivers/clk/clk_fixed_rate.c +0
-3@@ -15,9 +15,6 @@ struct clk_fixed_rate {static ulong clk_fixed_rate_get_rate (struct clk *clk) { -if (clk->id !=0 ) -return -EINVAL ; -return to_clk_fixed_rate (clk->dev)->fixed_rate; }
Quoted 2 lines
drivers/clk/clk_fixed_rate.c +0
-1--2.11.0
PATCH v4 3/13 clk: Remove clock ID check in .get_rate() of clk_fixed_*
In reply to Lukasz MajewskiQuoted 38 lines · Lukasz Majewski
This check requires the struct clk passed to .get_rate() to be always cleared out as any clock with valid ID causes
-EINVALreturn value.The return code of fixed clocks shall always be returned.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
drivers/clk/clk_fixed_factor.c | 3 --- drivers/clk/clk_fixed_rate.c | 3 --- 2 files changed, 6 deletions(-)drivers/clk/clk_fixed_factor.c +0
-3@@ -24,9 +24,6 @@ static ulong clk_fixed_factor_get_rate(struct clk *clk)uint64_t rate;struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); -if (clk->id !=0 ) -return -EINVAL ; - rate =clk_get_rate (&ff->parent);if (IS_ERR_VALUE (rate))return rate;drivers/clk/clk_fixed_rate.c +0
-0
drivers/clk/clk_fixed_rate.c struct clk_fixed_rate { · line 20
Quoted 9 lines
drivers/clk/clk_fixed_rate.c +0
-3@@ -15,9 +15,6 @@ struct clk_fixed_rate {static ulong clk_fixed_rate_get_rate (struct clk *clk) { -if (clk->id !=0 ) -return -EINVAL ; -return to_clk_fixed_rate (clk->dev)->fixed_rate; }
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 3/13 clk: Remove clock ID check in .get_rate()
In reply to Lukasz MajewskiQuoted 6 lines
This check requires the struct clk passed to .get_rate() to be always cleared out as any clock with valid ID causes
-EINVALreturn value. The return code of fixed clocks shall always be returned.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 4/13 clk: Extend struct clk to provide information regarding clock rate
In reply to Lukasz MajewskiThis commit extends the struct clk to provide information regarding the clock rate.
As a result the clock tree traversal is performed at most once, and further reads are using the cached value.
---
Changes in v4:
- None
Changes in v3: None
include/clk.h | 2 ++ 1 file changed, 2 insertions(+)
include/clk.h +2 -0
@@ -40,6 +40,7 @@ struct udevice;* other clock APIs to identify which clock signal to operate upon. * * @dev: The device which implements the clock signal. +* @rate: The clock rate (in HZ). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not * sufficient. If used, it can be populated through an .of_xlate op and
@@ -55,6 +56,7 @@ struct udevice;*/ struct clk {struct udevice *dev; +unsigned long rate;/* in HZ */ /* * Written by of_xlate. In the future, we might add more fields here. */
Signature · 1 line
2.11.0
PATCH v4 4/13 clk: Extend struct clk to provide information regarding clock rate
Quoted 30 lines · Lukasz Majewski
This commit extends the struct clk to provide information regarding the clock rate.
As a result the clock tree traversal is performed at most once, and further reads are using the cached value.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
include/clk.h | 2 ++ 1 file changed, 2 insertions(+)include/clk.h +1
-0@@ -40,6 +40,7 @@ struct udevice;* other clock APIs to identify which clock signal to operate upon. * * @dev: The device which implements the clock signal. +* @rate: The clock rate (in HZ). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not * sufficient. If used, it can be populated through an .of_xlate op and
include/clk.h struct udevice; · line 59
Quoted 4 lines
include/clk.h +1
-0@@ -55,6 +56,7 @@ struct udevice;*/ struct clk {struct udevice *dev; +unsigned long rate;/* in HZ */
Can this be unsigned long long ? Think of 3 GHz PLL on arm32 in IDT Versaclock line of clock synthesisers ; this would overflow right here.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v4 4/13 clk: Extend struct clk to provide information regarding clock rate
Hi Marek,
Quoted 32 lines · Lukasz Majewski
Quoted 31 lines
This commit extends the struct clk to provide information regarding the clock rate.
As a result the clock tree traversal is performed at most once, and further reads are using the cached value.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
include/clk.h | 2 ++ 1 file changed, 2 insertions(+)include/clk.h +1
-0@@ -40,6 +40,7 @@ struct udevice;* other clock APIs to identify which clock signal to operate upon. * * @dev: The device which implements the clock signal. +* @rate: The clock rate (in HZ). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not
* sufficient. If used, it can be populated through
an .of_xlate op and @@ -55,6 +56,7 @@ struct udevice;
Quoted 9 lines
include/clk.h struct udevice; · line 59
Quoted 4 lines
*/
struct clk {include/clk.h +1
-0struct udevice *dev; +unsigned long rate;/* in HZ */ Can this be unsigned long long ? Think of 3 GHz PLL on arm32 in IDT Versaclock line of clock synthesisers ; this would overflow right here.
Thanks for spotting this - I will use unsigned long long instead.
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/20190517/760800bf/attachment.sig>
PATCH v4 4/13 clk: Extend struct clk to provide information regarding clock rate
In reply to Lukasz MajewskiQuoted 31 lines · Lukasz Majewski
This commit extends the struct clk to provide information regarding the clock rate.
As a result the clock tree traversal is performed at most once, and further reads are using the cached value.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
include/clk.h | 2 ++ 1 file changed, 2 insertions(+)include/clk.h +1
-0@@ -40,6 +40,7 @@ struct udevice;* other clock APIs to identify which clock signal to operate upon. * * @dev: The device which implements the clock signal. +* @rate: The clock rate (in HZ). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not * sufficient. If used, it can be populated through an .of_xlate op and
include/clk.h struct udevice; · line 62
Quoted 7 lines
include/clk.h +1
-0@@ -55,6 +56,7 @@ struct udevice;*/ struct clk {struct udevice *dev; +unsigned long rate;/* in HZ */ /* * Written by of_xlate. In the future, we might add more fields here. */
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 4/13 clk: Extend struct clk to provide
In reply to Lukasz MajewskiQuoted 6 lines
This commit extends the struct clk to provide information regarding the clock rate.
As a result the clock tree traversal is performed at most once, and further reads are using the cached value.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 5/13 clk: Extend struct clk to provide clock type agnostic flags
In reply to Lukasz MajewskiThis commit extends the struct clk to provide information regarding the flags related to this devices.
Those flags are clk device agnostic and indicate generic features (like e.g. CLK_GET_RATE_NOCACHE - the need to always recalculate the rate).
---
Changes in v4:
- New patch
Changes in v3: None
include/clk.h | 4 ++++ 1 file changed, 4 insertions(+)
include/clk.h +4 -0
@@ -41,6 +41,9 @@ struct udevice;* * @dev: The device which implements the clock signal. * @rate: The clock rate (in HZ). +* @flags: Flags used across common clock structure (e.g. CLK_) +* Clock IP blocks specific flags (i.e. mux, div, gate, etc) are defined +* in struct's for those devices (e.g. struct clk_mux). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not * sufficient. If used, it can be populated through an .of_xlate op and
@@ -57,6 +60,7 @@ struct udevice;struct clk {struct udevice *dev;unsigned long rate;/* in HZ */ +uint32_t flags;/* * Written by of_xlate. In the future, we might add more fields here. */
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 5/13 clk: Extend struct clk to provide clock type agnostic flags
Quoted 37 lines
Subject: [PATCH v4 05/13] clk: Extend struct clk to provide clock type agnostic flags
This commit extends the struct clk to provide information regarding the flags related to this devices.
Those flags are clk device agnostic and indicate generic features (like e.g.
CLK_GET_RATE_NOCACHE- the need to always recalculate the rate).Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- New patchChanges in v3: None
include/clk.h | 4 ++++ 1 file changed, 4 insertions(+)include/clk.h +3
-0@@ -41,6 +41,9 @@ struct udevice;* * @dev: The device which implements the clock signal. * @rate: The clock rate (in HZ). +* @flags: Flags used across common clock structure (e.g. CLK_) +* Clock IP blocks specific flags (i.e. mux, div, gate, etc) are defined +* in struct's for those devices (e.g. struct clk_mux). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not
* sufficient. If used, it can be populated through an .of_xlate op and
include/clk.h struct udevice; · line 66
Quoted 7 lines
include/clk.h +1
-0@@ -57,6 +60,7 @@ struct udevice;struct clk {struct udevice *dev;unsigned long rate;/* in HZ */ +uint32_t flags;/* * Written by of_xlate. In the future, we might add more fields here. */
Quoted 2 lines
--
2.11.0
PATCH v4 5/13 clk: Extend struct clk to provide clock type agnostic flags
In reply to Lukasz MajewskiQuoted 34 lines · Lukasz Majewski
This commit extends the struct clk to provide information regarding the flags related to this devices.
Those flags are clk device agnostic and indicate generic features (like e.g.
CLK_GET_RATE_NOCACHE- the need to always recalculate the rate).Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- New patchChanges in v3: None
include/clk.h | 4 ++++ 1 file changed, 4 insertions(+)include/clk.h +3
-0@@ -41,6 +41,9 @@ struct udevice;* * @dev: The device which implements the clock signal. * @rate: The clock rate (in HZ). +* @flags: Flags used across common clock structure (e.g. CLK_) +* Clock IP blocks specific flags (i.e. mux, div, gate, etc) are defined +* in struct's for those devices (e.g. struct clk_mux). * @id: The clock signal ID within the provider. * @data: An optional data field for scenarios where a single integer ID is not * sufficient. If used, it can be populated through an .of_xlate op and
include/clk.h struct udevice; · line 66
Quoted 7 lines
include/clk.h +1
-0@@ -57,6 +60,7 @@ struct udevice;struct clk {struct udevice *dev;unsigned long rate;/* in HZ */ +uint32_t flags;/* * Written by of_xlate. In the future, we might add more fields here. */
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 5/13 clk: Extend struct clk to provide clock
In reply to Lukasz MajewskiQuoted 7 lines
This commit extends the struct clk to provide information regarding the flags related to this devices.
Those flags are clk device agnostic and indicate generic features (like e.g.CLK_GET_RATE_NOCACHE- the need to always recalculate the rate).Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 6/13 clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
In reply to Lukasz MajewskiUp till now the fixed rate clock ('osc') has been added to UCLASS_CLK without declaring struct clk. As a result it was only accessible by iterating the udevice's uclass list.
This is a problem for clock code, which operates on pointers to struct clk (like clk_get_rate()), not udevices.
After this change struct clk is accessible from udevice and udevice from struct clk.
---
Changes in v4:
- None
Changes in v3: None
drivers/clk/clk_fixed_rate.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/clk_fixed_rate.c +5 -0
@@ -8,6 +8,7 @@#include <dm.h> struct clk_fixed_rate { +struct clk clk;unsigned long fixed_rate; };
@@ -24,10 +25,14 @@ const struct clk_ops clk_fixed_rate_ops = {static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) { +struct clk *clk = &to_clk_fixed_rate (dev)->clk;#if !CONFIG_IS_ENABLED (OF_PLATDATA )to_clk_fixed_rate (dev)->fixed_rate =dev_read_u32_default (dev,"clock-frequency" ,0 );#endif +/* Make fixed rate clock accessible from higher level struct clk */ + dev->driver_data = (ulong )clk; + clk->dev = dev;return 0 ; }
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 6/13 clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
Quoted 38 lines
Subject: [PATCH v4 06/13] clk: Provide struct clk for fixed rate clock (
clk_fixed_rate.c)Up till now the fixed rate clock ('osc') has been added to
UCLASS_CLKwithout declaring struct clk. As a result it was only accessible by iterating the udevice's uclass list.This is a problem for clock code, which operates on pointers to struct clk (like
clk_get_rate()), not udevices.After this change struct clk is accessible from udevice and udevice from struct clk.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
drivers/clk/clk_fixed_rate.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/clk/clk_fixed_rate.c index renamed from drivers/clk/clk_fixed_rate.c +0
-0
50dbb13655..089f060a23100644drivers/clk/clk_fixed_rate.c +1
-0@@ -8,6 +8,7 @@#include <dm.h> struct clk_fixed_rate { +struct clk clk;unsigned long fixed_rate; };
drivers/clk/clk_fixed_rate.c const struct clk_ops clk_fixed_rate_ops = { · line 34
Quoted 10 lines
drivers/clk/clk_fixed_rate.c +4
-0@@ -24,10 +25,14 @@ const struct clk_ops clk_fixed_rate_ops = {static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) { +struct clk *clk = &to_clk_fixed_rate (dev)->clk;#if !CONFIG_IS_ENABLED (OF_PLATDATA )to_clk_fixed_rate (dev)->fixed_rate =dev_read_u32_default (dev,"clock-frequency" ,0 );#endif +/* Make fixed rate clock accessible from higher level struct clk */ + dev->driver_data = (ulong )clk; + clk->dev = dev;
Quoted 4 lines
drivers/clk/clk_fixed_rate.c +0
-1return 0 ; } --2.11.0
PATCH v4 6/13 clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
In reply to Lukasz MajewskiQuoted 40 lines · Lukasz Majewski
Up till now the fixed rate clock ('osc') has been added to
UCLASS_CLKwithout declaring struct clk. As a result it was only accessible by iterating the udevice's uclass list.This is a problem for clock code, which operates on pointers to struct clk (like
clk_get_rate()), not udevices.After this change struct clk is accessible from udevice and udevice from struct clk.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- NoneChanges in v3: None
drivers/clk/clk_fixed_rate.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/clk/clk_fixed_rate.c +2
-0@@ -8,6 +8,7 @@#include <dm.h> struct clk_fixed_rate { +struct clk clk;unsigned long fixed_rate; };@@ -24,10 +25,14 @@ const struct clk_ops clk_fixed_rate_ops = {static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) { +struct clk *clk = &to_clk_fixed_rate (dev)->clk;
drivers/clk/clk_fixed_rate.c const struct clk_ops clk_fixed_rate_ops = { · line 38
Quoted 10 lines
drivers/clk/clk_fixed_rate.c +3
-0#if !CONFIG_IS_ENABLED (OF_PLATDATA )to_clk_fixed_rate (dev)->fixed_rate =dev_read_u32_default (dev,"clock-frequency" ,0 );#endif +/* Make fixed rate clock accessible from higher level struct clk */ + dev->driver_data = (ulong )clk; + clk->dev = dev;return 0 ; }
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 6/13 clk: Provide struct clk for fixed rate
In reply to Lukasz MajewskiQuoted 10 lines
Up till now the fixed rate clock ('osc') has been added to
UCLASS_CLKwithout declaring struct clk. As a result it was only accessible by iterating the udevice's uclass list.
This is a problem for clock code, which operates on pointers to struct clk (likeclk_get_rate()), not udevices.
After this change struct clk is accessible from udevice and udevice from struct clk.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
In reply to Lukasz MajewskiThis commit adds the clk_get_parent() function, which is responsible for getting the parent's struct clock pointer.
U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the pdev->driver_data field is read.
---
Changes in v4: None
Changes in v3:
- New patch
drivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)
drivers/clk/clk-uclass.c +15 -0
@@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk)return ops->get_rate (clk); } +struct clk *clk_get_parent (struct clk *clk) +{ +struct udevice *pdev; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pdev =dev_get_parent (clk->dev); + pclk = (struct clk *)dev_get_driver_data (pdev); +if (!pclk) +return ERR_PTR (-ENODEV ); + +return pclk; +} +ulong clk_set_rate (struct clk *clk,ulong rate) {const struct clk_ops *ops =clk_dev_ops (clk->dev);
include/clk.h +9 -0
@@ -259,6 +259,15 @@ int clk_free(struct clk *clk);ulong clk_get_rate (struct clk *clk);/** +* clk_get_parent() - Get current clock's parent. +* +* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return pointer to parent's struct clk, or error code passed as pointer +*/ +struct clk *clk_get_parent (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
Quoted 43 lines
-----Original Message-----
From: Lukasz Majewski [mailto:lukma at denx.de]
Sent: 2019年5月17日 6:11
To: Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; Marek Vasut <[email protected]>; Simon Glass <[email protected]>; Tom Rini <[email protected]>; u-boot at lists.denx.de; Jagan Teki <[email protected]>; Peng Fan <[email protected]>; Marcel Ziswiler <[email protected]>; Adam Ford <[email protected]>
Cc: Lukasz Majewski <[email protected]>; Neil Armstrong <[email protected]>; Philipp Tomsich <[email protected]>; Andreas Dannenberg <[email protected]>; Fabrice Gasnier <[email protected]>; Liviu Dudau <[email protected]>
Subject: [PATCH v4 07/13] dm: clk: Defineclk_get_parent()for clk operationsThis commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
79b3b0494c..1a726dafaa100644drivers/clk/clk-uclass.c +0
-0@@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk)return ops->get_rate (clk);
drivers/clk/clk-uclass.c ulong clk_get_rate(struct clk *clk) · line 389
Quoted 10 lines
drivers/clk/clk-uclass.c +8
-0} +struct clk *clk_get_parent (struct clk *clk) { +struct udevice *pdev; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pdev =dev_get_parent (clk->dev); + pclk = (struct clk *)dev_get_driver_data (pdev);
This has a trick is that force driver_data to struct clk *, and this requires all clk wrappers needs take clk as the first element in the wrapper structure.
So better add a comment here. Then it is fine to me, and
Quoted 28 lines
drivers/clk/clk-uclass.c +6
-0+if (!pclk) +return ERR_PTR (-ENODEV ); + +return pclk; +} +ulong clk_set_rate (struct clk *clk,ulong rate) { const struct clk_ops *ops = clk_dev_ops(clk->dev); diff --git
a/include/clk.hb/include/clk.hindex89dc64bfaf..0873b1e507100644include/clk.h +8
-1@@ -259,6 +259,15 @@ int clk_free(struct clk *clk); ulong clk_get_rate(struct clk *clk);/** +* clk_get_parent() - Get current clock's parent. +* +* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return pointer to parent's struct clk, or error code passed as +pointer */ struct clk *clk_get_parent (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by -- 2.11.0
Peng Fan
reviewerPATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
Quoted 51 lines
Subject: Re: [U-Boot] [PATCH v4 07/13] dm: clk: Define
clk_get_parent()for clk operationsQuoted 8 lines
-----Original Message-----
From: Lukasz Majewski [mailto:lukma at denx.de]
Sent: 2019年5月17日 6:11
To: Stefano Babic <[email protected]>; Fabio Estevam <[email protected]>; Marek Vasut <[email protected]>; Simon Glass <[email protected]>; Tom Rini <[email protected]>;
u-boot at lists.denx.de; Jagan Teki <[email protected]>; Peng Fan <[email protected]>; Marcel ZiswilerQuoted 37 lines
Adam Ford <[email protected]>
Cc: Lukasz Majewski <[email protected]>; Neil Armstrong <[email protected]>; Philipp Tomsich <[email protected]>; Andreas Dannenberg <[email protected]>; Fabrice Gasnier <[email protected]>; Liviu Dudau <[email protected]>
Subject: [PATCH v4 07/13] dm: clk: Defineclk_get_parent()for clk operationsThis commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
79b3b0494c..1a726dafaa100644drivers/clk/clk-uclass.c +0
-0@@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk)return ops->get_rate (clk); }
Quoted 12 lines
drivers/clk/clk-uclass.c ulong clk_get_rate(struct clk *clk) · line 390
Quoted 8 lines
drivers/clk/clk-uclass.c +8
-0+struct clk *clk_get_parent (struct clk *clk) { +struct udevice *pdev; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pdev =dev_get_parent (clk->dev); + pclk = (struct clk *)dev_get_driver_data (pdev);This has a trick is that force
driver_datato struct clk *, and this requires all clk wrappers needs take clk as the first element in the wrapper structure. So better add a comment here. Then it is fine to me, and
Sorry, drop my upper comments. The code is correct. So Reviewed-by: Peng Fan <[email protected]>
Quoted 40 lines
Reviewed-by Peng Fan <[email protected]>Quoted 27 lines
drivers/clk/clk-uclass.c +6
-0+if (!pclk) +return ERR_PTR (-ENODEV ); + +return pclk; +} +ulong clk_set_rate (struct clk *clk,ulong rate) { const struct clk_ops *ops = clk_dev_ops(clk->dev); diff --git
a/include/clk.hb/include/clk.hindex89dc64bfaf..0873b1e507100644include/clk.h +8
-1@@ -259,6 +259,15 @@ int clk_free(struct clk *clk); ulong clk_get_rate(struct clk *clk);/** +* clk_get_parent() - Get current clock's parent. +* +* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return pointer to parent's struct clk, or error code passed as +pointer */ struct clk *clk_get_parent (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by -- Quoted 1 line
2.11.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.d
enx.de%2Flistinfo%2Fu-boot&data=02%7C01%7CPeng.Fan%40nxp.com %7C9d8b9fb6d116473a8af508d6da8b1d64%7C686ea1d3bc2b4c6fa92cd99c5 c301635%7C0%7C0%7C636936688386713361&sdata=68OR%2Fa6jjixt2 h5bs0darbR4%2B5Yz88JD51RfjSCfK3Q%3D&reserved=0
Peng Fan
reviewerPATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
In reply to Lukasz MajewskiQuoted 55 lines
Subject: [PATCH v4 07/13] dm: clk: Define
clk_get_parent()for clk operationsThis commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
79b3b0494c..1a726dafaa100644drivers/clk/clk-uclass.c +14
-0@@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk)return ops->get_rate (clk); } +struct clk *clk_get_parent (struct clk *clk) { +struct udevice *pdev; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pdev =dev_get_parent (clk->dev); + pclk = (struct clk *)dev_get_driver_data (pdev); +if (!pclk) +return ERR_PTR (-ENODEV ); + +return pclk; +} +ulong clk_set_rate (struct clk *clk,ulong rate) { const struct clk_ops *ops = clk_dev_ops(clk->dev); diff --git
a/include/clk.hb/include/clk.hindex89dc64bfaf..0873b1e507100644include/clk.h +2
-0@@ -259,6 +259,15 @@ int clk_free(struct clk *clk); ulong clk_get_rate(struct clk *clk);/** +* clk_get_parent() - Get current clock's parent. +*
include/clk.h int clk_free(struct clk *clk); ulong
Quoted 10 lines
include/clk.h +6
-1+* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return pointer to parent's struct clk, or error code passed as +pointer */ struct clk *clk_get_parent (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by --
Quoted 1 line
2.11.0
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
In reply to Lukasz MajewskiQuoted 13 lines · Lukasz Majewski
This commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Quoted 7 lines
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)
Please can you add a test for this?
Regards,
Simon
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
Quoted 18 lines · On Sat, 18 May 2019 10:08:36 -0600 Simon Glass <[email protected]> wrote:
Quoted 17 lines · Lukasz Majewski
This commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patch
Quoted 5 lines
Quoted 3 lines
drivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)Please can you add a test for this?
It is implicitly covered here:
http://patchwork.ozlabs.org/patch/1100767/
but maybe shall I add a separate test case?
However, considering the other reply to the driver_data field usage, those tests would probably need redesign anyway.
Quoted 3 lines
Regards,
Simon
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/20190518/b9a5e824/attachment.sig>
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
Hi Lukasz,
Quoted 26 lines · Lukasz Majewski
Quoted 22 lines · On Sat, 18 May 2019 10:08:36 -0600 Simon Glass <[email protected]> wrote:
Quoted 20 lines · Lukasz Majewski
This commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)
Quoted 6 lines
Quoted 1 line
Please can you add a test for this?
It is implicitly covered here:
http://patchwork.ozlabs.org/patch/1100767/but maybe shall I add a separate test case?
That's fine I think. We just want to make sure that if someone breaks the code we will notice.
Quoted 3 lines
However, considering the other reply to the
driver_datafield usage, those tests would probably need redesign anyway.
Yes I really am not keen on that.
Regards,
Simon
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk operations
In reply to Lukasz MajewskiQuoted 57 lines · Lukasz Majewski
This commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent the
pdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patchdrivers/clk/clk-uclass.c | 15 +++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 24 insertions(+)drivers/clk/clk-uclass.c +15
-0@@ -379,6 +379,21 @@ ulong clk_get_rate(struct clk *clk)return ops->get_rate (clk); } +struct clk *clk_get_parent (struct clk *clk) +{ +struct udevice *pdev; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pdev =dev_get_parent (clk->dev); + pclk = (struct clk *)dev_get_driver_data (pdev); +if (!pclk) +return ERR_PTR (-ENODEV ); + +return pclk; +} +ulong clk_set_rate (struct clk *clk,ulong rate) {const struct clk_ops *ops =clk_dev_ops (clk->dev);include/clk.h +2
-0@@ -259,6 +259,15 @@ int clk_free(struct clk *clk);ulong clk_get_rate (struct clk *clk);/** +* clk_get_parent() - Get current clock's parent. +*
include/clk.h int clk_free(struct clk *clk); · line 273
Quoted 10 lines
include/clk.h +7
-0+* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return pointer to parent's struct clk, or error code passed as pointer +*/ +struct clk *clk_get_parent (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 7/13 dm: clk: Define clk_get_parent() for clk
In reply to Lukasz MajewskiQuoted 10 lines
This commit adds the
clk_get_parent()function, which is responsible for getting the parent's struct clock pointer.
U-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux. To obtain the pointer to struct clk of parent thepdev->driver_datafield is read.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 8/13 dm: clk: Define clk_get_parent_rate() for clk operations
In reply to Lukasz MajewskiThis commit adds the clk_get_parent_rate() function, which is responsible for getting the rate of parent clock.
Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux.
To alleviate this problem - the clk_get_parent_rate() function has been introduced to clk-uclass.c.
---
Changes in v4: None
Changes in v3:
- The rate information is now cached into struct clk field
- The clk_get_parent() is used to get pointer to the parent struct clk
drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 31 insertions(+)
drivers/clk/clk-uclass.c +22 -0
@@ -394,6 +394,28 @@ struct clk *clk_get_parent(struct clk *clk)return pclk; } +ulong clk_get_parent_rate (struct clk *clk) +{ +const struct clk_ops *ops; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pclk =clk_get_parent (clk); +if (IS_ERR (pclk)) +return -ENODEV ; + + ops =clk_dev_ops (pclk->dev); +if (!ops->get_rate) +return -ENOSYS ; + +/* Read the 'rate' if not already set */ +if (!pclk->rate) + pclk->rate =clk_get_rate (pclk); + +return pclk->rate; +} +ulong clk_set_rate (struct clk *clk,ulong rate) {const struct clk_ops *ops =clk_dev_ops (clk->dev);
include/clk.h +9 -0
@@ -268,6 +268,15 @@ ulong clk_get_rate(struct clk *clk);struct clk *clk_get_parent (struct clk *clk);/** +* clk_get_parent_rate() - Get parent of current clock rate. +* +* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return clock rate in Hz, or -ve error code. +*/ +ulong clk_get_parent_rate (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 8/13 dm: clk: Define clk_get_parent_rate() for clk operations
Quoted 65 lines
Subject: [PATCH v4 08/13] dm: clk: Define
clk_get_parent_rate()for clk operationsThis commit adds the
clk_get_parent_rate()function, which is responsible for getting the rate of parent clock.
Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux.To alleviate this problem - the
clk_get_parent_rate()function has been introduced toclk-uclass.c.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clkdrivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 31 insertions(+)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
1a726dafaa..ea43871112100644drivers/clk/clk-uclass.c +21
-0@@ -394,6 +394,28 @@ struct clk *clk_get_parent(struct clk *clk)return pclk; } +ulong clk_get_parent_rate (struct clk *clk) { +const struct clk_ops *ops; +struct clk *pclk; + +debug ("%s(clk=%p)\n" , __func__, clk); + + pclk =clk_get_parent (clk); +if (IS_ERR (pclk)) +return -ENODEV ; + + ops =clk_dev_ops (pclk->dev); +if (!ops->get_rate) +return -ENOSYS ; + +/* Read the 'rate' if not already set */ +if (!pclk->rate) + pclk->rate =clk_get_rate (pclk); + +return pclk->rate; +} +ulong clk_set_rate (struct clk *clk,ulong rate) { const struct clk_ops *ops = clk_dev_ops(clk->dev); diff --git
a/include/clk.hb/include/clk.hindex0873b1e507..955699eb18100644include/clk.h +2
-0@@ -268,6 +268,15 @@ ulong clk_get_rate(struct clk *clk); struct clk *clk_get_parent(struct clk *clk);/** +* clk_get_parent_rate() - Get parent of current clock rate. +*
include/clk.h ulong clk_get_rate(struct clk *clk); struct clk · line 282
Quoted 10 lines
include/clk.h +7
-0+* @clk: A clock struct that was previously successfully requested by +* clk_request/get_by_*(). +* @return clock rate in Hz, or -ve error code. +*/ +ulong clk_get_parent_rate (struct clk *clk); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by
Quoted 2 lines
--
2.11.0
PATCH v4 8/13 dm: clk: Define clk_get_parent_rate() for clk operations
In reply to Lukasz MajewskiHi Lukasz,
Quoted 14 lines · Lukasz Majewski
This commit adds the
clk_get_parent_rate()function, which is responsible for getting the rate of parent clock.
Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux.To alleviate this problem - the
clk_get_parent_rate()function has been introduced toclk-uclass.c.Signed-off-by Lukasz Majewski <[email protected]>---
Quoted 9 lines
Changes in v4: None
Changes in v3:
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clkdrivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 31 insertions(+)
This also needs a test.
Regards,
Simon
PATCH v4 8/13 dm: clk: Define clk_get_parent_rate() for clk operations
Hi Simon,
Quoted 23 lines
Hi Lukasz,
Quoted 20 lines · Lukasz Majewski
This commit adds the
clk_get_parent_rate()function, which is responsible for getting the rate of parent clock. Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux.To alleviate this problem - the
clk_get_parent_rate()function has been introduced toclk-uclass.c.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
Quoted 6 lines
Quoted 4 lines
drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 9 +++++++++ 2 files changed, 31 insertions(+)This also needs a test.
Please find corresponding test:
http://patchwork.ozlabs.org/patch/1100767/
which covers clk_get_parent() and clk_get_parent_rate() as well.
Quoted 3 lines
Regards,
Simon
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/20190518/7bcb0447/attachment.sig>
PATCH v4 8/13 dm: clk: Define clk_get_parent_rate() for
In reply to Lukasz MajewskiQuoted 9 lines
This commit adds the
clk_get_parent_rate()function, which is responsible for getting the rate of parent clock.
Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in common clock framework (CCF) in Linux.
To alleviate this problem - theclk_get_parent_rate()function has been introduced toclk-uclass.c.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk operations
In reply to Lukasz MajewskiThis commit adds the clk_get_by_id() function, which is responsible for getting the udevice with matching clk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK). As a result - we don't need any other external list - it is just enough to look for UCLASS_CLK related udevices.
---
Changes in v4: None
Changes in v3:
- Replace -ENODEV with -ENOENT
- Use **clkp instead of **c
drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 11 +++++++++++ 2 files changed, 33 insertions(+)
drivers/clk/clk-uclass.c +22 -0
@@ -490,6 +490,28 @@ int clk_disable_bulk(struct clk_bulk *bulk)return 0 ; } +int clk_get_by_id (ulong id,struct clk **clkp) +{ +struct udevice *dev; +struct uclass *uc; +int ret; + + ret =uclass_get (UCLASS_CLK , &uc); +if (ret) +return ret; + + uclass_foreach_dev(dev, uc) { +struct clk *clk = (struct clk *)dev_get_driver_data (dev); + +if (clk && clk->id == id) { + *clkp = clk; +return 0 ; + } + } + +return -ENOENT ; +} +UCLASS_DRIVER (clk) = { .id =UCLASS_CLK , .name ="clk" ,
include/clk.h +11 -0
@@ -345,4 +345,15 @@ static inline bool clk_valid(struct clk *clk) {return !!clk->dev; } + +/** +* clk_get_by_id() - Get the clock by its ID +* +* @id: The clock ID to search for +* +* @clkp: A pointer to clock struct that has been found among added clocks +* to UCLASS_CLK +* @return zero on success, or -ENOENT on error +*/ +int clk_get_by_id (ulong id,struct clk **clkp);#endif
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk operations
Quoted 67 lines
Subject: [PATCH v4 09/13] dm: clk: Define
clk_get_by_id()for clk operationsThis commit adds the
clk_get_by_id()function, which is responsible for getting the udevice with matchingclk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK).
As a result - we don't need any other external list - it is just enough to look forUCLASS_CLKrelated udevices.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **cdrivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 11 +++++++++++ 2 files changed, 33 insertions(+)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
ea43871112..6f054396e3100644drivers/clk/clk-uclass.c +21
-0@@ -490,6 +490,28 @@ int clk_disable_bulk(struct clk_bulk *bulk)return 0 ; } +int clk_get_by_id (ulong id,struct clk **clkp) { +struct udevice *dev; +struct uclass *uc; +int ret; + + ret =uclass_get (UCLASS_CLK , &uc); +if (ret) +return ret; + + uclass_foreach_dev(dev, uc) { +struct clk *clk = (struct clk *)dev_get_driver_data (dev); + +if (clk && clk->id == id) { + *clkp = clk; +return 0 ; + } + } + +return -ENOENT ; +} +UCLASS_DRIVER (clk) = { .id =UCLASS_CLK , .name ="clk" ,include/clk.h index 955699eb18..32ac2386ed renamed from include/clk.h +0
-0100644
include/clk.h +7
-0@@ -345,4 +345,15 @@ static inline bool clk_valid(struct clk *clk) {return !!clk->dev; } + +/** +* clk_get_by_id() - Get the clock by its ID +* +* @id: The clock ID to search for +* +* @clkp: A pointer to clock struct that has been found among added
Quoted 4 lines
clocks
+ * toUCLASS_CLK
+ * @return zero on success, or-ENOENTon error */ int +clk_get_by_id(ulong id, struct clk **clkp);
Quoted 3 lines
#endif
--
2.11.0
PATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk operations
In reply to Lukasz MajewskiHi Lukasz,
Quoted 11 lines · Lukasz Majewski
This commit adds the
clk_get_by_id()function, which is responsible for getting the udevice with matchingclk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK). As a result - we don't need any other external list - it is just enough to look forUCLASS_CLKrelated udevices.Signed-off-by Lukasz Majewski <[email protected]>---
Quoted 8 lines
Changes in v4: None
Changes in v3:
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **cdrivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 11 +++++++++++ 2 files changed, 33 insertions(+)
Again this new function needs a test. I'll stop commenting now :-)
Regards,
Simon
PATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk operations
Hi Simon,
Quoted 19 lines
Hi Lukasz,
Quoted 16 lines · Lukasz Majewski
This commit adds the
clk_get_by_id()function, which is responsible for getting the udevice with matchingclk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK). As a result - we don't need any other external list - it is just enough to look forUCLASS_CLKrelated udevices.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
Quoted 6 lines
Quoted 3 lines
drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 11 +++++++++++ 2 files changed, 33 insertions(+)Again this new function needs a test. I'll stop commenting now :-)
Please find corresponding test:
http://patchwork.ozlabs.org/patch/1100769/
Quoted 2 lines
Regards,
Simon
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/20190518/0a272e2c/attachment.sig>
PATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk operations
In reply to Lukasz MajewskiQuoted 63 lines · Lukasz Majewski
This commit adds the
clk_get_by_id()function, which is responsible for getting the udevice with matchingclk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK). As a result - we don't need any other external list - it is just enough to look forUCLASS_CLKrelated udevices.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **cdrivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 11 +++++++++++ 2 files changed, 33 insertions(+)drivers/clk/clk-uclass.c +22
-0@@ -490,6 +490,28 @@ int clk_disable_bulk(struct clk_bulk *bulk)return 0 ; } +int clk_get_by_id (ulong id,struct clk **clkp) +{ +struct udevice *dev; +struct uclass *uc; +int ret; + + ret =uclass_get (UCLASS_CLK , &uc); +if (ret) +return ret; + + uclass_foreach_dev(dev, uc) { +struct clk *clk = (struct clk *)dev_get_driver_data (dev); + +if (clk && clk->id == id) { + *clkp = clk; +return 0 ; + } + } + +return -ENOENT ; +} +UCLASS_DRIVER (clk) = { .id =UCLASS_CLK , .name ="clk" ,include/clk.h +2
-0@@ -345,4 +345,15 @@ static inline bool clk_valid(struct clk *clk) {return !!clk->dev; } + +/**
include/clk.h static inline bool clk_valid(struct clk *clk) · line 359
Quoted 10 lines
include/clk.h +9
-0+* clk_get_by_id() - Get the clock by its ID +* +* @id: The clock ID to search for +* +* @clkp: A pointer to clock struct that has been found among added clocks +* to UCLASS_CLK +* @return zero on success, or -ENOENT on error +*/ +int clk_get_by_id (ulong id,struct clk **clkp);#endif
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 9/13 dm: clk: Define clk_get_by_id() for clk
In reply to Lukasz MajewskiQuoted 8 lines
This commit adds the
clk_get_by_id()function, which is responsible for getting the udevice with matchingclk->id. Such approach allows re-usage of inherit DM list relationship for the same class (UCLASS_CLK). As a result - we don't need any other external list - it is just enough to look forUCLASS_CLKrelated udevices.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 10/13 clk: test: Provide unit test for clk_get_by_id() method
In reply to Lukasz MajewskiThis commit provides sandbox unit test for clk_get_by_id() method.
To test it default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
The clk_get_by_id() relies on dev->driver_data having the pointer to struct clk.
---
Changes in v4: None
Changes in v3:
- New patch
arch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 23 +++++++++++++++++++++++ test/dm/clk.c | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-)
arch/sandbox/include/asm/clk.h +8 -0
@@ -63,6 +63,14 @@ int sandbox_clk_query_enable(struct udevice *dev, int id);*/ int sandbox_clk_test_get (struct udevice *dev);/** +* sandbox_clk_test_get_by_id - Ask the sandbox clock test device to request its +* clocks by using clock id. +* +* @dev: The sandbox clock test (client) devivce. +* @return: 0 if OK, or a negative error code. +*/ +int sandbox_clk_test_get_by_id (struct udevice *dev); +/** * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its * clocks with the bulk clk API. *
drivers/clk/clk_sandbox_test.c +23 -0
@@ -34,6 +34,29 @@ int sandbox_clk_test_get(struct udevice *dev)return 0 ; } +int sandbox_clk_test_get_by_id (struct udevice *dev) +{ +struct sandbox_clk_test *sbct =dev_get_priv (dev); +struct clk *clkp, *i2c_clk; +ulong driver_data_bkp; +const int id =24 ; +int ret, id_bkp; + + i2c_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_I2C ]; + + id_bkp = i2c_clk->id; + i2c_clk->id = id; + driver_data_bkp = i2c_clk->dev->driver_data; + i2c_clk->dev->driver_data = (ulong )i2c_clk; + + ret =clk_get_by_id (id, &clkp); + + i2c_clk->id = id_bkp; + i2c_clk->dev->driver_data = driver_data_bkp; + +return ret; +} +int sandbox_clk_test_get_bulk (struct udevice *dev) {struct sandbox_clk_test *sbct =dev_get_priv (dev);
test/dm/clk.c +2 -1
@@ -120,8 +120,9 @@ static int dm_test_clk(struct unit_test_state *uts)ut_asserteq (0 ,sandbox_clk_query_enable (dev_clk,SANDBOX_CLK_ID_SPI ));ut_asserteq (0 ,sandbox_clk_query_enable (dev_clk,SANDBOX_CLK_ID_I2C )); -ut_assertok (sandbox_clk_test_free (dev_test)); +ut_asserteq (0 ,sandbox_clk_test_get_by_id (dev_test)); +ut_assertok (sandbox_clk_test_free (dev_test));return 0 ; }DM_TEST (dm_test_clk,DM_TESTF_SCAN_FDT );
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 10/13 clk: test: Provide unit test for clk_get_by_id() method
Quoted 82 lines
Subject: [PATCH v4 10/13] clk: test: Provide unit test for
clk_get_by_id()methodThis commit provides sandbox unit test for
clk_get_by_id()method.To test it default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
The
clk_get_by_id()relies ondev->driver_datahaving the pointer to struct clk.Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4: None
Changes in v3:
- New patcharch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 23 +++++++++++++++++++++++ test/dm/clk.c | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/arch/sandbox/include/asm/clk.hindex2b1c49f783..90f925109f100644arch/sandbox/include/asm/clk.h +9
-0@@ -63,6 +63,14 @@ int sandbox_clk_query_enable(struct udevice *dev, intid); */ int sandbox_clk_test_get (struct udevice *dev);/** +* sandbox_clk_test_get_by_id - Ask the sandbox clock test device to +request its +* clocks by using clock id. +* +* @dev: The sandbox clock test (client) devivce. +* @return: 0 if OK, or a negative error code. +*/ +int sandbox_clk_test_get_by_id (struct udevice *dev); +/** * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its
* clocks with the bulk clk API.
*drivers/clk/clk_sandbox_test.c +22
-0@@ -34,6 +34,29 @@ int sandbox_clk_test_get(struct udevice *dev)return 0 ; } +int sandbox_clk_test_get_by_id (struct udevice *dev) { +struct sandbox_clk_test *sbct =dev_get_priv (dev); +struct clk *clkp, *i2c_clk; +ulong driver_data_bkp; +const int id =24 ; +int ret, id_bkp; + + i2c_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_I2C ]; + + id_bkp = i2c_clk->id; + i2c_clk->id = id; + driver_data_bkp = i2c_clk->dev->driver_data; + i2c_clk->dev->driver_data = (ulong )i2c_clk; + + ret =clk_get_by_id (id, &clkp); + + i2c_clk->id = id_bkp; + i2c_clk->dev->driver_data = driver_data_bkp; + +return ret; +} +int sandbox_clk_test_get_bulk (struct udevice *dev) { struct sandbox_clk_test *sbct = dev_get_priv(dev); diff --git
a/test/dm/clk.cb/test/dm/clk.cindex f301ecbb45..1685532259 100644
test/dm/clk.c static int dm_test_clk(struct unit_test_state *uts) · line 128
Quoted 10 lines
test/dm/clk.c +2
-1@@ -120,8 +120,9 @@ static int dm_test_clk(struct unit_test_state *uts)ut_asserteq (0 ,sandbox_clk_query_enable (dev_clk,SANDBOX_CLK_ID_SPI ));ut_asserteq (0 ,sandbox_clk_query_enable (dev_clk,SANDBOX_CLK_ID_I2C )); -ut_assertok (sandbox_clk_test_free (dev_test)); +ut_asserteq (0 ,sandbox_clk_test_get_by_id (dev_test)); +ut_assertok (sandbox_clk_test_free (dev_test));return 0 ;
Quoted 4 lines
}
DM_TEST(dm_test_clk, DM_TESTF_SCAN_FDT);
--
2.11.0
PATCH v4 10/13 clk: test: Provide unit test for
In reply to Lukasz MajewskiQuoted 8 lines
This commit provides sandbox unit test for
clk_get_by_id()method. To test it default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
Theclk_get_by_id()relies ondev->driver_datahaving the pointer to struct clk.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 11/13 clk: test: Provide unit test for clk_get_parent_rate() method
In reply to Lukasz MajewskiThis commit provides sandbox unit test for clk_get_parent_rate() method.
For testing the default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
The clk_get_parent_rate() relies on dev->driver_data having the pointer to proper struct clk.
It uses internally clk_get_parent() method also tested by this test.
---
Changes in v4: None
Changes in v3:
- New patch
arch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 26 ++++++++++++++++++++++++++ test/dm/clk.c | 1 + 3 files changed, 35 insertions(+)
arch/sandbox/include/asm/clk.h +8 -0
@@ -79,6 +79,14 @@ int sandbox_clk_test_get_by_id(struct udevice *dev);*/ int sandbox_clk_test_get_bulk (struct udevice *dev);/** +* sandbox_clk_test_get_parent_rate - Ask the sandbox clock test device to +* query a passed clock's parent rate. +* +* @dev: The sandbox clock test (client) devivce. +* @return: The rate of the clock +*/ +ulong sandbox_clk_test_get_parent_rate (struct udevice *dev); +/** * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a * clock's rate. *
drivers/clk/clk_sandbox_test.c +26 -0
@@ -64,6 +64,32 @@ int sandbox_clk_test_get_bulk(struct udevice *dev)return clk_get_bulk (dev, &sbct->bulk); } +ulong sandbox_clk_test_get_parent_rate (struct udevice *dev) +{ +struct sandbox_clk_test *sbct =dev_get_priv (dev); +struct clk *i2c_clk, *parent_clk; +struct udevice *parent_bkp; +ulong rate; + + parent_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_FIXED ]; + i2c_clk = &sbct->clks[SANDBOX_CLK_TEST_ID_I2C ]; + + parent_clk->dev->driver_data = (ulong )parent_clk; + parent_bkp = i2c_clk->dev->parent; + i2c_clk->dev->parent = parent_clk->dev; + + rate =clk_get_parent_rate (i2c_clk); + + i2c_clk->dev->parent = parent_bkp; + parent_clk->dev->driver_data =0 ; + +/* Check if cache'd value is correct */ +if (parent_clk->rate !=1234 ) +return 0 ; + +return rate; +} +ulong sandbox_clk_test_get_rate (struct udevice *dev,int id) {struct sandbox_clk_test *sbct =dev_get_priv (dev);
test/dm/clk.c +1 -0
@@ -121,6 +121,7 @@ static int dm_test_clk(struct unit_test_state *uts)ut_asserteq (0 ,sandbox_clk_query_enable (dev_clk,SANDBOX_CLK_ID_I2C ));ut_asserteq (0 ,sandbox_clk_test_get_by_id (dev_test)); +ut_asserteq (1234 ,sandbox_clk_test_get_parent_rate (dev_test));ut_assertok (sandbox_clk_test_free (dev_test));return 0 ;
Signature · 1 line
2.11.0
PATCH v4 11/13 clk: test: Provide unit test for clk_get_parent_rate() method
Hi Lukasz,
Quoted 9 lines · Lukasz Majewski
This commit provides sandbox unit test for
clk_get_parent_rate()method.For testing the default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
The
clk_get_parent_rate()relies ondev->driver_datahaving the pointer to proper struct clk.
Yes, really want to avoid this.
Quoted 6 lines
It uses internally
clk_get_parent()method also tested by this test.Signed-off-by Lukasz Majewski <[email protected]>---
Quoted 8 lines
Changes in v4: None
Changes in v3:
- New patcharch/sandbox/include/asm/clk.h | 8 ++++++++ drivers/clk/clk_sandbox_test.c | 26 ++++++++++++++++++++++++++ test/dm/clk.c | 1 + 3 files changed, 35 insertions(+)
Regards,
Simon
PATCH v4 11/13 clk: test: Provide unit test for
In reply to Lukasz MajewskiQuoted 8 lines
This commit provides sandbox unit test for
clk_get_parent_rate()method. For testing the default test clocks setup had to be adjusted to emulate structure similar to clocks in the Common Clock Framework [CCF] (for iMX devices).
Theclk_get_parent_rate()relies ondev->driver_datahaving the pointer to proper struct clk.
It uses internallyclk_get_parent()method also tested by this test.Signed-off-by Lukasz Majewski <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 12/13 clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3)
In reply to Lukasz MajewskiThis commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup.
The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree.
One needs to pay attention to the comments indicating necessary for U-boot's DM changes.
If needed the code can be extended to support the "set" part of the clock management.
---
Changes in v4:
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly use container_of() based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
Changes in v3: None
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.c | 56 +++++++++++++ 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/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ 14 files changed, 1138 insertions(+) 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
drivers/clk/Kconfig +14 -0
@@ -46,6 +46,20 @@ config CLK_BOSTON help Enable this to support the clocks +config SPL_CLK_CCF + bool "SPL Common Clock Framework [CCF] support " + depends on SPL_CLK + help + Enable this option if you want to (re-)use the Linux kernel's Common + Clock Framework [CCF] code in U-Boot's SPL. + +config CLK_CCF + bool "Common Clock Framework [CCF] support " + depends on CLK + help + Enable this option if you want to (re-)use the Linux kernel's Common + Clock Framework [CCF] code in U-Boot's clock driver. + config CLK_STM32F bool "Enable clock driver support for STM32F family" depends on CLK && (STM32F7 || STM32F4)
drivers/clk/Makefile +2 -0
@@ -7,6 +7,8 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o +obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o +obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o obj-y += imx/ obj-y += tegra/
drivers/clk/clk-divider.c new file +148 -0
148 lines not on this page · raw message
drivers/clk/clk-fixed-factor.c new file +87 -0
87 lines not on this page · raw message
drivers/clk/clk-mux.c new file +164 -0
164 lines not on this page · raw message
drivers/clk/clk.c new file +56 -0
56 lines not on this page · raw message
drivers/clk/imx/Kconfig +9 -0
@@ -1,3 +1,12 @@ +config CLK_IMX6Q + bool "Clock support for i.MX6Q" + depends on ARCH_MX6 + select CLK + select CLK_CCF + select SPL_CLK_CCF + help + This enables DM/DTS support for clock driver in i.MX6Q platforms. + config CLK_IMX8 bool "Clock support for i.MX8" depends on ARCH_IMX8
drivers/clk/imx/Makefile +2 -0
@@ -2,6 +2,8 @@ # # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-gate2.o clk-pllv3.o clk-pfd.o +obj-$(CONFIG_CLK_IMX6Q) += clk-imx6q.o obj-$(CONFIG_CLK_IMX8) += clk-imx8.o ifdef CONFIG_CLK_IMX8
drivers/clk/imx/clk-gate2.c new file +113 -0
113 lines not on this page · raw message
drivers/clk/imx/clk-imx6q.c new file +179 -0
179 lines not on this page · raw message
drivers/clk/imx/clk-pfd.c new file +91 -0
91 lines not on this page · raw message
drivers/clk/imx/clk-pllv3.c new file +83 -0
83 lines not on this page · raw message
drivers/clk/imx/clk.h new file +75 -0
75 lines not on this page · raw message
include/linux/clk-provider.h new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 12/13 clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3)
Hi Lukasz,
Quoted 11 lines · Lukasz Majewski
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup.
The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree.
One needs to pay attention to the comments indicating necessary for U-boot's
nits: it's U-Boot. Please fix this globally in the commit message, as well as in the code comments in this commit.
Quoted 38 lines
DM changes.
If needed the code can be extended to support the "set" part of the clock management.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/Changes in v3: None
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.c | 56 +++++++++++++ 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/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ 14 files changed, 1138 insertions(+) create mode 100644 drivers/clk/clk-divider.c create mode 100644 drivers/clk/clk-fixed-factor.c
Quoted 9 lines
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
Regards,
Bin
PATCH v4 12/13 clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3)
Quoted 8 lines · Bin Meng
Hi Lukasz,
Quoted 4 lines · Lukasz Majewski
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup.
Two issues / questions:
1) I tried to test this on the imx6q_logic board, and I enabled CLK_IMX6Q in the menu config, but when I save the defconfig, it appears there are unmet dependencies.
WARNING: unmet direct dependencies detected for SPL_CLK_CCF
Depends on [n]: SPL_CLK [=n]
Selected by [y]:
- CLK_IMX6Q [=y] && ARCH_MX6 [=y]
WARNING: unmet direct dependencies detected for SPL_CLK_CCF
Depends on [n]: SPL_CLK [=n]
Selected by [y]:
- CLK_IMX6Q [=y] && ARCH_MX6 [=y]
you may want to consider implying the correct functions if ARCH_MX6 && CLK_IMX6Q or select the proper SPL_CLK info. My board doesn't do DM in SPL right now, but I assume the CLK driver you ported is using DM.
2) I didn't attempt to load the SPL portion, but when I loaded the u-boot-dtb.img file, it didn't appear to boot.
U-Boot SPL 2019.01 (May 13 2019 - 16:57:41 -0500) Trying to boot from MMC1spl_load_image_fat_os: error reading image args, err - -2
(hang)
Other than enabling CLK_IMX6Q, are there other items I need to enable?
My board has OF_CONTROL in U-Boot with DM support working in the
U-Boot portion.
adam
Quoted 61 lines
Quoted 7 lines
The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree.
One needs to pay attention to the comments indicating necessary for U-boot's
nits: it's U-Boot. Please fix this globally in the commit message, as well as in the code comments in this commit.
Quoted 38 lines
DM changes.
If needed the code can be extended to support the "set" part of the clock management.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/Changes in v3: None
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.c | 56 +++++++++++++ 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/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ 14 files changed, 1138 insertions(+) create mode 100644 drivers/clk/clk-divider.c create mode 100644 drivers/clk/clk-fixed-factor.cQuoted 9 lines
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.hRegards,
Bin
PATCH v4 12/13 clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: 5.0-rc3)
Quoted 23 lines · On Fri, 17 May 2019 07:31:38 -0500 Adam Ford <[email protected]> wrote:
Quoted 9 lines · Bin Meng
Hi Lukasz,
Quoted 4 lines · Lukasz Majewski
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup.
Two issues / questions:
1) I tried to test this on the
imx6q_logicboard, and I enabledCLK_IMX6Qin the menu config, but when I save the defconfig, it appears there are unmet dependencies.WARNING: unmet direct dependencies detected for
SPL_CLK_CCF
Depends on [n]:SPL_CLK[=n]
Selected by [y]:
-CLK_IMX6Q[=y] &&ARCH_MX6[=y]
Quoted 8 lines
WARNING: unmet direct dependencies detected for
SPL_CLK_CCF
Depends on [n]:SPL_CLK[=n]
Selected by [y]:
-CLK_IMX6Q[=y] &&ARCH_MX6[=y]you may want to consider implying the correct functions if
ARCH_MX6&&CLK_IMX6Qor select the properSPL_CLKinfo. My board doesn't do DM in SPL right now, but I assume the CLK driver you ported is using DM.
Ok. I will look into the Kconfig options.
Quoted 10 lines
2) I didn't attempt to load the SPL portion, but when I loaded the u-boot-dtb.img file, it didn't appear to boot.
U-Boot SPL 2019.01 (May 13 2019 - 16:57:41 -0500) Trying to boot from MMC1
spl_load_image_fat_os: error reading image args, err - -2
Quoted 6 lines
(hang)
Other than enabling
CLK_IMX6Q, are there other items I need to enable?
My board hasOF_CONTROLin U-Boot with DM support working in the
U-Boot portion.
The CCF shall work also with a setup where it is enabled only in u-boot proper (CONFIG_CLK_CCF).
Please look into following TPC DM/DTS port as a reference:
https://github.com/lmajewski/u-boot-dfu/commits/DM-SPL-TPC70
This board is fully converted and uses DM/DTS in SPL and u-boot proper (with CCF).
Quoted 63 lines
adam
Quoted 62 lines
Quoted 8 lines
The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree.
One needs to pay attention to the comments indicating necessary for U-boot's
nits: it's U-Boot. Please fix this globally in the commit message, as well as in the code comments in this commit.
Quoted 38 lines
DM changes.
If needed the code can be extended to support the "set" part of the clock management.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/Changes in v3: None
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.c | 56 +++++++++++++ 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/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ 14 files changed, 1138 insertions(+) create mode 100644Quoted 9 lines
drivers/clk/clk-divider.ccreate mode 100644drivers/clk/clk-fixed-factor.ccreate mode 100644drivers/clk/clk-mux.ccreate mode 100644drivers/clk/clk.ccreate mode 100644drivers/clk/imx/clk-gate2.ccreate mode 100644drivers/clk/imx/clk-imx6q.ccreate mode 100644drivers/clk/imx/clk-pfd.ccreate mode 100644drivers/clk/imx/clk-pllv3.ccreate mode 100644drivers/clk/imx/clk.hcreate mode 100644include/linux/clk-provider.hRegards,
Bin
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/20190517/f6a15a84/attachment.sig>
PATCH v4 12/13 clk: Port Linux common clock framework
In reply to Lukasz MajewskiQuoted 11 lines
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup. The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree.
One needs to pay attention to the comments indicating necessary for U-boot's DM changes.
If needed the code can be extended to support the "set" part of the clock management.
Quoted 1 line
Signed-off-by Lukasz Majewski <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 12/13 clk: Port Linux common clock framework
In reply to Lukasz MajewskiHi Stefano,
Quoted 13 lines
Quoted 11 lines
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup. The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree. One needs to pay attention to the comments indicating necessary for U-boot's DM changes.
If needed the code can be extended to support the "set" part of the clock management.Quoted 1 line
Signed-off-by Lukasz Majewski <[email protected]>
Quoted 1 line
Applied to u-boot-imx, master, thanks !
Thanks for pulling this code, but the v4 is not the final one.
Simon had some comments regarding the overall design and architecture of this port. Unfortunately I did not have time to address them yet.
I'm planning to do it ASAP, but IMHO it would be best to drop this series (so the final one would be applied from the outset).
Sorry for trouble.
Quoted 4 lines
Best regards,
Stefano Babic
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/20190610/f163af9a/attachment.sig>
PATCH v4 12/13 clk: Port Linux common clock framework
Quoted 15 lines · Lukasz Majewski
Hi Stefano,
Quoted 13 lines
Quoted 12 lines
This commit brings the files from Linux kernel to provide clocks support as it is used on the Linux kernel with common clock framework [CCF] setup. The directory structure has been preserved. The ported code only supports reading information from PLL, MUX, Divider, etc and enabling/disabling the clocks USDHCx/ECSPIx depending on used bus. Moreover, it is agnostic to the alias numbering as the information about the clock is read from device tree. One needs to pay attention to the comments indicating necessary for U-boot's DM changes.
If needed the code can be extended to support the "set" part of the clock management.Signed-off-by Lukasz Majewski <[email protected]>
Quoted 7 lines
Quoted 1 line
Applied to u-boot-imx, master, thanks !
Thanks for pulling this code, but the v4 is not the final one.
Simon had some comments regarding the overall design and architecture of this port. Unfortunately I did not have time to address them yet.
Ouch...I have not seen this, my mistake !
Quoted 3 lines
I'm planning to do it ASAP, but IMHO it would be best to drop this series (so the final one would be applied from the outset).
Right - I will drop the series, even if this means a rebase for u-boot-imx.
Quoted 2 lines
Sorry for trouble.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 13/13 dm: clk: Extend clk_get_parent_rate() to support CLK_GET_RATE_NOCACHE flag
In reply to Lukasz MajewskiIf the CLK_GET_RATE_NOCACHE flag is set - the clk_get_parent_rate() provides recalculated clock value without considering the cache setting.
This may be necessary for some clocks tightly coupled with power domains (i.e. imx8), and prevents from reading invalid cached values.
---
Changes in v4:
- New patch
Changes in v3: None
drivers/clk/clk-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +3 -2
@@ -13,6 +13,7 @@#include <dm/read.h> #include <dt-structs.h> #include <errno.h> +#include <linux/clk-provider.h> static inline const struct clk_ops *clk_dev_ops (struct udevice *dev) {
@@ -409,8 +410,8 @@ ulong clk_get_parent_rate(struct clk *clk)if (!ops->get_rate)return -ENOSYS ; -/* Read the 'rate' if not already set */ -if (!pclk->rate) +/* Read the 'rate' if not already set or if proper flag set*/ +if (!pclk->rate || pclk->flags &CLK_GET_RATE_NOCACHE ) pclk->rate =clk_get_rate (pclk);return pclk->rate;
Signature · 1 line
2.11.0
Peng Fan
reviewerPATCH v4 13/13 dm: clk: Extend clk_get_parent_rate() to support CLK_GET_RATE_NOCACHE flag
Quoted 31 lines
Subject: [PATCH v4 13/13] dm: clk: Extend
clk_get_parent_rate()to supportCLK_GET_RATE_NOCACHEflagIf the
CLK_GET_RATE_NOCACHEflag is set - theclk_get_parent_rate()provides recalculated clock value without considering the cache setting.This may be necessary for some clocks tightly coupled with power domains (i.e. imx8), and prevents from reading invalid cached values.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes in v4:
- New patchChanges in v3: None
drivers/clk/clk-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/clk/clk-uclass.c index renamed from drivers/clk/clk-uclass.c +0
-0
6f054396e3..3dcfae85c4100644drivers/clk/clk-uclass.c +1
-0@@ -13,6 +13,7 @@#include <dm/read.h> #include <dt-structs.h> #include <errno.h> +#include <linux/clk-provider.h>
drivers/clk/clk-uclass.c
Quoted 10 lines
drivers/clk/clk-uclass.c +2
-3static inline const struct clk_ops *clk_dev_ops(struct udevice *dev) { @@ -409,8 +410,8 @@ ulong clk_get_parent_rate(struct clk *clk)if (!ops->get_rate)return -ENOSYS ; -/* Read the 'rate' if not already set */ -if (!pclk->rate) +/* Read the 'rate' if not already set or if proper flag set*/ +if (!pclk->rate || pclk->flags &CLK_GET_RATE_NOCACHE ) pclk->rate =clk_get_rate (pclk);
Quoted 4 lines
return
pclk->rate;
--
2.11.0
PATCH v4 13/13 dm: clk: Extend clk_get_parent_rate() to
In reply to Lukasz MajewskiQuoted 6 lines
If the
CLK_GET_RATE_NOCACHEflag is set - theclk_get_parent_rate()provides recalculated clock value without considering the cache setting. This may be necessary for some clocks tightly coupled with power domains (i.e. imx8), and prevents from reading invalid cached values.Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Peng Fan <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
In reply to Lukasz MajewskikHi Lukasz,
Quoted 81 lines · Lukasz Majewski
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.cfile.Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patchChanges in v3:
- New patch
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
- New patch
- New patchLukasz Majewski (13):
clk: doc: Add documentation entry for Common Clock Framework [CCF](i.MX) dm: Fix documentation entry as there is no UCLASS_CLOCK uclass clk: Remove clock ID check in .get_rate() of clk_fixed_* clk: Extend struct clk to provide information regarding clock rate clk: Extend struct clk to provide clock type agnostic flags 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)dm: clk: Extend
clk_get_parent_rate()to supportCLK_GET_RATE_NOCACHE
flagarch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390 insertions(+), 8 deletions(-) create mode 100644 doc/imx/clk/ccf.txt create mode 100644 drivers/clk/clk-divider.c create mode 100644 drivers/clk/clk-fixed-factor.c
Quoted 8 lines
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
I don't see any new tests here other a trivial change in test/dm/clk.c
When adding new functionality to the generic clock code, tests should be added to cover this code. The sandbox clock driver should be enhanced as needed.
Regards,
Simon
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
Hi Simon,
Quoted 95 lines
kHi Lukasz,
Quoted 85 lines · Lukasz Majewski
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.cfile.Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patchChanges in v3:
- New patch
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
- New patch
- New patchLukasz Majewski (13):
clk: doc: Add documentation entry for Common Clock Framework [CCF](i.MX)dm: Fix documentation entry as there is no
UCLASS_CLOCKuclass
clk: Remove clock ID check in .get_rate() of clk_fixed_*
clk: Extend struct clk to provide information regarding clock rate
clk: Extend struct clk to provide clock type agnostic flags
clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
dm: clk: Defineclk_get_parent()for clk operations
dm: clk: Defineclk_get_parent_rate()for clk operations
dm: clk: Defineclk_get_by_id()for clk operations
clk: test: Provide unit test forclk_get_by_id()method
clk: test: Provide unit test forclk_get_parent_rate()method
clk: Port Linux common clock framework [CCF] for imx6q to U-boot
(tag: 5.0-rc3)
dm: clk: Extendclk_get_parent_rate()to supportCLK_GET_RATE_NOCACHEflagarch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390insertions(+), 8 deletions(-) create mode 100644
doc/imx/clk/ccf.txtcreate mode 100644drivers/clk/clk-divider.ccreate mode 100644drivers/clk/clk-fixed-factor.ccreate mode 100644drivers/clk/clk-mux.ccreate mode 100644drivers/clk/clk.cQuoted 6 lines
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
Quoted 5 lines
I don't see any new tests here other a trivial change in
test/dm/clk.cWhen adding new functionality to the generic clock code, tests should be added to cover this code. The sandbox clock driver should be enhanced as needed.
Please correct me if I'm wrong (or provide not enough code for those use cases), but I've added some tests here:
http://patchwork.ozlabs.org/patch/1100767/
http://patchwork.ozlabs.org/patch/1100769/
Are those not exhaustive enough? Have I overlooked something?
Quoted 3 lines
Regards,
Simon
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/20190518/1eaca3e2/attachment.sig>
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
Hi Lukasz,
Quoted 104 lines · Lukasz Majewski
Hi Simon,
Quoted 95 lines
kHi Lukasz,
Quoted 85 lines · Lukasz Majewski
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.cfile.Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc)
Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patchChanges in v3:
- New patch
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
- New patch
- New patchLukasz Majewski (13):
clk: doc: Add documentation entry for Common Clock Framework [CCF](i.MX)dm: Fix documentation entry as there is no
UCLASS_CLOCKuclass
clk: Remove clock ID check in .get_rate() of clk_fixed_*
clk: Extend struct clk to provide information regarding clock rate
clk: Extend struct clk to provide clock type agnostic flags
clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)
dm: clk: Defineclk_get_parent()for clk operations
dm: clk: Defineclk_get_parent_rate()for clk operations
dm: clk: Defineclk_get_by_id()for clk operations
clk: test: Provide unit test forclk_get_by_id()method
clk: test: Provide unit test forclk_get_parent_rate()method
clk: Port Linux common clock framework [CCF] for imx6q to U-boot
(tag: 5.0-rc3)
dm: clk: Extendclk_get_parent_rate()to supportCLK_GET_RATE_NOCACHEflagarch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390insertions(+), 8 deletions(-) create mode 100644
doc/imx/clk/ccf.txtcreate mode 100644drivers/clk/clk-divider.ccreate mode 100644drivers/clk/clk-fixed-factor.ccreate mode 100644drivers/clk/clk-mux.ccreate mode 100644drivers/clk/clk.cQuoted 6 lines
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.hQuoted 5 lines
I don't see any new tests here other a trivial change in
test/dm/clk.cWhen adding new functionality to the generic clock code, tests should be added to cover this code. The sandbox clock driver should be enhanced as needed.
Quoted 7 lines
Please correct me if I'm wrong (or provide not enough code for those use cases), but I've added some tests here:
http://patchwork.ozlabs.org/patch/1100767/
http://patchwork.ozlabs.org/patch/1100769/Are those not exhaustive enough? Have I overlooked something?
Sorry...I even looked at those patches but missed that they were tests. I think it would be better if the test code were in test/dm instead of drivers/clk/clk_sandbox_test.c.
I made a comment about the driver_data thing though.
I wonder if we should try to put tests (code in test/dm/... at least) in with the change that introduces new functionality? Or would that be too painful?
Regards,
Simon
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
Hi Simon,
Quoted 115 lines
Hi Lukasz,
Quoted 112 lines · Lukasz Majewski
Hi Simon,
Quoted 99 lines
kHi Lukasz,
Quoted 83 lines · Lukasz Majewski
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.cfile.Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc) Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patchChanges in v3:
- New patch
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
- New patch
- New patchLukasz Majewski (13):
clk: doc: Add documentation entry for Common Clock Framework
[CCF] (i.MX)
dm: Fix documentation entry as there is noUCLASS_CLOCKuclass
clk: Remove clock ID check in .get_rate() of clk_fixed_*
clk: Extend struct clk to provide information regarding clock
rate clk: Extend struct clk to provide clock type agnostic flags
clk: Provide struct clk for fixed rate clock
(clk_fixed_rate.c) dm: clk: Defineclk_get_parent()for clk operations dm: clk: Defineclk_get_parent_rate()for clk operations dm: clk: Defineclk_get_by_id()for clk operations
clk: test: Provide unit test forclk_get_by_id()method
clk: test: Provide unit test forclk_get_parent_rate()method
clk: Port Linux common clock framework [CCF] for imx6q to
U-boot (tag: 5.0-rc3)
dm: clk: Extendclk_get_parent_rate()to supportCLK_GET_RATE_NOCACHEflagarch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390Quoted 11 lines
insertions(+), 8 deletions(-) create mode 100644
doc/imx/clk/ccf.txtcreate mode 100644drivers/clk/clk-divider.ccreate mode 100644drivers/clk/clk-fixed-factor.ccreate mode 100644drivers/clk/clk-mux.ccreate mode 100644drivers/clk/clk.ccreate mode 100644drivers/clk/imx/clk-gate2.ccreate mode 100644drivers/clk/imx/clk-imx6q.ccreate mode 100644drivers/clk/imx/clk-pfd.ccreate mode 100644drivers/clk/imx/clk-pllv3.ccreate mode 100644drivers/clk/imx/clk.hcreate mode 100644include/linux/clk-provider.hQuoted 6 lines
I don't see any new tests here other a trivial change in
test/dm/clk.cWhen adding new functionality to the generic clock code, tests should be added to cover this code. The sandbox clock driver should be enhanced as needed.
Please correct me if I'm wrong (or provide not enough code for those use cases), but I've added some tests here:
Quoted 8 lines
Quoted 4 lines
http://patchwork.ozlabs.org/patch/1100767/
http://patchwork.ozlabs.org/patch/1100769/Are those not exhaustive enough? Have I overlooked something?
Sorry...I even looked at those patches but missed that they were tests. I think it would be better if the test code were in test/dm instead of
drivers/clk/clk_sandbox_test.c.
I've added those tests in the same place as original clk_get_rate(). However, there is no issue from my side to add them to test/dm if this is a better place.
Quoted 6 lines
I made a comment about the
driver_datathing though.I wonder if we should try to put tests (code in test/dm/... at least) in with the change that introduces new functionality? Or would that be too painful?
As I said above - if the test/dm/ directory is a better place (than drivers/clk/clk_sandbox_test.c) to place CCF (clk) related tests - then I'm fine with it.
Quoted 3 lines
Regards,
Simon
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/20190519/0ad9db2e/attachment.sig>
v4 cover clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3)
Hi Lukasz,
Quoted 134 lines · Lukasz Majewski
Hi Simon,
Quoted 115 lines
Hi Lukasz,
Quoted 112 lines · Lukasz Majewski
Hi Simon,
Quoted 99 lines
kHi Lukasz,
Quoted 83 lines · Lukasz Majewski
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.cfile.Repository:
https://github.com/lmajewski/u-boot-dfu/commits/CCF-v4Changes in v4:
- New patch
- None
- None
- None
- New patch
- None
- Port some more Linux code to facilitate imx8 code porting (most notably flags)
- Explicitly usecontainer_of()based macro to provide struct clk in various places (e.g. gate2, mux, etc) Following patches has been squashed:
http://patchwork.ozlabs.org/patch/1093141/
http://patchwork.ozlabs.org/patch/1093142/
http://patchwork.ozlabs.org/patch/1093146/
- New patchChanges in v3:
- New patch
- The rate information is now cached into struct clk field
- Theclk_get_parent()is used to get pointer to the parent struct clk
- Replace-ENODEVwith-ENOENT
- Use **clkp instead of **c
- New patch
- New patchLukasz Majewski (13):
clk: doc: Add documentation entry for Common Clock Framework
[CCF] (i.MX)
dm: Fix documentation entry as there is noUCLASS_CLOCKuclass
clk: Remove clock ID check in .get_rate() of clk_fixed_*
clk: Extend struct clk to provide information regarding clock
rate clk: Extend struct clk to provide clock type agnostic flags
clk: Provide struct clk for fixed rate clock
(clk_fixed_rate.c) dm: clk: Defineclk_get_parent()for clk operations dm: clk: Defineclk_get_parent_rate()for clk operations dm: clk: Defineclk_get_by_id()for clk operations
clk: test: Provide unit test forclk_get_by_id()method
clk: test: Provide unit test forclk_get_parent_rate()method
clk: Port Linux common clock framework [CCF] for imx6q to
U-boot (tag: 5.0-rc3)
dm: clk: Extendclk_get_parent_rate()to supportCLK_GET_RATE_NOCACHEflagarch/sandbox/include/asm/clk.h | 16 ++++ doc/imx/clk/ccf.txt | 83 +++++++++++++++++++ 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 | 60 ++++++++++++++ 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 | 37 ++++++++- include/linux/clk-provider.h | 115 ++++++++++++++++++++++++++ test/dm/clk.c | 4 +- 22 files changed, 1390Quoted 11 lines
insertions(+), 8 deletions(-) create mode 100644
doc/imx/clk/ccf.txtcreate mode 100644drivers/clk/clk-divider.ccreate mode 100644drivers/clk/clk-fixed-factor.ccreate mode 100644drivers/clk/clk-mux.ccreate mode 100644drivers/clk/clk.ccreate mode 100644drivers/clk/imx/clk-gate2.ccreate mode 100644drivers/clk/imx/clk-imx6q.ccreate mode 100644drivers/clk/imx/clk-pfd.ccreate mode 100644drivers/clk/imx/clk-pllv3.ccreate mode 100644drivers/clk/imx/clk.hcreate mode 100644include/linux/clk-provider.hQuoted 6 lines
I don't see any new tests here other a trivial change in
test/dm/clk.cWhen adding new functionality to the generic clock code, tests should be added to cover this code. The sandbox clock driver should be enhanced as needed.
Please correct me if I'm wrong (or provide not enough code for those use cases), but I've added some tests here:
Quoted 8 lines
Quoted 4 lines
http://patchwork.ozlabs.org/patch/1100767/
http://patchwork.ozlabs.org/patch/1100769/Are those not exhaustive enough? Have I overlooked something?
Sorry...I even looked at those patches but missed that they were tests. I think it would be better if the test code were in test/dm instead of
drivers/clk/clk_sandbox_test.c.I've added those tests in the same place as original
clk_get_rate(). However, there is no issue from my side to add them to test/dm if this is a better place.Quoted 3 lines
I made a comment about the
driver_datathing though.
Quoted 7 lines
Quoted 3 lines
I wonder if we should try to put tests (code in test/dm/... at least) in with the change that introduces new functionality? Or would that be too painful?
As I said above - if the test/dm/ directory is a better place (than
drivers/clk/clk_sandbox_test.c) to place CCF (clk) related tests - then I'm fine with it.
Well that file is strange. It seems to be a driver and not a test. But why can't it use the normal sandbox clock drivers?
Regards,
Simon