Sat Oct 25 17:50:29 2008 UTC ()
Simplify NOERS case.  Revert most changes back to 1.283.


(matt)
diff -r1.285 -r1.286 src/sys/dev/ic/com.c

cvs diff -r1.285 -r1.286 src/sys/dev/ic/com.c (expand / switch to unified diff)

--- src/sys/dev/ic/com.c 2008/10/25 15:21:57 1.285
+++ src/sys/dev/ic/com.c 2008/10/25 17:50:29 1.286
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* com.c,v 1.262.2.3 2008/01/09 01:52:50 matt Exp */ 1/* $NetBSD: com.c,v 1.286 2008/10/25 17:50:29 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum. 8 * by Charles M. Hannum.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)com.c 7.5 (Berkeley) 5/16/91 60 * @(#)com.c 7.5 (Berkeley) 5/16/91
61 */ 61 */
62 62
63/* 63/*
64 * COM driver, uses National Semiconductor NS16450/NS16550AF UART 64 * COM driver, uses National Semiconductor NS16450/NS16550AF UART
65 * Supports automatic hardware flow control on StarTech ST16C650A UART 65 * Supports automatic hardware flow control on StarTech ST16C650A UART
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "com.c,v 1.262.2.3 2008/01/09 01:52:50 matt Exp"); 69__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.286 2008/10/25 17:50:29 matt Exp $");
70 70
71#include "opt_com.h" 71#include "opt_com.h"
72#include "opt_ddb.h" 72#include "opt_ddb.h"
73#include "opt_kgdb.h" 73#include "opt_kgdb.h"
74#include "opt_lockdebug.h" 74#include "opt_lockdebug.h"
75#include "opt_multiprocessor.h" 75#include "opt_multiprocessor.h"
76#include "opt_ntp.h" 76#include "opt_ntp.h"
77 77
78#include "rnd.h" 78#include "rnd.h"
79#if NRND > 0 && defined(RND_COM) 79#if NRND > 0 && defined(RND_COM)
80#include <sys/rnd.h> 80#include <sys/rnd.h>
81#endif 81#endif
82 82
@@ -394,26 +394,32 @@ com_attach_subr(struct com_softc *sc) @@ -394,26 +394,32 @@ com_attach_subr(struct com_softc *sc)
394 } 394 }
395 395
396 /* Probe for FIFO */ 396 /* Probe for FIFO */
397 switch (sc->sc_type) { 397 switch (sc->sc_type) {
398 case COM_TYPE_HAYESP: 398 case COM_TYPE_HAYESP:
399 goto fifodone; 399 goto fifodone;
400 400
401 case COM_TYPE_AU1x00: 401 case COM_TYPE_AU1x00:
402 sc->sc_fifolen = 16; 402 sc->sc_fifolen = 16;
403 fifo_msg = "Au1X00 UART, working fifo"; 403 fifo_msg = "Au1X00 UART, working fifo";
404 SET(sc->sc_hwflags, COM_HW_FIFO); 404 SET(sc->sc_hwflags, COM_HW_FIFO);
405 goto fifodelay; 405 goto fifodelay;
406  406
 407 case COM_TYPE_16550_NOERS:
 408 sc->sc_fifolen = 16;
 409 fifo_msg = "ns16650, no ERS, working fifo";
 410 SET(sc->sc_hwflags, COM_HW_FIFO);
 411 goto fifodelay;
 412
407 case COM_TYPE_OMAP: 413 case COM_TYPE_OMAP:
408 sc->sc_fifolen = 64; 414 sc->sc_fifolen = 64;
409 fifo_msg = "OMAP UART, working fifo"; 415 fifo_msg = "OMAP UART, working fifo";
410 SET(sc->sc_hwflags, COM_HW_FIFO); 416 SET(sc->sc_hwflags, COM_HW_FIFO);
411 goto fifodelay; 417 goto fifodelay;
412 } 418 }
413 419
414 sc->sc_fifolen = 1; 420 sc->sc_fifolen = 1;
415 /* look for a NS 16550AF UART with FIFOs */ 421 /* look for a NS 16550AF UART with FIFOs */
416 CSR_WRITE_1(regsp, COM_REG_FIFO, 422 CSR_WRITE_1(regsp, COM_REG_FIFO,
417 FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); 423 FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);
418 delay(100); 424 delay(100);
419 if (ISSET(CSR_READ_1(regsp, COM_REG_IIR), IIR_FIFO_MASK) 425 if (ISSET(CSR_READ_1(regsp, COM_REG_IIR), IIR_FIFO_MASK)
@@ -424,52 +430,45 @@ com_attach_subr(struct com_softc *sc) @@ -424,52 +430,45 @@ com_attach_subr(struct com_softc *sc)
424 430
425#ifdef COM_16650 431#ifdef COM_16650
426 /* 432 /*
427 * IIR changes into the EFR if LCR is set to LCR_EERS 433 * IIR changes into the EFR if LCR is set to LCR_EERS
428 * on 16650s. We also know IIR != 0 at this point. 434 * on 16650s. We also know IIR != 0 at this point.
429 * Write 0 into the EFR, and read it. If the result 435 * Write 0 into the EFR, and read it. If the result
430 * is 0, we have a 16650. 436 * is 0, we have a 16650.
431 * 437 *
432 * Older 16650s were broken; the test to detect them 438 * Older 16650s were broken; the test to detect them
433 * is taken from the Linux driver. Apparently 439 * is taken from the Linux driver. Apparently
434 * setting DLAB enable gives access to the EFR on 440 * setting DLAB enable gives access to the EFR on
435 * these chips. 441 * these chips.
436 */ 442 */
437 if (sc->sc_type != COM_TYPE_16550_NOERS) { 443 lcr = CSR_READ_1(regsp, COM_REG_LCR);
438 lcr = CSR_READ_1(regsp, COM_REG_LCR); 444 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
439 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS); 445 CSR_WRITE_1(regsp, COM_REG_EFR, 0);
440 CSR_WRITE_1(regsp, COM_REG_EFR, 0); 446 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) {
441  447 CSR_WRITE_1(regsp, COM_REG_LCR,
 448 lcr | LCR_DLAB);
442 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) { 449 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) {
443 CSR_WRITE_1(regsp, COM_REG_LCR, 450 CLR(sc->sc_hwflags, COM_HW_FIFO);
444 lcr | LCR_DLAB); 451 sc->sc_fifolen = 0;
445 if (CSR_READ_1(regsp, COM_REG_EFR) 452 } else {
446 == 0) { 453 SET(sc->sc_hwflags, COM_HW_FLOW);
447 CLR(sc->sc_hwflags, 454 sc->sc_fifolen = 32;
448 COM_HW_FIFO); 455 }
449 sc->sc_fifolen = 0; 
450 } else { 
451 SET(sc->sc_hwflags, 
452 COM_HW_FLOW); 
453 sc->sc_fifolen = 32; 
454 } 
455 } else 
456 sc->sc_fifolen = 16; 
457 CSR_WRITE_1(regsp, COM_REG_LCR, lcr); 
458 } else 456 } else
459#endif 457#endif
460 sc->sc_fifolen = 16; 458 sc->sc_fifolen = 16;
461 459
462#ifdef COM_16650 460#ifdef COM_16650
 461 CSR_WRITE_1(regsp, COM_REG_LCR, lcr);
