ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / drivers / serial / jsm / jsm_neo.c
index 9b79c1f..7960d96 100644 (file)
@@ -20,7 +20,7 @@
  *
  * Contact Information:
  * Scott H Kilau <Scott_Kilau@digi.com>
- * Wendy Xiong   <wendyx@us.ltcfwd.linux.ibm.com>
+ * Wendy Xiong   <wendyx@us.ibm.com>
  *
  ***********************************************************************/
 #include <linux/delay.h>       /* For udelay */
@@ -48,8 +48,9 @@ static inline void neo_pci_posting_flush(struct jsm_board *bd)
 
 static void neo_set_cts_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting CTSFLOW\n");
 
@@ -78,8 +79,9 @@ static void neo_set_cts_flow_control(struct jsm_channel *ch)
 
 static void neo_set_rts_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting RTSFLOW\n");
 
@@ -117,8 +119,9 @@ static void neo_set_rts_flow_control(struct jsm_channel *ch)
 
 static void neo_set_ixon_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting IXON FLOW\n");
 
@@ -153,8 +156,9 @@ static void neo_set_ixon_flow_control(struct jsm_channel *ch)
 
 static void neo_set_ixoff_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting IXOFF FLOW\n");
 
@@ -190,8 +194,9 @@ static void neo_set_ixoff_flow_control(struct jsm_channel *ch)
 
 static void neo_set_no_input_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Unsetting Input FLOW\n");
 
@@ -228,8 +233,9 @@ static void neo_set_no_input_flow_control(struct jsm_channel *ch)
 
 static void neo_set_no_output_flow_control(struct jsm_channel *ch)
 {
-       u8 ier = readb(&ch->ch_neo_uart->ier);
-       u8 efr = readb(&ch->ch_neo_uart->efr);
+       u8 ier, efr;
+       ier = readb(&ch->ch_neo_uart->ier);
+       efr = readb(&ch->ch_neo_uart->efr);
 
        jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Unsetting Output FLOW\n");
 
@@ -527,7 +533,6 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
        if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM)))
                return;
 
-       len_written = 0;
        n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel;
 
        /* cache head and tail of queue */
@@ -571,12 +576,14 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
        jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev,
                        "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals);
 
-       if (!ch)
-               return;
-
        /* Scrub off lower bits. They signify delta's, which I don't care about */
-       msignals &= 0xf0;
+       /* Keep DDCD and DDSR though */
+       msignals &= 0xf8;
 
+       if (msignals & UART_MSR_DDCD)
+               uart_handle_dcd_change(&ch->uart_port, msignals & UART_MSR_DCD);
+       if (msignals & UART_MSR_DDSR)
+               uart_handle_cts_change(&ch->uart_port, msignals & UART_MSR_CTS);
        if (msignals & UART_MSR_DCD)
                ch->ch_mistat |= UART_MSR_DCD;
        else
