[rtems commit] bsp/imx: Add UART baud change

Sebastian Huber sebh at rtems.org
Wed Nov 8 07:45:01 UTC 2017


Module:    rtems
Branch:    master
Commit:    fdf0e55cf929aba409e19c4692a73b6522f2a51e
Changeset: http://git.rtems.org/rtems/commit/?id=fdf0e55cf929aba409e19c4692a73b6522f2a51e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov  8 08:42:33 2017 +0100

bsp/imx: Add UART baud change

Update #3090.

---

 c/src/lib/libbsp/arm/imx/console/console-config.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/c/src/lib/libbsp/arm/imx/console/console-config.c b/c/src/lib/libbsp/arm/imx/console/console-config.c
index 5cceb9c..0731446 100644
--- a/c/src/lib/libbsp/arm/imx/console/console-config.c
+++ b/c/src/lib/libbsp/arm/imx/console/console-config.c
@@ -23,6 +23,7 @@
 #include <bsp/fdt.h>
 #include <bsp/irq.h>
 
+#include <arm/freescale/imx/imx_ccmvar.h>
 #include <arm/freescale/imx/imx_uartreg.h>
 
 #include <libfdt.h>
@@ -192,6 +193,24 @@ static bool imx_uart_set_attributes(
   const struct termios *term
 )
 {
+  imx_uart_context *ctx;
+  volatile imx_uart *regs;
+  uint32_t ufcr;
+  uint32_t baud;
+
+  ctx = (imx_uart_context *) base;
+  regs = imx_uart_get_regs(&ctx->base);
+
+  baud = rtems_termios_baud_to_number(term->c_ospeed);
+
+  if (baud != 0) {
+    ufcr = regs->ufcr;
+    ufcr = IMX_UART_UFCR_RFDIV_SET(ufcr, 0x5);
+    regs->ufcr = ufcr;
+    regs->ubir = 15;
+    regs->ubmr = imx_ccm_uart_hz() / baud - 1;
+  }
+
   return true;
 }
 



More information about the vc mailing list