1 From 11e7ff129807394d87c937b880bb58972dc91fc0 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
3 Date: Thu, 28 Nov 2013 09:00:47 -0300
4 Subject: [PATCH] fixup! clk: sunxi: add PLL5 and PLL6 support
7 drivers/clk/sunxi/clk-sunxi.c | 83 +++++++++++++++++++++++++++++++++++--------
8 1 file changed, 69 insertions(+), 14 deletions(-)
10 diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
11 index d2b8d3c..3ce33b8 100644
12 --- a/drivers/clk/sunxi/clk-sunxi.c
13 +++ b/drivers/clk/sunxi/clk-sunxi.c
14 @@ -807,10 +807,11 @@ struct divs_data {
15 struct clk_div_table *table; /* is it a table based divisor? */
16 u8 shift; /* otherwise it's a normal divisor with this shift */
17 u8 pow; /* is it power-of-two based? */
18 + u8 gate; /* is it independently gateable? */
19 } div[SUNXI_DIVS_MAX_QTY];
22 -static struct clk_div_table pll6_sata_table[] = {
23 +static struct clk_div_table pll6_sata_tbl[] = {
24 { .val = 0, .div = 6, },
25 { .val = 1, .div = 12, },
26 { .val = 2, .div = 18, },
27 @@ -829,7 +830,7 @@ struct divs_data {
28 static const struct divs_data pll6_divs_data __initconst = {
29 .factors = &sun4i_pll5_data,
31 - { .shift = 0, .table = pll6_sata_table }, /* M, SATA */
32 + { .shift = 0, .table = pll6_sata_tbl, .gate = 14 }, /* M, SATA */
33 { .fixed = 2 }, /* P, other */
36 @@ -852,6 +853,11 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
37 const char *parent = node->name;
39 struct clk **clks, *pclk;
40 + struct clk_hw *gate_hw, *rate_hw;
41 + const struct clk_ops *rate_ops;
42 + struct clk_gate *gate = NULL;
43 + struct clk_fixed_factor *fix_factor;
44 + struct clk_divider *divider;
48 @@ -866,10 +872,9 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
51 clks = kzalloc(SUNXI_DIVS_MAX_QTY * sizeof(struct clk *), GFP_KERNEL);
59 clk_data->clks = clks;
61 /* It's not a good idea to have automatic reparenting changing
62 @@ -881,19 +886,60 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
70 + /* If this leaf clock can be gated, create a gate */
71 + if (data->div[i].gate) {
72 + gate = kzalloc(sizeof(*gate), GFP_KERNEL);
77 + gate->bit_idx = data->div[i].gate;
78 + gate->lock = &clk_lock;
80 + gate_hw = &gate->hw;
83 + /* Leaves can be fixed or configurable divisors */
84 if (data->div[i].fixed) {
85 - clks[i] = clk_register_fixed_factor(NULL, clk_name,
87 - 1, data->div[i].fixed);
88 + fix_factor = kzalloc(sizeof(*fix_factor), GFP_KERNEL);
92 + fix_factor->mult = 1;
93 + fix_factor->div = data->div[i].fixed;
95 + rate_hw = &fix_factor->hw;
96 + rate_ops = &clk_fixed_factor_ops;
98 + divider = kzalloc(sizeof(*divider), GFP_KERNEL);
102 flags = data->div[i].pow ? CLK_DIVIDER_POWER_OF_TWO : 0;
103 - clks[i] = clk_register_divider_table(NULL, clk_name,
104 - parent, clkflags, reg,
105 - data->div[i].shift,
106 - SUNXI_DIVISOR_WIDTH, flags,
107 - data->div[i].table, &clk_lock);
109 + divider->reg = reg;
110 + divider->shift = data->div[i].shift;
111 + divider->width = SUNXI_DIVISOR_WIDTH;
112 + divider->flags = flags;
113 + divider->lock = &clk_lock;
114 + divider->table = data->div[i].table;
116 + rate_hw = ÷r->hw;
117 + rate_ops = &clk_divider_ops;
120 + /* Wrap the (potential) gate and the divisor on a composite
121 + * clock to unify them */
122 + clks[i] = clk_register_composite(NULL, clk_name, &parent, 1,
125 + gate_hw, &clk_gate_ops,
128 WARN_ON(IS_ERR(clk_data->clks[i]));
129 clk_register_clkdev(clks[i], clk_name, NULL);
131 @@ -905,6 +951,15 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
132 clk_data->clk_num = i;
134 of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);