clk: imx: Use Clock frameworkt to register UART clocks
Subsystems (3)
cover clk: imx: Use Clock frameworkt to register UART clocks
Currenty, most peripherals enable/disable their respecive clocks using the clock framework, but serial ports various imx platsforms do not. Some of the newer NXP SoC's register the UART clocks, but they are not necessarily associated the to serial_mxc driver, so these clocks need to be manually enabled, and even when the driver model enumerates the UART, the driver model doesn't always reflect the proper clock state beacause these clocks are not controlled by the serial driver.
This series does a few things:
Register the missing UART clocks on imx6, 8mm, 8mn, fixes a build dependency on CCF_FRAMEWORK on imx8mp in SPL, bulk enables the UART clocks from the serial_mxc driver, and finally, removes the manual references to enabling the UART clocks on Beacon EmbeddedWorks imx8mm, imx8mn, and imx8mp development kits.
I don't have access to an imx6 board right now, nor do I have imx9 or imxrt boards, so I can't verify regressions on those platforms.
For users who want to try this series and remove the manual UART calls, make sure the SoC clock driver is enabled in SPL and OF_SPL_REMOVE_PROPS should not remove the clocks or clock names.
With this series both "clk dump" and "dm tree" show the UART clocks are registred and the one clocking the console UART is enabled and running.
Adam Ford (10):
clk: imx6q: Properly handle imx6qp ESPI clk_sels
clk: imx6q: Register UART clocks
clk: imx8mm: register UART clocks
clk: imx8mn: register UART clocks
serial: mxc: Support bulk enabling clocks
board: beacon: imx8mm: Let clock system enable UART clock
board: beacon: imx8mn: Let clock system enable UART clock
clk: imx: select SPL_CLK_COMPOSITE_CCF when SPL_CLK_IMX8MP
configs: imx8mp_beacon: Select SPL_CLK_IMX8MP
board: beacon: imx8mp: Let clock system enable UART clock
board/beacon/imx8mm/spl.c | 6 +---- board/beacon/imx8mn/spl.c | 2 -- board/beacon/imx8mp/spl.c | 2 -- configs/imx8mp_beacon_defconfig | 1 + drivers/clk/imx/Kconfig | 1 + drivers/clk/imx/clk-imx6q.c | 34 ++++++++++++++++++++++++--- drivers/clk/imx/clk-imx8mm.c | 34 +++++++++++++++++++++++++++ drivers/clk/imx/clk-imx8mn.c | 32 +++++++++++++++++++++++++ drivers/serial/serial_mxc.c | 11 +++++++++ include/dm/platform_data/serial_mxc.h | 1 + 10 files changed, 112 insertions(+), 12 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/10 clk: imx6q: Properly handle imx6qp ESPI clk_sels
The ECSPI clock has the ability to select between pll3_60m and osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.
--- drivers/clk/imx/clk-imx6q.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx6q.c +19 -3
@@ -13,6 +13,11 @@#include "clk.h" +static inline int clk_on_imx6qp (void ) +{ +return of_machine_is_compatible ("fsl,imx6qp" ); +} +static int imx6q_clk_request (struct clk *clk) {if (clk->id <IMX6QDL_CLK_DUMMY || clk->id >=IMX6QDL_CLK_END ) {
@@ -35,6 +40,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };static const char *const periph_sels[] = {"periph_pre" ,"periph_clk2" , };static const char *const periph_pre_sels[] = {"pll2_bus" ,"pll2_pfd2_396m" ,"pll2_pfd0_352m" ,"pll2_198m" , }; +static const char *const ecspi_sels[] = {"pll3_60m" ,"osc" , };static int imx6q_clk_probe (struct udevice *dev) {
@@ -78,6 +84,12 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_mux ("usdhc4_sel" , base +0x1c ,19 ,1 , usdhc_sels, ARRAY_SIZE(usdhc_sels))); +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_SEL , +imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels, +ARRAY_SIZE (ecspi_sels))); + } +clk_dm (IMX6QDL_CLK_USDHC1_PODF ,imx_clk_divider ("usdhc1_podf" ,"usdhc1_sel" , base +0x24 ,11 ,3 ));
@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3)); -clk_dm (IMX6QDL_CLK_ECSPI_ROOT , -imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); - +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); + }else { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); + }clk_dm (IMX6QDL_CLK_ECSPI1 ,imx_clk_gate2 ("ecspi1" ,"ecspi_root" , base +0x6c ,0 )); clk_dm(IMX6QDL_CLK_ECSPI2,
Signature · 1 line
2.45.2
Re: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
Hi Adam
Quoted 15 lines · Adam Ford
The ECSPI clock has the ability to select between
pll3_60mand osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.Signed-off-by Adam Ford <[email protected]>--- drivers/clk/imx/clk-imx6q.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/clk/imx/clk-imx6q.c +0
-0
drivers/clk/imx/clk-imx6q.c line 21
Quoted 9 lines
drivers/clk/imx/clk-imx6q.c +5
-0@@ -13,6 +13,11 @@#include "clk.h" +static inline int clk_on_imx6qp (void ) +{ +return of_machine_is_compatible ("fsl,imx6qp" ); +} +
It's static, why just not use direct compatible?
Quoted 45 lines
drivers/clk/imx/clk-imx6q.c +0
-0static int imx6q_clk_request (struct clk *clk) {if (clk->id < IMX6QDL_CLK_DUMMY || clk->id >= IMX6QDL_CLK_END) {drivers/clk/imx/clk-imx6q.c +1
-0@@ -35,6 +40,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };static const char *const periph_sels[] = {"periph_pre" ,"periph_clk2" , };static const char *const periph_pre_sels[] = {"pll2_bus" ,"pll2_pfd2_396m" ,"pll2_pfd0_352m" ,"pll2_198m" , }; +static const char *const ecspi_sels[] = {"pll3_60m" ,"osc" , };static int
imx6q_clk_probe(struct udevice *dev)
{drivers/clk/imx/clk-imx6q.c +6
-0@@ -78,6 +84,12 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_mux ("usdhc4_sel" , base +0x1c ,19 ,1 , usdhc_sels, ARRAY_SIZE(usdhc_sels))); +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_SEL , +imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels, +ARRAY_SIZE (ecspi_sels))); + } + clk_dm(IMX6QDL_CLK_USDHC1_PODF, imx_clk_divider("usdhc1_podf", "usdhc1_sel",base + 0x24, 11, 3));drivers/clk/imx/clk-imx6q.c +7
-3@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3)); -clk_dm (IMX6QDL_CLK_ECSPI_ROOT , -imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 , 6)); - +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); + }else { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); + }
Quoted 4 lines
clk_dm(IMX6QDL_CLK_ECSPI1,
imx_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0));
clk_dm(IMX6QDL_CLK_ECSPI2,Apart of that I'm almost fine with it.
Quoted 4 lines
--
2.45.2
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
Re: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
Quoted 23 lines · Michael Nazzareno Trimarchi
Hi Adam
Quoted 19 lines · Adam Ford
The ECSPI clock has the ability to select between
pll3_60mand osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.Signed-off-by Adam Ford <[email protected]>--- drivers/clk/imx/clk-imx6q.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/clk/imx/clk-imx6q.c +0
-0@@ -13,6 +13,11 @@#include "clk.h"
Quoted 8 lines
drivers/clk/imx/clk-imx6q.c line 20
Quoted 5 lines
drivers/clk/imx/clk-imx6q.c +5
-0+static inline int clk_on_imx6qp (void ) +{ +return of_machine_is_compatible ("fsl,imx6qp" ); +} +It's static, why just not use direct compatible?
I looked at how it was done in Linux, and it seemed easier to read. I can look at alternatives too. There might already be a helper function.
adam
Quoted 67 lines
Quoted 33 lines
drivers/clk/imx/clk-imx6q.c +7
-3static int imx6q_clk_request (struct clk *clk) {if (clk->id <IMX6QDL_CLK_DUMMY || clk->id >=IMX6QDL_CLK_END ) {@@ -35,6 +40,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };static const char *const periph_sels[] = {"periph_pre" ,"periph_clk2" , };static const char *const periph_pre_sels[] = {"pll2_bus" ,"pll2_pfd2_396m" ,"pll2_pfd0_352m" ,"pll2_198m" , }; +static const char *const ecspi_sels[] = {"pll3_60m" ,"osc" , };static int imx6q_clk_probe (struct udevice *dev) {@@ -78,6 +84,12 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_mux ("usdhc4_sel" , base +0x1c ,19 ,1 , usdhc_sels, ARRAY_SIZE(usdhc_sels))); +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_SEL , +imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels, +ARRAY_SIZE (ecspi_sels))); + } +clk_dm (IMX6QDL_CLK_USDHC1_PODF ,imx_clk_divider ("usdhc1_podf" ,"usdhc1_sel" , base +0x24 ,11 ,3 ));@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3)); -clk_dm (IMX6QDL_CLK_ECSPI_ROOT , -imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); -drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 115
Quoted 10 lines
drivers/clk/imx/clk-imx6q.c +7
-0+if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); + }else { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); + }clk_dm (IMX6QDL_CLK_ECSPI1 ,imx_clk_gate2 ("ecspi1" ,"ecspi_root" , base +0x6c ,0 )); clk_dm(IMX6QDL_CLK_ECSPI2,Apart of that I'm almost fine with it.
Reviewed-by Michael Trimarchi <[email protected]>Quoted 4 lines
--
2.45.2--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
Re: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
Hi
Quoted 34 lines · Adam Ford
Quoted 23 lines · Michael Nazzareno Trimarchi
Hi Adam
Quoted 19 lines · Adam Ford
The ECSPI clock has the ability to select between
pll3_60mand osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.Signed-off-by Adam Ford <[email protected]>--- drivers/clk/imx/clk-imx6q.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/clk/imx/clk-imx6q.c +0
-0@@ -13,6 +13,11 @@#include "clk.h" Quoted 8 lines
drivers/clk/imx/clk-imx6q.c line 20
Quoted 5 lines
drivers/clk/imx/clk-imx6q.c +5
-0+static inline int clk_on_imx6qp (void ) +{ +return of_machine_is_compatible ("fsl,imx6qp" ); +} +It's static, why just not use direct compatible?
Quoted 5 lines
I looked at how it was done in Linux, and it seemed easier to read. I can look at alternatives too. There might already be a helper function.
It's ok with other patches, I have seen the rest. I can test on some imx6
Michael
Quoted 77 lines
adam
Quoted 6 lines
drivers/clk/imx/clk-imx6q.c static const char *const usdhc_sels[] = {
Quoted 6 lines
drivers/clk/imx/clk-imx6q.c +0
-0static int imx6q_clk_request (struct clk *clk) {if (clk->id <IMX6QDL_CLK_DUMMY || clk->id >=IMX6QDL_CLK_END ) {@@ -35,6 +40,7 @@ static const char *const usdhc_sels[] = {"
pll2_pfd2_396m", "pll2_pfd0_352m", };Quoted 1 line
drivers/clk/imx/clk-imx6q.c static const char *const usdhc_sels[] = { · line 40
Quoted 1 line
drivers/clk/imx/clk-imx6q.c +0
-0static const char *const periph_sels[] = {"periph_pre" ,"
periph_clk2", };Quoted 1 line
drivers/clk/imx/clk-imx6q.c static const char *const usdhc_sels[] = { · line 41
Quoted 1 line
drivers/clk/imx/clk-imx6q.c +0
-0static const char *const periph_pre_sels[] = {"pll2_bus" ,"
pll2_pfd2_396m",Quoted 1 line
drivers/clk/imx/clk-imx6q.c static const char *const usdhc_sels[] = { · line 42
Quoted 1 line
drivers/clk/imx/clk-imx6q.c +0
-0"pll2_pfd0_352m","
pll2_198m", };Quoted 11 lines
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 89
Quoted 11 lines
drivers/clk/imx/clk-imx6q.c +4
-0+static const char *const ecspi_sels[] = {"pll3_60m" ,"osc" , };static int imx6q_clk_probe (struct udevice *dev) {@@ -78,6 +84,12 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_mux ("usdhc4_sel" , base +0x1c ,19 ,1 , usdhc_sels, ARRAY_SIZE(usdhc_sels))); +if (clk_on_imx6qp ()) { + clk_dm(IMX6QDL_CLK_ECSPI_SEL, + imx_clk_mux("ecspi_sel", base + 0x38, 18, 1,
ecspi_sels,Quoted 10 lines
Quoted 10 lines
drivers/clk/imx/clk-imx6q.c +3
-0+ ARRAY_SIZE(ecspi_sels))); + } +clk_dm (IMX6QDL_CLK_USDHC1_PODF ,imx_clk_divider ("usdhc1_podf" ,"usdhc1_sel" , base +0x24 ,11 ,3 ));@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3));Quoted 2 lines
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 95
Quoted 2 lines
drivers/clk/imx/clk-imx6q.c +0
-2- clk_dm(IMX6QDL_CLK_ECSPI_ROOT, - imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38,19, 6));
Quoted 4 lines
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev)
Quoted 4 lines
drivers/clk/imx/clk-imx6q.c +3
-1- +if (clk_on_imx6qp ()) { + clk_dm(IMX6QDL_CLK_ECSPI_ROOT, + imx_clk_divider("ecspi_root", "ecspi_sel", base+
0x38, 19, 6));Quoted 3 lines
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev)
Quoted 3 lines
drivers/clk/imx/clk-imx6q.c +3
-0+ }else { + clk_dm(IMX6QDL_CLK_ECSPI_ROOT, + imx_clk_divider("ecspi_root", "pll3_60m", base +
0x38, 19, 6));Quoted 28 lines
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 115
Quoted 4 lines
drivers/clk/imx/clk-imx6q.c +1
-0+ }clk_dm (IMX6QDL_CLK_ECSPI1 ,imx_clk_gate2 ("ecspi1" ,"ecspi_root" , base +0x6c ,0 )); clk_dm(IMX6QDL_CLK_ECSPI2,Apart of that I'm almost fine with it.
Reviewed-by Michael Trimarchi <[email protected]>Quoted 4 lines
--
2.45.2--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
Fabio Estevam
reviewerRe: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
In reply to Adam FordQuoted 5 lines · Adam Ford
The ECSPI clock has the ability to select between
pll3_60mand osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.
s/ESPI/ECSPI in the Subject.
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 91
Quoted 5 lines
drivers/clk/imx/clk-imx6q.c +5
-0+if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_SEL , +imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels, +ARRAY_SIZE (ecspi_sels))); + }
No need for { }.
Quoted 8 lines
drivers/clk/imx/clk-imx6q.c +1
-0+clk_dm (IMX6QDL_CLK_USDHC1_PODF ,imx_clk_divider ("usdhc1_podf" ,"usdhc1_sel" , base +0x24 ,11 ,3 ));@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3));
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 112
Quoted 10 lines
drivers/clk/imx/clk-imx6q.c +7
-3-clk_dm (IMX6QDL_CLK_ECSPI_ROOT , -imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); - +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); + }else { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); + }
Same here.
Re: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
Quoted 8 lines · Fabio Estevam
Quoted 5 lines · Adam Ford
The ECSPI clock has the ability to select between
pll3_60mand osc on the imx6qp, where it's fixed on other variants. Fix this by adding using a helper function to determine SoC variant and register the clock accordingly.
Fabio,
Thanks for the review. I will make the updates to the two patches you requested. Is there anything else you want changed before I submit V2?
adam
Quoted 30 lines
s/ESPI/ECSPI in the Subject.
drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 91
Quoted 5 lines
drivers/clk/imx/clk-imx6q.c +5
-0+if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_SEL , +imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels, +ARRAY_SIZE (ecspi_sels))); + }No need for { }.
Quoted 8 lines
drivers/clk/imx/clk-imx6q.c +1
-0+clk_dm (IMX6QDL_CLK_USDHC1_PODF ,imx_clk_divider ("usdhc1_podf" ,"usdhc1_sel" , base +0x24 ,11 ,3 ));@@ -91,9 +103,13 @@ static int imx6q_clk_probe(struct udevice *dev)imx_clk_divider ("usdhc4_podf" ,"usdhc4_sel" , base + 0x24, 22, 3));drivers/clk/imx/clk-imx6q.c static int imx6q_clk_probe(struct udevice *dev) · line 112
Quoted 10 lines
drivers/clk/imx/clk-imx6q.c +7
-3-clk_dm (IMX6QDL_CLK_ECSPI_ROOT , -imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); - +if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); + }else { +clk_dm (IMX6QDL_CLK_ECSPI_ROOT , +imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); + }Same here.
Fabio Estevam
reviewerRe: [PATCH 01/10] clk: imx6q: Properly handle imx6qp ESPI clk_sels
Hi Adam,
Quoted 3 lines · Adam Ford
Thanks for the review. I will make the updates to the two patches you requested. Is there anything else you want changed before I submit V2?
The rest looks good, thanks.
PATCH 2/10 clk: imx6q: Register UART clocks
In reply to Adam FordIn order to use the driver model and clock system to enable UART clocks from the serial driver, it's necessary to register the UART clocks. With the helper function to check for imx6qp vs other variants, the UART can register for both scenarios.
--- drivers/clk/imx/clk-imx6q.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/clk/imx/clk-imx6q.c +12 -0
@@ -40,6 +40,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };static const char *const periph_sels[] = {"periph_pre" ,"periph_clk2" , };static const char *const periph_pre_sels[] = {"pll2_bus" ,"pll2_pfd2_396m" ,"pll2_pfd0_352m" ,"pll2_198m" , }; +static const char *const uart_sels[] = {"pll3_80m" ,"osc" , };static const char *const ecspi_sels[] = {"pll3_60m" ,"osc" , };static int imx6q_clk_probe (struct udevice *dev)
@@ -85,6 +86,9 @@ static int imx6q_clk_probe(struct udevice *dev) usdhc_sels, ARRAY_SIZE(usdhc_sels)));if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_UART_SEL , +imx_clk_mux ("uart_sel" , base +0x24 ,6 ,1 , uart_sels, +ARRAY_SIZE (uart_sels)));clk_dm (IMX6QDL_CLK_ECSPI_SEL ,imx_clk_mux ("ecspi_sel" , base +0x38 ,18 ,1 , ecspi_sels,ARRAY_SIZE (ecspi_sels)));
@@ -104,9 +108,13 @@ static int imx6q_clk_probe(struct udevice *dev) base + 0x24, 22, 3));if (clk_on_imx6qp ()) { +clk_dm (IMX6QDL_CLK_UART_SERIAL_PODF , +imx_clk_divider ("uart_serial_podf" ,"uart_sel" , base +0x24 ,0 ,6 ));clk_dm (IMX6QDL_CLK_ECSPI_ROOT ,imx_clk_divider ("ecspi_root" ,"ecspi_sel" , base +0x38 ,19 ,6 )); }else { +clk_dm (IMX6QDL_CLK_UART_SERIAL_PODF , +imx_clk_divider ("uart_serial_podf" ,"pll3_80m" , base +0x24 ,0 ,6 ));clk_dm (IMX6QDL_CLK_ECSPI_ROOT ,imx_clk_divider ("ecspi_root" ,"pll3_60m" , base +0x38 ,19 ,6 )); }
@@ -118,6 +126,10 @@ static int imx6q_clk_probe(struct udevice *dev) imx_clk_gate2("ecspi3", "ecspi_root", base + 0x6c, 4));clk_dm (IMX6QDL_CLK_ECSPI4 ,imx_clk_gate2 ("ecspi4" ,"ecspi_root" , base +0x6c ,6 )); +clk_dm (IMX6QDL_CLK_UART_IPG , +imx_clk_gate2 ("uart_ipg" ,"ipg" , base +0x7c ,24 )); +clk_dm (IMX6QDL_CLK_UART_SERIAL , +imx_clk_gate2 ("uart_serial" ,"uart_serial_podf" , base +0x7c ,26 ));clk_dm (IMX6QDL_CLK_USDHC1 ,imx_clk_gate2 ("usdhc1" ,"usdhc1_podf" , base +0x80 ,2 )); clk_dm(IMX6QDL_CLK_USDHC2,
Signature · 1 line
2.45.2
PATCH 3/10 clk: imx8mm: register UART clocks
In reply to Adam FordIn order to let the serial driver enable the clocks, the UART clocks must be registered first.
--- drivers/clk/imx/clk-imx8mm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/clk/imx/clk-imx8mm.c +34 -0
@@ -81,6 +81,22 @@ static const char * const imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m""sys_pll3_out" ,"audio_pll1_out" ,"video_pll1_out" , "audio_pll2_out", "sys_pll1_133m", }; +static const char *const imx8mm_uart1_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" ,"clk_ext4" , +"audio_pll2_out" , }; + +static const char *const imx8mm_uart2_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" ,"clk_ext3" , +"audio_pll2_out" , }; + +static const char *const imx8mm_uart3_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" ,"clk_ext4" , +"audio_pll2_out" , }; + +static const char *const imx8mm_uart4_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" ,"clk_ext3" , +"audio_pll2_out" , }; +#if CONFIG_IS_ENABLED (PCIE_DW_IMX )static const char *const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m" ,"sys_pll2_250m" ,"sys_pll2_200m" , "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_500m",
@@ -322,6 +338,24 @@ static int imx8mm_clk_probe(struct udevice *dev) imx8m_clk_composite("i2c3", imx8mm_i2c3_sels, base + 0xae00));clk_dm (IMX8MM_CLK_I2C4 ,imx8m_clk_composite ("i2c4" , imx8mm_i2c4_sels, base +0xae80 )); + +clk_dm (IMX8MM_CLK_UART1 , +imx8m_clk_composite ("uart1" , imx8mm_uart1_sels, base +0xaf00 )); +clk_dm (IMX8MM_CLK_UART2 , +imx8m_clk_composite ("uart2" , imx8mm_uart2_sels, base +0xaf80 )); +clk_dm (IMX8MM_CLK_UART3 , +imx8m_clk_composite ("uart3" , imx8mm_uart3_sels, base +0xb000 )); +clk_dm (IMX8MM_CLK_UART4 , +imx8m_clk_composite ("uart4" , imx8mm_uart4_sels, base +0xb080 )); +clk_dm (IMX8MM_CLK_UART1_ROOT , +imx_clk_gate4 ("uart1_root_clk" ,"uart1" , base +0x4490 ,0 )); +clk_dm (IMX8MM_CLK_UART2_ROOT , +imx_clk_gate4 ("uart2_root_clk" ,"uart2" , base +0x44a0 ,0 )); +clk_dm (IMX8MM_CLK_UART3_ROOT , +imx_clk_gate4 ("uart3_root_clk" ,"uart3" , base +0x44b0 ,0 )); +clk_dm (IMX8MM_CLK_UART4_ROOT , +imx_clk_gate4 ("uart4_root_clk" ,"uart4" , base +0x44c0 ,0 )); +clk_dm (IMX8MM_CLK_WDOG ,imx8m_clk_composite ("wdog" , imx8mm_wdog_sels, base +0xb900 )); clk_dm(IMX8MM_CLK_USDHC3,
Signature · 1 line
2.45.2
PATCH 4/10 clk: imx8mn: register UART clocks
In reply to Adam FordIn order to let the serial driver enable the clocks, the UART clocks must be registered first.
--- drivers/clk/imx/clk-imx8mn.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/clk/imx/clk-imx8mn.c +32 -0
@@ -97,6 +97,22 @@ static const char * const imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m""sys_pll3_out" ,"audio_pll1_out" ,"video_pll_out" , "audio_pll2_out", "sys_pll1_133m", }; +static const char *const imx8mn_uart1_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" , +"clk_ext4" ,"audio_pll2_out" , }; + +static const char *const imx8mn_uart2_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" , +"clk_ext3" ,"audio_pll2_out" , }; + +static const char *const imx8mn_uart3_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" , +"clk_ext4" ,"audio_pll2_out" , }; + +static const char *const imx8mn_uart4_sels[] = {"clock-osc-24m" ,"sys_pll1_80m" ,"sys_pll2_200m" , +"sys_pll2_100m" ,"sys_pll3_out" ,"clk_ext2" , +"clk_ext3" ,"audio_pll2_out" , }; +#ifndef CONFIG_XPL_BUILD static const char *const imx8mn_pwm1_sels[] = {"clock-osc-24m" ,"sys_pll2_100m" ,"sys_pll1_160m" , "sys_pll1_40m", "sys_pll3_out", "clk_ext1",
@@ -311,6 +327,14 @@ static int imx8mn_clk_probe(struct udevice *dev) imx8m_clk_composite("i2c3", imx8mn_i2c3_sels, base + 0xae00));clk_dm (IMX8MN_CLK_I2C4 ,imx8m_clk_composite ("i2c4" , imx8mn_i2c4_sels, base +0xae80 )); +clk_dm (IMX8MN_CLK_UART1 , +imx8m_clk_composite ("uart1" , imx8mn_uart1_sels, base +0xaf00 )); +clk_dm (IMX8MN_CLK_UART2 , +imx8m_clk_composite ("uart2" , imx8mn_uart2_sels, base +0xaf80 )); +clk_dm (IMX8MN_CLK_UART3 , +imx8m_clk_composite ("uart3" , imx8mn_uart3_sels, base +0xb000 )); +clk_dm (IMX8MN_CLK_UART4 , +imx8m_clk_composite ("uart4" , imx8mn_uart4_sels, base +0xb080 ));clk_dm (IMX8MN_CLK_WDOG ,imx8m_clk_composite ("wdog" , imx8mn_wdog_sels, base +0xb900 )); clk_dm(IMX8MN_CLK_USDHC3,
@@ -355,6 +379,14 @@ static int imx8mn_clk_probe(struct udevice *dev)imx_clk_gate2_shared2 ("nand_usdhc_rawnand_clk" ,"nand_usdhc_bus" , base +0x4300 ,0 , &share_count_nand)); +clk_dm (IMX8MN_CLK_UART1_ROOT , +imx_clk_gate4 ("uart1_root_clk" ,"uart1" , base +0x4490 ,0 )); +clk_dm (IMX8MN_CLK_UART2_ROOT , +imx_clk_gate4 ("uart2_root_clk" ,"uart2" , base +0x44a0 ,0 )); +clk_dm (IMX8MN_CLK_UART3_ROOT , +imx_clk_gate4 ("uart3_root_clk" ,"uart3" , base +0x44b0 ,0 )); +clk_dm (IMX8MN_CLK_UART4_ROOT , +imx_clk_gate4 ("uart4_root_clk" ,"uart4" , base +0x44c0 ,0 ));clk_dm (IMX8MN_CLK_USB1_CTRL_ROOT ,imx_clk_gate4 ("usb1_ctrl_root_clk" ,"usb_bus" , base +0x44d0 ,0 ));
Signature · 1 line
2.45.2
PATCH 5/10 serial: mxc: Support bulk enabling clocks
In reply to Adam FordDepending on the platform, there may be multiple clock sources required to enable a UART. Use the bulk functions to get and enable the clocks when the UART probes. This can facilitate the removal of functions to manually enable the clock.
This is made dependent on CLK_CCF which is used on imx6q, imx8m[mnqp], several imxrt, imx9. If/when the UART clock registration is done for older boards, this limitation could be updated.
--- drivers/serial/serial_mxc.c | 11 +++++++++++ include/dm/platform_data/serial_mxc.h | 1 + 2 files changed, 12 insertions(+)
drivers/serial/serial_mxc.c +11 -0
@@ -3,6 +3,7 @@* (c) 2007 Sascha Hauer <[email protected]> */ +#include <clk.h> #include <dm.h> #include <errno.h> #include <watchdog.h>
@@ -312,7 +313,17 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)static int mxc_serial_probe (struct udevice *dev) {struct mxc_serial_plat *plat =dev_get_plat (dev); +int ret; +#if CONFIG_IS_ENABLED (CLK_CCF ) + ret =clk_get_bulk (dev, &plat->clks); +if (ret) +return ret; + + ret =clk_enable_bulk (&plat->clks); +if (ret) +return ret; +#endif _mxc_serial_init (plat->reg, plat->use_dte);return 0 ;
include/dm/platform_data/serial_mxc.h +1 -0
@@ -9,6 +9,7 @@/* Information about a serial port */ struct mxc_serial_plat {struct mxc_uart *reg;/* address of registers in physical memory */ +struct clk_bulk clks;bool use_dte; };
Signature · 1 line
2.45.2
Fabio Estevam
reviewerRe: [PATCH 05/10] serial: mxc: Support bulk enabling clocks
Quoted 5 lines · Adam Ford
drivers/serial/serial_mxc.c +1
-0@@ -312,7 +313,17 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)static int mxc_serial_probe (struct udevice *dev) {struct mxc_serial_plat *plat =dev_get_plat (dev); +int ret;
drivers/serial/serial_mxc.c int mxc_serial_setbrg(struct udevice *dev, int baudrate) · line 326
Quoted 10 lines
drivers/serial/serial_mxc.c +9
-0+#if CONFIG_IS_ENABLED (CLK_CCF ) + ret =clk_get_bulk (dev, &plat->clks); +if (ret) +return ret; + + ret =clk_enable_bulk (&plat->clks); +if (ret) +return ret; +#endif
CI fails when building a target with CLK_CCF disabled:
aarch64: + imx8mp_evk+drivers/serial/serial_mxc.c: In function 'mxc_serial_probe':+drivers/serial/serial_mxc.c:316:13: error: unused variable 'ret' [-Werror=unused-variable]
+ 316 | int ret;
+ | ^~~
+cc1: all warnings being treated as errors
+make[4]: *** [scripts/Makefile.build:257:spl/drivers/serial/serial_mxc.o] Error 1
+make[3]: *** [scripts/Makefile.build:398: spl/drivers/serial] Error 2 +make[2]: *** [scripts/Makefile.xpl:550: spl/drivers] Error 2 +make[1]: *** [Makefile:2117: spl/u-boot-spl] Error 2 +make: *** [Makefile:177: sub-make] Error 2
Please fix and resend.
Re: [PATCH 05/10] serial: mxc: Support bulk enabling clocks
Quoted 9 lines · Fabio Estevam
Quoted 6 lines · Adam Ford
drivers/serial/serial_mxc.c +1
-0@@ -312,7 +313,17 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)static int mxc_serial_probe (struct udevice *dev) {struct mxc_serial_plat *plat =dev_get_plat (dev); +int ret;
Quoted 11 lines
drivers/serial/serial_mxc.c int mxc_serial_setbrg(struct udevice *dev, int baudrate) · line 326
Quoted 9 lines
drivers/serial/serial_mxc.c +9
-0+#if CONFIG_IS_ENABLED (CLK_CCF ) + ret =clk_get_bulk (dev, &plat->clks); +if (ret) +return ret; + + ret =clk_enable_bulk (&plat->clks); +if (ret) +return ret; +#endif CI fails when building a target with
CLK_CCFdisabled:
OK. Thanks for catching that. I'll move 'int ret' under the #if statement to fix it in V2.
Quoted 16 lines
aarch64: +
imx8mp_evk(quoted diff) +2
-0+drivers/serial/serial_mxc.c: In function 'mxc_serial_probe': +drivers/serial/serial_mxc.c:316:13: error: unused variable 'ret'[-Werror=unused-variable]
(quoted diff) +4
-0+ 316 | int ret; + | ^~~ +cc1: all warnings being treated as errors +make[4]: *** [scripts/Makefile.build:257:
spl/drivers/serial/serial_mxc.o] Error 1(quoted diff) +4
-0+make[3]: *** [scripts/Makefile.build:398: spl/drivers/serial] Error 2 +make[2]: *** [scripts/Makefile.xpl:550: spl/drivers] Error 2 +make[1]: *** [Makefile:2117: spl/u-boot-spl] Error 2 +make: *** [Makefile:177: sub-make] Error 2Please fix and resend.
PATCH 6/10 board: beacon: imx8mm: Let clock system enable UART clock
In reply to Adam FordNow that the UART driver can enable the required clocks, remove the hard-coded clock enable. This requires a small re-order of a couple functions.
--- board/beacon/imx8mm/spl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
board/beacon/imx8mm/spl.c +1 -5
@@ -100,9 +100,6 @@ void board_init_f(ulong dummy)int ret;arch_cpu_init (); - -init_uart_clk (1 ); -timer_init ();/* Clear the BSS. */
@@ -114,8 +111,6 @@ void board_init_f(ulong dummy)hang (); } -preloader_console_init (); - ret =uclass_get_device_by_name (UCLASS_CLK ,"clock-controller@30380000" , &dev);
@@ -124,6 +119,7 @@ void board_init_f(ulong dummy)hang (); } +preloader_console_init ();enable_tzc380 ();power_init_board ();
Signature · 1 line
2.45.2
PATCH 7/10 board: beacon: imx8mn: Let clock system enable UART clock
In reply to Adam FordNow that the UART driver can enable the required clocks, remove the hard-coded clock enable.
--- board/beacon/imx8mn/spl.c | 2 -- 1 file changed, 2 deletions(-)
board/beacon/imx8mn/spl.c +0 -2
@@ -111,8 +111,6 @@ int board_early_init_f(void)/* Claiming pwm pins prevents LCD flicker during startup*/ imx_iomux_v3_setup_multiple_pads (pwm_pads,ARRAY_SIZE (pwm_pads)); -init_uart_clk (1 ); -return 0 ; }
Signature · 1 line
2.45.2
PATCH 8/10 clk: imx: select SPL_CLK_COMPOSITE_CCF when SPL_CLK_IMX8MP
In reply to Adam FordIf SPL_CLK_IMX8MP is selected alone, it causes a build error. The clock composite is required when using the clock framework, so select it when SPL_CLK_IMX8MP is enabled. This is already being done outside of SPL.
--- drivers/clk/imx/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/clk/imx/Kconfig +1 -0
@@ -60,6 +60,7 @@ config SPL_CLK_IMX8MP depends on ARCH_IMX8M && SPL select SPL_CLK select SPL_CLK_CCF + select SPL_CLK_COMPOSITE_CCF help This enables SPL DM/DTS support for clock driver in i.MX8MP
Signature · 1 line
2.45.2
PATCH 9/10 configs: imx8mp_beacon: Select SPL_CLK_IMX8MP
In reply to Adam FordIn preparation to remove manual references for enabling some clocks, enable SPL_CLK_IMX8MP which automatically enables SPL_CCF and SPL_CLK_COMPOSITE_CCF which permit various drivers to activate their respective clocks automatically.
--- configs/imx8mp_beacon_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/imx8mp_beacon_defconfig +1 -0
@@ -86,6 +86,7 @@ CONFIG_USE_ETHPRIME=y CONFIG_ETHPRIME="eth1" CONFIG_SPL_DM=y CONFIG_CLK_COMPOSITE_CCF=y +CONFIG_SPL_CLK_IMX8MP=y CONFIG_CLK_IMX8MP=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0x42800000
Signature · 1 line
2.45.2
PATCH 10/10 board: beacon: imx8mp: Let clock system enable UART clock
In reply to Adam FordNow that the UART driver can enable the required clocks, remove the hard-coded clock enable.
--- board/beacon/imx8mp/spl.c | 2 -- 1 file changed, 2 deletions(-)
board/beacon/imx8mp/spl.c +0 -2
@@ -112,8 +112,6 @@ void board_init_f(ulong dummy)arch_cpu_init (); -init_uart_clk (1 ); - ret =spl_early_init ();if (ret) {debug ("spl_init() failed: %d\n" , ret);
Signature · 1 line
2.45.2