From 7570eebcdd5628978cbdbab2fb7cb99abbc62360 Mon Sep 17 00:00:00 2001 From: Thomas Langer Date: Tue, 16 Dec 2008 14:07:55 +0000 Subject: cleanup sources and prepare for 2.6.27 SVN-Revision: 13660 --- .../ifxmips/files/drivers/serial/ifxmips_asc.c | 322 +++++++++------------ 1 file changed, 142 insertions(+), 180 deletions(-) (limited to 'target/linux/ifxmips/files/drivers/serial') diff --git a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c index 2dc8917fe1..d6bf1803f9 100644 --- a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c +++ b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c @@ -42,10 +42,12 @@ #include #include #include +#include +#include +#include + #include -#include -#include -#include + #include #include @@ -56,19 +58,17 @@ #define UART_DUMMY_UER_RX 1 static void ifxmipsasc_tx_chars(struct uart_port *port); -extern void prom_printf(const char * fmt, ...); +extern void prom_printf(const char *fmt, ...); static struct uart_port ifxmipsasc_port[2]; static struct uart_driver ifxmipsasc_reg; extern unsigned int ifxmips_get_fpi_hz(void); -static void -ifxmipsasc_stop_tx(struct uart_port *port) +static void ifxmipsasc_stop_tx(struct uart_port *port) { return; } -static void -ifxmipsasc_start_tx(struct uart_port *port) +static void ifxmipsasc_start_tx(struct uart_port *port) { unsigned long flags; local_irq_save(flags); @@ -77,26 +77,28 @@ ifxmipsasc_start_tx(struct uart_port *port) return; } -static void -ifxmipsasc_stop_rx(struct uart_port *port) +static void ifxmipsasc_stop_rx(struct uart_port *port) { ifxmips_w32(ASCWHBSTATE_CLRREN, port->membase + IFXMIPS_ASC_WHBSTATE); } -static void -ifxmipsasc_enable_ms(struct uart_port *port) +static void ifxmipsasc_enable_ms(struct uart_port *port) { } -static void -ifxmipsasc_rx_chars(struct uart_port *port) +#include + +static void ifxmipsasc_rx_chars(struct uart_port *port) { +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26)) + struct tty_struct *tty = port->info->port.tty; +#else struct tty_struct *tty = port->info->tty; +#endif unsigned int ch = 0, rsr = 0, fifocnt; fifocnt = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; - while(fifocnt--) - { + while (fifocnt--) { u8 flag = TTY_NORMAL; ch = ifxmips_r32(port->membase + IFXMIPS_ASC_RBUF); rsr = (ifxmips_r32(port->membase + IFXMIPS_ASC_STATE) & ASCSTATE_ANY) | UART_DUMMY_UER_RX; @@ -107,35 +109,31 @@ ifxmipsasc_rx_chars(struct uart_port *port) * Note that the error handling code is * out of the main execution path */ - if(rsr & ASCSTATE_ANY) - { - if(rsr & ASCSTATE_PE) - { + if (rsr & ASCSTATE_ANY) { + if (rsr & ASCSTATE_PE) { port->icount.parity++; ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE, port->membase + IFXMIPS_ASC_WHBSTATE); - } else if(rsr & ASCSTATE_FE) - { + } else if (rsr & ASCSTATE_FE) { port->icount.frame++; ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRFE, port->membase + IFXMIPS_ASC_WHBSTATE); } - if(rsr & ASCSTATE_ROE) - { + if (rsr & ASCSTATE_ROE) { port->icount.overrun++; ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE); } rsr &= port->read_status_mask; - if(rsr & ASCSTATE_PE) + if (rsr & ASCSTATE_PE) flag = TTY_PARITY; - else if(rsr & ASCSTATE_FE) + else if (rsr & ASCSTATE_FE) flag = TTY_FRAME; } - if((rsr & port->ignore_status_mask) == 0) + if ((rsr & port->ignore_status_mask) == 0) tty_insert_flip_char(tty, ch, flag); - if(rsr & ASCSTATE_ROE) + if (rsr & ASCSTATE_ROE) /* * Overrun is special, since it's reported * immediately, and doesn't affect the current @@ -143,34 +141,30 @@ ifxmipsasc_rx_chars(struct uart_port *port) */ tty_insert_flip_char(tty, 0, TTY_OVERRUN); } - if(ch != 0) + if (ch != 0) tty_flip_buffer_push(tty); return; } -static void -ifxmipsasc_tx_chars(struct uart_port *port) +static void ifxmipsasc_tx_chars(struct uart_port *port) { struct circ_buf *xmit = &port->info->xmit; - if(uart_tx_stopped(port)) - { + if (uart_tx_stopped(port)) { ifxmipsasc_stop_tx(port); return; } - while(((ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK) - >> ASCFSTAT_TXFFLOFF) != TXFIFO_FULL) - { - if(port->x_char) - { + while (((ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK) + >> ASCFSTAT_TXFFLOFF) != TXFIFO_FULL) { + if (port->x_char) { ifxmips_w32(port->x_char, port->membase + IFXMIPS_ASC_TBUF); port->icount.tx++; port->x_char = 0; continue; } - if(uart_circ_empty(xmit)) + if (uart_circ_empty(xmit)) break; ifxmips_w32(port->info->xmit.buf[port->info->xmit.tail], port->membase + IFXMIPS_ASC_TBUF); @@ -178,66 +172,58 @@ ifxmipsasc_tx_chars(struct uart_port *port) port->icount.tx++; } - if(uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(port); } -static irqreturn_t -ifxmipsasc_tx_int(int irq, void *_port) +static irqreturn_t ifxmipsasc_tx_int(int irq, void *_port) { - struct uart_port *port = (struct uart_port*) _port; + struct uart_port *port = (struct uart_port *)_port; ifxmips_w32(ASC_IRNCR_TIR, port->membase + IFXMIPS_ASC_IRNCR); ifxmipsasc_start_tx(port); ifxmips_mask_and_ack_irq(irq); return IRQ_HANDLED; } -static irqreturn_t -ifxmipsasc_er_int(int irq, void *_port) +static irqreturn_t ifxmipsasc_er_int(int irq, void *_port) { - struct uart_port *port = (struct uart_port*) _port; + struct uart_port *port = (struct uart_port *)_port; /* clear any pending interrupts */ ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE | ASCWHBSTATE_CLRFE | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE); return IRQ_HANDLED; } -static irqreturn_t -ifxmipsasc_rx_int(int irq, void *_port) +static irqreturn_t ifxmipsasc_rx_int(int irq, void *_port) { - struct uart_port *port = (struct uart_port*)_port; + struct uart_port *port = (struct uart_port *)_port; ifxmips_w32(ASC_IRNCR_RIR, port->membase + IFXMIPS_ASC_IRNCR); - ifxmipsasc_rx_chars((struct uart_port*)port); + ifxmipsasc_rx_chars((struct uart_port *)port); ifxmips_mask_and_ack_irq(irq); return IRQ_HANDLED; } -static unsigned int -ifxmipsasc_tx_empty(struct uart_port *port) +static unsigned int ifxmipsasc_tx_empty(struct uart_port *port) { int status; status = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK; return status ? 0 : TIOCSER_TEMT; } -static unsigned int -ifxmipsasc_get_mctrl(struct uart_port *port) +static unsigned int ifxmipsasc_get_mctrl(struct uart_port *port) { return TIOCM_CTS | TIOCM_CAR | TIOCM_DSR; } -static void -ifxmipsasc_set_mctrl(struct uart_port *port, u_int mctrl) +static void ifxmipsasc_set_mctrl(struct uart_port *port, u_int mctrl) { } -static void -ifxmipsasc_break_ctl(struct uart_port *port, int break_state) +static void ifxmipsasc_break_ctl(struct uart_port *port, int break_state) { } -static int -ifxmipsasc_startup(struct uart_port *port) +static int ifxmipsasc_startup(struct uart_port *port) { unsigned long flags; int retval; @@ -249,29 +235,26 @@ ifxmipsasc_startup(struct uart_port *port) ifxmips_w32(0, port->membase + IFXMIPS_ASC_PISEL); ifxmips_w32(((TXFIFO_FL << ASCTXFCON_TXFITLOFF) & ASCTXFCON_TXFITLMASK) | ASCTXFCON_TXFEN | ASCTXFCON_TXFFLU, port->membase + IFXMIPS_ASC_TXFCON); ifxmips_w32(((RXFIFO_FL << ASCRXFCON_RXFITLOFF) & ASCRXFCON_RXFITLMASK) | ASCRXFCON_RXFEN | ASCRXFCON_RXFFLU, port->membase + IFXMIPS_ASC_RXFCON); - wmb (); + wmb(); ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | ASCCON_M_8ASYNC | ASCCON_FEN | ASCCON_TOEN | ASCCON_ROEN, port->membase + IFXMIPS_ASC_CON); local_irq_save(flags); retval = request_irq(port->irq, ifxmipsasc_tx_int, IRQF_DISABLED, "asc_tx", port); - if(retval) - { - printk("failed to request ifxmipsasc_tx_int\n"); + if (retval) { + printk(KERN_ERR "failed to request ifxmipsasc_tx_int\n"); return retval; } retval = request_irq(port->irq + 2, ifxmipsasc_rx_int, IRQF_DISABLED, "asc_rx", port); - if(retval) - { - printk("failed to request ifxmipsasc_rx_int\n"); + if (retval) { + printk(KERN_ERR "failed to request ifxmipsasc_rx_int\n"); goto err1; } retval = request_irq(port->irq + 3, ifxmipsasc_er_int, IRQF_DISABLED, "asc_er", port); - if(retval) - { - printk("failed to request ifxmipsasc_er_int\n"); + if (retval) { + printk(KERN_ERR "failed to request ifxmipsasc_er_int\n"); goto err2; } @@ -288,8 +271,7 @@ err1: return retval; } -static void -ifxmipsasc_shutdown(struct uart_port *port) +static void ifxmipsasc_shutdown(struct uart_port *port) { free_irq(port->irq, port); free_irq(port->irq + 2, port); @@ -314,8 +296,7 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, cflag = new->c_cflag; iflag = new->c_iflag; - switch(cflag & CSIZE) - { + switch (cflag & CSIZE) { case CS7: con = ASCCON_M_7ASYNC; break; @@ -327,36 +308,34 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, break; } - if(cflag & CSTOPB) + if (cflag & CSTOPB) con |= ASCCON_STP; - if(cflag & PARENB) - { - if(!(cflag & PARODD)) + if (cflag & PARENB) { + if (!(cflag & PARODD)) con &= ~ASCCON_ODD; else con |= ASCCON_ODD; } port->read_status_mask = ASCSTATE_ROE; - if(iflag & INPCK) + if (iflag & INPCK) port->read_status_mask |= ASCSTATE_FE | ASCSTATE_PE; port->ignore_status_mask = 0; - if(iflag & IGNPAR) + if (iflag & IGNPAR) port->ignore_status_mask |= ASCSTATE_FE | ASCSTATE_PE; - if(iflag & IGNBRK) - { + if (iflag & IGNBRK) { /* * If we're ignoring parity and break indicators, * ignore overruns too (for real raw support). */ - if(iflag & IGNPAR) + if (iflag & IGNPAR) port->ignore_status_mask |= ASCSTATE_ROE; } - if((cflag & CREAD) == 0) + if ((cflag & CREAD) == 0) port->ignore_status_mask |= UART_DUMMY_UER_RX; /* set error signals - framing, parity and overrun, enable receiver */ @@ -368,7 +347,7 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | con, port->membase + IFXMIPS_ASC_CON); /* Set baud rate - take a divider of 2 into account */ - baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); + baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); quot = uart_get_divisor(port, baud); quot = quot / 2 - 1; @@ -393,12 +372,10 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, local_irq_restore(flags); } -static const char* -ifxmipsasc_type(struct uart_port *port) +static const char *ifxmipsasc_type(struct uart_port *port) { - if(port->type == PORT_IFXMIPSASC) - { - if(port->membase == (void*)IFXMIPS_ASC_BASE_ADDR) + if (port->type == PORT_IFXMIPSASC) { + if (port->membase == (void *)IFXMIPS_ASC_BASE_ADDR) return "asc0"; else return "asc1"; @@ -407,120 +384,109 @@ ifxmipsasc_type(struct uart_port *port) } } -static void -ifxmipsasc_release_port(struct uart_port *port) +static void ifxmipsasc_release_port(struct uart_port *port) { } -static int -ifxmipsasc_request_port(struct uart_port *port) +static int ifxmipsasc_request_port(struct uart_port *port) { return 0; } -static void -ifxmipsasc_config_port(struct uart_port *port, int flags) +static void ifxmipsasc_config_port(struct uart_port *port, int flags) { - if(flags & UART_CONFIG_TYPE) - { + if (flags & UART_CONFIG_TYPE) { port->type = PORT_IFXMIPSASC; ifxmipsasc_request_port(port); } } -static int -ifxmipsasc_verify_port(struct uart_port *port, struct serial_struct *ser) +static int ifxmipsasc_verify_port(struct uart_port *port, struct serial_struct *ser) { int ret = 0; - if(ser->type != PORT_UNKNOWN && ser->type != PORT_IFXMIPSASC) + if (ser->type != PORT_UNKNOWN && ser->type != PORT_IFXMIPSASC) ret = -EINVAL; - if(ser->irq < 0 || ser->irq >= NR_IRQS) + if (ser->irq < 0 || ser->irq >= NR_IRQS) ret = -EINVAL; - if(ser->baud_base < 9600) + if (ser->baud_base < 9600) ret = -EINVAL; return ret; } -static struct uart_ops ifxmipsasc_pops = -{ - .tx_empty = ifxmipsasc_tx_empty, +static struct uart_ops ifxmipsasc_pops = { + .tx_empty = ifxmipsasc_tx_empty, .set_mctrl = ifxmipsasc_set_mctrl, .get_mctrl = ifxmipsasc_get_mctrl, - .stop_tx = ifxmipsasc_stop_tx, - .start_tx = ifxmipsasc_start_tx, - .stop_rx = ifxmipsasc_stop_rx, + .stop_tx = ifxmipsasc_stop_tx, + .start_tx = ifxmipsasc_start_tx, + .stop_rx = ifxmipsasc_stop_rx, .enable_ms = ifxmipsasc_enable_ms, .break_ctl = ifxmipsasc_break_ctl, - .startup = ifxmipsasc_startup, - .shutdown = ifxmipsasc_shutdown, + .startup = ifxmipsasc_startup, + .shutdown = ifxmipsasc_shutdown, .set_termios = ifxmipsasc_set_termios, - .type = ifxmipsasc_type, + .type = ifxmipsasc_type, .release_port = ifxmipsasc_release_port, .request_port = ifxmipsasc_request_port, .config_port = ifxmipsasc_config_port, .verify_port = ifxmipsasc_verify_port, }; -static struct uart_port ifxmipsasc_port[2] = -{ +static struct uart_port ifxmipsasc_port[2] = { { - membase: (void *)IFXMIPS_ASC_BASE_ADDR, - mapbase: IFXMIPS_ASC_BASE_ADDR, - iotype: SERIAL_IO_MEM, - irq: IFXMIPSASC_TIR(0), - uartclk: 0, - fifosize: 16, - type: PORT_IFXMIPSASC, - ops: &ifxmipsasc_pops, - flags: ASYNC_BOOT_AUTOCONF, - line: 0 + .membase = (void *)IFXMIPS_ASC_BASE_ADDR, + .mapbase = IFXMIPS_ASC_BASE_ADDR, + .iotype = SERIAL_IO_MEM, + .irq = IFXMIPSASC_TIR(0), + .uartclk = 0, + .fifosize = 16, + .type = PORT_IFXMIPSASC, + .ops = &ifxmipsasc_pops, + .flags = ASYNC_BOOT_AUTOCONF, + .line = 0 }, { - membase: (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF), - mapbase: IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF, - iotype: SERIAL_IO_MEM, - irq: IFXMIPSASC_TIR(1), - uartclk: 0, - fifosize: 16, - type: PORT_IFXMIPSASC, - ops: &ifxmipsasc_pops, - flags: ASYNC_BOOT_AUTOCONF, - line: 1 + .membase = (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF), + .mapbase = IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF, + .iotype = SERIAL_IO_MEM, + .irq = IFXMIPSASC_TIR(1), + .uartclk = 0, + .fifosize = 16, + .type = PORT_IFXMIPSASC, + .ops = &ifxmipsasc_pops, + .flags = ASYNC_BOOT_AUTOCONF, + .line = 1 } }; -static void -ifxmipsasc_console_write(struct console *co, const char *s, u_int count) +static void ifxmipsasc_console_write(struct console *co, const char *s, u_int count) { int port = co->index; int i, fifocnt; unsigned long flags; local_irq_save(flags); - for(i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { do { - fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) - >> ASCFSTAT_TXFFLOFF; - } while(fifocnt == TXFIFO_FULL); + fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) + >> ASCFSTAT_TXFFLOFF; + } while (fifocnt == TXFIFO_FULL); - if(s[i] == '\0') + if (s[i] == '\0') break; - if(s[i] == '\n') - { - ifxmips_w32('\r', (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); + if (s[i] == '\n') { + ifxmips_w32('\r', (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); do { - fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) + fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF; - } while(fifocnt == TXFIFO_FULL); + } while (fifocnt == TXFIFO_FULL); } - ifxmips_w32(s[i], (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); + ifxmips_w32(s[i], (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); } local_irq_restore(flags); } -static int __init -ifxmipsasc_console_setup(struct console *co, char *options) +static int __init ifxmipsasc_console_setup(struct console *co, char *options) { int port = co->index; int baud = 115200; @@ -529,7 +495,7 @@ ifxmipsasc_console_setup(struct console *co, char *options) int flow = 'n'; ifxmipsasc_port[port].uartclk = ifxmips_get_fpi_hz(); ifxmipsasc_port[port].type = PORT_IFXMIPSASC; - if(options) + if (options) uart_parse_options(options, &baud, &parity, &bits, &flow); return uart_set_options(&ifxmipsasc_port[port], co, baud, parity, bits, flow); } @@ -537,26 +503,25 @@ ifxmipsasc_console_setup(struct console *co, char *options) static struct console ifxmipsasc_console[2] = { { - name: "ttyS", - write: ifxmipsasc_console_write, - device: uart_console_device, - setup: ifxmipsasc_console_setup, - flags: CON_PRINTBUFFER, - index: 0, - data: &ifxmipsasc_reg, + .name = "ttyS", + .write = ifxmipsasc_console_write, + .device = uart_console_device, + .setup = ifxmipsasc_console_setup, + .flags = CON_PRINTBUFFER, + .index = 0, + .data = &ifxmipsasc_reg, }, { - name: "ttyS", - write: ifxmipsasc_console_write, - device: uart_console_device, - setup: ifxmipsasc_console_setup, - flags: CON_PRINTBUFFER, - index: 1, - data: &ifxmipsasc_reg, + .name = "ttyS", + .write = ifxmipsasc_console_write, + .device = uart_console_device, + .setup = ifxmipsasc_console_setup, + .flags = CON_PRINTBUFFER, + .index = 1, + .data = &ifxmipsasc_reg, } }; -static int __init -ifxmipsasc_console_init(void) +static int __init ifxmipsasc_console_init(void) { register_console(&ifxmipsasc_console[0]); register_console(&ifxmipsasc_console[1]); @@ -564,19 +529,17 @@ ifxmipsasc_console_init(void) } console_initcall(ifxmipsasc_console_init); -static struct uart_driver ifxmipsasc_reg = -{ - .owner = THIS_MODULE, - .driver_name = "serial", - .dev_name = "ttyS", - .major = TTY_MAJOR, - .minor = 64, - .nr = 2, - .cons = &ifxmipsasc_console[1], +static struct uart_driver ifxmipsasc_reg = { + .owner = THIS_MODULE, + .driver_name = "serial", + .dev_name = "ttyS", + .major = TTY_MAJOR, + .minor = 64, + .nr = 2, + .cons = &ifxmipsasc_console[1], }; -int __init -ifxmipsasc_init(void) +int __init ifxmipsasc_init(void) { int ret; uart_register_driver(&ifxmipsasc_reg); @@ -585,8 +548,7 @@ ifxmipsasc_init(void) return 0; } -void __exit -ifxmipsasc_exit(void) +void __exit ifxmipsasc_exit(void) { uart_unregister_driver(&ifxmipsasc_reg); } -- cgit v1.2.3