uart_dev_ns8250.c (168281) | uart_dev_ns8250.c (168285) |
---|---|
1/*- 2 * Copyright (c) 2003 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_dev_ns8250.c 168281 2007-04-02 22:00:22Z marcel $"); | 28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_dev_ns8250.c 168285 2007-04-03 01:21:10Z marcel $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/conf.h> 34#include <machine/bus.h> 35 36#include <dev/uart/uart.h> --- 243 unchanged lines hidden (view full) --- 280 /* Clear RTS & DTR. */ 281 uart_setreg(bas, REG_MCR, MCR_IE); 282 uart_barrier(bas); 283} 284 285static void 286ns8250_putc(struct uart_bas *bas, int c) 287{ | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/conf.h> 34#include <machine/bus.h> 35 36#include <dev/uart/uart.h> --- 243 unchanged lines hidden (view full) --- 280 /* Clear RTS & DTR. */ 281 uart_setreg(bas, REG_MCR, MCR_IE); 282 uart_barrier(bas); 283} 284 285static void 286ns8250_putc(struct uart_bas *bas, int c) 287{ |
288 int delay, limit; | 288 int limit; |
289 | 289 |
290 /* 1/10th the time to transmit 1 character (estimate). */ 291 delay = ns8250_delay(bas); 292 293 limit = 20; | 290 limit = 250000; |
294 while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0 && --limit) | 291 while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0 && --limit) |
295 DELAY(delay); | 292 DELAY(4); |
296 uart_setreg(bas, REG_DATA, c); 297 uart_barrier(bas); | 293 uart_setreg(bas, REG_DATA, c); 294 uart_barrier(bas); |
298 limit = 40; | 295 limit = 250000; |
299 while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit) | 296 while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit) |
300 DELAY(delay); | 297 DELAY(4); |
301} 302 303static int 304ns8250_rxready(struct uart_bas *bas) 305{ 306 307 return ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) != 0 ? 1 : 0); 308} 309 310static int 311ns8250_getc(struct uart_bas *bas, struct mtx *hwmtx) 312{ | 298} 299 300static int 301ns8250_rxready(struct uart_bas *bas) 302{ 303 304 return ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) != 0 ? 1 : 0); 305} 306 307static int 308ns8250_getc(struct uart_bas *bas, struct mtx *hwmtx) 309{ |
313 int c, delay; | 310 int c; |
314 315 uart_lock(hwmtx); 316 | 311 312 uart_lock(hwmtx); 313 |
317 /* 1/10th the time to transmit 1 character (estimate). */ 318 delay = ns8250_delay(bas); 319 | |
320 while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) == 0) { 321 uart_unlock(hwmtx); | 314 while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) == 0) { 315 uart_unlock(hwmtx); |
322 DELAY(delay); | 316 DELAY(4); |
323 uart_lock(hwmtx); 324 } 325 326 c = uart_getreg(bas, REG_DATA); 327 328 uart_unlock(hwmtx); 329 330 return (c); --- 493 unchanged lines hidden --- | 317 uart_lock(hwmtx); 318 } 319 320 c = uart_getreg(bas, REG_DATA); 321 322 uart_unlock(hwmtx); 323 324 return (c); --- 493 unchanged lines hidden --- |