uart_dev_ns8250.c (262649) | uart_dev_ns8250.c (266046) |
---|---|
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 * --- 13 unchanged lines hidden (view full) --- 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 "opt_platform.h" 28 29#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 * --- 13 unchanged lines hidden (view full) --- 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 "opt_platform.h" 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: stable/10/sys/dev/uart/uart_dev_ns8250.c 262649 2014-03-01 04:16:54Z imp $"); | 30__FBSDID("$FreeBSD: stable/10/sys/dev/uart/uart_dev_ns8250.c 266046 2014-05-14 16:32:27Z ian $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/bus.h> 35#include <sys/conf.h> 36#include <sys/kernel.h> 37#include <sys/sysctl.h> 38#include <machine/bus.h> --- 605 unchanged lines hidden (view full) --- 644 uart_unlock(sc->sc_hwmtx); 645 return (ipend); 646} 647 648int 649ns8250_bus_param(struct uart_softc *sc, int baudrate, int databits, 650 int stopbits, int parity) 651{ | 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/bus.h> 35#include <sys/conf.h> 36#include <sys/kernel.h> 37#include <sys/sysctl.h> 38#include <machine/bus.h> --- 605 unchanged lines hidden (view full) --- 644 uart_unlock(sc->sc_hwmtx); 645 return (ipend); 646} 647 648int 649ns8250_bus_param(struct uart_softc *sc, int baudrate, int databits, 650 int stopbits, int parity) 651{ |
652 struct ns8250_softc *ns8250; |
|
652 struct uart_bas *bas; | 653 struct uart_bas *bas; |
653 int error; | 654 int error, limit; |
654 | 655 |
656 ns8250 = (struct ns8250_softc*)sc; |
|
655 bas = &sc->sc_bas; 656 uart_lock(sc->sc_hwmtx); | 657 bas = &sc->sc_bas; 658 uart_lock(sc->sc_hwmtx); |
659 /* 660 * When using DW UART with BUSY detection it is necessary to wait 661 * until all serial transfers are finished before manipulating the 662 * line control. LCR will not be affected when UART is busy. 663 */ 664 if (ns8250->busy_detect != 0) { 665 /* 666 * Pick an arbitrary high limit to avoid getting stuck in 667 * an infinite loop in case when the hardware is broken. 668 */ 669 limit = 10 * 1024; 670 while (((uart_getreg(bas, DW_REG_USR) & USR_BUSY) != 0) && 671 --limit) 672 DELAY(4); 673 674 if (limit <= 0) { 675 /* UART appears to be stuck */ 676 uart_unlock(sc->sc_hwmtx); 677 return (EIO); 678 } 679 } 680 |
|
657 error = ns8250_param(bas, baudrate, databits, stopbits, parity); 658 uart_unlock(sc->sc_hwmtx); 659 return (error); 660} 661 662int 663ns8250_bus_probe(struct uart_softc *sc) 664{ --- 269 unchanged lines hidden --- | 681 error = ns8250_param(bas, baudrate, databits, stopbits, parity); 682 uart_unlock(sc->sc_hwmtx); 683 return (error); 684} 685 686int 687ns8250_bus_probe(struct uart_softc *sc) 688{ --- 269 unchanged lines hidden --- |