Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 225784
b: refs/heads/master
c: c19f12b
h: refs/heads/master
v: v3
  • Loading branch information
Russell King committed Jan 5, 2011
1 parent 2a27811 commit 698074d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 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: 5063e2c567ee569cccfc01ebf80c898cb4e6833a
refs/heads/master: c19f12b5ef3adf3c139eabbe3d3d0201838b77b1
51 changes: 27 additions & 24 deletions trunk/drivers/serial/amba-pl011.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,6 @@
#define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE)
#define UART_DUMMY_DR_RX (1 << 16)

/*
* We wrap our port structure around the generic uart_port.
*/
struct uart_amba_port {
struct uart_port port;
struct clk *clk;
unsigned int im; /* interrupt mask */
unsigned int old_status;
unsigned int ifls; /* vendor-specific */
unsigned int lcrh_tx; /* vendor-specific */
unsigned int lcrh_rx; /* vendor-specific */
bool oversampling; /* vendor-specific */
bool autorts;
char type[12];
};

/* There is by now at least one vendor with differing details, so handle it */
struct vendor_data {
unsigned int ifls;
Expand All @@ -104,6 +88,21 @@ static struct vendor_data vendor_st = {
.oversampling = true,
};

/*
* We wrap our port structure around the generic uart_port.
*/
struct uart_amba_port {
struct uart_port port;
struct clk *clk;
const struct vendor_data *vendor;
unsigned int im; /* interrupt mask */
unsigned int old_status;
unsigned int lcrh_tx; /* vendor-specific */
unsigned int lcrh_rx; /* vendor-specific */
bool autorts;
char type[12];
};

static void pl011_stop_tx(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
Expand Down Expand Up @@ -397,7 +396,7 @@ static int pl011_startup(struct uart_port *port)
if (retval)
goto clk_dis;

writew(uap->ifls, uap->port.membase + UART011_IFLS);
writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS);

/*
* Provoke TX FIFO interrupt into asserting.
Expand Down Expand Up @@ -503,13 +502,18 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int lcr_h, old_cr;
unsigned long flags;
unsigned int baud, quot;
unsigned int baud, quot, clkdiv;

if (uap->vendor->oversampling)
clkdiv = 8;
else
clkdiv = 16;

/*
* Ask the core to calculate the divisor for us.
*/
baud = uart_get_baud_rate(port, termios, old, 0,
port->uartclk/(uap->oversampling ? 8 : 16));
port->uartclk / clkdiv);

if (baud > port->uartclk/16)
quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud);
Expand Down Expand Up @@ -593,8 +597,8 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
uap->autorts = false;
}

if (uap->oversampling) {
if (baud > port->uartclk/16)
if (uap->vendor->oversampling) {
if (baud > port->uartclk / 16)
old_cr |= ST_UART011_CR_OVSFACT;
else
old_cr &= ~ST_UART011_CR_OVSFACT;
Expand Down Expand Up @@ -767,7 +771,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,

*baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd);

if (uap->oversampling) {
if (uap->vendor->oversampling) {
if (readw(uap->port.membase + UART011_CR)
& ST_UART011_CR_OVSFACT)
*baud *= 2;
Expand Down Expand Up @@ -864,10 +868,9 @@ static int pl011_probe(struct amba_device *dev, struct amba_id *id)
goto unmap;
}

uap->ifls = vendor->ifls;
uap->vendor = vendor;
uap->lcrh_rx = vendor->lcrh_rx;
uap->lcrh_tx = vendor->lcrh_tx;
uap->oversampling = vendor->oversampling;
uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
uap->port.membase = base;
Expand Down

0 comments on commit 698074d

Please sign in to comment.