diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2024-06-28 19:40:49 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-08-01 15:32:18 -0600 |
commit | a03174cbfaef9cc8b51429bbde6e27539f428a83 (patch) | |
tree | 16df47aa3e6e24ae43b692404c706292b58c0262 /drivers/clk | |
parent | 432cb967b04de96fc081c358c718942294f0a7e2 (diff) | |
download | u-boot-a03174cbfaef9cc8b51429bbde6e27539f428a83.zip u-boot-a03174cbfaef9cc8b51429bbde6e27539f428a83.tar.gz u-boot-a03174cbfaef9cc8b51429bbde6e27539f428a83.tar.bz2 |
clk: mediatek: add support for gate ID at offset
Add support to clk_gate ops to reference the clk ID at an offset by
using the just introduced gates_offs value from the unified muxes +
gates implementation.
Gate clock that doesn't have gates_offs set won't be affected as the
offset will simply be 0 and won't be offset of any value.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/mediatek/clk-mtk.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 986e735..1d5ae8f 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -530,8 +530,12 @@ static int mtk_gate_enable(void __iomem *base, const struct mtk_gate *gate) static int mtk_clk_gate_enable(struct clk *clk) { struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate = &priv->gates[clk->id]; + const struct mtk_gate *gate; + + if (clk->id < priv->tree->gates_offs) + return -EINVAL; + gate = &priv->gates[clk->id - priv->tree->gates_offs]; return mtk_gate_enable(priv->base, gate); } @@ -576,8 +580,12 @@ static int mtk_gate_disable(void __iomem *base, const struct mtk_gate *gate) static int mtk_clk_gate_disable(struct clk *clk) { struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate = &priv->gates[clk->id]; + const struct mtk_gate *gate; + if (clk->id < priv->tree->gates_offs) + return -EINVAL; + + gate = &priv->gates[clk->id - priv->tree->gates_offs]; return mtk_gate_disable(priv->base, gate); } @@ -597,8 +605,12 @@ static int mtk_clk_infrasys_disable(struct clk *clk) static ulong mtk_clk_gate_get_rate(struct clk *clk) { struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate = &priv->gates[clk->id]; + const struct mtk_gate *gate; + + if (clk->id < priv->tree->gates_offs) + return -EINVAL; + gate = &priv->gates[clk->id - priv->tree->gates_offs]; /* * Assume xtal_rate to be declared if some gates have * XTAL as parent |