diff --git a/arch/arm/include/tms570/tms570ls04x03x_irq.h b/arch/arm/include/tms570/tms570ls04x03x_irq.h index b567e26db0..6e19a7bfaf 100644 --- a/arch/arm/include/tms570/tms570ls04x03x_irq.h +++ b/arch/arm/include/tms570/tms570ls04x03x_irq.h @@ -69,7 +69,7 @@ #define TMS570_REQ_N2HET_0 10 /* N2HET level 0 interrupt */ #define TMS570_REQ_HTU_0 11 /* HTU level 0 interrupt */ #define TMS570_REQ_MIBSPI1_0 12 /* MIBSPI1 level 0 interrupt */ -#define TMS570_REQ_SCI_0 13 /* SCI/LIN level 0 interrupt */ +#define TMS570_REQ_SCI1_0 13 /* SCI1/LIN1 level 0 interrupt */ #define TMS570_REQ_MIBADCEV 14 /* MIBADC event group interrupt */ #define TMS570_REQ_MIBADSW1 15 /* MIBADC sw group 1 interrupt */ #define TMS570_REQ_DCAN1_0 16 /* DCAN1 level 0 interrupt */ @@ -81,7 +81,7 @@ #define TMS570_REQ_N2HET_1 24 /* N2HET level 1 interrupt */ #define TMS570_REQ_HTU_1 25 /* HTU level 1 interrupt */ #define TMS570_REQ_MIBSPI1_1 26 /* MIBSPI1 level 1 interrupt */ -#define TMS570_REQ_SCI_1 27 /* SCI/LIN level 1 interrupt */ +#define TMS570_REQ_SCI1_1 27 /* SCI1/LIN1 level 1 interrupt */ #define TMS570_REQ_MIBADCSW2 28 /* MIBADC sw group 2 interrupt */ #define TMS570_REQ_DCAN1_1 29 /* DCAN1 level 1 interrupt */ #define TMS570_REQ_SPI2_1 30 /* SPI2 level 1 interrupt */ diff --git a/arch/arm/src/tms570/Make.defs b/arch/arm/src/tms570/Make.defs index 5d45635bb8..0c6c3ee261 100644 --- a/arch/arm/src/tms570/Make.defs +++ b/arch/arm/src/tms570/Make.defs @@ -99,7 +99,8 @@ CHIP_ASRCS = # SAMA5-specific C source files -CHIP_CSRCS = tms570_boot.c tms570_clockconfig.c tms570_irq.c tms570_lowputc.c +CHIP_CSRCS = tms570_boot.c tms570_clockconfig.c tms570_irq.c +CHIP_CSRCS += tms570_lowputc.c tms570_serial.c # Configuration dependent C and assembly language files diff --git a/arch/arm/src/tms570/chip/tms570_sci.h b/arch/arm/src/tms570/chip/tms570_sci.h index 29dceda853..1cbfdb7718 100644 --- a/arch/arm/src/tms570/chip/tms570_sci.h +++ b/arch/arm/src/tms570/chip/tms570_sci.h @@ -250,8 +250,10 @@ #define SCI_INT_PBE (1 << 30) /* Bit 30: Physical bus error interrupt */ #define SCI_INT_BE (1 << 31) /* Bit 31: Bit error interrupt */ -#define SCI_INT_ALLERRORS 0xff000000 -#define SCI_INT_ALL 0xff0023d3 +#define SCI_INT_ALLERRORS 0xff000001 +#define SCI_INT_LINERRORS 0xff000000 +#define SCI_INT_SCIERRORS 0x87000001 +#define SCI_INT_ALLINTS 0xff0023d3 /* SCI Flags Register */ diff --git a/arch/arm/src/tms570/tms570_lowputc.c b/arch/arm/src/tms570/tms570_lowputc.c index 3eab5654c1..b97468d06d 100644 --- a/arch/arm/src/tms570/tms570_lowputc.c +++ b/arch/arm/src/tms570/tms570_lowputc.c @@ -297,8 +297,8 @@ int tms570_sci_configure(uint32_t base, FAR const struct sci_config_s *config) /* Disable all interrupts and map them all to INT0 */ - putreg32(SCI_INT_ALL, base + TMS570_SCI_CLEARINT_OFFSET); - putreg32(SCI_INT_ALL, base + TMS570_SCI_CLEARINTLVL_OFFSET); + putreg32(SCI_INT_ALLINTS, base + TMS570_SCI_CLEARINT_OFFSET); + putreg32(SCI_INT_ALLINTS, base + TMS570_SCI_CLEARINTLVL_OFFSET); /* Global control 1: * COMM=0 Idle line mode is used. diff --git a/arch/arm/src/tms570/tms570_serial.c b/arch/arm/src/tms570/tms570_serial.c index b4e9d1bb1f..ab176f91bc 100644 --- a/arch/arm/src/tms570/tms570_serial.c +++ b/arch/arm/src/tms570/tms570_serial.c @@ -63,6 +63,7 @@ #include "up_internal.h" #include "chip/tms570_sci.h" +#include "tms570_lowputc.h" /**************************************************************************** * Pre-processor Definitions @@ -131,20 +132,19 @@ struct tms570_dev_s { const uint32_t scibase; /* Base address of SCI registers */ struct sci_config_s config; /* SCI configuration */ - xcpt_t handler; /* Interrupt handler */ - uint32_t sr; /* Saved status bits */ - uint8_t irq; /* IRQ associated with this SCI */ + xcpt_t handler; /* Interrupt handler */ + uint8_t irq; /* IRQ associated with this SCI */ }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int tms570_setup(struct sci_dev_s *dev); -static void tms570_shutdown(struct sci_dev_s *dev); -static int tms570_attach(struct sci_dev_s *dev); -static void tms570_detach(struct sci_dev_s *dev); -static int tms570_interrupt(struct sci_dev_s *dev); +static int tms570_setup(struct uart_dev_s *dev); +static void tms570_shutdown(struct uart_dev_s *dev); +static int tms570_attach(struct uart_dev_s *dev); +static void tms570_detach(struct uart_dev_s *dev); +static int tms570_interrupt(struct uart_dev_s *dev); #ifdef CONFIG_TMS570_SCI1 static int tms570_sci1_interrupt(int irq, void *context); #endif @@ -152,19 +152,19 @@ static int tms570_sci1_interrupt(int irq, void *context); static int tms570_sci2_interrupt(int irq, void *context); #endif static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg); -static int tms570_receive(struct sci_dev_s *dev, uint32_t *status); -static void tms570_rxint(struct sci_dev_s *dev, bool enable); -static bool tms570_rxavailable(struct sci_dev_s *dev); -static void tms570_send(struct sci_dev_s *dev, int ch); -static void tms570_txint(struct sci_dev_s *dev, bool enable); -static bool tms570_txready(struct sci_dev_s *dev); -static bool tms570_txempty(struct sci_dev_s *dev); +static int tms570_receive(struct uart_dev_s *dev, uint32_t *status); +static void tms570_rxint(struct uart_dev_s *dev, bool enable); +static bool tms570_rxavailable(struct uart_dev_s *dev); +static void tms570_send(struct uart_dev_s *dev, int ch); +static void tms570_txint(struct uart_dev_s *dev, bool enable); +static bool tms570_txready(struct uart_dev_s *dev); +static bool tms570_txempty(struct uart_dev_s *dev); /**************************************************************************** * Private Variables ****************************************************************************/ -static const struct sci_ops_s g_sci_ops = +static const struct uart_ops_s g_sci_ops = { .setup = tms570_setup, .shutdown = tms570_shutdown, @@ -205,13 +205,13 @@ static struct tms570_dev_s g_sci1priv = .baud = CONFIG_SCI1_BAUD, .parity = CONFIG_SCI1_PARITY, .bits = CONFIG_SCI1_BITS, - .stopbit = CONFIG_SCI1_2STOP, - } + .stopbits2 = CONFIG_SCI1_2STOP, + }, .handler = tms570_sci1_interrupt, - .irq = TMS570_IRQ_SCI1, + .irq = TMS570_REQ_SCI1_0, }; -static sci_dev_t g_sci1port = +static uart_dev_t g_sci1port = { .recv = { @@ -239,13 +239,13 @@ static struct tms570_dev_s g_sci2priv = .baud = CONFIG_SCI2_BAUD, .parity = CONFIG_SCI2_PARITY, .bits = CONFIG_SCI2_BITS, - .stopbit = CONFIG_SCI2_2STOP, - } + .stopbits2 = CONFIG_SCI2_2STOP, + }, .handler = tms570_sci2_interrupt, - .irq = TMS570_IRQ_SCI2, + .irq = TMS570_REQ_SCI2_0, }; -static sci_dev_t g_sci2port = +static uart_dev_t g_sci2port = { .recv = { @@ -290,34 +290,34 @@ static inline void tms570_serialout(struct tms570_dev_s *priv, int offset, ****************************************************************************/ static inline void tms570_restoresciint(struct tms570_dev_s *priv, - uint32_t imr) + uint32_t ints) { /* Restore the previous interrupt state (assuming all interrupts disabled) */ - tms570_serialout(priv, TMS570_SCI_IER_OFFSET, imr); + tms570_serialout(priv, TMS570_SCI_SETINT_OFFSET, ints); } /**************************************************************************** * Name: tms570_disableallints ****************************************************************************/ -static void tms570_disableallints(struct tms570_dev_s *priv, uint32_t *imr) +static void tms570_disableallints(struct tms570_dev_s *priv, uint32_t *ints) { irqstate_t flags; /* The following must be atomic */ flags = irqsave(); - if (imr) + if (ints) { - /* Return the current interrupt mask */ + /* Return the current enable bitsopop9 */ - *imr = tms570_serialin(priv, TMS570_SCI_IMR_OFFSET); + *ints = tms570_serialin(priv, TMS570_SCI_SETINT_OFFSET); } /* Disable all interrupts */ - tms570_serialout(priv, TMS570_SCI_IDR_OFFSET, SCI_INT_ALLINTS); + tms570_serialout(priv, TMS570_SCI_CLEARINT_OFFSET, SCI_INT_ALLINTS); irqrestore(flags); } @@ -330,14 +330,14 @@ static void tms570_disableallints(struct tms570_dev_s *priv, uint32_t *imr) * ****************************************************************************/ -static int tms570_setup(struct sci_dev_s *dev) +static int tms570_setup(struct uart_dev_s *dev) { #ifndef CONFIG_SUPPRESS_SCI_CONFIG struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; /* Configure baud, number of bits, stop bits, and parity */ - return tms570_sci_configure(priv->base, &priv->config); + return tms570_sci_configure(priv->scibase, &priv->config); #else return OK; #endif @@ -352,15 +352,13 @@ static int tms570_setup(struct sci_dev_s *dev) * ****************************************************************************/ -static void tms570_shutdown(struct sci_dev_s *dev) +static void tms570_shutdown(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; /* Reset and disable receiver and transmitter */ - tms570_serialout(priv, TMS570_SCI_CR_OFFSET, - (SCI_CR_RSTRX | SCI_CR_RSTTX | SCI_CR_RXDIS | - SCI_CR_TXDIS)); + tms570_serialout(priv, TMS570_SCI_GCR1_OFFSET, 0); /* Disable all interrupts */ @@ -382,7 +380,7 @@ static void tms570_shutdown(struct sci_dev_s *dev) * ****************************************************************************/ -static int tms570_attach(struct sci_dev_s *dev) +static int tms570_attach(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; int ret; @@ -412,7 +410,7 @@ static int tms570_attach(struct sci_dev_s *dev) * ****************************************************************************/ -static void tms570_detach(struct sci_dev_s *dev) +static void tms570_detach(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; up_disable_irq(priv->irq); @@ -430,7 +428,7 @@ static void tms570_detach(struct sci_dev_s *dev) * ****************************************************************************/ -static int tms570_interrupt(struct sci_dev_s *dev) +static int tms570_interrupt(struct uart_dev_s *dev) { struct tms570_dev_s *priv; uint32_t intvec; @@ -453,7 +451,7 @@ static int tms570_interrupt(struct sci_dev_s *dev) switch (intvec) { case SCI_INTVECT_NONE: /* No interrupt */ - return; + return OK; case SCI_INTVECT_WAKEUP: /* Wake-up interrupt */ /* SCI sets the WAKEUP flag if bus activity on the RX line @@ -461,19 +459,24 @@ static int tms570_interrupt(struct sci_dev_s *dev) * line activity causes an exit from power-down mode. If * enabled wakeup interrupt is triggered once WAKEUP flag is * set. + * + * REVISIT: This interrupt is ignored because for now the + * break detect interrupt is never enabled. */ -#warning Missing Logic break; - /* SCI Errors */ + /* SCI Errors + * + * REVISIT: These error interrupta are ignored because for now the + * break detect interrupt is never enabled. + */ case SCI_INTVECT_PE: /* Parity error interrupt */ case SCI_INTVECT_FE: /* Framing error interrupt */ - case SCI_INTVECT_BRKDT: /* Break detect interrupt */ case SCI_INTVECT_OE: /* Overrun error interrupt */ + case SCI_INTVECT_BRKDT: /* Break detect interrupt */ case SCI_INTVECT_BE: /* Bit error interrupt */ -#warning Missing Logic break; case SCI_INTVECT_RX: /* Receive interrupt */ @@ -544,7 +547,7 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg) { #if defined(CONFIG_SERIAL_TERMIOS) || defined(CONFIG_SERIAL_TIOCSERGSTRUCT) struct inode *inode = filep->f_inode; - struct sci_dev_s *dev = inode->i_private; + struct uart_dev_s *dev = inode->i_private; #endif int ret = OK; @@ -624,7 +627,7 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg) struct termios *termiosp = (struct termios *)arg; struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; uint32_t baud; - uint32_t imr; + uint32_t ints; uint8_t parity; uint8_t nbits; bool stop2; @@ -699,12 +702,12 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg) * implement TCSADRAIN / TCSAFLUSH */ - tms570_disableallints(priv, &imr); + tms570_disableallints(priv, &ints); ret = tms570_sci_configure(priv->scibase, &priv->config); /* Restore the interrupt state */ - tms570_restoresciint(priv, imr); + tms570_restoresciint(priv, ints); } } break; @@ -728,18 +731,20 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg) * ****************************************************************************/ -static int tms570_receive(struct sci_dev_s *dev, uint32_t *status) +static int tms570_receive(struct uart_dev_s *dev, uint32_t *status) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; - /* Return the error information in the saved status */ + /* Return the error information in the saved status. + * + * REVISIT: RX error information is not currently retained. + */ - *status = priv->sr; - priv->sr = 0; + *status = 0; /* Then return the actual received byte */ - return (int)(tms570_serialin(priv, TMS570_SCI_RHR_OFFSET) & 0xff); + return (int)(tms570_serialin(priv, TMS570_SCI_RD_OFFSET) & 0xff); } /**************************************************************************** @@ -750,7 +755,7 @@ static int tms570_receive(struct sci_dev_s *dev, uint32_t *status) * ****************************************************************************/ -static void tms570_rxint(struct sci_dev_s *dev, bool enable) +static void tms570_rxint(struct uart_dev_s *dev, bool enable) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; @@ -761,12 +766,12 @@ static void tms570_rxint(struct sci_dev_s *dev, bool enable) */ #ifndef CONFIG_SUPPRESS_SERIAL_INTS - tms570_serialout(priv, TMS570_SCI_IER_OFFSET, SCI_INT_RXRDY); + tms570_serialout(priv, TMS570_SCI_SETINT_OFFSET, SCI_INT_RX); #endif } else { - tms570_serialout(priv, TMS570_SCI_IDR_OFFSET, SCI_INT_RXRDY); + tms570_serialout(priv, TMS570_SCI_CLEARINT_OFFSET, SCI_INT_RX); } } @@ -778,10 +783,10 @@ static void tms570_rxint(struct sci_dev_s *dev, bool enable) * ****************************************************************************/ -static bool tms570_rxavailable(struct sci_dev_s *dev) +static bool tms570_rxavailable(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; - return ((tms570_serialin(priv, TMS570_SCI_SR_OFFSET) & SCI_INT_RXRDY) != 0); + return ((tms570_serialin(priv, TMS570_SCI_FLR_OFFSET) & SCI_FLR_RXRDY) != 0); } /**************************************************************************** @@ -792,10 +797,10 @@ static bool tms570_rxavailable(struct sci_dev_s *dev) *- ****************************************************************************/ -static void tms570_send(struct sci_dev_s *dev, int ch) +static void tms570_send(struct uart_dev_s *dev, int ch) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; - tms570_serialout(priv, TMS570_SCI_THR_OFFSET, (uint32_t)ch); + tms570_serialout(priv, TMS570_SCI_TD_OFFSET, (uint32_t)ch); } /**************************************************************************** @@ -806,7 +811,7 @@ static void tms570_send(struct sci_dev_s *dev, int ch) * ****************************************************************************/ -static void tms570_txint(struct sci_dev_s *dev, bool enable) +static void tms570_txint(struct uart_dev_s *dev, bool enable) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; irqstate_t flags; @@ -819,21 +824,20 @@ static void tms570_txint(struct sci_dev_s *dev, bool enable) */ #ifndef CONFIG_SUPPRESS_SERIAL_INTS - tms570_serialout(priv, TMS570_SCI_IER_OFFSET, SCI_INT_TXRDY); + tms570_serialout(priv, TMS570_SCI_SETINT_OFFSET, SCI_INT_TX); - /* Fake a TX interrupt here by just calling sci_xmitchars() with + /* Fake a TX interrupt here by just calling uart_xmitchars() with * interrupts disabled (note this may recurse). */ - sci_xmitchars(dev); - + uart_xmitchars(dev); #endif } else { /* Disable the TX interrupt */ - tms570_serialout(priv, TMS570_SCI_IDR_OFFSET, SCI_INT_TXRDY); + tms570_serialout(priv, TMS570_SCI_CLEARINT_OFFSET, SCI_INT_TX); } irqrestore(flags); @@ -847,10 +851,10 @@ static void tms570_txint(struct sci_dev_s *dev, bool enable) * ****************************************************************************/ -static bool tms570_txready(struct sci_dev_s *dev) +static bool tms570_txready(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; - return ((tms570_serialin(priv, TMS570_SCI_SR_OFFSET) & SCI_INT_TXRDY) != 0); + return ((tms570_serialin(priv, TMS570_SCI_FLR_OFFSET) & SCI_FLR_TXRDY) != 0); } /**************************************************************************** @@ -861,10 +865,10 @@ static bool tms570_txready(struct sci_dev_s *dev) * ****************************************************************************/ -static bool tms570_txempty(struct sci_dev_s *dev) +static bool tms570_txempty(struct uart_dev_s *dev) { struct tms570_dev_s *priv = (struct tms570_dev_s *)dev->priv; - return ((tms570_serialin(priv, TMS570_SCI_SR_OFFSET) & SCI_INT_TXEMPTY) != 0); + return ((tms570_serialin(priv, TMS570_SCI_FLR_OFFSET) & SCI_FLR_TXEMPTY) != 0); } /**************************************************************************** @@ -896,14 +900,14 @@ void up_serialinit(void) /* Register the console */ - (void)sci_register("/dev/console", &CONSOLE_DEV); + (void)uart_register("/dev/console", &CONSOLE_DEV); #endif /* Register all SCIs */ - (void)sci_register("/dev/ttyS0", &TTYS0_DEV); + (void)uart_register("/dev/ttyS0", &TTYS0_DEV); #ifdef TTYS1_DEV - (void)sci_register("/dev/ttyS1", &TTYS1_DEV); + (void)uart_register("/dev/ttyS1", &TTYS1_DEV); #endif }