All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/8] i.MX early debug UART clock fixes
@ 2015-09-07 15:09 ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-arm-kernel,
	kernel, patchwork-lst

This series fixes a long standing interaction issue between the
kernels early debug facilities and the i.MX clock drivers.

Both earlyprintk and earlycon rely on the bootloader setup clocks
for the UARTs to be retained during kernel init. As those clocks are
only enabled in hardware, but not referenced in software they (or even
their parent clocks) may get disabled as a result of other clocks being
en-/disabled during boot.

This results in missing messages from the early debug console until the
regular system console takes over, or even worse system hangs in response
to unclocked register accesses. This renders those debugging facilities a
lot less useful.

The fix implemented here is to check if any of this early debugging is
enabled and keep the UART clocks referenced and enabled in that case.
The clocks will then only be disabled at the end of kernel init, at which
point the real console should have taken over and the early outputs being
disabled.

I've runtime tested this on i.MX6Q and i.MX53, other platforms are only
compile tested. This is mostly a mechanical change, but still I would
appreciate some testing.

Changes since v1:
- reworked logic to require significantly less code in the individual
  clock drivers

Changes since v2:
- fix checkpatch warning about initdata annotation placement
- make code a bit more compact in the for(...) loops
  (since 2 people already commented about this I made up my mind)
- change code style in driver as requested by Shawn
- add more const correctness
  (note that this triggers a false positive checkpatch error in the first patch)

Regards,
Lucas

Lucas Stach (8):
  clk: imx: add common logic to detect early UART usage
  clk: imx25: retain early UART clocks during kernel init
  clk: imx27: retain early UART clocks during kernel init
  clk: imx31: retain early UART clocks during kernel init
  clk: imx35: retain early UART clocks during kernel init
  clk: imx5: retain early UART clocks during kernel init
  clk: imx6: retain early UART clocks during kernel init
  clk: imx7d: retain early UART clocks during kernel init

 drivers/clk/imx/clk-imx25.c       | 12 ++++++++++++
 drivers/clk/imx/clk-imx27.c       | 13 +++++++++++++
 drivers/clk/imx/clk-imx31.c       | 12 ++++++++++++
 drivers/clk/imx/clk-imx35.c       | 10 ++++++++++
 drivers/clk/imx/clk-imx51-imx53.c | 16 ++++++++++++++++
 drivers/clk/imx/clk-imx6q.c       |  8 ++++++++
 drivers/clk/imx/clk-imx6sl.c      |  8 ++++++++
 drivers/clk/imx/clk-imx6sx.c      |  8 ++++++++
 drivers/clk/imx/clk-imx7d.c       | 13 +++++++++++++
 drivers/clk/imx/clk.c             | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h             |  1 +
 11 files changed, 139 insertions(+)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 0/8] i.MX early debug UART clock fixes
@ 2015-09-07 15:09 ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

This series fixes a long standing interaction issue between the
kernels early debug facilities and the i.MX clock drivers.

Both earlyprintk and earlycon rely on the bootloader setup clocks
for the UARTs to be retained during kernel init. As those clocks are
only enabled in hardware, but not referenced in software they (or even
their parent clocks) may get disabled as a result of other clocks being
en-/disabled during boot.

This results in missing messages from the early debug console until the
regular system console takes over, or even worse system hangs in response
to unclocked register accesses. This renders those debugging facilities a
lot less useful.

The fix implemented here is to check if any of this early debugging is
enabled and keep the UART clocks referenced and enabled in that case.
The clocks will then only be disabled at the end of kernel init, at which
point the real console should have taken over and the early outputs being
disabled.

I've runtime tested this on i.MX6Q and i.MX53, other platforms are only
compile tested. This is mostly a mechanical change, but still I would
appreciate some testing.

Changes since v1:
- reworked logic to require significantly less code in the individual
  clock drivers

Changes since v2:
- fix checkpatch warning about initdata annotation placement
- make code a bit more compact in the for(...) loops
  (since 2 people already commented about this I made up my mind)
- change code style in driver as requested by Shawn
- add more const correctness
  (note that this triggers a false positive checkpatch error in the first patch)

Regards,
Lucas

Lucas Stach (8):
  clk: imx: add common logic to detect early UART usage
  clk: imx25: retain early UART clocks during kernel init
  clk: imx27: retain early UART clocks during kernel init
  clk: imx31: retain early UART clocks during kernel init
  clk: imx35: retain early UART clocks during kernel init
  clk: imx5: retain early UART clocks during kernel init
  clk: imx6: retain early UART clocks during kernel init
  clk: imx7d: retain early UART clocks during kernel init

 drivers/clk/imx/clk-imx25.c       | 12 ++++++++++++
 drivers/clk/imx/clk-imx27.c       | 13 +++++++++++++
 drivers/clk/imx/clk-imx31.c       | 12 ++++++++++++
 drivers/clk/imx/clk-imx35.c       | 10 ++++++++++
 drivers/clk/imx/clk-imx51-imx53.c | 16 ++++++++++++++++
 drivers/clk/imx/clk-imx6q.c       |  8 ++++++++
 drivers/clk/imx/clk-imx6sl.c      |  8 ++++++++
 drivers/clk/imx/clk-imx6sx.c      |  8 ++++++++
 drivers/clk/imx/clk-imx7d.c       | 13 +++++++++++++
 drivers/clk/imx/clk.c             | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h             |  1 +
 11 files changed, 139 insertions(+)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	linux-clk, linux-arm-kernel

Both earlycon and earlyprintk depend on the bootloader setup UART
clocks being retained. This patch adds the common logic to detect such
situations and make the information available to the clock drivers, as
well as adding the facilities to disable those clocks at the end of
the kernel init.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk.c | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h |  1 +
 2 files changed, 39 insertions(+)

diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index df12b5307175..45a073dab435 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
 	*val ^= CSCMR1_FIXUP;
 	return;
 }
