[PATCH v2 3/4] bsp/tms570: include complete peripheral initialization to SCI driver.

pisa at cmp.felk.cvut.cz pisa at cmp.felk.cvut.cz
Mon Jun 20 19:52:28 UTC 2016


From: Pavel Pisa <pisa at cmp.felk.cvut.cz>

Signed-off-by: Pavel Pisa <pisa at cmp.felk.cvut.cz>
---
 c/src/lib/libbsp/arm/tms570/console/tms570-sci.c | 38 ++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c b/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c
index fac258d..4464859 100644
--- a/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c
+++ b/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c
@@ -95,6 +95,40 @@ rtems_device_driver console_initialize(
     ++minor
   ) {
     tms570_sci_context *ctx = &driver_context_table[minor];
+    uint32_t rx_pin = 1 << 1;
+    uint32_t tx_pin = 1 << 2;
+
+    /* Resec SCI peripheral */
+    ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 0;
+    ctx->regs->GCR0 = TMS570_SCI_GCR0_RESET * 1;
+
+    /* Clear all interrupt sources */
+    ctx->regs->CLEARINT = 0xffffffff;
+
+    /* Map all interrupts to SCI INT0 line */
+    ctx->regs->CLEARINTLVL = 0xffffffff;
+
+    ctx->regs->GCR1 = TMS570_SCI_GCR1_TXENA * 0 |
+                      TMS570_SCI_GCR1_RXENA * 0 |
+                      TMS570_SCI_GCR1_CONT * 0 | /* continue operation when debugged */
+                      TMS570_SCI_GCR1_LOOP_BACK * 0 |
+                      TMS570_SCI_GCR1_POWERDOWN * 0 |
+                      TMS570_SCI_GCR1_SLEEP * 0 |
+                      TMS570_SCI_GCR1_SWnRST * 0 | /* reset state */
+                      TMS570_SCI_GCR1_CLOCK * 1 | /* internal clock */
+                      TMS570_SCI_GCR1_TIMING_MODE * 1 |
+                      TMS570_SCI_GCR1_COMM_MODE * 0;
+
+    /* Setup connection of SCI peripheral Rx and Tx  pins */
+    ctx->regs->PIO0 = rx_pin * 1 | tx_pin * 1; /* Rx and Tx pins are not GPIO */
+    ctx->regs->PIO3 = rx_pin * 0 | tx_pin * 0; /* Default output low  */
+    ctx->regs->PIO1 = rx_pin * 0 | tx_pin * 0; /* Input when not used by SCI */
+    ctx->regs->PIO6 = rx_pin * 0 | tx_pin * 0; /* No open drain */
+    ctx->regs->PIO7 = rx_pin * 0 | tx_pin * 0; /* Pull-up/down enabled */
+    ctx->regs->PIO8 = rx_pin * 1 | tx_pin * 1; /* Select pull-up */
+
+    /* Bring device out of software reset */
+    ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST;
 
     /*
      * Install this device in the file system and Termios.  In order
@@ -107,7 +141,7 @@ rtems_device_driver console_initialize(
         major,
         minor,
         handler,
-	NULL,
+        NULL,
         &ctx->base
     );
     if ( sc != RTEMS_SUCCESSFUL ) {
@@ -473,7 +507,7 @@ static bool tms570_sci_interrupt_first_open(
   if ( ret == false ) {
     return false;
   }
-  ctx->regs->SETINTLVL = 0;
+
   /* Register Interrupt handler */
   sc = rtems_interrupt_handler_install(ctx->irq,
       ctx->device_name,
-- 
1.9.1




More information about the devel mailing list