Skip to content

Commit f1b5912

Browse files
committed
Merge tag 'clk-imx-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux into clk-imx
Pull i.MX clk driver updates from Abel Vesa: - Document bindings for i.MX93 ANATOP clock driver - Free clk_node in SCU driver for resource with different owner - Update the LVDS clocks to be compatible with SCU firmware 1.15 - Fix the name of the fvco in pll14xx by renaming it to fout * tag 'clk-imx-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelvesa/linux: clk: imx: pll14xx: change naming of fvco to fout clk: imx: clk-imx8qxp: fix LVDS bypass, pixel and phy clocks clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu() dt-bindings: clock: support i.MX93 ANATOP clock module
2 parents b85ea95 + f52f000 commit f1b5912

File tree

4 files changed

+77
-16
lines changed

4 files changed

+77
-16
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/fsl,imx93-anatop.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NXP i.MX93 ANATOP Clock Module
8+
9+
maintainers:
10+
- Peng Fan <[email protected]>
11+
12+
description: |
13+
NXP i.MX93 ANATOP module which contains PLL and OSC to Clock Controller
14+
Module.
15+
16+
properties:
17+
compatible:
18+
items:
19+
- const: fsl,imx93-anatop
20+
21+
reg:
22+
maxItems: 1
23+
24+
'#clock-cells':
25+
const: 1
26+
27+
required:
28+
- compatible
29+
- reg
30+
- '#clock-cells'
31+
32+
additionalProperties: false
33+
34+
examples:
35+
- |
36+
clock-controller@44480000 {
37+
compatible = "fsl,imx93-anatop";
38+
reg = <0x44480000 0x2000>;
39+
#clock-cells = <1>;
40+
};
41+
42+
...

drivers/clk/imx/clk-imx8qxp.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ static const char * const lcd_pxl_sels[] = {
6666
"lcd_pxl_bypass_div_clk",
6767
};
6868

