Skip to content
Snippets Groups Projects
Commit fc83c927 authored by Jean-Christophe PLAGNIOL-VILLARD's avatar Jean-Christophe PLAGNIOL-VILLARD Committed by Nobuhiro Iwamatsu
Browse files

sh: serial: use readx/writex accessors

parent 9e1fa628
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <common.h> #include <common.h>
#include <asm/io.h>
#include <asm/processor.h> #include <asm/processor.h>
#if defined(CONFIG_CONS_SCIF0) #if defined(CONFIG_CONS_SCIF0)
...@@ -132,17 +133,17 @@ void serial_setbrg(void) ...@@ -132,17 +133,17 @@ void serial_setbrg(void)
{ {
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
*SCBRR = SCBRR_VALUE(gd->baudrate, CONFIG_SYS_CLK_FREQ); writeb(SCBRR_VALUE(gd->baudrate, CONFIG_SYS_CLK_FREQ), SCBRR);
} }
int serial_init(void) int serial_init(void)
{ {
*SCSCR = (SCR_RE | SCR_TE); writew((SCR_RE | SCR_TE), SCSCR);
*SCSMR = 0; writew(0, SCSMR);
*SCSMR = 0; writew(0, SCSMR);
*SCFCR = (FCR_RFRST | FCR_TFRST); writew((FCR_RFRST | FCR_TFRST), SCFCR);
*SCFCR; readw(SCFCR);
*SCFCR = 0; writew(0, SCFCR);
serial_setbrg(); serial_setbrg();
return 0; return 0;
...@@ -151,9 +152,9 @@ int serial_init(void) ...@@ -151,9 +152,9 @@ int serial_init(void)
static int serial_rx_fifo_level(void) static int serial_rx_fifo_level(void)
{ {
#if defined(SCRFDR) #if defined(SCRFDR)
return (*SCRFDR >> 0) & FIFOLEVEL_MASK; return (readw(SCRFDR) >> 0) & FIFOLEVEL_MASK;
#else #else
return (*SCFDR >> 0) & FIFOLEVEL_MASK; return (readw(SCFDR) >> 0) & FIFOLEVEL_MASK;
#endif #endif
} }
...@@ -162,15 +163,15 @@ void serial_raw_putc(const char c) ...@@ -162,15 +163,15 @@ void serial_raw_putc(const char c)
unsigned int fsr_bits_to_clear; unsigned int fsr_bits_to_clear;
while (1) { while (1) {
if (*SCFSR & FSR_TEND) { /* Tx fifo is empty */ if (readw(SCFSR) & FSR_TEND) { /* Tx fifo is empty */
fsr_bits_to_clear = FSR_TEND; fsr_bits_to_clear = FSR_TEND;
break; break;
} }
} }
*SCFTDR = c; writeb(c, SCFTDR);
if (fsr_bits_to_clear != 0) if (fsr_bits_to_clear != 0)
*SCFSR &= ~fsr_bits_to_clear; writew(readw(SCFSR) & ~fsr_bits_to_clear, SCFSR);
} }
void serial_putc(const char c) void serial_putc(const char c)
...@@ -196,22 +197,21 @@ int serial_tstc(void) ...@@ -196,22 +197,21 @@ int serial_tstc(void)
#define RDRF_CLEAR 0x00fc #define RDRF_CLEAR 0x00fc
void handle_error(void) void handle_error(void)
{ {
readw(SCFSR);
(void)*SCFSR; writew(FSR_ERR_CLEAR, SCFSR);
*SCFSR = FSR_ERR_CLEAR; readw(SCLSR);
(void)*SCLSR; writew(0x00, SCLSR);
*SCLSR = 0x00;
} }
int serial_getc_check(void) int serial_getc_check(void)
{ {
unsigned short status; unsigned short status;
status = *SCFSR; status = readw(SCFSR);
if (status & (FSR_FER | FSR_ER | FSR_BRK)) if (status & (FSR_FER | FSR_ER | FSR_BRK))
handle_error(); handle_error();
if (*SCLSR & LSR_ORER) if (readw(SCLSR) & LSR_ORER)
handle_error(); handle_error();
return status & (FSR_DR | FSR_RDF); return status & (FSR_DR | FSR_RDF);
} }
...@@ -224,15 +224,15 @@ int serial_getc(void) ...@@ -224,15 +224,15 @@ int serial_getc(void)
while (!serial_getc_check()) while (!serial_getc_check())
; ;
ch = *SCFRDR; ch = readb(SCFRDR);
status = *SCFSR; status = readw(SCFSR);
*SCFSR = RDRF_CLEAR; writew(RDRF_CLEAR, SCFSR);
if (status & (FSR_FER | FSR_FER | FSR_ER | FSR_BRK)) if (status & (FSR_FER | FSR_FER | FSR_ER | FSR_BRK))
handle_error(); handle_error();
if (*SCLSR & LSR_ORER) if (readw(SCLSR) & LSR_ORER)
handle_error(); handle_error();
return ch; return ch;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment