2019-11-19 14:13:09

by Abel Vesa

[permalink] [raw]
Subject: [PATCH 0/9] clk: imx: Trivial cleanups for clk_hw based API

These changes are cleanups for the clk_hw based API i.MX clock drivers switch
longterm effort. As mentioned in the commit messages, the end goal here is to
have all the i.MX drivers use clk_hw based API only.

I've put these all in a single patchset since they do not impact in any way
the expected behavior of the drivers and they are quite obvious trivial ones.
More patches to follow for the older i.MX platforms but those might not be as
harmless (and trivial) as these ones.

Abel Vesa (9):
clk: imx: Replace all the clk based helpers with macros
clk: imx: pllv1: Switch to clk_hw based API
clk: imx: pllv2: Switch to clk_hw based API
clk: imx: imx7ulp composite: Rename to show is clk_hw based
clk: imx: Rename sccg and frac pll register to suggest clk_hw
clk: imx: Rename the imx_clk_pllv4 to imply it's clk_hw based
clk: imx: Rename the imx_clk_pfdv2 to imply it's clk_hw based
clk: imx: Rename the imx_clk_divider_gate to imply it's clk_hw based
clk: imx7up: Rename the clks to hws

drivers/clk/imx/clk-composite-7ulp.c | 2 +-
drivers/clk/imx/clk-divider-gate.c | 2 +-
drivers/clk/imx/clk-frac-pll.c | 7 +-
drivers/clk/imx/clk-imx7ulp.c | 182 +++++++++++++++++------------------
drivers/clk/imx/clk-pfdv2.c | 2 +-
drivers/clk/imx/clk-pllv1.c | 14 ++-
drivers/clk/imx/clk-pllv2.c | 14 ++-
drivers/clk/imx/clk-pllv4.c | 2 +-
drivers/clk/imx/clk-sccg-pll.c | 4 +-
drivers/clk/imx/clk.h | 69 +++++++------
10 files changed, 153 insertions(+), 145 deletions(-)

--
2.7.4



2019-11-19 14:13:16

by Abel Vesa

[permalink] [raw]
Subject: [PATCH 2/9] clk: imx: pllv1: Switch to clk_hw based API

Switch the imx_clk_pllv1 register function to clk_hw based API, rename
accordingly and add a macro for clk based legacy. This allows us to
move closer to a clear split between consumer and provider clk APIs.

Signed-off-by: Abel Vesa <[email protected]>
---
drivers/clk/imx/clk-pllv1.c | 14 +++++++++-----
drivers/clk/imx/clk.h | 5 ++++-
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/imx/clk-pllv1.c b/drivers/clk/imx/clk-pllv1.c
index 4ba9973..de4f8a4 100644
--- a/drivers/clk/imx/clk-pllv1.c
+++ b/drivers/clk/imx/clk-pllv1.c
@@ -111,12 +111,13 @@ static const struct clk_ops clk_pllv1_ops = {
.recalc_rate = clk_pllv1_recalc_rate,
};

-struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
+struct clk_hw *imx_clk_hw_pllv1(enum imx_pllv1_type type, const char *name,
const char *parent, void __iomem *base)
{
struct clk_pllv1 *pll;
- struct clk *clk;
+ struct clk_hw *hw;
struct clk_init_data init;
+ int ret;

pll = kmalloc(sizeof(*pll), GFP_KERNEL);
if (!pll)
@@ -132,10 +133,13 @@ struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
init.num_parents = 1;

pll->hw.init = &init;
+ hw = &pll->hw;

- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk))
+ ret = clk_hw_register(NULL, hw);
+ if (ret) {
kfree(pll);
+ return ERR_PTR(ret);
+ }

- return clk;
+ return hw;
}
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 945ce4d..af69fc1 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -109,10 +109,13 @@ extern struct imx_pll14xx_clk imx_1443x_pll;
#define imx_clk_fixed(name, rate) \
imx_clk_hw_fixed(name, rate)->clk

+#define imx_clk_pllv1(type, name, parent, base) \
+ imx_clk_hw_pllv1(type, name, parent, base)->clk
+
struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
void __iomem *base, const struct imx_pll14xx_clk *pll_clk);

-struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
+struct clk_hw *imx_clk_hw_pllv1(enum imx_pllv1_type type, const char *name,
const char *parent, void __iomem *base);

struct clk *imx_clk_pllv2(const char *name, const char *parent,
--
2.7.4


2019-11-19 14:13:26

by Abel Vesa

[permalink] [raw]
Subject: [PATCH 6/9] clk: imx: Rename the imx_clk_pllv4 to imply it's clk_hw based

Renaming the imx_clk_pllv4 register function to imx_clk_hw_pllv4 to be
more obvious it is clk_hw based.

Signed-off-by: Abel Vesa <[email protected]>
---
drivers/clk/imx/clk-imx7ulp.c | 4 ++--
drivers/clk/imx/clk-pllv4.c | 2 +-
drivers/clk/imx/clk.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c
index 64b79a8..afd2c2c 100644
--- a/drivers/clk/imx/clk-imx7ulp.c
+++ b/drivers/clk/imx/clk-imx7ulp.c
@@ -90,8 +90,8 @@ static void __init imx7ulp_clk_scg1_init(struct device_node *np)
clks[IMX7ULP_CLK_SPLL_PRE_DIV] = imx_clk_hw_divider_flags("spll_pre_div", "spll_pre_sel", base + 0x608, 8, 3, CLK_SET_RATE_GATE);

/* name parent_name base */
- clks[IMX7ULP_CLK_APLL] = imx_clk_pllv4("apll", "apll_pre_div", base + 0x500);
- clks[IMX7ULP_CLK_SPLL] = imx_clk_pllv4("spll", "spll_pre_div", base + 0x600);
+ clks[IMX7ULP_CLK_APLL] = imx_clk_hw_pllv4("apll", "apll_pre_div", base + 0x500);
+ clks[IMX7ULP_CLK_SPLL] = imx_clk_hw_pllv4("spll", "spll_pre_div", base + 0x600);

/* APLL PFDs */
clks[IMX7ULP_CLK_APLL_PFD0] = imx_clk_pfdv2("apll_pfd0", "apll", base + 0x50c, 0);
diff --git a/drivers/clk/imx/clk-pllv4.c b/drivers/clk/imx/clk-pllv4.c
index 8155b12..f51a800 100644
--- a/drivers/clk/imx/clk-pllv4.c
+++ b/drivers/clk/imx/clk-pllv4.c
@@ -206,7 +206,7 @@ static const struct clk_ops clk_pllv4_ops = {
.is_enabled = clk_pllv4_is_enabled,
};

-struct clk_hw *imx_clk_pllv4(const char *name, const char *parent_name,
+struct clk_hw *imx_clk_hw_pllv4(const char *name, const char *parent_name,
void __iomem *base)
{
struct clk_pllv4 *pll;
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 15c6f54..0ac6614 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -175,7 +175,7 @@ struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
.kdiv = (_k), \
}

-struct clk_hw *imx_clk_pllv4(const char *name, const char *parent_name,
+struct clk_hw *imx_clk_hw_pllv4(const char *name, const char *parent_name,
void __iomem *base);

struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name,
--
2.7.4


2019-11-19 14:14:14

by Abel Vesa

[permalink] [raw]
Subject: [PATCH 3/9] clk: imx: pllv2: Switch to clk_hw based API

Switch the imx_clk_pllv2 register function to clk_hw based API, rename
accordingly and add a macro for clk based legacy. This allows us to
move closer to a clear split between consumer and provider clk APIs.

Signed-off-by: Abel Vesa <[email protected]>
---
drivers/clk/imx/clk-pllv2.c | 14 +++++++++-----
drivers/clk/imx/clk.h | 5 ++++-
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/imx/clk-pllv2.c b/drivers/clk/imx/clk-pllv2.c
index eeba3cb..ff17f06 100644
--- a/drivers/clk/imx/clk-pllv2.c
+++ b/drivers/clk/imx/clk-pllv2.c
@@ -239,12 +239,13 @@ static const struct clk_ops clk_pllv2_ops = {
.set_rate = clk_pllv2_set_rate,
};

-struct clk *imx_clk_pllv2(const char *name, const char *parent,
+struct clk_hw *imx_clk_hw_pllv2(const char *name, const char *parent,
void __iomem *base)
{
struct clk_pllv2 *pll;
- struct clk *clk;
+ struct clk_hw *hw;
struct clk_init_data init;
+ int ret;

pll = kzalloc(sizeof(*pll), GFP_KERNEL);
if (!pll)
@@ -259,10 +260,13 @@ struct clk *imx_clk_pllv2(const char *name, const char *parent,
init.num_parents = 1;

pll->hw.init = &init;
+ hw = &pll->hw;

- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk))
+ ret = clk_hw_register(NULL, hw);
+ if (ret) {
kfree(pll);
+ return ERR_PTR(ret);
+ }

- return clk;
+ return hw;
}
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index af69fc1..bb5243e 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -112,13 +112,16 @@ extern struct imx_pll14xx_clk imx_1443x_pll;
#define imx_clk_pllv1(type, name, parent, base) \
imx_clk_hw_pllv1(type, name, parent, base)->clk

+#define imx_clk_pllv2(name, parent, base) \
+ imx_clk_hw_pllv2(name, parent, base)->clk
+
struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
void __iomem *base, const struct imx_pll14xx_clk *pll_clk);

struct clk_hw *imx_clk_hw_pllv1(enum imx_pllv1_type type, const char *name,
const char *parent, void __iomem *base);

-struct clk *imx_clk_pllv2(const char *name, const char *parent,
+struct clk_hw *imx_clk_hw_pllv2(const char *name, const char *parent,
void __iomem *base);

struct clk *imx_clk_frac_pll(const char *name, const char *parent_name,
--
2.7.4


2019-11-22 07:58:23

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH 0/9] clk: imx: Trivial cleanups for clk_hw based API

> Subject: [PATCH 0/9] clk: imx: Trivial cleanups for clk_hw based API
>
> These changes are cleanups for the clk_hw based API i.MX clock drivers
> switch longterm effort. As mentioned in the commit messages, the end goal
> here is to have all the i.MX drivers use clk_hw based API only.
>
> I've put these all in a single patchset since they do not impact in any way the
> expected behavior of the drivers and they are quite obvious trivial ones.
> More patches to follow for the older i.MX platforms but those might not be as
> harmless (and trivial) as these ones.

For the patchset,

Reviewed-by: Peng Fan <[email protected]>

>
> Abel Vesa (9):
> clk: imx: Replace all the clk based helpers with macros
> clk: imx: pllv1: Switch to clk_hw based API
> clk: imx: pllv2: Switch to clk_hw based API
> clk: imx: imx7ulp composite: Rename to show is clk_hw based
> clk: imx: Rename sccg and frac pll register to suggest clk_hw
> clk: imx: Rename the imx_clk_pllv4 to imply it's clk_hw based
> clk: imx: Rename the imx_clk_pfdv2 to imply it's clk_hw based
> clk: imx: Rename the imx_clk_divider_gate to imply it's clk_hw based
> clk: imx7up: Rename the clks to hws
>
> drivers/clk/imx/clk-composite-7ulp.c | 2 +-
> drivers/clk/imx/clk-divider-gate.c | 2 +-
> drivers/clk/imx/clk-frac-pll.c | 7 +-
> drivers/clk/imx/clk-imx7ulp.c | 182
> +++++++++++++++++------------------
> drivers/clk/imx/clk-pfdv2.c | 2 +-
> drivers/clk/imx/clk-pllv1.c | 14 ++-
> drivers/clk/imx/clk-pllv2.c | 14 ++-
> drivers/clk/imx/clk-pllv4.c | 2 +-
> drivers/clk/imx/clk-sccg-pll.c | 4 +-
> drivers/clk/imx/clk.h | 69 +++++++------
> 10 files changed, 153 insertions(+), 145 deletions(-)
>
> --
> 2.7.4