mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-01 16:14:13 +08:00
clk: at91: Migrate to clk_hw based registration and OF APIs
Now that we have clk_hw based provider APIs to register clks, we can get rid of struct clk pointers in this driver, allowing us to move closer to a clear split of consumer and provider clk APIs. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This commit is contained in:
parent
b19f009d45
commit
f5644f10dc
@ -233,14 +233,16 @@ static void clk_generated_startup(struct clk_generated *gck)
|
|||||||
>> AT91_PMC_PCR_GCKDIV_OFFSET;
|
>> AT91_PMC_PCR_GCKDIV_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, const char
|
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
|
||||||
*name, const char **parent_names, u8 num_parents,
|
const char *name, const char **parent_names,
|
||||||
u8 id, const struct clk_range *range)
|
u8 num_parents, u8 id,
|
||||||
|
const struct clk_range *range)
|
||||||
{
|
{
|
||||||
struct clk_generated *gck;
|
struct clk_generated *gck;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
gck = kzalloc(sizeof(*gck), GFP_KERNEL);
|
gck = kzalloc(sizeof(*gck), GFP_KERNEL);
|
||||||
if (!gck)
|
if (!gck)
|
||||||
@ -258,13 +260,15 @@ at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, const char
|
|||||||
gck->lock = lock;
|
gck->lock = lock;
|
||||||
gck->range = *range;
|
gck->range = *range;
|
||||||
|
|
||||||
clk = clk_register(NULL, &gck->hw);
|
hw = &gck->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &gck->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(gck);
|
kfree(gck);
|
||||||
else
|
hw = ERR_PTR(ret);
|
||||||
|
} else
|
||||||
clk_generated_startup(gck);
|
clk_generated_startup(gck);
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
|
static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
|
||||||
@ -272,7 +276,7 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
|
|||||||
int num;
|
int num;
|
||||||
u32 id;
|
u32 id;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *parent_names[GENERATED_SOURCE_MAX];
|
const char *parent_names[GENERATED_SOURCE_MAX];
|
||||||
struct device_node *gcknp;
|
struct device_node *gcknp;
|
||||||
@ -306,13 +310,13 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
|
|||||||
of_at91_get_clk_range(gcknp, "atmel,clk-output-range",
|
of_at91_get_clk_range(gcknp, "atmel,clk-output-range",
|
||||||
&range);
|
&range);
|
||||||
|
|
||||||
clk = at91_clk_register_generated(regmap, &pmc_pcr_lock, name,
|
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, name,
|
||||||
parent_names, num_parents,
|
parent_names, num_parents,
|
||||||
id, &range);
|
id, &range);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
of_clk_add_provider(gcknp, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(gcknp, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(of_sama5d2_clk_generated_setup, "atmel,sama5d2-clk-generated",
|
CLK_OF_DECLARE(of_sama5d2_clk_generated_setup, "atmel,sama5d2-clk-generated",
|
||||||
|
@ -92,7 +92,7 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np)
|
|||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct clk *clk;
|
int ret;
|
||||||
|
|
||||||
regmap = syscon_node_to_regmap(of_get_parent(np));
|
regmap = syscon_node_to_regmap(of_get_parent(np));
|
||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
@ -113,13 +113,13 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np)
|
|||||||
h32mxclk->hw.init = &init;
|
h32mxclk->hw.init = &init;
|
||||||
h32mxclk->regmap = regmap;
|
h32mxclk->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &h32mxclk->hw);
|
ret = clk_hw_register(NULL, &h32mxclk->hw);
|
||||||
if (IS_ERR(clk)) {
|
if (ret) {
|
||||||
kfree(h32mxclk);
|
kfree(h32mxclk);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, &h32mxclk->hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx",
|
CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx",
|
||||||
of_sama5d4_clk_h32mx_setup);
|
of_sama5d4_clk_h32mx_setup);
|
||||||
|
@ -128,15 +128,16 @@ static const struct clk_ops main_osc_ops = {
|
|||||||
.is_prepared = clk_main_osc_is_prepared,
|
.is_prepared = clk_main_osc_is_prepared,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_main_osc(struct regmap *regmap,
|
at91_clk_register_main_osc(struct regmap *regmap,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *parent_name,
|
const char *parent_name,
|
||||||
bool bypass)
|
bool bypass)
|
||||||
{
|
{
|
||||||
struct clk_main_osc *osc;
|
struct clk_main_osc *osc;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name || !parent_name)
|
if (!name || !parent_name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -160,16 +161,19 @@ at91_clk_register_main_osc(struct regmap *regmap,
|
|||||||
AT91_PMC_MOSCEN,
|
AT91_PMC_MOSCEN,
|
||||||
AT91_PMC_OSCBYPASS | AT91_PMC_KEY);
|
AT91_PMC_OSCBYPASS | AT91_PMC_KEY);
|
||||||
|
|
||||||
clk = clk_register(NULL, &osc->hw);
|
hw = &osc->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &osc->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(osc);
|
kfree(osc);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
|
static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
@ -183,11 +187,11 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
|
hw = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc",
|
CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc",
|
||||||
of_at91rm9200_clk_main_osc_setup);
|
of_at91rm9200_clk_main_osc_setup);
|
||||||
@ -271,14 +275,15 @@ static const struct clk_ops main_rc_osc_ops = {
|
|||||||
.recalc_accuracy = clk_main_rc_osc_recalc_accuracy,
|
.recalc_accuracy = clk_main_rc_osc_recalc_accuracy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_main_rc_osc(struct regmap *regmap,
|
at91_clk_register_main_rc_osc(struct regmap *regmap,
|
||||||
const char *name,
|
const char *name,
|
||||||
u32 frequency, u32 accuracy)
|
u32 frequency, u32 accuracy)
|
||||||
{
|
{
|
||||||
struct clk_main_rc_osc *osc;
|
struct clk_main_rc_osc *osc;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name || !frequency)
|
if (!name || !frequency)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -298,16 +303,19 @@ at91_clk_register_main_rc_osc(struct regmap *regmap,
|
|||||||
osc->frequency = frequency;
|
osc->frequency = frequency;
|
||||||
osc->accuracy = accuracy;
|
osc->accuracy = accuracy;
|
||||||
|
|
||||||
clk = clk_register(NULL, &osc->hw);
|
hw = &osc->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, hw);
|
||||||
|
if (ret) {
|
||||||
kfree(osc);
|
kfree(osc);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
|
static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
u32 frequency = 0;
|
u32 frequency = 0;
|
||||||
u32 accuracy = 0;
|
u32 accuracy = 0;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -321,11 +329,11 @@ static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy);
|
hw = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc",
|
CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc",
|
||||||
of_at91sam9x5_clk_main_rc_osc_setup);
|
of_at91sam9x5_clk_main_rc_osc_setup);
|
||||||
@ -395,14 +403,15 @@ static const struct clk_ops rm9200_main_ops = {
|
|||||||
.recalc_rate = clk_rm9200_main_recalc_rate,
|
.recalc_rate = clk_rm9200_main_recalc_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_rm9200_main(struct regmap *regmap,
|
at91_clk_register_rm9200_main(struct regmap *regmap,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *parent_name)
|
const char *parent_name)
|
||||||
{
|
{
|
||||||
struct clk_rm9200_main *clkmain;
|
struct clk_rm9200_main *clkmain;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -423,16 +432,19 @@ at91_clk_register_rm9200_main(struct regmap *regmap,
|
|||||||
clkmain->hw.init = &init;
|
clkmain->hw.init = &init;
|
||||||
clkmain->regmap = regmap;
|
clkmain->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &clkmain->hw);
|
hw = &clkmain->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &clkmain->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(clkmain);
|
kfree(clkmain);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
|
static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
@ -444,11 +456,11 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_rm9200_main(regmap, name, parent_name);
|
hw = at91_clk_register_rm9200_main(regmap, name, parent_name);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main",
|
CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main",
|
||||||
of_at91rm9200_clk_main_setup);
|
of_at91rm9200_clk_main_setup);
|
||||||
@ -529,16 +541,17 @@ static const struct clk_ops sam9x5_main_ops = {
|
|||||||
.get_parent = clk_sam9x5_main_get_parent,
|
.get_parent = clk_sam9x5_main_get_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_sam9x5_main(struct regmap *regmap,
|
at91_clk_register_sam9x5_main(struct regmap *regmap,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char **parent_names,
|
const char **parent_names,
|
||||||
int num_parents)
|
int num_parents)
|
||||||
{
|
{
|
||||||
struct clk_sam9x5_main *clkmain;
|
struct clk_sam9x5_main *clkmain;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
unsigned int status;
|
unsigned int status;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -561,16 +574,19 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
|
|||||||
regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status);
|
regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status);
|
||||||
clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0;
|
clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0;
|
||||||
|
|
||||||
clk = clk_register(NULL, &clkmain->hw);
|
hw = &clkmain->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &clkmain->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(clkmain);
|
kfree(clkmain);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
|
static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_names[2];
|
const char *parent_names[2];
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -587,12 +603,12 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
|
|||||||
|
|
||||||
of_property_read_string(np, "clock-output-names", &name);
|
of_property_read_string(np, "clock-output-names", &name);
|
||||||
|
|
||||||
clk = at91_clk_register_sam9x5_main(regmap, name, parent_names,
|
hw = at91_clk_register_sam9x5_main(regmap, name, parent_names,
|
||||||
num_parents);
|
num_parents);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_main, "atmel,at91sam9x5-clk-main",
|
CLK_OF_DECLARE(at91sam9x5_clk_main, "atmel,at91sam9x5-clk-main",
|
||||||
of_at91sam9x5_clk_main_setup);
|
of_at91sam9x5_clk_main_setup);
|
||||||
|
@ -120,7 +120,7 @@ static const struct clk_ops master_ops = {
|
|||||||
.get_parent = clk_master_get_parent,
|
.get_parent = clk_master_get_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_master(struct regmap *regmap,
|
at91_clk_register_master(struct regmap *regmap,
|
||||||
const char *name, int num_parents,
|
const char *name, int num_parents,
|
||||||
const char **parent_names,
|
const char **parent_names,
|
||||||
@ -128,8 +128,9 @@ at91_clk_register_master(struct regmap *regmap,
|
|||||||
const struct clk_master_characteristics *characteristics)
|
const struct clk_master_characteristics *characteristics)
|
||||||
{
|
{
|
||||||
struct clk_master *master;
|
struct clk_master *master;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name || !num_parents || !parent_names)
|
if (!name || !num_parents || !parent_names)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -149,12 +150,14 @@ at91_clk_register_master(struct regmap *regmap,
|
|||||||
master->characteristics = characteristics;
|
master->characteristics = characteristics;
|
||||||
master->regmap = regmap;
|
master->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &master->hw);
|
hw = &master->hw;
|
||||||
if (IS_ERR(clk)) {
|
ret = clk_hw_register(NULL, &master->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(master);
|
kfree(master);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +201,7 @@ static void __init
|
|||||||
of_at91_clk_master_setup(struct device_node *np,
|
of_at91_clk_master_setup(struct device_node *np,
|
||||||
const struct clk_master_layout *layout)
|
const struct clk_master_layout *layout)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *parent_names[MASTER_SOURCE_MAX];
|
const char *parent_names[MASTER_SOURCE_MAX];
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -221,13 +224,13 @@ of_at91_clk_master_setup(struct device_node *np,
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_master(regmap, name, num_parents,
|
hw = at91_clk_register_master(regmap, name, num_parents,
|
||||||
parent_names, layout,
|
parent_names, layout,
|
||||||
characteristics);
|
characteristics);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
goto out_free_characteristics;
|
goto out_free_characteristics;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out_free_characteristics:
|
out_free_characteristics:
|
||||||
|
@ -104,13 +104,14 @@ static const struct clk_ops peripheral_ops = {
|
|||||||
.is_enabled = clk_peripheral_is_enabled,
|
.is_enabled = clk_peripheral_is_enabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_peripheral(struct regmap *regmap, const char *name,
|
at91_clk_register_peripheral(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name, u32 id)
|
const char *parent_name, u32 id)
|
||||||
{
|
{
|
||||||
struct clk_peripheral *periph;
|
struct clk_peripheral *periph;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name || !parent_name || id > PERIPHERAL_ID_MAX)
|
if (!name || !parent_name || id > PERIPHERAL_ID_MAX)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -129,11 +130,14 @@ at91_clk_register_peripheral(struct regmap *regmap, const char *name,
|
|||||||
periph->hw.init = &init;
|
periph->hw.init = &init;
|
||||||
periph->regmap = regmap;
|
periph->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &periph->hw);
|
hw = &periph->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &periph->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(periph);
|
kfree(periph);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph)
|
static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph)
|
||||||
@ -327,14 +331,15 @@ static const struct clk_ops sam9x5_peripheral_ops = {
|
|||||||
.set_rate = clk_sam9x5_peripheral_set_rate,
|
.set_rate = clk_sam9x5_peripheral_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
|
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
|
||||||
const char *name, const char *parent_name,
|
const char *name, const char *parent_name,
|
||||||
u32 id, const struct clk_range *range)
|
u32 id, const struct clk_range *range)
|
||||||
{
|
{
|
||||||
struct clk_sam9x5_peripheral *periph;
|
struct clk_sam9x5_peripheral *periph;
|
||||||
struct clk *clk = NULL;
|
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
struct clk_hw *hw;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name || !parent_name)
|
if (!name || !parent_name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -357,13 +362,15 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
|
|||||||
periph->auto_div = true;
|
periph->auto_div = true;
|
||||||
periph->range = *range;
|
periph->range = *range;
|
||||||
|
|
||||||
clk = clk_register(NULL, &periph->hw);
|
hw = &periph->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &periph->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(periph);
|
kfree(periph);
|
||||||
else
|
hw = ERR_PTR(ret);
|
||||||
|
} else
|
||||||
clk_sam9x5_peripheral_autodiv(periph);
|
clk_sam9x5_peripheral_autodiv(periph);
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init
|
static void __init
|
||||||
@ -371,7 +378,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
|
|||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
u32 id;
|
u32 id;
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct device_node *periphclknp;
|
struct device_node *periphclknp;
|
||||||
@ -400,7 +407,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
|
|||||||
name = periphclknp->name;
|
name = periphclknp->name;
|
||||||
|
|
||||||
if (type == PERIPHERAL_AT91RM9200) {
|
if (type == PERIPHERAL_AT91RM9200) {
|
||||||
clk = at91_clk_register_peripheral(regmap, name,
|
hw = at91_clk_register_peripheral(regmap, name,
|
||||||
parent_name, id);
|
parent_name, id);
|
||||||
} else {
|
} else {
|
||||||
struct clk_range range = CLK_RANGE(0, 0);
|
struct clk_range range = CLK_RANGE(0, 0);
|
||||||
@ -409,17 +416,17 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
|
|||||||
"atmel,clk-output-range",
|
"atmel,clk-output-range",
|
||||||
&range);
|
&range);
|
||||||
|
|
||||||
clk = at91_clk_register_sam9x5_peripheral(regmap,
|
hw = at91_clk_register_sam9x5_peripheral(regmap,
|
||||||
&pmc_pcr_lock,
|
&pmc_pcr_lock,
|
||||||
name,
|
name,
|
||||||
parent_name,
|
parent_name,
|
||||||
id, &range);
|
id, &range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
of_clk_add_provider(periphclknp, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(periphclknp, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,17 +296,18 @@ static const struct clk_ops pll_ops = {
|
|||||||
.set_rate = clk_pll_set_rate,
|
.set_rate = clk_pll_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_pll(struct regmap *regmap, const char *name,
|
at91_clk_register_pll(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name, u8 id,
|
const char *parent_name, u8 id,
|
||||||
const struct clk_pll_layout *layout,
|
const struct clk_pll_layout *layout,
|
||||||
const struct clk_pll_characteristics *characteristics)
|
const struct clk_pll_characteristics *characteristics)
|
||||||
{
|
{
|
||||||
struct clk_pll *pll;
|
struct clk_pll *pll;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
int offset = PLL_REG(id);
|
int offset = PLL_REG(id);
|
||||||
unsigned int pllr;
|
unsigned int pllr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (id > PLL_MAX_ID)
|
if (id > PLL_MAX_ID)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -330,12 +331,14 @@ at91_clk_register_pll(struct regmap *regmap, const char *name,
|
|||||||
pll->div = PLL_DIV(pllr);
|
pll->div = PLL_DIV(pllr);
|
||||||
pll->mul = PLL_MUL(pllr, layout);
|
pll->mul = PLL_MUL(pllr, layout);
|
||||||
|
|
||||||
clk = clk_register(NULL, &pll->hw);
|
hw = &pll->hw;
|
||||||
if (IS_ERR(clk)) {
|
ret = clk_hw_register(NULL, &pll->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(pll);
|
kfree(pll);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -465,7 +468,7 @@ of_at91_clk_pll_setup(struct device_node *np,
|
|||||||
const struct clk_pll_layout *layout)
|
const struct clk_pll_layout *layout)
|
||||||
{
|
{
|
||||||
u32 id;
|
u32 id;
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -486,12 +489,12 @@ of_at91_clk_pll_setup(struct device_node *np,
|
|||||||
if (!characteristics)
|
if (!characteristics)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_pll(regmap, name, parent_name, id, layout,
|
hw = at91_clk_register_pll(regmap, name, parent_name, id, layout,
|
||||||
characteristics);
|
characteristics);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
goto out_free_characteristics;
|
goto out_free_characteristics;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out_free_characteristics:
|
out_free_characteristics:
|
||||||
|
@ -75,13 +75,14 @@ static const struct clk_ops plldiv_ops = {
|
|||||||
.set_rate = clk_plldiv_set_rate,
|
.set_rate = clk_plldiv_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_plldiv(struct regmap *regmap, const char *name,
|
at91_clk_register_plldiv(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name)
|
const char *parent_name)
|
||||||
{
|
{
|
||||||
struct clk_plldiv *plldiv;
|
struct clk_plldiv *plldiv;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
plldiv = kzalloc(sizeof(*plldiv), GFP_KERNEL);
|
plldiv = kzalloc(sizeof(*plldiv), GFP_KERNEL);
|
||||||
if (!plldiv)
|
if (!plldiv)
|
||||||
@ -96,18 +97,20 @@ at91_clk_register_plldiv(struct regmap *regmap, const char *name,
|
|||||||
plldiv->hw.init = &init;
|
plldiv->hw.init = &init;
|
||||||
plldiv->regmap = regmap;
|
plldiv->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &plldiv->hw);
|
hw = &plldiv->hw;
|
||||||
|
ret = clk_hw_register(NULL, &plldiv->hw);
|
||||||
if (IS_ERR(clk))
|
if (ret) {
|
||||||
kfree(plldiv);
|
kfree(plldiv);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init
|
static void __init
|
||||||
of_at91sam9x5_clk_plldiv_setup(struct device_node *np)
|
of_at91sam9x5_clk_plldiv_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
@ -120,12 +123,11 @@ of_at91sam9x5_clk_plldiv_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_plldiv(regmap, name, parent_name);
|
hw = at91_clk_register_plldiv(regmap, name, parent_name);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_plldiv, "atmel,at91sam9x5-clk-plldiv",
|
CLK_OF_DECLARE(at91sam9x5_clk_plldiv, "atmel,at91sam9x5-clk-plldiv",
|
||||||
of_at91sam9x5_clk_plldiv_setup);
|
of_at91sam9x5_clk_plldiv_setup);
|
||||||
|
@ -170,15 +170,16 @@ static const struct clk_ops programmable_ops = {
|
|||||||
.set_rate = clk_programmable_set_rate,
|
.set_rate = clk_programmable_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_programmable(struct regmap *regmap,
|
at91_clk_register_programmable(struct regmap *regmap,
|
||||||
const char *name, const char **parent_names,
|
const char *name, const char **parent_names,
|
||||||
u8 num_parents, u8 id,
|
u8 num_parents, u8 id,
|
||||||
const struct clk_programmable_layout *layout)
|
const struct clk_programmable_layout *layout)
|
||||||
{
|
{
|
||||||
struct clk_programmable *prog;
|
struct clk_programmable *prog;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (id > PROG_ID_MAX)
|
if (id > PROG_ID_MAX)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -198,11 +199,14 @@ at91_clk_register_programmable(struct regmap *regmap,
|
|||||||
prog->hw.init = &init;
|
prog->hw.init = &init;
|
||||||
prog->regmap = regmap;
|
prog->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &prog->hw);
|
hw = &prog->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &prog->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(prog);
|
kfree(prog);
|
||||||
|
hw = &prog->hw;
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct clk_programmable_layout at91rm9200_programmable_layout = {
|
static const struct clk_programmable_layout at91rm9200_programmable_layout = {
|
||||||
@ -229,7 +233,7 @@ of_at91_clk_prog_setup(struct device_node *np,
|
|||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
u32 id;
|
u32 id;
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *parent_names[PROG_SOURCE_MAX];
|
const char *parent_names[PROG_SOURCE_MAX];
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -257,13 +261,13 @@ of_at91_clk_prog_setup(struct device_node *np,
|
|||||||
if (of_property_read_string(np, "clock-output-names", &name))
|
if (of_property_read_string(np, "clock-output-names", &name))
|
||||||
name = progclknp->name;
|
name = progclknp->name;
|
||||||
|
|
||||||
clk = at91_clk_register_programmable(regmap, name,
|
hw = at91_clk_register_programmable(regmap, name,
|
||||||
parent_names, num_parents,
|
parent_names, num_parents,
|
||||||
id, layout);
|
id, layout);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
of_clk_add_provider(progclknp, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(progclknp, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ static const struct clk_ops slow_osc_ops = {
|
|||||||
.is_prepared = clk_slow_osc_is_prepared,
|
.is_prepared = clk_slow_osc_is_prepared,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_slow_osc(void __iomem *sckcr,
|
at91_clk_register_slow_osc(void __iomem *sckcr,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *parent_name,
|
const char *parent_name,
|
||||||
@ -119,8 +119,9 @@ at91_clk_register_slow_osc(void __iomem *sckcr,
|
|||||||
bool bypass)
|
bool bypass)
|
||||||
{
|
{
|
||||||
struct clk_slow_osc *osc;
|
struct clk_slow_osc *osc;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!sckcr || !name || !parent_name)
|
if (!sckcr || !name || !parent_name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -143,17 +144,20 @@ at91_clk_register_slow_osc(void __iomem *sckcr,
|
|||||||
writel((readl(sckcr) & ~AT91_SCKC_OSC32EN) | AT91_SCKC_OSC32BYP,
|
writel((readl(sckcr) & ~AT91_SCKC_OSC32EN) | AT91_SCKC_OSC32BYP,
|
||||||
sckcr);
|
sckcr);
|
||||||
|
|
||||||
clk = clk_register(NULL, &osc->hw);
|
hw = &osc->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &osc->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(osc);
|
kfree(osc);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init of_at91sam9x5_clk_slow_osc_setup(struct device_node *np,
|
void __init of_at91sam9x5_clk_slow_osc_setup(struct device_node *np,
|
||||||
void __iomem *sckcr)
|
void __iomem *sckcr)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
u32 startup;
|
u32 startup;
|
||||||
@ -164,12 +168,12 @@ void __init of_at91sam9x5_clk_slow_osc_setup(struct device_node *np,
|
|||||||
of_property_read_u32(np, "atmel,startup-time-usec", &startup);
|
of_property_read_u32(np, "atmel,startup-time-usec", &startup);
|
||||||
bypass = of_property_read_bool(np, "atmel,osc-bypass");
|
bypass = of_property_read_bool(np, "atmel,osc-bypass");
|
||||||
|
|
||||||
clk = at91_clk_register_slow_osc(sckcr, name, parent_name, startup,
|
hw = at91_clk_register_slow_osc(sckcr, name, parent_name, startup,
|
||||||
bypass);
|
bypass);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long clk_slow_rc_osc_recalc_rate(struct clk_hw *hw,
|
static unsigned long clk_slow_rc_osc_recalc_rate(struct clk_hw *hw,
|
||||||
@ -223,7 +227,7 @@ static const struct clk_ops slow_rc_osc_ops = {
|
|||||||
.recalc_accuracy = clk_slow_rc_osc_recalc_accuracy,
|
.recalc_accuracy = clk_slow_rc_osc_recalc_accuracy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_slow_rc_osc(void __iomem *sckcr,
|
at91_clk_register_slow_rc_osc(void __iomem *sckcr,
|
||||||
const char *name,
|
const char *name,
|
||||||
unsigned long frequency,
|
unsigned long frequency,
|
||||||
@ -231,8 +235,9 @@ at91_clk_register_slow_rc_osc(void __iomem *sckcr,
|
|||||||
unsigned long startup)
|
unsigned long startup)
|
||||||
{
|
{
|
||||||
struct clk_slow_rc_osc *osc;
|
struct clk_slow_rc_osc *osc;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!sckcr || !name)
|
if (!sckcr || !name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -253,17 +258,20 @@ at91_clk_register_slow_rc_osc(void __iomem *sckcr,
|
|||||||
osc->accuracy = accuracy;
|
osc->accuracy = accuracy;
|
||||||
osc->startup_usec = startup;
|
osc->startup_usec = startup;
|
||||||
|
|
||||||
clk = clk_register(NULL, &osc->hw);
|
hw = &osc->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &osc->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(osc);
|
kfree(osc);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init of_at91sam9x5_clk_slow_rc_osc_setup(struct device_node *np,
|
void __init of_at91sam9x5_clk_slow_rc_osc_setup(struct device_node *np,
|
||||||
void __iomem *sckcr)
|
void __iomem *sckcr)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
u32 frequency = 0;
|
u32 frequency = 0;
|
||||||
u32 accuracy = 0;
|
u32 accuracy = 0;
|
||||||
u32 startup = 0;
|
u32 startup = 0;
|
||||||
@ -274,12 +282,12 @@ void __init of_at91sam9x5_clk_slow_rc_osc_setup(struct device_node *np,
|
|||||||
of_property_read_u32(np, "clock-accuracy", &accuracy);
|
of_property_read_u32(np, "clock-accuracy", &accuracy);
|
||||||
of_property_read_u32(np, "atmel,startup-time-usec", &startup);
|
of_property_read_u32(np, "atmel,startup-time-usec", &startup);
|
||||||
|
|
||||||
clk = at91_clk_register_slow_rc_osc(sckcr, name, frequency, accuracy,
|
hw = at91_clk_register_slow_rc_osc(sckcr, name, frequency, accuracy,
|
||||||
startup);
|
startup);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
|
static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
|
||||||
@ -321,15 +329,16 @@ static const struct clk_ops sam9x5_slow_ops = {
|
|||||||
.get_parent = clk_sam9x5_slow_get_parent,
|
.get_parent = clk_sam9x5_slow_get_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_sam9x5_slow(void __iomem *sckcr,
|
at91_clk_register_sam9x5_slow(void __iomem *sckcr,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char **parent_names,
|
const char **parent_names,
|
||||||
int num_parents)
|
int num_parents)
|
||||||
{
|
{
|
||||||
struct clk_sam9x5_slow *slowck;
|
struct clk_sam9x5_slow *slowck;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!sckcr || !name || !parent_names || !num_parents)
|
if (!sckcr || !name || !parent_names || !num_parents)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -348,17 +357,20 @@ at91_clk_register_sam9x5_slow(void __iomem *sckcr,
|
|||||||
slowck->sckcr = sckcr;
|
slowck->sckcr = sckcr;
|
||||||
slowck->parent = !!(readl(sckcr) & AT91_SCKC_OSCSEL);
|
slowck->parent = !!(readl(sckcr) & AT91_SCKC_OSCSEL);
|
||||||
|
|
||||||
clk = clk_register(NULL, &slowck->hw);
|
hw = &slowck->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &slowck->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(slowck);
|
kfree(slowck);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
|
void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
|
||||||
void __iomem *sckcr)
|
void __iomem *sckcr)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_names[2];
|
const char *parent_names[2];
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -371,12 +383,12 @@ void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
|
|||||||
|
|
||||||
of_property_read_string(np, "clock-output-names", &name);
|
of_property_read_string(np, "clock-output-names", &name);
|
||||||
|
|
||||||
clk = at91_clk_register_sam9x5_slow(sckcr, name, parent_names,
|
hw = at91_clk_register_sam9x5_slow(sckcr, name, parent_names,
|
||||||
num_parents);
|
num_parents);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 clk_sam9260_slow_get_parent(struct clk_hw *hw)
|
static u8 clk_sam9260_slow_get_parent(struct clk_hw *hw)
|
||||||
@ -393,15 +405,16 @@ static const struct clk_ops sam9260_slow_ops = {
|
|||||||
.get_parent = clk_sam9260_slow_get_parent,
|
.get_parent = clk_sam9260_slow_get_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_sam9260_slow(struct regmap *regmap,
|
at91_clk_register_sam9260_slow(struct regmap *regmap,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char **parent_names,
|
const char **parent_names,
|
||||||
int num_parents)
|
int num_parents)
|
||||||
{
|
{
|
||||||
struct clk_sam9260_slow *slowck;
|
struct clk_sam9260_slow *slowck;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -422,16 +435,19 @@ at91_clk_register_sam9260_slow(struct regmap *regmap,
|
|||||||
slowck->hw.init = &init;
|
slowck->hw.init = &init;
|
||||||
slowck->regmap = regmap;
|
slowck->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &slowck->hw);
|
hw = &slowck->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &slowck->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(slowck);
|
kfree(slowck);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9260_clk_slow_setup(struct device_node *np)
|
static void __init of_at91sam9260_clk_slow_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_names[2];
|
const char *parent_names[2];
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -448,12 +464,12 @@ static void __init of_at91sam9260_clk_slow_setup(struct device_node *np)
|
|||||||
|
|
||||||
of_property_read_string(np, "clock-output-names", &name);
|
of_property_read_string(np, "clock-output-names", &name);
|
||||||
|
|
||||||
clk = at91_clk_register_sam9260_slow(regmap, name, parent_names,
|
hw = at91_clk_register_sam9260_slow(regmap, name, parent_names,
|
||||||
num_parents);
|
num_parents);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLK_OF_DECLARE(at91sam9260_clk_slow, "atmel,at91sam9260-clk-slow",
|
CLK_OF_DECLARE(at91sam9260_clk_slow, "atmel,at91sam9260-clk-slow",
|
||||||
|
@ -111,13 +111,14 @@ static const struct clk_ops at91sam9x5_smd_ops = {
|
|||||||
.set_rate = at91sam9x5_clk_smd_set_rate,
|
.set_rate = at91sam9x5_clk_smd_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
|
at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
|
||||||
const char **parent_names, u8 num_parents)
|
const char **parent_names, u8 num_parents)
|
||||||
{
|
{
|
||||||
struct at91sam9x5_clk_smd *smd;
|
struct at91sam9x5_clk_smd *smd;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
smd = kzalloc(sizeof(*smd), GFP_KERNEL);
|
smd = kzalloc(sizeof(*smd), GFP_KERNEL);
|
||||||
if (!smd)
|
if (!smd)
|
||||||
@ -132,16 +133,19 @@ at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
|
|||||||
smd->hw.init = &init;
|
smd->hw.init = &init;
|
||||||
smd->regmap = regmap;
|
smd->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &smd->hw);
|
hw = &smd->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &smd->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(smd);
|
kfree(smd);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
|
static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *parent_names[SMD_SOURCE_MAX];
|
const char *parent_names[SMD_SOURCE_MAX];
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -159,12 +163,12 @@ static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91sam9x5_clk_register_smd(regmap, name, parent_names,
|
hw = at91sam9x5_clk_register_smd(regmap, name, parent_names,
|
||||||
num_parents);
|
num_parents);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_smd, "atmel,at91sam9x5-clk-smd",
|
CLK_OF_DECLARE(at91sam9x5_clk_smd, "atmel,at91sam9x5-clk-smd",
|
||||||
of_at91sam9x5_clk_smd_setup);
|
of_at91sam9x5_clk_smd_setup);
|
||||||
|
@ -88,13 +88,14 @@ static const struct clk_ops system_ops = {
|
|||||||
.is_prepared = clk_system_is_prepared,
|
.is_prepared = clk_system_is_prepared,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_system(struct regmap *regmap, const char *name,
|
at91_clk_register_system(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name, u8 id)
|
const char *parent_name, u8 id)
|
||||||
{
|
{
|
||||||
struct clk_system *sys;
|
struct clk_system *sys;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!parent_name || id > SYSTEM_MAX_ID)
|
if (!parent_name || id > SYSTEM_MAX_ID)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -113,18 +114,21 @@ at91_clk_register_system(struct regmap *regmap, const char *name,
|
|||||||
sys->hw.init = &init;
|
sys->hw.init = &init;
|
||||||
sys->regmap = regmap;
|
sys->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &sys->hw);
|
hw = &sys->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &sys->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(sys);
|
kfree(sys);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
|
static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
u32 id;
|
u32 id;
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct device_node *sysclknp;
|
struct device_node *sysclknp;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
@ -147,11 +151,11 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
|
|||||||
|
|
||||||
parent_name = of_clk_get_parent_name(sysclknp, 0);
|
parent_name = of_clk_get_parent_name(sysclknp, 0);
|
||||||
|
|
||||||
clk = at91_clk_register_system(regmap, name, parent_name, id);
|
hw = at91_clk_register_system(regmap, name, parent_name, id);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
of_clk_add_provider(sysclknp, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(sysclknp, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91rm9200_clk_sys, "atmel,at91rm9200-clk-system",
|
CLK_OF_DECLARE(at91rm9200_clk_sys, "atmel,at91rm9200-clk-system",
|
||||||
|
@ -192,13 +192,14 @@ static const struct clk_ops at91sam9n12_usb_ops = {
|
|||||||
.set_rate = at91sam9x5_clk_usb_set_rate,
|
.set_rate = at91sam9x5_clk_usb_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
|
at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
|
||||||
const char **parent_names, u8 num_parents)
|
const char **parent_names, u8 num_parents)
|
||||||
{
|
{
|
||||||
struct at91sam9x5_clk_usb *usb;
|
struct at91sam9x5_clk_usb *usb;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
||||||
if (!usb)
|
if (!usb)
|
||||||
@ -214,20 +215,24 @@ at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
|
|||||||
usb->hw.init = &init;
|
usb->hw.init = &init;
|
||||||
usb->regmap = regmap;
|
usb->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &usb->hw);
|
hw = &usb->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &usb->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(usb);
|
kfree(usb);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
|
at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name)
|
const char *parent_name)
|
||||||
{
|
{
|
||||||
struct at91sam9x5_clk_usb *usb;
|
struct at91sam9x5_clk_usb *usb;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
||||||
if (!usb)
|
if (!usb)
|
||||||
@ -242,11 +247,14 @@ at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
|
|||||||
usb->hw.init = &init;
|
usb->hw.init = &init;
|
||||||
usb->regmap = regmap;
|
usb->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &usb->hw);
|
hw = &usb->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &usb->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(usb);
|
kfree(usb);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long at91rm9200_clk_usb_recalc_rate(struct clk_hw *hw,
|
static unsigned long at91rm9200_clk_usb_recalc_rate(struct clk_hw *hw,
|
||||||
@ -334,13 +342,14 @@ static const struct clk_ops at91rm9200_usb_ops = {
|
|||||||
.set_rate = at91rm9200_clk_usb_set_rate,
|
.set_rate = at91rm9200_clk_usb_set_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
|
at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
|
||||||
const char *parent_name, const u32 *divisors)
|
const char *parent_name, const u32 *divisors)
|
||||||
{
|
{
|
||||||
struct at91rm9200_clk_usb *usb;
|
struct at91rm9200_clk_usb *usb;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
usb = kzalloc(sizeof(*usb), GFP_KERNEL);
|
||||||
if (!usb)
|
if (!usb)
|
||||||
@ -356,16 +365,19 @@ at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
|
|||||||
usb->regmap = regmap;
|
usb->regmap = regmap;
|
||||||
memcpy(usb->divisors, divisors, sizeof(usb->divisors));
|
memcpy(usb->divisors, divisors, sizeof(usb->divisors));
|
||||||
|
|
||||||
clk = clk_register(NULL, &usb->hw);
|
hw = &usb->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &usb->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(usb);
|
kfree(usb);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np)
|
static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
unsigned int num_parents;
|
unsigned int num_parents;
|
||||||
const char *parent_names[USB_SOURCE_MAX];
|
const char *parent_names[USB_SOURCE_MAX];
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
@ -383,19 +395,19 @@ static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91sam9x5_clk_register_usb(regmap, name, parent_names,
|
hw = at91sam9x5_clk_register_usb(regmap, name, parent_names,
|
||||||
num_parents);
|
num_parents);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_usb, "atmel,at91sam9x5-clk-usb",
|
CLK_OF_DECLARE(at91sam9x5_clk_usb, "atmel,at91sam9x5-clk-usb",
|
||||||
of_at91sam9x5_clk_usb_setup);
|
of_at91sam9x5_clk_usb_setup);
|
||||||
|
|
||||||
static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np)
|
static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
@ -410,18 +422,18 @@ static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91sam9n12_clk_register_usb(regmap, name, parent_name);
|
hw = at91sam9n12_clk_register_usb(regmap, name, parent_name);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9n12_clk_usb, "atmel,at91sam9n12-clk-usb",
|
CLK_OF_DECLARE(at91sam9n12_clk_usb, "atmel,at91sam9n12-clk-usb",
|
||||||
of_at91sam9n12_clk_usb_setup);
|
of_at91sam9n12_clk_usb_setup);
|
||||||
|
|
||||||
static void __init of_at91rm9200_clk_usb_setup(struct device_node *np)
|
static void __init of_at91rm9200_clk_usb_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
u32 divisors[4] = {0, 0, 0, 0};
|
u32 divisors[4] = {0, 0, 0, 0};
|
||||||
@ -440,12 +452,11 @@ static void __init of_at91rm9200_clk_usb_setup(struct device_node *np)
|
|||||||
regmap = syscon_node_to_regmap(of_get_parent(np));
|
regmap = syscon_node_to_regmap(of_get_parent(np));
|
||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
hw = at91rm9200_clk_register_usb(regmap, name, parent_name, divisors);
|
||||||
clk = at91rm9200_clk_register_usb(regmap, name, parent_name, divisors);
|
if (IS_ERR(hw))
|
||||||
if (IS_ERR(clk))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91rm9200_clk_usb, "atmel,at91rm9200-clk-usb",
|
CLK_OF_DECLARE(at91rm9200_clk_usb, "atmel,at91rm9200-clk-usb",
|
||||||
of_at91rm9200_clk_usb_setup);
|
of_at91rm9200_clk_usb_setup);
|
||||||
|
@ -77,13 +77,14 @@ static const struct clk_ops utmi_ops = {
|
|||||||
.recalc_rate = clk_utmi_recalc_rate,
|
.recalc_rate = clk_utmi_recalc_rate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct clk * __init
|
static struct clk_hw * __init
|
||||||
at91_clk_register_utmi(struct regmap *regmap,
|
at91_clk_register_utmi(struct regmap *regmap,
|
||||||
const char *name, const char *parent_name)
|
const char *name, const char *parent_name)
|
||||||
{
|
{
|
||||||
struct clk_utmi *utmi;
|
struct clk_utmi *utmi;
|
||||||
struct clk *clk = NULL;
|
struct clk_hw *hw;
|
||||||
struct clk_init_data init;
|
struct clk_init_data init;
|
||||||
|
int ret;
|
||||||
|
|
||||||
utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
|
utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
|
||||||
if (!utmi)
|
if (!utmi)
|
||||||
@ -98,16 +99,19 @@ at91_clk_register_utmi(struct regmap *regmap,
|
|||||||
utmi->hw.init = &init;
|
utmi->hw.init = &init;
|
||||||
utmi->regmap = regmap;
|
utmi->regmap = regmap;
|
||||||
|
|
||||||
clk = clk_register(NULL, &utmi->hw);
|
hw = &utmi->hw;
|
||||||
if (IS_ERR(clk))
|
ret = clk_hw_register(NULL, &utmi->hw);
|
||||||
|
if (ret) {
|
||||||
kfree(utmi);
|
kfree(utmi);
|
||||||
|
hw = ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
return clk;
|
return hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
|
static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct clk *clk;
|
struct clk_hw *hw;
|
||||||
const char *parent_name;
|
const char *parent_name;
|
||||||
const char *name = np->name;
|
const char *name = np->name;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
@ -120,11 +124,11 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clk = at91_clk_register_utmi(regmap, name, parent_name);
|
hw = at91_clk_register_utmi(regmap, name, parent_name);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(hw))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
of_clk_add_provider(np, of_clk_src_simple_get, clk);
|
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CLK_OF_DECLARE(at91sam9x5_clk_utmi, "atmel,at91sam9x5-clk-utmi",
|
CLK_OF_DECLARE(at91sam9x5_clk_utmi, "atmel,at91sam9x5-clk-utmi",
|
||||||
|
Loading…
Reference in New Issue
Block a user