Commit 3400d546 authored by Dario Binacchi's avatar Dario Binacchi Committed by Stephen Boyd
Browse files

clk: ti: change ti_clk_register[_omap_hw]() API



The ti_clk_register() and ti_clk_register_omap_hw() functions are always
called with the parameter of type "struct device" set to NULL, since the
functions from which they are called always have a parameter of type
"struct device_node". Replacing "struct device" type parameter with
"struct device_node" will allow you to register a TI clock to the common
clock framework by taking advantage of the facilities provided by the
"struct device_node" type. Further, adding the "of_" prefix to the name
of these functions explicitly binds them to the "struct device_node"
type.

The patch has been tested on a Beaglebone board.

Signed-off-by: default avatarDario Binacchi <dario.binacchi@amarulasolutions.com>
Tested-by: default avatarTony Lindgren <tony@atomide.com>
Reviewed-by: default avatarTony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221113181147.1626585-1-dario.binacchi@amarulasolutions.com


Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 9abf2313
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ static void __init omap_clk_register_apll(void *user,
	ad->clk_bypass = __clk_get_hw(clk);

	name = ti_dt_clk_name(node);
	clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
	clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
	if (!IS_ERR(clk)) {
		of_clk_add_provider(node, of_clk_src_simple_get, clk);
		kfree(init->parent_names);
@@ -400,7 +400,7 @@ static void __init of_omap2_apll_setup(struct device_node *node)
		goto cleanup;

	name = ti_dt_clk_name(node);
	clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
	clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
	if (!IS_ERR(clk)) {
		of_clk_add_provider(node, of_clk_src_simple_get, clk);
		kfree(init);
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node)

	init.parent_names = parent_names;

	clk = ti_clk_register(NULL, &clk_hw->hw, name);
	clk = of_ti_clk_register(node, &clk_hw->hw, name);

	if (!IS_ERR(clk)) {
		of_clk_add_provider(node, of_clk_src_simple_get, clk);
+16 −18
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ void __init ti_clk_add_aliases(void)
		clkspec.np = np;
		clk = of_clk_get_from_provider(&clkspec);

		ti_clk_add_alias(NULL, clk, ti_dt_clk_name(np));
		ti_clk_add_alias(clk, ti_dt_clk_name(np));
	}
}

@@ -528,7 +528,6 @@ void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks)

/**
 * ti_clk_add_alias - add a clock alias for a TI clock
 * @dev: device alias for this clock
 * @clk: clock handle to create alias for
 * @con: connection ID for this clock
 *
@@ -536,7 +535,7 @@ void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks)
 * and assigns the data to it. Returns 0 if successful, negative error
 * value otherwise.
 */
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
int ti_clk_add_alias(struct clk *clk, const char *con)
{
	struct clk_lookup *cl;

@@ -550,8 +549,6 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
	if (!cl)
		return -ENOMEM;

	if (dev)
		cl->dev_id = dev_name(dev);
	cl->con_id = con;
	cl->clk = clk;

@@ -561,8 +558,8 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
}

/**
 * ti_clk_register - register a TI clock to the common clock framework
 * @dev: device for this clock
 * of_ti_clk_register - register a TI clock to the common clock framework
 * @node: device node for this clock
 * @hw: hardware clock handle
 * @con: connection ID for this clock
 *
@@ -570,17 +567,18 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con)
 * alias for it. Returns a handle to the registered clock if successful,
 * ERR_PTR value in failure.
 */
struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw,
			       const char *con)
{
	struct clk *clk;
	int ret;

	clk = clk_register(dev, hw);
	if (IS_ERR(clk))
		return clk;
	ret = of_clk_hw_register(node, hw);
	if (ret)
		return ERR_PTR(ret);

	ret = ti_clk_add_alias(dev, clk, con);
	clk = hw->clk;
	ret = ti_clk_add_alias(clk, con);
	if (ret) {
		clk_unregister(clk);
		return ERR_PTR(ret);
@@ -590,8 +588,8 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
}

/**
 * ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
 * @dev: device for this clock
 * of_ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework
 * @node: device node for this clock
 * @hw: hardware clock handle
 * @con: connection ID for this clock
 *
@@ -600,13 +598,13 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
 * Returns a handle to the registered clock if successful, ERR_PTR value
 * in failure.
 */
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
				    const char *con)
struct clk *of_ti_clk_register_omap_hw(struct device_node *node,
				       struct clk_hw *hw, const char *con)
{
	struct clk *clk;
	struct clk_hw_omap *oclk;

	clk = ti_clk_register(dev, hw, con);
	clk = of_ti_clk_register(node, hw, con);
	if (IS_ERR(clk))
		return clk;

+2 −2
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ _ti_clkctrl_clk_register(struct omap_clkctrl_provider *provider,
	init.ops = ops;
	init.flags = 0;

	clk = ti_clk_register(NULL, clk_hw, init.name);
	clk = of_ti_clk_register(node, clk_hw, init.name);
	if (IS_ERR_OR_NULL(clk)) {
		ret = -EINVAL;
		goto cleanup;
@@ -682,7 +682,7 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
		init.ops = &omap4_clkctrl_clk_ops;
		hw->hw.init = &init;

		clk = ti_clk_register_omap_hw(NULL, &hw->hw, init.name);
		clk = of_ti_clk_register_omap_hw(node, &hw->hw, init.name);
		if (IS_ERR_OR_NULL(clk))
			goto cleanup;

+5 −5
Original line number Diff line number Diff line
@@ -199,12 +199,12 @@ extern const struct omap_clkctrl_data dm816_clkctrl_data[];

typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *);

struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
			    const char *con);
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw,
			       const char *con);
struct clk *of_ti_clk_register_omap_hw(struct device_node *node,
				       struct clk_hw *hw, const char *con);
const char *ti_dt_clk_name(struct device_node *np);
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
int ti_clk_add_alias(struct clk *clk, const char *con);
void ti_clk_add_aliases(void);

void ti_clk_latch(struct clk_omap_reg *reg, s8 shift);
Loading