Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26648
b: refs/heads/master
c: b32b19b
h: refs/heads/master
v: v3
  • Loading branch information
Jon Anders Haugum authored and Russell King committed Apr 30, 2006
1 parent c11c344 commit 2957a3d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 85835f442e5bbf9d3b8f6e574751da8db77016d2
refs/heads/master: b32b19b8ffc05cbd3bf91c65e205f6a912ca15d9
55 changes: 42 additions & 13 deletions trunk/drivers/serial/8250.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,40 @@ serial_out(struct uart_8250_port *up, int offset, int value)
#define serial_inp(up, offset) serial_in(up, offset)
#define serial_outp(up, offset, value) serial_out(up, offset, value)

/* Uart divisor latch read */
static inline int _serial_dl_read(struct uart_8250_port *up)
{
return serial_inp(up, UART_DLL) | serial_inp(up, UART_DLM) << 8;
}

/* Uart divisor latch write */
static inline void _serial_dl_write(struct uart_8250_port *up, int value)
{
serial_outp(up, UART_DLL, value & 0xff);
serial_outp(up, UART_DLM, value >> 8 & 0xff);
}

#ifdef CONFIG_SERIAL_8250_AU1X00
/* Au1x00 haven't got a standard divisor latch */
static int serial_dl_read(struct uart_8250_port *up)
{
if (up->port.iotype == UPIO_AU)
return __raw_readl(up->port.membase + 0x28);
else
return _serial_dl_read(up);
}

static void serial_dl_write(struct uart_8250_port *up, int value)
{
if (up->port.iotype == UPIO_AU)
__raw_writel(value, up->port.membase + 0x28);
else
_serial_dl_write(up, value);
}
#else
#define serial_dl_read(up) _serial_dl_read(up)
#define serial_dl_write(up, value) _serial_dl_write(up, value)
#endif

/*
* For the 16C950
Expand Down Expand Up @@ -494,7 +528,8 @@ static void disable_rsa(struct uart_8250_port *up)
*/
static int size_fifo(struct uart_8250_port *up)
{
unsigned char old_fcr, old_mcr, old_dll, old_dlm, old_lcr;
unsigned char old_fcr, old_mcr, old_lcr;
unsigned short old_dl;
int count;

old_lcr = serial_inp(up, UART_LCR);
Expand All @@ -505,10 +540,8 @@ static int size_fifo(struct uart_8250_port *up)
UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
serial_outp(up, UART_MCR, UART_MCR_LOOP);
serial_outp(up, UART_LCR, UART_LCR_DLAB);
old_dll = serial_inp(up, UART_DLL);
old_dlm = serial_inp(up, UART_DLM);
serial_outp(up, UART_DLL, 0x01);
serial_outp(up, UART_DLM, 0x00);
old_dl = serial_dl_read(up);
serial_dl_write(up, 0x0001);
serial_outp(up, UART_LCR, 0x03);
for (count = 0; count < 256; count++)
serial_outp(up, UART_TX, count);
Expand All @@ -519,8 +552,7 @@ static int size_fifo(struct uart_8250_port *up)
serial_outp(up, UART_FCR, old_fcr);
serial_outp(up, UART_MCR, old_mcr);
serial_outp(up, UART_LCR, UART_LCR_DLAB);
serial_outp(up, UART_DLL, old_dll);
serial_outp(up, UART_DLM, old_dlm);
serial_dl_write(up, old_dl);
serial_outp(up, UART_LCR, old_lcr);

return count;
Expand Down Expand Up @@ -750,17 +782,15 @@ static void autoconfig_16550a(struct uart_8250_port *up)

serial_outp(up, UART_LCR, 0xE0);

quot = serial_inp(up, UART_DLM) << 8;
quot += serial_inp(up, UART_DLL);
quot = serial_dl_read(up);
quot <<= 3;

status1 = serial_in(up, 0x04); /* EXCR1 */
status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
serial_outp(up, 0x04, status1);

serial_outp(up, UART_DLL, quot & 0xff);
serial_outp(up, UART_DLM, quot >> 8);
serial_dl_write(up, quot);

serial_outp(up, UART_LCR, 0);

Expand Down Expand Up @@ -1862,8 +1892,7 @@ serial8250_set_termios(struct uart_port *port, struct termios *termios,
serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */
}

serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */
serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */
serial_dl_write(up, quot);

/*
* LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR
Expand Down

0 comments on commit 2957a3d

Please sign in to comment.