From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Johannes Zink <j.zink@pengutronix.de>,
Lars Pedersen <lapeddk@gmail.com>,
Bruno Thomsen <bruno.thomsen@gmail.com>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] ARM: i.MX7: don't hardcode UART1 in imx7_early_setup_uart_clock
Date: Mon, 10 Oct 2022 09:48:34 +0200 [thread overview]
Message-ID: <20221010074834.2361014-1-a.fatoum@pengutronix.de> (raw)
imx7_early_setup_uart_clock() has a very generic sounding name, but so
far only set up clocks for UART1. This can lead board code authors
astray that intend to user a different UART for DEBUG_LL.
This issue affects board code for kamstrup-mx7-concentrator, meerkat96
and zii-imx7d-dev, which use UART4, UART6 and UART2 respectively.
As I don't have this boards available to test and clock changes may have
adverse effect elsewhere, we have all existing users setup UART1 as
before, but note with a comment that this may not be the original
author's intention.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
I have CC'd authors of the three likely misconfigured boards,
in case they want to fix them and test.
---
arch/arm/boards/ac-sxb/lowlevel.c | 2 +-
.../boards/freescale-mx7-sabresd/lowlevel.c | 2 +-
.../kamstrup-mx7-concentrator/lowlevel.c | 3 ++-
arch/arm/boards/meerkat96/lowlevel.c | 3 ++-
arch/arm/boards/zii-imx7d-dev/lowlevel.c | 3 ++-
.../arm/mach-imx/include/mach/imx7-ccm-regs.h | 21 +++++++++----------
6 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/arch/arm/boards/ac-sxb/lowlevel.c b/arch/arm/boards/ac-sxb/lowlevel.c
index a910555f9bd7..a26454968304 100644
--- a/arch/arm/boards/ac-sxb/lowlevel.c
+++ b/arch/arm/boards/ac-sxb/lowlevel.c
@@ -93,7 +93,7 @@ extern char __dtb_z_ac_sxb_start[];
static inline void setup_uart(void)
{
- imx7_early_setup_uart_clock();
+ imx7_early_setup_uart_clock(1);
imx7_setup_pad(MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX);
diff --git a/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c b/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
index a8733d62091f..6d393bf2b10e 100644
--- a/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
+++ b/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
@@ -17,7 +17,7 @@ extern char __dtb_imx7d_sdb_start[];
static inline void setup_uart(void)
{
- imx7_early_setup_uart_clock();
+ imx7_early_setup_uart_clock(1);
imx7_setup_pad(MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX);
diff --git a/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c b/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c
index 4a9eae80d153..511f01757c46 100644
--- a/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c
+++ b/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c
@@ -17,7 +17,8 @@ extern char __dtb_z_imx7d_flex_concentrator_mfg_start[];
static inline void setup_uart(void)
{
- imx7_early_setup_uart_clock();
+ /* FIXME: Below UART4 is muxed, not UART1 */
+ imx7_early_setup_uart_clock(1);
imx7_setup_pad(MX7D_PAD_SAI2_TX_BCLK__UART4_DCE_TX);
diff --git a/arch/arm/boards/meerkat96/lowlevel.c b/arch/arm/boards/meerkat96/lowlevel.c
index 1c9baeacfb2a..e65726ef1c27 100644
--- a/arch/arm/boards/meerkat96/lowlevel.c
+++ b/arch/arm/boards/meerkat96/lowlevel.c
@@ -14,7 +14,8 @@ extern char __dtb_z_imx7d_meerkat96_start[];
static void setup_uart(void)
{
- imx7_early_setup_uart_clock();
+ /* FIXME: Below UART6 is muxed, not UART1 */
+ imx7_early_setup_uart_clock(1);
imx7_setup_pad(MX7D_PAD_SD1_WP__UART6_DCE_TX);
imx7_uart_setup_ll();
putc_ll('>');
diff --git a/arch/arm/boards/zii-imx7d-dev/lowlevel.c b/arch/arm/boards/zii-imx7d-dev/lowlevel.c
index 7579a2a8a050..0e316b602436 100644
--- a/arch/arm/boards/zii-imx7d-dev/lowlevel.c
+++ b/arch/arm/boards/zii-imx7d-dev/lowlevel.c
@@ -23,7 +23,8 @@ extern char __dtb_z_imx7d_zii_rmu2_start[];
static inline void setup_uart(void)
{
- imx7_early_setup_uart_clock();
+ /* FIXME: Below UART2 is muxed, not UART1 */
+ imx7_early_setup_uart_clock(1);
imx7_setup_pad(MX7D_PAD_UART2_TX_DATA__UART2_DCE_TX);
diff --git a/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h b/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
index aecf9a26d017..0ef0742bb65d 100644
--- a/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
@@ -39,16 +39,15 @@
#define IMX7_CCM_CCGR_SETTINGn_NEEDED_RUN_WAIT(n) IMX7_CCM_CCGR_SETTINGn(n, 0b10)
#define IMX7_CCM_CCGR_SETTINGn_NEEDED(n) IMX7_CCM_CCGR_SETTINGn(n, 0b11)
-static inline void imx7_early_setup_uart_clock(void)
-{
- void __iomem *ccm = IOMEM(MX7_CCM_BASE_ADDR);
-
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_CLR(IMX7_CCM_CCGR_UART1));
- writel(IMX7_CCM_TARGET_ROOTn_ENABLE | IMX7_UART1_CLK_ROOT__OSC_24M,
- ccm + IMX7_CCM_TARGET_ROOTn(IMX7_UART1_CLK_ROOT));
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_SET(IMX7_CCM_CCGR_UART1));
-}
+/* UART counting starts for 1, like in the datasheet/dt-bindings */
+#define imx7_early_setup_uart_clock(uart) do { \
+ void __iomem *ccm = IOMEM(MX7_CCM_BASE_ADDR); \
+ writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0), \
+ ccm + IMX7_CCM_CCGRn_CLR(IMX7_CCM_CCGR_UART ## uart)); \
+ writel(IMX7_CCM_TARGET_ROOTn_ENABLE | IMX7_UART ## uart ## _CLK_ROOT__OSC_24M, \
+ ccm + IMX7_CCM_TARGET_ROOTn(IMX7_UART ## uart ## _CLK_ROOT)); \
+ writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0), \
+ ccm + IMX7_CCM_CCGRn_SET(IMX7_CCM_CCGR_UART ## uart)); \
+} while (0)
#endif
--
2.30.2
next reply other threads:[~2022-10-10 7:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 7:48 Ahmad Fatoum [this message]
2022-10-12 12:32 ` Sascha Hauer
2022-10-27 18:35 ` Bruno Thomsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221010074834.2361014-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=bruno.thomsen@gmail.com \
--cc=j.zink@pengutronix.de \
--cc=lapeddk@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox