Commit 9919d44f authored by Stephen Boyd's avatar Stephen Boyd
Browse files

clk: sunxi: Use CLK_IS_CRITICAL flag for critical clks



We'd like to privatize __clk_get(), but the sunxi clk driver is
calling this function to keep a reference held on the clk and
call clk_prepare_enable() on it. We support this design in the
clk core now with the CLK_IS_CRITICAL flag, so let's just use
that instead.

Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent e0af0c16
Loading
Loading
Loading
Loading
+21 −5
Original line number Original line Diff line number Diff line
@@ -176,10 +176,10 @@ static const struct clk_ops clk_factors_ops = {
	.set_rate = clk_factors_set_rate,
	.set_rate = clk_factors_set_rate,
};
};


struct clk *sunxi_factors_register(struct device_node *node,
static struct clk *__sunxi_factors_register(struct device_node *node,
					    const struct factors_data *data,
					    const struct factors_data *data,
				   spinlock_t *lock,
					    spinlock_t *lock, void __iomem *reg,
				   void __iomem *reg)
					    unsigned long flags)
{
{
	struct clk *clk;
	struct clk *clk;
	struct clk_factors *factors;
	struct clk_factors *factors;
@@ -249,7 +249,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
			parents, i,
			parents, i,
			mux_hw, &clk_mux_ops,
			mux_hw, &clk_mux_ops,
			&factors->hw, &clk_factors_ops,
			&factors->hw, &clk_factors_ops,
			gate_hw, &clk_gate_ops, 0);
			gate_hw, &clk_gate_ops, CLK_IS_CRITICAL);
	if (IS_ERR(clk))
	if (IS_ERR(clk))
		goto err_register;
		goto err_register;


@@ -272,6 +272,22 @@ struct clk *sunxi_factors_register(struct device_node *node,
	return NULL;
	return NULL;
}
}


struct clk *sunxi_factors_register(struct device_node *node,
				   const struct factors_data *data,
				   spinlock_t *lock,
				   void __iomem *reg)
{
	return __sunxi_factors_register(node, data, lock, reg, 0);
}

struct clk *sunxi_factors_register_critical(struct device_node *node,
					    const struct factors_data *data,
					    spinlock_t *lock,
					    void __iomem *reg)
{
	return __sunxi_factors_register(node, data, lock, reg, CLK_IS_CRITICAL);
}

void sunxi_factors_unregister(struct device_node *node, struct clk *clk)
void sunxi_factors_unregister(struct device_node *node, struct clk *clk)
{
{
	struct clk_hw *hw = __clk_get_hw(clk);
	struct clk_hw *hw = __clk_get_hw(clk);
+4 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,10 @@ struct clk *sunxi_factors_register(struct device_node *node,
				   const struct factors_data *data,
				   const struct factors_data *data,
				   spinlock_t *lock,
				   spinlock_t *lock,
				   void __iomem *reg);
				   void __iomem *reg);
struct clk *sunxi_factors_register_critical(struct device_node *node,
					    const struct factors_data *data,
					    spinlock_t *lock,
					    void __iomem *reg);


void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
void sunxi_factors_unregister(struct device_node *node, struct clk *clk);


+2 −7
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
 */
 */


#include <linux/clk.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
@@ -155,7 +154,6 @@ static DEFINE_SPINLOCK(sun5i_a13_mbus_lock);


static void __init sun5i_a13_mbus_setup(struct device_node *node)
static void __init sun5i_a13_mbus_setup(struct device_node *node)
{
{
	struct clk *mbus;
	void __iomem *reg;
	void __iomem *reg;


	reg = of_iomap(node, 0);
	reg = of_iomap(node, 0);
@@ -164,12 +162,9 @@ static void __init sun5i_a13_mbus_setup(struct device_node *node)
		return;
		return;
	}
	}


	mbus = sunxi_factors_register(node, &sun4i_a10_mod0_data,
				      &sun5i_a13_mbus_lock, reg);

	/* The MBUS clocks needs to be always enabled */
	/* The MBUS clocks needs to be always enabled */
	__clk_get(mbus);
	sunxi_factors_register_critical(node, &sun4i_a10_mod0_data,
	clk_prepare_enable(mbus);
					&sun5i_a13_mbus_lock, reg);
}
}
CLK_OF_DECLARE(sun5i_a13_mbus, "allwinner,sun5i-a13-mbus-clk", sun5i_a13_mbus_setup);
CLK_OF_DECLARE(sun5i_a13_mbus, "allwinner,sun5i-a13-mbus-clk", sun5i_a13_mbus_setup);


+2 −5
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
 */
 */


#include <linux/clk.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/clk-provider.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
@@ -82,11 +81,12 @@ static void __init sun8i_a23_mbus_setup(struct device_node *node)
	mux->mask = SUN8I_MBUS_MUX_MASK;
	mux->mask = SUN8I_MBUS_MUX_MASK;
	mux->lock = &sun8i_a23_mbus_lock;
	mux->lock = &sun8i_a23_mbus_lock;


	/* The MBUS clocks needs to be always enabled */
	clk = clk_register_composite(NULL, clk_name, parents, num_parents,
	clk = clk_register_composite(NULL, clk_name, parents, num_parents,
				     &mux->hw, &clk_mux_ops,
				     &mux->hw, &clk_mux_ops,
				     &div->hw, &clk_divider_ops,
				     &div->hw, &clk_divider_ops,
				     &gate->hw, &clk_gate_ops,
				     &gate->hw, &clk_gate_ops,
				     0);
				     CLK_IS_CRITICAL);
	if (IS_ERR(clk))
	if (IS_ERR(clk))
		goto err_free_gate;
		goto err_free_gate;


@@ -95,9 +95,6 @@ static void __init sun8i_a23_mbus_setup(struct device_node *node)
		goto err_unregister_clk;
		goto err_unregister_clk;


	kfree(parents); /* parents is deep copied */
	kfree(parents); /* parents is deep copied */
	/* The MBUS clocks needs to be always enabled */
	__clk_get(clk);
	clk_prepare_enable(clk);


	return;
	return;


+2 −7
Original line number Original line Diff line number Diff line
@@ -15,7 +15,6 @@
 */
 */


#include <linux/clk.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_address.h>
@@ -140,7 +139,6 @@ static DEFINE_SPINLOCK(sun9i_a80_gt_lock);
static void __init sun9i_a80_gt_setup(struct device_node *node)
static void __init sun9i_a80_gt_setup(struct device_node *node)
{
{
	void __iomem *reg;
	void __iomem *reg;
	struct clk *gt;


	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
	if (IS_ERR(reg)) {
	if (IS_ERR(reg)) {
@@ -149,12 +147,9 @@ static void __init sun9i_a80_gt_setup(struct device_node *node)
		return;
		return;
	}
	}


	gt = sunxi_factors_register(node, &sun9i_a80_gt_data,
				    &sun9i_a80_gt_lock, reg);

	/* The GT bus clock needs to be always enabled */
	/* The GT bus clock needs to be always enabled */
	__clk_get(gt);
	sunxi_factors_register_critical(node, &sun9i_a80_gt_data,
	clk_prepare_enable(gt);
					&sun9i_a80_gt_lock, reg);
}
}
CLK_OF_DECLARE(sun9i_a80_gt, "allwinner,sun9i-a80-gt-clk", sun9i_a80_gt_setup);
CLK_OF_DECLARE(sun9i_a80_gt, "allwinner,sun9i-a80-gt-clk", sun9i_a80_gt_setup);


Loading