463 if (sc->sc_fifolen == 0) 462 if (sc->sc_fifolen == 0)
464 fifo_msg = "st16650, broken fifo"; 463 fifo_msg = "st16650, broken fifo";
465 else if (sc->sc_fifolen == 32) 464 else if (sc->sc_fifolen == 32)
466 fifo_msg = "st16650a, working fifo"; 465 fifo_msg = "st16650a, working fifo";
467 else 466 else
468#endif 467#endif
469 fifo_msg = "ns16550a, working fifo"; 468 fifo_msg = "ns16550a, working fifo";
470 } else 469 } else
471 fifo_msg = "ns16550, broken fifo"; 470 fifo_msg = "ns16550, broken fifo";
472 else 471 else
473 fifo_msg = "ns8250 or ns16450, no fifo"; 472 fifo_msg = "ns8250 or ns16450, no fifo";
474 CSR_WRITE_1(regsp, COM_REG_FIFO, 0); 473 CSR_WRITE_1(regsp, COM_REG_FIFO, 0);
475fifodelay: 474fifodelay:
@@ -1451,32 +1450,31 @@ com_loadchannelregs(struct com_softc *sc @@ -1451,32 +1450,31 @@ com_loadchannelregs(struct com_softc *sc
1451 com_iflush(sc); 1450 com_iflush(sc);
1452 1451
1453 if (sc->sc_type == COM_TYPE_PXA2x0) 1452 if (sc->sc_type == COM_TYPE_PXA2x0)
1454 CSR_WRITE_1(regsp, COM_REG_IER, IER_EUART); 1453 CSR_WRITE_1(regsp, COM_REG_IER, IER_EUART);
1455 else 1454 else
1456 CSR_WRITE_1(regsp, COM_REG_IER, 0); 1455 CSR_WRITE_1(regsp, COM_REG_IER, 0);
1457 1456
1458 if (sc->sc_type == COM_TYPE_OMAP) { 1457 if (sc->sc_type == COM_TYPE_OMAP) {
1459 /* disable before changing settings */ 1458 /* disable before changing settings */
1460 CSR_WRITE_1(regsp, COM_REG_MDR1, MDR1_MODE_DISABLE); 1459 CSR_WRITE_1(regsp, COM_REG_MDR1, MDR1_MODE_DISABLE);
1461 } 1460 }
1462 1461
1463 if (ISSET(sc->sc_hwflags, COM_HW_FLOW)) { 1462 if (ISSET(sc->sc_hwflags, COM_HW_FLOW)) {
1464 if (sc->sc_type != COM_TYPE_AU1x00 1463 KASSERT(sc->sc_type != COM_TYPE_AU1x00);
1465 && sc->sc_type != COM_TYPE_16550_NOERS) { 1464 KASSERT(sc->sc_type != COM_TYPE_16550_NOERS);
1466 /* no EFR on alchemy */ 1465 /* no EFR on alchemy */
1467 CSR_WRITE_1(regsp, COM_REG_EFR, sc->sc_efr); 1466 CSR_WRITE_1(regsp, COM_REG_EFR, sc->sc_efr);
1468 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS); 1467 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
1469 } 
1470 } 1468 }
1471 if (sc->sc_type == COM_TYPE_AU1x00) { 1469 if (sc->sc_type == COM_TYPE_AU1x00) {
1472 /* alchemy has single separate 16-bit clock divisor register */ 1470 /* alchemy has single separate 16-bit clock divisor register */
1473 CSR_WRITE_2(regsp, COM_REG_DLBL, sc->sc_dlbl + 1471 CSR_WRITE_2(regsp, COM_REG_DLBL, sc->sc_dlbl +
1474 (sc->sc_dlbh << 8)); 1472 (sc->sc_dlbh << 8));
1475 } else { 1473 } else {
1476 CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr | LCR_DLAB); 1474 CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr | LCR_DLAB);
1477 CSR_WRITE_1(regsp, COM_REG_DLBL, sc->sc_dlbl); 1475 CSR_WRITE_1(regsp, COM_REG_DLBL, sc->sc_dlbl);
1478 CSR_WRITE_1(regsp, COM_REG_DLBH, sc->sc_dlbh); 1476 CSR_WRITE_1(regsp, COM_REG_DLBH, sc->sc_dlbh);
1479 } 1477 }
1480 CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr); 1478 CSR_WRITE_1(regsp, COM_REG_LCR, sc->sc_lcr);
1481 CSR_WRITE_1(regsp, COM_REG_MCR, sc->sc_mcr_active = sc->sc_mcr); 1479 CSR_WRITE_1(regsp, COM_REG_MCR, sc->sc_mcr_active = sc->sc_mcr);
1482 CSR_WRITE_1(regsp, COM_REG_FIFO, sc->sc_fifo); 1480 CSR_WRITE_1(regsp, COM_REG_FIFO, sc->sc_fifo);