69+
static const char *const lvds0_sels[] = {
70+
"clk_dummy",
71+
"clk_dummy",
72+
"clk_dummy",
73+
"clk_dummy",
74+
"mipi0_lvds_bypass_clk",
75+
};
76+
77+
static const char *const lvds1_sels[] = {
78+
"clk_dummy",
79+
"clk_dummy",
80+
"clk_dummy",
81+
"clk_dummy",
82+
"mipi1_lvds_bypass_clk",
83+
};
84+
6985
static const char * const mipi_sels[] = {
7086
"clk_dummy",
7187
"clk_dummy",
@@ -207,9 +223,9 @@ static int imx8qxp_clk_probe(struct platform_device *pdev)
207223
/* MIPI-LVDS SS */
208224
imx_clk_scu("mipi0_bypass_clk", IMX_SC_R_MIPI_0, IMX_SC_PM_CLK_BYPASS);
209225
imx_clk_scu("mipi0_pixel_clk", IMX_SC_R_MIPI_0, IMX_SC_PM_CLK_PER);
210-
imx_clk_scu("mipi0_lvds_pixel_clk", IMX_SC_R_LVDS_0, IMX_SC_PM_CLK_MISC2);
211226
imx_clk_scu("mipi0_lvds_bypass_clk", IMX_SC_R_LVDS_0, IMX_SC_PM_CLK_BYPASS);
212-
imx_clk_scu("mipi0_lvds_phy_clk", IMX_SC_R_LVDS_0, IMX_SC_PM_CLK_MISC3);
227+
imx_clk_scu2("mipi0_lvds_pixel_clk", lvds0_sels, ARRAY_SIZE(lvds0_sels), IMX_SC_R_LVDS_0, IMX_SC_PM_CLK_MISC2);
228+
imx_clk_scu2("mipi0_lvds_phy_clk", lvds0_sels, ARRAY_SIZE(lvds0_sels), IMX_SC_R_LVDS_0, IMX_SC_PM_CLK_MISC3);
213229
imx_clk_scu2("mipi0_dsi_tx_esc_clk", mipi_sels, ARRAY_SIZE(mipi_sels), IMX_SC_R_MIPI_0, IMX_SC_PM_CLK_MST_BUS);
214230
imx_clk_scu2("mipi0_dsi_rx_esc_clk", mipi_sels, ARRAY_SIZE(mipi_sels), IMX_SC_R_MIPI_0, IMX_SC_PM_CLK_SLV_BUS);
215231
imx_clk_scu2("mipi0_dsi_phy_clk", mipi_sels, ARRAY_SIZE(mipi_sels), IMX_SC_R_MIPI_0, IMX_SC_PM_CLK_PHY);
@@ -219,9 +235,9 @@ static int imx8qxp_clk_probe(struct platform_device *pdev)
219235

220236
imx_clk_scu("mipi1_bypass_clk", IMX_SC_R_MIPI_1, IMX_SC_PM_CLK_BYPASS);
221237
imx_clk_scu("mipi1_pixel_clk", IMX_SC_R_MIPI_1, IMX_SC_PM_CLK_PER);
222-
imx_clk_scu("mipi1_lvds_pixel_clk", IMX_SC_R_LVDS_1, IMX_SC_PM_CLK_MISC2);
223238
imx_clk_scu("mipi1_lvds_bypass_clk", IMX_SC_R_LVDS_1, IMX_SC_PM_CLK_BYPASS);
224-
imx_clk_scu("mipi1_lvds_phy_clk", IMX_SC_R_LVDS_1, IMX_SC_PM_CLK_MISC3);
239+
imx_clk_scu2("mipi1_lvds_pixel_clk", lvds1_sels, ARRAY_SIZE(lvds1_sels), IMX_SC_R_LVDS_1, IMX_SC_PM_CLK_MISC2);
240+
imx_clk_scu2("mipi1_lvds_phy_clk", lvds1_sels, ARRAY_SIZE(lvds1_sels), IMX_SC_R_LVDS_1, IMX_SC_PM_CLK_MISC3);
225241

226242
imx_clk_scu2("mipi1_dsi_tx_esc_clk", mipi_sels, ARRAY_SIZE(mipi_sels), IMX_SC_R_MIPI_1, IMX_SC_PM_CLK_MST_BUS);
227243
imx_clk_scu2("mipi1_dsi_rx_esc_clk", mipi_sels, ARRAY_SIZE(mipi_sels), IMX_SC_R_MIPI_1, IMX_SC_PM_CLK_SLV_BUS);

drivers/clk/imx/clk-pll14xx.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ static const struct imx_pll14xx_rate_table *imx_get_pll_settings(
104104
static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv,
105105
int sdiv, int kdiv, unsigned long prate)
106106
{
107-
u64 fvco = prate;
107+
u64 fout = prate;
108108

109-
/* fvco = (m * 65536 + k) * Fin / (p * 65536) */
110-
fvco *= (mdiv * 65536 + kdiv);
109+
/* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */
110+
fout *= (mdiv * 65536 + kdiv);
111111
pdiv *= 65536;
112112

113-
do_div(fvco, pdiv << sdiv);
113+
do_div(fout, pdiv << sdiv);
114114

115-
return fvco;
115+
return fout;
116116
}
117117

118118
static long pll1443x_calc_kdiv(int mdiv, int pdiv, int sdiv,
@@ -131,7 +131,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
131131
{
132132
u32 pll_div_ctl0, pll_div_ctl1;
133133
int mdiv, pdiv, sdiv, kdiv;
134-
long fvco, rate_min, rate_max, dist, best = LONG_MAX;
134+
long fout, rate_min, rate_max, dist, best = LONG_MAX;
135135
const struct imx_pll14xx_rate_table *tt;
136136

137137
/*
@@ -143,6 +143,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
143143
* d) -32768 <= k <= 32767
144144
*
145145
* fvco = (m * 65536 + k) * prate / (p * 65536)
146+
* fout = (m * 65536 + k) * prate / (p * 65536) / (1 << sdiv)
146147
*/
147148

148149
/* First try if we can get the desired rate from one of the static entries */
@@ -173,8 +174,8 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
173174
pr_debug("%s: in=%ld, want=%ld Only adjust kdiv %ld -> %d\n",
174175
clk_hw_get_name(&pll->hw), prate, rate,
175176
FIELD_GET(KDIV_MASK, pll_div_ctl1), kdiv);
176-
fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
177-
t->rate = (unsigned int)fvco;
177+
fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
178+
t->rate = (unsigned int)fout;
178179
t->mdiv = mdiv;
179180
t->pdiv = pdiv;
180181
t->sdiv = sdiv;
@@ -190,13 +191,13 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
190191
mdiv = clamp(mdiv, 64, 1023);
191192

192193
kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
193-
fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
194+
fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
194195

195196
/* best match */
196-
dist = abs((long)rate - (long)fvco);
197+
dist = abs((long)rate - (long)fout);
197198
if (dist < best) {
198199
best = dist;
199-
t->rate = (unsigned int)fvco;
200+
t->rate = (unsigned int)fout;
200201
t->mdiv = mdiv;
201202
t->pdiv = pdiv;
202203
t->sdiv = sdiv;

drivers/clk/imx/clk-scu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,10 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
886886
return ERR_PTR(-EINVAL);
887887
}
888888

889-
if (!imx_clk_is_resource_owned(rsrc_id))
889+
if (!imx_clk_is_resource_owned(rsrc_id)) {
890+
kfree(clk_node);
890891
return NULL;
892+
}
891893

892894
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
893895
if (!clk) {

0 commit comments

Comments
 (0)