From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 5/8] i.MX: serial: Add setup_uart_ll function
Date: Sat, 2 May 2015 19:26:17 -0700 [thread overview]
Message-ID: <1430619980-26243-6-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1430619980-26243-1-git-send-email-andrew.smirnov@gmail.com>
It appears that all i.MX based boards that support early debug output
inevitably do exactly the same thing with the registers of the UART
peripheral. So to avoid code duplication distill that functionality
into dedicated subroutine.
IMPORTANT: Please note that 'setup_uart_ll' function does add a slight
difference in behaviour by dropping the initialization of ONEMS and
UESC registers since those do not seem to be needed for early UART
functionality
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/mach-imx/include/mach/debug_ll.h | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
index 1c9f3a6..5b0b33b 100644
--- a/arch/arm/mach-imx/include/mach/debug_ll.h
+++ b/arch/arm/mach-imx/include/mach/debug_ll.h
@@ -30,10 +30,12 @@
#define IMX_DEBUG_SOC MX35
#elif defined CONFIG_DEBUG_IMX51_UART
#define IMX_DEBUG_SOC MX51
+#define IMX_DEBUG_UART_REFCLOCK_HZ 54000000
#elif defined CONFIG_DEBUG_IMX53_UART
#define IMX_DEBUG_SOC MX53
#elif defined CONFIG_DEBUG_IMX6Q_UART
#define IMX_DEBUG_SOC MX6
+#define IMX_DEBUG_UART_REFCLOCK_HZ 80000000
#else
#error "unknown i.MX debug uart soc type"
#endif
@@ -41,6 +43,34 @@
#define __IMX_UART_BASE(soc, num) soc##_UART##num##_BASE_ADDR
#define IMX_UART_BASE(soc, num) __IMX_UART_BASE(soc, num)
+
+#if defined IMX_DEBUG_UART_REFCLOCK_HZ
+
+static inline void setup_uart_ll(void)
+{
+ void __iomem *uartbase =
+ (void *)IMX_UART_BASE(IMX_DEBUG_SOC,
+ CONFIG_DEBUG_IMX_UART_PORT);
+
+ writel(0x00000000, uartbase + UCR1);
+
+ writel(UCR2_IRTS | UCR2_WS | UCR2_TXEN | UCR2_RXEN | UCR2_SRST,
+ uartbase + UCR2);
+ writel(UCR3_DSR | UCR3_DCD | UCR3_RI | UCR3_ADNIMP | UCR3_RXDMUXSEL,
+ uartbase + UCR3);
+ writel((0b10 << UFCR_TXTL_SHF) | UFCR_RFDIV1 | (1 << UFCR_RXTL_SHF),
+ uartbase + UFCR);
+
+ writel(baudrate_to_ubir(CONFIG_BAUDRATE),
+ uartbase + UBIR);
+ writel(refclock_to_ubmr(IMX_DEBUG_UART_REFCLOCK_HZ),
+ uartbase + UBMR);
+
+ writel(UCR1_UARTEN, uartbase + UCR1);
+}
+
+#endif
+
static inline void PUTC_LL(int c)
{
void __iomem *base = (void *)IMX_UART_BASE(IMX_DEBUG_SOC,
@@ -56,5 +86,9 @@ static inline void PUTC_LL(int c)
writel(c, base + URTX0);
}
+#else
+static inline void setup_uart_ll(void)
+{
+}
#endif /* CONFIG_DEBUG_LL */
#endif /* __MACH_DEBUG_LL_H__ */
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-05-03 2:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-03 2:26 [RFC, PATCH] i.MX: Add provisions to boot from IRAM Andrey Smirnov
2015-05-03 2:26 ` [PATCH 1/8] i.MX: Move UART definitions into a separate file Andrey Smirnov
2015-05-04 7:08 ` Sascha Hauer
2015-05-03 2:26 ` [PATCH 2/8] i.MX: serial: Add constants for UART clock divisor Andrey Smirnov
2015-05-03 2:26 ` [PATCH 3/8] i.MX: serial: Add baud rate calculation convenience functions Andrey Smirnov
2015-05-03 2:26 ` [PATCH 4/8] i.MX51: babbage: Implement CONFIG_DEBUG_LL Andrey Smirnov
2015-05-04 6:43 ` Sascha Hauer
2015-05-03 2:26 ` Andrey Smirnov [this message]
2015-05-04 6:53 ` [PATCH 5/8] i.MX: serial: Add setup_uart_ll function Sascha Hauer
2015-05-03 2:26 ` [PATCH 6/8] i.MX: serial: Convert i.MX51 and i.MX6 to use 'setup_uart_ll' Andrey Smirnov
2015-05-04 6:57 ` Sascha Hauer
2015-05-03 2:26 ` [PATCH 7/8] i.MX: serial: Distil common clock ungating code Andrey Smirnov
2015-05-04 7:01 ` Sascha Hauer
2015-05-04 18:04 ` Andrey Smirnov
2015-05-04 19:52 ` Sascha Hauer
2015-05-03 2:26 ` [PATCH 8/8] Makefile.lib: Make 'check_file_size' more flexible Andrey Smirnov
2015-05-04 7:14 ` [RFC, PATCH] i.MX: Add provisions to boot from IRAM Sascha Hauer
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=1430619980-26243-6-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/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