From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/5] debug_ll: Add ns16550 early debugging functions
Date: Wed, 6 Mar 2019 10:42:37 +0100 [thread overview]
Message-ID: <20190306094239.29413-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190306094239.29413-1-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/debug_ll/ns16550.h | 56 ++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 include/debug_ll/ns16550.h
diff --git a/include/debug_ll/ns16550.h b/include/debug_ll/ns16550.h
new file mode 100644
index 0000000000..7e4dbeb453
--- /dev/null
+++ b/include/debug_ll/ns16550.h
@@ -0,0 +1,56 @@
+#ifndef __DEBUG_LL_NS16550_H
+#define __DEBUG_LL_NS16550_H
+
+/*
+ * Early debugging functions for the NS16550
+ * This file needs register access functions declared as:
+ *
+ * uint8_t debug_ll_read_reg(int reg);
+ * void debug_ll_write_reg(int reg, uint8_t val);
+ */
+#define NS16550_THR 0x0
+#define NS16550_RBR 0x0
+#define NS16550_DLL 0x0
+#define NS16550_IER 0x1
+#define NS16550_DLM 0x1
+#define NS16550_FCR 0x2
+#define NS16550_LCR 0x3
+#define NS16550_MCR 0x4
+#define NS16550_LSR 0x5
+
+#define NS16550_LCR_VAL 0x3 /* 8 data, 1 stop, no parity */
+#define NS16550_MCR_VAL 0x3 /* RTS/DTR */
+#define NS16550_FCR_VAL 0x7 /* Clear & enable FIFOs */
+
+#define NS16550_LSR_DR 0x01 /* UART received data present */
+#define NS16550_LSR_THRE 0x20 /* Xmit holding register empty */
+
+#define NS16550_LCR_BKSE 0x80 /* Bank select enable */
+
+static inline void PUTC_LL(char ch)
+{
+ while (!(debug_ll_read_reg(NS16550_LSR) & NS16550_LSR_THRE))
+ ;
+
+ debug_ll_write_reg(NS16550_THR, ch);
+}
+
+static inline uint16_t debug_ll_ns16550_calc_divisor(unsigned long clk)
+{
+ return clk / (115200 * 16);
+}
+
+static inline void debug_ll_ns16550_init(uint16_t divisor)
+{
+ debug_ll_write_reg(NS16550_LCR, 0x0); /* select ier reg */
+ debug_ll_write_reg(0x00, NS16550_IER);
+
+ debug_ll_write_reg(NS16550_LCR, NS16550_LCR_BKSE);
+ debug_ll_write_reg(NS16550_DLL, divisor & 0xff);
+ debug_ll_write_reg(NS16550_DLM, (divisor >> 8) & 0xff);
+ debug_ll_write_reg(NS16550_LCR, NS16550_LCR_VAL);
+ debug_ll_write_reg(NS16550_MCR, NS16550_MCR_VAL);
+ debug_ll_write_reg(NS16550_FCR, NS16550_FCR_VAL);
+}
+
+#endif
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-03-06 9:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 9:42 [PATCH 0/5] ARM: rpi: refactor debug_ll Sascha Hauer
2019-03-06 9:42 ` [PATCH 1/5] ARM: rpi: Move UART base address definitions to header file Sascha Hauer
2019-03-06 9:42 ` [PATCH 2/5] debug_ll: Move pl011 header file to architecture independent place Sascha Hauer
2019-03-06 9:42 ` Sascha Hauer [this message]
2019-03-06 9:42 ` [PATCH 4/5] ARM: rpi: move debug UART Kconfig settings Sascha Hauer
2019-03-07 9:52 ` Tomaž Šolc
2019-03-06 9:42 ` [PATCH 5/5] ARM: rpi: Add mini UART debug_ll support Sascha Hauer
2019-03-07 9:52 ` Tomaž Šolc
2019-03-07 13:24 ` Sascha Hauer
2019-03-07 13:32 ` [HELP] Kernel + initrd in FIT Seraphim Dolbilov
2019-03-11 7:25 ` Sascha Hauer
2019-03-07 10:00 ` [PATCH 0/5] ARM: rpi: refactor debug_ll Tomaž Šolc
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=20190306094239.29413-4-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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