+
+static int imx_keep_uart_clocks __initdata;
+static struct clk ** const *imx_uart_clocks __initdata;
+
+static int __init imx_keep_uart_clocks_param(char *str)
+{
+	imx_keep_uart_clocks = 1;
+
+	return 0;
+}
+__setup_param("earlycon", imx_keep_uart_earlycon,
+	      imx_keep_uart_clocks_param, 0);
+__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
+	      imx_keep_uart_clocks_param, 0);
+
+void __init imx_register_uart_clocks(struct clk ** const clks[])
+{
+	if (imx_keep_uart_clocks) {
+		int i;
+
+		imx_uart_clocks = clks;
+		for (i = 0; imx_uart_clocks[i]; i++)
+			clk_prepare_enable(*imx_uart_clocks[i]);
+	}
+}
+
+static int __init imx_clk_disable_uart(void)
+{
+	if (imx_keep_uart_clocks) {
+		int i;
+
+		for (i = 0; imx_uart_clocks[i]; i++)
+			clk_disable_unprepare(*imx_uart_clocks[i]);
+	}
+
+	return 0;
+}
+late_initcall_sync(imx_clk_disable_uart);
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 1049b0c7d818..c94ac5c26226 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -7,6 +7,7 @@
 extern spinlock_t imx_ccm_lock;
 
 void imx_check_clocks(struct clk *clks[], unsigned int count);
+void imx_register_uart_clocks(struct clk ** const clks[]);
 
 extern void imx_cscmr1_fixup(u32 *val);
 
-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Both earlycon and earlyprintk depend on the bootloader setup UART
clocks being retained. This patch adds the common logic to detect such
situations and make the information available to the clock drivers, as
well as adding the facilities to disable those clocks at the end of
the kernel init.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk.c | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h |  1 +
 2 files changed, 39 insertions(+)

diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index df12b5307175..45a073dab435 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
 	*val ^= CSCMR1_FIXUP;
 	return;
 }
+
+static int imx_keep_uart_clocks __initdata;
+static struct clk ** const *imx_uart_clocks __initdata;
+
+static int __init imx_keep_uart_clocks_param(char *str)
+{
+	imx_keep_uart_clocks = 1;
+
+	return 0;
+}
+__setup_param("earlycon", imx_keep_uart_earlycon,
+	      imx_keep_uart_clocks_param, 0);
+__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
+	      imx_keep_uart_clocks_param, 0);
+
+void __init imx_register_uart_clocks(struct clk ** const clks[])
+{
+	if (imx_keep_uart_clocks) {
+		int i;
+
+		imx_uart_clocks = clks;
+		for (i = 0; imx_uart_clocks[i]; i++)
+			clk_prepare_enable(*imx_uart_clocks[i]);
+	}
+}
+
+static int __init imx_clk_disable_uart(void)
+{
+	if (imx_keep_uart_clocks) {
+		int i;
+
+		for (i = 0; imx_uart_clocks[i]; i++)
+			clk_disable_unprepare(*imx_uart_clocks[i]);
+	}
+
+	return 0;
+}
+late_initcall_sync(imx_clk_disable_uart);
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 1049b0c7d818..c94ac5c26226 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -7,6 +7,7 @@
 extern spinlock_t imx_ccm_lock;
 
 void imx_check_clocks(struct clk *clks[], unsigned int count);
