Sat Jan 22 16:59:27 2011 UTC ()
Revert part of changes in rev 1.298:
 - it breaks cobalt's serial console as mentioned in PR port-cobalt/44292
 - MCR_PRESCALE doesn't affect unless EFR_EFCR is set in the EFR register
 - even if MCR_PRESCALE is enabled we should define appropriate sc_type
   variants and BRG values should be adjusted in comspeed() per sc_type
 - sc_frequency should be adjusted in MD attachment if necessary
Tested on cobalt by several people, ok from jklos@


(tsutsui)
diff -r1.298 -r1.299 src/sys/dev/ic/com.c

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

--- src/sys/dev/ic/com.c 2010/07/20 06:17:20 1.298
+++ src/sys/dev/ic/com.c 2011/01/22 16:59:26 1.299
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: com.c,v 1.298 2010/07/20 06:17:20 jklos Exp $ */ 1/* $NetBSD: com.c,v 1.299 2011/01/22 16:59:26 tsutsui 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, "$NetBSD: com.c,v 1.298 2010/07/20 06:17:20 jklos Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.299 2011/01/22 16:59:26 tsutsui 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
@@ -455,28 +455,26 @@ com_attach_subr(struct com_softc *sc) @@ -455,28 +455,26 @@ com_attach_subr(struct com_softc *sc)
455 * these chips. 455 * these chips.
456 */ 456 */
457 lcr = CSR_READ_1(regsp, COM_REG_LCR); 457 lcr = CSR_READ_1(regsp, COM_REG_LCR);
458 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS); 458 CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
459 CSR_WRITE_1(regsp, COM_REG_EFR, 0); 459 CSR_WRITE_1(regsp, COM_REG_EFR, 0);
460 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) { 460 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) {
461 CSR_WRITE_1(regsp, COM_REG_LCR, 461 CSR_WRITE_1(regsp, COM_REG_LCR,
462 lcr | LCR_DLAB); 462 lcr | LCR_DLAB);
463 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) { 463 if (CSR_READ_1(regsp, COM_REG_EFR) == 0) {
464 CLR(sc->sc_hwflags, COM_HW_FIFO); 464 CLR(sc->sc_hwflags, COM_HW_FIFO);
465 sc->sc_fifolen = 0; 465 sc->sc_fifolen = 0;
466 } else { 466 } else {
467 SET(sc->sc_hwflags, COM_HW_FLOW); 467 SET(sc->sc_hwflags, COM_HW_FLOW);
468 SET(sc->sc_mcr, MCR_PRESCALE); 
469 sc->sc_frequency /= 4; 
470 sc->sc_fifolen = 32; 468 sc->sc_fifolen = 32;
471 } 469 }
472 } else 470 } else
473#endif 471#endif
474 sc->sc_fifolen = 16; 472 sc->sc_fifolen = 16;
475 473
476#ifdef COM_16650 474#ifdef COM_16650
477 CSR_WRITE_1(regsp, COM_REG_LCR, lcr); 475 CSR_WRITE_1(regsp, COM_REG_LCR, lcr);
478 if (sc->sc_fifolen == 0) 476 if (sc->sc_fifolen == 0)
479 fifo_msg = "st16650, broken fifo"; 477 fifo_msg = "st16650, broken fifo";
480 else if (sc->sc_fifolen == 32) 478 else if (sc->sc_fifolen == 32)
481 fifo_msg = "st16650a, working fifo"; 479 fifo_msg = "st16650a, working fifo";
482 else 480 else