* [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support
@ 2013-07-23 1:01 Emilio López
2013-07-23 1:01 ` [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks Emilio López
` (7 more replies)
0 siblings, 8 replies; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
Hi everyone,
This patchset provides more clock support for the sunxi platform. Its
main aim is to implement support for PLL4, 5 and 6, as well as
MOD0-style clocks, used for various components such as MMC and IR.
The first patch fixes a small regression found while testing on
3.11-rc1. It does not affect the system in any way though, so there is
no real need to submit it as an rc fix.
The second patch reworks the way factor clocks are registered. By doing
so behind a composite clock, we gain the ability to divide, mux or gate
these clocks. This comes in handy to implement PLL5, PLL6 and MOD0
The third patch adds gating support to PLL1, and by doing so, it also
becomes bit-compatible with PLL4. The fourth patch adds a node on DT to
get PLL4 supported this way.
The fifth and sixth patches implement support for PLL5 and 6 on the
driver and adding the DT node, respectively.
Patches 7 and 8 implement support for module 0 style clocks and add all
the corresponding DT nodes for sun4i.
I have marked this series as RFC as I still need to write the bindings
for sun5i mod0 clocks and might change a thing or two on the other patches,
but I wanted to get this code out there for review early this cycle.
As always, any comments will be highly appreciated.
Thanks,
Emilio
Emilio L?pez (8):
clk: sunxi: fix initialization of basic clocks
clk: sunxi: register factors clocks behind composite
clk: sunxi: add gating support to PLL1
ARM: sunxi: add PLL4 support
clk: sunxi: add PLL5 and PLL6 support
ARM: sunxi: add PLL5 and PLL6 support
clk: sunxi: mod0 support
ARM: sun4i: mod0 clocks
Documentation/devicetree/bindings/clock/sunxi.txt | 5 +-
arch/arm/boot/dts/sun4i-a10.dtsi | 131 +++++++++-
arch/arm/boot/dts/sun5i-a10s.dtsi | 26 +-
arch/arm/boot/dts/sun5i-a13.dtsi | 26 +-
drivers/clk/sunxi/clk-factors.c | 63 +----
drivers/clk/sunxi/clk-factors.h | 16 +-
drivers/clk/sunxi/clk-sunxi.c | 285 +++++++++++++++++++++-
7 files changed, 466 insertions(+), 86 deletions(-)
--
1.8.3.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 9:33 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite Emilio López
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
With the recent move towards CLK_OF_DECLARE(...), the driver stopped
initializing osc32k, which is compatible "fixed-clock". This is because
we never called of_clk_init(NULL). Fix this by moving the only other
simple clock (osc24M) to use CLK_OF_DECLARE(...) and call of_clk_init(NULL)
to initialize both of them.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
drivers/clk/sunxi/clk-sunxi.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 412912b..323366b 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -411,10 +411,7 @@ static void __init sunxi_gates_clk_setup(struct device_node *node,
}
/* Matches for of_clk_init */
-static const __initconst struct of_device_id clk_match[] = {
- {.compatible = "allwinner,sun4i-osc-clk", .data = sunxi_osc_clk_setup,},
- {}
-};
+CLK_OF_DECLARE(sunxi_osc, "allwinner,sun4i-osc-clk", sunxi_osc_clk_setup);
/* Matches for factors clocks */
static const __initconst struct of_device_id clk_factors_match[] = {
@@ -467,8 +464,8 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat
void __init sunxi_init_clocks(void)
{
- /* Register all the simple sunxi clocks on DT */
- of_clk_init(clk_match);
+ /* Register all the simple and basic clocks on DT */
+ of_clk_init(NULL);
/* Register factor clocks */
of_sunxi_table_clock_setup(clk_factors_match, sunxi_factors_clk_setup);
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
2013-07-23 1:01 ` [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 9:35 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1 Emilio López
` (5 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit reworks factors clock registration to be done behind a
composite clock. This allows us to additionally add a gate, mux or
divisors, as it will be needed by some future PLLs.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
drivers/clk/sunxi/clk-factors.c | 63 +--------------------------------------
drivers/clk/sunxi/clk-factors.h | 16 +++++-----
drivers/clk/sunxi/clk-sunxi.c | 66 ++++++++++++++++++++++++++++++++++++++---
3 files changed, 72 insertions(+), 73 deletions(-)
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 88523f9..6e3926c 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -30,14 +30,6 @@
* parent - fixed parent. No clk_set_parent support
*/
-struct clk_factors {
- struct clk_hw hw;
- void __iomem *reg;
- struct clk_factors_config *config;
- void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
- spinlock_t *lock;
-};
-
#define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
#define SETMASK(len, pos) (((-1U) >> (31-len)) << (pos))
@@ -120,61 +112,8 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,
return 0;
}
-static const struct clk_ops clk_factors_ops = {
+const struct clk_ops clk_factors_ops = {
.recalc_rate = clk_factors_recalc_rate,
.round_rate = clk_factors_round_rate,
.set_rate = clk_factors_set_rate,
};
-
-/**
- * clk_register_factors - register a factors clock with
- * the clock framework
- * @dev: device registering this clock
- * @name: name of this clock
- * @parent_name: name of clock's parent
- * @flags: framework-specific flags
- * @reg: register address to adjust factors
- * @config: shift and width of factors n, k, m and p
- * @get_factors: function to calculate the factors for a given frequency
- * @lock: shared register lock for this clock
- */
-struct clk *clk_register_factors(struct device *dev, const char *name,
- const char *parent_name,
- unsigned long flags, void __iomem *reg,
- struct clk_factors_config *config,
- void (*get_factors)(u32 *rate, u32 parent,
- u8 *n, u8 *k, u8 *m, u8 *p),
- spinlock_t *lock)
-{
- struct clk_factors *factors;
- struct clk *clk;
- struct clk_init_data init;
-
- /* allocate the factors */
- factors = kzalloc(sizeof(struct clk_factors), GFP_KERNEL);
- if (!factors) {
- pr_err("%s: could not allocate factors clk\n", __func__);
- return ERR_PTR(-ENOMEM);
- }
-
- init.name = name;
- init.ops = &clk_factors_ops;
- init.flags = flags;
- init.parent_names = (parent_name ? &parent_name : NULL);
- init.num_parents = (parent_name ? 1 : 0);
-
- /* struct clk_factors assignments */
- factors->reg = reg;
- factors->config = config;
- factors->lock = lock;
- factors->hw.init = &init;
- factors->get_factors = get_factors;
-
- /* register the clock */
- clk = clk_register(dev, &factors->hw);
-
- if (IS_ERR(clk))
- kfree(factors);
-
- return clk;
-}
diff --git a/drivers/clk/sunxi/clk-factors.h b/drivers/clk/sunxi/clk-factors.h
index f49851c..02e1a43 100644
--- a/drivers/clk/sunxi/clk-factors.h
+++ b/drivers/clk/sunxi/clk-factors.h
@@ -17,11 +17,13 @@ struct clk_factors_config {
u8 pwidth;
};
-struct clk *clk_register_factors(struct device *dev, const char *name,
- const char *parent_name,
- unsigned long flags, void __iomem *reg,
- struct clk_factors_config *config,
- void (*get_factors) (u32 *rate, u32 parent_rate,
- u8 *n, u8 *k, u8 *m, u8 *p),
- spinlock_t *lock);
+struct clk_factors {
+ struct clk_hw hw;
+ void __iomem *reg;
+ struct clk_factors_config *config;
+ void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
+ spinlock_t *lock;
+};
+
+extern const struct clk_ops clk_factors_ops;
#endif
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 323366b..f258a20 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -173,7 +173,11 @@ static void sunxi_get_apb1_factors(u32 *freq, u32 parent_rate,
* sunxi_factors_clk_setup() - Setup function for factor clocks
*/
+#define SUNXI_FACTORS_MUX_MASK 0x3
+
struct factors_data {
+ int enable;
+ int mux;
struct clk_factors_config *table;
void (*getter) (u32 *rate, u32 parent_rate, u8 *n, u8 *k, u8 *m, u8 *p);
};
@@ -210,16 +214,70 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
struct factors_data *data)
{
struct clk *clk;
+ struct clk_factors *factors;
+ struct clk_gate *gate = NULL;
+ struct clk_mux *mux = NULL;
+ struct clk_hw *gate_hw = NULL;
+ struct clk_hw *mux_hw = NULL;
const char *clk_name = node->name;
- const char *parent;
+ const char *parents[5];
void *reg;
+ int i = 0;
reg = of_iomap(node, 0);
- parent = of_clk_get_parent_name(node, 0);
+ /* if we have a mux, we will have >1 parents */
+ while (i < 5 && (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
+ i++;
+
+ factors = kzalloc(sizeof(struct clk_factors), GFP_KERNEL);
+ if (!factors)
+ return;
- clk = clk_register_factors(NULL, clk_name, parent, 0, reg,
- data->table, data->getter, &clk_lock);
+ /* Add a gate if this factor clock can be gated */
+ if (data->enable) {
+ gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
+ if (!gate) {
+ kfree(factors);
+ return;
+ }
+
+ /* set up gate properties */
+ gate->reg = reg;
+ gate->bit_idx = data->enable;
+ gate->lock = &clk_lock;
+ gate_hw = &gate->hw;
+ }
+
+ /* Add a mux if this factor clock can be muxed */
+ if (data->mux) {
+ mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);
+ if (!mux) {
+ kfree(factors);
+ kfree(gate);
+ return;
+ }
+
+ /* set up gate properties */
+ mux->reg = reg;
+ mux->shift = data->mux;
+ mux->mask = SUNXI_FACTORS_MUX_MASK;
+ mux->lock = &clk_lock;
+ mux_hw = &mux->hw;
+ }
+
+ /* set up factors properties */
+ factors->reg = reg;
+ factors->config = data->table;
+ factors->get_factors = data->getter;
+ factors->lock = &clk_lock;
+
+ clk = clk_register_composite(NULL, clk_name,
+ parents, i,
+ mux_hw, &clk_mux_ops,
+ &factors->hw, &clk_factors_ops,
+ gate_hw, &clk_gate_ops,
+ i ? 0 : CLK_IS_ROOT);
if (clk) {
of_clk_add_provider(node, of_clk_src_simple_get, clk);
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
2013-07-23 1:01 ` [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks Emilio López
2013-07-23 1:01 ` [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 13:15 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 4/8] ARM: sunxi: add PLL4 support Emilio López
` (4 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit adds gating support to PLL1 on the clock driver. This makes
the PLL1 implementation fully compatible with PLL4 as well.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 2 +-
drivers/clk/sunxi/clk-sunxi.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index d495521..9a28022 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -7,7 +7,7 @@ This binding uses the common clock binding[1].
Required properties:
- compatible : shall be one of the following:
"allwinner,sun4i-osc-clk" - for a gatable oscillator
- "allwinner,sun4i-pll1-clk" - for the main PLL clock
+ "allwinner,sun4i-pll1-clk" - for the main PLL clock as well as PLL4
"allwinner,sun4i-cpu-clk" - for the CPU multiplexer clock
"allwinner,sun4i-axi-clk" - for the AXI clock
"allwinner,sun4i-axi-gates-clk" - for the AXI gates
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index f258a20..4dccdb9 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -201,6 +201,7 @@ static struct clk_factors_config apb1_config = {
};
static const __initconst struct factors_data pll1_data = {
+ .enable = 31,
.table = &pll1_config,
.getter = sunxi_get_pll1_factors,
};
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 4/8] ARM: sunxi: add PLL4 support
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
` (2 preceding siblings ...)
2013-07-23 1:01 ` [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1 Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 1:01 ` [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support Emilio López
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit adds the PLL4 definition to the sun4i and sun5i device
trees. PLL4 is compatible with PLL1.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 7 +++++++
arch/arm/boot/dts/sun5i-a10s.dtsi | 7 +++++++
arch/arm/boot/dts/sun5i-a13.dtsi | 7 +++++++
3 files changed, 21 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index b2bd6e1..6d569fd 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -66,6 +66,13 @@
clocks = <&osc24M>;
};
+ pll4: pll4 at 01c20018 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-pll1-clk";
+ reg = <0x01c20018 0x4>;
+ clocks = <&osc24M>;
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 2307ce8..9c1a2b9 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -63,6 +63,13 @@
clocks = <&osc24M>;
};
+ pll4: pll4 at 01c20018 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-pll1-clk";
+ reg = <0x01c20018 0x4>;
+ clocks = <&osc24M>;
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index 7363211..67889cf 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -67,6 +67,13 @@
clocks = <&osc24M>;
};
+ pll4: pll4 at 01c20018 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-pll1-clk";
+ reg = <0x01c20018 0x4>;
+ clocks = <&osc24M>;
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
` (3 preceding siblings ...)
2013-07-23 1:01 ` [PATCH RFC 4/8] ARM: sunxi: add PLL4 support Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 13:22 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 6/8] ARM: " Emilio López
` (2 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit implements PLL5 and PLL6 support on the sunxi clock driver.
These PLLs use a similar factor clock, but differ on their outputs.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 2 +
drivers/clk/sunxi/clk-sunxi.c | 159 +++++++++++++++++++++-
2 files changed, 159 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 9a28022..6634eac 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -8,6 +8,8 @@ Required properties:
- compatible : shall be one of the following:
"allwinner,sun4i-osc-clk" - for a gatable oscillator
"allwinner,sun4i-pll1-clk" - for the main PLL clock as well as PLL4
+ "allwinner,sun4i-pll5-clk" - for the PLL5 clock
+ "allwinner,sun4i-pll6-clk" - for the PLL6 clock
"allwinner,sun4i-cpu-clk" - for the CPU multiplexer clock
"allwinner,sun4i-axi-clk" - for the AXI clock
"allwinner,sun4i-axi-gates-clk" - for the AXI gates
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 4dccdb9..743c2c2 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -127,6 +127,38 @@ static void sunxi_get_pll1_factors(u32 *freq, u32 parent_rate,
/**
+ * sunxi_get_pll5_factors() - calculates n, k factors for PLL5
+ * PLL5 rate is calculated as follows
+ * rate = parent_rate * n * (k + 1)
+ * parent_rate is always 24Mhz
+ */
+
+static void sunxi_get_pll5_factors(u32 *freq, u32 parent_rate,
+ u8 *n, u8 *k, u8 *m, u8 *p)
+{
+ u8 div;
+
+ /* Normalize value to a 24M multiple */
+ div = *freq / 24000000;
+ *freq = 24000000 * div;
+
+ /* we were called to round the frequency, we can now return */
+ if (n == NULL)
+ return;
+
+ if (*freq < 480000000)
+ *k = 0;
+ else if (*freq < 960000000)
+ *k = 1;
+ else
+ *k = 3;
+
+ *n = DIV_ROUND_UP(*freq, ((*k+1) * 24000000));
+}
+
+
+
+/**
* sunxi_get_apb1_factors() - calculates m, p factors for APB1
* APB1 rate is calculated as follows
* rate = (parent_rate >> p) / (m + 1);
@@ -193,6 +225,13 @@ static struct clk_factors_config pll1_config = {
.pwidth = 2,
};
+static struct clk_factors_config pll5_config = {
+ .nshift = 8,
+ .nwidth = 5,
+ .kshift = 4,
+ .kwidth = 2,
+};
+
static struct clk_factors_config apb1_config = {
.mshift = 0,
.mwidth = 5,
@@ -206,6 +245,12 @@ static const __initconst struct factors_data pll1_data = {
.getter = sunxi_get_pll1_factors,
};
+static const __initconst struct factors_data pll5_data = {
+ .enable = 31,
+ .table = &pll5_config,
+ .getter = sunxi_get_pll5_factors,
+};
+
static const __initconst struct factors_data apb1_data = {
.table = &apb1_config,
.getter = sunxi_get_apb1_factors,
@@ -223,6 +268,7 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
const char *clk_name = node->name;
const char *parents[5];
void *reg;
+ unsigned long flags;
int i = 0;
reg = of_iomap(node, 0);
@@ -273,12 +319,14 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
factors->get_factors = data->getter;
factors->lock = &clk_lock;
+ /* We should not disable pll5, it powers the RAM */
+ flags = !strcmp("pll5", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
clk = clk_register_composite(NULL, clk_name,
parents, i,
mux_hw, &clk_mux_ops,
&factors->hw, &clk_factors_ops,
- gate_hw, &clk_gate_ops,
- i ? 0 : CLK_IS_ROOT);
+ gate_hw, &clk_gate_ops, flags);
if (clk) {
of_clk_add_provider(node, of_clk_src_simple_get, clk);
@@ -469,6 +517,103 @@ static void __init sunxi_gates_clk_setup(struct device_node *node,
of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
}
+
+
+/**
+ * sunxi_divs_clk_setup() - Setup function for leaf divisors on clocks
+ */
+
+#define SUNXI_DIVS_MAX_QTY 2
+
+struct divs_data {
+ const struct factors_data *factors; /* data for the factor clock */
+ struct {
+ u8 fixed; /* is it a fixed divisor? if not... */
+ struct clk_div_table *table; /* is it a table based divisor? */
+ u8 shift; /* otherwise it's a normal divisor with this shift */
+ u8 pow; /* is it power-of-two based? */
+ } div[SUNXI_DIVS_MAX_QTY];
+};
+
+static struct clk_div_table pll6_sata_table[] = {
+ { .val = 0, .div = 6, },
+ { .val = 1, .div = 12, },
+ { .val = 2, .div = 18, },
+ { .val = 3, .div = 24, },
+ { } /* sentinel */
+};
+
+static const __initconst struct divs_data pll5_divs_data = {
+ .factors = &pll5_data,
+ .div = {
+ { .shift = 0, .pow = 0, }, /* M, DDR */
+ { .shift = 16, .pow = 1, }, /* P, other */
+ }
+};
+
+static const __initconst struct divs_data pll6_divs_data = {
+ .factors = &pll5_data,
+ .div = {
+ { .shift = 0, .table = pll6_sata_table }, /* M, SATA */
+ { .fixed = 2 }, /* P, other */
+ }
+};
+
+static void __init sunxi_divs_clk_setup(struct device_node *node,
+ struct divs_data *data)
+{
+ struct clk_onecell_data *clk_data;
+ const char *parent = node->name;
+ const char *clk_name;
+ struct clk **clks;
+ void *reg;
+ int i = 0;
+ int flags;
+
+ /* Set up factor clock that we will be dividing */
+ sunxi_factors_clk_setup(node, (struct factors_data *)data->factors);
+
+ reg = of_iomap(node, 0);
+
+ clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+ if (!clk_data)
+ return;
+ clks = kzalloc(SUNXI_DIVS_MAX_QTY * sizeof(struct clk *), GFP_KERNEL);
+ if (!clk_data->clks) {
+ kfree(clk_data);
+ return;
+ }
+ clk_data->clks = clks;
+
+ for (i = 0; i < SUNXI_DIVS_MAX_QTY; i++) {
+ if (of_property_read_string_index(node, "clock-output-names",
+ i, &clk_name) != 0)
+ break;
+
+ if (data->div[i].fixed) {
+ clks[i] = clk_register_fixed_factor(NULL, clk_name,
+ parent, 0, 1,
+ data->div[i].fixed);
+ } else {
+ flags = data->div[i].pow ? CLK_DIVIDER_POWER_OF_TWO : 0;
+ clks[i] = clk_register_divider_table(NULL, clk_name,
+ parent, 0, reg,
+ data->div[i].shift,
+ SUNXI_DIVISOR_WIDTH,
+ flags,
+ data->div[i].table,
+ &clk_lock);
+ }
+
+ WARN_ON(IS_ERR(clk_data->clks[i]));
+ }
+
+ /* Adjust to the real max */
+ clk_data->clk_num = i;
+
+ of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
/* Matches for of_clk_init */
CLK_OF_DECLARE(sunxi_osc, "allwinner,sun4i-osc-clk", sunxi_osc_clk_setup);
@@ -487,6 +632,13 @@ static const __initconst struct of_device_id clk_div_match[] = {
{}
};
+/* Matches for divided outputs */
+static const __initconst struct of_device_id clk_divs_match[] = {
+ {.compatible = "allwinner,sun4i-pll5-clk", .data = &pll5_divs_data,},
+ {.compatible = "allwinner,sun4i-pll6-clk", .data = &pll6_divs_data,},
+ {}
+};
+
/* Matches for mux clocks */
static const __initconst struct of_device_id clk_mux_match[] = {
{.compatible = "allwinner,sun4i-cpu-clk", .data = &cpu_mux_data,},
@@ -532,6 +684,9 @@ void __init sunxi_init_clocks(void)
/* Register divider clocks */
of_sunxi_table_clock_setup(clk_div_match, sunxi_divider_clk_setup);
+ /* Register divided output clocks */
+ of_sunxi_table_clock_setup(clk_divs_match, sunxi_divs_clk_setup);
+
/* Register mux clocks */
of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 6/8] ARM: sunxi: add PLL5 and PLL6 support
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
` (4 preceding siblings ...)
2013-07-23 1:01 ` [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 1:01 ` [PATCH RFC 7/8] clk: sunxi: mod0 support Emilio López
2013-07-23 1:01 ` [PATCH RFC 8/8] ARM: sun4i: mod0 clocks Emilio López
7 siblings, 0 replies; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit adds PLL5 and PLL6 nodes to the sun4i and sun5i device trees.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 19 +++++++++++++++++--
arch/arm/boot/dts/sun5i-a10s.dtsi | 19 +++++++++++++++++--
arch/arm/boot/dts/sun5i-a13.dtsi | 19 +++++++++++++++++--
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 6d569fd..620290b 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -73,6 +73,22 @@
clocks = <&osc24M>;
};
+ pll5: pll5 at 01c20020 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll5-clk";
+ reg = <0x01c20020 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll5_ddr", "pll5_other";
+ };
+
+ pll6: pll6 at 01c20028 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll6-clk";
+ reg = <0x01c20028 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll6_sata", "pll6_other";
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
@@ -138,12 +154,11 @@
"apb0_ir1", "apb0_keypad";
};
- /* dummy is pll62 */
apb1_mux: apb1_mux at 01c20058 {
#clock-cells = <0>;
compatible = "allwinner,sun4i-apb1-mux-clk";
reg = <0x01c20058 0x4>;
- clocks = <&osc24M>, <&dummy>, <&osc32k>;
+ clocks = <&osc24M>, <&pll6 1>, <&osc32k>;
};
apb1: apb1 at 01c20058 {
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 9c1a2b9..4d47abc 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -70,6 +70,22 @@
clocks = <&osc24M>;
};
+ pll5: pll5 at 01c20020 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll5-clk";
+ reg = <0x01c20020 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll5_ddr", "pll5_other";
+ };
+
+ pll6: pll6 at 01c20028 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll6-clk";
+ reg = <0x01c20028 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll6_sata", "pll6_other";
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
@@ -135,12 +151,11 @@
"apb0_ir1", "apb0_keypad";
};
- /* dummy is pll62 */
apb1_mux: apb1_mux at 01c20058 {
#clock-cells = <0>;
compatible = "allwinner,sun4i-apb1-mux-clk";
reg = <0x01c20058 0x4>;
- clocks = <&osc24M>, <&dummy>, <&osc32k>;
+ clocks = <&osc24M>, <&pll6 1>, <&osc32k>;
};
apb1: apb1 at 01c20058 {
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index 67889cf..e652b5f 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -74,6 +74,22 @@
clocks = <&osc24M>;
};
+ pll5: pll5 at 01c20020 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll5-clk";
+ reg = <0x01c20020 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll5_ddr", "pll5_other";
+ };
+
+ pll6: pll6 at 01c20028 {
+ #clock-cells = <1>;
+ compatible = "allwinner,sun4i-pll6-clk";
+ reg = <0x01c20028 0x4>;
+ clocks = <&osc24M>;
+ clock-output-names = "pll6_sata", "pll6_other";
+ };
+
/* dummy is 200M */
cpu: cpu at 01c20054 {
#clock-cells = <0>;
@@ -132,12 +148,11 @@
clock-output-names = "apb0_codec", "apb0_pio", "apb0_ir";
};
- /* dummy is pll6 */
apb1_mux: apb1_mux at 01c20058 {
#clock-cells = <0>;
compatible = "allwinner,sun4i-apb1-mux-clk";
reg = <0x01c20058 0x4>;
- clocks = <&osc24M>, <&dummy>, <&osc32k>;
+ clocks = <&osc24M>, <&pll6 1>, <&osc32k>;
};
apb1: apb1 at 01c20058 {
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 7/8] clk: sunxi: mod0 support
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
` (5 preceding siblings ...)
2013-07-23 1:01 ` [PATCH RFC 6/8] ARM: " Emilio López
@ 2013-07-23 1:01 ` Emilio López
2013-07-23 13:29 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 8/8] ARM: sun4i: mod0 clocks Emilio López
7 siblings, 1 reply; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit implements support for the "module 0" type of clocks, as
used by MMC, IR, NAND, SATA and other components.
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
drivers/clk/sunxi/clk-sunxi.c | 54 +++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 6634eac..74c8f2e 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -23,6 +23,7 @@ Required properties:
"allwinner,sun4i-apb1-mux-clk" - for the APB1 clock muxing
"allwinner,sun4i-apb1-gates-clk" - for the APB1 gates on A10
"allwinner,sun5i-a13-apb1-gates-clk" - for the APB1 gates on A13
+ "allwinner,sun4i-mod0-clk" - for the module 0 family of clocks
Required properties for all clocks:
- reg : shall be the control register address for the clock.
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 743c2c2..28bf36f 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -202,6 +202,44 @@ static void sunxi_get_apb1_factors(u32 *freq, u32 parent_rate,
/**
+ * sunxi_get_mod0_factors() - calculates m, n factors for MOD0-style clocks
+ * MMC rate is calculated as follows
+ * rate = (parent_rate >> p) / (m + 1);
+ */
+
+static void sunxi_get_mod0_factors(u32 *freq, u32 parent_rate,
+ u8 *n, u8 *k, u8 *m, u8 *p)
+{
+ u8 div, calcm, calcp;
+
+ /* Normalize value to a division of the parent */
+ div = parent_rate / *freq;
+ *freq = parent_rate / div;
+
+ if (div < 16)
+ calcp = 0;
+ else if (div / 2 < 16)
+ calcp = 1;
+ else if (div / 4 < 16)
+ calcp = 2;
+ else
+ calcp = 3;
+
+ calcm = DIV_ROUND_UP(div, 1 << calcp);
+
+ *freq = (parent_rate >> calcp) / calcm;
+
+ /* we were called to round the frequency, we can now return */
+ if (n == NULL)
+ return;
+
+ *m = calcm - 1;
+ *p = calcp;
+}
+
+
+
+/**
* sunxi_factors_clk_setup() - Setup function for factor clocks
*/
@@ -239,6 +277,14 @@ static struct clk_factors_config apb1_config = {
.pwidth = 2,
};
+/* user manual says "n" but it's really "p" */
+static struct clk_factors_config mod0_config = {
+ .mshift = 0,
+ .mwidth = 4,
+ .pshift = 16,
+ .pwidth = 2,
+};
+
static const __initconst struct factors_data pll1_data = {
.enable = 31,
.table = &pll1_config,
@@ -256,6 +302,13 @@ static const __initconst struct factors_data apb1_data = {
.getter = sunxi_get_apb1_factors,
};
+static const __initconst struct factors_data mod0_data = {
+ .enable = 31,
+ .mux = 24,
+ .table = &mod0_config,
+ .getter = sunxi_get_mod0_factors,
+};
+
static void __init sunxi_factors_clk_setup(struct device_node *node,
struct factors_data *data)
{
@@ -621,6 +674,7 @@ CLK_OF_DECLARE(sunxi_osc, "allwinner,sun4i-osc-clk", sunxi_osc_clk_setup);
static const __initconst struct of_device_id clk_factors_match[] = {
{.compatible = "allwinner,sun4i-pll1-clk", .data = &pll1_data,},
{.compatible = "allwinner,sun4i-apb1-clk", .data = &apb1_data,},
+ {.compatible = "allwinner,sun4i-mod0-clk", .data = &mod0_data,},
{}
};
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 8/8] ARM: sun4i: mod0 clocks
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
` (6 preceding siblings ...)
2013-07-23 1:01 ` [PATCH RFC 7/8] clk: sunxi: mod0 support Emilio López
@ 2013-07-23 1:01 ` Emilio López
7 siblings, 0 replies; 14+ messages in thread
From: Emilio López @ 2013-07-23 1:01 UTC (permalink / raw)
To: linux-arm-kernel
This commit adds all the mod0 clocks present on sun4i to its device tree
Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 105 +++++++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 620290b..90493e3 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -180,6 +180,111 @@
"apb1_uart4", "apb1_uart5", "apb1_uart6",
"apb1_uart7";
};
+
+ nand: nand at 01c20080 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20080 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ ms: ms at 01c20084 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20084 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ mmc0: mmc0 at 01c20088 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20088 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ mmc1: mmc1 at 01c2008c {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c2008c 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ mmc2: mmc2 at 01c20090 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20090 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ mmc3: mmc3 at 01c20094 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20094 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ ts: ts at 01c20098 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c20098 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ ss: ss at 01c2009c {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c2009c 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ spi0: spi0 at 01c200a0 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200a0 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ spi1: spi0 at 01c200a4 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200a4 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ spi2: spi0 at 01c200a8 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200a8 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ pata: pata at 01c200ac {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200ac 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ ir0: ir0 at 01c200b0 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200b0 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ ir1: ir1 at 01c200b4 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200b4 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
+
+ spi3: spi3 at 01c200d4 {
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-mod0-clk";
+ reg = <0x01c200d4 0x4>;
+ clocks = <&osc24M>, <&pll6 1>, <&pll5 1>;
+ };
};
soc at 01c20000 {
--
1.8.3.3
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks
2013-07-23 1:01 ` [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks Emilio López
@ 2013-07-23 9:33 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2013-07-23 9:33 UTC (permalink / raw)
To: linux-arm-kernel
Hi Emilio,
On Mon, Jul 22, 2013 at 10:01:05PM -0300, Emilio L?pez wrote:
> With the recent move towards CLK_OF_DECLARE(...), the driver stopped
> initializing osc32k, which is compatible "fixed-clock". This is because
> we never called of_clk_init(NULL). Fix this by moving the only other
> simple clock (osc24M) to use CLK_OF_DECLARE(...) and call of_clk_init(NULL)
> to initialize both of them.
>
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
> ---
> drivers/clk/sunxi/clk-sunxi.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index 412912b..323366b 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -411,10 +411,7 @@ static void __init sunxi_gates_clk_setup(struct device_node *node,
> }
>
> /* Matches for of_clk_init */
> -static const __initconst struct of_device_id clk_match[] = {
> - {.compatible = "allwinner,sun4i-osc-clk", .data = sunxi_osc_clk_setup,},
> - {}
> -};
> +CLK_OF_DECLARE(sunxi_osc, "allwinner,sun4i-osc-clk", sunxi_osc_clk_setup);
Maybe we can drop the comment and the newline above?
Apart from this nitpick,
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Thanks,
Maxime
--
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: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/2c6476d6/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite
2013-07-23 1:01 ` [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite Emilio López
@ 2013-07-23 9:35 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2013-07-23 9:35 UTC (permalink / raw)
To: linux-arm-kernel
Hi Emilio,
On Mon, Jul 22, 2013 at 10:01:06PM -0300, Emilio L?pez wrote:
> This commit reworks factors clock registration to be done behind a
> composite clock. This allows us to additionally add a gate, mux or
> divisors, as it will be needed by some future PLLs.
Thanks for this patch, it looks fine.
I'm actually wondering if we could do this as well for the mux/gate/div
that we have?
This way, we would cover all the cases, and could only have one clock
defined per actual hardware clock.
Maxime
--
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: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/84a933b0/attachment-0001.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1
2013-07-23 1:01 ` [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1 Emilio López
@ 2013-07-23 13:15 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2013-07-23 13:15 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jul 22, 2013 at 10:01:07PM -0300, Emilio L?pez wrote:
> This commit adds gating support to PLL1 on the clock driver. This makes
> the PLL1 implementation fully compatible with PLL4 as well.
>
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
--
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: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/10e37aeb/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support
2013-07-23 1:01 ` [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support Emilio López
@ 2013-07-23 13:22 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2013-07-23 13:22 UTC (permalink / raw)
To: linux-arm-kernel
Hi Emilio,
On Mon, Jul 22, 2013 at 10:01:09PM -0300, Emilio L?pez wrote:
> This commit implements PLL5 and PLL6 support on the sunxi clock driver.
> These PLLs use a similar factor clock, but differ on their outputs.
>
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
> ---
> Documentation/devicetree/bindings/clock/sunxi.txt | 2 +
> drivers/clk/sunxi/clk-sunxi.c | 159 +++++++++++++++++++++-
> 2 files changed, 159 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index 9a28022..6634eac 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -8,6 +8,8 @@ Required properties:
> - compatible : shall be one of the following:
> "allwinner,sun4i-osc-clk" - for a gatable oscillator
> "allwinner,sun4i-pll1-clk" - for the main PLL clock as well as PLL4
> + "allwinner,sun4i-pll5-clk" - for the PLL5 clock
> + "allwinner,sun4i-pll6-clk" - for the PLL6 clock
> "allwinner,sun4i-cpu-clk" - for the CPU multiplexer clock
> "allwinner,sun4i-axi-clk" - for the AXI clock
> "allwinner,sun4i-axi-gates-clk" - for the AXI gates
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index 4dccdb9..743c2c2 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -127,6 +127,38 @@ static void sunxi_get_pll1_factors(u32 *freq, u32 parent_rate,
>
>
> /**
> + * sunxi_get_pll5_factors() - calculates n, k factors for PLL5
> + * PLL5 rate is calculated as follows
> + * rate = parent_rate * n * (k + 1)
In the A10 and A10s datasheet, the given formula is:
for the DDR
rate = parent * n * (k + 1) / (m + 1)
and for the other output
rate = (parent * n * (k + 1)) >> (p + 1)
so it doesn't look very right to me here.
> + * parent_rate is always 24Mhz
> + */
> +
> +static void sunxi_get_pll5_factors(u32 *freq, u32 parent_rate,
> + u8 *n, u8 *k, u8 *m, u8 *p)
> +{
> + u8 div;
> +
> + /* Normalize value to a 24M multiple */
> + div = *freq / 24000000;
> + *freq = 24000000 * div;
And that also means that we can generate frequencies that are not
necessarily multiples of 24MHz, so the round up here is wrong as well.
Maxime
--
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: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/ce2aee0b/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC 7/8] clk: sunxi: mod0 support
2013-07-23 1:01 ` [PATCH RFC 7/8] clk: sunxi: mod0 support Emilio López
@ 2013-07-23 13:29 ` Maxime Ripard
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Ripard @ 2013-07-23 13:29 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jul 22, 2013 at 10:01:11PM -0300, Emilio L?pez wrote:
> This commit implements support for the "module 0" type of clocks, as
> used by MMC, IR, NAND, SATA and other components.
>
> Signed-off-by: Emilio L?pez <emilio@elopez.com.ar>
It looks right to me,
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Thanks,
Maxime
--
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: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130723/a39266d4/attachment.sig>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-07-23 13:29 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-23 1:01 [PATCH RFC 0/8] sunxi clk: PLL4/5/6 and module 0 support Emilio López
2013-07-23 1:01 ` [PATCH RFC 1/8] clk: sunxi: fix initialization of basic clocks Emilio López
2013-07-23 9:33 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 2/8] clk: sunxi: register factors clocks behind composite Emilio López
2013-07-23 9:35 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 3/8] clk: sunxi: add gating support to PLL1 Emilio López
2013-07-23 13:15 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 4/8] ARM: sunxi: add PLL4 support Emilio López
2013-07-23 1:01 ` [PATCH RFC 5/8] clk: sunxi: add PLL5 and PLL6 support Emilio López
2013-07-23 13:22 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 6/8] ARM: " Emilio López
2013-07-23 1:01 ` [PATCH RFC 7/8] clk: sunxi: mod0 support Emilio López
2013-07-23 13:29 ` Maxime Ripard
2013-07-23 1:01 ` [PATCH RFC 8/8] ARM: sun4i: mod0 clocks Emilio López
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).