@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/clk/at91_pmc.h>
#include <linux/of.h>
@@ -29,11 +30,11 @@ static DEFINE_SPINLOCK(mck_lock);
#ifdef CONFIG_HAVE_AT91_AUDIO_PLL
static void __init of_sama5d2_clk_audio_pll_frac_setup(struct device_node *np)
{
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
- const char *parent_name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
@@ -41,9 +42,15 @@ static void __init of_sama5d2_clk_audio_pll_frac_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
- hw = at91_clk_register_audio_pll_frac(regmap, name, parent_name, NULL);
+ hw = at91_clk_register_audio_pll_frac(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -55,11 +62,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_audio_pll_frac_setup,
static void __init of_sama5d2_clk_audio_pll_pad_setup(struct device_node *np)
{
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
- const char *parent_name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
@@ -67,9 +74,15 @@ static void __init of_sama5d2_clk_audio_pll_pad_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
- hw = at91_clk_register_audio_pll_pad(regmap, name, parent_name, NULL);
+ hw = at91_clk_register_audio_pll_pad(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -81,11 +94,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_audio_pll_pad_setup,
static void __init of_sama5d2_clk_audio_pll_pmc_setup(struct device_node *np)
{
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
- const char *parent_name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
@@ -93,9 +106,15 @@ static void __init of_sama5d2_clk_audio_pll_pmc_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
- hw = at91_clk_register_audio_pll_pmc(regmap, name, parent_name, NULL);
+ hw = at91_clk_register_audio_pll_pmc(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -126,18 +145,26 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
int num;
u32 id;
const char *name;
- struct clk_hw *hw;
- unsigned int num_parents;
- const char *parent_names[GENERATED_SOURCE_MAX];
+ struct clk_hw *hw, *parent_hws[GENERATED_SOURCE_MAX];
+ unsigned int num_parents, i;
struct device_node *gcknp, *parent_np;
struct clk_range range = CLK_RANGE(0, 0);
struct regmap *regmap;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > GENERATED_SOURCE_MAX)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
num = of_get_child_count(np);
if (!num || num > PERIPHERAL_MAX)
@@ -171,7 +198,7 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
&dt_pcr_layout, name,
- parent_names, NULL, NULL,
+ NULL, parent_hws, NULL,
num_parents, id, &range,
chg_pid);
if (IS_ERR(hw))
@@ -187,11 +214,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_generated_setup, "atmel,sama5d2-clk-generated",
#ifdef CONFIG_HAVE_AT91_H32MX
static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np)
{
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
- const char *parent_name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
@@ -199,9 +226,15 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
- hw = at91_clk_register_h32mx(regmap, name, parent_name, NULL);
+ hw = at91_clk_register_h32mx(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -217,11 +250,10 @@ CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx",
static void __init of_sama5d2_clk_i2s_mux_setup(struct device_node *np)
{
struct regmap *regmap_sfr;
- u8 bus_id;
- const char *parent_names[2];
+ u8 bus_id, i;
struct device_node *i2s_mux_np;
- struct clk_hw *hw;
- int ret;
+ struct clk_hw *hw, *parent_hws[2] = {};
+ struct clk *clk;
regmap_sfr = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr");
if (IS_ERR(regmap_sfr))
@@ -234,16 +266,26 @@ static void __init of_sama5d2_clk_i2s_mux_setup(struct device_node *np)
if (bus_id > I2S_BUS_NR)
continue;
- ret = of_clk_parent_fill(i2s_mux_np, parent_names, 2);
- if (ret != 2)
+ for (i = 0; i < 2; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ break;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ break;
+ }
+ if (!parent_hws[1])
continue;
hw = at91_clk_i2s_mux_register(regmap_sfr, i2s_mux_np->name,
- parent_names, NULL, 2, bus_id);
+ NULL, parent_hws, 2, bus_id);
if (IS_ERR(hw))
continue;
of_clk_add_hw_provider(i2s_mux_np, of_clk_hw_simple_get, hw);
+
+ parent_hws[1] = NULL;
}
}
CLK_OF_DECLARE(sama5d2_clk_i2s_mux, "atmel,sama5d2-clk-i2s-mux",
@@ -258,6 +300,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
struct regmap *regmap;
bool bypass;
struct device_node *parent_np;
+ static struct clk_parent_data parent_data;
of_property_read_string(np, "clock-output-names", &name);
bypass = of_property_read_bool(np, "atmel,osc-bypass");
@@ -269,7 +312,9 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91_clk_register_main_osc(regmap, name, parent_name, NULL, bypass);
+ parent_data.name = parent_name;
+ parent_data.fw_name = parent_name;
+ hw = at91_clk_register_main_osc(regmap, name, NULL, &parent_data, bypass);
if (IS_ERR(hw))
return;
@@ -308,13 +353,12 @@ CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc",
static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
of_property_read_string(np, "clock-output-names", &name);
parent_np = of_get_parent(np);
@@ -323,7 +367,15 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91_clk_register_rm9200_main(regmap, name, parent_name, NULL);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
+
+ hw = at91_clk_register_rm9200_main(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -334,18 +386,26 @@ CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main",
static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_names[2];
- unsigned int num_parents;
+ struct clk_hw *hw, *parent_hws[2];
+ unsigned int num_parents, i;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > 2)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
of_node_put(parent_np);
@@ -354,7 +414,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
of_property_read_string(np, "clock-output-names", &name);
- hw = at91_clk_register_sam9x5_main(regmap, name, parent_names, NULL,
+ hw = at91_clk_register_sam9x5_main(regmap, name, NULL, parent_hws,
num_parents);
if (IS_ERR(hw))
return;
@@ -393,19 +453,27 @@ static void __init
of_at91_clk_master_setup(struct device_node *np,
const struct clk_master_layout *layout)
{
- struct clk_hw *hw;
- unsigned int num_parents;
- const char *parent_names[MASTER_SOURCE_MAX];
+ struct clk_hw *hw, *parent_hws[MASTER_SOURCE_MAX];
+ unsigned int num_parents, i;
const char *name = np->name;
struct clk_master_characteristics *characteristics;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > MASTER_SOURCE_MAX)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < MASTER_SOURCE_MAX; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
of_property_read_string(np, "clock-output-names", &name);
@@ -420,12 +488,12 @@ of_at91_clk_master_setup(struct device_node *np,
return;
hw = at91_clk_register_master_pres(regmap, "masterck_pres", num_parents,
- parent_names, NULL, layout,
+ NULL, parent_hws, layout,
characteristics, &mck_lock);
if (IS_ERR(hw))
goto out_free_characteristics;
- hw = at91_clk_register_master_div(regmap, name, "masterck_pres", NULL,
+ hw = at91_clk_register_master_div(regmap, name, NULL, hw,
layout, characteristics,
&mck_lock, CLK_SET_RATE_GATE, 0);
if (IS_ERR(hw))
@@ -457,15 +525,19 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
{
int num;
u32 id;
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name;
struct device_node *periphclknp;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
- if (!parent_name)
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
return;
num = of_get_child_count(np);
@@ -490,7 +562,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
if (type == PERIPHERAL_AT91RM9200) {
hw = at91_clk_register_peripheral(regmap, name,
- parent_name, NULL, id);
+ NULL, parent_hw, id);
} else {
struct clk_range range = CLK_RANGE(0, 0);
unsigned long flags = 0;
@@ -511,8 +583,8 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
&pmc_pcr_lock,
&dt_pcr_layout,
name,
- parent_name,
NULL,
+ parent_hw,
id, &range,
INT_MIN,
flags);
@@ -640,17 +712,23 @@ of_at91_clk_pll_setup(struct device_node *np,
const struct clk_pll_layout *layout)
{
u32 id;
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
struct regmap *regmap;
- const char *parent_name;
const char *name = np->name;
struct device_node *parent_np;
struct clk_pll_characteristics *characteristics;
+ struct clk *clk;
if (of_property_read_u32(np, "reg", &id))
return;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
of_property_read_string(np, "clock-output-names", &name);
@@ -664,7 +742,7 @@ of_at91_clk_pll_setup(struct device_node *np,
if (!characteristics)
return;
- hw = at91_clk_register_pll(regmap, name, parent_name, NULL, id, layout,
+ hw = at91_clk_register_pll(regmap, name, NULL, parent_hw, id, layout,
characteristics);
if (IS_ERR(hw))
goto out_free_characteristics;
@@ -707,13 +785,19 @@ CLK_OF_DECLARE(sama5d3_clk_pll, "atmel,sama5d3-clk-pll",
static void __init
of_at91sam9x5_clk_plldiv_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
of_property_read_string(np, "clock-output-names", &name);
@@ -723,7 +807,7 @@ of_at91sam9x5_clk_plldiv_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91_clk_register_plldiv(regmap, name, parent_name, NULL);
+ hw = at91_clk_register_plldiv(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -739,18 +823,26 @@ of_at91_clk_prog_setup(struct device_node *np,
{
int num;
u32 id;
- struct clk_hw *hw;
- unsigned int num_parents;
- const char *parent_names[PROG_SOURCE_MAX];
+ struct clk_hw *hw, *parent_hws[PROG_SOURCE_MAX];
+ unsigned int num_parents, i;
const char *name;
struct device_node *progclknp, *parent_np;
struct regmap *regmap;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > PROG_SOURCE_MAX)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
num = of_get_child_count(np);
if (!num || num > (PROG_ID_MAX + 1))
@@ -770,7 +862,7 @@ of_at91_clk_prog_setup(struct device_node *np,
name = progclknp->name;
hw = at91_clk_register_programmable(regmap, name,
- parent_names, NULL, num_parents,
+ NULL, parent_hws, num_parents,
id, layout, mux_table);
if (IS_ERR(hw))
continue;
@@ -802,18 +894,26 @@ CLK_OF_DECLARE(at91sam9x5_clk_prog, "atmel,at91sam9x5-clk-programmable",
static void __init of_at91sam9260_clk_slow_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_names[2];
- unsigned int num_parents;
+ struct clk_hw *hw, *parent_hws[2];
+ unsigned int num_parents, i;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents != 2)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
parent_np = of_get_parent(np);
regmap = syscon_node_to_regmap(parent_np);
of_node_put(parent_np);
@@ -822,7 +922,7 @@ static void __init of_at91sam9260_clk_slow_setup(struct device_node *np)
of_property_read_string(np, "clock-output-names", &name);
- hw = at91_clk_register_sam9260_slow(regmap, name, parent_names, NULL,
+ hw = at91_clk_register_sam9260_slow(regmap, name, NULL, parent_hws,
num_parents);
if (IS_ERR(hw))
return;
@@ -837,18 +937,26 @@ CLK_OF_DECLARE(at91sam9260_clk_slow, "atmel,at91sam9260-clk-slow",
static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
{
- struct clk_hw *hw;
- unsigned int num_parents;
- const char *parent_names[SMD_SOURCE_MAX];
+ struct clk_hw *hw, *parent_hws[SMD_SOURCE_MAX];
+ unsigned int num_parents, i;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > SMD_SOURCE_MAX)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
of_property_read_string(np, "clock-output-names", &name);
@@ -858,7 +966,7 @@ static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91sam9x5_clk_register_smd(regmap, name, parent_names, NULL,
+ hw = at91sam9x5_clk_register_smd(regmap, name, NULL, parent_hws,
num_parents);
if (IS_ERR(hw))
return;
@@ -873,11 +981,11 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
{
int num;
u32 id;
- struct clk_hw *hw;
+ struct clk_hw *hw, *parent_hw;
const char *name;
struct device_node *sysclknp, *parent_np;
- const char *parent_name;
struct regmap *regmap;
+ struct clk *clk;
num = of_get_child_count(np);
if (num > (SYSTEM_MAX_ID + 1))
@@ -898,7 +1006,13 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
if (of_property_read_string(np, "clock-output-names", &name))
name = sysclknp->name;
- parent_name = of_clk_get_parent_name(sysclknp, 0);
+ clk = of_clk_get(sysclknp, 0);
+ if (IS_ERR(clk))
+ continue;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ continue;
/*
* ddrck feeds DDR controller and is enabled by bootloader thus
@@ -908,7 +1022,7 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
if (!strcmp(sysclknp->name, "ddrck"))
flags = CLK_IS_CRITICAL;
- hw = at91_clk_register_system(regmap, name, parent_name, NULL,
+ hw = at91_clk_register_system(regmap, name, NULL, parent_hw,
id, flags);
if (IS_ERR(hw))
continue;
@@ -924,18 +1038,26 @@ CLK_OF_DECLARE(at91rm9200_clk_sys, "atmel,at91rm9200-clk-system",
static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np)
{
- struct clk_hw *hw;
- unsigned int num_parents;
- const char *parent_names[USB_SOURCE_MAX];
+ struct clk_hw *hw, *parent_hws[USB_SOURCE_MAX];
+ unsigned int num_parents, i;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > USB_SOURCE_MAX)
return;
- of_clk_parent_fill(np, parent_names, num_parents);
+ for (i = 0; i < num_parents; i++) {
+ clk = of_clk_get(np, i);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hws[i] = __clk_get_hw(clk);
+ if (!parent_hws[i])
+ return;
+ }
of_property_read_string(np, "clock-output-names", &name);
@@ -945,7 +1067,7 @@ static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91sam9x5_clk_register_usb(regmap, name, parent_names, NULL,
+ hw = at91sam9x5_clk_register_usb(regmap, name, NULL, parent_hws,
num_parents);
if (IS_ERR(hw))
return;
@@ -957,14 +1079,18 @@ CLK_OF_DECLARE(at91sam9x5_clk_usb, "atmel,at91sam9x5-clk-usb",
static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
- if (!parent_name)
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
return;
of_property_read_string(np, "clock-output-names", &name);
@@ -975,7 +1101,7 @@ static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np)
if (IS_ERR(regmap))
return;
- hw = at91sam9n12_clk_register_usb(regmap, name, parent_name, NULL);
+ hw = at91sam9n12_clk_register_usb(regmap, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
@@ -986,15 +1112,19 @@ CLK_OF_DECLARE(at91sam9n12_clk_usb, "atmel,at91sam9n12-clk-usb",
static void __init of_at91rm9200_clk_usb_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
u32 divisors[4] = {0, 0, 0, 0};
struct regmap *regmap;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
- if (!parent_name)
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
return;
of_property_read_u32_array(np, "atmel,clk-divisors", divisors, 4);
@@ -1008,7 +1138,7 @@ static void __init of_at91rm9200_clk_usb_setup(struct device_node *np)
of_node_put(parent_np);
if (IS_ERR(regmap))
return;
- hw = at91rm9200_clk_register_usb(regmap, name, parent_name, NULL, divisors);
+ hw = at91rm9200_clk_register_usb(regmap, name, NULL, parent_hw, divisors);
if (IS_ERR(hw))
return;
@@ -1021,13 +1151,19 @@ CLK_OF_DECLARE(at91rm9200_clk_usb, "atmel,at91rm9200-clk-usb",
#ifdef CONFIG_HAVE_AT91_UTMI
static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
{
- struct clk_hw *hw;
- const char *parent_name;
+ struct clk_hw *hw, *parent_hw;
const char *name = np->name;
struct regmap *regmap_pmc, *regmap_sfr;
struct device_node *parent_np;
+ struct clk *clk;
- parent_name = of_clk_get_parent_name(np, 0);
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ return;
+
+ parent_hw = __clk_get_hw(clk);
+ if (!parent_hw)
+ return;
of_property_read_string(np, "clock-output-names", &name);
@@ -1055,7 +1191,7 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
regmap_sfr = NULL;
}
- hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL);
+ hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, NULL, parent_hw);
if (IS_ERR(hw))
return;
Switch old dt-compat clocks to use parent_hw and parent_data. Having parent_hw instead of parent names improves to clock registration speed and re-parenting. Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> --- drivers/clk/at91/dt-compat.c | 328 +++++++++++++++++++++++++---------- 1 file changed, 232 insertions(+), 96 deletions(-)