Skip to content

Commit a986397

Browse files
committed
Merge branch 'clk-imx' into clk-next
* clk-imx: (25 commits) clk: imx: imx8ulp: update clk flag for system critical clock clk: imx: imx8ulp: Add tpm5 clock as critical gate clock clk: imx: imx8ulp: keep MU0_B clock enabled always clk: imx: imx8ulp: Add divider closest support to get more accurate clock rate clk: imx: imx8ulp: Fix XBAR_DIVBUS and AD_SLOW clock parents clk: imx: imx93: Add nic and A55 clk dt-bindings: clock: imx93: add NIC, A55 and ARM PLL CLK clk: imx: imx93: add mcore_booted module paratemter clk: imx: fracn-gppll: Add 300MHz freq support for imx9 clk: imx: fracn-gppll: support integer pll clk: imx: fracn-gppll: disable hardware select control clk: imx: fracn-gppll: fix the rate table clk: imx: imx8mp: change the 'nand_usdhc_bus' clock to non-critical clk: imx: imx8mp: Add LDB root clock dt-bindings: clock: imx8mp: Add LDB clock entry clk: imx: imx8mp: correct DISP2 pixel clock type clk: imx: drop duplicated macro clk: imx: clk-gpr-mux: Provide clock name in error message clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate ...
2 parents c19c6c7 + 80e9552 commit a986397

File tree

16 files changed

+517
-47
lines changed

16 files changed

+517
-47
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/imx8mp-audiomix.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NXP i.MX8MP AudioMIX Block Control Binding
8+
9+
maintainers:
10+
- Marek Vasut <marex@denx.de>
11+
12+
description: |
13+
NXP i.MX8M Plus AudioMIX is dedicated clock muxing and gating IP
14+
used to control Audio related clock on the SoC.
15+
16+
properties:
17+
compatible:
18+
const: fsl,imx8mp-audio-blk-ctrl
19+
20+
reg:
21+
maxItems: 1
22+
23+
power-domains:
24+
maxItems: 1
25+
26+
clocks:
27+
minItems: 7
28+
maxItems: 7
29+
30+
clock-names:
31+
items:
32+
- const: ahb
33+
- const: sai1
34+
- const: sai2
35+
- const: sai3
36+
- const: sai5
37+
- const: sai6
38+
- const: sai7
39+
40+
'#clock-cells':
41+
const: 1
42+
description:
43+
The clock consumer should specify the desired clock by having the clock
44+
ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx8mp-clock.h
45+
for the full list of i.MX8MP IMX8MP_CLK_AUDIOMIX_ clock IDs.
46+
47+
required:
48+
- compatible
49+
- reg
50+
- clocks
51+
- clock-names
52+
- power-domains
53+
- '#clock-cells'
54+
55+
additionalProperties: false
56+
57+
examples:
58+
# Clock Control Module node:
59+
- |
60+
#include <dt-bindings/clock/imx8mp-clock.h>
61+
62+
clock-controller@30e20000 {
63+
compatible = "fsl,imx8mp-audio-blk-ctrl";
64+
reg = <0x30e20000 0x10000>;
65+
#clock-cells = <1>;
66+
clocks = <&clk IMX8MP_CLK_AUDIO_ROOT>,
67+
<&clk IMX8MP_CLK_SAI1>,
68+
<&clk IMX8MP_CLK_SAI2>,
69+
<&clk IMX8MP_CLK_SAI3>,
70+
<&clk IMX8MP_CLK_SAI5>,
71+
<&clk IMX8MP_CLK_SAI6>,
72+
<&clk IMX8MP_CLK_SAI7>;
73+
clock-names = "ahb",
74+
"sai1", "sai2", "sai3",
75+
"sai5", "sai6", "sai7";
76+
power-domains = <&pgc_audio>;
77+
};
78+
79+
...

drivers/clk/imx/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ obj-$(CONFIG_MXC_CLK) += mxc-clk.o
2727

2828
obj-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o
2929
obj-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o
30-
obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o
30+
obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o clk-imx8mp-audiomix.o
3131
obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o
3232

3333
obj-$(CONFIG_CLK_IMX93) += clk-imx93.o

drivers/clk/imx/clk-composite-8m.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,17 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw,
119119
return ret;
120120
}
121121