@@ -611,14 +618,10 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
 /* Make the UART raise any of the output signals we want up */
 static void neo_assert_modem_signals(struct jsm_channel *ch)
 {
-       u8 out;
-
        if (!ch)
                return;
 
-       out = ch->ch_mostat;
-
-       writeb(out, &ch->ch_neo_uart->mcr);
+       writeb(ch->ch_mostat, &ch->ch_neo_uart->mcr);
 
        /* flush write operation */
        neo_pci_posting_flush(ch->ch_bd);
@@ -688,7 +691,7 @@ static void neo_flush_uart_read(struct jsm_channel *ch)
 /*
  * No locks are assumed to be held when calling this function.
  */
-void neo_clear_break(struct jsm_channel *ch, int force)
+static void neo_clear_break(struct jsm_channel *ch, int force)
 {
        unsigned long lock_flags;
 
@@ -928,10 +931,9 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
 static void neo_param(struct jsm_channel *ch)
 {
        u8 lcr = 0;
-       u8 uart_lcr = 0;
-       u8 ier = 0;
-       u32 baud = 9600;
-       int quot = 0;
+       u8 uart_lcr, ier;
+       u32 baud;
+       int quot;
        struct jsm_board *bd;
 
        bd = ch->ch_bd;
@@ -952,63 +954,49 @@ static void neo_param(struct jsm_channel *ch)
                ch->ch_flags |= (CH_BAUD0);
                ch->ch_mostat &= ~(UART_MCR_RTS | UART_MCR_DTR);
                neo_assert_modem_signals(ch);
-               ch->ch_old_baud = 0;
                return;
 
-       } else if (ch->ch_custom_speed) {
-                       baud = ch->ch_custom_speed;
-                       if (ch->ch_flags & CH_BAUD0)
-                               ch->ch_flags &= ~(CH_BAUD0);
-               } else {
-                       int iindex = 0;
-                       int jindex = 0;
-
-                       const u64 bauds[4][16] = {
-                               {
-                                       0,      50,     75,     110,
-                                       134,    150,    200,    300,
-                                       600,    1200,   1800,   2400,
-                                       4800,   9600,   19200,  38400 },
-                               {
-                                       0,      57600,  115200, 230400,
-                                       460800, 150,    200,    921600,
-                                       600,    1200,   1800,   2400,
-                                       4800,   9600,   19200,  38400 },
-                               {
-                                       0,      57600,  76800, 115200,
-                                       131657, 153600, 230400, 460800,
-                                       921600, 1200,   1800,   2400,
-                                       4800,   9600,   19200,  38400 },
-                               {
-                                       0,      57600,  115200, 230400,
-                                       460800, 150,    200,    921600,
-                                       600,    1200,   1800,   2400,
-                                       4800,   9600,   19200,  38400 }
-                       };
-
-                       baud = C_BAUD(ch->uart_port.info->tty) & 0xff;
-
-                       if (ch->ch_c_cflag & CBAUDEX)
-                               iindex = 1;
-
-                       jindex = baud;
-
-                       if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16))
-                               baud = bauds[iindex][jindex];
-                       else {
-                               jsm_printk(IOCTL, DEBUG, &ch->ch_bd->pci_dev,
-                                       "baud indices were out of range (%d)(%d)",
-                               iindex, jindex);
-                               baud = 0;
+       } else {
+               int i;
+               unsigned int cflag;
+               static struct {
+                       unsigned int rate;
+                       unsigned int cflag;
+               } baud_rates[] = {
+                       { 921600, B921600 },
+                       { 460800, B460800 },
+                       { 230400, B230400 },
+                       { 115200, B115200 },
+                       {  57600, B57600  },
+                       {  38400, B38400  },
+                       {  19200, B19200  },
+                       {   9600, B9600   },
+                       {   4800, B4800   },
+                       {   2400, B2400   },
+                       {   1200, B1200   },
+                       {    600, B600    },
+                       {    300, B300    },
+                       {    200, B200    },
+                       {    150, B150    },
+                       {    134, B134    },
+                       {    110, B110    },
+                       {     75, B75     },
+                       {     50, B50     },
+               };
+
+               cflag = C_BAUD(ch->uart_port.state->port.tty);
+               baud = 9600;
+               for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
+                       if (baud_rates[i].cflag == cflag) {
+                               baud = baud_rates[i].rate;
+                               break;
                        }
-
-                       if (baud == 0)
-                               baud = 9600;
-
-                       if (ch->ch_flags & CH_BAUD0)
-                               ch->ch_flags &= ~(CH_BAUD0);
                }
 
+               if (ch->ch_flags & CH_BAUD0)
+                       ch->ch_flags &= ~(CH_BAUD0);
+       }
+
        if (ch->ch_c_cflag & PARENB)
                lcr |= UART_LCR_PARITY;
 
@@ -1052,7 +1040,6 @@ static void neo_param(struct jsm_channel *ch)
        quot = ch->ch_bd->bd_dividend / baud;
 
        if (quot != 0) {
-               ch->ch_old_baud = baud;
                writeb(UART_LCR_DLAB, &ch->ch_neo_uart->lcr);
                writeb((quot & 0xff), &ch->ch_neo_uart->txrx);
                writeb((quot >> 8), &ch->ch_neo_uart->ier);
@@ -1117,9 +1104,9 @@ static void neo_param(struct jsm_channel *ch)
  *
  * Neo specific interrupt handler.
  */
-static irqreturn_t neo_intr(int irq, void *voidbrd, struct pt_regs *regs)
+static irqreturn_t neo_intr(int irq, void *voidbrd)
 {
-       struct jsm_board *brd = (struct jsm_board *) voidbrd;
+       struct jsm_board *brd = voidbrd;
        struct jsm_channel *ch;
        int port = 0;
        int type = 0;
@@ -1130,8 +1117,6 @@ static irqreturn_t neo_intr(int irq, void *voidbrd, struct pt_regs *regs)
        unsigned long lock_flags2;
        int outofloop_count = 0;
 
-       brd->intr_count++;
-
        /* Lock out the slow poller from running on this board. */
        spin_lock_irqsave(&brd->bd_intr_lock, lock_flags);