Skip to content

Commit c57aaaa

Browse files
claudiubezneabebarino
authored andcommitted
clk: at91: clk-programmable: add mux_table option
Add mux table option. This is necessary for IP versions that has gaps in the range of available clock sources (e.g. SAMA7G5). Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent b4c115c commit c57aaaa

File tree

13 files changed

+38
-17
lines changed

13 files changed

+38
-17
lines changed

drivers/clk/at91/at91rm9200.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
160160

161161
hw = at91_clk_register_programmable(regmap, name,
162162
parent_names, 4, i,
163-
&at91rm9200_programmable_layout);
163+
&at91rm9200_programmable_layout,
164+
NULL);
164165
if (IS_ERR(hw))
165166
goto err_free;
166167

drivers/clk/at91/at91sam9260.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
436436

437437
hw = at91_clk_register_programmable(regmap, name,
438438
parent_names, 4, i,
439-
&at91rm9200_programmable_layout);
439+
&at91rm9200_programmable_layout,
440+
NULL);
440441
if (IS_ERR(hw))
441442
goto err_free;
442443

drivers/clk/at91/at91sam9g45.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
181181

182182
hw = at91_clk_register_programmable(regmap, name,
183183
parent_names, 5, i,
184-
&at91sam9g45_programmable_layout);
184+
&at91sam9g45_programmable_layout,
185+
NULL);
185186
if (IS_ERR(hw))
186187
goto err_free;
187188

drivers/clk/at91/at91sam9n12.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
199199

200200
hw = at91_clk_register_programmable(regmap, name,
201201
parent_names, 5, i,
202-
&at91sam9x5_programmable_layout);
202+
&at91sam9x5_programmable_layout,
203+
NULL);
203204
if (IS_ERR(hw))
204205
goto err_free;
205206

drivers/clk/at91/at91sam9rl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
137137

138138
hw = at91_clk_register_programmable(regmap, name,
139139
parent_names, 5, i,
140-
&at91rm9200_programmable_layout);
140+
&at91rm9200_programmable_layout,
141+
NULL);
141142
if (IS_ERR(hw))
142143
goto err_free;
143144

drivers/clk/at91/at91sam9x5.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
226226

227227
hw = at91_clk_register_programmable(regmap, name,
228228
parent_names, 5, i,
229-
&at91sam9x5_programmable_layout);
229+
&at91sam9x5_programmable_layout,
230+
NULL);
230231
if (IS_ERR(hw))
231232
goto err_free;
232233

drivers/clk/at91/clk-programmable.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
struct clk_programmable {
2222
struct clk_hw hw;
2323
struct regmap *regmap;
24+
u32 *mux_table;
2425
u8 id;
2526
const struct clk_programmable_layout *layout;
2627
};
@@ -108,6 +109,9 @@ static int clk_programmable_set_parent(struct clk_hw *hw, u8 index)
108109
if (layout->have_slck_mck)
109110
mask |= AT91_PMC_CSSMCK_MCK;
110111

112+
if (prog->mux_table)
113+
pckr = clk_mux_index_to_val(prog->mux_table, 0, index);
114+
111115
if (index > layout->css_mask) {
112116
if (index > PROG_MAX_RM9200_CSS && !layout->have_slck_mck)
113117
return -EINVAL;
@@ -134,6 +138,9 @@ static u8 clk_programmable_get_parent(struct clk_hw *hw)
134138
if (layout->have_slck_mck && (pckr & AT91_PMC_CSSMCK_MCK) && !ret)
135139
ret = PROG_MAX_RM9200_CSS + 1;
136140

141+
if (prog->mux_table)
142+
ret = clk_mux_val_to_index(&prog->hw, prog->mux_table, 0, ret);
143+
137144
return ret;
138145
}
139146

