Commit 7c18a65c authored by Tero Kristo's avatar Tero Kristo Committed by Michael Turquette

clk: ti: mux: add support for legacy mux init

Legacy clock data is initialized slightly differently compared to
DT clocks, thus add support for this.
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarMichael Turquette <mturquette@linaro.org>
parent c82f8957
...@@ -211,6 +211,9 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup) ...@@ -211,6 +211,9 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup)
clk = clk_register_fixed_rate(NULL, setup->name, NULL, clk = clk_register_fixed_rate(NULL, setup->name, NULL,
CLK_IS_ROOT, fixed->frequency); CLK_IS_ROOT, fixed->frequency);
break; break;
case TI_CLK_MUX:
clk = ti_clk_register_mux(setup);
break;
case TI_CLK_FIXED_FACTOR: case TI_CLK_FIXED_FACTOR:
fixed_factor = setup->data; fixed_factor = setup->data;
......
...@@ -153,6 +153,10 @@ struct ti_clk_dpll { ...@@ -153,6 +153,10 @@ struct ti_clk_dpll {
u8 recal_st_bit; u8 recal_st_bit;
}; };
struct clk *ti_clk_register_mux(struct ti_clk *setup);
struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup);
void ti_clk_patch_legacy_clks(struct ti_clk **patch); void ti_clk_patch_legacy_clks(struct ti_clk **patch);
struct clk *ti_clk_register_clk(struct ti_clk *setup); struct clk *ti_clk_register_clk(struct ti_clk *setup);
int ti_clk_register_legacy_clks(struct ti_clk_alias *clks); int ti_clk_register_legacy_clks(struct ti_clk_alias *clks);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/clk/ti.h> #include <linux/clk/ti.h>
#include "clock.h"
#undef pr_fmt #undef pr_fmt
#define pr_fmt(fmt) "%s: " fmt, __func__ #define pr_fmt(fmt) "%s: " fmt, __func__
...@@ -144,6 +145,39 @@ static struct clk *_register_mux(struct device *dev, const char *name, ...@@ -144,6 +145,39 @@ static struct clk *_register_mux(struct device *dev, const char *name,
return clk; return clk;
} }
struct clk *ti_clk_register_mux(struct ti_clk *setup)
{
struct ti_clk_mux *mux;
u32 flags;
u8 mux_flags = 0;
struct clk_omap_reg *reg_setup;
u32 reg;
u32 mask;
reg_setup = (struct clk_omap_reg *)&reg;
mux = setup->data;
flags = CLK_SET_RATE_NO_REPARENT;
mask = mux->num_parents;
if (!(mux->flags & CLKF_INDEX_STARTS_AT_ONE))
mask--;
mask = (1 << fls(mask)) - 1;
reg_setup->index = mux->module;
reg_setup->offset = mux->reg;
if (mux->flags & CLKF_INDEX_STARTS_AT_ONE)
mux_flags |= CLK_MUX_INDEX_ONE;
if (mux->flags & CLKF_SET_RATE_PARENT)
flags |= CLK_SET_RATE_PARENT;
return _register_mux(NULL, setup->name, mux->parents, mux->num_parents,
flags, (void __iomem *)reg, mux->bit_shift, mask,
mux_flags, NULL, NULL);
}
/** /**
* of_mux_clk_setup - Setup function for simple mux rate clock * of_mux_clk_setup - Setup function for simple mux rate clock
* @node: DT node for the clock * @node: DT node for the clock
...@@ -194,8 +228,9 @@ static void of_mux_clk_setup(struct device_node *node) ...@@ -194,8 +228,9 @@ static void of_mux_clk_setup(struct device_node *node)
mask = (1 << fls(mask)) - 1; mask = (1 << fls(mask)) - 1;
clk = _register_mux(NULL, node->name, parent_names, num_parents, flags, clk = _register_mux(NULL, node->name, parent_names, num_parents,
reg, shift, mask, clk_mux_flags, NULL, NULL); flags, reg, shift, mask, clk_mux_flags, NULL,
NULL);
if (!IS_ERR(clk)) if (!IS_ERR(clk))
of_clk_add_provider(node, of_clk_src_simple_get, clk); of_clk_add_provider(node, of_clk_src_simple_get, clk);
...@@ -205,6 +240,37 @@ static void of_mux_clk_setup(struct device_node *node) ...@@ -205,6 +240,37 @@ static void of_mux_clk_setup(struct device_node *node)
} }
CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup); CLK_OF_DECLARE(mux_clk, "ti,mux-clock", of_mux_clk_setup);
struct clk_hw *ti_clk_build_component_mux(struct ti_clk_mux *setup)
{
struct clk_mux *mux;
struct clk_omap_reg *reg;
int num_parents;
if (!setup)
return NULL;
mux = kzalloc(sizeof(*mux), GFP_KERNEL);
if (!mux)
return ERR_PTR(-ENOMEM);
reg = (struct clk_omap_reg *)&mux->reg;
mux->shift = setup->bit_shift;
reg->index = setup->module;
reg->offset = setup->reg;
if (setup->flags & CLKF_INDEX_STARTS_AT_ONE)
mux->flags |= CLK_MUX_INDEX_ONE;
num_parents = setup->num_parents;
mux->mask = num_parents - 1;
mux->mask = (1 << fls(mux->mask)) - 1;
return &mux->hw;
}
static void __init of_ti_composite_mux_clk_setup(struct device_node *node) static void __init of_ti_composite_mux_clk_setup(struct device_node *node)
{ {
struct clk_mux *mux; struct clk_mux *mux;
......
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