clk: sun6i: Unify AHB1 clock and fix rate calculation
Subsystems (5)
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matching OF_CLK_DECLARE.
However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual OF_CLK_DECLARE statements, which adds a lot of boilerplate code.
The contents of this series are as follows:
Patch 1 adds support for a fixed divider on the output of factor clocks, which is used by the next patch.
Patch 2 fixes PLL6 rate calculation error, due to one of the factor values starting from 1, instead of 0. It also adds the /2 divider on the output.
Patch 3 adds the unified AHB1 clock driver.
Patch 4 and 5 unify the AHB1 clock nodes on sun6i and sun8i respectively.
Patch 6 sets the default parent and clock rate for AHB1, as required by the DMA controller. Curiously I did not require this when I tried dmatest on my A31 Hummingbird.
Patch 7 removes the clk_set_parent calls from the sun6i-dma driver, as it no longer works, and is replaced by the previous patch.
Suggestions are more than welcome.
Cheers
ChenYu
Chen-Yu Tsai (7):
clk: sunxi: Add post clk divider for factor clocks
clk: sunxi: Fix PLL6 calculation on sun6i
clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
ARM: dts: sun8i: Unify ahb1 clock nodes
ARM: dts: sun6i: Unify ahb1 clock nodes
ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma
controller
dmaengine: sun6i: Remove obsolete clk muxing code
Documentation/devicetree/bindings/clock/sunxi.txt | 2 +- arch/arm/boot/dts/sun6i-a31.dtsi | 17 +- arch/arm/boot/dts/sun8i-a23.dtsi | 12 +- drivers/clk/sunxi/clk-factors.c | 3 + drivers/clk/sunxi/clk-factors.h | 1 + drivers/clk/sunxi/clk-sunxi.c | 215 +++++++++++++++++++++- drivers/dma/sun6i-dma.c | 23 --- 7 files changed, 227 insertions(+), 46 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)
drivers/clk/sunxi/clk-factors.c +3 -0
@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }
drivers/clk/sunxi/clk-factors.h +1 -0
@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };struct clk_factors {
Signature · 1 line
2.1.0
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
Quoted 5 lines · Chen-Yu Tsai
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/cf136ac2/attachment.sig>
Emilio López
maintainerPATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
In reply to Chen-Yu TsaiHi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 30 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }drivers/clk/sunxi/clk-factors.h +0
-0
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 7 lines
drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };struct clk_factors {
For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
Cheers!
Emilio
[linux-sunxi] Re: [PATCH 1/7] clk: sunxi: Add post clk divider for factor clocks
Hi,
Quoted 43 lines · Emilio L?pez
Hi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 39 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(structclk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate;}drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };
Quoted 7 lines
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 2 lines
drivers/clk/sunxi/clk-factors.h +0
-0struct clk_factors {For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
I'm OK either way. It's really up to Maxime whether he likes the DT representation.
Quoted 5 lines
Cheers!
Emilio
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
In reply to Emilio LópezHi Emilio,
Quoted 38 lines · Emilio L?pez
Hi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 35 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };
Quoted 8 lines
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 2 lines
drivers/clk/sunxi/clk-factors.h +0
-0struct clk_factors {For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
No, you still wrote most of the clock support, so your opinion is always valuable (and valued).
Thing is, unlike what was done in the sun4i driver where there was a "real" technical issue that was preventing us from using only fixed-factor, we're not in such a case in sun6i (and later, apparently).
PLL6 has only one output, which is then directly multiplied by fixed-factors, without any (pre|post)-dividers for any of them.
That means that following what you did for the sun4i would just register 3 "dumbs" fixed-factors, that we couldn't reference from DT, or through a cryptic index (which is not even documented in our bindings).
I'd be fine either way, I just prefer the solution that has less code and is more explicit.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140916/202624f8/attachment.sig>
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
Hi Maxime, Emilio,
Quoted 61 lines · Maxime Ripard
Hi Emilio,
Quoted 38 lines · Emilio L?pez
Hi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 35 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };Quoted 8 lines
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 2 lines
drivers/clk/sunxi/clk-factors.h +0
-0struct clk_factors {For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
No, you still wrote most of the clock support, so your opinion is always valuable (and valued).
Thing is, unlike what was done in the sun4i driver where there was a "real" technical issue that was preventing us from using only fixed-factor, we're not in such a case in sun6i (and later, apparently).
PLL6 has only one output, which is then directly multiplied by fixed-factors, without any (pre|post)-dividers for any of them.
Quoted 7 lines
That means that following what you did for the sun4i would just register 3 "dumbs" fixed-factors, that we couldn't reference from DT, or through a cryptic index (which is not even documented in our bindings).
I'd be fine either way, I just prefer the solution that has less code and is more explicit.
What's the verdict on this series?
ChenYu
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
Quoted 70 lines · Chen-Yu Tsai
Hi Maxime, Emilio,
Quoted 66 lines · Maxime Ripard
Hi Emilio,
Quoted 38 lines · Emilio L?pez
Hi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 35 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };Quoted 8 lines
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 2 lines
drivers/clk/sunxi/clk-factors.h +0
-0struct clk_factors {For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
No, you still wrote most of the clock support, so your opinion is always valuable (and valued).
Thing is, unlike what was done in the sun4i driver where there was a "real" technical issue that was preventing us from using only fixed-factor, we're not in such a case in sun6i (and later, apparently).
PLL6 has only one output, which is then directly multiplied by fixed-factors, without any (pre|post)-dividers for any of them.
That means that following what you did for the sun4i would just register 3 "dumbs" fixed-factors, that we couldn't reference from DT, or through a cryptic index (which is not even documented in our bindings).
Quoted 4 lines
Quoted 2 lines
I'd be fine either way, I just prefer the solution that has less code and is more explicit.
What's the verdict on this series?
If Emilio prefers to have a single clock node, fine. But please update the DT bindings documentation.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140927/b6bd7df0/attachment.sig>
PATCH 1/7 clk: sunxi: Add post clk divider for factor clocks
Quoted 71 lines · Maxime Ripard
Quoted 70 lines · Chen-Yu Tsai
Hi Maxime, Emilio,
Quoted 66 lines · Maxime Ripard
Hi Emilio,
Quoted 38 lines · Emilio L?pez
Hi,
El 06/09/14 a las 07:47, Chen-Yu Tsai escibi?:
Quoted 35 lines
Some factor clocks, mostly PLLs, have an extra fixed divider just before the clock output. Add an option to the factor clk driver config data to specify this divider.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/clk/sunxi/clk-factors.c | 3 +++ drivers/clk/sunxi/clk-factors.h | 1 + 2 files changed, 4 insertions(+)drivers/clk/sunxi/clk-factors.c +3
-0@@ -64,6 +64,9 @@ static unsigned long clk_factors_recalc_rate(struct clk_hw *hw,/* Calculate the rate */ rate = (parent_rate * (n + config->n_start) * (k +1 ) >> p) / (m +1 ); +if (config->post_div) + rate /= config->post_div; +return rate; }drivers/clk/sunxi/clk-factors.h +1
-0@@ -16,6 +16,7 @@ struct clk_factors_config {u8 pshift;u8 pwidth;u8 n_start; +u8 post_div; };Quoted 8 lines
drivers/clk/sunxi/clk-factors.h struct clk_factors_config { · line 22
Quoted 2 lines
drivers/clk/sunxi/clk-factors.h +0
-0struct clk_factors {For the record, I liked your solution on[1] more, as it's in line with what we're doing on the other sunxi platforms, instead of adding features in factors to cover for some cases. But it's your and Maxime's call, as I haven't written any of the sun6i code so far.
No, you still wrote most of the clock support, so your opinion is always valuable (and valued).
Thing is, unlike what was done in the sun4i driver where there was a "real" technical issue that was preventing us from using only fixed-factor, we're not in such a case in sun6i (and later, apparently).
PLL6 has only one output, which is then directly multiplied by fixed-factors, without any (pre|post)-dividers for any of them.
That means that following what you did for the sun4i would just register 3 "dumbs" fixed-factors, that we couldn't reference from DT, or through a cryptic index (which is not even documented in our bindings).
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I'd be fine either way, I just prefer the solution that has less code and is more explicit.
What's the verdict on this series?
If Emilio prefers to have a single clock node, fine. But please update the DT bindings documentation.
OK. Then this series needs a bit of work. I'll pick the orignal divs clocks patch from patchwork (as I didn't keep one) and fix up the DT.
ChenYu
PATCH 2/7 clk: sunxi: Fix PLL6 calculation on sun6i
In reply to Chen-Yu TsaiThe N factor for PLL6 counts from 1 to 32, as specified in the A23 manual, and shown in Allwinner's original A31 code.
Also the PLL6 factors alone calculate the clock rate for PLL6x2, not the normal halved output for PLL6. This is what the factors clk .recalc_rate callback expects.
This patch fixes the N factor in the clock driver, and adds a post PLL divider of 2 to calculate the rate for PLL6.
A further patch (to the DT) should add a fixed-factor x2 clock as the PLL6x2 output.
--- drivers/clk/sunxi/clk-sunxi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/sunxi/clk-sunxi.c +4 -2
@@ -246,7 +246,7 @@ static void sun4i_get_pll5_factors(u32 *freq, u32 parent_rate,/** * sun6i_a31_get_pll6_factors() - calculates n, k factors for A31 PLL6 * PLL6 rate is calculated as follows -* rate = parent_rate * n * (k + 1) / 2 +* rate = parent_rate * (n + 1) * (k + 1) / 2 * parent_rate is always 24Mhz */
@@ -273,7 +273,7 @@ static void sun6i_a31_get_pll6_factors(u32 *freq, u32 parent_rate,if (*k >3 ) *k =3 ; - *n =DIV_ROUND_UP (div, (*k+1 )); + *n =DIV_ROUND_UP (div, (*k+1 )) -1 ; }/**
@@ -494,6 +494,8 @@ static struct clk_factors_config sun6i_a31_pll6_config = { .nwidth = 5, .kshift = 4, .kwidth = 2, + .n_start = 1, + .post_div = 2, };static struct clk_factors_config sun4i_apb1_config = {
Signature · 1 line
2.1.0
PATCH 2/7 clk: sunxi: Fix PLL6 calculation on sun6i
Quoted 7 lines · Chen-Yu Tsai
The N factor for PLL6 counts from 1 to 32, as specified in the A23 manual, and shown in Allwinner's original A31 code.
Also the PLL6 factors alone calculate the clock rate for PLL6x2, not the normal halved output for PLL6. This is what the factors clk .recalc_rate callback expects.
Quoted 7 lines
This patch fixes the N factor in the clock driver, and adds a post PLL divider of 2 to calculate the rate for PLL6.
A further patch (to the DT) should add a fixed-factor x2 clock as the PLL6x2 output.
Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/3f493df6/attachment.sig>
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
In reply to Chen-Yu TsaiThis patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
--- Documentation/devicetree/bindings/clock/sunxi.txt | 2 +- drivers/clk/sunxi/clk-sunxi.c | 209 ++++++++++++++++++++++ 2 files changed, 210 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -1
@@ -23,7 +23,7 @@ Required properties: "allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s "allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20 "allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31 - "allwinner,sun6i-a31-ahb1-mux-clk" - for the AHB1 multiplexer on A31 + "allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31 "allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31 "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23 "allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
drivers/clk/sunxi/clk-sunxi.c +209 -0
218 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
Hi,
Quoted 6 lines · Chen-Yu Tsai
This patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
Signed-off-by Chen-Yu Tsai <[email protected]>
It looks fine, but I'd rather see this in a separate file, especially since we don't seem to have any order dependency.
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/03a0bc3f/attachment.sig>
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
Hi,
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Chen-Yu Tsai
This patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
Quoted 4 lines
Quoted 1 line
Signed-off-by Chen-Yu Tsai <[email protected]>It looks fine, but I'd rather see this in a separate file, especially since we don't seem to have any order dependency.
Sorry, just to be clear, separate file under clk/sunxi?
This cannot be in a separate file, as it shares a spinlock with apb1 divider. They share the same register.
We could move apb1 out though. But i would prefer to do that when we split out all the clocks into individual OF_CLK_DECLAREs.
ChenYu
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
Quoted 12 lines · Chen-Yu Tsai
Hi,
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Chen-Yu Tsai
This patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Chen-Yu Tsai <[email protected]>It looks fine, but I'd rather see this in a separate file, especially since we don't seem to have any order dependency.
Sorry, just to be clear, separate file under clk/sunxi?
Yes
Quoted 5 lines
This cannot be in a separate file, as it shares a spinlock with apb1 divider. They share the same register.
We could move apb1 out though. But i would prefer to do that when we split out all the clocks into individual
OF_CLK_DECLAREs.
Ah right, my bad :)
My plan on the long term is to kill clk-sunxi as a place where all the clocks are defined, and only leave the "policy" there, for example the clock protection code (even if that should probably be removed too, together with clkdev), the various rates / parenting enforcements, etc.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140913/364cc588/attachment.sig>
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
Quoting Maxime Ripard (2014-09-13 03:26:03)
Quoted 28 lines · Chen-Yu Tsai
Quoted 12 lines
Hi,
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Chen-Yu Tsai
This patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Chen-Yu Tsai <[email protected]>It looks fine, but I'd rather see this in a separate file, especially since we don't seem to have any order dependency.
Sorry, just to be clear, separate file under clk/sunxi?
Yes
Quoted 5 lines
This cannot be in a separate file, as it shares a spinlock with apb1 divider. They share the same register.
We could move apb1 out though. But i would prefer to do that when we split out all the clocks into individual
OF_CLK_DECLAREs.
Quoted 7 lines
Ah right, my bad :)
My plan on the long term is to kill clk-sunxi as a place where all the clocks are defined, and only leave the "policy" there, for example the clock protection code (even if that should probably be removed too, together with clkdev), the various rates / parenting enforcements, etc.
Interesting! Where are you planning to store the clock data?
Regards,
Mike
Quoted 7 lines
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/7 clk: sunxi: unify sun6i AHB1 clock with proper PLL6 pre-divider
Quoted 31 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-13 03:26:03)
Quoted 30 lines · Chen-Yu Tsai
Quoted 12 lines
Hi,
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Chen-Yu Tsai
This patch unifies the sun6i AHB1 clock, originally supported with separate mux and divider clks. It also adds support for the pre-divider on the PLL6 input, thus allowing the clock to be muxed to PLL6 with proper clock rate calculation.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Chen-Yu Tsai <[email protected]>It looks fine, but I'd rather see this in a separate file, especially since we don't seem to have any order dependency.
Sorry, just to be clear, separate file under clk/sunxi?
Yes
Quoted 5 lines
This cannot be in a separate file, as it shares a spinlock with apb1 divider. They share the same register.
We could move apb1 out though. But i would prefer to do that when we split out all the clocks into individual
OF_CLK_DECLAREs.Ah right, my bad :)
Quoted 7 lines
Quoted 5 lines
My plan on the long term is to kill clk-sunxi as a place where all the clocks are defined, and only leave the "policy" there, for example the clock protection code (even if that should probably be removed too, together with clkdev), the various rates / parenting enforcements, etc.
Interesting! Where are you planning to store the clock data?
Which data?
I guess, for the rate boundaries, the DT would be the right place, wether a clock should be protected can be derived from its compatible. And for the rate to enforce, maybe a clock-frequency property in the DT too, or directly in the driver, I haven't really thought about that part at the moment to be honest :)
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140926/11e68a61/attachment.sig>
PATCH 4/7 ARM: dts: sun8i: Unify ahb1 clock nodes
In reply to Chen-Yu TsaiThe clock driver has unified support for the ahb1 clock. Unify the clock nodes so it works.
--- arch/arm/boot/dts/sun8i-a23.dtsi | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
arch/arm/boot/dts/sun8i-a23.dtsi +2 -10
@@ -104,19 +104,11 @@ clock-output-names = "axi"; }; - ahb1_mux: ahb1_mux_clk at 01c20054 { - #clock-cells = <0>; - compatible = "allwinner,sun6i-a31-ahb1-mux-clk"; - reg = <0x01c20054 0x4>; - clocks = <&osc32k>, <&osc24M>, <&axi>, <&pll6>; - clock-output-names = "ahb1_mux"; - }; - ahb1: ahb1_clk at 01c20054 { #clock-cells = <0>; - compatible = "allwinner,sun4i-a10-ahb-clk"; + compatible = "allwinner,sun6i-a31-ahb1-clk"; reg = <0x01c20054 0x4>; - clocks = <&ahb1_mux>; + clocks = <&osc32k>, <&osc24M>, <&axi>, <&pll6>; clock-output-names = "ahb1"; };
Signature · 1 line
2.1.0
PATCH 5/7 ARM: dts: sun6i: Unify ahb1 clock nodes
In reply to Chen-Yu TsaiThe clock driver has unified support for the ahb1 clock. Unify the clock nodes so it works.
--- arch/arm/boot/dts/sun6i-a31.dtsi | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
arch/arm/boot/dts/sun6i-a31.dtsi +2 -10
@@ -126,19 +126,11 @@ clock-output-names = "axi"; }; - ahb1_mux: ahb1_mux at 01c20054 { - #clock-cells = <0>; - compatible = "allwinner,sun6i-a31-ahb1-mux-clk"; - reg = <0x01c20054 0x4>; - clocks = <&osc32k>, <&osc24M>, <&axi>, <&pll6>; - clock-output-names = "ahb1_mux"; - }; - ahb1: ahb1 at 01c20054 { #clock-cells = <0>; - compatible = "allwinner,sun4i-a10-ahb-clk"; + compatible = "allwinner,sun6i-a31-ahb1-clk"; reg = <0x01c20054 0x4>; - clocks = <&ahb1_mux>; + clocks = <&osc32k>, <&osc24M>, <&axi>, <&pll6>; clock-output-names = "ahb1"; };
Signature · 1 line
2.1.0
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
In reply to Chen-Yu TsaiThe DMA controller requires AHB1 bus clock to be clocked from PLL6.
--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/sun6i-a31.dtsi +5 -0
@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>; }; mmc0: mmc at 01c0f000 {
Signature · 1 line
2.1.0
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0
arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;
Where did you get that from?
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/fb780bb6/attachment.sig>
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.
Hope this clears it up. :)
Cheers
ChenYu
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 32 lines · Chen-Yu Tsai
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Quoted 8 lines
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls
aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.Hope this clears it up. :)
It does, thanks :)
But still, I find it the wrong place to enforce such a limit. This should go into the clock driver itself. The DMA controller requires such a parenting, but it doesn't require any specific rate, this is more something of the global system policy.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140916/25a15db7/attachment-0001.sig>
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 40 lines · Maxime Ripard
Quoted 39 lines · Chen-Yu Tsai
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls
aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.
Quoted 8 lines
Quoted 1 line
Hope this clears it up. :)
It does, thanks :)
But still, I find it the wrong place to enforce such a limit. This should go into the clock driver itself. The DMA controller requires such a parenting, but it doesn't require any specific rate, this is more something of the global system policy.
But I am guessing the AHB bus clock cannot be clock at any arbitrary rate. Just muxing without setting a specific clock rate might result in a hang. We could address this with per clock limitations, like the patch you posted earlier. Not sure if there's anything in the kernel like that at the moment, or how the clock framework handles clock rates after re-parenting.
Or we could just specify in the clock driver, or in the DT via clock supplier defaults, that the AHB bus should be clocked from PLL6 @ 200 MHz.
The latter seems easier to do.
Also, I tested the DMA controller using dmatest on my A31 Hummingbird without this re-parenting patch. It worked fine. How did your tests fail?
Cheers
ChenYu
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 51 lines · Chen-Yu Tsai
Quoted 40 lines · Maxime Ripard
Quoted 39 lines · Chen-Yu Tsai
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls
aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.Quoted 8 lines
Quoted 1 line
Hope this clears it up. :)
It does, thanks :)
But still, I find it the wrong place to enforce such a limit. This should go into the clock driver itself. The DMA controller requires such a parenting, but it doesn't require any specific rate, this is more something of the global system policy.
Quoted 6 lines
But I am guessing the AHB bus clock cannot be clock at any arbitrary rate. Just muxing without setting a specific clock rate might result in a hang. We could address this with per clock limitations, like the patch you posted earlier. Not sure if there's anything in the kernel like that at the moment, or how the clock framework handles clock rates after re-parenting.
There's the Tomeu patch series that allows to set clock rate requirements from the user side, I guess that could be easily extended to integrate some clock side boundaries. That's why I stopped working on the sun5i MMC clock issue until that patch is merged.
Quoted 4 lines
Or we could just specify in the clock driver, or in the DT via clock supplier defaults, that the AHB bus should be clocked from PLL6 @ 200 MHz.
The latter seems easier to do.
IIRC, there was some opposition to having the muxing assignment in the clock driver.
Quoted 2 lines
Also, I tested the DMA controller using dmatest on my A31 Hummingbird without this re-parenting patch. It worked fine. How did your tests fail?
It was just timeouting, and actually, it was only working to the SRAM, and not the DRAM.
Maybe the bootloader sets up the clock muxing already?
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140920/000ec49f/attachment.sig>
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 59 lines · Maxime Ripard
Quoted 51 lines · Chen-Yu Tsai
Quoted 40 lines · Maxime Ripard
Quoted 39 lines · Chen-Yu Tsai
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls
aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.Quoted 8 lines
Quoted 1 line
Hope this clears it up. :)
It does, thanks :)
But still, I find it the wrong place to enforce such a limit. This should go into the clock driver itself. The DMA controller requires such a parenting, but it doesn't require any specific rate, this is more something of the global system policy.
Quoted 6 lines
But I am guessing the AHB bus clock cannot be clock at any arbitrary rate. Just muxing without setting a specific clock rate might result in a hang. We could address this with per clock limitations, like the patch you posted earlier. Not sure if there's anything in the kernel like that at the moment, or how the clock framework handles clock rates after re-parenting.
Quoted 4 lines
There's the Tomeu patch series that allows to set clock rate requirements from the user side, I guess that could be easily extended to integrate some clock side boundaries. That's why I stopped working on the sun5i MMC clock issue until that patch is merged.
I could take a look, but AFAIK none of our drivers need to propagate clock rate changes.
Quoted 8 lines
Quoted 4 lines
Or we could just specify in the clock driver, or in the DT via clock supplier defaults, that the AHB bus should be clocked from PLL6 @ 200 MHz.
The latter seems easier to do.
IIRC, there was some opposition to having the muxing assignment in the clock driver.
Quoted 7 lines
Quoted 2 lines
Also, I tested the DMA controller using dmatest on my A31 Hummingbird without this re-parenting patch. It worked fine. How did your tests fail?
It was just timeouting, and actually, it was only working to the SRAM, and not the DRAM.
Maybe the bootloader sets up the clock muxing already?
I just reran my tests on the A31, and dmatest indeed passes. I'm using your A31 sdcard.img, replaced u-boot with one built from u-boot-sunxi, so it supports DT.
I also checked both the clock framework and the raw registers. AHB1 is indeed clocked from AXI on my system.
Full log: https://gist.github.com/wens/ae17aed6728b83c0a9c3
If you (or someone else with A31) can verify the results, maybe we can just drop this patch.
Cheers
ChenYu
PATCH 6/7 ARM: dts: sun6i: Add required ahb1 clock parent and rates for dma controller
Quoted 61 lines · Chen-Yu Tsai
Quoted 59 lines · Maxime Ripard
Quoted 57 lines · Chen-Yu Tsai
Quoted 40 lines · Maxime Ripard
Quoted 39 lines · Chen-Yu Tsai
Quoted 24 lines · Maxime Ripard
Quoted 12 lines · Chen-Yu Tsai
The DMA controller requires AHB1 bus clock to be clocked from PLL6.
Signed-off-by Chen-Yu Tsai <[email protected]>--- arch/arm/boot/dts/sun6i-a31.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/boot/dts/sun6i-a31.dtsi +0
-0arch/arm/boot/dts/sun6i-a31.dtsi line 324
Quoted 8 lines
arch/arm/boot/dts/sun6i-a31.dtsi +5
-0@@ -317,6 +317,11 @@ clocks = <&ahb1_gates 6>; resets = <&ahb1_rst 6>; #dma-cells = <1>; + + /* DMA controller requires AHB1 clocked from PLL6 */ + assigned-clocks = <&ahb1>; + assigned-clock-parents = <&pll6>; + assigned-clock-rates = <200000000>;Where did you get that from?
Quoted 2 lines
The user manual says that it should be clocked at 600MHz, and I'm not sure it should be enforced there either.
The bindings mean that ahb1 should be clocked from pll6 and at 200 MHz, not "pll6 should be 200 MHz". I assume you were misled by them.
Clocking ahb1 from pll6 and at 200 MHz with the /3 pre-divider is the vendor BSP default:
On sun6i, the clock init code calls
aw_ccu_switch_ahb_2_pll6(), which muxes ahb1 from pll6 with the highest dividers, then sets the rate for ahb1 to pll6, which sets pre-divider to /3 and divider to /1.Quoted 8 lines
Quoted 1 line
Hope this clears it up. :)
It does, thanks :)
But still, I find it the wrong place to enforce such a limit. This should go into the clock driver itself. The DMA controller requires such a parenting, but it doesn't require any specific rate, this is more something of the global system policy.
But I am guessing the AHB bus clock cannot be clock at any arbitrary rate. Just muxing without setting a specific clock rate might result in a hang. We could address this with per clock limitations, like the patch you posted earlier. Not sure if there's anything in the kernel like that at the moment, or how the clock framework handles clock rates after re-parenting.
Quoted 7 lines
Quoted 4 lines
There's the Tomeu patch series that allows to set clock rate requirements from the user side, I guess that could be easily extended to integrate some clock side boundaries. That's why I stopped working on the sun5i MMC clock issue until that patch is merged.
I could take a look, but AFAIK none of our drivers need to propagate clock rate changes.
Don't worry about this.
Quoted 20 lines
Quoted 8 lines
Quoted 4 lines
Or we could just specify in the clock driver, or in the DT via clock supplier defaults, that the AHB bus should be clocked from PLL6 @ 200 MHz.
The latter seems easier to do.
IIRC, there was some opposition to having the muxing assignment in the clock driver.
Quoted 7 lines
Quoted 2 lines
Also, I tested the DMA controller using dmatest on my A31 Hummingbird without this re-parenting patch. It worked fine. How did your tests fail?
It was just timeouting, and actually, it was only working to the SRAM, and not the DRAM.
Maybe the bootloader sets up the clock muxing already?
I just reran my tests on the A31, and dmatest indeed passes. I'm using your A31 sdcard.img, replaced u-boot with one built from u-boot-sunxi, so it supports DT.
Quoted 7 lines
I also checked both the clock framework and the raw registers. AHB1 is indeed clocked from AXI on my system.
Full log: https://gist.github.com/wens/ae17aed6728b83c0a9c3
If you (or someone else with A31) can verify the results, maybe we can just drop this patch.
I'm away from the colombus board this week, but if it works on the hummingbird, we can just move this patch to the colombus DT, and not put it in the DTSI.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140925/dacb99ce/attachment.sig>
PATCH 7/7 dmaengine: sun6i: Remove obsolete clk muxing code
In reply to Chen-Yu TsaiThe sun6i DMA controller requires the AHB1 bus clock to be clocked from PLL6. This was originally done by the dmaengine driver during probe time. The AHB1 clock driver has since been unified, so the original code does not work.
Remove the clk muxing code, and replace it with DT clk default properties.
--- drivers/dma/sun6i-dma.c | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/dma/sun6i-dma.c +0 -23
@@ -862,7 +862,6 @@ static int sun6i_dma_probe(struct platform_device *pdev) {struct sun6i_dma_dev *sdc;struct resource *res; -struct clk *mux, *pll6;int ret, i; sdc =devm_kzalloc (&pdev->dev,sizeof (*sdc),GFP_KERNEL );
@@ -886,28 +885,6 @@ static int sun6i_dma_probe(struct platform_device *pdev)return PTR_ERR (sdc->clk); } - mux =clk_get (NULL ,"ahb1_mux" ); -if (IS_ERR (mux)) { -dev_err (&pdev->dev,"Couldn't get AHB1 Mux\n" ); -return PTR_ERR (mux); - } - - pll6 =clk_get (NULL ,"pll6" ); -if (IS_ERR (pll6)) { -dev_err (&pdev->dev,"Couldn't get PLL6\n" ); -clk_put (mux); -return PTR_ERR (pll6); - } - - ret =clk_set_parent (mux, pll6); -clk_put (pll6); -clk_put (mux); - -if (ret) { -dev_err (&pdev->dev,"Couldn't reparent AHB1 on PLL6\n" ); -return ret; - } - sdc->rstc =devm_reset_control_get (&pdev->dev,NULL );if (IS_ERR (sdc->rstc)) {dev_err (&pdev->dev,"No reset controller specified\n" );
Signature · 1 line
2.1.0
PATCH 7/7 dmaengine: sun6i: Remove obsolete clk muxing code
Quoted 9 lines · Chen-Yu Tsai
The sun6i DMA controller requires the AHB1 bus clock to be clocked from PLL6. This was originally done by the dmaengine driver during probe time. The AHB1 clock driver has since been unified, so the original code does not work.
Remove the clk muxing code, and replace it with DT clk default properties.
Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/070a48b6/attachment.sig>
Vinod Koul
AppliedPATCH 7/7 dmaengine: sun6i: Remove obsolete clk muxing code
In reply to Chen-Yu TsaiQuoted 7 lines · Chen-Yu Tsai
The sun6i DMA controller requires the AHB1 bus clock to be clocked from PLL6. This was originally done by the dmaengine driver during probe time. The AHB1 clock driver has since been unified, so the original code does not work.
Remove the clk muxing code, and replace it with DT clk default properties.
Applied, thanks
Signature · 1 line
~Vinod
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
In reply to Chen-Yu TsaiHi Chen-Yu,
Quoted 24 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
Quoted 4 lines
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.
I don't know what Mike thinks of this, but I'd prefer the second.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140911/c5b977f3/attachment.sig>
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Quoting Maxime Ripard (2014-09-11 13:36:23)
Quoted 27 lines
Hi Chen-Yu,
Quoted 24 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
Quoted 6 lines
Quoted 4 lines
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.I don't know what Mike thinks of this, but I'd prefer the second.
I do not fully understand the problem. Ideally the clock driver should have some way to fail with EPROBE_DEFER until the fixed-rate clocks are registered. Those fixed-rate parents are enumerated in your dts, right? Why isn't this enough?
Thanks,
Mike
Quoted 7 lines
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Quoted 33 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-11 13:36:23)
Quoted 32 lines
Hi Chen-Yu,
Quoted 28 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.
Quoted 6 lines
Quoted 1 line
I don't know what Mike thinks of this, but I'd prefer the second.
I do not fully understand the problem. Ideally the clock driver should have some way to fail with
EPROBE_DEFERuntil the fixed-rate clocks are registered. Those fixed-rate parents are enumerated in your dts, right? Why isn't this enough?
This is due to the way the sunxi clock driver is setup. The clock driver's OF_CLK_DECLARE matches against the "soc" node, not the individual clock nodes. When the setup function is called, it just registers all the supported clocks. There are no dependencies listed.
Unfortunately, the fixed-factor clock is in the middle of the whole clock tree. The sunxi clock driver provides its parents _and_ its children. Naturally the clock framework then probes the fixed-factor clock after the sunxi ones. Any attempts to change the state of clocks under the unavailable fixed-factor clock, such as done by of_clk_set_defaults(), would get an incomplete clock, likely with no parents and parent_rate = 0. That is until of_clk_init() finishes and all clocks are properly hooked up.
Anyway, this problem only occurred when I added clk-assigned-* defaults to the clock provider node, which is not the case anymore.
The second method i proposed is to have OF_CLK_DECLAREs for each individual clock. An example can be found here:
https://github.com/wens/linux/commit/1276898da02a93da4af163ed5bdc88cdead565dc
This does add a lot of boilerplate code. Not really happy about it. But it seems the proper way to split up the driver.
Cheers
ChenYu
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Quoting Chen-Yu Tsai (2014-09-25 17:55:27)
Quoted 55 lines · Mike Turquette
Quoted 33 lines
Quoting Maxime Ripard (2014-09-11 13:36:23)
Quoted 32 lines
Hi Chen-Yu,
Quoted 28 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.Quoted 6 lines
Quoted 1 line
I don't know what Mike thinks of this, but I'd prefer the second.
I do not fully understand the problem. Ideally the clock driver should have some way to fail with
EPROBE_DEFERuntil the fixed-rate clocks are registered. Those fixed-rate parents are enumerated in your dts, right? Why isn't this enough?This is due to the way the sunxi clock driver is setup. The clock driver's
OF_CLK_DECLAREmatches against the "soc" node, not the individual clock nodes. When the setup function is called, it just registers all the supported clocks. There are no dependencies listed.Unfortunately, the fixed-factor clock is in the middle of the whole clock tree. The sunxi clock driver provides its parents _and_ its children. Naturally the clock framework then probes the fixed-factor clock after the sunxi ones. Any attempts to change the state of clocks under the unavailable fixed-factor clock, such as done by
of_clk_set_defaults(), would get an incomplete clock, likely with no parents andparent_rate= 0. That is untilof_clk_init()finishes and all clocks are properly hooked up.
Quoted 2 lines
Anyway, this problem only occurred when I added clk-assigned-* defaults to the clock provider node, which is not the case anymore.
Makes sense. I guess you could ignore the problem until you need to use the assigned defaults.
Quoted 8 lines
The second method i proposed is to have
OF_CLK_DECLAREsfor each individual clock. An example can be found here:https://github.com/wens/linux/commit/1276898da02a93da4af163ed5bdc88cdead565dc
This does add a lot of boilerplate code. Not really happy about it. But it seems the proper way to split up the driver.
Yeah, this is OK. Ugly, but OK.
Regards,
Mike
Quoted 4 lines
Cheers
ChenYu
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Quoted 56 lines · Mike Turquette
Quoting Chen-Yu Tsai (2014-09-25 17:55:27)
Quoted 55 lines · Mike Turquette
Quoted 33 lines
Quoting Maxime Ripard (2014-09-11 13:36:23)
Quoted 32 lines
Hi Chen-Yu,
Quoted 28 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.Quoted 6 lines
Quoted 1 line
I don't know what Mike thinks of this, but I'd prefer the second.
I do not fully understand the problem. Ideally the clock driver should have some way to fail with
EPROBE_DEFERuntil the fixed-rate clocks are registered. Those fixed-rate parents are enumerated in your dts, right? Why isn't this enough?This is due to the way the sunxi clock driver is setup. The clock driver's
OF_CLK_DECLAREmatches against the "soc" node, not the individual clock nodes. When the setup function is called, it just registers all the supported clocks. There are no dependencies listed.Unfortunately, the fixed-factor clock is in the middle of the whole clock tree. The sunxi clock driver provides its parents _and_ its children. Naturally the clock framework then probes the fixed-factor clock after the sunxi ones. Any attempts to change the state of clocks under the unavailable fixed-factor clock, such as done by
of_clk_set_defaults(), would get an incomplete clock, likely with no parents andparent_rate= 0. That is untilof_clk_init()finishes and all clocks are properly hooked up.
Quoted 5 lines
Quoted 2 lines
Anyway, this problem only occurred when I added clk-assigned-* defaults to the clock provider node, which is not the case anymore.
Makes sense. I guess you could ignore the problem until you need to use the assigned defaults.
An update on this. Improper ordering of clock probing also affects sunxi's clock protection code.
Currently we have 2 mechanisms for protecting clocks.
a) A list of clock names in sunxi/clk-sunxi.c, fetched and enabled using clkdev.
b) Enabling clocks right after they are registered. Used for separated clock drivers like sun5i-a13-mbus and sun8i-a23-mbus.
One issue I ran across was when most of the clock tree is registered using independent CLK_OF_DECLAREs, as I'm doing for the A80, if the protected clocks list is handled before the clock tree is complete, the prepare and enable calls are not correctly propagated to the parents that arrive later on.
This happens to the ahb*_sdram gates.
Quoted 9 lines
Quoted 7 lines
The second method i proposed is to have
OF_CLK_DECLAREsfor each individual clock. An example can be found here:https://github.com/wens/linux/commit/1276898da02a93da4af163ed5bdc88cdead565dc
This does add a lot of boilerplate code. Not really happy about it. But it seems the proper way to split up the driver.
Yeah, this is OK. Ugly, but OK.
Thanks.
ChenYu
cover clk: sun6i: Unify AHB1 clock and fix rate calculation
Quoted 73 lines · Chen-Yu Tsai
Quoted 56 lines · Mike Turquette
Quoting Chen-Yu Tsai (2014-09-25 17:55:27)
Quoted 55 lines · Mike Turquette
Quoted 33 lines
Quoting Maxime Ripard (2014-09-11 13:36:23)
Quoted 32 lines
Hi Chen-Yu,
Quoted 28 lines · Chen-Yu Tsai
Hi everyone,
This series unifies the mux and divider parts of the AHB1 clock found on sun6i and sun8i, while also adding support for the pre-divider on the PLL6 input.
The rate calculation logic must factor in which parent it is using to calculate the rate, to decide whether to use the pre-divider or not. This is beyond the original factors clk design in sunxi. To avoid feature bloat, this is implemented as a seperate composite clk.
The new clock driver is registered with a separate
OF_CLK_DECLARE. This is done so that assigned-clocks* properties on the clk provider node can actually work. The clock framework arranges the clock setup order by checking whether all clock parents are available, by checking the node matchingOF_CLK_DECLARE.However, the sunxi clk driver is based on the root node compatible, has no defined dependencies (parents), and is setup before the fixed-rate clocks. Thus when the ahb1 clock is added, all parents have rate = 0. There is no way to calculate the required clock factors to set a default clock rate under these circumstances. This happens when we set the defaults in the clock node (provider), rather than a clock consumer.
I can think of 2 ways to solve the dependency issue, but neither is pretty. One would be to move the root fixed-rate clocks into the sunxi clk driver. The other would be separating all the clocks into individual
OF_CLK_DECLAREstatements, which adds a lot of boilerplate code.Quoted 6 lines
Quoted 1 line
I don't know what Mike thinks of this, but I'd prefer the second.
I do not fully understand the problem. Ideally the clock driver should have some way to fail with
EPROBE_DEFERuntil the fixed-rate clocks are registered. Those fixed-rate parents are enumerated in your dts, right? Why isn't this enough?This is due to the way the sunxi clock driver is setup. The clock driver's
OF_CLK_DECLAREmatches against the "soc" node, not the individual clock nodes. When the setup function is called, it just registers all the supported clocks. There are no dependencies listed.Unfortunately, the fixed-factor clock is in the middle of the whole clock tree. The sunxi clock driver provides its parents _and_ its children. Naturally the clock framework then probes the fixed-factor clock after the sunxi ones. Any attempts to change the state of clocks under the unavailable fixed-factor clock, such as done by
of_clk_set_defaults(), would get an incomplete clock, likely with no parents andparent_rate= 0. That is untilof_clk_init()finishes and all clocks are properly hooked up.Quoted 5 lines
Quoted 2 lines
Anyway, this problem only occurred when I added clk-assigned-* defaults to the clock provider node, which is not the case anymore.
Makes sense. I guess you could ignore the problem until you need to use the assigned defaults.
An update on this. Improper ordering of clock probing also affects sunxi's clock protection code.
Currently we have 2 mechanisms for protecting clocks.
a) A list of clock names in
sunxi/clk-sunxi.c, fetched and enabled using clkdev.
b) Enabling clocks right after they are registered. Used for separated clock drivers like sun5i-a13-mbus and sun8i-a23-mbus.
Quoted 7 lines
One issue I ran across was when most of the clock tree is registered using independent
CLK_OF_DECLAREs, as I'm doing for the A80, if the protected clocks list is handled before the clock tree is complete, the prepare and enable calls are not correctly propagated to the parents that arrive later on.This happens to the ahb*_sdram gates.
I guess that eventually, we should be able to remove a). For the time being, maybe we can just move the clock protection code itself to a later initcall?
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141013/1d84f837/attachment.sig>