Skip to contentSkip to conversation

Correct clk_out_mux parents

PATCH In review Peter De Schrijver 3 participants 10 messages Jul 19, 2018 – Jul 26, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Correct clk_out_mux parents

This series corrects the parents for the clk_out_mux clocks. Patch 1 does some cleanup work to keep checkpatch.pl and the compiler happy. Patch 2 does the actual work.

v2:

Fixed const compiler warnings

Peter De Schrijver (2):
clk: tegra: Fix const for clk_out parents
clk: tegra: Correct clk_out_mux parents

 drivers/clk/tegra/clk-id.h               |  5 +++++
 drivers/clk/tegra/clk-tegra-fixed.c      | 16 ++++++++++++++
 drivers/clk/tegra/clk-tegra-pmc.c        | 36 ++++++++++++++++++++++++++++----
 drivers/clk/tegra/clk-tegra210.c         | 14 ++++++-------
 include/dt-bindings/clock/tegra210-car.h |  9 ++++++--
 5 files changed, 67 insertions(+), 13 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/2 clk: tegra: Fix const for clk_out parents

---
 drivers/clk/tegra/clk-tegra-pmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/tegra/clk-tegra-pmc.c +4 -4
index a35579a..90a353a 100644
@@ -36,7 +36,7 @@
 struct pmc_clk_init_data {
 	char *mux_name;
 	char *gate_name;
-	const char **parents;
+	const char * const *parents;
 	int num_parents;
 	int mux_id;
 	int gate_id;
@@ -60,15 +60,15 @@ struct pmc_clk_init_data {
 
 static DEFINE_SPINLOCK(clk_out_lock);
 
-static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
+static const char * const clk_out1_parents[] = { "clk_m", "clk_m_div2",
 	"clk_m_div4", "extern1",
 };
 
-static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
+static const char * const clk_out2_parents[] = { "clk_m", "clk_m_div2",
 	"clk_m_div4", "extern2",
 };
 
-static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
+static const char * const clk_out3_parents[] = { "clk_m", "clk_m_div2",
 	"clk_m_div4", "extern3",
 };
 
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH v2 1/2] clk: tegra: Fix const for clk_out parents

Quoting Peter De Schrijver (2018-07-19 07:22:54)

Quoted 1 line

Please add a commit text here. Maybe why this patch is sent to the list?

#3 lore raw

Re: [PATCH v2 1/2] clk: tegra: Fix const for clk_out parents

Quoted 4 lines · Stephen Boyd

Quoting Peter De Schrijver (2018-07-19 07:22:54)

Quoted 1 line

Please add a commit text here. Maybe why this patch is sent to the list?

See description of the series.

Peter.

maintainer
#4 lore raw

Re: [PATCH v2 1/2] clk: tegra: Fix const for clk_out parents

Quoted 7 lines · Peter De Schrijver
Quoted 4 lines · Stephen Boyd

Quoting Peter De Schrijver (2018-07-19 07:22:54)

Quoted 1 line

Please add a commit text here. Maybe why this patch is sent to the list?

See description of the series.

There still needs to be a commit message for the patch.

Cheers
Jon

Signature · 1 line
nvpublic
#5 lore raw

PATCH v2 2/2 clk: tegra: Correct clk_out_mux parents

In reply to Peter De Schrijver

The first 3 possible parents of clk_out_[1-3] are defined as clk_m, clk_m/2 and clk_m/4. However They are actually osc, osc/2 and osc/4. In chips prior to Tegra210 clk_m and osc had the same frequency, so this difference didn't matter. Since Tegra210 however, clk_m is a divided version of osc. This results in CCF reporting the rate as only half the actual rate on Tegra210. To fix this, we add new clocks which have osc, osc/2, osc/4 and the respective extern clock as their possible parents and use them for Tegra210. Also 2 new DT clock defines are added to reflect the new names of clk_m/2 and clk_m/4. The old defines are still kept for backwards compatibility.

---
 drivers/clk/tegra/clk-id.h               |  5 +++++
 drivers/clk/tegra/clk-tegra-fixed.c      | 16 ++++++++++++++++
 drivers/clk/tegra/clk-tegra-pmc.c        | 28 ++++++++++++++++++++++++++++
 drivers/clk/tegra/clk-tegra210.c         | 14 +++++++-------
 include/dt-bindings/clock/tegra210-car.h |  9 +++++++--
 5 files changed, 63 insertions(+), 9 deletions(-)
drivers/clk/tegra/clk-id.h +5 -0
index b616e33..d9a0a87 100644
@@ -326,6 +326,11 @@ enum clk_id {
 	tegra_clk_pll_a_out0_out_adsp,
 	tegra_clk_adsp,
 	tegra_clk_adsp_neon,
+	tegra_clk_osc_div2,
+	tegra_clk_osc_div4,
+	tegra_clk_clk_out_1_osc_mux,
+	tegra_clk_clk_out_2_osc_mux,
+	tegra_clk_clk_out_3_osc_mux,
 	tegra_clk_max,
 };
 
drivers/clk/tegra/clk-tegra-fixed.c +16 -0
index 91c38f1..e15b67b 100644
@@ -106,4 +106,20 @@ void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks)
 					CLK_SET_RATE_PARENT, 1, 4);
 		*dt_clk = clk;
 	}