122+
static int imx8m_clk_divider_determine_rate(struct clk_hw *hw,
123+
struct clk_rate_request *req)
124+
{
125+
return clk_divider_ops.determine_rate(hw, req);
126+
}
127+
122128
static const struct clk_ops imx8m_clk_composite_divider_ops = {
123129
.recalc_rate = imx8m_clk_composite_divider_recalc_rate,
124130
.round_rate = imx8m_clk_composite_divider_round_rate,
125131
.set_rate = imx8m_clk_composite_divider_set_rate,
132+
.determine_rate = imx8m_clk_divider_determine_rate,
126133
};
127134

128135
static u8 imx8m_clk_composite_mux_get_parent(struct clk_hw *hw)

drivers/clk/imx/clk-composite-93.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *p
222222
hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
223223
mux_hw, &clk_mux_ro_ops, div_hw,
224224
&clk_divider_ro_ops, NULL, NULL, flags);
225-
} else {
225+
} else if (!mcore_booted) {
226226
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
227227
if (!gate)
228228
goto fail;
@@ -238,6 +238,12 @@ struct clk_hw *imx93_clk_composite_flags(const char *name, const char * const *p
238238
&imx93_clk_composite_divider_ops, gate_hw,
239239
&imx93_clk_composite_gate_ops,
240240
flags | CLK_SET_RATE_NO_REPARENT);
241+
} else {
242+
hw = clk_hw_register_composite(NULL, name, parent_names, num_parents,
243+
mux_hw, &imx93_clk_composite_mux_ops, div_hw,
244+
&imx93_clk_composite_divider_ops, NULL,
245+
&imx93_clk_composite_gate_ops,
246+
flags | CLK_SET_RATE_NO_REPARENT);
241247
}
242248

243249
if (IS_ERR(hw))

drivers/clk/imx/clk-fracn-gppll.c

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clk.h"
1616

1717
#define PLL_CTRL 0x0
18+
#define HW_CTRL_SEL BIT(16)
1819
#define CLKMUX_BYPASS BIT(2)
1920
#define CLKMUX_EN BIT(1)
2021
#define POWERUP_MASK BIT(0)
@@ -52,26 +53,40 @@
5253
.odiv = (_odiv), \
5354
}
5455

56+
#define PLL_FRACN_GP_INTEGER(_rate, _mfi, _rdiv, _odiv) \
57+
{ \
58+
.rate = (_rate), \
59+
.mfi = (_mfi), \
60+
.mfn = 0, \
61+
.mfd = 0, \
62+
.rdiv = (_rdiv), \
63+
.odiv = (_odiv), \
64+
}
65+
5566
struct clk_fracn_gppll {
5667
struct clk_hw hw;
5768
void __iomem *base;
5869
const struct imx_fracn_gppll_rate_table *rate_table;
5970
int rate_count;
71+
u32 flags;
6072
};
6173

6274
/*
63-
* Fvco = Fref * (MFI + MFN / MFD)
64-
* Fout = Fvco / (rdiv * odiv)
75+
* Fvco = (Fref / rdiv) * (MFI + MFN / MFD)
76+
* Fout = Fvco / odiv
77+
* The (Fref / rdiv) should be in range 20MHz to 40MHz
78+
* The Fvco should be in range 2.5Ghz to 5Ghz
6579
*/
6680
static const struct imx_fracn_gppll_rate_table fracn_tbl[] = {
67-
PLL_FRACN_GP(650000000U, 81, 0, 1, 0, 3),
81+
PLL_FRACN_GP(650000000U, 162, 50, 100, 0, 6),
6882
PLL_FRACN_GP(594000000U, 198, 0, 1, 0, 8),
69-
PLL_FRACN_GP(560000000U, 70, 0, 1, 0, 3),
70-
PLL_FRACN_GP(498000000U, 83, 0, 1, 0, 4),
83+
PLL_FRACN_GP(560000000U, 140, 0, 1, 0, 6),
84+
PLL_FRACN_GP(498000000U, 166, 0, 1, 0, 8),
7185
PLL_FRACN_GP(484000000U, 121, 0, 1, 0, 6),
7286
PLL_FRACN_GP(445333333U, 167, 0, 1, 0, 9),
73-
PLL_FRACN_GP(400000000U, 50, 0, 1, 0, 3),
74-
PLL_FRACN_GP(393216000U, 81, 92, 100, 0, 5)
87+
PLL_FRACN_GP(400000000U, 200, 0, 1, 0, 12),
88+
PLL_FRACN_GP(393216000U, 163, 84, 100, 0, 10),
89+
PLL_FRACN_GP(300000000U, 150, 0, 1, 0, 12)
7590
};
7691

