clk: Use generic CCF ops where possible
This converts most CCF drivers to use generic ops. imx6q is the only
outlier, where we retain the existing functionality by moving the check to
request().
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20220320203446.740178-2-seanga2@gmail.com
[ fixed missing include for at91 ]
Signed-off-by: Sean Anderson <seanga2@gmail.com>
diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
index 5343036..67825af 100644
--- a/drivers/clk/imx/clk-imx6q.c
+++ b/drivers/clk/imx/clk-imx6q.c
@@ -14,79 +14,22 @@
#include "clk.h"
-static int imx6q_check_id(ulong id)
+static int imx6q_clk_request(struct clk *clk)
{
- if (id < IMX6QDL_CLK_DUMMY || id >= IMX6QDL_CLK_END) {
- printf("%s: Invalid clk ID #%lu\n", __func__, id);
+ if (clk->id < IMX6QDL_CLK_DUMMY || clk->id >= IMX6QDL_CLK_END) {
+ printf("%s: Invalid clk ID #%lu\n", __func__, clk->id);
return -EINVAL;
}
return 0;
}
-static ulong imx6q_clk_get_rate(struct clk *clk)
-{
- struct clk *c;
- int ret;
-
- debug("%s(#%lu)\n", __func__, clk->id);
-
- ret = imx6q_check_id(clk->id);
- if (ret)
- return ret;
-
- ret = clk_get_by_id(clk->id, &c);
- if (ret)
- return ret;
-
- return clk_get_rate(c);
-}
-
-static ulong imx6q_clk_set_rate(struct clk *clk, unsigned long rate)
-{
- debug("%s(#%lu), rate: %lu\n", __func__, clk->id, rate);
-
- return rate;
-}
-
-static int __imx6q_clk_enable(struct clk *clk, bool enable)
-{
- struct clk *c;
- int ret = 0;
-
- debug("%s(#%lu) en: %d\n", __func__, clk->id, enable);
-
- ret = imx6q_check_id(clk->id);
- if (ret)
- return ret;
-
- ret = clk_get_by_id(clk->id, &c);
- if (ret)
- return ret;
-
- if (enable)
- ret = clk_enable(c);
- else
- ret = clk_disable(c);
-
- return ret;
-}
-
-static int imx6q_clk_disable(struct clk *clk)
-{
- return __imx6q_clk_enable(clk, 0);
-}
-
-static int imx6q_clk_enable(struct clk *clk)
-{
- return __imx6q_clk_enable(clk, 1);
-}
-
static struct clk_ops imx6q_clk_ops = {
- .set_rate = imx6q_clk_set_rate,
- .get_rate = imx6q_clk_get_rate,
- .enable = imx6q_clk_enable,
- .disable = imx6q_clk_disable,
+ .request = imx6q_clk_request,
+ .set_rate = ccf_clk_set_rate,
+ .get_rate = ccf_clk_get_rate,
+ .enable = ccf_clk_enable,
+ .disable = ccf_clk_disable,
};
static const char *const usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };