diff mbox series

[U-Boot,v4,3/8] pico-imx7d: Correct uart clock root

Message ID 1557297516-18616-4-git-send-email-jun.nie@linaro.org
State Accepted
Commit 79fcbde8eb57a0dfc9761c4ba167186843d7a707
Delegated to: Stefano Babic
Headers show
Series pico-imx7d: Add support for BL33 case | expand

Commit Message

Jun Nie May 8, 2019, 6:38 a.m. UTC
Correct uart clock root ID. Incorrect ID may result the
clock is gated because rate value 0 is returned in
imx_get_uartclk()

The ID can be ignored if CONFIG_SKIP_LOWLEVEL_INIT is not enabled
because init_clk_uart() will enable all uart clocks in that case.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
---
 arch/arm/include/asm/arch-mx7/clock.h | 18 ++++++++++++++++++
 arch/arm/mach-imx/mx7/clock.c         |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Fabio Estevam May 30, 2019, 11:56 p.m. UTC | #1
On Wed, May 8, 2019 at 3:39 AM Jun Nie <jun.nie@linaro.org> wrote:

> +#if (CONFIG_CONS_INDEX == 0)
> +#define UART_CLK_ROOT UART1_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 1)
> +#define UART_CLK_ROOT UART2_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 2)
> +#define UART_CLK_ROOT UART3_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 3)
> +#define UART_CLK_ROOT UART4_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 4)
> +#define UART_CLK_ROOT UART5_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 5)
> +#define UART_CLK_ROOT UART6_CLK_ROOT
> +#elif (CONFIG_CONS_INDEX == 6)
> +#define UART_CLK_ROOT UART7_CLK_ROOT

I remember I commented about this before: this looks ugly.

We don't do this on other i.MX devices.
Jun Nie May 31, 2019, 3:26 a.m. UTC | #2
Fabio Estevam <festevam@gmail.com> 于2019年5月31日周五 上午7:56写道:
>
> On Wed, May 8, 2019 at 3:39 AM Jun Nie <jun.nie@linaro.org> wrote:
>
> > +#if (CONFIG_CONS_INDEX == 0)
> > +#define UART_CLK_ROOT UART1_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 1)
> > +#define UART_CLK_ROOT UART2_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 2)
> > +#define UART_CLK_ROOT UART3_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 3)
> > +#define UART_CLK_ROOT UART4_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 4)
> > +#define UART_CLK_ROOT UART5_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 5)
> > +#define UART_CLK_ROOT UART6_CLK_ROOT
> > +#elif (CONFIG_CONS_INDEX == 6)
> > +#define UART_CLK_ROOT UART7_CLK_ROOT
>
> I remember I commented about this before: this looks ugly.
>
> We don't do this on other i.MX devices.

I thought this can be removed if dts is enabled, but no actually. I
will find another solution for this. Thanks!
Stefano Babic June 10, 2019, 9:19 a.m. UTC | #3
> Correct uart clock root ID. Incorrect ID may result the
> clock is gated because rate value 0 is returned in
> imx_get_uartclk()
> The ID can be ignored if CONFIG_SKIP_LOWLEVEL_INIT is not enabled
> because init_clk_uart() will enable all uart clocks in that case.
> Signed-off-by: Jun Nie <jun.nie@linaro.org>

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/include/asm/arch-mx7/clock.h b/arch/arm/include/asm/arch-mx7/clock.h
index f56564e..1d07fde 100644
--- a/arch/arm/include/asm/arch-mx7/clock.h
+++ b/arch/arm/include/asm/arch-mx7/clock.h
@@ -175,6 +175,24 @@  enum clk_root_index {
 	CLK_ROOT_MAX,
 };
 
+#if (CONFIG_CONS_INDEX == 0)
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 1)
+#define UART_CLK_ROOT UART2_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 2)
+#define UART_CLK_ROOT UART3_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 3)
+#define UART_CLK_ROOT UART4_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 4)
+#define UART_CLK_ROOT UART5_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 5)
+#define UART_CLK_ROOT UART6_CLK_ROOT
+#elif (CONFIG_CONS_INDEX == 6)
+#define UART_CLK_ROOT UART7_CLK_ROOT
+#else
+#error "Invalid IMX UART ID for serial console is defined"
+#endif
+
 struct clk_root_setting {
 	enum clk_root_index root;
 	u32 setting;
diff --git a/arch/arm/mach-imx/mx7/clock.c b/arch/arm/mach-imx/mx7/clock.c
index 8cda71c..e364b16 100644
--- a/arch/arm/mach-imx/mx7/clock.c
+++ b/arch/arm/mach-imx/mx7/clock.c
@@ -53,7 +53,7 @@  static u32 get_ipg_clk(void)
 
 u32 imx_get_uartclk(void)
 {
-	return get_root_clk(UART1_CLK_ROOT);
+	return get_root_clk(UART_CLK_ROOT);
 }
 
 u32 imx_get_fecclk(void)