7792
struct imx_fracn_gppll_clk imx_fracn_gppll = {
@@ -80,6 +95,24 @@ struct imx_fracn_gppll_clk imx_fracn_gppll = {
8095
};
8196
EXPORT_SYMBOL_GPL(imx_fracn_gppll);
8297

98+
/*
99+
* Fvco = (Fref / rdiv) * MFI
100+
* Fout = Fvco / odiv
101+
* The (Fref / rdiv) should be in range 20MHz to 40MHz
102+
* The Fvco should be in range 2.5Ghz to 5Ghz
103+
*/
104+
static const struct imx_fracn_gppll_rate_table int_tbl[] = {
105+
PLL_FRACN_GP_INTEGER(1700000000U, 141, 1, 2),
106+
PLL_FRACN_GP_INTEGER(1400000000U, 175, 1, 3),
107+
PLL_FRACN_GP_INTEGER(900000000U, 150, 1, 4),
108+
};
109+
110+
struct imx_fracn_gppll_clk imx_fracn_gppll_integer = {
111+
.rate_table = int_tbl,
112+
.rate_count = ARRAY_SIZE(int_tbl),
113+
};
114+
EXPORT_SYMBOL_GPL(imx_fracn_gppll_integer);
115+
83116
static inline struct clk_fracn_gppll *to_clk_fracn_gppll(struct clk_hw *hw)
84117
{
85118
return container_of(hw, struct clk_fracn_gppll, hw);
@@ -166,9 +199,15 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lon
166199
break;
167200
}
168201

169-
/* Fvco = Fref * (MFI + MFN / MFD) */
170-
fvco = fvco * mfi * mfd + fvco * mfn;
171-
do_div(fvco, mfd * rdiv * odiv);
202+
if (pll->flags & CLK_FRACN_GPPLL_INTEGER) {
203+
/* Fvco = (Fref / rdiv) * MFI */
204+
fvco = fvco * mfi;
205+
do_div(fvco, rdiv * odiv);
206+
} else {
207+
/* Fvco = (Fref / rdiv) * (MFI + MFN / MFD) */
208+
fvco = fvco * mfi * mfd + fvco * mfn;
209+
do_div(fvco, mfd * rdiv * odiv);
210+
}
172211

173212
return (unsigned long)fvco;
174213
}
@@ -191,6 +230,11 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate,
191230

192231
rate = imx_get_pll_settings(pll, drate);
193232

233+
/* Hardware control select disable. PLL is control by register */
234+
tmp = readl_relaxed(pll->base + PLL_CTRL);
235+
tmp &= ~HW_CTRL_SEL;
236+
writel_relaxed(tmp, pll->base + PLL_CTRL);
237+
194238
/* Disable output */
195239
tmp = readl_relaxed(pll->base + PLL_CTRL);
196240
tmp &= ~CLKMUX_EN;
@@ -207,8 +251,10 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate,
207251
pll_div = FIELD_PREP(PLL_RDIV_MASK, rate->rdiv) | rate->odiv |
208252
FIELD_PREP(PLL_MFI_MASK, rate->mfi);
209253
writel_relaxed(pll_div, pll->base + PLL_DIV);
210-
writel_relaxed(rate->mfd, pll->base + PLL_DENOMINATOR);
211-
writel_relaxed(FIELD_PREP(PLL_MFN_MASK, rate->mfn), pll->base + PLL_NUMERATOR);
254+
if (pll->flags & CLK_FRACN_GPPLL_FRACN) {
255+
writel_relaxed(rate->mfd, pll->base + PLL_DENOMINATOR);
256+
writel_relaxed(FIELD_PREP(PLL_MFN_MASK, rate->mfn), pll->base + PLL_NUMERATOR);
257+
}
212258

213259
/* Wait for 5us according to fracn mode pll doc */
214260
udelay(5);
@@ -292,8 +338,10 @@ static const struct clk_ops clk_fracn_gppll_ops = {
292338
.set_rate = clk_fracn_gppll_set_rate,
293339
};
294340