+void imx_register_uart_clocks(struct clk ** const clks[]);
 
 extern void imx_cscmr1_fixup(u32 *val);
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/8] clk: imx25: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	linux-clk, linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx25.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/imx/clk-imx25.c b/drivers/clk/imx/clk-imx25.c
index ec1a4c1dacf1..c4c141cab444 100644
--- a/drivers/clk/imx/clk-imx25.c
+++ b/drivers/clk/imx/clk-imx25.c
@@ -86,6 +86,16 @@ enum mx25_clks {
 
 static struct clk *clk[clk_max];
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[uart_ipg_per],
+	&clk[uart1_ipg],
+	&clk[uart2_ipg],
+	&clk[uart3_ipg],
+	&clk[uart4_ipg],
+	&clk[uart5_ipg],
+	NULL
+};
+
 static int __init __mx25_clocks_init(unsigned long osc_rate,
 				     void __iomem *ccm_base)
 {
@@ -233,6 +243,8 @@ static int __init __mx25_clocks_init(unsigned long osc_rate,
 	 */
 	clk_set_parent(clk[cko_sel], clk[ipg]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	return 0;
 }
 
-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/8] clk: imx25: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx25.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/imx/clk-imx25.c b/drivers/clk/imx/clk-imx25.c
index ec1a4c1dacf1..c4c141cab444 100644
--- a/drivers/clk/imx/clk-imx25.c
+++ b/drivers/clk/imx/clk-imx25.c
@@ -86,6 +86,16 @@ enum mx25_clks {
 
 static struct clk *clk[clk_max];
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[uart_ipg_per],
+	&clk[uart1_ipg],
+	&clk[uart2_ipg],
+	&clk[uart3_ipg],
+	&clk[uart4_ipg],
+	&clk[uart5_ipg],
+	NULL
+};
+
 static int __init __mx25_clocks_init(unsigned long osc_rate,
 				     void __iomem *ccm_base)
 {
@@ -233,6 +243,8 @@ static int __init __mx25_clocks_init(unsigned long osc_rate,
 	 */
 	clk_set_parent(clk[cko_sel], clk[ipg]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	return 0;
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/8] clk: imx27: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-arm-kernel,
	kernel, patchwork-lst

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx27.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/clk/imx/clk-imx27.c b/drivers/clk/imx/clk-imx27.c
index d9d50d54ef2a..0d7b8df04dfa 100644
--- a/drivers/clk/imx/clk-imx27.c
+++ b/drivers/clk/imx/clk-imx27.c
@@ -47,6 +47,17 @@ static const char *ssi_sel_clks[] = { "spll_gate", "mpll", };
 static struct clk *clk[IMX27_CLK_MAX];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX27_CLK_PER1_GATE],
+	&clk[IMX27_CLK_UART1_IPG_GATE],
+	&clk[IMX27_CLK_UART2_IPG_GATE],
+	&clk[IMX27_CLK_UART3_IPG_GATE],
+	&clk[IMX27_CLK_UART4_IPG_GATE],
+	&clk[IMX27_CLK_UART5_IPG_GATE],
+	&clk[IMX27_CLK_UART6_IPG_GATE],
+	NULL
+};
+
 static void __init _mx27_clocks_init(unsigned long fref)
 {
 	BUG_ON(!ccm);
@@ -163,6 +174,8 @@ static void __init _mx27_clocks_init(unsigned long fref)
 
 	clk_prepare_enable(clk[IMX27_CLK_EMI_AHB_GATE]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	imx_print_silicon_rev("i.MX27", mx27_revision());
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/8] clk: imx27: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx27.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/clk/imx/clk-imx27.c b/drivers/clk/imx/clk-imx27.c
index d9d50d54ef2a..0d7b8df04dfa 100644
--- a/drivers/clk/imx/clk-imx27.c
+++ b/drivers/clk/imx/clk-imx27.c
@@ -47,6 +47,17 @@ static const char *ssi_sel_clks[] = { "spll_gate", "mpll", };
 static struct clk *clk[IMX27_CLK_MAX];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX27_CLK_PER1_GATE],
+	&clk[IMX27_CLK_UART1_IPG_GATE],
+	&clk[IMX27_CLK_UART2_IPG_GATE],
+	&clk[IMX27_CLK_UART3_IPG_GATE],
+	&clk[IMX27_CLK_UART4_IPG_GATE],
+	&clk[IMX27_CLK_UART5_IPG_GATE],
+	&clk[IMX27_CLK_UART6_IPG_GATE],
+	NULL
+};
+
 static void __init _mx27_clocks_init(unsigned long fref)
 {
 	BUG_ON(!ccm);
@@ -163,6 +174,8 @@ static void __init _mx27_clocks_init(unsigned long fref)
 
 	clk_prepare_enable(clk[IMX27_CLK_EMI_AHB_GATE]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	imx_print_silicon_rev("i.MX27", mx27_revision());
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/8] clk: imx31: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-arm-kernel,
	kernel, patchwork-lst

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx31.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index fe66c40b7be2..e283142f123a 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -62,6 +62,16 @@ enum mx31_clks {
 static struct clk *clk[clk_max];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[ipg],
+	&clk[uart1_gate],
+	&clk[uart2_gate],
+	&clk[uart3_gate],
+	&clk[uart4_gate],
+	&clk[uart5_gate],
+	NULL
+};
+
 int __init mx31_clocks_init(unsigned long fref)
 {
 	void __iomem *base;
@@ -199,6 +209,8 @@ int __init mx31_clocks_init(unsigned long fref)
 	mx31_revision();
 	clk_disable_unprepare(clk[iim_gate]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	mxc_timer_init(MX31_GPT1_BASE_ADDR, MX31_INT_GPT, GPT_TYPE_IMX31);
 
 	return 0;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/8] clk: imx31: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx31.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index fe66c40b7be2..e283142f123a 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -62,6 +62,16 @@ enum mx31_clks {
 static struct clk *clk[clk_max];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[ipg],
+	&clk[uart1_gate],
+	&clk[uart2_gate],
+	&clk[uart3_gate],
+	&clk[uart4_gate],
+	&clk[uart5_gate],
+	NULL
+};
+
 int __init mx31_clocks_init(unsigned long fref)
 {
 	void __iomem *base;
@@ -199,6 +209,8 @@ int __init mx31_clocks_init(unsigned long fref)
 	mx31_revision();
 	clk_disable_unprepare(clk[iim_gate]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	mxc_timer_init(MX31_GPT1_BASE_ADDR, MX31_INT_GPT, GPT_TYPE_IMX31);
 
 	return 0;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/8] clk: imx35: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	linux-clk, linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx35.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
index 69138ba3dec7..cbe9eee8c80b 100644
--- a/drivers/clk/imx/clk-imx35.c
+++ b/drivers/clk/imx/clk-imx35.c
@@ -84,6 +84,14 @@ enum mx35_clks {
 
 static struct clk *clk[clk_max];
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[ipg],
+	&clk[uart1_gate],
+	&clk[uart2_gate],
+	&clk[uart3_gate],
+	NULL
+};
+
 int __init mx35_clocks_init(void)
 {
 	void __iomem *base;
@@ -292,6 +300,8 @@ int __init mx35_clocks_init(void)
 	 */
 	clk_prepare_enable(clk[scc_gate]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	imx_print_silicon_rev("i.MX35", mx35_revision());
 
 	mxc_timer_init(MX35_GPT1_BASE_ADDR, MX35_INT_GPT, GPT_TYPE_IMX31);
-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/8] clk: imx35: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx35.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
index 69138ba3dec7..cbe9eee8c80b 100644
--- a/drivers/clk/imx/clk-imx35.c
+++ b/drivers/clk/imx/clk-imx35.c
@@ -84,6 +84,14 @@ enum mx35_clks {
 
 static struct clk *clk[clk_max];
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[ipg],
+	&clk[uart1_gate],
+	&clk[uart2_gate],
+	&clk[uart3_gate],
+	NULL
+};
+
 int __init mx35_clocks_init(void)
 {
 	void __iomem *base;
@@ -292,6 +300,8 @@ int __init mx35_clocks_init(void)
 	 */
 	clk_prepare_enable(clk[scc_gate]);
 
+	imx_register_uart_clocks(uart_clks);
+
 	imx_print_silicon_rev("i.MX35", mx35_revision());
 
 	mxc_timer_init(MX35_GPT1_BASE_ADDR, MX35_INT_GPT, GPT_TYPE_IMX31);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 6/8] clk: imx5: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	linux-clk, linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx51-imx53.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/clk/imx/clk-imx51-imx53.c b/drivers/clk/imx/clk-imx51-imx53.c
index a7e4f394be0d..c6770348d2ab 100644
--- a/drivers/clk/imx/clk-imx51-imx53.c
+++ b/drivers/clk/imx/clk-imx51-imx53.c
@@ -130,6 +130,20 @@ static const char *cpu_podf_sels[] = { "pll1_sw", "step_sel" };
 static struct clk *clk[IMX5_CLK_END];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX5_CLK_UART1_IPG_GATE],
+	&clk[IMX5_CLK_UART1_PER_GATE],
+	&clk[IMX5_CLK_UART2_IPG_GATE],
+	&clk[IMX5_CLK_UART2_PER_GATE],
+	&clk[IMX5_CLK_UART3_IPG_GATE],
+	&clk[IMX5_CLK_UART3_PER_GATE],
+	&clk[IMX5_CLK_UART4_IPG_GATE],
+	&clk[IMX5_CLK_UART4_PER_GATE],
+	&clk[IMX5_CLK_UART5_IPG_GATE],
+	&clk[IMX5_CLK_UART5_PER_GATE],
+	NULL
+};
+
 static void __init mx5_clocks_common_init(void __iomem *ccm_base)
 {
 	clk[IMX5_CLK_DUMMY]		= imx_clk_fixed("dummy", 0);
@@ -310,6 +324,8 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base)
 	clk_prepare_enable(clk[IMX5_CLK_TMAX1]);
 	clk_prepare_enable(clk[IMX5_CLK_TMAX2]); /* esdhc2, fec */
 	clk_prepare_enable(clk[IMX5_CLK_TMAX3]); /* esdhc1, esdhc4 */
+
+	imx_register_uart_clocks(uart_clks);
 }
 
 static void __init mx50_clocks_init(struct device_node *np)
-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 6/8] clk: imx5: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx51-imx53.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/clk/imx/clk-imx51-imx53.c b/drivers/clk/imx/clk-imx51-imx53.c
index a7e4f394be0d..c6770348d2ab 100644
--- a/drivers/clk/imx/clk-imx51-imx53.c
+++ b/drivers/clk/imx/clk-imx51-imx53.c
@@ -130,6 +130,20 @@ static const char *cpu_podf_sels[] = { "pll1_sw", "step_sel" };
 static struct clk *clk[IMX5_CLK_END];
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX5_CLK_UART1_IPG_GATE],
+	&clk[IMX5_CLK_UART1_PER_GATE],
+	&clk[IMX5_CLK_UART2_IPG_GATE],
+	&clk[IMX5_CLK_UART2_PER_GATE],
+	&clk[IMX5_CLK_UART3_IPG_GATE],
+	&clk[IMX5_CLK_UART3_PER_GATE],
+	&clk[IMX5_CLK_UART4_IPG_GATE],
+	&clk[IMX5_CLK_UART4_PER_GATE],
+	&clk[IMX5_CLK_UART5_IPG_GATE],
+	&clk[IMX5_CLK_UART5_PER_GATE],
+	NULL
+};
+
 static void __init mx5_clocks_common_init(void __iomem *ccm_base)
 {
 	clk[IMX5_CLK_DUMMY]		= imx_clk_fixed("dummy", 0);
@@ -310,6 +324,8 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base)
 	clk_prepare_enable(clk[IMX5_CLK_TMAX1]);
 	clk_prepare_enable(clk[IMX5_CLK_TMAX2]); /* esdhc2, fec */
 	clk_prepare_enable(clk[IMX5_CLK_TMAX3]); /* esdhc1, esdhc4 */
+
+	imx_register_uart_clocks(uart_clks);
 }
 
 static void __init mx50_clocks_init(struct device_node *np)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 7/8] clk: imx6: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	linux-clk, linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx6q.c  | 8 ++++++++
 drivers/clk/imx/clk-imx6sl.c | 8 ++++++++
 drivers/clk/imx/clk-imx6sx.c | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
index d046f8e43de8..4221c038a3ba 100644
--- a/drivers/clk/imx/clk-imx6q.c
+++ b/drivers/clk/imx/clk-imx6q.c
@@ -130,6 +130,12 @@ static inline int clk_on_imx6dl(void)
 	return of_machine_is_compatible("fsl,imx6dl");
 }
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX6QDL_CLK_UART_IPG],
+	&clk[IMX6QDL_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6q_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -534,5 +540,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	/* All existing boards with PCIe use LVDS1 */
 	if (IS_ENABLED(CONFIG_PCI_IMX6))
 		clk_set_parent(clk[IMX6QDL_CLK_LVDS1_SEL], clk[IMX6QDL_CLK_SATA_REF_100M]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6q, "fsl,imx6q-ccm", imx6q_clocks_init);
diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c
index a0d4cf26cfa9..3c3333faae8e 100644
--- a/drivers/clk/imx/clk-imx6sl.c
+++ b/drivers/clk/imx/clk-imx6sl.c
@@ -184,6 +184,12 @@ void imx6sl_set_wait_clk(bool enter)
 		imx6sl_enable_pll_arm(false);
 }
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX6SL_CLK_UART],
+	&clks[IMX6SL_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6sl_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -439,5 +445,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
 
 	clk_set_parent(clks[IMX6SL_CLK_LCDIF_AXI_SEL],
 		       clks[IMX6SL_CLK_PLL2_PFD2]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6sl, "fsl,imx6sl-ccm", imx6sl_clocks_init);
diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
index 5b95c2c2bf52..f0ad8bbc12f8 100644
--- a/drivers/clk/imx/clk-imx6sx.c
+++ b/drivers/clk/imx/clk-imx6sx.c
@@ -135,6 +135,12 @@ static u32 share_count_ssi1;
 static u32 share_count_ssi2;
 static u32 share_count_ssi3;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX6SX_CLK_UART_IPG],
