sio.c (112275) | sio.c (112384) |
---|---|
1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 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 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 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 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/dev/sio/sio.c 112275 2003-03-15 18:49:41Z sobomax $ | 33 * $FreeBSD: head/sys/dev/sio/sio.c 112384 2003-03-18 21:26:28Z sobomax $ |
34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 35 * from: i386/isa sio.c,v 1.234 36 */ 37 38#include "opt_comconsole.h" 39#include "opt_compat.h" 40#include "opt_ddb.h" 41#include "opt_sio.h" --- 73 unchanged lines hidden (view full) --- 115#define COM_NOFIFO(flags) ((flags) & 0x02) 116#define COM_PPSCTS(flags) ((flags) & 0x10000) 117#define COM_ST16650A(flags) ((flags) & 0x20000) 118#define COM_C_NOPROBE (0x40000) 119#define COM_NOPROBE(flags) ((flags) & COM_C_NOPROBE) 120#define COM_C_IIR_TXRDYBUG (0x80000) 121#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG) 122#define COM_NOSCR(flags) ((flags) & 0x100000) | 34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 35 * from: i386/isa sio.c,v 1.234 36 */ 37 38#include "opt_comconsole.h" 39#include "opt_compat.h" 40#include "opt_ddb.h" 41#include "opt_sio.h" --- 73 unchanged lines hidden (view full) --- 115#define COM_NOFIFO(flags) ((flags) & 0x02) 116#define COM_PPSCTS(flags) ((flags) & 0x10000) 117#define COM_ST16650A(flags) ((flags) & 0x20000) 118#define COM_C_NOPROBE (0x40000) 119#define COM_NOPROBE(flags) ((flags) & COM_C_NOPROBE) 120#define COM_C_IIR_TXRDYBUG (0x80000) 121#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG) 122#define COM_NOSCR(flags) ((flags) & 0x100000) |
123#define COM_TI16754(flags) ((flags) & 0x200000) | 123#define COM_TI16754(flags) ((flags) & 0x200000) |
124#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24) 125 126#define sio_getreg(com, off) \ 127 (bus_space_read_1((com)->bst, (com)->bsh, (off))) 128#define sio_setreg(com, off, value) \ 129 (bus_space_write_1((com)->bst, (com)->bsh, (off), (value))) 130 131/* --- 469 unchanged lines hidden (view full) --- 601 * Interrupts from this line should already be masked in the ICU, 602 * but mask them in the processor as well in case there are some 603 * (misconfigured) shared interrupts. 604 */ 605 mtx_lock_spin(&sio_lock); 606/* EXTRA DELAY? */ 607 608 /* | 124#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24) 125 126#define sio_getreg(com, off) \ 127 (bus_space_read_1((com)->bst, (com)->bsh, (off))) 128#define sio_setreg(com, off, value) \ 129 (bus_space_write_1((com)->bst, (com)->bsh, (off), (value))) 130 131/* --- 469 unchanged lines hidden (view full) --- 601 * Interrupts from this line should already be masked in the ICU, 602 * but mask them in the processor as well in case there are some 603 * (misconfigured) shared interrupts. 604 */ 605 mtx_lock_spin(&sio_lock); 606/* EXTRA DELAY? */ 607 608 /* |
609 * For the TI16754 chips set prescaler to 1 (4 is often the 610 * default after-reset value), otherwise it's impossible to | 609 * For the TI16754 chips, set prescaler to 1 (4 is often the 610 * default after-reset value) as otherwise it's impossible to |
611 * get highest baudrates. 612 */ 613 if (COM_TI16754(flags)) { | 611 * get highest baudrates. 612 */ 613 if (COM_TI16754(flags)) { |
614 u_char t1, t2; | 614 u_char cfcr, efr; |
615 | 615 |
616 /* Save LCR */ 617 t1 = sio_getreg(com, com_lctl); 618 /* Enable EFR */ 619 sio_setreg(com, com_lctl, 0xbf); 620 /* Save EFR */ 621 t2 = sio_getreg(com, com_iir); 622 /* Unlock MCR[7] */ 623 sio_setreg(com, com_iir, t2 | 0x10); 624 /* Disable EFR */ 625 sio_setreg(com, com_lctl, 0); 626 /* Set prescaler to 1 */ 627 sio_setreg(com, com_mcr, sio_getreg(com, com_mcr) & 0x7f); 628 /* Enable EFR */ 629 sio_setreg(com, com_lctl, 0xbf); 630 /* Restore EFR */ 631 sio_setreg(com, com_iir, t2); 632 /* Restore LCR */ 633 sio_setreg(com, com_lctl, t1); | 616 cfcr = sio_getreg(com, com_cfcr); 617 sio_setreg(com, com_cfcr, CFCR_EFR_ENABLE); 618 efr = sio_getreg(com, com_efr); 619 /* Unlock extended features to turn off prescaler. */ 620 sio_setreg(com, com_efr, efr | EFR_EFE); 621 /* Disable EFR. */ 622 sio_setreg(com, com_cfcr, (cfcr != CFCR_EFR_ENABLE) ? cfcr : 0); 623 /* Turn off prescaler. */ 624 sio_setreg(com, com_mcr, 625 sio_getreg(com, com_mcr) & ~MCR_PRESCALE); 626 sio_setreg(com, com_cfcr, CFCR_EFR_ENABLE); 627 sio_setreg(com, com_efr, efr); 628 sio_setreg(com, com_cfcr, cfcr); |
634 } | 629 } |
630 |
|
635 /* 636 * Initialize the speed and the word size and wait long enough to 637 * drain the maximum of 16 bytes of junk in device output queues. 638 * The speed is undefined after a master reset and must be set 639 * before relying on anything related to output. There may be 640 * junk after a (very fast) soft reboot and (apparently) after 641 * master reset. 642 * XXX what about the UART bug avoided by waiting in comparam()? --- 2666 unchanged lines hidden --- | 631 /* 632 * Initialize the speed and the word size and wait long enough to 633 * drain the maximum of 16 bytes of junk in device output queues. 634 * The speed is undefined after a master reset and must be set 635 * before relying on anything related to output. There may be 636 * junk after a (very fast) soft reboot and (apparently) after 637 * master reset. 638 * XXX what about the UART bug avoided by waiting in comparam()? --- 2666 unchanged lines hidden --- |