295-
struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, void __iomem *base,
296-
const struct imx_fracn_gppll_clk *pll_clk)
341+
static struct clk_hw *_imx_clk_fracn_gppll(const char *name, const char *parent_name,
342+
void __iomem *base,
343+
const struct imx_fracn_gppll_clk *pll_clk,
344+
u32 pll_flags)
297345
{
298346
struct clk_fracn_gppll *pll;
299347
struct clk_hw *hw;
@@ -314,6 +362,7 @@ struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, vo
314362
pll->hw.init = &init;
315363
pll->rate_table = pll_clk->rate_table;
316364
pll->rate_count = pll_clk->rate_count;
365+
pll->flags = pll_flags;
317366

318367
hw = &pll->hw;
319368

@@ -326,4 +375,18 @@ struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, vo
326375

327376
return hw;
328377
}
378+
379+
struct clk_hw *imx_clk_fracn_gppll(const char *name, const char *parent_name, void __iomem *base,
380+
const struct imx_fracn_gppll_clk *pll_clk)
381+
{
382+
return _imx_clk_fracn_gppll(name, parent_name, base, pll_clk, CLK_FRACN_GPPLL_FRACN);
383+
}
329384
EXPORT_SYMBOL_GPL(imx_clk_fracn_gppll);
385+
386+
struct clk_hw *imx_clk_fracn_gppll_integer(const char *name, const char *parent_name,
387+
void __iomem *base,
388+
const struct imx_fracn_gppll_clk *pll_clk)
389+
{
390+
return _imx_clk_fracn_gppll(name, parent_name, base, pll_clk, CLK_FRACN_GPPLL_INTEGER);
391+
}
392+
EXPORT_SYMBOL_GPL(imx_clk_fracn_gppll_integer);

drivers/clk/imx/clk-gpr-mux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ static u8 imx_clk_gpr_mux_get_parent(struct clk_hw *hw)
4848
return ret;
4949

5050
get_parent_err:
51-
pr_err("failed to get parent (%pe)\n", ERR_PTR(ret));
51+
pr_err("%s: failed to get parent (%pe)\n",
52+
clk_hw_get_name(hw), ERR_PTR(ret));
5253

5354
/* return some realistic non negative value. Potentially we could
5455
* give index to some dummy error parent.

drivers/clk/imx/clk-imx8mm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
468468
hws[IMX8MM_CLK_PCIE1_PHY] = imx8m_clk_hw_composite("pcie1_phy", imx8mm_pcie1_phy_sels, base + 0xa380);
469469
hws[IMX8MM_CLK_PCIE1_AUX] = imx8m_clk_hw_composite("pcie1_aux", imx8mm_pcie1_aux_sels, base + 0xa400);
470470
hws[IMX8MM_CLK_DC_PIXEL] = imx8m_clk_hw_composite("dc_pixel", imx8mm_dc_pixel_sels, base + 0xa480);
471-
hws[IMX8MM_CLK_LCDIF_PIXEL] = imx8m_clk_hw_composite("lcdif_pixel", imx8mm_lcdif_pixel_sels, base + 0xa500);
471+
hws[IMX8MM_CLK_LCDIF_PIXEL] = imx8m_clk_hw_composite_flags("lcdif_pixel", imx8mm_lcdif_pixel_sels, base + 0xa500, CLK_SET_RATE_PARENT);
472472
hws[IMX8MM_CLK_SAI1] = imx8m_clk_hw_composite("sai1", imx8mm_sai1_sels, base + 0xa580);
473473
hws[IMX8MM_CLK_SAI2] = imx8m_clk_hw_composite("sai2", imx8mm_sai2_sels, base + 0xa600);
474474
hws[IMX8MM_CLK_SAI3] = imx8m_clk_hw_composite("sai3", imx8mm_sai3_sels, base + 0xa680);

drivers/clk/imx/clk-imx8mn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
470470
hws[IMX8MN_CLK_DRAM_ALT] = imx8m_clk_hw_fw_managed_composite("dram_alt", imx8mn_dram_alt_sels, base + 0xa000);
471471
hws[IMX8MN_CLK_DRAM_APB] = imx8m_clk_hw_fw_managed_composite_critical("dram_apb", imx8mn_dram_apb_sels, base + 0xa080);
472472

473-
hws[IMX8MN_CLK_DISP_PIXEL] = imx8m_clk_hw_composite("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500);
473+
hws[IMX8MN_CLK_DISP_PIXEL] = imx8m_clk_hw_composite_flags("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500, CLK_SET_RATE_PARENT);
474474
hws[IMX8MN_CLK_SAI2] = imx8m_clk_hw_composite("sai2", imx8mn_sai2_sels, base + 0xa600);
475475
hws[IMX8MN_CLK_SAI3] = imx8m_clk_hw_composite("sai3", imx8mn_sai3_sels, base + 0xa680);
476476
hws[IMX8MN_CLK_SAI5] = imx8m_clk_hw_composite("sai5", imx8mn_sai5_sels, base + 0xa780);

0 commit comments

Comments
 (0)