+	&clks[IMX6SX_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6sx_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -557,5 +563,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
 
 	clk_set_parent(clks[IMX6SX_CLK_QSPI1_SEL], clks[IMX6SX_CLK_PLL2_BUS]);
 	clk_set_parent(clks[IMX6SX_CLK_QSPI2_SEL], clks[IMX6SX_CLK_PLL2_BUS]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6sx, "fsl,imx6sx-ccm", imx6sx_clocks_init);
-- 
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 7/8] clk: imx6: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx6q.c  | 8 ++++++++
 drivers/clk/imx/clk-imx6sl.c | 8 ++++++++
 drivers/clk/imx/clk-imx6sx.c | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
index d046f8e43de8..4221c038a3ba 100644
--- a/drivers/clk/imx/clk-imx6q.c
+++ b/drivers/clk/imx/clk-imx6q.c
@@ -130,6 +130,12 @@ static inline int clk_on_imx6dl(void)
 	return of_machine_is_compatible("fsl,imx6dl");
 }
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clk[IMX6QDL_CLK_UART_IPG],
+	&clk[IMX6QDL_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6q_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -534,5 +540,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	/* All existing boards with PCIe use LVDS1 */
 	if (IS_ENABLED(CONFIG_PCI_IMX6))
 		clk_set_parent(clk[IMX6QDL_CLK_LVDS1_SEL], clk[IMX6QDL_CLK_SATA_REF_100M]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6q, "fsl,imx6q-ccm", imx6q_clocks_init);
diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c
index a0d4cf26cfa9..3c3333faae8e 100644
--- a/drivers/clk/imx/clk-imx6sl.c
+++ b/drivers/clk/imx/clk-imx6sl.c
@@ -184,6 +184,12 @@ void imx6sl_set_wait_clk(bool enter)
 		imx6sl_enable_pll_arm(false);
 }
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX6SL_CLK_UART],
+	&clks[IMX6SL_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6sl_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -439,5 +445,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
 
 	clk_set_parent(clks[IMX6SL_CLK_LCDIF_AXI_SEL],
 		       clks[IMX6SL_CLK_PLL2_PFD2]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6sl, "fsl,imx6sl-ccm", imx6sl_clocks_init);
diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
index 5b95c2c2bf52..f0ad8bbc12f8 100644
--- a/drivers/clk/imx/clk-imx6sx.c
+++ b/drivers/clk/imx/clk-imx6sx.c
@@ -135,6 +135,12 @@ static u32 share_count_ssi1;
 static u32 share_count_ssi2;
 static u32 share_count_ssi3;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX6SX_CLK_UART_IPG],
+	&clks[IMX6SX_CLK_UART_SERIAL],
+	NULL
+};
+
 static void __init imx6sx_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -557,5 +563,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
 
 	clk_set_parent(clks[IMX6SX_CLK_QSPI1_SEL], clks[IMX6SX_CLK_PLL2_BUS]);
 	clk_set_parent(clks[IMX6SX_CLK_QSPI2_SEL], clks[IMX6SX_CLK_PLL2_BUS]);
+
+	imx_register_uart_clocks(uart_clks);
 }
 CLK_OF_DECLARE(imx6sx, "fsl,imx6sx-ccm", imx6sx_clocks_init);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 8/8] clk: imx7d: retain early UART clocks during kernel init
  2015-09-07 15:09 ` Lucas Stach
@ 2015-09-07 15:09   ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-arm-kernel,
	kernel, patchwork-lst

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx7d.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
index 71f3a94b472c..f86b68049872 100644
--- a/drivers/clk/imx/clk-imx7d.c
+++ b/drivers/clk/imx/clk-imx7d.c
@@ -363,6 +363,17 @@ static const char *pll_video_bypass_sel[] = { "pll_video_main", "pll_video_main_
 
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX7D_UART1_ROOT_CLK],
+	&clks[IMX7D_UART2_ROOT_CLK],
+	&clks[IMX7D_UART3_ROOT_CLK],
+	&clks[IMX7D_UART4_ROOT_CLK],
+	&clks[IMX7D_UART5_ROOT_CLK],
+	&clks[IMX7D_UART6_ROOT_CLK],
+	&clks[IMX7D_UART7_ROOT_CLK],
+	NULL
+};
+
 static void __init imx7d_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -856,5 +867,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node)
 	/* set uart module clock's parent clock source that must be great then 80MHz */
 	clk_set_parent(clks[IMX7D_UART1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]);
 
+	imx_register_uart_clocks(uart_clks);
+
 }
 CLK_OF_DECLARE(imx7d, "fsl,imx7d-ccm", imx7d_clocks_init);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 8/8] clk: imx7d: retain early UART clocks during kernel init
@ 2015-09-07 15:09   ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure to keep UART clocks enabled during kernel init if
earlyprintk or earlycon are active.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/clk/imx/clk-imx7d.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
index 71f3a94b472c..f86b68049872 100644
--- a/drivers/clk/imx/clk-imx7d.c
+++ b/drivers/clk/imx/clk-imx7d.c
@@ -363,6 +363,17 @@ static const char *pll_video_bypass_sel[] = { "pll_video_main", "pll_video_main_
 
 static struct clk_onecell_data clk_data;
 
+static struct clk ** const uart_clks[] __initconst = {
+	&clks[IMX7D_UART1_ROOT_CLK],
+	&clks[IMX7D_UART2_ROOT_CLK],
+	&clks[IMX7D_UART3_ROOT_CLK],
+	&clks[IMX7D_UART4_ROOT_CLK],
+	&clks[IMX7D_UART5_ROOT_CLK],
+	&clks[IMX7D_UART6_ROOT_CLK],
+	&clks[IMX7D_UART7_ROOT_CLK],
+	NULL
+};
+
 static void __init imx7d_clocks_init(struct device_node *ccm_node)
 {
 	struct device_node *np;
@@ -856,5 +867,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node)
 	/* set uart module clock's parent clock source that must be great then 80MHz */
 	clk_set_parent(clks[IMX7D_UART1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]);
 
+	imx_register_uart_clocks(uart_clks);
+
 }
 CLK_OF_DECLARE(imx7d, "fsl,imx7d-ccm", imx7d_clocks_init);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
  2015-09-07 15:09   ` Lucas Stach