+
+	/* clk_m_div2 */
+	dt_clk = tegra_lookup_dt_id(tegra_clk_osc_div2, tegra_clks);
+	if (dt_clk) {
+		clk = clk_register_fixed_factor(NULL, "osc_div2", "osc",
+					CLK_SET_RATE_PARENT, 1, 2);
+		*dt_clk = clk;
+	}
+
+	/* clk_m_div4 */
+	dt_clk = tegra_lookup_dt_id(tegra_clk_osc_div4, tegra_clks);
+	if (dt_clk) {
+		clk = clk_register_fixed_factor(NULL, "osc_div4", "osc",
+					CLK_SET_RATE_PARENT, 1, 4);
+		*dt_clk = clk;
+	}
 }
drivers/clk/tegra/clk-tegra-pmc.c +28 -0
index 90a353a..9ddaf1b 100644
@@ -58,6 +58,19 @@ struct pmc_clk_init_data {
 		.gate_shift = _gate_shift,\
 	}
 
+#define PMC_OSC_CLK(_num, _mux_shift, _gate_shift)\
+	{\
+		.mux_name = "clk_out_" #_num "_mux",\
+		.gate_name = "clk_out_" #_num,\
+		.parents = clk_out ##_num ##_osc_parents,\
+		.num_parents = ARRAY_SIZE(clk_out ##_num ##_osc_parents),\
+		.mux_id = tegra_clk_clk_out_ ##_num ##_osc_mux,\
+		.gate_id = tegra_clk_clk_out_ ##_num,\
+		.dev_name = "extern" #_num,\
+		.mux_shift = _mux_shift,\
+		.gate_shift = _gate_shift,\
+	}
+
 static DEFINE_SPINLOCK(clk_out_lock);
 
 static const char * const clk_out1_parents[] = { "clk_m", "clk_m_div2",
@@ -72,10 +85,25 @@ struct pmc_clk_init_data {
 	"clk_m_div4", "extern3",
 };
 
+static const char * const clk_out1_osc_parents[] = { "osc", "osc_div2",
+	"osc_div4", "extern1",
+};
+
+static const char * const clk_out2_osc_parents[] = { "osc", "osc_div2",
+	"osc_div4", "extern2",
+};
+
+static const char * const clk_out3_osc_parents[] = { "osc", "osc_div2",
+	"osc_div4", "extern3",
+};
+
 static struct pmc_clk_init_data pmc_clks[] = {
 	PMC_CLK(1, 6, 2),
 	PMC_CLK(2, 14, 10),
 	PMC_CLK(3, 22, 18),
+	PMC_OSC_CLK(1, 6, 2),
+	PMC_OSC_CLK(2, 14, 10),
+	PMC_OSC_CLK(3, 22, 18),
 };
 
 void __init tegra_pmc_clk_init(void __iomem *pmc_base,
drivers/clk/tegra/clk-tegra210.c +7 -7
index 5435d01..d92f1d7 100644
@@ -2370,8 +2370,8 @@ struct utmi_clk_param {
 	[tegra_clk_fuse_burn] = { .dt_id = TEGRA210_CLK_FUSE_BURN, .present = true },
 	[tegra_clk_clk_32k] = { .dt_id = TEGRA210_CLK_CLK_32K, .present = true },
 	[tegra_clk_clk_m] = { .dt_id = TEGRA210_CLK_CLK_M, .present = true },
-	[tegra_clk_clk_m_div2] = { .dt_id = TEGRA210_CLK_CLK_M_DIV2, .present = true },
-	[tegra_clk_clk_m_div4] = { .dt_id = TEGRA210_CLK_CLK_M_DIV4, .present = true },
+	[tegra_clk_osc_div2] = { .dt_id = TEGRA210_CLK_OSC_DIV2, .present = true },
+	[tegra_clk_osc_div4] = { .dt_id = TEGRA210_CLK_OSC_DIV4, .present = true },
 	[tegra_clk_pll_ref] = { .dt_id = TEGRA210_CLK_PLL_REF, .present = true },
 	[tegra_clk_pll_c] = { .dt_id = TEGRA210_CLK_PLL_C, .present = true },
 	[tegra_clk_pll_c_out1] = { .dt_id = TEGRA210_CLK_PLL_C_OUT1, .present = true },
@@ -2451,9 +2451,9 @@ struct utmi_clk_param {
 	[tegra_clk_audio3_mux] = { .dt_id = TEGRA210_CLK_AUDIO3_MUX, .present = true },
 	[tegra_clk_audio4_mux] = { .dt_id = TEGRA210_CLK_AUDIO4_MUX, .present = true },
 	[tegra_clk_spdif_mux] = { .dt_id = TEGRA210_CLK_SPDIF_MUX, .present = true },
-	[tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_1_MUX, .present = true },
-	[tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_2_MUX, .present = true },
-	[tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_3_MUX, .present = true },
+	[tegra_clk_clk_out_1_osc_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_1_MUX, .present = true },
+	[tegra_clk_clk_out_2_osc_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_2_MUX, .present = true },
+	[tegra_clk_clk_out_3_osc_mux] = { .dt_id = TEGRA210_CLK_CLK_OUT_3_MUX, .present = true },
 	[tegra_clk_maud] = { .dt_id = TEGRA210_CLK_MAUD, .present = true },
 	[tegra_clk_mipibif] = { .dt_id = TEGRA210_CLK_MIPIBIF, .present = true },
 	[tegra_clk_qspi] = { .dt_id = TEGRA210_CLK_QSPI, .present = true },
@@ -2496,8 +2496,8 @@ struct utmi_clk_param {
 	{ .con_id = "clk_m", .dt_id = TEGRA210_CLK_CLK_M },
 	{ .con_id = "pll_ref", .dt_id = TEGRA210_CLK_PLL_REF },
 	{ .con_id = "clk_32k", .dt_id = TEGRA210_CLK_CLK_32K },
-	{ .con_id = "clk_m_div2", .dt_id = TEGRA210_CLK_CLK_M_DIV2 },
-	{ .con_id = "clk_m_div4", .dt_id = TEGRA210_CLK_CLK_M_DIV4 },
+	{ .con_id = "osc_div2", .dt_id = TEGRA210_CLK_OSC_DIV2 },
+	{ .con_id = "osc_div4", .dt_id = TEGRA210_CLK_OSC_DIV4 },
 	{ .con_id = "pll_c", .dt_id = TEGRA210_CLK_PLL_C },
 	{ .con_id = "pll_c_out1", .dt_id = TEGRA210_CLK_PLL_C_OUT1 },
 	{ .con_id = "pll_c2", .dt_id = TEGRA210_CLK_PLL_C2 },
include/dt-bindings/clock/tegra210-car.h +7 -2
index 6b77e72..08ec981 100644
@@ -260,8 +260,13 @@
 #define TEGRA210_CLK_FUSE_BURN 231
 #define TEGRA210_CLK_CLK_32K 232
 #define TEGRA210_CLK_CLK_M 233
-#define TEGRA210_CLK_CLK_M_DIV2 234
-#define TEGRA210_CLK_CLK_M_DIV4 235
+
+#define TEGRA210_CLK_OSC_DIV2 234
+#define TEGRA210_CLK_OSC_DIV4 235
+/* for backwards compatibility */
+#define TEGRA210_CLK_CLK_M_DIV2 TEGRA210_CLK_OSC_DIV2
+#define TEGRA210_CLK_CLK_M_DIV4 TEGRA210_CLK_OSC_DIV4
+
 #define TEGRA210_CLK_PLL_REF 236
 #define TEGRA210_CLK_PLL_C 237
 #define TEGRA210_CLK_PLL_C_OUT1 238
Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [PATCH v2 2/2] clk: tegra: Correct clk_out_mux parents

Quoted 11 lines · Peter De Schrijver

The first 3 possible parents of clk_out_[1-3] are defined as clk_m, clk_m/2 and clk_m/4. However They are actually osc, osc/2 and osc/4. In chips prior to Tegra210 clk_m and osc had the same frequency, so this difference didn't matter. Since Tegra210 however, clk_m is a divided version of osc. This results in CCF reporting the rate as only half the actual rate on Tegra210. To fix this, we add new clocks which have osc, osc/2, osc/4 and the respective extern clock as their possible parents and use them for Tegra210. Also 2 new DT clock defines are added to reflect the new names of clk_m/2 and clk_m/4. The old defines are still kept for backwards compatibility.

Quoted 1 line

I gave this a whirl on the Tegra210 Smaug which uses the PMC CLK_OUT1 to clock the audio codec, but unfortunately this did not work. The good news is that I know why. Basically, for Tegra210 there is a slight change in the behaviour of the CLKx_ACCEPT_REQ bit. Essentially, this bit must always be set if you want to use any of the osc clocks to drive the CLK_OUTx. Setting this bit does not effect the CLK_OUTx if you are using the CAR to drive the pin. The simplest thing to do for Tegra210 is to always set the CLKx_ACCEPT_REQ.

Cheers
Jon

Signature · 1 line
nvpublic
maintainer
#7 lore raw

Re: [PATCH v2 2/2] clk: tegra: Correct clk_out_mux parents

Quoting Jon Hunter (2018-07-19 08:06:50)

Quoted 4 lines

=

Quoted 1 line · Peter De Schrijver

The first 3 possible parents of clk_out_[1-3] are defined as clk_m, clk=

_m/2

Quoted 1 line
Quoted 1 line

and clk_m/4. However They are actually osc, osc/2 and osc/4. In chips p=

rior

Quoted 1 line
Quoted 1 line

to Tegra210 clk_m and osc had the same frequency, so this difference di=

dn't

Quoted 2 lines
Quoted 2 lines

matter. Since Tegra210 however, clk_m is a divided version of osc. This results in CCF reporting the rate as only half the actual rate on Tegra=

210.

Quoted 4 lines
Quoted 4 lines

To fix this, we add new clocks which have osc, osc/2, osc/4 and the respective extern clock as their possible parents and use them for Tegra210. Also 2 new DT clock defines are added to reflect the new names of clk_m/2 and clk_m/4. The old defines are still kept for backwa=

rds

Quoted 7 lines
Quoted 4 lines

compatibility.
=

I gave this a whirl on the Tegra210 Smaug which uses the PMC CLK_OUT1 to clock the audio codec, but unfortunately this did not work. The good news is that I know why. Basically, for Tegra210 there is a slight change in t=

he

Quoted 2 lines

behaviour of the CLKx_ACCEPT_REQ bit. Essentially, this bit must always be set if you want to use any of the osc clocks to drive the CLK_OUTx. Setti=

ng

Quoted 1 line

this bit does not effect the CLK_OUTx if you are using the CAR to drive t=

he

Quoted 4 lines

pin. The simplest thing to do for Tegra210 is to always set the CLKx_ACCEPT_REQ. =

=

So resend with that bit also set?

#8 lore raw

Re: [PATCH v2 2/2] clk: tegra: Correct clk_out_mux parents

Quoted 25 lines · Stephen Boyd

Quoting Jon Hunter (2018-07-19 08:06:50)

Quoted 14 lines · Peter De Schrijver
Quoted 11 lines

The first 3 possible parents of clk_out_[1-3] are defined as clk_m, clk_m/2 and clk_m/4. However They are actually osc, osc/2 and osc/4. In chips prior to Tegra210 clk_m and osc had the same frequency, so this difference didn't matter. Since Tegra210 however, clk_m is a divided version of osc. This results in CCF reporting the rate as only half the actual rate on Tegra210. To fix this, we add new clocks which have osc, osc/2, osc/4 and the respective extern clock as their possible parents and use them for Tegra210. Also 2 new DT clock defines are added to reflect the new names of clk_m/2 and clk_m/4. The old defines are still kept for backwards compatibility.

Quoted 1 line
Quoted 9 lines

I gave this a whirl on the Tegra210 Smaug which uses the PMC CLK_OUT1 to clock the audio codec, but unfortunately this did not work. The good news is that I know why. Basically, for Tegra210 there is a slight change in the behaviour of the CLKx_ACCEPT_REQ bit. Essentially, this bit must always be set if you want to use any of the osc clocks to drive the CLK_OUTx. Setting this bit does not effect the CLK_OUTx if you are using the CAR to drive the pin. The simplest thing to do for Tegra210 is to always set the CLKx_ACCEPT_REQ.

Quoted 2 lines

So resend with that bit also set?

We haven't figured out who should set this bit as it has some other side-effects like overriding the pinmux settings. Also not all CLK_OUT clocks appear to behave the same way.

Peter.

maintainer
#9 lore raw

Re: [PATCH v2 2/2] clk: tegra: Correct clk_out_mux parents

Quoting Peter De Schrijver (2018-07-26 01:19:20)

Quoted 6 lines · Stephen Boyd
Quoted 5 lines

Quoting Jon Hunter (2018-07-19 08:06:50)

Quoted 4 lines

=

Quoted 1 line · Peter De Schrijver

The first 3 possible parents of clk_out_[1-3] are defined as clk_m,=

clk_m/2

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and clk_m/4. However They are actually osc, osc/2 and osc/4. In chi=

ps prior

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to Tegra210 clk_m and osc had the same frequency, so this differenc=

e didn't

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

matter. Since Tegra210 however, clk_m is a divided version of osc. =

This

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

results in CCF reporting the rate as only half the actual rate on T=

egra210.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

To fix this, we add new clocks which have osc, osc/2, osc/4 and the respective extern clock as their possible parents and use them for Tegra210. Also 2 new DT clock defines are added to reflect the new names of clk_m/2 and clk_m/4. The old defines are still kept for ba=

ckwards

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

compatibility.
=

I gave this a whirl on the Tegra210 Smaug which uses the PMC CLK_OUT1=

to

Quoted 1 line
Quoted 1 line
Quoted 1 line

clock the audio codec, but unfortunately this did not work. The good =

news

Quoted 1 line
Quoted 1 line
Quoted 1 line

is that I know why. Basically, for Tegra210 there is a slight change =

in the

Quoted 1 line
Quoted 1 line
Quoted 1 line

behaviour of the CLKx_ACCEPT_REQ bit. Essentially, this bit must alwa=

ys be

Quoted 1 line
Quoted 1 line
Quoted 1 line

set if you want to use any of the osc clocks to drive the CLK_OUTx. S=

etting

Quoted 1 line
Quoted 1 line
Quoted 1 line

this bit does not effect the CLK_OUTx if you are using the CAR to dri=

ve the

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

pin. The simplest thing to do for Tegra210 is to always set the CLKx_ACCEPT_REQ. =

=

=

So resend with that bit also set?
=

Quoted 6 lines

=

We haven't figured out who should set this bit as it has some other side-effects like overriding the pinmux settings. Also not all CLK_OUT clocks appear to behave the same way.
=

Ok! Thanks for letting me know.