Unverified Commit ecffd058 authored by Nicolas Frattaroli's avatar Nicolas Frattaroli Committed by Stephen Boyd
Browse files

clk: mediatek: Pass device to clk_hw_register for PLLs



Passing the struct device pointer to clk_hw_register allows for runtime
power management to work for the registered clock controllers. However,
the mediatek PLL clocks do not do this.

Change this by adding a struct device pointer argument to
mtk_clk_register_pll, and fix up the only other user of it. Also add a
new member to the struct mtk_clk_pll for the struct device pointer,
which is set by mtk_clk_register_pll and is used by
mtk_clk_register_pll_ops.

If mtk_clk_register_pll is called with a NULL struct device pointer,
then everything still works as expected; the clock core will simply
treat them as previously, i.e. without runtime power management.

Reviewed-by: default avatarChen-Yu Tsai <wenst@chromium.org>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarNicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent c9ced38a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
		init.parent_names = &parent_name;
	init.num_parents = 1;

	ret = clk_hw_register(NULL, &pll->hw);
	ret = clk_hw_register(pll->dev, &pll->hw);

	if (ret)
		return ERR_PTR(ret);
@@ -374,7 +374,8 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
	return &pll->hw;
}

struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
struct clk_hw *mtk_clk_register_pll(struct device *dev,
				    const struct mtk_pll_data *data,
				    void __iomem *base)
{
	struct mtk_clk_pll *pll;
@@ -385,6 +386,8 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
	if (!pll)
		return ERR_PTR(-ENOMEM);

	pll->dev = dev;

	hw = mtk_clk_register_pll_ops(pll, data, base, pll_ops);
	if (IS_ERR(hw))
		kfree(pll);
@@ -428,7 +431,7 @@ int mtk_clk_register_plls(struct device *dev,
			continue;
		}

		hw = mtk_clk_register_pll(pll, base);
		hw = mtk_clk_register_pll(dev, pll, base);

		if (IS_ERR(hw)) {
			pr_err("Failed to register clk %s: %pe\n", pll->name,
+3 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct mtk_pll_data {
 */

struct mtk_clk_pll {
	struct device *dev;
	struct clk_hw	hw;
	void __iomem	*base_addr;
	void __iomem	*pd_addr;
@@ -108,7 +109,8 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
					const struct mtk_pll_data *data,
					void __iomem *base,
					const struct clk_ops *pll_ops);
struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
struct clk_hw *mtk_clk_register_pll(struct device *dev,
				    const struct mtk_pll_data *data,
				    void __iomem *base);
void mtk_clk_unregister_pll(struct clk_hw *hw);

+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ int mtk_clk_register_pllfhs(struct device_node *node,
		if (use_fhctl)
			hw = mtk_clk_register_pllfh(pll, pllfh, base);
		else
			hw = mtk_clk_register_pll(pll, base);
			hw = mtk_clk_register_pll(NULL, pll, base);

		if (IS_ERR(hw)) {
			pr_err("Failed to register %s clk %s: %ld\n",