@ 2015-09-07 18:52     ` Uwe Kleine-König
  -1 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2015-09-07 18:52 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	Shawn Guo, linux-clk, linux-arm-kernel

Hello Lucas,

On Mon, Sep 07, 2015 at 05:09:26PM +0200, Lucas Stach wrote:
> Both earlycon and earlyprintk depend on the bootloader setup UART
> clocks being retained. This patch adds the common logic to detect such
> situations and make the information available to the clock drivers, as
> well as adding the facilities to disable those clocks at the end of
> the kernel init.
> =

> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/clk/imx/clk.c | 38 ++++++++++++++++++++++++++++++++++++++
>  drivers/clk/imx/clk.h |  1 +
>  2 files changed, 39 insertions(+)
> =

> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index df12b5307175..45a073dab435 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
>  	*val ^=3D CSCMR1_FIXUP;
>  	return;
>  }
> +
> +static int imx_keep_uart_clocks __initdata;
> +static struct clk ** const *imx_uart_clocks __initdata;
> +
> +static int __init imx_keep_uart_clocks_param(char *str)
> +{
> +	imx_keep_uart_clocks =3D 1;
> +
> +	return 0;
> +}
> +__setup_param("earlycon", imx_keep_uart_earlycon,
> +	      imx_keep_uart_clocks_param, 0);
> +__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
> +	      imx_keep_uart_clocks_param, 0);
> +
> +void __init imx_register_uart_clocks(struct clk ** const clks[])
> +{
> +	if (imx_keep_uart_clocks) {
> +		int i;
> +
> +		imx_uart_clocks =3D clks;
> +		for (i =3D 0; imx_uart_clocks[i]; i++)
> +			clk_prepare_enable(*imx_uart_clocks[i]);
> +	}
> +}
> +
> +static int __init imx_clk_disable_uart(void)
> +{
> +	if (imx_keep_uart_clocks) {
> +		int i;
> +
> +		for (i =3D 0; imx_uart_clocks[i]; i++)
> +			clk_disable_unprepare(*imx_uart_clocks[i]);
> +	}
> +
> +	return 0;
> +}
> +late_initcall_sync(imx_clk_disable_uart);

I bet you didn't test if this works when earlyprintk (or earlycon) is
provided on the command line but imx_register_uart_clocks isn't called
(e.g. because this is a Samsung CPU running a multiarch kernel).

Best regards
Uwe

-- =

Pengutronix e.K.                           | Uwe Kleine-K=F6nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
@ 2015-09-07 18:52     ` Uwe Kleine-König
  0 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2015-09-07 18:52 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lucas,

On Mon, Sep 07, 2015 at 05:09:26PM +0200, Lucas Stach wrote:
> Both earlycon and earlyprintk depend on the bootloader setup UART
> clocks being retained. This patch adds the common logic to detect such
> situations and make the information available to the clock drivers, as
> well as adding the facilities to disable those clocks at the end of
> the kernel init.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/clk/imx/clk.c | 38 ++++++++++++++++++++++++++++++++++++++
>  drivers/clk/imx/clk.h |  1 +
>  2 files changed, 39 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> index df12b5307175..45a073dab435 100644
> --- a/drivers/clk/imx/clk.c
> +++ b/drivers/clk/imx/clk.c
> @@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
>  	*val ^= CSCMR1_FIXUP;
>  	return;
>  }
> +
> +static int imx_keep_uart_clocks __initdata;
> +static struct clk ** const *imx_uart_clocks __initdata;
> +
> +static int __init imx_keep_uart_clocks_param(char *str)
> +{
> +	imx_keep_uart_clocks = 1;
> +
> +	return 0;
> +}
> +__setup_param("earlycon", imx_keep_uart_earlycon,
> +	      imx_keep_uart_clocks_param, 0);
> +__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
> +	      imx_keep_uart_clocks_param, 0);
> +
> +void __init imx_register_uart_clocks(struct clk ** const clks[])
> +{
> +	if (imx_keep_uart_clocks) {
> +		int i;
> +
> +		imx_uart_clocks = clks;
> +		for (i = 0; imx_uart_clocks[i]; i++)
> +			clk_prepare_enable(*imx_uart_clocks[i]);
> +	}
> +}
> +
> +static int __init imx_clk_disable_uart(void)
> +{
> +	if (imx_keep_uart_clocks) {
> +		int i;
> +
> +		for (i = 0; imx_uart_clocks[i]; i++)
> +			clk_disable_unprepare(*imx_uart_clocks[i]);
> +	}
> +
> +	return 0;
> +}
> +late_initcall_sync(imx_clk_disable_uart);

I bet you didn't test if this works when earlyprintk (or earlycon) is
provided on the command line but imx_register_uart_clocks isn't called
(e.g. because this is a Samsung CPU running a multiarch kernel).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
  2015-09-07 18:52     ` Uwe Kleine-König
@ 2015-09-08  8:51       ` Lucas Stach
  -1 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-08  8:51 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Michael Turquette, Stephen Boyd, patchwork-lst, kernel,
	Shawn Guo, linux-clk, linux-arm-kernel

