Commit 22a1dfe9 authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Stephen Boyd

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: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1595403506-8209-12-git-send-email-claudiu.beznea@microchip.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 64c9247b
...@@ -23,6 +23,7 @@ struct clk_generated { ...@@ -23,6 +23,7 @@ struct clk_generated {
struct regmap *regmap; struct regmap *regmap;
struct clk_range range; struct clk_range range;
spinlock_t *lock; spinlock_t *lock;
u32 *mux_table;
u32 id; u32 id;
u32 gckdiv; u32 gckdiv;
const struct clk_pcr_layout *layout; const struct clk_pcr_layout *layout;
...@@ -201,7 +202,11 @@ static int clk_generated_set_parent(struct clk_hw *hw, u8 index) ...@@ -201,7 +202,11 @@ static int clk_generated_set_parent(struct clk_hw *hw, u8 index)
if (index >= clk_hw_get_num_parents(hw)) if (index >= clk_hw_get_num_parents(hw))
return -EINVAL; return -EINVAL;
gck->parent_id = index; if (gck->mux_table)
gck->parent_id = clk_mux_index_to_val(gck->mux_table, 0, index);
else
gck->parent_id = index;
return 0; return 0;
} }
...@@ -273,8 +278,9 @@ struct clk_hw * __init ...@@ -273,8 +278,9 @@ struct clk_hw * __init
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
const struct clk_pcr_layout *layout, const struct clk_pcr_layout *layout,
const char *name, const char **parent_names, const char *name, const char **parent_names,
u8 num_parents, u8 id, u32 *mux_table, u8 num_parents, u8 id,
const struct clk_range *range, int chg_pid) const struct clk_range *range,
int chg_pid)
{ {
struct clk_generated *gck; struct clk_generated *gck;
struct clk_init_data init; struct clk_init_data init;
...@@ -300,6 +306,7 @@ at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, ...@@ -300,6 +306,7 @@ at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
gck->range = *range; gck->range = *range;
gck->chg_pid = chg_pid; gck->chg_pid = chg_pid;
gck->layout = layout; gck->layout = layout;
gck->mux_table = mux_table;
clk_generated_startup(gck); clk_generated_startup(gck);
hw = &gck->hw; hw = &gck->hw;
......
...@@ -158,8 +158,9 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np) ...@@ -158,8 +158,9 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
&dt_pcr_layout, name, &dt_pcr_layout, name,
parent_names, num_parents, parent_names, NULL,
id, &range, chg_pid); num_parents, id, &range,
chg_pid);
if (IS_ERR(hw)) if (IS_ERR(hw))
continue; continue;
......
...@@ -122,7 +122,7 @@ struct clk_hw * __init ...@@ -122,7 +122,7 @@ struct clk_hw * __init
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
const struct clk_pcr_layout *layout, const struct clk_pcr_layout *layout,
const char *name, const char **parent_names, const char *name, const char **parent_names,
u8 num_parents, u8 id, u32 *mux_table, u8 num_parents, u8 id,
const struct clk_range *range, int chg_pid); const struct clk_range *range, int chg_pid);
struct clk_hw * __init struct clk_hw * __init
......
...@@ -288,7 +288,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) ...@@ -288,7 +288,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
&sam9x60_pcr_layout, &sam9x60_pcr_layout,
sam9x60_gck[i].n, sam9x60_gck[i].n,
parent_names, 6, parent_names, NULL, 6,
sam9x60_gck[i].id, sam9x60_gck[i].id,
&sam9x60_gck[i].r, INT_MIN); &sam9x60_gck[i].r, INT_MIN);
if (IS_ERR(hw)) if (IS_ERR(hw))
......
...@@ -321,7 +321,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np) ...@@ -321,7 +321,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
&sama5d2_pcr_layout, &sama5d2_pcr_layout,
sama5d2_gck[i].n, sama5d2_gck[i].n,
parent_names, 6, parent_names, NULL, 6,
sama5d2_gck[i].id, sama5d2_gck[i].id,
&sama5d2_gck[i].r, &sama5d2_gck[i].r,
sama5d2_gck[i].chg_pid); sama5d2_gck[i].chg_pid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment