CVS commit: src/sys/arch/evbarm/dev

2020-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Oct 19 17:00:02 UTC 2020

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
remove superfluous parentheses in PREAD4/PWRITE4 macros


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.61 src/sys/arch/evbarm/dev/plcom.c:1.62
--- src/sys/arch/evbarm/dev/plcom.c:1.61	Sat Apr 25 21:34:08 2020
+++ src/sys/arch/evbarm/dev/plcom.c	Mon Oct 19 17:00:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.61 2020/04/25 21:34:08 jmcneill Exp $	*/
+/*	$NetBSD: plcom.c,v 1.62 2020/10/19 17:00:02 tnn Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.61 2020/04/25 21:34:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.62 2020/10/19 17:00:02 tnn Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -297,12 +297,12 @@ pwritem1(struct plcom_instance *pi, bus_
 
 #define	PREAD1(pi, reg)		pread1(pi, reg)
 #define	PREAD4(pi, reg)		\
-	(bus_space_read_4((pi)->pi_iot, (pi)->pi_ioh, (reg)))
+	bus_space_read_4((pi)->pi_iot, (pi)->pi_ioh, (reg))
 
 #define	PWRITE1(pi, reg, val)	pwrite1(pi, reg, val)
 #define	PWRITEM1(pi, reg, d, c)	pwritem1(pi, reg, d, c)
 #define	PWRITE4(pi, reg, val)	\
-	(bus_space_write_4((pi)->pi_iot, (pi)->pi_ioh, (reg), (val)))
+	bus_space_write_4((pi)->pi_iot, (pi)->pi_ioh, (reg), (val))
 
 int
 pl010comspeed(long speed, long frequency)



CVS commit: src/sys/arch/evbarm/dev

2020-04-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Apr 25 21:34:08 UTC 2020

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
plcom_common_putc: do not wait for FIFO to train after writing data


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.60 src/sys/arch/evbarm/dev/plcom.c:1.61
--- src/sys/arch/evbarm/dev/plcom.c:1.60	Sun Nov 10 21:16:25 2019
+++ src/sys/arch/evbarm/dev/plcom.c	Sat Apr 25 21:34:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.60 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: plcom.c,v 1.61 2020/04/25 21:34:08 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.60 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.61 2020/04/25 21:34:08 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2327,11 +2327,6 @@ plcom_common_putc(dev_t dev, struct plco
 	PWRITE1(pi, PL01XCOM_DR, c);
 	PLCOM_BARRIER(pi, BR | BW);
 
-	/* wait for this transmission to complete */
-	timo = 150;
-	while (!ISSET(PREAD1(pi, PL01XCOM_FR), PL01X_FR_TXFE) && --timo)
-		continue;
-
 	splx(s);
 }
 



CVS commit: src/sys/arch/evbarm/dev

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 23:57:00 UTC 2018

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Don't write FBRD/IBRD if ref clk frequency is unknown


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.54 src/sys/arch/evbarm/dev/plcom.c:1.55
--- src/sys/arch/evbarm/dev/plcom.c:1.54	Fri Oct 12 22:18:38 2018
+++ src/sys/arch/evbarm/dev/plcom.c	Fri Oct 12 23:57:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $	*/
+/*	$NetBSD: plcom.c,v 1.55 2018/10/12 23:57:00 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.55 2018/10/12 23:57:00 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -1537,8 +1537,10 @@ plcom_loadchannelregs(struct plcom_softc
 	switch (pi->pi_type) {
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, 0);
-		PWRITE1(pi, PL010COM_DLBL, sc->sc_ratel);
-		PWRITE1(pi, PL010COM_DLBH, sc->sc_rateh);
+		if (sc->sc_frequency != 0) {
+			PWRITE1(pi, PL010COM_DLBL, sc->sc_ratel);
+			PWRITE1(pi, PL010COM_DLBH, sc->sc_rateh);
+		}
 		PWRITE1(pi, PL010COM_LCR, sc->sc_lcr);
 
 		/* XXX device_unit() abuse */
@@ -1552,8 +1554,10 @@ plcom_loadchannelregs(struct plcom_softc
 
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, 0);
-		PWRITE1(pi, PL011COM_FBRD, sc->sc_ratel);
-		PWRITE4(pi, PL011COM_IBRD, sc->sc_rateh);
+		if (sc->sc_frequency != 0) {
+			PWRITE1(pi, PL011COM_FBRD, sc->sc_ratel);
+			PWRITE4(pi, PL011COM_IBRD, sc->sc_rateh);
+		}
 		PWRITE1(pi, PL011COM_LCRH, sc->sc_lcr);
 		sc->sc_mcr_active = sc->sc_mcr;
 		CLR(sc->sc_cr, PL011_MCR(PL01X_MCR_RTS | PL01X_MCR_DTR));



CVS commit: src/sys/arch/evbarm/dev

2018-10-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct 12 22:18:38 UTC 2018

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
If rate or frequency are unspecified, assume "use firmware configuration" for 
clocks


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.53 src/sys/arch/evbarm/dev/plcom.c:1.54
--- src/sys/arch/evbarm/dev/plcom.c:1.53	Tue Nov  7 07:21:13 2017
+++ src/sys/arch/evbarm/dev/plcom.c	Fri Oct 12 22:18:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.54 2018/10/12 22:18:38 jmcneill Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2367,18 +2367,22 @@ plcominit(struct plcom_instance *pi, int
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, 0);
 
-		rate = pl010comspeed(rate, frequency);
-		PWRITE1(pi, PL010COM_DLBL, (rate & 0xff));
-		PWRITE1(pi, PL010COM_DLBH, ((rate >> 8) & 0xff));
+		if (rate && frequency) {
+			rate = pl010comspeed(rate, frequency);
+			PWRITE1(pi, PL010COM_DLBL, (rate & 0xff));
+			PWRITE1(pi, PL010COM_DLBH, ((rate >> 8) & 0xff));
+		}
 		PWRITE1(pi, PL010COM_LCR, lcr);
 		PWRITE1(pi, PL010COM_CR, PL01X_CR_UARTEN);
 		break;
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, 0);
 
-		rate = pl011comspeed(rate, frequency);
-		PWRITE1(pi, PL011COM_FBRD, rate & ((1 << 6) - 1));
-		PWRITE4(pi, PL011COM_IBRD, rate >> 6);
+		if (rate && frequency) {
+			rate = pl011comspeed(rate, frequency);
+			PWRITE1(pi, PL011COM_FBRD, rate & ((1 << 6) - 1));
+			PWRITE4(pi, PL011COM_IBRD, rate >> 6);
+		}
 		PWRITE1(pi, PL011COM_LCRH, lcr);
 		PWRITE4(pi, PL011COM_CR,
 		PL01X_CR_UARTEN | PL011_CR_RXE | PL011_CR_TXE);



CVS commit: src/sys/arch/evbarm/dev

2017-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Nov  7 07:21:13 UTC 2017

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Fix the "wait for any pending transmission to finish" - doesn't really
matter at the moment as the fifo is disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.52 src/sys/arch/evbarm/dev/plcom.c:1.53
--- src/sys/arch/evbarm/dev/plcom.c:1.52	Mon Apr 13 21:18:41 2015
+++ src/sys/arch/evbarm/dev/plcom.c	Tue Nov  7 07:21:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.52 2015/04/13 21:18:41 riastradh Exp $	*/
+/*	$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.52 2015/04/13 21:18:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.53 2017/11/07 07:21:13 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2323,7 +2323,7 @@ plcom_common_putc(dev_t dev, struct plco
 
 	/* wait for any pending transmission to finish */
 	timo = 15;
-	while (!ISSET(PREAD1(pi, PL01XCOM_FR), PL01X_FR_TXFE) && --timo)
+	while (ISSET(PREAD1(pi, PL01XCOM_FR), PL01X_FR_TXFF) && --timo)
 		continue;
 
 	PWRITE1(pi, PL01XCOM_DR, c);



CVS commit: src/sys/arch/evbarm/dev

2017-10-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 12 20:05:42 UTC 2017

Modified Files:
src/sys/arch/evbarm/dev: plcomvar.h

Log Message:
G/C unused struct


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.16 src/sys/arch/evbarm/dev/plcomvar.h:1.17
--- src/sys/arch/evbarm/dev/plcomvar.h:1.16	Mon Apr 13 21:18:41 2015
+++ src/sys/arch/evbarm/dev/plcomvar.h	Thu Oct 12 20:05:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.16 2015/04/13 21:18:41 riastradh Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.17 2017/10/12 20:05:42 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -84,14 +84,6 @@ struct plcom_instance {
 	struct plcom_registers	*pi_regs;
 };
 
-struct plcomcons_info {
-	int	rate;
-	int	frequency;
-	int	type;
-
-	tcflag_t	cflag;
-};
-
 struct plcom_softc {
 	device_t sc_dev;
 



CVS commit: src/sys/arch/evbarm/dev

2014-02-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 21 16:08:19 UTC 2014

Modified Files:
src/sys/arch/evbarm/dev: plcomvar.h

Log Message:
No need to include sys/simplelock.h here.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.14 src/sys/arch/evbarm/dev/plcomvar.h:1.15
--- src/sys/arch/evbarm/dev/plcomvar.h:1.14	Wed May  1 07:33:24 2013
+++ src/sys/arch/evbarm/dev/plcomvar.h	Fri Feb 21 16:08:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.14 2013/05/01 07:33:24 mlelstv Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.15 2014/02/21 16:08:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -42,7 +42,6 @@
 
 #include 
 #include 
-#include 
 
 struct plcom_instance;
 



CVS commit: src/sys/arch/evbarm/dev

2013-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 09:52:33 UTC 2013

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Sprinkle __unused.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.46 src/sys/arch/evbarm/dev/plcom.c:1.47
--- src/sys/arch/evbarm/dev/plcom.c:1.46	Thu Sep  5 07:09:14 2013
+++ src/sys/arch/evbarm/dev/plcom.c	Sat Dec 14 09:52:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.46 2013/09/05 07:09:14 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.47 2013/12/14 09:52:33 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.46 2013/09/05 07:09:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.47 2013/12/14 09:52:33 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2288,7 +2288,7 @@ plcom_common_getc(dev_t dev, struct plco
 
 	c = PREAD1(pi, PL01XCOM_DR);
 	{
-		int cn_trapped = 0; /* unused */
+		int cn_trapped __unused = 0;
 #ifdef DDB
 		extern int db_active;
 		if (!db_active)
@@ -2308,7 +2308,7 @@ plcom_common_putc(dev_t dev, struct plco
 	int cin, stat;
 	if (plcom_readaheadcount < MAX_READAHEAD
 	 && !ISSET(stat = PREAD1(pi, PL01XCOM_FR), PL01X_FR_RXFE)) {
-		int cn_trapped = 0;
+		int cn_trapped __unused = 0;
 		cin = PREAD1(pi, PL01XCOM_DR);
 		cn_check_magic(dev, cin, plcom_cnm_state);
 		plcom_readahead[plcom_readaheadcount++] = cin;



CVS commit: src/sys/arch/evbarm/dev

2013-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep  5 07:09:14 UTC 2013

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.45 src/sys/arch/evbarm/dev/plcom.c:1.46
--- src/sys/arch/evbarm/dev/plcom.c:1.45	Wed May  1 07:38:01 2013
+++ src/sys/arch/evbarm/dev/plcom.c	Thu Sep  5 07:09:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.45 2013/05/01 07:38:01 mlelstv Exp $	*/
+/*	$NetBSD: plcom.c,v 1.46 2013/09/05 07:09:14 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -27,7 +27,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * Copyright (c) 1998, 1999, 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.45 2013/05/01 07:38:01 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.46 2013/09/05 07:09:14 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -218,9 +218,9 @@ static struct cnm_state plcom_cnm_state;
 
 static int ppscap =
 	PPS_TSFMT_TSPEC |
-	PPS_CAPTUREASSERT | 
+	PPS_CAPTUREASSERT |
 	PPS_CAPTURECLEAR |
-#ifdef  PPS_SYNC 
+#ifdef  PPS_SYNC
 	PPS_HARDPPSONASSERT | PPS_HARDPPSONCLEAR |
 #endif	/* PPS_SYNC */
 	PPS_OFFSETASSERT | PPS_OFFSETCLEAR;
@@ -328,10 +328,10 @@ pl011comspeed(long speed, long frequency
 	int denom = 16 * speed;
 	int div = frequency / denom;
 	int rem = frequency % denom;
-	
+
 	int ibrd = div << 6;
 	int fbrd = (((8 * rem) / speed) + 1) / 2;
-	
+
 	/* Tolerance? */
 	return ibrd | fbrd;
 }
@@ -463,7 +463,7 @@ plcom_attach_subr(struct plcom_softc *sc
 		 * hang when trying to print.
 		 */
 		sc->sc_cr = PL01X_CR_UARTEN;
-		if (pi->pi_type == PLCOM_TYPE_PL011) 
+		if (pi->pi_type == PLCOM_TYPE_PL011)
 			SET(sc->sc_cr, PL011_CR_RXE | PL011_CR_TXE);
 	}
 
@@ -471,12 +471,12 @@ plcom_attach_subr(struct plcom_softc *sc
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, sc->sc_cr);
 		break;
-		
+
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, sc->sc_cr);
 		PWRITE4(pi, PL011COM_IMSC, sc->sc_imsc);
 		break;
-	}		
+	}
 
 	if (sc->sc_fifolen == 0) {
 		switch (pi->pi_type) {
@@ -514,7 +514,7 @@ plcom_attach_subr(struct plcom_softc *sc
 	sc->sc_rbavail = plcom_rbuf_size;
 	if (sc->sc_rbuf == NULL) {
 		aprint_error_dev(sc->sc_dev,
-		"unable to allocate ring buffer\n");		
+		"unable to allocate ring buffer\n");
 		return;
 	}
 	sc->sc_ebuf = sc->sc_rbuf + (plcom_rbuf_size << 1);
@@ -579,12 +579,12 @@ plcom_config(struct plcom_softc *sc)
 	case PLCOM_TYPE_PL010:
 		PWRITE1(pi, PL010COM_CR, sc->sc_cr);
 		break;
-		
+
 	case PLCOM_TYPE_PL011:
 		PWRITE4(pi, PL011COM_CR, sc->sc_cr);
 		PWRITE4(pi, PL011COM_IMSC, sc->sc_imsc);
 		break;
-	}		
+	}
 
 	if (ISSET(sc->sc_hwflags, PLCOM_HW_CONSOLE|PLCOM_HW_KGDB))
 		plcom_enable_debugport(sc);
@@ -618,7 +618,7 @@ plcom_detach(device_t self, int flags)
 		/*
 		 * Ring buffer allocation failed in the plcom_attach_subr,
 		 * only the tty is allocated, and nothing else.
-		 */ 
+		 */
 		tty_free(sc->sc_tty);
 		return 0;
 	}
@@ -697,7 +697,7 @@ plcom_shutdown(struct plcom_softc *sc)
 	/* Turn off interrupts. */
 	if (ISSET(sc->sc_hwflags, PLCOM_HW_CONSOLE)) {
 		/* interrupt on break */
-	
+
 		sc->sc_cr = PL01X_CR_UARTEN;
 		sc->sc_imsc = 0;
 		switch (pi->pi_type) {
@@ -872,7 +872,7 @@ plcomopen(dev_t dev, int flag, int mode,
 
 		mutex_spin_exit(&sc->sc_lock);
 	}
-	
+
 	splx(s);
 
 	error = ttyopen(tp, PLCOMDIALOUT(dev), ISSET(flag, O_NONBLOCK));
@@ -896,7 +896,7 @@ bad:
 
 	return error;
 }
- 
+
 int
 plcomclose(dev_t dev, int flag, int mode, struct lwp *l)
 {
@@ -925,7 +925,7 @@ plcomclose(dev_t dev, int flag, int mode
 
 	return 0;
 }
- 
+
 int
 plcomread(dev_t dev, struct uio *uio, int flag)
 {
@@ -935,10 +935,10 @@ plcomread(dev_t dev, struct uio *uio, in
 
 	if (PLCOM_ISALIVE(sc) == 0)
 		return EIO;
- 
+
 	return (*tp->t_linesw->l_read)(tp, uio, flag);
 }
- 
+
 int
 plcomwrite(dev_t dev, struct uio *uio, int flag)
 {
@@ -948,7 +948,7 @@ plcomwrite(dev_t dev, struct uio *uio, i
 
 	if (PLCOM_ISALIVE(sc) == 0)
 		return EIO;
- 
+
 	return (*tp->t_linesw->l_write)(tp, uio, flag);
 }
 
@@ -961,7 +961,7 @@ plcompoll(dev_t dev, int events, struct 
 
 	if (PLCOM_ISALIVE(sc) == 0)
 		return EIO;
- 
+
 	return (*tp->t_linesw->l_poll)(tp, events, l);
 }
 
@@ -1074,7 +1074,7 @@ plcomioctl(dev_t dev, u_long cmd, void *
 			break;
 		}
 		sc->ppsparam = *pp;
-	 	/* 
+	 	/*
 		 * Compute msr masks from user-specified timestamp state.
 		 */
 		mode = sc->ppsparam.mode;
@@ -1092,13 +1092,13 @@ plcomioctl(dev_t dev, u_long cmd, void 

CVS commit: src/sys/arch/evbarm/dev

2013-05-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed May  1 07:33:24 UTC 2013

Modified Files:
src/sys/arch/evbarm/dev: plcomvar.h

Log Message:
Fix prototype


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.13 src/sys/arch/evbarm/dev/plcomvar.h:1.14
--- src/sys/arch/evbarm/dev/plcomvar.h:1.13	Fri Aug 17 09:38:51 2012
+++ src/sys/arch/evbarm/dev/plcomvar.h	Wed May  1 07:33:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.13 2012/08/17 09:38:51 skrll Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.14 2013/05/01 07:33:24 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -50,7 +50,7 @@ int  plcomcnattach	(struct plcom_instanc
 void plcomcndetach	(void);
 
 #ifdef KGDB
-int  plcom_kgdb_attach	(struct plcom_instance *, int, int, tcflag_t);
+int  plcom_kgdb_attach	(struct plcom_instance *, int, int, tcflag_t, int);
 #endif
 
 int  plcom_is_console	(bus_space_tag_t, bus_addr_t, bus_space_handle_t *);



CVS commit: src/sys/arch/evbarm/dev

2013-03-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar  3 10:26:19 UTC 2013

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
fix build for KGDB


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.43 src/sys/arch/evbarm/dev/plcom.c:1.44
--- src/sys/arch/evbarm/dev/plcom.c:1.43	Wed Oct 10 21:54:13 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Sun Mar  3 10:26:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.43 2012/10/10 21:54:13 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.44 2013/03/03 10:26:18 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.43 2012/10/10 21:54:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.44 2013/03/03 10:26:18 mlelstv Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -537,7 +537,7 @@ plcom_attach_subr(struct plcom_softc *sc
 	 * Allow kgdb to "take over" this port.  If this is
 	 * the kgdb device, it has exclusive use.
 	 */
-	if (bus_space_is_equal(iot, plcomkgdb_info.pi_iot) &&
+	if (bus_space_is_equal(pi->pi_iot, plcomkgdb_info.pi_iot) &&
 	pi->pi_iobase == plcomkgdb_info.pi_iobase) {
 		if (!ISSET(sc->sc_hwflags, PLCOM_HW_CONSOLE)) {
 			plcom_kgdb_attached = 1;
@@ -2481,15 +2481,14 @@ plcom_kgdb_attach(struct plcom_instance 
 int
 plcom_kgdb_getc(void *arg)
 {
-
-	return plcom_common_getc(NODEV, plcom_kgdb_iot, plcom_kgdb_ioh);
+	return plcom_common_getc(NODEV, &plcomkgdb_info);
 }
 
 /* ARGSUSED */
 void
 plcom_kgdb_putc(void *arg, int c)
 {
-	plcom_common_putc(NODEV, plcom_kgdb_iot, plcom_kgdb_ioh, c);
+	plcom_common_putc(NODEV, &plcomkgdb_info, c);
 }
 #endif /* KGDB */
 
@@ -2509,7 +2508,7 @@ plcom_is_console(bus_space_tag_t iot, bu
 	else if (!plcom_kgdb_attached &&
 	bus_space_is_equal(iot, plcomkgdb_info.pi_iot) &&
 	iobase == plcomkgdb_info.pi_iobase) 
-		help = plcom_kgdb_ioh;
+		help = plcomkgdb_info.pi_ioh;
 #endif
 	else
 		return 0;



CVS commit: src/sys/arch/evbarm/dev

2012-10-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Oct 24 21:23:45 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcomreg.h

Log Message:
Add the ifls register.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/dev/plcomreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcomreg.h
diff -u src/sys/arch/evbarm/dev/plcomreg.h:1.4 src/sys/arch/evbarm/dev/plcomreg.h:1.5
--- src/sys/arch/evbarm/dev/plcomreg.h:1.4	Wed Jul 25 07:26:17 2012
+++ src/sys/arch/evbarm/dev/plcomreg.h	Wed Oct 24 21:23:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomreg.h,v 1.4 2012/07/25 07:26:17 skrll Exp $	*/
+/*	$NetBSD: plcomreg.h,v 1.5 2012/10/24 21:23:45 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -106,6 +106,15 @@
 #define	PL01X_MSR_CTS		PL01X_FR_CTS
 #define	PL011_MSR_RI		PL011_FR_RI
 
+/* ifls */
+#define	PL011_IFLS_1EIGHTH	0
+#define	PL011_IFLS_1QUARTER	1
+#define	PL011_IFLS_1HALF	2
+#define	PL011_IFLS_3QUARTERS	3
+#define	PL011_IFLS_7EIGHTHS	4
+#define	PL011_IFLS_RXIFLS(x)	(((x) & 0x7) << 3)
+#define	PL011_IFLS_TXIFLS(x)	(((x) & 0x7) << 0)
+
 /* All interrupt status/clear registers */
 #define	PL011_INT_OE	0x400
 #define	PL011_INT_BE	0x200



CVS commit: src/sys/arch/evbarm/dev

2012-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Oct 10 21:54:14 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Fix #if 0'ed code.

>From chuq


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.42 src/sys/arch/evbarm/dev/plcom.c:1.43
--- src/sys/arch/evbarm/dev/plcom.c:1.42	Fri Aug 17 09:38:51 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Wed Oct 10 21:54:13 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.42 2012/08/17 09:38:51 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.43 2012/10/10 21:54:13 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.42 2012/08/17 09:38:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.43 2012/10/10 21:54:13 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -2382,7 +2382,7 @@ plcominit(struct plcom_instance *pi, int
 	/* Ought to do something like this, but we have no sc to
 	   dereference. */
 	/* XXX device_unit() abuse */
-	sc->sc_set_mcr(sc->sc_set_mcr_arg, device_unit(&sc->sc_dev),
+	sc->sc_set_mcr(sc->sc_set_mcr_arg, device_unit(sc->sc_dev),
 	PL01X_MCR_DTR | PL01X_MCR_RTS);
 #endif
 



CVS commit: src/sys/arch/evbarm/dev

2012-08-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug 17 09:38:52 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c plcomvar.h

Log Message:
Backout previous - it breaks rpi console for me and jak.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.41 src/sys/arch/evbarm/dev/plcom.c:1.42
--- src/sys/arch/evbarm/dev/plcom.c:1.41	Sun Aug 12 10:13:17 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Fri Aug 17 09:38:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.41 2012/08/12 10:13:17 reinoud Exp $	*/
+/*	$NetBSD: plcom.c,v 1.42 2012/08/17 09:38:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.41 2012/08/12 10:13:17 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.42 2012/08/17 09:38:51 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -428,10 +428,8 @@ plcom_enable_debugport(struct plcom_soft
 void
 plcom_attach_subr(struct plcom_softc *sc)
 {
-	static const uint8_t txintr_fill[] = {14, 12, 8, 4, 2};
 	struct plcom_instance *pi = &sc->sc_pi;
 	struct tty *tp;
-	int tx_tresh;
 
 	aprint_naive("\n");
 
@@ -480,7 +478,6 @@ plcom_attach_subr(struct plcom_softc *sc
 		break;
 	}		
 
-	tx_tresh = PREAD4(pi, PL011COM_IFLS) & 7;
 	if (sc->sc_fifolen == 0) {
 		switch (pi->pi_type) {
 		case PLCOM_TYPE_PL010:
@@ -488,13 +485,11 @@ plcom_attach_subr(struct plcom_softc *sc
 			 * The PL010 has a 16-byte fifo, but the tx interrupt
 			 * triggers when there is space for 8 more bytes.
 			*/
-			sc->sc_fifolen = 8;	/* XXX can be bumped to 16 */
-			sc->sc_txintrfill = 8;
+			sc->sc_fifolen = 8;
 			break;
 		case PLCOM_TYPE_PL011:
 			/* Some revisions have a 32 byte TX FIFO */
 			sc->sc_fifolen = 16;
-			sc->sc_txintrfill = txintr_fill[tx_tresh];
 			break;
 		}
 	}
@@ -1684,16 +1679,11 @@ plcomstart(struct tty *tp)
 
 	/* Output the first chunk of the contiguous buffer. */
 	{
-		int n, maxn;
-
-		maxn = sc->sc_fifolen;
-		if (!ISSET(PREAD1(pi, PL01XCOM_FR), PL01X_FR_TXFE))
-			maxn = sc->sc_txintrfill;
+		int n;
 
 		n = sc->sc_tbc;
-		if (n > maxn)
-			n = maxn;
-
+		if (n > sc->sc_fifolen)
+			n = sc->sc_fifolen;
 		PWRITEM1(pi, PL01XCOM_DR, sc->sc_tba, n);
 		sc->sc_tbc -= n;
 		sc->sc_tba += n;
@@ -2211,8 +2201,8 @@ plcomintr(void *arg)
 int n;
 
 n = sc->sc_tbc;
-if (n > sc->sc_txintrfill)
-	n = sc->sc_txintrfill;
+if (n > sc->sc_fifolen)
+	n = sc->sc_fifolen;
 PWRITEM1(pi, PL01XCOM_DR, sc->sc_tba, n);
 sc->sc_tbc -= n;
 sc->sc_tba += n;

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.12 src/sys/arch/evbarm/dev/plcomvar.h:1.13
--- src/sys/arch/evbarm/dev/plcomvar.h:1.12	Sun Aug 12 10:13:17 2012
+++ src/sys/arch/evbarm/dev/plcomvar.h	Fri Aug 17 09:38:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.12 2012/08/12 10:13:17 reinoud Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.13 2012/08/17 09:38:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -113,7 +113,6 @@ struct plcom_softc {
 	int sc_hwflags,
 	sc_swflags;
 	u_int sc_fifolen;
-	u_int sc_txintrfill;
 
 	u_int sc_r_hiwat,
 	  sc_r_lowat;



CVS commit: src/sys/arch/evbarm/dev

2012-08-12 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sun Aug 12 10:13:17 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c plcomvar.h

Log Message:
Improve support for transmit fifo support for plcom.

As Nick, Michiel and I concluded this driver needs a big overhaul since its
logic is modelled on the standard com.c driver which doesn't have the plcom's
treshold interrupt at al.

On Nicks request, the HW FIFO support hasn't been enabled by default on the
RPi though.

Tested with the RPi.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.40 src/sys/arch/evbarm/dev/plcom.c:1.41
--- src/sys/arch/evbarm/dev/plcom.c:1.40	Wed Jul 25 07:26:17 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Sun Aug 12 10:13:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.40 2012/07/25 07:26:17 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.41 2012/08/12 10:13:17 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.40 2012/07/25 07:26:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.41 2012/08/12 10:13:17 reinoud Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -428,8 +428,10 @@ plcom_enable_debugport(struct plcom_soft
 void
 plcom_attach_subr(struct plcom_softc *sc)
 {
+	static const uint8_t txintr_fill[] = {14, 12, 8, 4, 2};
 	struct plcom_instance *pi = &sc->sc_pi;
 	struct tty *tp;
+	int tx_tresh;
 
 	aprint_naive("\n");
 
@@ -478,6 +480,7 @@ plcom_attach_subr(struct plcom_softc *sc
 		break;
 	}		
 
+	tx_tresh = PREAD4(pi, PL011COM_IFLS) & 7;
 	if (sc->sc_fifolen == 0) {
 		switch (pi->pi_type) {
 		case PLCOM_TYPE_PL010:
@@ -485,11 +488,13 @@ plcom_attach_subr(struct plcom_softc *sc
 			 * The PL010 has a 16-byte fifo, but the tx interrupt
 			 * triggers when there is space for 8 more bytes.
 			*/
-			sc->sc_fifolen = 8;
+			sc->sc_fifolen = 8;	/* XXX can be bumped to 16 */
+			sc->sc_txintrfill = 8;
 			break;
 		case PLCOM_TYPE_PL011:
 			/* Some revisions have a 32 byte TX FIFO */
 			sc->sc_fifolen = 16;
+			sc->sc_txintrfill = txintr_fill[tx_tresh];
 			break;
 		}
 	}
@@ -1679,11 +1684,16 @@ plcomstart(struct tty *tp)
 
 	/* Output the first chunk of the contiguous buffer. */
 	{
-		int n;
+		int n, maxn;
+
+		maxn = sc->sc_fifolen;
+		if (!ISSET(PREAD1(pi, PL01XCOM_FR), PL01X_FR_TXFE))
+			maxn = sc->sc_txintrfill;
 
 		n = sc->sc_tbc;
-		if (n > sc->sc_fifolen)
-			n = sc->sc_fifolen;
+		if (n > maxn)
+			n = maxn;
+
 		PWRITEM1(pi, PL01XCOM_DR, sc->sc_tba, n);
 		sc->sc_tbc -= n;
 		sc->sc_tba += n;
@@ -2201,8 +2211,8 @@ plcomintr(void *arg)
 int n;
 
 n = sc->sc_tbc;
-if (n > sc->sc_fifolen)
-	n = sc->sc_fifolen;
+if (n > sc->sc_txintrfill)
+	n = sc->sc_txintrfill;
 PWRITEM1(pi, PL01XCOM_DR, sc->sc_tba, n);
 sc->sc_tbc -= n;
 sc->sc_tba += n;

Index: src/sys/arch/evbarm/dev/plcomvar.h
diff -u src/sys/arch/evbarm/dev/plcomvar.h:1.11 src/sys/arch/evbarm/dev/plcomvar.h:1.12
--- src/sys/arch/evbarm/dev/plcomvar.h:1.11	Wed Jul 25 07:26:18 2012
+++ src/sys/arch/evbarm/dev/plcomvar.h	Sun Aug 12 10:13:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomvar.h,v 1.11 2012/07/25 07:26:18 skrll Exp $	*/
+/*	$NetBSD: plcomvar.h,v 1.12 2012/08/12 10:13:17 reinoud Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -113,6 +113,7 @@ struct plcom_softc {
 	int sc_hwflags,
 	sc_swflags;
 	u_int sc_fifolen;
+	u_int sc_txintrfill;
 
 	u_int sc_r_hiwat,
 	  sc_r_lowat;



CVS commit: src/sys/arch/evbarm/dev

2012-07-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  5 10:56:52 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Fix locking botch introduced in 1.36.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.38 src/sys/arch/evbarm/dev/plcom.c:1.39
--- src/sys/arch/evbarm/dev/plcom.c:1.38	Sun May 20 10:28:44 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Thu Jul  5 10:56:52 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.38 2012/05/20 10:28:44 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.39 2012/07/05 10:56:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.38 2012/05/20 10:28:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.39 2012/07/05 10:56:52 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -640,7 +640,7 @@ plcomopen(dev_t dev, int flag, int mode,
 		sc->ppsparam.mode = 0;
 		mutex_spin_exit(&timecounter_lock);
 
-		mutex_spin_enter(&sc->sc_lock);
+		mutex_spin_exit(&sc->sc_lock);
 
 		/*
 		 * Initialize the termios status to the defaults.  Add in the



CVS commit: src/sys/arch/evbarm/dev

2012-05-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 20 07:57:34 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
DOH.  Replace a line that got accidently deleted in the last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.36 src/sys/arch/evbarm/dev/plcom.c:1.37
--- src/sys/arch/evbarm/dev/plcom.c:1.36	Sun May 20 07:54:40 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Sun May 20 07:57:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.36 2012/05/20 07:54:40 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.37 2012/05/20 07:57:34 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.36 2012/05/20 07:54:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.37 2012/05/20 07:57:34 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -1569,6 +1569,7 @@ plcom_rxsoft(struct plcom_softc *sc, str
 			if (ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {
 CLR(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);
 SET(sc->sc_cr, PL010_CR_RIE | PL010_CR_RTIE);
+bus_space_write_1(sc->sc_iot, sc->sc_ioh, plcom_cr, sc->sc_cr);
 			}
 			if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) {
 CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED);



CVS commit: src/sys/arch/evbarm/dev

2012-05-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 20 07:54:40 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcom.c plcomvar.h

Log Message:
Replace the simple_lock with a kmutex_t.  Update the locking to match
com(4) in the few places it didn't already.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/evbarm/dev/plcom.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/dev/plcomvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.35 src/sys/arch/evbarm/dev/plcom.c:1.36
--- src/sys/arch/evbarm/dev/plcom.c:1.35	Mon May 14 19:40:06 2012
+++ src/sys/arch/evbarm/dev/plcom.c	Sun May 20 07:54:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.35 2012/05/14 19:40:06 skrll Exp $	*/
+/*	$NetBSD: plcom.c,v 1.36 2012/05/20 07:54:40 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.35 2012/05/14 19:40:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.36 2012/05/20 07:54:40 skrll Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -248,9 +248,6 @@ void	plcom_kgdb_putc (void *, int);
 #define	BW	BUS_SPACE_BARRIER_WRITE
 #define PLCOM_BARRIER(t, h, f) bus_space_barrier((t), (h), 0, PLCOM_UART_SIZE, (f))
 
-#define PLCOM_LOCK(sc) simple_lock(&(sc)->sc_lock)
-#define PLCOM_UNLOCK(sc) simple_unlock(&(sc)->sc_lock)
-
 int
 plcomspeed(long speed, long frequency)
 {
@@ -331,22 +328,21 @@ plcomprobe1(bus_space_tag_t iot, bus_spa
 	return 1;
 }
 
+/*
+ * No locking in this routine; it is only called during attach,
+ * or with the port already locked.
+ */
 static void
 plcom_enable_debugport(struct plcom_softc *sc)
 {
-	int s;
 
 	/* Turn on line break interrupt, set carrier. */
-	s = splserial();
-	PLCOM_LOCK(sc);
 	sc->sc_cr = PL010_CR_RIE | PL010_CR_RTIE | PL01X_CR_UARTEN;
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, plcom_cr, sc->sc_cr);
 	SET(sc->sc_mcr, PL01X_MCR_DTR | PL01X_MCR_RTS);
 	/* XXX device_unit() abuse */
 	sc->sc_set_mcr(sc->sc_set_mcr_arg, device_unit(&sc->sc_dev),
 	sc->sc_mcr);
-	PLCOM_UNLOCK(sc);
-	splx(s);
 }
 
 void
@@ -358,7 +354,7 @@ plcom_attach_subr(struct plcom_softc *sc
 	struct tty *tp;
 
 	callout_init(&sc->sc_diag_callout, 0);
-	simple_lock_init(&sc->sc_lock);
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_HIGH);
 
 	/* Disable interrupts before configuring the device. */
 	sc->sc_cr = 0;
@@ -505,6 +501,9 @@ plcom_detach(struct device *self, int fl
 	rnd_detach_source(&sc->rnd_source);
 #endif
 
+	/* Destroy the lock. */
+	mutex_destroy(&sc->sc_lock);
+
 	return 0;
 }
 
@@ -526,10 +525,7 @@ void
 plcom_shutdown(struct plcom_softc *sc)
 {
 	struct tty *tp = sc->sc_tty;
-	int s;
-
-	s = splserial();
-	PLCOM_LOCK(sc);	
+	mutex_spin_enter(&sc->sc_lock);
 
 	/* If we were asserting flow control, then deassert it. */
 	SET(sc->sc_rx_flags, RX_IBUF_BLOCKED);
@@ -551,12 +547,10 @@ plcom_shutdown(struct plcom_softc *sc)
 	 */
 	if (ISSET(tp->t_cflag, HUPCL)) {
 		plcom_modem(sc, 0);
-		PLCOM_UNLOCK(sc);
-		splx(s);
-		/* XXX tsleep will only timeout */
-		(void) tsleep(sc, TTIPRI, ttclos, hz);
-		s = splserial();
-		PLCOM_LOCK(sc);	
+		mutex_spin_exit(&sc->sc_lock);
+		/* XXX will only timeout */
+		(void) kpause(ttclos, false, hz, NULL);
+		mutex_spin_enter(&sc->sc_lock);
 	}
 
 	/* Turn off interrupts. */
@@ -567,6 +561,7 @@ plcom_shutdown(struct plcom_softc *sc)
 		sc->sc_cr = 0;
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, plcom_cr, sc->sc_cr);
 
+	mutex_spin_exit(&sc->sc_lock);
 	if (sc->disable) {
 #ifdef DIAGNOSTIC
 		if (!sc->enabled)
@@ -575,8 +570,6 @@ plcom_shutdown(struct plcom_softc *sc)
 		(*sc->disable)(sc);
 		sc->enabled = 0;
 	}
-	PLCOM_UNLOCK(sc);
-	splx(s);
 }
 
 int
@@ -584,7 +577,7 @@ plcomopen(dev_t dev, int flag, int mode,
 {
 	struct plcom_softc *sc;
 	struct tty *tp;
-	int s, s2;
+	int s;
 	int error;
 
 	sc = device_lookup_private(&plcom_cd, PLCOMUNIT(dev));
@@ -618,20 +611,18 @@ plcomopen(dev_t dev, int flag, int mode,
 
 		tp->t_dev = dev;
 
-		s2 = splserial();
-		PLCOM_LOCK(sc);
-
 		if (sc->enable) {
 			if ((*sc->enable)(sc)) {
-PLCOM_UNLOCK(sc);
-splx(s2);
 splx(s);
 printf("%s: device enable failed\n",
    sc->sc_dev.dv_xname);
 return EIO;
 			}
+			mutex_spin_enter(&sc->sc_lock);
 			sc->enabled = 1;
 			plcom_config(sc);
+		} else {
+			mutex_spin_enter(&sc->sc_lock);
 		}
 
 		/* Turn on interrupts. */
@@ -649,8 +640,7 @@ plcomopen(dev_t dev, int flag, int mode,
 		sc->ppsparam.mode = 0;
 		mutex_spin_exit(&timecounter_lock);
 
-		PLCOM_UNLOCK(sc);
-		splx(s2);
+		mutex_spin_enter(&sc->sc_lock);
 
 		/*
 		 * Initialize the termios status to the defaults.  Add in the
@@ -679,8 +669,7 @@ plcomopen(dev_t dev, int flag, int mode,
 		ttychars(tp);
 		ttsetwater(tp);
 
-		s2 = splserial();
-		PLCOM_LOCK(sc);
+		mutex_spin_enter(&sc->sc_lo

CVS commit: src/sys/arch/evbarm/dev

2012-04-05 Thread Hiroyuki Bessho
Module Name:src
Committed By:   bsh
Date:   Fri Apr  6 01:35:58 UTC 2012

Modified Files:
src/sys/arch/evbarm/dev: plcomreg.h

Log Message:
don't mix #define and #define in a file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/dev/plcomreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcomreg.h
diff -u src/sys/arch/evbarm/dev/plcomreg.h:1.1 src/sys/arch/evbarm/dev/plcomreg.h:1.2
--- src/sys/arch/evbarm/dev/plcomreg.h:1.1	Sat Oct 27 16:22:06 2001
+++ src/sys/arch/evbarm/dev/plcomreg.h	Fri Apr  6 01:35:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcomreg.h,v 1.1 2001/10/27 16:22:06 rearnsha Exp $	*/
+/*	$NetBSD: plcomreg.h,v 1.2 2012/04/06 01:35:58 bsh Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -34,14 +34,14 @@
 #define	PLCOM_TOLERANCE	30	/* baud rate tolerance, in 0.1% units */
 
 /* control register */
-#define CR_LBE		0x80	/* Loopback enable */
-#define CR_RTIE		0x40	/* Receive timeout interrupt enable */
-#define CR_TIE		0x20	/* Transmit interrupt enable */
-#define CR_RIE		0x10	/* Receive interrrupt enable */
-#define CR_MSIE		0x08	/* Modem status interrupt enable */
-#define CR_SIRLP	0x04	/* IrDA SIR Low power mode */
-#define CR_SIREN	0x02	/* SIR Enable */
-#define CR_UARTEN	0x01	/* Uart enable */
+#define	CR_LBE		0x80	/* Loopback enable */
+#define	CR_RTIE		0x40	/* Receive timeout interrupt enable */
+#define	CR_TIE		0x20	/* Transmit interrupt enable */
+#define	CR_RIE		0x10	/* Receive interrrupt enable */
+#define	CR_MSIE		0x08	/* Modem status interrupt enable */
+#define	CR_SIRLP	0x04	/* IrDA SIR Low power mode */
+#define	CR_SIREN	0x02	/* SIR Enable */
+#define	CR_UARTEN	0x01	/* Uart enable */
 
 /* interrupt identification register */
 #define	IIR_IMASK	0x0f
@@ -51,15 +51,15 @@
 #define	IIR_MIS		0x01
 
 /* line control register */
-#define LCR_WLEN	0x60	/* Mask of size bits */
+#define	LCR_WLEN	0x60	/* Mask of size bits */
 #define	LCR_8BITS	0x60	/* 8 bits per serial word */
 #define	LCR_7BITS	0x40	/* 7 bits */
 #define	LCR_6BITS	0x20	/* 6 bits */
 #define	LCR_5BITS	0x00	/* 5 bits */
-#define LCR_FEN		0x10	/* FIFO enable */
+#define	LCR_FEN		0x10	/* FIFO enable */
 #define	LCR_STP2	0x08	/* 2 stop bits per serial word */
-#define LCR_EPS		0x04	/* Even parity select */
-#define LCR_PEN		0x02	/* Parity enable */
+#define	LCR_EPS		0x04	/* Even parity select */
+#define	LCR_PEN		0x02	/* Parity enable */
 #define	LCR_PEVEN	(LCR_PEN | LCR_EPS)
 #define	LCR_PODD	LCR_PEN
 #define	LCR_PNONE	0x00	/* No parity */
@@ -71,10 +71,10 @@
 
 /* receive status register */
 
-#define RSR_OE		0x08	/* Overrun Error */
-#define RSR_BE		0x04	/* Break */
-#define RSR_PE		0x02	/* Parity Error */
-#define RSR_FE		0x01	/* Framing Error */
+#define	RSR_OE		0x08	/* Overrun Error */
+#define	RSR_BE		0x04	/* Break */
+#define	RSR_PE		0x02	/* Parity Error */
+#define	RSR_FE		0x01	/* Framing Error */
 
 /* flag register */
 #define	FR_TXFE		0x80	/* Transmit fifo empty */
@@ -93,17 +93,17 @@
 #define	MSR_CTS		FR_CTS
 
 /* Register offsets */
-#define plcom_dr	0x00
-#define plcom_rsr	0x04
-#define plcom_ecr	0x04
-#define plcom_lcr	0x08
-#define plcom_dlbh	0x0c
-#define plcom_dlbl	0x10
-#define plcom_cr	0x14
-#define plcom_fr	0x18
-#define plcom_iir	0x1c
-#define plcom_icr	0x1c
-#define plcom_ilpr	0x20
+#define	plcom_dr	0x00
+#define	plcom_rsr	0x04
+#define	plcom_ecr	0x04
+#define	plcom_lcr	0x08
+#define	plcom_dlbh	0x0c
+#define	plcom_dlbl	0x10
+#define	plcom_cr	0x14
+#define	plcom_fr	0x18
+#define	plcom_iir	0x1c
+#define	plcom_icr	0x1c
+#define	plcom_ilpr	0x20
 
 /* IFPGA specific */
-#define PLCOM_UART_SIZE	0x24
+#define	PLCOM_UART_SIZE	0x24



CVS commit: src/sys/arch/evbarm/dev

2009-12-06 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Sun Dec  6 21:38:42 UTC 2009

Modified Files:
src/sys/arch/evbarm/dev: plcom.c

Log Message:
Simplify the device-activation hook.  Move some of the device
deactivation to the detachment routine, where it belongs.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/evbarm/dev/plcom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/dev/plcom.c
diff -u src/sys/arch/evbarm/dev/plcom.c:1.30 src/sys/arch/evbarm/dev/plcom.c:1.31
--- src/sys/arch/evbarm/dev/plcom.c:1.30	Sat Nov 21 20:32:28 2009
+++ src/sys/arch/evbarm/dev/plcom.c	Sun Dec  6 21:38:42 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: plcom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $	*/
+/*	$NetBSD: plcom.c,v 1.31 2009/12/06 21:38:42 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2001 ARM Ltd
@@ -94,7 +94,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.31 2009/12/06 21:38:42 dyoung Exp $");
 
 #include "opt_plcom.h"
 #include "opt_ddb.h"
@@ -471,6 +471,14 @@
 	struct plcom_softc *sc = (struct plcom_softc *)self;
 	int maj, mn;
 
+	if (sc->sc_hwflags & (PLCOM_HW_CONSOLE|PLCOM_HW_KGDB))
+		return EBUSY;
+
+	if (sc->disable != NULL && sc->enabled != 0) {
+		(*sc->disable)(sc);
+		sc->enabled = 0;
+	}
+
 	/* locate the major number */
 	maj = cdevsw_lookup_major(&plcom_cdevsw);
 
@@ -500,34 +508,17 @@
 }
 
 int
-plcom_activate(struct device *self, enum devact act)
+plcom_activate(device_t self, enum devact act)
 {
-	struct plcom_softc *sc = (struct plcom_softc *)self;
-	int s, rv = 0;
+	struct plcom_softc *sc = device_private(self);
 
-	s = splserial();
-	PLCOM_LOCK(sc);
 	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
 	case DVACT_DEACTIVATE:
-		if (sc->sc_hwflags & (PLCOM_HW_CONSOLE|PLCOM_HW_KGDB)) {
-			rv = EBUSY;
-			break;
-		}
-
-		if (sc->disable != NULL && sc->enabled != 0) {
-			(*sc->disable)(sc);
-			sc->enabled = 0;
-		}
-		break;
+		sc->enabled = 0;
+		return 0;
+	default:
+		return EOPNOTSUPP;
 	}
-
-	PLCOM_UNLOCK(sc);	
-	splx(s);
-	return rv;
 }
 
 void