SGkgVXdlLAoKQW0gTW9udGFnLCBkZW4gMDcuMDkuMjAxNSwgMjA6NTIgKzAyMDAgc2NocmllYiBV
d2UgS2xlaW5lLUvDtm5pZzoKPiBIZWxsbyBMdWNhcywKPiAKPiBPbiBNb24sIFNlcCAwNywgMjAx
NSBhdCAwNTowOToyNlBNICswMjAwLCBMdWNhcyBTdGFjaCB3cm90ZToKPiA+IEJvdGggZWFybHlj
b24gYW5kIGVhcmx5cHJpbnRrIGRlcGVuZCBvbiB0aGUgYm9vdGxvYWRlciBzZXR1cCBVQVJUCj4g
PiBjbG9ja3MgYmVpbmcgcmV0YWluZWQuIFRoaXMgcGF0Y2ggYWRkcyB0aGUgY29tbW9uIGxvZ2lj
IHRvIGRldGVjdCBzdWNoCj4gPiBzaXR1YXRpb25zIGFuZCBtYWtlIHRoZSBpbmZvcm1hdGlvbiBh
dmFpbGFibGUgdG8gdGhlIGNsb2NrIGRyaXZlcnMsIGFzCj4gPiB3ZWxsIGFzIGFkZGluZyB0aGUg
ZmFjaWxpdGllcyB0byBkaXNhYmxlIHRob3NlIGNsb2NrcyBhdCB0aGUgZW5kIG9mCj4gPiB0aGUg
a2VybmVsIGluaXQuCj4gPiAKPiA+IFNpZ25lZC1vZmYtYnk6IEx1Y2FzIFN0YWNoIDxsLnN0YWNo
QHBlbmd1dHJvbml4LmRlPgo+ID4gLS0tCj4gPiAgZHJpdmVycy9jbGsvaW14L2Nsay5jIHwgMzgg
KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysKPiA+ICBkcml2ZXJzL2Nsay9p
bXgvY2xrLmggfCAgMSArCj4gPiAgMiBmaWxlcyBjaGFuZ2VkLCAzOSBpbnNlcnRpb25zKCspCj4g
PiAKPiA+IGRpZmYgLS1naXQgYS9kcml2ZXJzL2Nsay9pbXgvY2xrLmMgYi9kcml2ZXJzL2Nsay9p
bXgvY2xrLmMKPiA+IGluZGV4IGRmMTJiNTMwNzE3NS4uNDVhMDczZGFiNDM1IDEwMDY0NAo+ID4g
LS0tIGEvZHJpdmVycy9jbGsvaW14L2Nsay5jCj4gPiArKysgYi9kcml2ZXJzL2Nsay9pbXgvY2xr
LmMKPiA+IEBAIC03MywzICs3Myw0MSBAQCB2b2lkIGlteF9jc2NtcjFfZml4dXAodTMyICp2YWwp
Cj4gPiAgCSp2YWwgXj0gQ1NDTVIxX0ZJWFVQOwo+ID4gIAlyZXR1cm47Cj4gPiAgfQo+ID4gKwo+
ID4gK3N0YXRpYyBpbnQgaW14X2tlZXBfdWFydF9jbG9ja3MgX19pbml0ZGF0YTsKPiA+ICtzdGF0
aWMgc3RydWN0IGNsayAqKiBjb25zdCAqaW14X3VhcnRfY2xvY2tzIF9faW5pdGRhdGE7Cj4gPiAr
Cj4gPiArc3RhdGljIGludCBfX2luaXQgaW14X2tlZXBfdWFydF9jbG9ja3NfcGFyYW0oY2hhciAq
c3RyKQo+ID4gK3sKPiA+ICsJaW14X2tlZXBfdWFydF9jbG9ja3MgPSAxOwo+ID4gKwo+ID4gKwly
ZXR1cm4gMDsKPiA+ICt9Cj4gPiArX19zZXR1cF9wYXJhbSgiZWFybHljb24iLCBpbXhfa2VlcF91
YXJ0X2Vhcmx5Y29uLAo+ID4gKwkgICAgICBpbXhfa2VlcF91YXJ0X2Nsb2Nrc19wYXJhbSwgMCk7
Cj4gPiArX19zZXR1cF9wYXJhbSgiZWFybHlwcmludGsiLCBpbXhfa2VlcF91YXJ0X2Vhcmx5cHJp
bnRrLAo+ID4gKwkgICAgICBpbXhfa2VlcF91YXJ0X2Nsb2Nrc19wYXJhbSwgMCk7Cj4gPiArCj4g
PiArdm9pZCBfX2luaXQgaW14X3JlZ2lzdGVyX3VhcnRfY2xvY2tzKHN0cnVjdCBjbGsgKiogY29u
c3QgY2xrc1tdKQo+ID4gK3sKPiA+ICsJaWYgKGlteF9rZWVwX3VhcnRfY2xvY2tzKSB7Cj4gPiAr
CQlpbnQgaTsKPiA+ICsKPiA+ICsJCWlteF91YXJ0X2Nsb2NrcyA9IGNsa3M7Cj4gPiArCQlmb3Ig
KGkgPSAwOyBpbXhfdWFydF9jbG9ja3NbaV07IGkrKykKPiA+ICsJCQljbGtfcHJlcGFyZV9lbmFi
bGUoKmlteF91YXJ0X2Nsb2Nrc1tpXSk7Cj4gPiArCX0KPiA+ICt9Cj4gPiArCj4gPiArc3RhdGlj
IGludCBfX2luaXQgaW14X2Nsa19kaXNhYmxlX3VhcnQodm9pZCkKPiA+ICt7Cj4gPiArCWlmIChp
bXhfa2VlcF91YXJ0X2Nsb2Nrcykgewo+ID4gKwkJaW50IGk7Cj4gPiArCj4gPiArCQlmb3IgKGkg
PSAwOyBpbXhfdWFydF9jbG9ja3NbaV07IGkrKykKPiA+ICsJCQljbGtfZGlzYWJsZV91bnByZXBh
cmUoKmlteF91YXJ0X2Nsb2Nrc1tpXSk7Cj4gPiArCX0KPiA+ICsKPiA+ICsJcmV0dXJuIDA7Cj4g
PiArfQo+ID4gK2xhdGVfaW5pdGNhbGxfc3luYyhpbXhfY2xrX2Rpc2FibGVfdWFydCk7Cj4gCj4g
SSBiZXQgeW91IGRpZG4ndCB0ZXN0IGlmIHRoaXMgd29ya3Mgd2hlbiBlYXJseXByaW50ayAob3Ig
ZWFybHljb24pIGlzCj4gcHJvdmlkZWQgb24gdGhlIGNvbW1hbmQgbGluZSBidXQgaW14X3JlZ2lz
dGVyX3VhcnRfY2xvY2tzIGlzbid0IGNhbGxlZAo+IChlLmcuIGJlY2F1c2UgdGhpcyBpcyBhIFNh
bXN1bmcgQ1BVIHJ1bm5pbmcgYSBtdWx0aWFyY2gga2VybmVsKS4KPiAKQWgsIGRhbW4hIFRoYW5r
cyBmb3Igc3BvdHRpbmcuCgpSZWdhcmRzLApMdWNhcwoKLS0gClBlbmd1dHJvbml4IGUuSy4gICAg
ICAgICAgICAgfCBMdWNhcyBTdGFjaCAgICAgICAgICAgICAgICAgfApJbmR1c3RyaWFsIExpbnV4
IFNvbHV0aW9ucyAgIHwgaHR0cDovL3d3dy5wZW5ndXRyb25peC5kZS8gIHwKCgpfX19fX19fX19f
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXwpsaW51eC1hcm0ta2VybmVsIG1h
aWxpbmcgbGlzdApsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmcKaHR0cDovL2xp
c3RzLmluZnJhZGVhZC5vcmcvbWFpbG1hbi9saXN0aW5mby9saW51eC1hcm0ta2VybmVsCg==

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage
@ 2015-09-08  8:51       ` Lucas Stach
  0 siblings, 0 replies; 22+ messages in thread
From: Lucas Stach @ 2015-09-08  8:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Uwe,

Am Montag, den 07.09.2015, 20:52 +0200 schrieb Uwe Kleine-K?nig:
> Hello Lucas,
> 
> On Mon, Sep 07, 2015 at 05:09:26PM +0200, Lucas Stach wrote:
> > Both earlycon and earlyprintk depend on the bootloader setup UART
> > clocks being retained. This patch adds the common logic to detect such
> > situations and make the information available to the clock drivers, as
> > well as adding the facilities to disable those clocks at the end of
> > the kernel init.
> > 
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > ---
> >  drivers/clk/imx/clk.c | 38 ++++++++++++++++++++++++++++++++++++++
> >  drivers/clk/imx/clk.h |  1 +
> >  2 files changed, 39 insertions(+)
> > 
> > diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> > index df12b5307175..45a073dab435 100644
> > --- a/drivers/clk/imx/clk.c
> > +++ b/drivers/clk/imx/clk.c
> > @@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
> >  	*val ^= CSCMR1_FIXUP;
> >  	return;
> >  }
> > +
> > +static int imx_keep_uart_clocks __initdata;
> > +static struct clk ** const *imx_uart_clocks __initdata;
> > +
> > +static int __init imx_keep_uart_clocks_param(char *str)
> > +{
> > +	imx_keep_uart_clocks = 1;
> > +
> > +	return 0;
> > +}
> > +__setup_param("earlycon", imx_keep_uart_earlycon,
> > +	      imx_keep_uart_clocks_param, 0);
> > +__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
> > +	      imx_keep_uart_clocks_param, 0);
> > +
> > +void __init imx_register_uart_clocks(struct clk ** const clks[])
> > +{
> > +	if (imx_keep_uart_clocks) {
> > +		int i;
> > +
> > +		imx_uart_clocks = clks;
> > +		for (i = 0; imx_uart_clocks[i]; i++)
> > +			clk_prepare_enable(*imx_uart_clocks[i]);
> > +	}
> > +}
> > +
> > +static int __init imx_clk_disable_uart(void)
> > +{
> > +	if (imx_keep_uart_clocks) {
> > +		int i;
> > +
> > +		for (i = 0; imx_uart_clocks[i]; i++)
> > +			clk_disable_unprepare(*imx_uart_clocks[i]);
> > +	}
> > +
> > +	return 0;
> > +}
> > +late_initcall_sync(imx_clk_disable_uart);
> 
> I bet you didn't test if this works when earlyprintk (or earlycon) is
> provided on the command line but imx_register_uart_clocks isn't called
> (e.g. because this is a Samsung CPU running a multiarch kernel).
> 
Ah, damn! Thanks for spotting.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-09-08  8:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-07 15:09 [PATCH v3 0/8] i.MX early debug UART clock fixes Lucas Stach
2015-09-07 15:09 ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 1/8] clk: imx: add common logic to detect early UART usage Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 18:52   ` Uwe Kleine-König
2015-09-07 18:52     ` Uwe Kleine-König
2015-09-08  8:51     ` Lucas Stach
2015-09-08  8:51       ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 2/8] clk: imx25: retain early UART clocks during kernel init Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 3/8] clk: imx27: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 4/8] clk: imx31: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 5/8] clk: imx35: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 6/8] clk: imx5: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 7/8] clk: imx6: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach
2015-09-07 15:09 ` [PATCH v3 8/8] clk: imx7d: " Lucas Stach
2015-09-07 15:09   ` Lucas Stach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.