Skip to contentSkip to conversation

clk: sunxi: add correct divider table for sun4i-apb0 clock

PATCH New Chen-Yu Tsai 3 participants 3 messages Sep 6, 2014 – Sep 13, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: sunxi: add correct divider table for sun4i-apb0 clock

The sun4i-apb0 clock, as found on all platforms using it, is a power-of-two-based divider clock, with a special divider of 2 for value 0.

This was causing the clock framework to incorrectly calculate the clock rate for apb1 and related modules on sun6i and sun8i. On sun[4/5/7]i, u-boot SPL configures the divider with value 1 for /2 divider, so no suprises there.

This patch adds a proper divider table for it, so the correct clock rate can be calculated.

---
 drivers/clk/sunxi/clk-sunxi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/clk/sunxi/clk-sunxi.c +9 -0
index b654b7b..2cf6581 100644
@@ -762,10 +762,19 @@ static const struct div_data sun4i_ahb_data __initconst = {
 	.width	= 2,
 };
 
+static const struct clk_div_table sun4i_apb0_table[] __initconst = {
+	{ .val = 0, .div = 2 },
+	{ .val = 1, .div = 2 },
+	{ .val = 2, .div = 4 },
+	{ .val = 3, .div = 8 },
+	{ } /* sentinel */
+};
+
 static const struct div_data sun4i_apb0_data __initconst = {
 	.shift	= 8,
 	.pow	= 1,
 	.width	= 2,
+	.table	= sun4i_apb0_table,
 };
 
 static const struct div_data sun6i_a31_apb2_div_data __initconst = {
Signature · 1 line
2.1.0
maintainer
#1 lore raw

PATCH 1/1 clk: sunxi: add correct divider table for sun4i-apb0 clock

Hi,

El 06/09/14 a las 03:45, Chen-Yu Tsai escibi?:

Quoted 9 lines

The sun4i-apb0 clock, as found on all platforms using it, is a power-of-two-based divider clock, with a special divider of 2 for value 0.

This was causing the clock framework to incorrectly calculate the clock rate for apb1 and related modules on sun6i and sun8i. On sun[4/5/7]i, u-boot SPL configures the divider with value 1 for /2 divider, so no suprises there.

Quoted 4 lines

This patch adds a proper divider table for it, so the correct clock rate can be calculated.

From a quick look at the A10 manual,

I'll see about testing it on hardware today/tomorrow

Thanks!

Emilio

#2 lore raw

PATCH 1/1 clk: sunxi: add correct divider table for sun4i-apb0 clock

In reply to Chen-Yu Tsai
Quoted 9 lines · Chen-Yu Tsai

The sun4i-apb0 clock, as found on all platforms using it, is a power-of-two-based divider clock, with a special divider of 2 for value 0.

This was causing the clock framework to incorrectly calculate the clock rate for apb1 and related modules on sun6i and sun8i. On sun[4/5/7]i, u-boot SPL configures the divider with value 1 for /2 divider, so no suprises there.

Quoted 4 lines

This patch adds a proper divider table for it, so the correct clock rate can be calculated.

Applied, 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/20140913/5859a864/attachment.sig>