git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
serial
/
amba-pl011.c
diff --git
a/drivers/serial/amba-pl011.c
b/drivers/serial/amba-pl011.c
index
7db88ee
..
44639e7
100644
(file)
--- a/
drivers/serial/amba-pl011.c
+++ b/
drivers/serial/amba-pl011.c
@@
-31,7
+31,6
@@
* required, these have to be supplied via some other means (eg, GPIO)
* and hooked into this driver.
*/
* required, these have to be supplied via some other means (eg, GPIO)
* and hooked into this driver.
*/
-#include <linux/config.h>
#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
@@
-47,12
+46,12
@@
#include <linux/tty_flip.h>
#include <linux/serial_core.h>
#include <linux/serial.h>
#include <linux/tty_flip.h>
#include <linux/serial_core.h>
#include <linux/serial.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/serial.h>
+#include <linux/clk.h>
#include <asm/io.h>
#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/hardware/amba.h>
-#include <asm/hardware/clock.h>
-#include <asm/hardware/amba_serial.h>
+#include <asm/sizes.h>
#define UART_NR 14
#define UART_NR 14
@@
-62,7
+61,8
@@
#define AMBA_ISR_PASS_LIMIT 256
#define AMBA_ISR_PASS_LIMIT 256
-#define UART_DUMMY_RSR_RX 256
+#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.
/*
* We wrap our port structure around the generic uart_port.
@@
-74,7
+74,7
@@
struct uart_amba_port {
unsigned int old_status;
};
unsigned int old_status;
};
-static void pl011_stop_tx(struct uart_port *port
, unsigned int tty_stop
)
+static void pl011_stop_tx(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@
-82,7
+82,7
@@
static void pl011_stop_tx(struct uart_port *port, unsigned int tty_stop)
writew(uap->im, uap->port.membase + UART011_IMSC);
}
writew(uap->im, uap->port.membase + UART011_IMSC);
}
-static void pl011_start_tx(struct uart_port *port
, unsigned int tty_start
)
+static void pl011_start_tx(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@
-107,28
+107,14
@@
static void pl011_enable_ms(struct uart_port *port)
writew(uap->im, uap->port.membase + UART011_IMSC);
}
writew(uap->im, uap->port.membase + UART011_IMSC);
}
-static void
-#ifdef SUPPORT_SYSRQ
-pl011_rx_chars(struct uart_amba_port *uap, struct pt_regs *regs)
-#else
-pl011_rx_chars(struct uart_amba_port *uap)
-#endif
+static void pl011_rx_chars(struct uart_amba_port *uap)
{
struct tty_struct *tty = uap->port.info->tty;
{
struct tty_struct *tty = uap->port.info->tty;
- unsigned int status, ch, flag,
rsr,
max_count = 256;
+ unsigned int status, ch, flag, max_count = 256;
status = readw(uap->port.membase + UART01x_FR);
while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
status = readw(uap->port.membase + UART01x_FR);
while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
- if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
- if (tty->low_latency)
- tty_flip_buffer_push(tty);
- /*
- * If this failed then we will throw away the
- * bytes but must do so to clear interrupts
- */
- }
-
- ch = readw(uap->port.membase + UART01x_DR);
+ ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX;
flag = TTY_NORMAL;
uap->port.icount.rx++;
flag = TTY_NORMAL;
uap->port.icount.rx++;
@@
-136,34
+122,33
@@
pl011_rx_chars(struct uart_amba_port *uap)
* Note that the error handling code is
* out of the main execution path
*/
* Note that the error handling code is
* out of the main execution path
*/
- rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
- if (unlikely(rsr & UART01x_RSR_ANY)) {
- if (rsr & UART01x_RSR_BE) {
- rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
+ if (unlikely(ch & UART_DR_ERROR)) {
+ if (ch & UART011_DR_BE) {
+ ch &= ~(UART011_DR_FE | UART011_DR_PE);
uap->port.icount.brk++;
if (uart_handle_break(&uap->port))
goto ignore_char;
uap->port.icount.brk++;
if (uart_handle_break(&uap->port))
goto ignore_char;
- } else if (
rsr & UART01x_RS
R_PE)
+ } else if (
ch & UART011_D
R_PE)
uap->port.icount.parity++;
uap->port.icount.parity++;
- else if (
rsr & UART01x_RS
R_FE)
+ else if (
ch & UART011_D
R_FE)
uap->port.icount.frame++;
uap->port.icount.frame++;
- if (
rsr & UART01x_RS
R_OE)
+ if (
ch & UART011_D
R_OE)
uap->port.icount.overrun++;
uap->port.icount.overrun++;
-
rsr
&= uap->port.read_status_mask;
+
ch
&= uap->port.read_status_mask;
- if (
rsr & UART01x_RS
R_BE)
+ if (
ch & UART011_D
R_BE)
flag = TTY_BREAK;
flag = TTY_BREAK;
- else if (
rsr & UART01x_RS
R_PE)
+ else if (
ch & UART011_D
R_PE)
flag = TTY_PARITY;
flag = TTY_PARITY;
- else if (
rsr & UART01x_RS
R_FE)
+ else if (
ch & UART011_D
R_FE)
flag = TTY_FRAME;
}
flag = TTY_FRAME;
}
- if (uart_handle_sysrq_char(&uap->port, ch
, regs
))
+ if (uart_handle_sysrq_char(&uap->port, ch
& 255
))
goto ignore_char;
goto ignore_char;
- uart_insert_char(&uap->port,
rsr, UART01x_RS
R_OE, ch, flag);
+ uart_insert_char(&uap->port,
ch, UART011_D
R_OE, ch, flag);
ignore_char:
status = readw(uap->port.membase + UART01x_FR);
ignore_char:
status = readw(uap->port.membase + UART01x_FR);
@@
-184,7
+169,7
@@
static void pl011_tx_chars(struct uart_amba_port *uap)
return;
}
if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
return;
}
if (uart_circ_empty(xmit) || uart_tx_stopped(&uap->port)) {
- pl011_stop_tx(&uap->port
, 0
);
+ pl011_stop_tx(&uap->port);
return;
}
return;
}
@@
-201,7
+186,7
@@
static void pl011_tx_chars(struct uart_amba_port *uap)
uart_write_wakeup(&uap->port);
if (uart_circ_empty(xmit))
uart_write_wakeup(&uap->port);
if (uart_circ_empty(xmit))
- pl011_stop_tx(&uap->port
, 0
);
+ pl011_stop_tx(&uap->port);
}
static void pl011_modem_status(struct uart_amba_port *uap)
}
static void pl011_modem_status(struct uart_amba_port *uap)
@@
-228,7
+213,7
@@
static void pl011_modem_status(struct uart_amba_port *uap)
wake_up_interruptible(&uap->port.info->delta_msr_wait);
}
wake_up_interruptible(&uap->port.info->delta_msr_wait);
}
-static irqreturn_t pl011_int(int irq, void *dev_id
, struct pt_regs *regs
)
+static irqreturn_t pl011_int(int irq, void *dev_id)
{
struct uart_amba_port *uap = dev_id;
unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
{
struct uart_amba_port *uap = dev_id;
unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
@@
-244,11
+229,7
@@
static irqreturn_t pl011_int(int irq, void *dev_id, struct pt_regs *regs)
uap->port.membase + UART011_ICR);
if (status & (UART011_RTIS|UART011_RXIS))
uap->port.membase + UART011_ICR);
if (status & (UART011_RTIS|UART011_RXIS))
-#ifdef SUPPORT_SYSRQ
- pl011_rx_chars(uap, regs);
-#else
pl011_rx_chars(uap);
pl011_rx_chars(uap);
-#endif
if (status & (UART011_DSRMIS|UART011_DCDMIS|
UART011_CTSMIS|UART011_RIMIS))
pl011_modem_status(uap);
if (status & (UART011_DSRMIS|UART011_DCDMIS|
UART011_CTSMIS|UART011_RIMIS))
pl011_modem_status(uap);
@@
-431,8
+412,8
@@
static void pl011_shutdown(struct uart_port *port)
}
static void
}
static void
-pl011_set_termios(struct uart_port *port, struct termios *termios,
- struct termios *old)
+pl011_set_termios(struct uart_port *port, struct
k
termios *termios,
+ struct
k
termios *old)
{
unsigned int lcr_h, old_cr;
unsigned long flags;
{
unsigned int lcr_h, old_cr;
unsigned long flags;
@@
-475,33
+456,33
@@
pl011_set_termios(struct uart_port *port, struct termios *termios,
*/
uart_update_timeout(port, termios->c_cflag, baud);
*/
uart_update_timeout(port, termios->c_cflag, baud);
- port->read_status_mask = UART01
x_RSR_OE
;
+ port->read_status_mask = UART01
1_DR_OE | 255
;
if (termios->c_iflag & INPCK)
if (termios->c_iflag & INPCK)
- port->read_status_mask |= UART01
x_RSR_FE | UART01x_RS
R_PE;
+ port->read_status_mask |= UART01
1_DR_FE | UART011_D
R_PE;
if (termios->c_iflag & (BRKINT | PARMRK))
if (termios->c_iflag & (BRKINT | PARMRK))
- port->read_status_mask |= UART01
x_RS
R_BE;
+ port->read_status_mask |= UART01
1_D
R_BE;
/*
* Characters to ignore
*/
port->ignore_status_mask = 0;
if (termios->c_iflag & IGNPAR)
/*
* Characters to ignore
*/
port->ignore_status_mask = 0;
if (termios->c_iflag & IGNPAR)
- port->ignore_status_mask |= UART01
x_RSR_FE | UART01x_RS
R_PE;
+ port->ignore_status_mask |= UART01
1_DR_FE | UART011_D
R_PE;
if (termios->c_iflag & IGNBRK) {
if (termios->c_iflag & IGNBRK) {
- port->ignore_status_mask |= UART01
x_RS
R_BE;
+ port->ignore_status_mask |= UART01
1_D
R_BE;
/*
* If we're ignoring parity and break indicators,
* ignore overruns too (for real raw support).
*/
if (termios->c_iflag & IGNPAR)
/*
* If we're ignoring parity and break indicators,
* ignore overruns too (for real raw support).
*/
if (termios->c_iflag & IGNPAR)
- port->ignore_status_mask |= UART01
x_RS
R_OE;
+ port->ignore_status_mask |= UART01
1_D
R_OE;
}
/*
* Ignore all characters if CREAD is not set.
*/
if ((termios->c_cflag & CREAD) == 0)
}
/*
* Ignore all characters if CREAD is not set.
*/
if ((termios->c_cflag & CREAD) == 0)
- port->ignore_status_mask |= UART_DUMMY_
RS
R_RX;
+ port->ignore_status_mask |= UART_DUMMY_
D
R_RX;
if (UART_ENABLE_MS(port, termios->c_cflag))
pl011_enable_ms(port);
if (UART_ENABLE_MS(port, termios->c_cflag))
pl011_enable_ms(port);
@@
-596,14
+577,12
@@
static struct uart_amba_port *amba_ports[UART_NR];
#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
-static inline void
-pl011_console_write_char(struct uart_amba_port *uap, char ch)
+static void pl011_console_putchar(struct uart_port *port, int ch)
{
{
-
unsigned int status
;
+
struct uart_amba_port *uap = (struct uart_amba_port *)port
;
- do {
- status = readw(uap->port.membase + UART01x_FR);
- } while (status & UART01x_FR_TXFF);
+ while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
+ barrier();
writew(ch, uap->port.membase + UART01x_DR);
}
writew(ch, uap->port.membase + UART01x_DR);
}
@@
-612,7
+591,6
@@
pl011_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_amba_port *uap = amba_ports[co->index];
unsigned int status, old_cr, new_cr;
{
struct uart_amba_port *uap = amba_ports[co->index];
unsigned int status, old_cr, new_cr;
- int i;
clk_enable(uap->clk);
clk_enable(uap->clk);
@@
-624,14
+602,7
@@
pl011_console_write(struct console *co, const char *s, unsigned int count)
new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
writew(new_cr, uap->port.membase + UART011_CR);
new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
writew(new_cr, uap->port.membase + UART011_CR);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- pl011_console_write_char(uap, s[i]);
- if (s[i] == '\n')
- pl011_console_write_char(uap, '\r');
- }
+ uart_console_write(&uap->port, s, count, pl011_console_putchar);
/*
* Finally, wait for transmitter to become empty
/*
* Finally, wait for transmitter to become empty
@@
-690,6
+661,8
@@
static int __init pl011_console_setup(struct console *co, char *options)
if (co->index >= UART_NR)
co->index = 0;
uap = amba_ports[co->index];
if (co->index >= UART_NR)
co->index = 0;
uap = amba_ports[co->index];
+ if (!uap)
+ return -ENODEV;
uap->port.uartclk = clk_get_rate(uap->clk);
uap->port.uartclk = clk_get_rate(uap->clk);
@@
-701,7
+674,7
@@
static int __init pl011_console_setup(struct console *co, char *options)
return uart_set_options(&uap->port, co, baud, parity, bits, flow);
}
return uart_set_options(&uap->port, co, baud, parity, bits, flow);
}
-
extern
struct uart_driver amba_reg;
+
static
struct uart_driver amba_reg;
static struct console amba_console = {
.name = "ttyAMA",
.write = pl011_console_write,
static struct console amba_console = {
.name = "ttyAMA",
.write = pl011_console_write,
@@
-761,10
+734,6
@@
static int pl011_probe(struct amba_device *dev, void *id)
goto unmap;
}
goto unmap;
}
- ret = clk_use(uap->clk);
- if (ret)
- goto putclk;
-
uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
uap->port.membase = base;
uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
uap->port.membase = base;
@@
-782,8
+751,6
@@
static int pl011_probe(struct amba_device *dev, void *id)
if (ret) {
amba_set_drvdata(dev, NULL);
amba_ports[i] = NULL;
if (ret) {
amba_set_drvdata(dev, NULL);
amba_ports[i] = NULL;
- clk_unuse(uap->clk);
- putclk:
clk_put(uap->clk);
unmap:
iounmap(base);
clk_put(uap->clk);
unmap:
iounmap(base);
@@
-808,7
+775,6
@@
static int pl011_remove(struct amba_device *dev)
amba_ports[i] = NULL;
iounmap(uap->port.membase);
amba_ports[i] = NULL;
iounmap(uap->port.membase);
- clk_unuse(uap->clk);
clk_put(uap->clk);
kfree(uap);
return 0;
clk_put(uap->clk);
kfree(uap);
return 0;