|
Message
From: György 'nog' Jeney<nog@s...>
Date: Sun May 29 17:52:28 CEST 2005
Subject: [openrisc] [or1ksim #99] UART: Move vapi command handling out of
uart_clock16 [1/6]
Hi,Changelog says it all. ChangeLog: * Move vapi command handling out of uart_clock16.
nog. -------------- next part -------------- --- ../or1ksim-patch/peripheral/16450.c 2005-05-29 14:19:02.000000000 +0200 +++ peripheral/16450.c 2005-05-29 14:32:53.000000000 +0200 @@ -386,6 +386,70 @@ uint8_t uart_read_byte(oraddr_t addr, vo return value; } +/*--------------------------------------------------------[ VAPI handling ]---*/ +/* Decodes the read vapi command */ +static void uart_vapi_cmd(struct dev_16450 *uart) +{ + int received = 0; + + while (!received) { + if (uart->vapi_buf_head_ptr != uart->vapi_buf_tail_ptr) { + unsigned long data = uart->vapi_buf[uart->vapi_buf_tail_ptr]; + TRACE("\tHandling: %08lx (%i,%i)\n", data, uart->vapi_buf_head_ptr, + uart->vapi_buf_tail_ptr); + uart->vapi_buf_tail_ptr = (uart->vapi_buf_tail_ptr + 1) % UART_VAPI_BUF_LEN; + switch (data >> 24) { + case 0x00: + uart->vapi.lcr = (data >> 8) & 0xff; + /* Put data into rx fifo */ + uart->iregs.rxser = data & 0xff; + uart->vapi.char_clks = char_clks (uart->vapi.dll, uart->vapi.dlh, uart->vapi.lcr); + if((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC) + || uart->vapi.char_clks != uart->char_clks + || uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) { + if((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC)) + WARN("unmatched VAPI (%02"PRIx8") and uart (%02"PRIx8") modes.\n", + uart->vapi.lcr & ~UART_LCR_SBC, uart->regs.lcr & ~UART_LCR_SBC); + if(uart->vapi.char_clks != uart->char_clks) { + WARN("unmatched VAPI (%li) and uart (%li) char clocks.\n", + uart->vapi.char_clks, uart->char_clks); + WARN("VAPI: lcr: %02"PRIx8", dll: %02"PRIx8", dlh: %02"PRIx8"\n", + uart->vapi.lcr, uart->vapi.dll, uart->vapi.dlh); + WARN("UART: lcr: %02"PRIx8", dll: %02"PRIx8", dlh: %02"PRIx8"\n", + uart->regs.lcr, uart->regs.dll, uart->vapi.dlh); + } + if(uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) + WARN("VAPI skew is beyond max: %i\n", uart->vapi.skew); + /* Set error bits */ + uart->iregs.rxser |= (UART_LSR_FRAME | UART_LSR_RXERR) << 8; + if(uart->regs.lcr & UART_LCR_PARITY) + uart->iregs.rxser |= UART_LSR_PARITY << 8; + } + uart->istat.rxser_full = 1; + received = 1; + break; + case 0x01: + uart->vapi.dll = (data >> 0) & 0xff; + uart->vapi.dlh = (data >> 8) & 0xff; + break; + case 0x02: + uart->vapi.lcr = (data >> 8) & 0xff; + break; + case 0x03: + uart->vapi.skew = (signed short)(data & 0xffff); + break; + case 0x04: + uart->vapi.next_break_cnt = data & 0xffff; + uart->vapi.next_break = (data >> 16) & 1; + break; + default: + WARN("WARNING: Invalid vapi command %02lx\n", data >> 24); + break; + } + } else break; + } +} + /* Function that handles incoming VAPI data. */ void uart_vapi_read (unsigned long id, unsigned long data, void *dat) { @@ -498,53 +562,9 @@ void uart_clock16 (void *dat) } } } else { /* VAPI */ - int received = 0; /* do not handle commands while receiving */ if (uart->istat.rxser_full) return; - while (!received) { - if (uart->vapi_buf_head_ptr != uart->vapi_buf_tail_ptr) { - unsigned long data = uart->vapi_buf[uart->vapi_buf_tail_ptr]; - TRACE("\tHandling: %08lx (%i,%i)\n", data, uart->vapi_buf_head_ptr, - uart->vapi_buf_tail_ptr); - uart->vapi_buf_tail_ptr = (uart->vapi_buf_tail_ptr + 1) % UART_VAPI_BUF_LEN; - switch (data >> 24) { - case 0x00: - uart->vapi.lcr = (data >> 8) & 0xff; - /* Put data into rx fifo */ - uart->iregs.rxser = data & 0xff; - uart->vapi.char_clks = char_clks (uart->vapi.dll, uart->vapi.dlh, uart->vapi.lcr); - if ((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC) - || uart->vapi.char_clks != uart->char_clks - || uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) { - WARN("WARNING: unmatched VAPI (%02x) and uart (%02x) modes.\n",
- uart->vapi.lcr & ~UART_LCR_SBC, uart->regs.lcr & ~UART_LCR_SBC);
- /* Set error bits */
- uart->iregs.rxser |= (UART_LSR_FRAME | UART_LSR_RXERR) << 8;
- if (uart->regs.lcr & UART_LCR_PARITY) uart->iregs.rxser |= UART_LSR_PARITY << 8;
- }
- uart->istat.rxser_full = 1;
- received = 1;
- break;
- case 0x01:
- uart->vapi.dll = (data >> 0) & 0xff;
- uart->vapi.dlh = (data >> 8) & 0xff;
- break;
- case 0x02:
- uart->vapi.lcr = (data >> 8) & 0xff;
- break;
- case 0x03:
- uart->vapi.skew = (signed short)(data & 0xffff);
- break;
- case 0x04:
- uart->vapi.next_break_cnt = data & 0xffff;
- uart->vapi.next_break = (data >> 16) & 1;
- break;
- default:
- WARN ("WARNING: Invalid vapi command %02lx\n", data >> 24);
- break;
- }
- } else break;
- }
+ uart_vapi_cmd(uart);
}
}
|
 |