From: Peng Fan <[email protected]>
V3:
Add R-b
Drop of_match_ptr in patch 2, so I drop Abel's R-b in this patch.
V2:
Add A-b from Rob
Add a new patch 2 reported by intel test robot
Use Abel's new address for sending mail
The current clk driver use gate API as i.MX8M*, the gate2 API use 0x3 as
val/mask, however i.MX93 LPCG DIRECT use BIT0 as on/off gate. So clk
disable unused actually not gate off the LPCG clocks.
And i.MX93 has AUTHEN feature, so add a new API to support i.MX93 clk gate.
i.MX93 CCM ROOT has slice busy check bit when updating register value, add
check. CCM ROOT also has AUTHEN whitelist, so add DID check.
Besides the gate/composite update, add MU[X] and SAI IPG clk in this
patchset
This patchset has got reviewed in NXP internal, so I keep R-b tag here.
For those that have some change compared with downstream, R-b tag dropped.
Peng Fan (8):
dt-bindings: clock: imx93-clock: add more MU/SAI clocks
clk: imx93: drop of_match_ptr
clk: imx: clk-composite-93: check slice busy
clk: imx: clk-composite-93: check white_list
clk: imx: add i.MX93 clk gate
clk: imx93: switch to use new clk gate API
clk: imx93: add MU1/2 clock
clk: imx93: add SAI IPG clk
drivers/clk/imx/Makefile | 2 +-
drivers/clk/imx/clk-composite-93.c | 171 +++++++++++++++++++-
drivers/clk/imx/clk-gate-93.c | 199 ++++++++++++++++++++++++
drivers/clk/imx/clk-imx93.c | 32 ++--
drivers/clk/imx/clk.h | 9 +-
include/dt-bindings/clock/imx93-clock.h | 9 +-
6 files changed, 402 insertions(+), 20 deletions(-)
create mode 100644 drivers/clk/imx/clk-gate-93.c
--
2.37.1
From: Peng Fan <[email protected]>
There is build warning when CONFIG_OF is not selected.
>> drivers/clk/imx/clk-imx93.c:324:34: warning: 'imx93_clk_of_match'
>> defined but not used [-Wunused-const-variable=]
324 | static const struct of_device_id imx93_clk_of_match[] = {
| ^~~~~~~~~~~~~~~~~~
The driver only support DT table, no sense to use of_match_ptr.
Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
---
drivers/clk/imx/clk-imx93.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index f5c9fa40491c..dcc41d178238 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -332,7 +332,7 @@ static struct platform_driver imx93_clk_driver = {
.driver = {
.name = "imx93-ccm",
.suppress_bind_attrs = true,
- .of_match_table = of_match_ptr(imx93_clk_of_match),
+ .of_match_table = imx93_clk_of_match,
},
};
module_platform_driver(imx93_clk_driver);
--
2.37.1
From: Peng Fan <[email protected]>
Add MU[1,2]_[A,B] clock entries.
Add SAI IPG clock entries.
Acked-by: Rob Herring <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
---
include/dt-bindings/clock/imx93-clock.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/dt-bindings/clock/imx93-clock.h b/include/dt-bindings/clock/imx93-clock.h
index 21fda9c5cb5e..19bc32788d81 100644
--- a/include/dt-bindings/clock/imx93-clock.h
+++ b/include/dt-bindings/clock/imx93-clock.h
@@ -196,6 +196,13 @@
#define IMX93_CLK_TMC_GATE 187
#define IMX93_CLK_PMRO_GATE 188
#define IMX93_CLK_32K 189
-#define IMX93_CLK_END 190
+#define IMX93_CLK_SAI1_IPG 190
+#define IMX93_CLK_SAI2_IPG 191
+#define IMX93_CLK_SAI3_IPG 192
+#define IMX93_CLK_MU1_A_GATE 193
+#define IMX93_CLK_MU1_B_GATE 194
+#define IMX93_CLK_MU2_A_GATE 195
+#define IMX93_CLK_MU2_B_GATE 196
+#define IMX93_CLK_END 197
#endif
--
2.37.1
From: Peng Fan <[email protected]>
Use i.MX93 specific clk gate API
Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Ye Li <[email protected]>
Reviewed-by: Jacky Bai <[email protected]>
---
drivers/clk/imx/clk-imx93.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index 6d9cbe26b2fb..d9ec4d618f48 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -146,6 +146,7 @@ static const struct imx93_clk_ccgr {
char *parent_name;
u32 off;
unsigned long flags;
+ u32 *shared_count;
} ccgr_array[] = {
{ IMX93_CLK_A55_GATE, "a55", "a55_root", 0x8000, },
/* M33 critical clk for system run */
@@ -299,10 +300,9 @@ static int imx93_clocks_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(ccgr_array); i++) {
ccgr = &ccgr_array[i];
- clks[ccgr->clk] = imx_clk_hw_gate4_flags(ccgr->name,
- ccgr->parent_name,
- base + ccgr->off, 0,
- ccgr->flags);
+ clks[ccgr->clk] = imx93_clk_gate(NULL, ccgr->name, ccgr->parent_name,
+ ccgr->flags, base + ccgr->off, 0, 1, 1, 3,
+ ccgr->shared_count);
}
imx_check_clk_hws(clks, IMX93_CLK_END);
--
2.37.1
From: Peng Fan <[email protected]>
The CCM ROOT AUTHEN register WHITE_LIST indicate:
Each bit in this field represent for one domain. Bit16~Bit31 represent
for DOMAIN0~DOMAIN15 respectively. Only corresponding bit of the domains
is set to 1 can change the registers of this Clock Root.
i.MX93 DID is 3, so if BIT(3 + WHITE_LIST_SHIFT) is 0, the clk should be
set to read only. To make the imx93_clk_composite_flags be reusable,
add a new parameter named did(domain id);
Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Ye Li <[email protected]>
Reviewed-by: Jacky Bai <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
---
drivers/clk/imx/clk-composite-93.c | 8 ++++++--
drivers/clk/imx/clk-imx93.c | 2 +-
drivers/clk/imx/clk.h | 5 +++--
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/imx/clk-composite-93.c b/drivers/clk/imx/clk-composite-93.c
index 19f4037e6cca..74a66b0203e4 100644
--- a/drivers/clk/imx/clk-composite-93.c
+++ b/drivers/clk/imx/clk-composite-93.c
@@ -28,6 +28,8 @@
#define TZ_NS_SHIFT 9
#define TZ_NS_MASK BIT(9)
+#define WHITE_LIST_SHIFT 16
+
static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)
{
int ret;
@@ -180,7 +182,7 @@ static const struct clk_ops imx93_clk_composite_mux_ops = {
};
struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *parent_names,
- int num_parents, void __iomem *reg,
+ int num_parents, void __iomem *reg, u32 domain_id,
unsigned long flags)
{
struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
@@ -189,6 +191,7 @@ struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *p
struct clk_gate *gate = NULL;
struct clk_mux *mux = NULL;
bool clk_ro = false;
+ u32 authen;
mux = kzalloc(sizeof(*mux), GFP_KERNEL);
if (!mux)
@@ -211,7 +214,8 @@ struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *p
div->lock = &imx_ccm_lock;
div->flags = CLK_DIVIDER_ROUND_CLOSEST;
- if (!(readl(reg + AUTHEN_OFFSET) & TZ_NS_MASK))
+ authen = readl(reg + AUTHEN_OFFSET);
+ if (!(authen & TZ_NS_MASK) || !(authen & BIT(WHITE_LIST_SHIFT + domain_id)))
clk_ro = true;
if (clk_ro) {
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index dcc41d178238..6d9cbe26b2fb 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -293,7 +293,7 @@ static int imx93_clocks_probe(struct platform_device *pdev)
root = &root_array[i];
clks[root->clk] = imx93_clk_composite_flags(root->name,
parent_names[root->sel],
- 4, base + root->off,
+ 4, base + root->off, 3,
root->flags);
}
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 5061a06468df..396a5ea75083 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -445,9 +445,10 @@ struct clk_hw *imx93_clk_composite_flags(const char *name,
const char * const *parent_names,
int num_parents,
void __iomem *reg,
+ u32 domain_id,
unsigned long flags);
-#define imx93_clk_composite(name, parent_names, num_parents, reg) \
- imx93_clk_composite_flags(name, parent_names, num_parents, reg, \
+#define imx93_clk_composite(name, parent_names, num_parents, reg, domain_id) \
+ imx93_clk_composite_flags(name, parent_names, num_parents, reg, domain_id \
CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
struct clk_hw *imx_clk_hw_divider_gate(const char *name, const char *parent_name,
--
2.37.1
From: Peng Fan <[email protected]>
The clk tree should be as:
bus_aon_root------>\ /--->MU1_B IP
-->MU_B gate-->
bus_wakeup_root--->/ \--->MU2_B IP
bus_aon_root------>\ /--->MU1_A IP
-->MU_A gate-->
bus_wakeup_root--->/ \--->MU2_A IP
So need use shared count gate. And linux use MU_B,
so set MU_A clk as CLK_IGNORE_UNUSED.
Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Ye Li <[email protected]>
Reviewed-by: Jacky Bai <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
---
drivers/clk/imx/clk-imx93.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index d9ec4d618f48..51af0b12ff9e 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -28,6 +28,8 @@ enum clk_sel {
MAX_SEL
};
+static u32 share_count_mub;
+
static const char *parent_names[MAX_SEL][4] = {
{"osc_24m", "sys_pll_pfd0_div2", "sys_pll_pfd1_div2", "video_pll"},
{"osc_24m", "sys_pll_pfd0_div2", "sys_pll_pfd1_div2", "sys_pll_pfd2_div2"},
@@ -159,8 +161,10 @@ static const struct imx93_clk_ccgr {
{ IMX93_CLK_WDOG5_GATE, "wdog5", "osc_24m", 0x8400, },
{ IMX93_CLK_SEMA1_GATE, "sema1", "bus_aon_root", 0x8440, },
{ IMX93_CLK_SEMA2_GATE, "sema2", "bus_wakeup_root", 0x8480, },
- { IMX93_CLK_MU_A_GATE, "mu_a", "bus_aon_root", 0x84c0, },
- { IMX93_CLK_MU_B_GATE, "mu_b", "bus_aon_root", 0x8500, },
+ { IMX93_CLK_MU1_A_GATE, "mu1_a", "bus_aon_root", 0x84c0, CLK_IGNORE_UNUSED },
+ { IMX93_CLK_MU2_A_GATE, "mu2_a", "bus_wakeup_root", 0x84c0, CLK_IGNORE_UNUSED },
+ { IMX93_CLK_MU1_B_GATE, "mu1_b", "bus_aon_root", 0x8500, 0, &share_count_mub },
+ { IMX93_CLK_MU2_B_GATE, "mu2_b", "bus_wakeup_root", 0x8500, 0, &share_count_mub },
{ IMX93_CLK_EDMA1_GATE, "edma1", "m33_root", 0x8540, },
{ IMX93_CLK_EDMA2_GATE, "edma2", "wakeup_axi_root", 0x8580, },
{ IMX93_CLK_FLEXSPI1_GATE, "flexspi", "flexspi_root", 0x8640, },
--
2.37.1
On 22-08-30 11:31:31, Peng Fan (OSS) wrote:
> From: Peng Fan <[email protected]>
>
> There is build warning when CONFIG_OF is not selected.
> >> drivers/clk/imx/clk-imx93.c:324:34: warning: 'imx93_clk_of_match'
> >> defined but not used [-Wunused-const-variable=]
> 324 | static const struct of_device_id imx93_clk_of_match[] = {
> | ^~~~~~~~~~~~~~~~~~
>
> The driver only support DT table, no sense to use of_match_ptr.
>
> Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Peng Fan <[email protected]>
Reviewed-by: Abel Vesa <[email protected]>
Stephen will you pick this patch?
I'll take the rest through my tree.
> ---
> drivers/clk/imx/clk-imx93.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
> index f5c9fa40491c..dcc41d178238 100644
> --- a/drivers/clk/imx/clk-imx93.c
> +++ b/drivers/clk/imx/clk-imx93.c
> @@ -332,7 +332,7 @@ static struct platform_driver imx93_clk_driver = {
> .driver = {
> .name = "imx93-ccm",
> .suppress_bind_attrs = true,
> - .of_match_table = of_match_ptr(imx93_clk_of_match),
> + .of_match_table = imx93_clk_of_match,
> },
> };
> module_platform_driver(imx93_clk_driver);
> --
> 2.37.1
>
On 22-08-30 11:31:29, Peng Fan (OSS) wrote:
> From: Peng Fan <[email protected]>
>
>
> V3:
> Add R-b
> Drop of_match_ptr in patch 2, so I drop Abel's R-b in this patch.
>
> V2:
> Add A-b from Rob
> Add a new patch 2 reported by intel test robot
> Use Abel's new address for sending mail
>
> The current clk driver use gate API as i.MX8M*, the gate2 API use 0x3 as
> val/mask, however i.MX93 LPCG DIRECT use BIT0 as on/off gate. So clk
> disable unused actually not gate off the LPCG clocks.
> And i.MX93 has AUTHEN feature, so add a new API to support i.MX93 clk gate.
>
> i.MX93 CCM ROOT has slice busy check bit when updating register value, add
> check. CCM ROOT also has AUTHEN whitelist, so add DID check.
>
> Besides the gate/composite update, add MU[X] and SAI IPG clk in this
> patchset
>
> This patchset has got reviewed in NXP internal, so I keep R-b tag here.
> For those that have some change compared with downstream, R-b tag dropped.
Applied all, except patch no. 2. Will wait for Stephen to pick that one
up since it is a fix and so it might need to go through his clk/fixes.
If not, I'll apply it to my tree along with the others.
>
> Peng Fan (8):
> dt-bindings: clock: imx93-clock: add more MU/SAI clocks
> clk: imx93: drop of_match_ptr
> clk: imx: clk-composite-93: check slice busy
> clk: imx: clk-composite-93: check white_list
> clk: imx: add i.MX93 clk gate
> clk: imx93: switch to use new clk gate API
> clk: imx93: add MU1/2 clock
> clk: imx93: add SAI IPG clk
>
> drivers/clk/imx/Makefile | 2 +-
> drivers/clk/imx/clk-composite-93.c | 171 +++++++++++++++++++-
> drivers/clk/imx/clk-gate-93.c | 199 ++++++++++++++++++++++++
> drivers/clk/imx/clk-imx93.c | 32 ++--
> drivers/clk/imx/clk.h | 9 +-
> include/dt-bindings/clock/imx93-clock.h | 9 +-
> 6 files changed, 402 insertions(+), 20 deletions(-)
> create mode 100644 drivers/clk/imx/clk-gate-93.c
>
> --
> 2.37.1
>
Quoting Abel Vesa (2022-09-02 11:31:06)
> On 22-08-30 11:31:31, Peng Fan (OSS) wrote:
> > From: Peng Fan <[email protected]>
> >
> > There is build warning when CONFIG_OF is not selected.
> > >> drivers/clk/imx/clk-imx93.c:324:34: warning: 'imx93_clk_of_match'
> > >> defined but not used [-Wunused-const-variable=]
> > 324 | static const struct of_device_id imx93_clk_of_match[] = {
> > | ^~~~~~~~~~~~~~~~~~
> >
> > The driver only support DT table, no sense to use of_match_ptr.
> >
> > Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk")
> > Reported-by: kernel test robot <[email protected]>
> > Signed-off-by: Peng Fan <[email protected]>
>
> Reviewed-by: Abel Vesa <[email protected]>
>
> Stephen will you pick this patch?
Ok. Got it for fixes.