clk: imx: Refactor entire sccg pll clk
Subsystems (3)
PATCH v2 1/1 clk: imx: Refactor entire sccg pll clk
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents list. The determine_rate does a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used by set_rate later to set up all the divs and bypasses.
---
Changes since v1:
* fixed all the warnings and errors for arm32
* removed the explicit reparenting from clk-imx8mq leaving that work to be done by each clock driver explicitly
drivers/clk/imx/clk-imx8mq.c | 53 +---- drivers/clk/imx/clk-sccg-pll.c | 514 ++++++++++++++++++++++++++++++++--------- drivers/clk/imx/clk.h | 9 +- 3 files changed, 417 insertions(+), 159 deletions(-)
drivers/clk/imx/clk-imx8mq.c +8 -45
@@ -34,15 +34,10 @@ static const char * const audio_pll1_bypass_sels[] = {"audio_pll1", "audio_pll1_static const char *const audio_pll2_bypass_sels[] = {"audio_pll2" ,"audio_pll2_ref_sel" , };static const char *const video_pll1_bypass_sels[] = {"video_pll1" ,"video_pll1_ref_sel" , }; -static const char *const sys1_pll1_out_sels[] = {"sys1_pll1" ,"sys1_pll1_ref_sel" , }; -static const char *const sys2_pll1_out_sels[] = {"sys2_pll1" ,"sys1_pll1_ref_sel" , }; -static const char *const sys3_pll1_out_sels[] = {"sys3_pll1" ,"sys3_pll1_ref_sel" , }; -static const char *const dram_pll1_out_sels[] = {"dram_pll1" ,"dram_pll1_ref_sel" , }; - -static const char *const sys1_pll2_out_sels[] = {"sys1_pll2_div" ,"sys1_pll1_ref_sel" , }; -static const char *const sys2_pll2_out_sels[] = {"sys2_pll2_div" ,"sys2_pll1_ref_sel" , }; -static const char *const sys3_pll2_out_sels[] = {"sys3_pll2_div" ,"sys2_pll1_ref_sel" , }; -static const char *const dram_pll2_out_sels[] = {"dram_pll2_div" ,"dram_pll1_ref_sel" , }; +static const char *const sys1_pll_out_sels[] = {"sys1_pll1_ref_sel" , }; +static const char *const sys2_pll_out_sels[] = {"sys1_pll1_ref_sel" ,"sys2_pll1_ref_sel" , }; +static const char *const sys3_pll_out_sels[] = {"sys3_pll1_ref_sel" ,"sys2_pll1_ref_sel" , }; +static const char *const dram_pll_out_sels[] = {"dram_pll1_ref_sel" , };/* CCM ROOT */ static const char *const imx8mq_a53_sels[] = {"osc_25m" ,"arm_pll_out" ,"sys2_pll_500m" ,"sys2_pll_1000m" ,
@@ -313,10 +308,6 @@ static int imx8mq_clocks_probe(struct platform_device *pdev) clks[IMX8MQ_AUDIO_PLL1_REF_DIV ] =imx_clk_divider ("audio_pll1_ref_div" ,"audio_pll1_ref_sel" , base +0x0 ,5 ,6 ); clks[IMX8MQ_AUDIO_PLL2_REF_DIV ] =imx_clk_divider ("audio_pll2_ref_div" ,"audio_pll2_ref_sel" , base +0x8 ,5 ,6 ); clks[IMX8MQ_VIDEO_PLL1_REF_DIV ] =imx_clk_divider ("video_pll1_ref_div" ,"video_pll1_ref_sel" , base +0x10 ,5 ,6 ); - clks[IMX8MQ_SYS1_PLL1_REF_DIV ] =imx_clk_divider ("sys1_pll1_ref_div" ,"sys1_pll1_ref_sel" , base +0x38 ,25 ,3 ); - clks[IMX8MQ_SYS2_PLL1_REF_DIV ] =imx_clk_divider ("sys2_pll1_ref_div" ,"sys2_pll1_ref_sel" , base +0x44 ,25 ,3 ); - clks[IMX8MQ_SYS3_PLL1_REF_DIV ] =imx_clk_divider ("sys3_pll1_ref_div" ,"sys3_pll1_ref_sel" , base +0x50 ,25 ,3 ); - clks[IMX8MQ_DRAM_PLL1_REF_DIV ] =imx_clk_divider ("dram_pll1_ref_div" ,"dram_pll1_ref_sel" , base +0x68 ,25 ,3 ); clks[IMX8MQ_ARM_PLL ] =imx_clk_frac_pll ("arm_pll" ,"arm_pll_ref_div" , base +0x28 ); clks[IMX8MQ_GPU_PLL ] =imx_clk_frac_pll ("gpu_pll" ,"gpu_pll_ref_div" , base +0x18 );
@@ -324,25 +315,6 @@ static int imx8mq_clocks_probe(struct platform_device *pdev) clks[IMX8MQ_AUDIO_PLL1 ] =imx_clk_frac_pll ("audio_pll1" ,"audio_pll1_ref_div" , base +0x0 ); clks[IMX8MQ_AUDIO_PLL2 ] =imx_clk_frac_pll ("audio_pll2" ,"audio_pll2_ref_div" , base +0x8 ); clks[IMX8MQ_VIDEO_PLL1 ] =imx_clk_frac_pll ("video_pll1" ,"video_pll1_ref_div" , base +0x10 ); - clks[IMX8MQ_SYS1_PLL1 ] =imx_clk_sccg_pll ("sys1_pll1" ,"sys1_pll1_ref_div" , base +0x30 ,SCCG_PLL1 ); - clks[IMX8MQ_SYS2_PLL1 ] =imx_clk_sccg_pll ("sys2_pll1" ,"sys2_pll1_ref_div" , base +0x3c ,SCCG_PLL1 ); - clks[IMX8MQ_SYS3_PLL1 ] =imx_clk_sccg_pll ("sys3_pll1" ,"sys3_pll1_ref_div" , base +0x48 ,SCCG_PLL1 ); - clks[IMX8MQ_DRAM_PLL1 ] =imx_clk_sccg_pll ("dram_pll1" ,"dram_pll1_ref_div" , base +0x60 ,SCCG_PLL1 ); - - clks[IMX8MQ_SYS1_PLL2 ] =imx_clk_sccg_pll ("sys1_pll2" ,"sys1_pll1_out_div" , base +0x30 ,SCCG_PLL2 ); - clks[IMX8MQ_SYS2_PLL2 ] =imx_clk_sccg_pll ("sys2_pll2" ,"sys2_pll1_out_div" , base +0x3c ,SCCG_PLL2 ); - clks[IMX8MQ_SYS3_PLL2 ] =imx_clk_sccg_pll ("sys3_pll2" ,"sys3_pll1_out_div" , base +0x48 ,SCCG_PLL2 ); - clks[IMX8MQ_DRAM_PLL2 ] =imx_clk_sccg_pll ("dram_pll2" ,"dram_pll1_out_div" , base +0x60 ,SCCG_PLL2 ); - -/* PLL divs */ - clks[IMX8MQ_SYS1_PLL1_OUT_DIV ] =imx_clk_divider ("sys1_pll1_out_div" ,"sys1_pll1_out" , base +0x38 ,19 ,6 ); - clks[IMX8MQ_SYS2_PLL1_OUT_DIV ] =imx_clk_divider ("sys2_pll1_out_div" ,"sys2_pll1_out" , base +0x44 ,19 ,6 ); - clks[IMX8MQ_SYS3_PLL1_OUT_DIV ] =imx_clk_divider ("sys3_pll1_out_div" ,"sys3_pll1_out" , base +0x50 ,19 ,6 ); - clks[IMX8MQ_DRAM_PLL1_OUT_DIV ] =imx_clk_divider ("dram_pll1_out_div" ,"dram_pll1_out" , base +0x68 ,19 ,6 ); - clks[IMX8MQ_SYS1_PLL2_DIV ] =imx_clk_divider ("sys1_pll2_div" ,"sys1_pll2" , base +0x38 ,1 ,6 ); - clks[IMX8MQ_SYS2_PLL2_DIV ] =imx_clk_divider ("sys2_pll2_div" ,"sys2_pll2" , base +0x44 ,1 ,6 ); - clks[IMX8MQ_SYS3_PLL2_DIV ] =imx_clk_divider ("sys3_pll2_div" ,"sys3_pll2" , base +0x50 ,1 ,6 ); - clks[IMX8MQ_DRAM_PLL2_DIV ] =imx_clk_divider ("dram_pll2_div" ,"dram_pll2" , base +0x68 ,1 ,6 );/* PLL bypass out */ clks[IMX8MQ_ARM_PLL_BYPASS ] =imx_clk_mux_flags ("arm_pll_bypass" , base +0x28 ,14 ,1 , arm_pll_bypass_sels,ARRAY_SIZE (arm_pll_bypass_sels),CLK_SET_RATE_PARENT );
@@ -352,15 +324,6 @@ static int imx8mq_clocks_probe(struct platform_device *pdev) clks[IMX8MQ_AUDIO_PLL2_BYPASS ] =imx_clk_mux ("audio_pll2_bypass" , base +0x8 ,14 ,1 , audio_pll2_bypass_sels,ARRAY_SIZE (audio_pll2_bypass_sels)); clks[IMX8MQ_VIDEO_PLL1_BYPASS ] =imx_clk_mux ("video_pll1_bypass" , base +0x10 ,14 ,1 , video_pll1_bypass_sels,ARRAY_SIZE (video_pll1_bypass_sels)); - clks[IMX8MQ_SYS1_PLL1_OUT ] =imx_clk_mux ("sys1_pll1_out" , base +0x30 ,5 ,1 , sys1_pll1_out_sels,ARRAY_SIZE (sys1_pll1_out_sels)); - clks[IMX8MQ_SYS2_PLL1_OUT ] =imx_clk_mux ("sys2_pll1_out" , base +0x3c ,5 ,1 , sys2_pll1_out_sels,ARRAY_SIZE (sys2_pll1_out_sels)); - clks[IMX8MQ_SYS3_PLL1_OUT ] =imx_clk_mux ("sys3_pll1_out" , base +0x48 ,5 ,1 , sys3_pll1_out_sels,ARRAY_SIZE (sys3_pll1_out_sels)); - clks[IMX8MQ_DRAM_PLL1_OUT ] =imx_clk_mux ("dram_pll1_out" , base +0x60 ,5 ,1 , dram_pll1_out_sels,ARRAY_SIZE (dram_pll1_out_sels)); - clks[IMX8MQ_SYS1_PLL2_OUT ] =imx_clk_mux ("sys1_pll2_out" , base +0x30 ,4 ,1 , sys1_pll2_out_sels,ARRAY_SIZE (sys1_pll2_out_sels)); - clks[IMX8MQ_SYS2_PLL2_OUT ] =imx_clk_mux ("sys2_pll2_out" , base +0x3c ,4 ,1 , sys2_pll2_out_sels,ARRAY_SIZE (sys2_pll2_out_sels)); - clks[IMX8MQ_SYS3_PLL2_OUT ] =imx_clk_mux ("sys3_pll2_out" , base +0x48 ,4 ,1 , sys3_pll2_out_sels,ARRAY_SIZE (sys3_pll2_out_sels)); - clks[IMX8MQ_DRAM_PLL2_OUT ] =imx_clk_mux ("dram_pll2_out" , base +0x60 ,4 ,1 , dram_pll2_out_sels,ARRAY_SIZE (dram_pll2_out_sels)); -/* PLL OUT GATE */ clks[IMX8MQ_ARM_PLL_OUT ] =imx_clk_gate ("arm_pll_out" ,"arm_pll_bypass" , base +0x28 ,21 ); clks[IMX8MQ_GPU_PLL_OUT ] =imx_clk_gate ("gpu_pll_out" ,"gpu_pll_bypass" , base +0x18 ,21 );
@@ -368,11 +331,11 @@ static int imx8mq_clocks_probe(struct platform_device *pdev) clks[IMX8MQ_AUDIO_PLL1_OUT ] =imx_clk_gate ("audio_pll1_out" ,"audio_pll1_bypass" , base +0x0 ,21 ); clks[IMX8MQ_AUDIO_PLL2_OUT ] =imx_clk_gate ("audio_pll2_out" ,"audio_pll2_bypass" , base +0x8 ,21 ); clks[IMX8MQ_VIDEO_PLL1_OUT ] =imx_clk_gate ("video_pll1_out" ,"video_pll1_bypass" , base +0x10 ,21 ); - clks[IMX8MQ_SYS1_PLL_OUT ] =imx_clk_gate ("sys1_pll_out" ,"sys1_pll2_out" , base +0x30 ,9 ); - clks[IMX8MQ_SYS2_PLL_OUT ] =imx_clk_gate ("sys2_pll_out" ,"sys2_pll2_out" , base +0x3c ,9 ); - clks[IMX8MQ_SYS3_PLL_OUT ] =imx_clk_gate ("sys3_pll_out" ,"sys3_pll2_out" , base +0x48 ,9 ); - clks[IMX8MQ_DRAM_PLL_OUT ] =imx_clk_gate ("dram_pll_out" ,"dram_pll2_out" , base +0x60 ,9 ); + clks[IMX8MQ_SYS1_PLL_OUT ] =imx_clk_sccg_pll ("sys1_pll_out" , sys1_pll_out_sels,ARRAY_SIZE (sys1_pll_out_sels),0 ,0 ,0 , base +0x30 ,CLK_IS_CRITICAL ); + clks[IMX8MQ_SYS2_PLL_OUT ] =imx_clk_sccg_pll ("sys2_pll_out" , sys2_pll_out_sels,ARRAY_SIZE (sys2_pll_out_sels),0 ,0 ,1 , base +0x3c ,CLK_IS_CRITICAL ); + clks[IMX8MQ_SYS3_PLL_OUT ] =imx_clk_sccg_pll ("sys3_pll_out" , sys3_pll_out_sels,ARRAY_SIZE (sys3_pll_out_sels),0 ,0 ,1 , base +0x48 ,CLK_IS_CRITICAL ); + clks[IMX8MQ_DRAM_PLL_OUT ] =imx_clk_sccg_pll ("dram_pll_out" , dram_pll_out_sels,ARRAY_SIZE (dram_pll_out_sels),0 ,0 ,0 , base +0x60 ,CLK_IS_CRITICAL );/* SYS PLL fixed output */ clks[IMX8MQ_SYS1_PLL_40M ] =imx_clk_fixed_factor ("sys1_pll_40m" ,"sys1_pll_out" ,1 ,20 ); clks[IMX8MQ_SYS1_PLL_80M ] =imx_clk_fixed_factor ("sys1_pll_80m" ,"sys1_pll_out" ,1 ,10 );
drivers/clk/imx/clk-sccg-pll.c +403 -111
621 lines not on this page · raw message
drivers/clk/imx/clk.h +6 -3
@@ -60,9 +60,12 @@ struct clk *imx_clk_pllv2(const char *name, const char *parent,struct clk *imx_clk_frac_pll (const char *name,const char *parent_name,void __iomem *base); -struct clk *imx_clk_sccg_pll (const char *name,const char *parent_name, -void __iomem *base, -enum imx_sccg_pll_type pll_type); +struct clk *imx_clk_sccg_pll (const char *name, +const char *const *parent_names, +u8 num_parents, +u8 parent,u8 bypass1,u8 bypass2, +void __iomem *base, +unsigned long flags);enum imx_pllv3_type {IMX_PLLV3_GENERIC ,
Signature · 1 line
2.7.4
Stephen Boyd
maintainerQuoting Abel Vesa (2019-02-22 09:07:32)
Quoted 9 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents list. The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs and bypasses.Signed-off-by Abel Vesa <[email protected]>Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>
I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Quoted 7 lines · Stephen Boyd
Quoting Abel Vesa (2019-02-22 09:07:32)
Quoted 6 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents list. The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs and bypasses.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Abel Vesa <[email protected]>Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Oups, I forgot to drop them.
Stephen Boyd
maintainerQuoting Abel Vesa (2019-02-23 02:58:14)
Quoted 12 lines · Stephen Boyd
Quoted 11 lines
Quoting Abel Vesa (2019-02-22 09:07:32)
Quoted 9 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents list. The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs and bypasses.Signed-off-by Abel Vesa <[email protected]>Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>
Quoted 5 lines
Quoted 3 lines
I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Oups, I forgot to drop them.
Ok. Can Lucas re-test?
Aisheng Dong
Tested-byQuoted 4 lines
From: Stephen Boyd [mailto:[email protected]]
Sent: Tuesday, February 26, 2019 1:23 AM>
Quoting Abel Vesa (2019-02-23 02:58:14)Quoted 1 line · Stephen Boyd
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoting Abel Vesa (2019-02-22 09:07:32)
Quoted 2 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents
list.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs andbypasses.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Abel Vesa <[email protected]>
This significantly simply the clock tree output.
Thanks for the work.
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Oups, I forgot to drop them.
Ok. Can Lucas re-test?
Tested on clk-next by cherry-pick a few defconfig patches from imx tree. So:
Regards
Dong Aisheng
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 25 lines · Aisheng Dong
Quoted 4 lines
From: Stephen Boyd [mailto:[email protected]]
Sent: Tuesday, February 26, 2019 1:23 AM>
Quoting Abel Vesa (2019-02-23 02:58:14)Quoted 1 line · Stephen Boyd
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoting Abel Vesa (2019-02-22 09:07:32)
Quoted 2 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents
list.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs andbypasses.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Abel Vesa <[email protected]>This significantly simply the clock tree output.
Thanks for the work.Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Oups, I forgot to drop them.
Ok. Can Lucas re-test?
Tested on clk-next by cherry-pick a few defconfig patches from imx tree. So:
Tested-by Dong Aisheng <[email protected]>
Thanks for helping with the testing.
I don't think there should be any defconfig changes required by this patch.
Can you please list here the CONFIGs added?
Just wanna make sure I'm not missing anything.
Quoted 2 lines
Regards
Dong Aisheng
[...]
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Oups, I forgot to drop them.
Ok. Can Lucas re-test?
Tested on clk-next by cherry-pick a few defconfig patches from imx tree. So:
Tested-by Dong Aisheng <[email protected]>
Quoted 8 lines
Thanks for helping with the testing.
I don't think there should be any defconfig changes required by this patch.
Can you please list here the CONFIGs added?
Just wanna make sure I'm not missing anything.
Clk-next does not have MX8 defconfig patches.
So I manually cherry-picked them from imx-next. Below two needed:
dee305e arm64: defconfig: Add i.MX8MQ boot necessary configs a1624ef arm64: defconfig: add imx8qxp support
Regards
Dong Aisheng
Quoted 2 lines
Quoted 2 lines
Regards
Dong Aisheng
Quoted 24 lines · Aisheng Dong
[...]
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>I suspect these tested by and acked tags should have been dropped, unless you discussed and tested off-list?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Oups, I forgot to drop them.
Ok. Can Lucas re-test?
Tested on clk-next by cherry-pick a few defconfig patches from imx tree. So:
Tested-by Dong Aisheng <[email protected]>Thanks for helping with the testing.
I don't think there should be any defconfig changes required by this patch.
Can you please list here the CONFIGs added?
Quoted 9 lines
Quoted 2 lines
Just wanna make sure I'm not missing anything.
Clk-next does not have MX8 defconfig patches.
So I manually cherry-picked them from imx-next. Below two needed:
dee305e arm64: defconfig: Add i.MX8MQ boot necessary configs a1624ef arm64: defconfig: add imx8qxp support
Ah, makes sense.
Thanks.
Quoted 5 lines
Regards
Dong AishengQuoted 2 lines
Quoted 2 lines
Regards
Dong Aisheng
Quoting Abel Vesa (2019-02-22 09:07:32)
Quoted 10 lines
Make the entire combination of plls to be one single clock. The parents used for bypasses are specified each as an index in the parents list. The
determine_ratedoes a lookup throughout all the possible combinations for all the divs and returns the best possible 'setup' which in turn is used byset_ratelater to set up all the divs and bypasses.Signed-off-by Abel Vesa <[email protected]>Tested-by Lucas Stach <[email protected]>Acked-by Lucas Stach <[email protected]>---
Applied to clk-next