@@ -182,7 +189,8 @@ struct clk_hw * __init
182189
at91_clk_register_programmable(struct regmap *regmap,
183190
const char *name, const char **parent_names,
184191
u8 num_parents, u8 id,
185-
const struct clk_programmable_layout *layout)
192+
const struct clk_programmable_layout *layout,
193+
u32 *mux_table)
186194
{
187195
struct clk_programmable *prog;
188196
struct clk_hw *hw;
@@ -206,6 +214,7 @@ at91_clk_register_programmable(struct regmap *regmap,
206214
prog->layout = layout;
207215
prog->hw.init = &init;
208216
prog->regmap = regmap;
217+
prog->mux_table = mux_table;
209218

210219
hw = &prog->hw;
211220
ret = clk_hw_register(NULL, &prog->hw);

drivers/clk/at91/dt-compat.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ CLK_OF_DECLARE(at91sam9x5_clk_plldiv, "atmel,at91sam9x5-clk-plldiv",
677677

678678
static void __init
679679
of_at91_clk_prog_setup(struct device_node *np,
680-
const struct clk_programmable_layout *layout)
680+
const struct clk_programmable_layout *layout,
681+
u32 *mux_table)
681682
{
682683
int num;
683684
u32 id;
@@ -711,7 +712,7 @@ of_at91_clk_prog_setup(struct device_node *np,
711712

712713
hw = at91_clk_register_programmable(regmap, name,
713714
parent_names, num_parents,
714-
id, layout);
715+
id, layout, mux_table);
715716
if (IS_ERR(hw))
716717
continue;
717718

@@ -721,21 +722,21 @@ of_at91_clk_prog_setup(struct device_node *np,
721722

722723
static void __init of_at91rm9200_clk_prog_setup(struct device_node *np)
723724
{
724-
of_at91_clk_prog_setup(np, &at91rm9200_programmable_layout);
725+
of_at91_clk_prog_setup(np, &at91rm9200_programmable_layout, NULL);
725726
}
726727
CLK_OF_DECLARE(at91rm9200_clk_prog, "atmel,at91rm9200-clk-programmable",
727728
of_at91rm9200_clk_prog_setup);
728729

729730
static void __init of_at91sam9g45_clk_prog_setup(struct device_node *np)
730731
{
731-
of_at91_clk_prog_setup(np, &at91sam9g45_programmable_layout);
732+
of_at91_clk_prog_setup(np, &at91sam9g45_programmable_layout, NULL);
732733
}
733734
CLK_OF_DECLARE(at91sam9g45_clk_prog, "atmel,at91sam9g45-clk-programmable",
734735
of_at91sam9g45_clk_prog_setup);
735736

736737
static void __init of_at91sam9x5_clk_prog_setup(struct device_node *np)
737738
{
738-
of_at91_clk_prog_setup(np, &at91sam9x5_programmable_layout);
739+
of_at91_clk_prog_setup(np, &at91sam9x5_programmable_layout, NULL);
739740
}
740741
CLK_OF_DECLARE(at91sam9x5_clk_prog, "atmel,at91sam9x5-clk-programmable",
741742
of_at91sam9x5_clk_prog_setup);

drivers/clk/at91/pmc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ sam9x60_clk_register_pll(struct regmap *regmap, spinlock_t *lock,
188188
struct clk_hw * __init
189189
at91_clk_register_programmable(struct regmap *regmap, const char *name,
190190
const char **parent_names, u8 num_parents, u8 id,
191-
const struct clk_programmable_layout *layout);
191+
const struct clk_programmable_layout *layout,
192+
u32 *mux_table);
192193

193194
struct clk_hw * __init
194195
at91_clk_register_sam9260_slow(struct regmap *regmap,

drivers/clk/at91/sam9x60.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
254254

255255
hw = at91_clk_register_programmable(regmap, name,
256256
parent_names, 6, i,
257-
&sam9x60_programmable_layout);
257+
&sam9x60_programmable_layout,
258+
NULL);
258259
if (IS_ERR(hw))
259260
goto err_free;
260261

0 commit comments

Comments
 (0)