Skip to content

Commit 22a1dfe

Browse files
claudiubezneabebarino
authored andcommitted
clk: at91: clk-generated: 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 64c9247 commit 22a1dfe

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

drivers/clk/at91/clk-generated.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct clk_generated {
2323
struct regmap *regmap;
2424
struct clk_range range;
2525
spinlock_t *lock;
26+
u32 *mux_table;
2627
u32 id;
2728
u32 gckdiv;
2829
const struct clk_pcr_layout *layout;
@@ -201,7 +202,11 @@ static int clk_generated_set_parent(struct clk_hw *hw, u8 index)
201202
if (index >= clk_hw_get_num_parents(hw))
202203
return -EINVAL;
203204

204-
gck->parent_id = index;
205+
if (gck->mux_table)
206+
gck->parent_id = clk_mux_index_to_val(gck->mux_table, 0, index);
207+
else
208+
gck->parent_id = index;
209+
205210
return 0;
206211
}
207212

@@ -273,8 +278,9 @@ struct clk_hw * __init
273278
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
274279
const struct clk_pcr_layout *layout,
275280
const char *name, const char **parent_names,
276-
u8 num_parents, u8 id,
277-
const struct clk_range *range, int chg_pid)
281+
u32 *mux_table, u8 num_parents, u8 id,
282+
const struct clk_range *range,
283+
int chg_pid)
278284
{
279285
struct clk_generated *gck;
280286
struct clk_init_data init;
@@ -300,6 +306,7 @@ at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
300306
gck->range = *range;
301307
gck->chg_pid = chg_pid;
302308
gck->layout = layout;
309+
gck->mux_table = mux_table;
303310

304311
clk_generated_startup(gck);
305312
hw = &gck->hw;

drivers/clk/at91/dt-compat.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
158158

159159
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
160160
&dt_pcr_layout, name,
161-
parent_names, num_parents,
162-
id, &range, chg_pid);
161+
parent_names, NULL,
162+
num_parents, id, &range,
163+
chg_pid);
163164
if (IS_ERR(hw))
164165
continue;
165166

drivers/clk/at91/pmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct clk_hw * __init
122122
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
123123
const struct clk_pcr_layout *layout,
124124
const char *name, const char **parent_names,
125-
u8 num_parents, u8 id,
125+
u32 *mux_table, u8 num_parents, u8 id,
126126
const struct clk_range *range, int chg_pid);
127127

128128
struct clk_hw * __init

drivers/clk/at91/sam9x60.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
288288
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
289289
&sam9x60_pcr_layout,
290290
sam9x60_gck[i].n,
291-
parent_names, 6,
291+
parent_names, NULL, 6,
292292
sam9x60_gck[i].id,
293293
&sam9x60_gck[i].r, INT_MIN);
294294
if (IS_ERR(hw))

drivers/clk/at91/sama5d2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
321321
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
322322
&sama5d2_pcr_layout,
323323
sama5d2_gck[i].n,
324-
parent_names, 6,
324+
parent_names, NULL, 6,
325325
sama5d2_gck[i].id,
326326
&sama5d2_gck[i].r,
327327
sama5d2_gck[i].chg_pid);

0 commit comments

Comments
 (0)