CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-05 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Sun Nov  5 17:06:15 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c

Log Message:
Add NetBSD keyword.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -u xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.5 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.6
--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.5	Sun Nov  5 17:01:05 2023
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c	Sun Nov  5 17:06:14 2023
@@ -29,6 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+/* $NetBSD: pnozz_exa.c,v 1.6 2023/11/05 17:06:14 jdc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"



CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-05 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Sun Nov  5 17:06:15 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c

Log Message:
Add NetBSD keyword.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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



CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-05 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Sun Nov  5 17:01:05 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c

Log Message:
Revert r1.4.
The changes are minimal and they cause redraw problems (as reported by
Maxim Devaev on port-sparc).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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



CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2023-11-05 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Sun Nov  5 17:01:05 UTC 2023

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c

Log Message:
Revert r1.4.
The changes are minimal and they cause redraw problems (as reported by
Maxim Devaev on port-sparc).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -u xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.5
--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4	Wed Jun  9 07:25:57 2021
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c	Sun Nov  5 17:01:05 2023
@@ -1,6 +1,7 @@
 /*
  * SBus Weitek P9100 EXA support
- *
+ */
+/*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -78,9 +79,11 @@ static CARD32 PnozzDrawROP[] = {
 #define waitReady(pPnozz) while((pnozz_read_4(pPnozz, ENGINE_STATUS) & \
 (ENGINE_BUSY | BLITTER_BUSY)) !=0 )
 
-/* From pnozz_accel.c */
+void PnozzInitEngine(PnozzPtr);
 void pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour);
 
+extern CARD32 MaxClip, junk;
+
 static void
 PnozzWaitMarker(ScreenPtr pScreen, int Marker)
 {
@@ -107,10 +110,8 @@ PnozzPrepareCopy
 waitReady(pPnozz);
 pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[alu] & 0xff));
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
-pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap);
+pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap) / pPnozz->width;
 
-if (exaGetPixmapPitch(pSrcPixmap) != exaGetPixmapPitch(pDstPixmap))
-	return FALSE;
 return TRUE;
 }
 
@@ -129,25 +130,24 @@ PnozzCopy
 ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 CARD32 src, dst, srcw, dstw;
-int soff = pPnozz->srcoff / exaGetPixmapPitch(pDstPixmap);
-int doff = exaGetPixmapOffset(pDstPixmap) / exaGetPixmapPitch(pDstPixmap);
+int doff = exaGetPixmapOffset(pDstPixmap) / pPnozz->width;
 
 src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) |
-	((ySrc + soff) & 0x1fff);
+	((ySrc + pPnozz->srcoff) & 0x1fff);
 dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) |
 	((yDst + doff) & 0x1fff);
-srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) |
-	((ySrc + soff + h) & 0x1fff);
+srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) | 
+((ySrc + pPnozz->srcoff + h - 1) & 0x1fff);
 dstw = xDst + w) << pPnozz->depthshift) - 1) << 16) |
-	((yDst + doff + h) & 0x1fff);
+((yDst + doff + h - 1) & 0x1fff);
 
 waitReady(pPnozz);
+
 pnozz_write_4(pPnozz, ABS_XY0, src);
 pnozz_write_4(pPnozz, ABS_XY1, srcw);
 pnozz_write_4(pPnozz, ABS_XY2, dst);
 pnozz_write_4(pPnozz, ABS_XY3, dstw);
-pnozz_read_4(pPnozz, COMMAND_BLIT);
-
+junk = pnozz_read_4(pPnozz, COMMAND_BLIT);
 exaMarkSync(pDstPixmap->drawable.pScreen);
 }
 
@@ -172,8 +172,7 @@ PnozzPrepareSolid(
 
 waitReady(pPnozz);
 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);
-pnozz_write_colour(pPnozz, BACKGROUND_COLOR, fg);
-pnozz_write_4(pPnozz, RASTER_OP, ROP_PAT);
+pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[alu] & 0xff);
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
 pnozz_write_4(pPnozz, COORD_INDEX, 0);
 
@@ -190,18 +189,15 @@ PnozzSolid(
 {
 ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
-int doff = exaGetPixmapOffset(pPixmap);
+int w = x2 - x - 1;
+int h = y2 - y - 1;
 
 waitReady(pPnozz);
-pnozz_write_4(pPnozz, ABS_XY0, (((x + doff) & 0x1fff) << 16) |
-	(y & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY1, (((x + doff) & 0x1fff) << 16) |
-	(y2 & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY2, (((x2 + doff) & 0x1fff) << 16) |
-	(y2 & 0x1fff));
-pnozz_write_4(pPnozz, ABS_XY3, (((x2 + doff) & 0x1fff) << 16) |
-	(y & 0x1fff));
-pnozz_read_4(pPnozz, COMMAND_QUAD);
+pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) | 
+(y & 0x1fff));
+pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) | 
+(h & 0x1fff)));
+junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
 exaMarkSync(pPixmap->drawable.pScreen);
 }
 
@@ -212,6 +208,8 @@ PnozzEXAInit(ScreenPtr pScreen)
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 ExaDriverPtr pExa;
 
+PnozzInitEngine(pPnozz);
+
 pExa = exaDriverAlloc();
 if (!pExa)
 	return FALSE;
@@ -225,8 +223,7 @@ PnozzEXAInit(ScreenPtr pScreen)
 
 /* round to multiple of pixmap pitch */
 pExa->memorySize = (pPnozz->vidmem / pPnozz->width) * pPnozz->width;
-pExa->offScreenBase = pPnozz->width * pPnozz->height *
-	

CVS commit: src/sys/arch/sparc64

2023-09-01 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Sep  2 05:51:57 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: fdc.c
src/sys/arch/sparc64/include: intr.h psl.h
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
sparc64: fix interrupt level mapping for disk and and parallel devices
on SBUS-based machines
Change the mapping from PIL_SCSI to PIL_BIO, so that they interrupt above
the highest soft interrupt (softserial)
Remove unused PIL_SCSI, PIL_FDSOFT, PIL_AUSOFT and fix the printf in fdc.c
Add "socal" and "SUNW,bpp" to the interrupt map.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sparc64/dev/fdc.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc64/include/intr.h
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sparc64/include/psl.h
cvs rdiff -u -r1.238 -r1.239 src/sys/arch/sparc64/sparc64/autoconf.c

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



CVS commit: src/sys/arch/sparc64

2023-09-01 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Sep  2 05:51:57 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: fdc.c
src/sys/arch/sparc64/include: intr.h psl.h
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
sparc64: fix interrupt level mapping for disk and and parallel devices
on SBUS-based machines
Change the mapping from PIL_SCSI to PIL_BIO, so that they interrupt above
the highest soft interrupt (softserial)
Remove unused PIL_SCSI, PIL_FDSOFT, PIL_AUSOFT and fix the printf in fdc.c
Add "socal" and "SUNW,bpp" to the interrupt map.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sparc64/dev/fdc.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc64/include/intr.h
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sparc64/include/psl.h
cvs rdiff -u -r1.238 -r1.239 src/sys/arch/sparc64/sparc64/autoconf.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/sparc64/dev/fdc.c
diff -u src/sys/arch/sparc64/dev/fdc.c:1.51 src/sys/arch/sparc64/dev/fdc.c:1.52
--- src/sys/arch/sparc64/dev/fdc.c:1.51	Sat Aug  7 16:19:05 2021
+++ src/sys/arch/sparc64/dev/fdc.c	Sat Sep  2 05:51:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdc.c,v 1.51 2021/08/07 16:19:05 thorpej Exp $	*/
+/*	$NetBSD: fdc.c,v 1.52 2023/09/02 05:51:57 jdc Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.51 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.52 2023/09/02 05:51:57 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -825,7 +825,7 @@ fdcattach(struct fdc_softc *fdc, int pri
 #ifdef SUN4
 	printf(" softpri %d: chip 8207%c\n", IPL_SOFTFDC, code);
 #elif SUN4U
-	printf(" softpri %d: chip 8207%c", PIL_FDSOFT, code);
+	printf(" softpri %d: chip 8207%c", IPL_BIO, code);
 	if (fdc->sc_flags & FDC_NOEJECT)
 		printf(": manual eject");
 	printf("\n");

Index: src/sys/arch/sparc64/include/intr.h
diff -u src/sys/arch/sparc64/include/intr.h:1.31 src/sys/arch/sparc64/include/intr.h:1.32
--- src/sys/arch/sparc64/include/intr.h:1.31	Fri Jul 27 05:36:12 2012
+++ src/sys/arch/sparc64/include/intr.h	Sat Sep  2 05:51:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.31 2012/07/27 05:36:12 matt Exp $ */
+/*	$NetBSD: intr.h,v 1.32 2023/09/02 05:51:57 jdc Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -54,7 +54,6 @@
 #define	IPL_HIGH	PIL_HIGH	/* everything */
 #define	IPL_HALT	5		/* cpu stop-self */
 #define	IPL_PAUSE	13		/* pause cpu */
-#define	IPL_FDSOFT	PIL_FDSOFT	/* floppy */
 
 /*
  * IPL_SAFEPRI is a safe priority for sleep to set for a spin-wait

Index: src/sys/arch/sparc64/include/psl.h
diff -u src/sys/arch/sparc64/include/psl.h:1.63 src/sys/arch/sparc64/include/psl.h:1.64
--- src/sys/arch/sparc64/include/psl.h:1.63	Tue Jul 11 11:02:07 2023
+++ src/sys/arch/sparc64/include/psl.h	Sat Sep  2 05:51:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: psl.h,v 1.63 2023/07/11 11:02:07 martin Exp $ */
+/*	$NetBSD: psl.h,v 1.64 2023/09/02 05:51:57 jdc Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -73,9 +73,6 @@
 #define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET"
 
 /* Interesting spl()s */
-#define PIL_SCSI	3
-#define PIL_FDSOFT	4
-#define PIL_AUSOFT	4
 #define PIL_BIO		5
 #define PIL_VIDEO	5
 #define PIL_TTY		6
@@ -514,12 +511,6 @@ SPLHOLD(splsoftint, 1)
 
 SPLHOLD(splsoftserial, 4)
 
-/* audio software interrupts are at software level 4 */
-SPLHOLD(splausoft, PIL_AUSOFT)
-
-/* floppy software interrupts are at software level 4 too */
-SPLHOLD(splfdsoft, PIL_FDSOFT)
-
 /*
  * Memory allocation (must be as high as highest network, tty, or disk device)
  */

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.238 src/sys/arch/sparc64/sparc64/autoconf.c:1.239
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.238	Sat Jan 22 11:49:17 2022
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Sep  2 05:51:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.238 2022/01/22 11:49:17 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.239 2023/09/02 05:51:57 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.238 2022/01/22 11:49:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.239 2023/09/02 05:51:57 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -165,19 +165,22 @@ int kernel_dtlb_slots;
 int kernel_itlb_slots;
 
 /* Global interrupt mappings for all device types.  Match against the OBP
- * 'device_type' property. 
+ * 'device_type' property.  Note, that the resulting PIL must be higher than
+ * the highest soft interrupt level (IPL_SOFTSERIAL).
  */
 struct intrmap intrmap[] = {
 	{ "block",	PIL_FD },	/* Floppy disk */
 	{ "serial",	PIL_SER },	/* zs */
-	{ "scsi",	PIL_SCSI },
-	{ "scsi-2",	PIL_SCSI },
+	{ "scsi",	PIL_BIO },
+	{ "scsi-2",	PIL_BIO },
 	{ "network",	

CVS commit: src/sys/arch/sparc64/sparc64

2023-08-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Aug 29 20:17:02 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: static_edid.c

Log Message:
Update the horizontal sync offset based on the Naturetech video timing.
While here, correct the spelling of "Naturetech" in the data.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/static_edid.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/sparc64/sparc64/static_edid.c
diff -u src/sys/arch/sparc64/sparc64/static_edid.c:1.1 src/sys/arch/sparc64/sparc64/static_edid.c:1.2
--- src/sys/arch/sparc64/sparc64/static_edid.c:1.1	Sun Oct 11 19:39:22 2020
+++ src/sys/arch/sparc64/sparc64/static_edid.c	Tue Aug 29 20:17:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $ */
+/*	$NetBSD: static_edid.c,v 1.2 2023/08/29 20:17:02 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.2 2023/08/29 20:17:02 jdc Exp $");
 #include 
 
 /* EDID blocks for some known hardware that doesn't provide its own */
@@ -46,13 +46,13 @@ uint8_t edid_meso999[128] = {
 /* 20 */	0x16, 0x50, 0x54, 0xa5, 0x4a, 0x80, 0x81, 0x40,
 /* 28 */	0x81, 0x80, 0x81, 0x8f, 0x95, 0x00, 0x01, 0x01,
 /* 30 */	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xab, 0x22,
-/* 38 */	0xa0, 0xa0, 0x50, 0x84, 0x1a, 0x30, 0x38, 0x20,
+/* 38 */	0xa0, 0xa0, 0x50, 0x84, 0x1a, 0x30, 0x30, 0x20,
 /* 40 */	0x36, 0x00, 0x9a, 0x01, 0x11, 0x00, 0x00, 0x1a,
 /* 48 */	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 /* 50 */	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 /* 58 */	0x00, 0x01, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x4e,
-/* 60 */	0x41, 0x74, 0x75, 0x72, 0x65, 0x74, 0x65, 0x63,
+/* 60 */	0x61, 0x74, 0x75, 0x72, 0x65, 0x74, 0x65, 0x63,
 /* 68 */	0x68, 0x0a, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfe,
 /* 70 */	0x00, 0x4d, 0x65, 0x73, 0x6f, 0x20, 0x39, 0x39,
-/* 78 */	0x39, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x00, 0xed
+/* 78 */	0x39, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x00, 0xd5
 };



CVS commit: src/sys/arch/sparc64/sparc64

2023-08-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Aug 29 20:17:02 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: static_edid.c

Log Message:
Update the horizontal sync offset based on the Naturetech video timing.
While here, correct the spelling of "Naturetech" in the data.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/static_edid.c

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



CVS commit: [netbsd-10] src/doc

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:09:08 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #127


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.53 -r1.1.2.54 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src/doc

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:09:08 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #127


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.53 -r1.1.2.54 src/doc/CHANGES-10.0

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.53 src/doc/CHANGES-10.0:1.1.2.54
--- src/doc/CHANGES-10.0:1.1.2.53	Mon Apr  3 18:36:09 2023
+++ src/doc/CHANGES-10.0	Sat Apr 15 12:09:07 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.53 2023/04/03 18:36:09 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.54 2023/04/15 12:09:07 jdc Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1523,6 +1523,12 @@ sys/dev/fss.c	1.114
 	this flag and may trigger an assertion.
 	[hannken, ticket #126]
 
+src/tests/sbin/envstat/t_envstat.sh		1.2
+	PR 57284: rewrite test to extract all temperaturs from all local sensors
+	and test them (instead of only one temperature from a tiny list of hard
+	coded possible devices).
+	[martin, ticket #127]
+
 sys/dev/pci/if_vioif.c1.83-1.102,1.105-1.107
 sys/arch/mips/include/bus_space_defs.h		1.5
 sys/arch/mips/include/types.h			1.78



CVS commit: [netbsd-10] src/tests/sbin/envstat

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:08:42 UTC 2023

Modified Files:
src/tests/sbin/envstat [netbsd-10]: t_envstat.sh

Log Message:
Pull up the following revision (requested by martin in ticket #127):

tests/sbin/envstat/t_envstat.sh: revision 1.2

PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.6.1 src/tests/sbin/envstat/t_envstat.sh

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



CVS commit: [netbsd-10] src/tests/sbin/envstat

2023-04-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Apr 15 12:08:42 UTC 2023

Modified Files:
src/tests/sbin/envstat [netbsd-10]: t_envstat.sh

Log Message:
Pull up the following revision (requested by martin in ticket #127):

tests/sbin/envstat/t_envstat.sh: revision 1.2

PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.1.6.1 src/tests/sbin/envstat/t_envstat.sh

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

Modified files:

Index: src/tests/sbin/envstat/t_envstat.sh
diff -u src/tests/sbin/envstat/t_envstat.sh:1.1 src/tests/sbin/envstat/t_envstat.sh:1.1.6.1
--- src/tests/sbin/envstat/t_envstat.sh:1.1	Thu Jun 25 15:01:35 2020
+++ src/tests/sbin/envstat/t_envstat.sh	Sat Apr 15 12:08:42 2023
@@ -1,4 +1,4 @@
-# $NetBSD: t_envstat.sh,v 1.1 2020/06/25 15:01:35 jruoho Exp $
+# $NetBSD: t_envstat.sh,v 1.1.6.1 2023/04/15 12:08:42 jdc Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,9 +36,8 @@ zerotemp_head() {
 
 zerotemp_body() {
 
-	devices="amdtemp0 coretemp0 acpitz0" # XXX: What else?
-
-	for dev in $devices; do
+	for dev in $( envstat -D | awk '{print $1}' )
+	do
 
 		envstat -d $dev >/dev/null 2>&1
 
@@ -47,18 +46,23 @@ zerotemp_body() {
 			continue
 		fi
 
-		if [ $dev = "amdtemp0" ]; then
-			atf_expect_fail "PR kern/53410"
-		fi
-
-		tempf=$(envstat -d $dev | awk '/Current/{getline;print $3}')
-		tempi=$(printf "%.0f" $tempf)
-
-		echo "$dev = $tempf =~ $tempi"
-
-		if [ $tempi -eq 0 ]; then
-			atf_fail "Zero-temperature from $dev"
-		fi
+		# extract all temperatures from $dev
+		for tempf in $(envstat -d $dev | \
+			awk -F: '/degC$/{print $2}' | \
+			awk '{print $1}' )
+		do
+			tempi=$(printf "%.0f" $tempf)
+
+			echo "$dev = $tempf =~ $tempi"
+
+			if [ $tempi -eq 0 ]; then
+
+if [ $dev = "amdtemp0" ]; then
+	atf_expect_fail "PR kern/53410"
+fi
+atf_fail "Zero-temperature from $dev"
+			fi
+		done
 	done
 }
 



CVS commit: [netbsd-10] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:40:40 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #117


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.42 -r1.1.2.43 src/doc/CHANGES-10.0

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.42 src/doc/CHANGES-10.0:1.1.2.43
--- src/doc/CHANGES-10.0:1.1.2.42	Sun Mar 12 17:53:01 2023
+++ src/doc/CHANGES-10.0	Mon Mar 13 21:40:40 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.42 2023/03/12 17:53:01 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.43 2023/03/13 21:40:40 jdc Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1457,3 +1457,9 @@ sys/dev/acpi/igpio_acpi.c			1.2
 	igpio(4): PR 57225: disable Baytrail and Lynxpoint support.
 	[msaitoh, ticket #116]
 
+build.sh	1.366
+	Avoid the dependency on a populated tooldir (or building the tools)
+	when simply doing mkrepro-timestamp and the current repository setups
+	does not actually require it.
+	[martin, ticket #1807]
+



CVS commit: [netbsd-10] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:40:40 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #117


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.42 -r1.1.2.43 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:40:24 UTC 2023

Modified Files:
src [netbsd-10]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #117):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.365.2.1 src/build.sh

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

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.365 src/build.sh:1.365.2.1
--- src/build.sh:1.365	Sun Aug 21 07:57:50 2022
+++ src/build.sh	Mon Mar 13 21:40:24 2023
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.365 2022/08/21 07:57:50 lukem Exp $
+#	$NetBSD: build.sh,v 1.365.2.1 2023/03/13 21:40:24 jdc Exp $
 #
 # Copyright (c) 2001-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -2010,7 +2010,7 @@ createmakewrapper()
 	eval cat <

CVS commit: [netbsd-10] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:40:24 UTC 2023

Modified Files:
src [netbsd-10]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #117):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.365.2.1 src/build.sh

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



CVS commit: [netbsd-9] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:38:46 UTC 2023

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Ticket #1611


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.56 -r1.1.2.57 src/doc/CHANGES-9.4

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



CVS commit: [netbsd-9] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:38:46 UTC 2023

Modified Files:
src/doc [netbsd-9]: CHANGES-9.4

Log Message:
Ticket #1611


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.56 -r1.1.2.57 src/doc/CHANGES-9.4

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

Modified files:

Index: src/doc/CHANGES-9.4
diff -u src/doc/CHANGES-9.4:1.1.2.56 src/doc/CHANGES-9.4:1.1.2.57
--- src/doc/CHANGES-9.4:1.1.2.56	Tue Mar  7 20:02:04 2023
+++ src/doc/CHANGES-9.4	Mon Mar 13 21:38:46 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.4,v 1.1.2.56 2023/03/07 20:02:04 martin Exp $
+# $NetBSD: CHANGES-9.4,v 1.1.2.57 2023/03/13 21:38:46 jdc Exp $
 
 A complete list of changes from the NetBSD 9.3 release to the NetBSD 9.4
 release:
@@ -1271,3 +1271,10 @@ sys/kern/vfs_syscalls.c1.557
 	open(2): PR 57260: don't map ERESTART to EINTR.
 	[riastradh, ticket #1610]
 
+build.sh	1.366 via patch
+
+	Avoid the dependency on a populated tooldir (or building the tools)
+	when simply doing mkrepro-timestamp and the current repository setups
+	does not actually require it.
+	[martin, ticket #1611]
+



CVS commit: [netbsd-9] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:38:13 UTC 2023

Modified Files:
src [netbsd-9]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #1611):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.333.2.2 -r1.333.2.3 src/build.sh

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

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.333.2.2 src/build.sh:1.333.2.3
--- src/build.sh:1.333.2.2	Wed Feb  2 14:23:11 2022
+++ src/build.sh	Mon Mar 13 21:38:13 2023
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.333.2.2 2022/02/02 14:23:11 martin Exp $
+#	$NetBSD: build.sh,v 1.333.2.3 2023/03/13 21:38:13 jdc Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1953,7 +1953,7 @@ createmakewrapper()
 	eval cat <

CVS commit: [netbsd-9] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:38:13 UTC 2023

Modified Files:
src [netbsd-9]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #1611):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.333.2.2 -r1.333.2.3 src/build.sh

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



CVS commit: [netbsd-8] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:36:56 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1807


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.168 -r1.1.2.169 src/doc/CHANGES-8.3

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

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.168 src/doc/CHANGES-8.3:1.1.2.169
--- src/doc/CHANGES-8.3:1.1.2.168	Mon Mar 13 21:06:01 2023
+++ src/doc/CHANGES-8.3	Mon Mar 13 21:36:56 2023
@@ -1,4 +1,4 @@
- $NetBSD: CHANGES-8.3,v 1.1.2.168 2023/03/13 21:06:01 jdc Exp $
+ $NetBSD: CHANGES-8.3,v 1.1.2.169 2023/03/13 21:36:56 jdc Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -3219,3 +3219,10 @@ sys/kern/vfs_syscalls.c1.557
 	open(2): PR 57260: don't map ERESTART to EINTR.
 	[riastradh, ticket #1806]
 
+build.sh	1.366 via patch
+
+	Avoid the dependency on a populated tooldir (or building the tools)
+	when simply doing mkrepro-timestamp and the current repository setups
+	does not actually require it.
+	[martin, ticket #1807]
+



CVS commit: [netbsd-8] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:36:56 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1807


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.168 -r1.1.2.169 src/doc/CHANGES-8.3

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



CVS commit: [netbsd-8] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:36:29 UTC 2023

Modified Files:
src [netbsd-8]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #1807):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.316.4.3 -r1.316.4.4 src/build.sh

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



CVS commit: [netbsd-8] src

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:36:29 UTC 2023

Modified Files:
src [netbsd-8]: build.sh

Log Message:
Pull up the following revision (requested by martin in ticket #1807):

build.sh: revision 1.366 via patch

Avoid the dependency on a populated tooldir (or building the tools)
when simply doing mkrepro-timestamp and the current repository setups
does not actually require it.


To generate a diff of this commit:
cvs rdiff -u -r1.316.4.3 -r1.316.4.4 src/build.sh

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

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.316.4.3 src/build.sh:1.316.4.4
--- src/build.sh:1.316.4.3	Wed Sep 15 05:07:42 2021
+++ src/build.sh	Mon Mar 13 21:36:29 2023
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.316.4.3 2021/09/15 05:07:42 msaitoh Exp $
+#	$NetBSD: build.sh,v 1.316.4.4 2023/03/13 21:36:29 jdc Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1914,7 +1914,7 @@ createmakewrapper()
 	eval cat <

CVS commit: [netbsd-8] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:06:02 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1806


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.167 -r1.1.2.168 src/doc/CHANGES-8.3

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

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.167 src/doc/CHANGES-8.3:1.1.2.168
--- src/doc/CHANGES-8.3:1.1.2.167	Fri Feb 24 14:21:22 2023
+++ src/doc/CHANGES-8.3	Mon Mar 13 21:06:01 2023
@@ -1,4 +1,4 @@
- $NetBSD: CHANGES-8.3,v 1.1.2.167 2023/02/24 14:21:22 martin Exp $
+ $NetBSD: CHANGES-8.3,v 1.1.2.168 2023/03/13 21:06:01 jdc Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -3214,3 +3214,8 @@ sys/dev/ata/satavar.h1.10
 	sata: do not consider "PHY offline" conditions an error.
 	[msaitoh, ticket #1805]
 
+sys/kern/vfs_syscalls.c1.557
+
+	open(2): PR 57260: don't map ERESTART to EINTR.
+	[riastradh, ticket #1806]
+



CVS commit: [netbsd-8] src/doc

2023-03-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 13 21:06:02 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1806


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.167 -r1.1.2.168 src/doc/CHANGES-8.3

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



CVS commit: src/sys/arch/sparc/sparc

2022-09-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Sep 30 14:32:45 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Make this compile for SUN4-only kernels
(move namebuf inside the SUN4C/SUN4M/SUN4D ifdef to match where it's used).


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.270 src/sys/arch/sparc/sparc/autoconf.c:1.271
--- src/sys/arch/sparc/sparc/autoconf.c:1.270	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/sparc/sparc/autoconf.c	Fri Sep 30 14:32:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.271 2022/09/30 14:32:45 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.271 2022/09/30 14:32:45 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1119,8 +1119,8 @@ mainbus_attach(device_t parent, device_t
 	};
 
 	struct mainbus_attach_args ma;
-	char namebuf[32];
 #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
+	char namebuf[32];
 	const char *sp = NULL;
 	int node0, node;
 	const struct boot_special *openboot_special, *ssp;



CVS commit: src/sys/arch/sparc/sparc

2022-09-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Sep 30 14:32:45 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Make this compile for SUN4-only kernels
(move namebuf inside the SUN4C/SUN4M/SUN4D ifdef to match where it's used).


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/autoconf.c

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



CVS commit: src/sys/arch/arm/amlogic

2021-11-18 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Nov 19 07:04:27 UTC 2021

Modified Files:
src/sys/arch/arm/amlogic: meson_dwmac.c

Log Message:
PR port-evbarm/50416

Redo the previous change.  The  "snps,..." properties are on the ethernet
node and the "reset-..." properties are on the phy node.  Handle this by
creating a separate reset routine for each case.  Idea from Jared.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/meson_dwmac.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/arm/amlogic/meson_dwmac.c
diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.13 src/sys/arch/arm/amlogic/meson_dwmac.c:1.14
--- src/sys/arch/arm/amlogic/meson_dwmac.c:1.13	Wed Nov 17 11:57:27 2021
+++ src/sys/arch/arm/amlogic/meson_dwmac.c	Fri Nov 19 07:04:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $ */
+/* $NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $");
 
 #include 
 #include 
@@ -66,72 +66,69 @@ static const struct device_compatible_en
 };
 
 static int
-meson_dwmac_reset(const int phandle)
+meson_dwmac_reset_eth(const int phandle)
 {
 	struct fdtbus_gpio_pin *pin_reset;
 	const u_int *reset_delay_us;
-	const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios;
 	bool reset_active_low;
 	int len, val;
 
-	/*
-	 * Depending on the DTS, we need to check either the "snps,...",
-	 * or the "reset-..." properties for the MAC reset information.
-	 */
-
 	pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio",
 	GPIO_PIN_OUTPUT);
-	if (pin_reset != NULL) {
+	if (pin_reset == NULL)
+		return ENXIO;
 
-		reset_delay_us = fdtbus_get_prop(phandle,
-		"snps,reset-delays-us", );
-		if (reset_delay_us == NULL || len != 12)
-			return ENXIO;
+	reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", );
+	if (reset_delay_us == NULL || len != 12)
+		return ENXIO;
 
-		reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
+	reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
 
-		val = reset_active_low ? 1 : 0;
+	val = reset_active_low ? 1 : 0;
 
-		fdtbus_gpio_write(pin_reset, val);
-		delay(be32toh(reset_delay_us[0]));
-		fdtbus_gpio_write(pin_reset, !val);
-		delay(be32toh(reset_delay_us[1]));
-		fdtbus_gpio_write(pin_reset, val);
-		delay(be32toh(reset_delay_us[2]));
+	fdtbus_gpio_write(pin_reset, val);
+	delay(be32toh(reset_delay_us[0]));
+	fdtbus_gpio_write(pin_reset, !val);
+	delay(be32toh(reset_delay_us[1]));
+	fdtbus_gpio_write(pin_reset, val);
+	delay(be32toh(reset_delay_us[2]));
 
-		return 0;
-	}
+	return 0;
+}
+
+static int
+meson_dwmac_reset_phy(const int phandle)
+{
+	struct fdtbus_gpio_pin *pin_reset;
+	const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios;
+	bool reset_active_low;
+	int len, val;
 
 	pin_reset = fdtbus_gpio_acquire(phandle, "reset-gpios",
 	GPIO_PIN_OUTPUT);
-	if (pin_reset != NULL) {
-		reset_assert_us = fdtbus_get_prop(phandle,
-		"reset-assert-us", );
-		if (reset_assert_us == NULL || len != 4)
-			return ENXIO;
-		reset_deassert_us = fdtbus_get_prop(phandle,
-		"reset-deassert-us", );
-		if (reset_deassert_us == NULL || len != 4)
-			return ENXIO;
-		reset_gpios = fdtbus_get_prop(phandle,
-		"reset-gpios", );
-		if (reset_gpios == NULL || len != 12)
-			return ENXIO;
-
-		reset_active_low = be32toh(reset_gpios[2]);
-
-		val = reset_active_low ? 1 : 0;
-
-
-		fdtbus_gpio_write(pin_reset, val);
-		delay(be32toh(reset_assert_us[0]));
-		fdtbus_gpio_write(pin_reset, !val);
-		delay(be32toh(reset_deassert_us[0]));
+	if (pin_reset == NULL)
+		return ENXIO;
 
-		return 0;
-	}
+	reset_assert_us = fdtbus_get_prop(phandle, "reset-assert-us", );
+	if (reset_assert_us == NULL || len != 4)
+		return ENXIO;
+	reset_deassert_us = fdtbus_get_prop(phandle, "reset-deassert-us", );
+	if (reset_deassert_us == NULL || len != 4)
+		return ENXIO;
+	reset_gpios = fdtbus_get_prop(phandle, "reset-gpios", );
+	if (reset_gpios == NULL || len != 12)
+		return ENXIO;
+
+	reset_active_low = be32toh(reset_gpios[2]);
+
+	val = reset_active_low ? 1 : 0;
+
+	fdtbus_gpio_write(pin_reset, val);
+	delay(be32toh(reset_assert_us[0]));
+	fdtbus_gpio_write(pin_reset, !val);
+	delay(be32toh(reset_deassert_us[0]));
 
-	return ENXIO;
+	return 0;
 }
 
 static void
@@ -276,8 +273,19 @@ meson_dwmac_attach(device_t parent, devi
 	}
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
-	if (meson_dwmac_reset(phandle_phy) != 0)
-		aprint_error_dev(self, "PHY reset failed\n");
+	/*
+	 * Depending on the DTS, we need to check either the "snps,...",
+	 * properties on the ethernet node, or the "reset-..."
+	 * 

CVS commit: src/sys/arch/arm/amlogic

2021-11-18 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Nov 19 07:04:27 UTC 2021

Modified Files:
src/sys/arch/arm/amlogic: meson_dwmac.c

Log Message:
PR port-evbarm/50416

Redo the previous change.  The  "snps,..." properties are on the ethernet
node and the "reset-..." properties are on the phy node.  Handle this by
creating a separate reset routine for each case.  Idea from Jared.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/meson_dwmac.c

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



CVS commit: src/sys/arch/arm/amlogic

2021-11-17 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Nov 17 11:57:27 UTC 2021

Modified Files:
src/sys/arch/arm/amlogic: meson_dwmac.c

Log Message:
PR port-evbarm/50416

Also check the "reset_gpios", "reset-assert-us", and "reset-deassert-us"
properties for ethernet MAC reset information.  Makes the built-in ethernet
work on Odroid C1 and Odroid C2 (with mesongxbb_pinctrl.c >= r1.3).

Based on a hint from Jared.  C2 tested by Martin.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/meson_dwmac.c

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



CVS commit: src/sys/arch/arm/amlogic

2021-11-17 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Nov 17 11:57:27 UTC 2021

Modified Files:
src/sys/arch/arm/amlogic: meson_dwmac.c

Log Message:
PR port-evbarm/50416

Also check the "reset_gpios", "reset-assert-us", and "reset-deassert-us"
properties for ethernet MAC reset information.  Makes the built-in ethernet
work on Odroid C1 and Odroid C2 (with mesongxbb_pinctrl.c >= r1.3).

Based on a hint from Jared.  C2 tested by Martin.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/meson_dwmac.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/arm/amlogic/meson_dwmac.c
diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.12 src/sys/arch/arm/amlogic/meson_dwmac.c:1.13
--- src/sys/arch/arm/amlogic/meson_dwmac.c:1.12	Sun Nov  7 19:21:32 2021
+++ src/sys/arch/arm/amlogic/meson_dwmac.c	Wed Nov 17 11:57:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: meson_dwmac.c,v 1.12 2021/11/07 19:21:32 jmcneill Exp $ */
+/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.12 2021/11/07 19:21:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $");
 
 #include 
 #include 
@@ -70,29 +70,68 @@ meson_dwmac_reset(const int phandle)
 {
 	struct fdtbus_gpio_pin *pin_reset;
 	const u_int *reset_delay_us;
+	const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios;
 	bool reset_active_low;
 	int len, val;
 
-	pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio", GPIO_PIN_OUTPUT);
-	if (pin_reset == NULL)
+	/*
+	 * Depending on the DTS, we need to check either the "snps,...",
+	 * or the "reset-..." properties for the MAC reset information.
+	 */
+
+	pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio",
+	GPIO_PIN_OUTPUT);
+	if (pin_reset != NULL) {
+
+		reset_delay_us = fdtbus_get_prop(phandle,
+		"snps,reset-delays-us", );
+		if (reset_delay_us == NULL || len != 12)
+			return ENXIO;
+
+		reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
+
+		val = reset_active_low ? 1 : 0;
+
+		fdtbus_gpio_write(pin_reset, val);
+		delay(be32toh(reset_delay_us[0]));
+		fdtbus_gpio_write(pin_reset, !val);
+		delay(be32toh(reset_delay_us[1]));
+		fdtbus_gpio_write(pin_reset, val);
+		delay(be32toh(reset_delay_us[2]));
+
 		return 0;
+	}
+
+	pin_reset = fdtbus_gpio_acquire(phandle, "reset-gpios",
+	GPIO_PIN_OUTPUT);
+	if (pin_reset != NULL) {
+		reset_assert_us = fdtbus_get_prop(phandle,
+		"reset-assert-us", );
+		if (reset_assert_us == NULL || len != 4)
+			return ENXIO;
+		reset_deassert_us = fdtbus_get_prop(phandle,
+		"reset-deassert-us", );
+		if (reset_deassert_us == NULL || len != 4)
+			return ENXIO;
+		reset_gpios = fdtbus_get_prop(phandle,
+		"reset-gpios", );
+		if (reset_gpios == NULL || len != 12)
+			return ENXIO;
+
+		reset_active_low = be32toh(reset_gpios[2]);
+
+		val = reset_active_low ? 1 : 0;
+
+
+		fdtbus_gpio_write(pin_reset, val);
+		delay(be32toh(reset_assert_us[0]));
+		fdtbus_gpio_write(pin_reset, !val);
+		delay(be32toh(reset_deassert_us[0]));
 
-	reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", );
-	if (reset_delay_us == NULL || len != 12)
-		return ENXIO;
-
-	reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
-
-	val = reset_active_low ? 1 : 0;
-
-	fdtbus_gpio_write(pin_reset, val);
-	delay(be32toh(reset_delay_us[0]));
-	fdtbus_gpio_write(pin_reset, !val);
-	delay(be32toh(reset_delay_us[1]));
-	fdtbus_gpio_write(pin_reset, val);
-	delay(be32toh(reset_delay_us[2]));
+		return 0;
+	}
 
-	return 0;
+	return ENXIO;
 }
 
 static void



CVS commit: src/sys/dev/i2c

2021-06-14 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jun 14 13:52:11 UTC 2021

Modified Files:
src/sys/dev/i2c: adm1026.c

Log Message:
Call sysmon_envsys_destroy() if we receive any error from sysmon, rather
than just on some errors.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/adm1026.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/dev/i2c/adm1026.c
diff -u src/sys/dev/i2c/adm1026.c:1.12 src/sys/dev/i2c/adm1026.c:1.13
--- src/sys/dev/i2c/adm1026.c:1.12	Mon Jun 14 09:56:04 2021
+++ src/sys/dev/i2c/adm1026.c	Mon Jun 14 13:52:11 2021
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.12 2021/06/14 09:56:04 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.13 2021/06/14 13:52:11 jdc Exp $");
 
 #include 
 #include 
@@ -104,9 +104,9 @@ static int adm1026_detach(device_t, int)
 bool adm1026_pmf_suspend(device_t, const pmf_qual_t *);
 bool adm1026_pmf_resume(device_t, const pmf_qual_t *);
 
-static void adm1026_setup_fans(struct adm1026_softc *sc, int div2_val);
-static void adm1026_setup_temps(struct adm1026_softc *sc);
-static void adm1026_setup_volts(struct adm1026_softc *sc);
+static int adm1026_setup_fans(struct adm1026_softc *sc, int div2_val);
+static int adm1026_setup_temps(struct adm1026_softc *sc);
+static int adm1026_setup_volts(struct adm1026_softc *sc);
 
 void adm1026_refresh(struct sysmon_envsys *sme, envsys_data_t *edata);
 static void adm1026_read_fan(struct adm1026_softc *sc, envsys_data_t *edata);
@@ -221,10 +221,13 @@ adm1026_attach(device_t parent, device_t
 
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_nfans = 0;
-	adm1026_setup_fans(sc, div2_val);
 	sc->sc_ntemps = 0;
-	adm1026_setup_temps(sc);
-	adm1026_setup_volts(sc);
+	if (adm1026_setup_fans(sc, div2_val))
+		goto bad;
+	if (adm1026_setup_temps(sc))
+		goto bad;
+	if (adm1026_setup_volts(sc))
+		goto bad;
 	aprint_normal_dev(self, "%d fans, %d temperatures, %d voltages\n",
 	sc->sc_nfans, sc->sc_ntemps, sc->sc_ntemps == 3 ? 15 : 17);
 	
@@ -234,15 +237,18 @@ adm1026_attach(device_t parent, device_t
 	if (sysmon_envsys_register(sc->sc_sme)) {
 		aprint_error_dev(self,
 		"unable to register with sysmon\n");
-		sysmon_envsys_destroy(sc->sc_sme);
-		sc->sc_sme = NULL;
-		return;
+		goto bad;
 	}
 
 	if (!pmf_device_register(self, adm1026_pmf_suspend, adm1026_pmf_resume))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	return;
+
+bad:
+	sysmon_envsys_destroy(sc->sc_sme);
+	sc->sc_sme = NULL;
+	return;
 }
 
 /*
@@ -275,7 +281,7 @@ adm1026_detach(device_t self, int flags)
 	return 0;
 }
 
-static void
+static int
 adm1026_setup_fans(struct adm1026_softc *sc, int div2_val)
 {
 	int i, err = 0;
@@ -284,11 +290,11 @@ adm1026_setup_fans(struct adm1026_softc 
 	/* Read fan-related registers (configuration and divisors) */
 	if ((err = adm1026_read_reg(sc, ADM1026_CONF2, >sc_cfg[1])) != 0) {
 		aprint_error_dev(sc->sc_dev, "unable to read conf2\n");
-		return;
+		return 0;
 	}
 	if ((err = adm1026_read_reg(sc, ADM1026_FAN_DIV1, )) != 0) {
 		aprint_error_dev(sc->sc_dev, "unable to read fan_div1\n");
-		return;
+		return 0;
 	}
 	sc->sc_fandiv[0] = 1 << ADM1026_FAN0_DIV(div1);
 	sc->sc_fandiv[1] = 1 << ADM1026_FAN1_DIV(div1);
@@ -299,7 +305,7 @@ adm1026_setup_fans(struct adm1026_softc 
 		adm1026_read_reg(sc, ADM1026_FAN_DIV2, )) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to read fan_div2\n");
-			return;
+			return 0;
 		}
 	} else
 		div2 = div2_val;
@@ -317,20 +323,19 @@ adm1026_setup_fans(struct adm1026_softc 
 			snprintf(sc->sc_sensor[ADM1026_FAN_NUM(i)].desc,
 			sizeof(sc->sc_sensor[ADM1026_FAN_NUM(i)].desc),
 			"fan %d", ADM1026_FAN_NUM(i));
-			sc->sc_nfans++;
 			if (sysmon_envsys_sensor_attach(
 			sc->sc_sme, >sc_sensor[ADM1026_FAN_NUM(i)])) {
-sysmon_envsys_destroy(sc->sc_sme);
-sc->sc_sme = NULL;
 aprint_error_dev(sc->sc_dev,
 "unable to attach fan %d at sysmon\n", i);
-return;
+return 1;
 			}
+			sc->sc_nfans++;
 		}
 	}
+	return 0;
 }
 
-static void
+static int
 adm1026_setup_temps(struct adm1026_softc *sc)
 {
 	int i;
@@ -340,7 +345,7 @@ adm1026_setup_temps(struct adm1026_softc
 	if (adm1026_read_reg(sc, ADM1026_INT_TEMP_OFF, )
 	!= 0) {
 		aprint_error_dev(sc->sc_dev, "unable to read int temp. off.\n");
-		return;
+		return 0;
 	}
 	if (val & 0x80)
 		sc->sc_temp_off[0] = 0 - 100 * (val & 0x7f);
@@ -348,7 +353,7 @@ adm1026_setup_temps(struct adm1026_softc
 		sc->sc_temp_off[0] = 100 * (val & 0x7f);
 	if (adm1026_read_reg(sc, ADM1026_TDM1_OFF, ) != 0) {
 		aprint_error_dev(sc->sc_dev, "unable to read tdm1 off.\n");
-		return;
+		return 0;
 	}
 	if (val & 0x80)
 		sc->sc_temp_off[1] = 0 - 100 * (val & 0x7f);
@@ -356,7 +361,7 @@ adm1026_setup_temps(struct adm1026_softc
 		sc->sc_temp_off[1] = 100 * (val & 0x7f);
 	if 

CVS commit: src/sys/dev/i2c

2021-06-14 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jun 14 13:52:11 UTC 2021

Modified Files:
src/sys/dev/i2c: adm1026.c

Log Message:
Call sysmon_envsys_destroy() if we receive any error from sysmon, rather
than just on some errors.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/adm1026.c

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



CVS commit: src/share/man/man4/man4.sparc

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 05:10:45 UTC 2021

Modified Files:
src/share/man/man4/man4.sparc: tslot.4

Log Message:
Add a bugs section about inserting two cards with different requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/man4.sparc/tslot.4

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



CVS commit: src/share/man/man4/man4.sparc

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 05:10:45 UTC 2021

Modified Files:
src/share/man/man4/man4.sparc: tslot.4

Log Message:
Add a bugs section about inserting two cards with different requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/man4.sparc/tslot.4

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

Modified files:

Index: src/share/man/man4/man4.sparc/tslot.4
diff -u src/share/man/man4/man4.sparc/tslot.4:1.4 src/share/man/man4/man4.sparc/tslot.4:1.5
--- src/share/man/man4/man4.sparc/tslot.4:1.4	Fri Feb 17 22:24:47 2017
+++ src/share/man/man4/man4.sparc/tslot.4	Fri Jun 11 05:10:45 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tslot.4,v 1.4 2017/02/17 22:24:47 christos Exp $
+.\"	$NetBSD: tslot.4,v 1.5 2021/06/11 05:10:45 jdc Exp $
 .\"
 .\" Copyright (c) 2005 Michael Lorenz
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" ported from OpenBSD
-.Dd February 17, 2017
+.Dd June 11, 2021
 .Dt TSLOT 4 sparc
 .Os
 .Sh NAME
@@ -50,3 +50,6 @@ handling the attachment and initializati
 .Xr pcmcia 4 ,
 .Xr sbus 4 ,
 .Xr sparc/tctrl 4
+.Sh BUGS
+Inserting two cards with different requirements, like voltage,
+may cause one of them not to function correctly.



CVS commit: src/sys/dev/ic

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 05:00:42 UTC 2021

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Add a missing htole16() around the length passed to bpf_mtap2().
Allows `tcpdump` to work on BE machines without panicing the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/ic/an.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/dev/ic/an.c
diff -u src/sys/dev/ic/an.c:1.73 src/sys/dev/ic/an.c:1.74
--- src/sys/dev/ic/an.c:1.73	Wed Jan 29 14:09:58 2020
+++ src/sys/dev/ic/an.c	Fri Jun 11 05:00:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $	*/
+/*	$NetBSD: an.c,v 1.74 2021/06/11 05:00:41 jdc Exp $	*/
 /*
  * Copyright (c) 1997, 1998, 1999
  *	Bill Paul .  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.74 2021/06/11 05:00:41 jdc Exp $");
 
 
 #include 
@@ -1509,7 +1509,7 @@ an_rx_intr(struct an_softc *sc)
 		(le16toh(frmhdr.an_rx_status) & AN_STAT_UNDECRYPTABLE))
 		tap->ar_flags |= IEEE80211_RADIOTAP_F_BADFCS;
 
-		bpf_mtap2(sc->sc_drvbpf, tap, tap->ar_ihdr.it_len, m,
+		bpf_mtap2(sc->sc_drvbpf, tap, htole16(tap->ar_ihdr.it_len), m,
 		BPF_D_IN);
 	}
 	wh = mtod(m, struct ieee80211_frame_min *);



CVS commit: src/sys/dev/ic

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 05:00:42 UTC 2021

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Add a missing htole16() around the length passed to bpf_mtap2().
Allows `tcpdump` to work on BE machines without panicing the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/ic/an.c

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



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

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 04:58:30 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: ts102.c

Log Message:
During slot enable and disable, make sure that the card Access and VCC
controls are enabled and disabled at the same time.
Also remove the software reset during slot enable (we are already in
reset because of the earlier Access and VCC changes).
While here, convert DELAY() to delay() and tsleep(), like nell(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/ts102.c

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



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

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 04:58:30 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: ts102.c

Log Message:
During slot enable and disable, make sure that the card Access and VCC
controls are enabled and disabled at the same time.
Also remove the software reset during slot enable (we are already in
reset because of the earlier Access and VCC changes).
While here, convert DELAY() to delay() and tsleep(), like nell(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/ts102.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/sparc/dev/ts102.c
diff -u src/sys/arch/sparc/dev/ts102.c:1.19 src/sys/arch/sparc/dev/ts102.c:1.20
--- src/sys/arch/sparc/dev/ts102.c:1.19	Sat Apr 24 23:36:49 2021
+++ src/sys/arch/sparc/dev/ts102.c	Fri Jun 11 04:58:30 2021
@@ -1,5 +1,5 @@
 /*	$OpenBSD: ts102.c,v 1.14 2005/01/27 17:03:23 millert Exp $	*/
-/*	$NetBSD: ts102.c,v 1.19 2021/04/24 23:36:49 thorpej Exp $ */
+/*	$NetBSD: ts102.c,v 1.20 2021/06/11 04:58:30 jdc Exp $ */
 /*
  * Copyright (c) 2003, 2004, Miodrag Vallat.
  * Copyright (c) 2005, Michael Lorenz.
@@ -182,6 +182,7 @@ static void tslot_slot_intr(struct tslot
 static void tslot_slot_settype(pcmcia_chipset_handle_t, int);
 static void tslot_update_lcd(struct tslot_softc *, int, int);
 static void tslot_intr_dispatch(void *arg);
+void tslot_delay(struct tslot_softc *sc, unsigned int ms);
 
 CFATTACH_DECL_NEW(tslot, sizeof(struct tslot_softc),
 tslot_match, tslot_attach, NULL, NULL);
@@ -620,22 +621,35 @@ static void
 tslot_slot_disable(pcmcia_chipset_handle_t pch)
 {
 	struct tslot_data *td = (struct tslot_data *)pch;
+	int status;
+
 #ifdef TSLOT_DEBUG
 	printf("%s: disable slot %d\n",
 	device_xname(td->td_parent->sc_dev), td->td_slot);
 #endif
 
-	/*
-	 * Disable card access.
-	 */
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS,
-	TSLOT_READ(td, TS102_REG_CARD_A_STS) & ~TS102_CARD_STS_ACEN);
+	status = TSLOT_READ(td, TS102_REG_CARD_A_STS);
+
+	status &= ~TS102_CARD_STS_ACEN;
 
 	/*
 	 * Disable interrupts, except for insertion.
 	 */
 	TSLOT_WRITE(td, TS102_REG_CARD_A_INT,
 	TS102_CARD_INT_MASK_CARDDETECT_STATUS);
+
+	/*
+	 * Power down the socket and disable access
+	 */
+	status &= ~TS102_CARD_STS_ACEN;
+	status &= ~(TS102_CARD_STS_VPP1_MASK | TS102_CARD_STS_VPP2_MASK);
+	status |= TS102_CARD_STS_VCCEN;
+	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
+	
+	/*
+	 * wait 300ms until power fails (Tpf).
+	 */
+	tslot_delay(td->td_parent, 300);
 }
 
 static void
@@ -652,18 +666,23 @@ tslot_slot_enable(pcmcia_chipset_handle_
 	/* Power down the socket to reset it */
 	status = TSLOT_READ(td, TS102_REG_CARD_A_STS);
 	TSPRINTF("status: %x\n", status);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status | TS102_CARD_STS_VCCEN);
+
+	status &= ~TS102_CARD_STS_ACEN;
+	status &= ~(TS102_CARD_STS_VPP1_MASK | TS102_CARD_STS_VPP2_MASK);
+	status |= TS102_CARD_STS_VCCEN;
+	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
 
 	/*
 	 * wait 300ms until power fails (Tpf).  Then, wait 100ms since we
 	 * are changing Vcc (Toff).
 	 */
-	DELAY((300 + 100) * 1000);
+	tslot_delay(td->td_parent, 300 + 100);
 
 	/*
 	 * Power on the card if not already done, and enable card access
 	 */
 	status |= TS102_CARD_STS_ACEN;
+	status |= TS102_CARD_STS_VPP1_VCC;
 	status &= ~TS102_CARD_STS_VCCEN;
 	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
 
@@ -671,22 +690,18 @@ tslot_slot_enable(pcmcia_chipset_handle_
 	 * wait 100ms until power raise (Tpr) and 20ms to become
 	 * stable (Tsu(Vcc)).
 	 */
-	DELAY((100 + 20) * 1000);
-
-	status &= ~TS102_CARD_STS_VPP1_MASK;
-	status |= TS102_CARD_STS_VPP1_VCC;
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
+	tslot_delay(td->td_parent, 100 + 20);
 
 	/*
 	 * hold RESET at least 20us.
 	 */
 	intr = TSLOT_READ(td, TS102_REG_CARD_A_INT);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_INT, TS102_CARD_INT_SOFT_RESET);
-	DELAY(20);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_INT, intr);
+	delay(20);
+	TSLOT_WRITE(td, TS102_REG_CARD_A_INT,
+	intr & ~TS102_CARD_INT_SOFT_RESET);
 
 	/* wait 20ms as per pc card standard (r2.01) section 4.3.6 */
-	DELAY(20 * 1000);
+	tslot_delay(td->td_parent, 20);
 
 	/* We need level-triggered interrupts for PC Card hardware */
 	TSLOT_WRITE(td, TS102_REG_CARD_A_STS,
@@ -709,7 +724,7 @@ tslot_slot_enable(pcmcia_chipset_handle_
 		if (status & TS102_CARD_STS_RDY)
 			break;
 		else
-			DELAY(100);
+			delay(100);
 	}
 
 	if (i == 0) {
@@ -1020,3 +1035,24 @@ tslot_update_lcd(struct tslot_softc *sc,
 	}
 #endif
 }
+
+/*
+ * Delay and possibly yield CPU.
+ * XXX - assumes a context
+ */
+void
+tslot_delay(struct tslot_softc *sc, unsigned int ms)
+{
+	unsigned int ticks = mstohz(ms);
+
+	if (cold || ticks == 0) {
+		delay(ms);
+		return;
+	}
+
+#ifdef DIAGNOSTIC
+	if (ticks > 60*hz)
+		panic("tslot: preposterous delay: %u", ticks);
+#endif
+	tsleep(sc, 0, "tslotdel", ticks);

CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2021-06-09 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Wed Jun  9 07:25:57 UTC 2021

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c pnozz_regs.h

Log Message:
Add some acceleration using the P9100 quad and blit commands:
- for solid fill (quad)
- for pixmap copy (blit) when source and destination pitch are the same


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
cvs rdiff -u -r1.1 -r1.2 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_regs.h

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

Modified files:

Index: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -u xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.3 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.4
--- xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.3	Thu May 27 20:20:43 2021
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c	Wed Jun  9 07:25:57 2021
@@ -1,7 +1,6 @@
 /*
  * SBus Weitek P9100 EXA support
- */
-/*-
+ *
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -79,11 +78,9 @@ static CARD32 PnozzDrawROP[] = {
 #define waitReady(pPnozz) while((pnozz_read_4(pPnozz, ENGINE_STATUS) & \
 (ENGINE_BUSY | BLITTER_BUSY)) !=0 )
 
-void PnozzInitEngine(PnozzPtr);
+/* From pnozz_accel.c */
 void pnozz_write_colour(PnozzPtr pPnozz, int reg, CARD32 colour);
 
-extern CARD32 MaxClip, junk;
-
 static void
 PnozzWaitMarker(ScreenPtr pScreen, int Marker)
 {
@@ -110,8 +107,10 @@ PnozzPrepareCopy
 waitReady(pPnozz);
 pnozz_write_4(pPnozz, RASTER_OP, (PnozzCopyROP[alu] & 0xff));
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
-pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap) / pPnozz->width;
+pPnozz->srcoff = exaGetPixmapOffset(pSrcPixmap);
 
+if (exaGetPixmapPitch(pSrcPixmap) != exaGetPixmapPitch(pDstPixmap))
+	return FALSE;
 return TRUE;
 }
 
@@ -130,24 +129,25 @@ PnozzCopy
 ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 CARD32 src, dst, srcw, dstw;
-int doff = exaGetPixmapOffset(pDstPixmap) / pPnozz->width;
+int soff = pPnozz->srcoff / exaGetPixmapPitch(pDstPixmap);
+int doff = exaGetPixmapOffset(pDstPixmap) / exaGetPixmapPitch(pDstPixmap);
 
 src = (((xSrc << pPnozz->depthshift) & 0x1fff) << 16) |
-	((ySrc + pPnozz->srcoff) & 0x1fff);
+	((ySrc + soff) & 0x1fff);
 dst = (((xDst << pPnozz->depthshift) & 0x1fff) << 16) |
 	((yDst + doff) & 0x1fff);
-srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) | 
-((ySrc + pPnozz->srcoff + h - 1) & 0x1fff);
+srcw = xSrc + w) << pPnozz->depthshift) - 1) << 16) |
+	((ySrc + soff + h) & 0x1fff);
 dstw = xDst + w) << pPnozz->depthshift) - 1) << 16) |
-((yDst + doff + h - 1) & 0x1fff);
+	((yDst + doff + h) & 0x1fff);
 
 waitReady(pPnozz);
-
 pnozz_write_4(pPnozz, ABS_XY0, src);
 pnozz_write_4(pPnozz, ABS_XY1, srcw);
 pnozz_write_4(pPnozz, ABS_XY2, dst);
 pnozz_write_4(pPnozz, ABS_XY3, dstw);
-junk = pnozz_read_4(pPnozz, COMMAND_BLIT);
+pnozz_read_4(pPnozz, COMMAND_BLIT);
+
 exaMarkSync(pDstPixmap->drawable.pScreen);
 }
 
@@ -172,7 +172,8 @@ PnozzPrepareSolid(
 
 waitReady(pPnozz);
 pnozz_write_colour(pPnozz, FOREGROUND_COLOR, fg);
-pnozz_write_4(pPnozz, RASTER_OP, PnozzDrawROP[alu] & 0xff);
+pnozz_write_colour(pPnozz, BACKGROUND_COLOR, fg);
+pnozz_write_4(pPnozz, RASTER_OP, ROP_PAT);
 pnozz_write_4(pPnozz, PLANE_MASK, planemask);
 pnozz_write_4(pPnozz, COORD_INDEX, 0);
 
@@ -189,15 +190,18 @@ PnozzSolid(
 {
 ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
-int w = x2 - x - 1;
-int h = y2 - y - 1;
+int doff = exaGetPixmapOffset(pPixmap);
 
 waitReady(pPnozz);
-pnozz_write_4(pPnozz, RECT_RTW_XY, ((x & 0x1fff) << 16) | 
-(y & 0x1fff));
-pnozz_write_4(pPnozz, RECT_RTP_XY, (((w & 0x1fff) << 16) | 
-(h & 0x1fff)));
-junk = pnozz_read_4(pPnozz, COMMAND_QUAD);
+pnozz_write_4(pPnozz, ABS_XY0, (((x + doff) & 0x1fff) << 16) |
+	(y & 0x1fff));
+pnozz_write_4(pPnozz, ABS_XY1, (((x + doff) & 0x1fff) << 16) |
+	(y2 & 0x1fff));
+pnozz_write_4(pPnozz, ABS_XY2, (((x2 + doff) & 0x1fff) << 16) |
+	(y2 & 0x1fff));
+pnozz_write_4(pPnozz, ABS_XY3, (((x2 + doff) & 0x1fff) << 16) |
+	(y & 0x1fff));
+pnozz_read_4(pPnozz, COMMAND_QUAD);
 exaMarkSync(pPixmap->drawable.pScreen);
 }
 
@@ -208,8 +212,6 @@ PnozzEXAInit(ScreenPtr pScreen)
 PnozzPtr pPnozz = GET_PNOZZ_FROM_SCRN(pScrn);
 ExaDriverPtr pExa;
 
-PnozzInitEngine(pPnozz);
-
 pExa = exaDriverAlloc();
 if (!pExa)
 	return FALSE;
@@ -223,7 +225,8 @@ PnozzEXAInit(ScreenPtr pScreen)
 
 /* round to multiple of pixmap pitch */
 

CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2021-06-09 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Wed Jun  9 07:25:57 UTC 2021

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz_exa.c pnozz_regs.h

Log Message:
Add some acceleration using the P9100 quad and blit commands:
- for solid fill (quad)
- for pixmap copy (blit) when source and destination pitch are the same


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
cvs rdiff -u -r1.1 -r1.2 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_regs.h

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



CVS commit: src/distrib/sets/lists/xserver

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:55:34 UTC 2021

Modified Files:
src/distrib/sets/lists/xserver: md.sparc

Log Message:
Restore the pnozz Xorg driver, now that it has EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/distrib/sets/lists/xserver/md.sparc

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

Modified files:

Index: src/distrib/sets/lists/xserver/md.sparc
diff -u src/distrib/sets/lists/xserver/md.sparc:1.74 src/distrib/sets/lists/xserver/md.sparc:1.75
--- src/distrib/sets/lists/xserver/md.sparc:1.74	Tue Nov 10 21:47:41 2020
+++ src/distrib/sets/lists/xserver/md.sparc	Thu May 27 04:55:34 2021
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc,v 1.74 2020/11/10 21:47:41 kamil Exp $
+# $NetBSD: md.sparc,v 1.75 2021/05/27 04:55:34 jdc Exp $
 ./usr/X11R7/bin/X	xserver-xorg-server-bin	xorg
 ./usr/X11R7/bin/Xorg	xserver-xorg-server-bin	xorg
 ./usr/X11R7/bin/cvt	xserver-xorg-server-bin	xorg
@@ -39,10 +39,8 @@
 ./usr/X11R7/lib/modules/drivers/mga_drv.so.2		xserver-xf86-video-mga-drivers	xorg
 ./usr/X11R7/lib/modules/drivers/mouse_drv.so		xserver-xf86-input-mouse-drivers	xorg
 ./usr/X11R7/lib/modules/drivers/mouse_drv.so.1		xserver-xf86-input-mouse-drivers	xorg
-./usr/X11R7/lib/modules/drivers/pnozz_drv.so		-unknown-	xorg,xorg_server_ver=110
-./usr/X11R7/lib/modules/drivers/pnozz_drv.so		xserver-obsolete	xorg,xorg_server_ver=120,obsolete
-./usr/X11R7/lib/modules/drivers/pnozz_drv.so.0		-unknown-	xorg,xorg_server_ver=110
-./usr/X11R7/lib/modules/drivers/pnozz_drv.so.0		xserver-obsolete	xorg,xorg_server_ver=120,obsolete
+./usr/X11R7/lib/modules/drivers/pnozz_drv.so		xserver-xf86-video-pnozz-drivers	xorg
+./usr/X11R7/lib/modules/drivers/pnozz_drv.so.0		xserver-xf86-video-pnozz-drivers	xorg
 ./usr/X11R7/lib/modules/drivers/r128_drv.so		xserver-xf86-video-r128-drivers	xorg
 ./usr/X11R7/lib/modules/drivers/r128_drv.so.6		xserver-xf86-video-r128-drivers	xorg
 ./usr/X11R7/lib/modules/drivers/radeon_drv.so		xserver-xf86-video-radeon-kms-drivers	xorg
@@ -192,8 +190,7 @@
 ./usr/X11R7/man/cat4/kbd.0xserver-xf86-input-keyboard-catman	.cat,xorg
 ./usr/X11R7/man/cat4/mga.0xserver-xf86-video-mga-catman	.cat,xorg
 ./usr/X11R7/man/cat4/mousedrv.0xserver-xf86-input-mouse-catman	.cat,xorg
-./usr/X11R7/man/cat4/pnozz.0-unknown-	.cat,xorg,xorg_server_ver=110
-./usr/X11R7/man/cat4/pnozz.0xserver-obsolete	.cat,xorg,xorg_server_ver=120,obsolete
+./usr/X11R7/man/cat4/pnozz.0xserver-xf86-video-pnozz-drivers	.cat,xorg
 ./usr/X11R7/man/cat4/r128.0xserver-xf86-video-r128-catman	.cat,xorg
 ./usr/X11R7/man/cat4/radeon.0xserver-xf86-video-radeon-kms-catman	.cat,xorg
 ./usr/X11R7/man/cat4/suncg14.0xserver-xf86-video-suncg14-catman	.cat,xorg
@@ -218,8 +215,7 @@
 ./usr/X11R7/man/html4/kbd.htmlxserver-xf86-input-keyboard-htmlman	html,xorg
 ./usr/X11R7/man/html4/mga.htmlxserver-xf86-video-mga-htmlman	html,xorg
 ./usr/X11R7/man/html4/mousedrv.html			xserver-xf86-input-mouse-htmlman	html,xorg
-./usr/X11R7/man/html4/pnozz.html			-unknown-	html,xorg,xorg_server_ver=110
-./usr/X11R7/man/html4/pnozz.html			xserver-obsolete	html,xorg,xorg_server_ver=120,obsolete
+./usr/X11R7/man/html4/pnozz.html			xserver-xf86-video-pnozz-drivers	html
 ./usr/X11R7/man/html4/r128.htmlxserver-xf86-video-r128-htmlman	html,xorg
 ./usr/X11R7/man/html4/radeon.html			xserver-xf86-video-radeon-kms-htmlman	html,xorg
 ./usr/X11R7/man/html4/suncg14.html			xserver-xf86-video-suncg14-htmlman	html,xorg
@@ -244,8 +240,7 @@
 ./usr/X11R7/man/man4/kbd.4xserver-xf86-input-keyboard-man	.man,xorg
 ./usr/X11R7/man/man4/mga.4xserver-xf86-video-mga-man	.man,xorg
 ./usr/X11R7/man/man4/mousedrv.4xserver-xf86-input-mouse-man	.man,xorg
-./usr/X11R7/man/man4/pnozz.4-unknown-	.man,xorg,xorg_server_ver=110
-./usr/X11R7/man/man4/pnozz.4xserver-obsolete	.man,xorg,xorg_server_ver=120,obsolete
+./usr/X11R7/man/man4/pnozz.4xserver-xf86-video-pnozz-drivers	.man,xorg
 ./usr/X11R7/man/man4/r128.4xserver-xf86-video-r128-man	.man,xorg
 ./usr/X11R7/man/man4/radeon.4xserver-xf86-video-radeon-kms-man	.man,xorg
 ./usr/X11R7/man/man4/suncg14.4xserver-xf86-video-suncg14-man	.man,xorg



CVS commit: src/distrib/sets/lists/xserver

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:55:34 UTC 2021

Modified Files:
src/distrib/sets/lists/xserver: md.sparc

Log Message:
Restore the pnozz Xorg driver, now that it has EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/distrib/sets/lists/xserver/md.sparc

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



CVS commit: src/external/mit/xorg/server/drivers

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:54:21 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers: Makefile

Log Message:
Restore the build of the pnozz driver on sparc, now that it has EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/external/mit/xorg/server/drivers/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/drivers/Makefile
diff -u src/external/mit/xorg/server/drivers/Makefile:1.101 src/external/mit/xorg/server/drivers/Makefile:1.102
--- src/external/mit/xorg/server/drivers/Makefile:1.101	Sun Mar  7 10:42:27 2021
+++ src/external/mit/xorg/server/drivers/Makefile	Thu May 27 04:54:21 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.101 2021/03/07 10:42:27 rin Exp $
+#	$NetBSD: Makefile,v 1.102 2021/05/27 04:54:21 jdc Exp $
 
 .include 
 
@@ -335,6 +335,7 @@ SUBDIR+= \
 
 .if ${MACHINE} == "sparc"
 SUBDIR+= \
+	xf86-video-pnozz \
 	xf86-video-suncg14 \
 	xf86-video-suntcx
 



CVS commit: src/external/mit/xorg/server/drivers

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:54:21 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers: Makefile

Log Message:
Restore the build of the pnozz driver on sparc, now that it has EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/external/mit/xorg/server/drivers/Makefile

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



CVS commit: src/external/mit/xorg/server/drivers/xf86-video-pnozz

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:53:44 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers/xf86-video-pnozz: Makefile

Log Message:
Update the pnozz files list for EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile

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

Modified files:

Index: src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile
diff -u src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile:1.1 src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile:1.2
--- src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile:1.1	Wed Aug 26 22:30:46 2009
+++ src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile	Thu May 27 04:53:44 2021
@@ -1,12 +1,16 @@
-#	$NetBSD: Makefile,v 1.1 2009/08/26 22:30:46 macallan Exp $
+#	$NetBSD: Makefile,v 1.2 2021/05/27 04:53:44 jdc Exp $
 
 DRIVER=		xf86-video-pnozz
 DRIVER_NAME=	pnozz_drv
 
-SRCS=		pnozz_driver.c pnozz_cursor.c pnozz_accel.c
+SRCS=		pnozz_driver.c pnozz_cursor.c pnozz_accel.c pnozz_exa.c
 
 CPPFLAGS+=	${X11FLAGS.DRI}
 
 MAN=		pnozz.4
 
 .include "../Makefile.xf86-driver"
+
+# XXX
+COPTS.pnozz_accel.c+=	${${ACTIVE_CC} == "gcc":? -Wno-error=discarded-qualifiers :}
+COPTS.pnozz_accel.c+=	${${ACTIVE_CC} == "clang":? -Wno-error=incompatible-pointer-types-discards-qualifiers :}



CVS commit: src/external/mit/xorg/server/drivers/xf86-video-pnozz

2021-05-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu May 27 04:53:44 UTC 2021

Modified Files:
src/external/mit/xorg/server/drivers/xf86-video-pnozz: Makefile

Log Message:
Update the pnozz files list for EXA support.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/mit/xorg/server/drivers/xf86-video-pnozz/Makefile

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



CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2021-05-26 Thread Julian Coleman
;scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS pScreen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS pScrn
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
Index: xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
diff -u /dev/null xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c:1.1
--- /dev/null	Thu May 27 04:48:10 2021
+++ xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c	Thu May 27 04:48:10 2021
@@ -0,0 +1,250 @@
+/*
+ * SBus Weitek P9100 EXA support
+ *
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pnozz.h"
+#include "pnozz_regs.h"
+
+
+static CARD32 PnozzCopyROP[] = {
+	/*GXclear*/		0,
+	/*GXand*/		ROP_SRC & ROP_DST,
+	/*GXandReverse*/	ROP_SRC & (~ROP_DST),
+	/*GXcopy*/		ROP_SRC,
+	/*GXandInverted*/	(~ROP_SRC) & ROP_DST,
+	/*GXnoop*/		ROP_DST,
+	/*GXxor*/		ROP_SRC ^ ROP_DST,
+	/*GXor*/		ROP_SRC | ROP_DST,
+	/*GXnor*/		(~ROP_SRC) & (~ROP_DST),
+	/*GXequiv*/		(~ROP_SRC) ^ ROP_DST,
+	/*GXinvert*/		(~ROP_DST),
+	/*GXorReverse*/		ROP_SRC | (~ROP_DST),
+	/*GXcopyInverted*/	(~ROP_SRC),
+	/*GXorInverted*/	(~ROP_SRC) | ROP_DST,
+	/*GXnand*/		(~ROP_SRC) | (~ROP_DST),
+	/*GXset*/		ROP_SET
+};
+
+static CARD32 PnozzDrawROP[] = {
+	/*GXclear*/		0,
+	/*GXand*/		ROP_PAT & ROP_DST,
+	/*GXandReverse*/	ROP_PAT & (~ROP_DST),
+	/*GXcopy*/		ROP_PAT,
+	/*GXandInverted*/	(~ROP_PAT) & ROP_DST,
+	/*GXnoop*/		ROP_DST,
+	/*GXxor*/		ROP_PAT ^ ROP_DST,
+	/*GXor*/		ROP_PAT | ROP_DST,
+	/*GXnor*/		(~ROP_PAT) & (~ROP_DST),
+	/*GXequiv*/		(~ROP_PAT) ^ ROP_DST,
+	/*GXinvert*/		(~ROP_DST),
+	/*GXorReverse*/		ROP_PAT | (~ROP_DST),
+	/*GXcopyInverted*/	(~ROP_PAT),
+	/*GXorInverted*/	(~ROP_PAT

CVS commit: xsrc/external/mit/xf86-video-pnozz/dist/src

2021-05-26 Thread Julian Coleman
Module Name:xsrc
Committed By:   jdc
Date:   Thu May 27 04:48:10 UTC 2021

Modified Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: pnozz.h pnozz_accel.c
pnozz_cursor.c pnozz_driver.c
Added Files:
xsrc/external/mit/xf86-video-pnozz/dist/src: compat-api.h pnozz_exa.c

Log Message:
Add support for EXA, so that the pnozz driver works again with Xorg.
Note, that only minimal acceleration is currently supported.

Thanks to macallan for the pointers to get this working.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
xsrc/external/mit/xf86-video-pnozz/dist/src/compat-api.h \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_exa.c
cvs rdiff -u -r1.1 -r1.2 xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz.h
cvs rdiff -u -r1.2 -r1.3 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_accel.c \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_cursor.c
cvs rdiff -u -r1.6 -r1.7 \
xsrc/external/mit/xf86-video-pnozz/dist/src/pnozz_driver.c

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



CVS commit: src/sys/dev/ic

2021-01-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jan 30 07:53:01 UTC 2021

Modified Files:
src/sys/dev/ic: gem.c gemvar.h

Log Message:
Improve handling of receive overflows.  When we get an overflow, don't
reset the chip if we are still receiving packets.  Real overflows can
happen when network and CPU(s) are loaded, so the reset is not needed
in this case.
Add a counter to track receive overflows (when GEM_COUNTERS is defined).

This reverts some changes (always reset on overflow) from
PR port-sparc64/46260.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/gemvar.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/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.132 src/sys/dev/ic/gem.c:1.133
--- src/sys/dev/ic/gem.c:1.132	Tue Sep 15 08:33:40 2020
+++ src/sys/dev/ic/gem.c	Sat Jan 30 07:53:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $ */
+/*	$NetBSD: gem.c,v 1.133 2021/01/30 07:53:01 jdc Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.133 2021/01/30 07:53:01 jdc Exp $");
 
 #include "opt_inet.h"
 
@@ -169,6 +169,7 @@ gem_detach(struct gem_softc *sc, int fla
 		evcnt_detach(>sc_ev_rxfull);
 		evcnt_detach(>sc_ev_rxint);
 		evcnt_detach(>sc_ev_txint);
+		evcnt_detach(>sc_ev_rxoverflow);
 #endif
 		evcnt_detach(>sc_ev_intr);
 
@@ -596,6 +597,8 @@ gem_attach(struct gem_softc *sc, const u
 	>sc_ev_rxint, device_xname(sc->sc_dev), "rx ring full");
 	evcnt_attach_dynamic(>sc_ev_rxnobuf, EVCNT_TYPE_INTR,
 	>sc_ev_rxint, device_xname(sc->sc_dev), "rx malloc failure");
+	evcnt_attach_dynamic(>sc_ev_rxoverflow, EVCNT_TYPE_INTR,
+	>sc_ev_rxint, device_xname(sc->sc_dev), "rx overflow");
 	evcnt_attach_dynamic(>sc_ev_rxhist[0], EVCNT_TYPE_INTR,
 	>sc_ev_rxint, device_xname(sc->sc_dev), "rx 0desc");
 	evcnt_attach_dynamic(>sc_ev_rxhist[1], EVCNT_TYPE_INTR,
@@ -1803,8 +1806,8 @@ gem_rint(struct gem_softc *sc)
 
 		if (rxstat & GEM_RD_BAD_CRC) {
 			if_statinc(ifp, if_ierrors);
-			aprint_error_dev(sc->sc_dev,
-			"receive error: CRC error\n");
+			DPRINTF(sc, ("%s: receive error: CRC error\n",
+			device_xname(sc->sc_dev)));
 			GEM_INIT_RXDESC(sc, i);
 			continue;
 		}
@@ -2215,8 +2218,11 @@ gem_intr(void *v)
 		 */
 		if (rxstat & GEM_MAC_RX_OVERFLOW) {
 			if_statinc(ifp, if_ierrors);
+			GEM_COUNTER_INCR(sc, sc_ev_rxoverflow);
+#ifdef GEM_DEBUG
 			aprint_error_dev(sc->sc_dev,
 			"receive error: RX overflow sc->rxptr %d, complete %d\n", sc->sc_rxptr, bus_space_read_4(t, h, GEM_RX_COMPLETION));
+#endif
 			sc->sc_rx_fifo_wr_ptr =
 bus_space_read_4(t, h, GEM_RX_FIFO_WR_PTR);
 			sc->sc_rx_fifo_rd_ptr =
@@ -2282,25 +2288,33 @@ gem_rx_watchdog(void *arg)
 		"receiver stuck in overflow, resetting\n");
 		gem_init(ifp);
 	} else {
+		int needreset = 1;
 		if ((state & GEM_MAC_STATE_OVERFLOW) != GEM_MAC_STATE_OVERFLOW) {
-			aprint_error_dev(sc->sc_dev,
-"rx_watchdog: not in overflow state: 0x%x\n",
-state);
+			DPRINTF(sc,
+			("%s: rx_watchdog: not in overflow state: 0x%x\n",
+			device_xname(sc->sc_dev), state));
 		}
 		if (rx_fifo_wr_ptr != rx_fifo_rd_ptr) {
-			aprint_error_dev(sc->sc_dev,
-"rx_watchdog: wr & rd ptr different\n");
+			DPRINTF(sc,
+			("%s: rx_watchdog: wr & rd ptr different\n",
+			device_xname(sc->sc_dev), state));
+			needreset = 0;
 		}
 		if (sc->sc_rx_fifo_wr_ptr != rx_fifo_wr_ptr) {
-			aprint_error_dev(sc->sc_dev,
-"rx_watchdog: wr pointer != saved\n");
+			DPRINTF(sc, ("%s: rx_watchdog: wr pointer != saved\n",
+			device_xname(sc->sc_dev), state));
+			needreset = 0;
 		}
 		if (sc->sc_rx_fifo_rd_ptr != rx_fifo_rd_ptr) {
+			DPRINTF(sc, ("%s: rx_watchdog: rd pointer != saved\n",
+			device_xname(sc->sc_dev), state));
+			needreset = 0;
+		}
+		if (needreset) {
 			aprint_error_dev(sc->sc_dev,
-"rx_watchdog: rd pointer != saved\n");
+			"rx_watchdog: resetting anyway\n");
+			gem_init(ifp);
 		}
-		aprint_error_dev(sc->sc_dev, "resetting anyway\n");
-		gem_init(ifp);
 	}
 }
 

Index: src/sys/dev/ic/gemvar.h
diff -u src/sys/dev/ic/gemvar.h:1.27 src/sys/dev/ic/gemvar.h:1.28
--- src/sys/dev/ic/gemvar.h:1.27	Sun Mar  1 05:50:56 2020
+++ src/sys/dev/ic/gemvar.h	Sat Jan 30 07:53:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gemvar.h,v 1.27 2020/03/01 05:50:56 thorpej Exp $ */
+/*	$NetBSD: gemvar.h,v 1.28 2021/01/30 07:53:01 jdc Exp $ */
 
 /*
  *
@@ -219,6 +219,7 @@ struct gem_softc {
 #ifdef GEM_COUNTERS
 	struct evcnt sc_ev_txint;
 	struct evcnt sc_ev_rxint;
+	struct evcnt sc_ev_rxoverflow;
 	struct evcnt sc_ev_rxnobuf;
 	struct evcnt sc_ev_rxfull;
 	struct evcnt sc_ev_rxhist[9];



CVS commit: src/sys/dev/ic

2021-01-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jan 30 07:53:01 UTC 2021

Modified Files:
src/sys/dev/ic: gem.c gemvar.h

Log Message:
Improve handling of receive overflows.  When we get an overflow, don't
reset the chip if we are still receiving packets.  Real overflows can
happen when network and CPU(s) are loaded, so the reset is not needed
in this case.
Add a counter to track receive overflows (when GEM_COUNTERS is defined).

This reverts some changes (always reset on overflow) from
PR port-sparc64/46260.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/gemvar.h

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



CVS commit: src/sys/dev/usb

2020-12-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Dec 29 08:04:59 UTC 2020

Modified Files:
src/sys/dev/usb: uaudio.c

Log Message:
During detach, re-use the functions that halt playback and record DMA.
Prevents a panic during shutdown when media is playing.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/usb/uaudio.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/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.165 src/sys/dev/usb/uaudio.c:1.166
--- src/sys/dev/usb/uaudio.c:1.165	Sat Mar 14 02:35:33 2020
+++ src/sys/dev/usb/uaudio.c	Tue Dec 29 08:04:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.165 2020/03/14 02:35:33 christos Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.166 2020/12/29 08:04:59 jdc Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.165 2020/03/14 02:35:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.166 2020/12/29 08:04:59 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -343,6 +343,8 @@ Static int	uaudio_trigger_input
 	 const audio_params_t *);
 Static int	uaudio_halt_in_dma(void *);
 Static int	uaudio_halt_out_dma(void *);
+Static void	uaudio_halt_in_dma_unlocked(struct uaudio_softc *);
+Static void	uaudio_halt_out_dma_unlocked(struct uaudio_softc *);
 Static int	uaudio_getdev(void *, struct audio_device *);
 Static int	uaudio_mixer_set_port(void *, mixer_ctrl_t *);
 Static int	uaudio_mixer_get_port(void *, mixer_ctrl_t *);
@@ -519,10 +521,13 @@ uaudio_detach(device_t self, int flags)
 	struct uaudio_softc *sc = device_private(self);
 	int rv = 0;
 
+	sc->sc_dying = 1;
+
 	pmf_device_deregister(self);
 
 	/* Wait for outstanding requests to complete. */
-	usbd_delay_ms(sc->sc_udev, UAUDIO_NCHANBUFS * UAUDIO_NFRAMES);
+	uaudio_halt_out_dma_unlocked(sc);
+	uaudio_halt_in_dma_unlocked(sc);
 
 	if (sc->sc_audiodev != NULL)
 		rv = config_detach(sc->sc_audiodev, flags);
@@ -2167,15 +2172,21 @@ uaudio_halt_out_dma(void *addr)
 	DPRINTF("%s", "enter\n");
 
 	mutex_exit(>sc_intr_lock);
+	uaudio_halt_out_dma_unlocked(sc);
+	mutex_enter(>sc_intr_lock);
+
+	return 0;
+}
+
+Static void
+uaudio_halt_out_dma_unlocked(struct uaudio_softc *sc)
+{
 	if (sc->sc_playchan.pipe != NULL) {
 		uaudio_chan_abort(sc, >sc_playchan);
 		uaudio_chan_free_buffers(sc, >sc_playchan);
 		uaudio_chan_close(sc, >sc_playchan);
 		sc->sc_playchan.intr = NULL;
 	}
-	mutex_enter(>sc_intr_lock);
-
-	return 0;
 }
 
 Static int
@@ -2186,15 +2197,21 @@ uaudio_halt_in_dma(void *addr)
 	DPRINTF("%s", "enter\n");
 
 	mutex_exit(>sc_intr_lock);
+	uaudio_halt_in_dma_unlocked(sc);
+	mutex_enter(>sc_intr_lock);
+
+	return 0;
+}
+
+Static void
+uaudio_halt_in_dma_unlocked(struct uaudio_softc *sc)
+{
 	if (sc->sc_recchan.pipe != NULL) {
 		uaudio_chan_abort(sc, >sc_recchan);
 		uaudio_chan_free_buffers(sc, >sc_recchan);
 		uaudio_chan_close(sc, >sc_recchan);
 		sc->sc_recchan.intr = NULL;
 	}
-	mutex_enter(>sc_intr_lock);
-
-	return 0;
 }
 
 Static int



CVS commit: src/sys/dev/usb

2020-12-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Dec 29 08:04:59 UTC 2020

Modified Files:
src/sys/dev/usb: uaudio.c

Log Message:
During detach, re-use the functions that halt playback and record DMA.
Prevents a panic during shutdown when media is playing.


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/dev/usb/uaudio.c

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



CVS commit: src/doc

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:26:36 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
Mention sparc64 E250 environmental monitoring.
Belatedly mention pcf8574(4).


To generate a diff of this commit:
cvs rdiff -u -r1.2766 -r1.2767 src/doc/CHANGES

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



CVS commit: src/doc

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:26:36 UTC 2020

Modified Files:
src/doc: CHANGES

Log Message:
Mention sparc64 E250 environmental monitoring.
Belatedly mention pcf8574(4).


To generate a diff of this commit:
cvs rdiff -u -r1.2766 -r1.2767 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2766 src/doc/CHANGES:1.2767
--- src/doc/CHANGES:1.2766	Sat Dec 12 11:02:06 2020
+++ src/doc/CHANGES	Wed Dec 23 07:26:36 2020
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2766 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2767 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -297,6 +297,7 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	tzcode: Updated to 2020c. [christos 20201017]
 	ossaudio(3): Added support for the OSSv4 Mixer API [nia 20201017]
 	tzdata updated to 2020d  [kre 20201022]
+	pcf8574(4): Add a driver for the PCF8574 I/O expander [jdc 20201029]
 	dhcpcd: Update to version 9.3.2 [roy 20201101]
 	tmux(1): Imported 3.1c. [christos 20201101]
 	kernel: Better default for kern.maxfiles for systems with
@@ -316,3 +317,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	acpicpu(4): Add support for Arm CPUs. [jmcneill 20201207]
 	OpenSSL: Imported 1.1.1i. [christos 20201209]
 	pkg_install: Updated to 20201212. [wiz 20201212]
+	sparc64: Add environment monitoring for the E250 [jdc 20201223]



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

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:09:50 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Rename the CPU fan to SYS fan to match what the firmware calls it.
Check for fan failure and high temperature events when setting the fan
speed.  If one or both is true, run the fans at full speed.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.16
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15	Sun Dec 20 09:08:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Wed Dec 23 07:09:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $");
 
 #include 
 #include 
@@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #define PCF8591_CTRL_OSCILLATOR	0x40
 
 #define PCF8591_TEMP_SENS	0x00
-#define PCF8591_CPU_FAN_CTRL	0x01
+#define PCF8591_SYS_FAN_CTRL	0x01
 
 struct ecadc_channel {
 	u_int		chan_num;
@@ -228,12 +228,12 @@ ecadc_attach(device_t parent, device_t s
 	OF_getprop(node, "cpu-fan-speeds", >sc_cpu_fan_spd,
 	XLATE_MAX) > 0) {
 		sc->sc_channels[sc->sc_nchan].chan_num = 1;
-		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_CPU_FAN_CTRL;
+		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_SYS_FAN_CTRL;
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_INTEGER;
 		sensor->flags = ENVSYS_FMONNOTSUPP;
 		sensor->state = ENVSYS_SINVALID;
-		strlcpy(sensor->desc, "CPUFAN", sizeof(sensor->desc));
+		strlcpy(sensor->desc, "SYSFAN", sizeof(sensor->desc));
 		sc->sc_channels[sc->sc_nchan].chan_xlate = sc->sc_cpu_fan_spd;
 		DPRINTF("%s: "
 		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
@@ -298,7 +298,7 @@ ecadc_detach(device_t self, int flags)
 	for (i = 0; i < sc->sc_nchan; i++) {
 		struct ecadc_channel *chp = >sc_channels[i];
 
-		if (chp->chan_type == PCF8591_CPU_FAN_CTRL) {
+		if (chp->chan_type == PCF8591_SYS_FAN_CTRL) {
 			/* Loop in case the bus is busy */
 			for (c = 0; c < 5; c++) {
 chp->chan_speed = sc->sc_cpu_fan_spd[0];
@@ -307,8 +307,8 @@ ecadc_detach(device_t self, int flags)
 	return 0;
 delay(1);
 			}
-			aprint_error_dev(sc->sc_dev,
-			"cannot set fan speed (chan %d)\n", chp->chan_num);
+			printf("%s: cannot set fan speed (chan %d)\n",
+			device_xname(sc->sc_dev), chp->chan_num);
 		}
 	}
 
@@ -374,11 +374,10 @@ ecadc_refresh(struct sysmon_envsys *sme,
 			}
 			chp->chan_sensor.flags |= ENVSYS_FMONLIMITS;
 		}
-		if (chp->chan_type == PCF8591_CPU_FAN_CTRL)
+		if (chp->chan_type == PCF8591_SYS_FAN_CTRL)
 			chp->chan_sensor.value_cur = data[1 + chp->chan_num];
 
 		chp->chan_sensor.state = ENVSYS_SVALID;
-		chp->chan_sensor.flags &= ~ENVSYS_FNEED_REFRESH;
 	}
 }
 
@@ -419,6 +418,22 @@ is_cpu_temp(const envsys_data_t *edata)
 	return strncmp(edata->desc, "CPU", 3) == 0;
 }
 
+static bool
+is_high_temp(const envsys_data_t *edata)
+{
+	if (edata->units != ENVSYS_INDICATOR)
+		return false;
+	return strcmp(edata->desc, "high_temp") == 0;
+}
+
+static bool
+is_fan_fail(const envsys_data_t *edata)
+{
+	if (edata->units != ENVSYS_INDICATOR)
+		return false;
+	return strcmp(edata->desc, "fan_fail") == 0;
+}
+
 static int
 ecadc_set_fan_speed(struct ecadc_softc *sc, u_int8_t chan, u_int8_t val)
 {
@@ -428,15 +443,15 @@ ecadc_set_fan_speed(struct ecadc_softc *
 	ctrl |= chan;
 	ret = iic_acquire_bus(sc->sc_tag, 0);
 	if (ret) {
-		aprint_error_dev(sc->sc_dev,
-		"error acquiring i2c bus (ch %d)\n", chan);
+		printf("%s: error acquiring i2c bus (ch %d)\n",
+		device_xname(sc->sc_dev), chan);
 		return ret;
 	}
 	ret = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, , 1, 0);
 	if (ret)
-		aprint_error_dev(sc->sc_dev,
-		"error changing fan speed (ch %d)\n", chan);
+		printf("%s: error changing fan speed (ch %d)\n",
+		device_xname(sc->sc_dev), chan);
 	else
 		DPRINTF("%s changed fan speed (ch %d) to 0x%x\n",
 		device_xname(sc->sc_dev), chan, val);
@@ -448,30 +463,47 @@ static void
 ecadc_fan_adjust(void *v)
 {
 	struct ecadc_softc *sc = v;
+	struct ecadc_channel *chp;
 	int i;
 	u_int8_t temp, speed;
+	u_int32_t htemp, ffail;
 
 	for (i = 0; i < sc->sc_nchan; i++) {
-		struct ecadc_channel *chp = >sc_channels[i];
+		chp = >sc_channels[i];
+		if (chp->chan_type != 

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

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:09:50 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Rename the CPU fan to SYS fan to match what the firmware calls it.
Check for fan failure and high temperature events when setting the fan
speed.  If one or both is true, run the fans at full speed.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



CVS commit: src/sys/dev/i2c

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:06:26 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Handle pins that represent alerts.
  split out common code for alert and indicator pins
  change the previously debug-only callout to work for alerts too
  split out common code for alerts in refresh and in callout
While here, remove redundant variable used for checking sysmon setup.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/pcf8574.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/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.5 src/sys/dev/i2c/pcf8574.c:1.6
--- src/sys/dev/i2c/pcf8574.c:1.5	Sun Dec  6 10:09:36 2020
+++ src/sys/dev/i2c/pcf8574.c	Wed Dec 23 07:06:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $ */
+/* $NetBSD: pcf8574.c,v 1.6 2020/12/23 07:06:26 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.6 2020/12/23 07:06:26 jdc Exp $");
 
 #include 
 #include 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -59,6 +60,12 @@ struct pcf8574_led {
 	uint8_t mask, v_on, v_off;
 };
 
+struct pcf8574_pin {
+	int pin_sensor;
+	int pin_active;
+	char pin_desc[ENVSYS_DESCLEN];
+};
+
 #define PCF8574_NPINS	8
 struct pcf8574_softc {
 	device_t	sc_dev;
@@ -67,34 +74,35 @@ struct pcf8574_softc {
 	uint8_t		sc_state;
 	uint8_t		sc_mask;
 
+	uint8_t		sc_alert_mask;
+#define	PCF8574_DEFAULT_TIMER	60
+	int		sc_callout_time;
+	callout_t	sc_timer;
+
 	int		sc_nleds;
 	struct pcf8574_led sc_leds[PCF8574_NPINS];
+	struct pcf8574_pin sc_pins[PCF8574_NPINS];
 
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t	sc_sensor[PCF8574_NPINS];
-	int		sc_pin_sensor[PCF8574_NPINS];
-	int		sc_pin_active[PCF8574_NPINS];
-
-#ifdef PCF8574_DEBUG
-	callout_t	sc_timer;
-#endif
 };
 
 static int	pcf8574_match(device_t, cfdata_t, void *);
 static void	pcf8574_attach(device_t, device_t, void *);
 static int	pcf8574_detach(device_t, int);
 
-static int	pcf8574_read(struct pcf8574_softc *sc, uint8_t *val);
-static int	pcf8574_write(struct pcf8574_softc *sc, uint8_t val);
+static int	pcf8574_read(struct pcf8574_softc *sc, uint8_t *);
+static int	pcf8574_write(struct pcf8574_softc *sc, uint8_t);
 static void	pcf8574_attach_led(
 			struct pcf8574_softc *, char *, int, int, int);
+static int	pcf8574_attach_sysmon(
+			struct pcf8574_softc *, char *, int, int, int);
 void		pcf8574_refresh(struct sysmon_envsys *, envsys_data_t *);
 int		pcf8574_get_led(void *);
 void		pcf8574_set_led(void *, int);
-
-#ifdef PCF8574_DEBUG
-static void pcf8574_timeout(void *);
-#endif
+static void	pcf8574_timeout(void *);
+static void	pcf8574_check(void *);
+static void	pcf8574_check_alert(struct pcf8574_softc *, uint8_t, uint8_t);
 
 CFATTACH_DECL_NEW(pcf8574io, sizeof(struct pcf8574_softc),
 	pcf8574_match, pcf8574_attach, pcf8574_detach, NULL);
@@ -128,12 +136,19 @@ pcf8574_attach(device_t parent, device_t
 	int i, num, def, envc = 0;
 	char name[32];
 	const char *nptr = NULL, *spptr;
-	bool ok = TRUE, act, sysmon = FALSE;
+	bool ok = TRUE, act;
 
 	sc->sc_tag = ia->ia_tag;
 	sc->sc_addr = ia->ia_addr;
 	sc->sc_dev = self;
 
+	sc->sc_sme = NULL;
+#ifdef PCF8574_DEBUG
+	sc->sc_callout_time = 60;	/* watch for changes when debugging */
+#else
+	sc->sc_callout_time = 0;
+#endif
+
 	/*
 	 * The PCF8574 requires input pins to be written with the value 1,
 	 * and then read.  Assume that all pins are input initially.
@@ -150,9 +165,6 @@ pcf8574_attach(device_t parent, device_t
 
 #ifdef PCF8574_DEBUG
 	aprint_normal(": GPIO: state = 0x%02x\n", sc->sc_state);
-
-	callout_init(>sc_timer, CALLOUT_MPSAFE);
-	callout_reset(>sc_timer, hz*30, pcf8574_timeout, sc);
 #else
 	aprint_normal(": GPIO\n");
 #endif
@@ -177,37 +189,38 @@ pcf8574_attach(device_t parent, device_t
 			continue;
 		spptr += 1;
 		strncpy(name, spptr, 31);
-		sc->sc_pin_active[i] = act;
+		sc->sc_pins[i].pin_active = act;
 		if (!strncmp(nptr, "LED ", 4)) {
 			sc->sc_mask &= ~(1 << num);
 			pcf8574_attach_led(sc, name, num, act, def);
 		}
-		if (!strncmp(nptr, "INDICATOR ", 4)) {
-			if (!sysmon) {
-sc->sc_sme = sysmon_envsys_create();
-sysmon = TRUE;
-			}
-			/* envsys sensor # to pin # mapping */
-			sc->sc_pin_sensor[envc] = num;
-			sc->sc_sensor[i].state = ENVSYS_SINVALID;
-			sc->sc_sensor[i].units = ENVSYS_INDICATOR;
-			strlcpy(sc->sc_sensor[i].desc, name,
-			sizeof(sc->sc_sensor[i].desc));
-			if (sysmon_envsys_sensor_attach(sc->sc_sme,
-			>sc_sensor[i])) {
-sysmon_envsys_destroy(sc->sc_sme);
-sc->sc_sme = NULL;
-aprint_error_dev(self,
-"unable to attach pin %d at sysmon\n", i);
+		if 

CVS commit: src/sys/dev/i2c

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:06:26 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Handle pins that represent alerts.
  split out common code for alert and indicator pins
  change the previously debug-only callout to work for alerts too
  split out common code for alerts in refresh and in callout
While here, remove redundant variable used for checking sysmon setup.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/pcf8574.c

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



CVS commit: src/sys/arch/sparc64/sparc64

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:01:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add GPIO pin alert definitions for the E250.
Note, that the front panel also applies to the E450.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6	Thu Oct 29 06:47:38 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Wed Dec 23 07:01:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $");
 
 #include 
 
@@ -134,6 +134,16 @@ add_gpio_props_e250(device_t dev, void *
 	prop_array_t pins;
 
 	switch (ia->ia_addr) {
+		case 0x38:	/* interrupt status */
+			pins = prop_array_create();
+			add_gpio_pin(pins, "ALERT high_temp", 1, 0, 30);
+			add_gpio_pin(pins, "ALERT disk_event", 2, 0, 30);
+			add_gpio_pin(pins, "ALERT fan_fail", 4, 0, 30);
+			add_gpio_pin(pins, "ALERT key_event", 5, 0, 30);
+			add_gpio_pin(pins, "ALERT psu_event", 6, 0, 30);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
 		case 0x39:	/* PSU status */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "INDICATOR psu0_present", 0, 0, -1);
@@ -160,7 +170,7 @@ add_gpio_props_e250(device_t dev, void *
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x3e:	/* front panel LEDs */
+		case 0x3e:	/* front panel LEDs (E250/E450) */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "LED disk_fault", 0, 0, -1);
 			add_gpio_pin(pins, "LED psu_fault", 1, 0, -1);



CVS commit: src/sys/arch/sparc64/sparc64

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:01:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add GPIO pin alert definitions for the E250.
Note, that the front panel also applies to the E450.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/ofw_patch.c

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



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

2020-12-20 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec 20 09:08:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
For the E250:
  set fans to medium speed when attaching and full speed when detaching.
  remove unused PS fan definition.
In general:
  return early from attach if the device isn't present.
  handle errors from sysmon during attach so that detach doesn't crash.
  try to handle errors when acquiring the iic bus during detach.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14	Mon Dec  7 13:24:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Dec 20 09:08:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $");
 
 #include 
 #include 
@@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 
 #define PCF8591_TEMP_SENS	0x00
 #define PCF8591_CPU_FAN_CTRL	0x01
-#define PCF8591_PS_FAN_CTRL	0x02
 
 struct ecadc_channel {
 	u_int		chan_num;
@@ -89,6 +88,7 @@ static int	ecadc_detach(device_t, int);
 static void	ecadc_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void	ecadc_get_limits(struct sysmon_envsys *, envsys_data_t *,
 			sysmon_envsys_lim_t *, u_int32_t *);
+static int	ecadc_set_fan_speed(struct ecadc_softc *, u_int8_t, u_int8_t);
 static void	ecadc_timeout(void *);
 static void	ecadc_fan_adjust(void *);
 
@@ -205,6 +205,21 @@ ecadc_attach(device_t parent, device_t s
 		sc->sc_nchan++;
 	}
 
+	sc->sc_tag = ia->ia_tag;
+	sc->sc_addr = ia->ia_addr;
+
+	iic_acquire_bus(sc->sc_tag, 0);
+
+	/* Try a read now, so we can fail if this component isn't present */
+	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
+	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
+		aprint_normal(": read failed\n");
+		iic_release_bus(sc->sc_tag, 0);
+		return;
+	}
+
+	iic_release_bus(sc->sc_tag, 0);
+
 	/*
 	 * Fan speed changing information is missing from OFW
 	 * The E250 CPU fan is connected to the sensor at addr 0x4a, channel 1
@@ -214,7 +229,6 @@ ecadc_attach(device_t parent, device_t s
 	XLATE_MAX) > 0) {
 		sc->sc_channels[sc->sc_nchan].chan_num = 1;
 		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_CPU_FAN_CTRL;
-		sc->sc_channels[sc->sc_nchan].chan_speed = 0;
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_INTEGER;
 		sensor->flags = ENVSYS_FMONNOTSUPP;
@@ -225,26 +239,17 @@ ecadc_attach(device_t parent, device_t s
 		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
 		device_xname(sc->sc_dev),
 		sc->sc_channels[sc->sc_nchan].chan_num);
-		sc->sc_nchan++;
 
-		sc->sc_hastimer = 1;
-	}
+		/* Set the fan to medium speed */
+		sc->sc_channels[sc->sc_nchan].chan_speed =
+		(sc->sc_cpu_fan_spd[0]+sc->sc_cpu_fan_spd[XLATE_MAX])/2;
+		ecadc_set_fan_speed(sc, sc->sc_channels[sc->sc_nchan].chan_num,
+		sc->sc_channels[sc->sc_nchan].chan_speed);
 
-	sc->sc_tag = ia->ia_tag;
-	sc->sc_addr = ia->ia_addr;
-
-	iic_acquire_bus(sc->sc_tag, 0);
-
-	/* Try a read now, so we can fail if this component isn't present */
-	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
-		aprint_normal(": read failed\n");
-		iic_release_bus(sc->sc_tag, 0);
-		return;
+		sc->sc_nchan++;
+		sc->sc_hastimer = 1;
 	}
 
-	iic_release_bus(sc->sc_tag, 0);
-
 	/* Hook us into the sysmon_envsys subsystem */
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sme->sme_name = device_xname(self);
@@ -280,6 +285,8 @@ static int
 ecadc_detach(device_t self, int flags)
 {
 	struct ecadc_softc *sc = device_private(self);
+	int c, i;
+
 	if (sc->sc_hastimer) {
 		callout_halt(>sc_timer, NULL);
 		callout_destroy(>sc_timer);
@@ -288,6 +295,23 @@ ecadc_detach(device_t self, int flags)
 	if (sc->sc_sme != NULL)
 		sysmon_envsys_unregister(sc->sc_sme);
 
+	for (i = 0; i < sc->sc_nchan; i++) {
+		struct ecadc_channel *chp = >sc_channels[i];
+
+		if (chp->chan_type == PCF8591_CPU_FAN_CTRL) {
+			/* Loop in case the bus is busy */
+			for (c = 0; c < 5; c++) {
+chp->chan_speed = sc->sc_cpu_fan_spd[0];
+if (!ecadc_set_fan_speed(sc, chp->chan_num,
+chp->chan_speed))
+	return 0;
+delay(1);
+			}
+			aprint_error_dev(sc->sc_dev,
+			"cannot set fan speed (chan %d)\n", 

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

2020-12-20 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec 20 09:08:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
For the E250:
  set fans to medium speed when attaching and full speed when detaching.
  remove unused PS fan definition.
In general:
  return early from attach if the device isn't present.
  handle errors from sysmon during attach so that detach doesn't crash.
  try to handle errors when acquiring the iic bus during detach.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



CVS commit: src/sys/dev/i2c

2020-12-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Dec 10 17:02:51 UTC 2020

Modified Files:
src/sys/dev/i2c: adm1021.c

Log Message:
Handle failing to acquire the iic bus.
Better handle errors when attaching sysmon sensors.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/adm1021.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/dev/i2c/adm1021.c
diff -u src/sys/dev/i2c/adm1021.c:1.20 src/sys/dev/i2c/adm1021.c:1.21
--- src/sys/dev/i2c/adm1021.c:1.20	Fri Aug 21 20:44:38 2020
+++ src/sys/dev/i2c/adm1021.c	Thu Dec 10 17:02:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan Exp $ */
+/*	$NetBSD: adm1021.c,v 1.21 2020/12/10 17:02:51 jdc Exp $ */
 /*	$OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.21 2020/12/10 17:02:51 jdc Exp $");
 
 #include 
 #include 
@@ -396,6 +396,7 @@ admtemp_attach(device_t parent, device_t
 	if (sysmon_envsys_sensor_attach(
 	sc->sc_sme, >sc_sensor[ADMTEMP_INT])) {
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		aprint_error_dev(self,
 		"unable to attach internal at sysmon\n");
 		return;
@@ -404,6 +405,7 @@ admtemp_attach(device_t parent, device_t
 	sysmon_envsys_sensor_attach(
 	sc->sc_sme, >sc_sensor[ADMTEMP_EXT])) {
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		aprint_error_dev(self,
 		"unable to attach external at sysmon\n");
 		return;
@@ -425,6 +427,7 @@ admtemp_attach(device_t parent, device_t
 		aprint_error_dev(self,
 		"unable to register with sysmon\n");
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		return;
 	}
 }
@@ -437,7 +440,10 @@ admtemp_refresh(struct sysmon_envsys *sm
 	uint8_t cmd, xdata;
 	int8_t sdata;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0)) {
+		edata->state = ENVSYS_SINVALID;
+		return;
+	}
 
 	if (edata->sensor == ADMTEMP_INT)
 		cmd = ADM1021_INT_TEMP;
@@ -472,7 +478,8 @@ admtemp_getlim_1021(struct sysmon_envsys
 
 	*props &= ~(PROP_CRITMAX | PROP_CRITMIN);
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (edata->sensor == ADMTEMP_INT)
 		cmd = ADM1021_INT_HIGH_READ;
@@ -521,7 +528,8 @@ admtemp_getlim_1023(struct sysmon_envsys
 
 	*props &= ~(PROP_CRITMAX | PROP_CRITMIN);
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (edata->sensor == ADMTEMP_INT)
 		cmd = ADM1021_INT_HIGH_READ;
@@ -585,7 +593,8 @@ admtemp_getlim_1032(struct sysmon_envsys
 
 	*props &= ~(PROP_WARNMAX | PROP_CRITMAX | PROP_WARNMIN);
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (edata->sensor == ADMTEMP_INT)
 		cmd = ADM1032_INT_THERM;
@@ -660,7 +669,8 @@ admtemp_setlim_1021(struct sysmon_envsys
 	int tmp;
 	int8_t sdata;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (*props & PROP_CRITMAX) {
 		if (edata->sensor == ADMTEMP_INT)
@@ -746,7 +756,8 @@ admtemp_setlim_1023(struct sysmon_envsys
 	else
 		ext11 = 1;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (*props & PROP_CRITMAX) {
 		if (edata->sensor == ADMTEMP_INT)
@@ -803,7 +814,8 @@ admtemp_setlim_1032(struct sysmon_envsys
 	else
 		ext11 = 1;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 
 	if (*props & PROP_CRITMAX) {
 		if (edata->sensor == ADMTEMP_INT)



CVS commit: src/sys/dev/i2c

2020-12-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Dec 10 17:02:51 UTC 2020

Modified Files:
src/sys/dev/i2c: adm1021.c

Log Message:
Handle failing to acquire the iic bus.
Better handle errors when attaching sysmon sensors.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/i2c/adm1021.c

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



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

2020-12-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Dec  7 13:24:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Add some debugging output to check sensor addition and refresh.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13	Sun Dec  6 10:06:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Mon Dec  7 13:24:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $");
 
 #include 
 #include 
@@ -34,6 +34,12 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #include 
 #include 
 
+#ifdef ECADC_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
 /* Translation tables contain 254 entries */
 #define XLATE_SIZE		256
 #define XLATE_MAX		(XLATE_SIZE - 2)
@@ -126,6 +132,7 @@ ecadc_attach(device_t parent, device_t s
 	sc->sc_nchan = 0;
 	sc->sc_hastimer = 0;
 
+	DPRINTF("\n");
 	if ((len = OF_getprop(node, "thermisters", term,
 	sizeof(term))) < 0) {
 		aprint_error(": couldn't find \"thermisters\" property\n");
@@ -170,15 +177,25 @@ ecadc_attach(device_t parent, device_t s
 		sensor->state = ENVSYS_SINVALID;
 		strlcpy(sensor->desc, desc, sizeof(sensor->desc));
 
-		if (strncmp(desc, "CPU", 3) == 0)
+		if (strncmp(desc, "CPU", 3) == 0) {
 			sc->sc_channels[sc->sc_nchan].chan_xlate =
 			sc->sc_cpu_xlate;
-		else if (strncmp(desc, "PS", 2) == 0)
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) with cpu_xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		} else if (strncmp(desc, "PS", 2) == 0) {
 			sc->sc_channels[sc->sc_nchan].chan_xlate =
 			sc->sc_ps_xlate;
-		else
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) with ps_xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		} else {
 			sc->sc_channels[sc->sc_nchan].chan_factor =
 			(100 * num) / den;
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) without xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		}
 		sc->sc_channels[sc->sc_nchan].chan_min =
 		27315 + 100 * minv;
 		sc->sc_channels[sc->sc_nchan].chan_warn =
@@ -204,6 +221,10 @@ ecadc_attach(device_t parent, device_t s
 		sensor->state = ENVSYS_SINVALID;
 		strlcpy(sensor->desc, "CPUFAN", sizeof(sensor->desc));
 		sc->sc_channels[sc->sc_nchan].chan_xlate = sc->sc_cpu_fan_spd;
+		DPRINTF("%s: "
+		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
+		device_xname(sc->sc_dev),
+		sc->sc_channels[sc->sc_nchan].chan_num);
 		sc->sc_nchan++;
 
 		sc->sc_hastimer = 1;
@@ -312,9 +333,21 @@ ecadc_refresh(struct sysmon_envsys *sme,
 temp &= ~0xff;
 temp += data[1 + chp->chan_num];
 chp->chan_sensor.value_cur = temp;
-			} else
+DPRINTF("%s: xlate %s sensor = %d"
+" (0x%x > 0x%x)\n",
+device_xname(sc->sc_dev),
+chp->chan_sensor.desc, temp,
+data[1 + chp->chan_num],
+chp->chan_xlate[data[1 + chp->chan_num]]);
+			} else {
 chp->chan_sensor.value_cur = 27315 +
 chp->chan_factor * data[1 + chp->chan_num];
+DPRINTF("%s: read %s sensor = %d (0x%x)\n",
+device_xname(sc->sc_dev),
+chp->chan_sensor.desc,
+chp->chan_sensor.value_cur,
+data[1 + chp->chan_num]);
+			}
 			chp->chan_sensor.flags |= ENVSYS_FMONLIMITS;
 		}
 		if (chp->chan_type == PCF8591_CPU_FAN_CTRL ||
@@ -382,8 +415,8 @@ ecadc_set_fan_speed(struct ecadc_softc *
 		aprint_error_dev(sc->sc_dev,
 		"error changing fan speed (ch %d)\n", chan);
 	else
-		aprint_debug_dev(sc->sc_dev,
-		"changed fan speed (ch %d) to 0x%x\n", chan, val);
+		DPRINTF("%s changed fan speed (ch %d) to 0x%x\n",
+		device_xname(sc->sc_dev), chan, val);
 	iic_release_bus(sc->sc_tag, 0);
 	return ret;
 }



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

2020-12-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Dec  7 13:24:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Add some debugging output to check sensor addition and refresh.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



CVS commit: src/sys/dev/i2c

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:09:36 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcf8574.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/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.4 src/sys/dev/i2c/pcf8574.c:1.5
--- src/sys/dev/i2c/pcf8574.c:1.4	Sat Dec  5 15:02:29 2020
+++ src/sys/dev/i2c/pcf8574.c	Sun Dec  6 10:09:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $ */
+/* $NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.5 2020/12/06 10:09:36 jdc Exp $");
 
 #include 
 #include 
@@ -108,21 +108,10 @@ static int
 pcf8574_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	struct pcf8574_softc sc;
 	int match_result;
 
-	if (!iic_use_direct_match(ia, cf, compat_data, _result))
-		return 0;
-
-	/* Try a read so that we don't match on optional components */
-	if (match_result) {
-		sc.sc_tag = ia->ia_tag;
-		sc.sc_addr = ia->ia_addr;
-		if (pcf8574_read(, _state))
-			return 0;
-		else
-			return match_result;
-	}
+	if (iic_use_direct_match(ia, cf, compat_data, _result))
+		return match_result;
 
 	/* We don't support indirect matches */
 	return 0;
@@ -153,7 +142,11 @@ pcf8574_attach(device_t parent, device_t
 	 */
 	sc->sc_mask = 0xff;
 
-	pcf8574_read(sc, >sc_state);
+	/* Try a read, and fail if this component isn't present */
+	if (pcf8574_read(sc, >sc_state)) {
+		aprint_normal(": read failed\n");
+		return;
+	}
 
 #ifdef PCF8574_DEBUG
 	aprint_normal(": GPIO: state = 0x%02x\n", sc->sc_state);



CVS commit: src/sys/dev/i2c

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:09:36 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcf8574.c

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



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

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:06:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.
While here, handle errors attaching sysmon and acquiring the iic bus lock.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12	Sat Dec  5 15:08:21 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Dec  6 10:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $");
 
 #include 
 #include 
@@ -99,28 +99,10 @@ static int
 ecadc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	struct ecadc_softc sc;
 	int match_result;
-	u_int8_t junk;
 
-	if (!iic_use_direct_match(ia, cf, compat_data, _result))
-		return 0;
-
-	/* Try a read so that we don't match on optional components */
-	if (match_result) {
-		sc.sc_tag = ia->ia_tag;
-		sc.sc_addr = ia->ia_addr;
-
-		iic_acquire_bus(sc.sc_tag, 0);
-		if (iic_exec(sc.sc_tag, I2C_OP_READ_WITH_STOP, sc.sc_addr,
-		NULL, 0, , 1, 0)) {
-			iic_release_bus(sc.sc_tag, 0);
-			return 0;
-		} else {
-			iic_release_bus(sc.sc_tag, 0);
-			return match_result;
-		}
-	}
+	if (iic_use_direct_match(ia, cf, compat_data, _result))
+		return match_result;
 
 	/* This driver is direct-config only. */
 
@@ -232,10 +214,10 @@ ecadc_attach(device_t parent, device_t s
 
 	iic_acquire_bus(sc->sc_tag, 0);
 
-	/* Try a read now, so we can fail if it doesn't work */
+	/* Try a read now, so we can fail if this component isn't present */
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
 	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
-		aprint_error(": read failed\n");
+		aprint_normal(": read failed\n");
 		iic_release_bus(sc->sc_tag, 0);
 		return;
 	}
@@ -259,6 +241,7 @@ ecadc_attach(device_t parent, device_t s
 		aprint_error_dev(self, "error %d registering with sysmon\n",
 			error);
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		return;
 	}
 	
@@ -296,7 +279,8 @@ ecadc_refresh(struct sysmon_envsys *sme,
 	u_int8_t ctrl = PCF8591_CTRL_CH0 | PCF8591_CTRL_AUTOINC |
 	PCF8591_CTRL_OSCILLATOR;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 	if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, NULL, 0, 0)) {
 		iic_release_bus(sc->sc_tag, 0);
@@ -386,7 +370,12 @@ ecadc_set_fan_speed(struct ecadc_softc *
 	int ret;
 
 	ctrl |= chan;
-	iic_acquire_bus(sc->sc_tag, 0);
+	ret = iic_acquire_bus(sc->sc_tag, 0);
+	if (ret) {
+		aprint_error_dev(sc->sc_dev,
+		"error acquiring i2c bus (ch %d)\n", chan);
+		return ret;
+	}
 	ret = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, , 1, 0);
 	if (ret)



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

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:06:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.
While here, handle errors attaching sysmon and acquiring the iic bus lock.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



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

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 15:08:21 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
When matching, try a read in case this is an optional device and isn't
actually present.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11	Sat Oct 31 13:17:34 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Dec  5 15:08:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $");
 
 #include 
 #include 
@@ -99,10 +99,28 @@ static int
 ecadc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
+	struct ecadc_softc sc;
 	int match_result;
+	u_int8_t junk;
 
-	if (iic_use_direct_match(ia, cf, compat_data, _result))
-		return match_result;
+	if (!iic_use_direct_match(ia, cf, compat_data, _result))
+		return 0;
+
+	/* Try a read so that we don't match on optional components */
+	if (match_result) {
+		sc.sc_tag = ia->ia_tag;
+		sc.sc_addr = ia->ia_addr;
+
+		iic_acquire_bus(sc.sc_tag, 0);
+		if (iic_exec(sc.sc_tag, I2C_OP_READ_WITH_STOP, sc.sc_addr,
+		NULL, 0, , 1, 0)) {
+			iic_release_bus(sc.sc_tag, 0);
+			return 0;
+		} else {
+			iic_release_bus(sc.sc_tag, 0);
+			return match_result;
+		}
+	}
 
 	/* This driver is direct-config only. */
 



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

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 15:08:21 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
When matching, try a read in case this is an optional device and isn't
actually present.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 15:02:29 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Return "match_result", not "1".  Pointed out by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/pcf8574.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/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.3 src/sys/dev/i2c/pcf8574.c:1.4
--- src/sys/dev/i2c/pcf8574.c:1.3	Sat Dec  5 14:48:09 2020
+++ src/sys/dev/i2c/pcf8574.c	Sat Dec  5 15:02:29 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8574.c,v 1.3 2020/12/05 14:48:09 jdc Exp $ */
+/* $NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.3 2020/12/05 14:48:09 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.4 2020/12/05 15:02:29 jdc Exp $");
 
 #include 
 #include 
@@ -121,7 +121,7 @@ pcf8574_match(device_t parent, cfdata_t 
 		if (pcf8574_read(, _state))
 			return 0;
 		else
-			return 1;
+			return match_result;
 	}
 
 	/* We don't support indirect matches */



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 15:02:29 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Return "match_result", not "1".  Pointed out by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/pcf8574.c

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



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 14:50:33 UTC 2020

Modified Files:
src/sys/dev/i2c: hytp14.c si70xx.c

Log Message:
Make sure that we set sc->sc_sme to NULL in failure cases in order to avoid
calling sysmon_envsys_unregister() with an invalid struct when we detach.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/hytp14.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/si70xx.c

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



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 14:50:33 UTC 2020

Modified Files:
src/sys/dev/i2c: hytp14.c si70xx.c

Log Message:
Make sure that we set sc->sc_sme to NULL in failure cases in order to avoid
calling sysmon_envsys_unregister() with an invalid struct when we detach.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/hytp14.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/si70xx.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/dev/i2c/hytp14.c
diff -u src/sys/dev/i2c/hytp14.c:1.9 src/sys/dev/i2c/hytp14.c:1.10
--- src/sys/dev/i2c/hytp14.c:1.9	Tue Oct  8 21:16:11 2019
+++ src/sys/dev/i2c/hytp14.c	Sat Dec  5 14:50:33 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.9 2019/10/08 21:16:11 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.10 2020/12/05 14:50:33 jdc Exp $");
 
 #include 
 #include 
@@ -189,6 +189,7 @@ hytp14_attach(device_t parent, device_t 
 			aprint_error_dev(sc->sc_dev,
 			"unable to attach sensor\n");
 			sysmon_envsys_destroy(sc->sc_sme);
+			sc->sc_sme = NULL;
 			return;
 		}
 	}

Index: src/sys/dev/i2c/si70xx.c
diff -u src/sys/dev/i2c/si70xx.c:1.5 src/sys/dev/i2c/si70xx.c:1.6
--- src/sys/dev/i2c/si70xx.c:1.5	Sun Feb  3 12:18:21 2019
+++ src/sys/dev/i2c/si70xx.c	Sat Dec  5 14:50:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $	*/
+/*	$NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $	*/
 
 /*
  * Copyright (c) 2017 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $");
 
 /*
   Driver for the Silicon Labs SI7013/SI7020/SI7021
@@ -718,6 +718,7 @@ si70xx_attach(device_t parent, device_t 
 		if (error) {
 			aprint_error_dev(self,
 			"Unable to attach sensor %d: %d\n", i, error);
+			sc->sc_sme = NULL;
 			goto out;
 		}
 	}



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 14:48:09 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
When matching, try a read in case this is an optional device and isn't
actually present.
Make sure that we set sc->sc_sme to NULL in failure cases and when we
detach in order to avoid calling sysmon_envsys_unregister() with an
invalid struct.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/pcf8574.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/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.2 src/sys/dev/i2c/pcf8574.c:1.3
--- src/sys/dev/i2c/pcf8574.c:1.2	Sat Oct 31 14:39:31 2020
+++ src/sys/dev/i2c/pcf8574.c	Sat Dec  5 14:48:09 2020
@@ -1,3 +1,5 @@
+/* $NetBSD: pcf8574.c,v 1.3 2020/12/05 14:48:09 jdc Exp $ */
+
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.2 2020/10/31 14:39:31 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.3 2020/12/05 14:48:09 jdc Exp $");
 
 #include 
 #include 
@@ -106,10 +108,21 @@ static int
 pcf8574_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
+	struct pcf8574_softc sc;
 	int match_result;
 
-	if (iic_use_direct_match(ia, cf, compat_data, _result))
-		return match_result;
+	if (!iic_use_direct_match(ia, cf, compat_data, _result))
+		return 0;
+
+	/* Try a read so that we don't match on optional components */
+	if (match_result) {
+		sc.sc_tag = ia->ia_tag;
+		sc.sc_addr = ia->ia_addr;
+		if (pcf8574_read(, _state))
+			return 0;
+		else
+			return 1;
+	}
 
 	/* We don't support indirect matches */
 	return 0;
@@ -190,6 +203,7 @@ pcf8574_attach(device_t parent, device_t
 			if (sysmon_envsys_sensor_attach(sc->sc_sme,
 			>sc_sensor[i])) {
 sysmon_envsys_destroy(sc->sc_sme);
+sc->sc_sme = NULL;
 aprint_error_dev(self,
 "unable to attach pin %d at sysmon\n", i);
 return;
@@ -208,6 +222,7 @@ pcf8574_attach(device_t parent, device_t
 			aprint_error_dev(self,
 			"unable to register with sysmon\n");
 			sysmon_envsys_destroy(sc->sc_sme);
+			sc->sc_sme = NULL;
 			return;
 		}
 	}
@@ -219,8 +234,10 @@ pcf8574_detach(device_t self, int flags)
 	struct pcf8574_softc *sc = device_private(self);
 	int i;
 
-	if (sc->sc_sme != NULL)
+	if (sc->sc_sme != NULL) {
 		sysmon_envsys_unregister(sc->sc_sme);
+		sc->sc_sme = NULL;
+	}
 
 	for (i = 0; i < sc->sc_nleds; i++)
 		led_detach(sc->sc_leds[i].led);



CVS commit: src/sys/dev/i2c

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 14:48:09 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
When matching, try a read in case this is an optional device and isn't
actually present.
Make sure that we set sc->sc_sme to NULL in failure cases and when we
detach in order to avoid calling sysmon_envsys_unregister() with an
invalid struct.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/pcf8574.c

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



CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:38:54 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Detach led's in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/pcagpio.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/dev/i2c/pcagpio.c
diff -u src/sys/dev/i2c/pcagpio.c:1.5 src/sys/dev/i2c/pcagpio.c:1.6
--- src/sys/dev/i2c/pcagpio.c:1.5	Thu Oct 29 06:50:53 2020
+++ src/sys/dev/i2c/pcagpio.c	Sat Oct 31 14:38:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $ */
+/* $NetBSD: pcagpio.c,v 1.6 2020/10/31 14:38:54 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.6 2020/10/31 14:38:54 jdc Exp $");
 
 #include 
 #include 
@@ -67,6 +67,7 @@ static void	pcagpio_timeout(void *);
 /* we can only pass one cookie to led_attach() but we need several values... */
 struct pcagpio_led {
 	void *cookie;
+	struct led_device *led;
 	uint32_t mask, v_on, v_off;
 };
 
@@ -215,9 +216,13 @@ pcagpio_attach(device_t parent, device_t
 static int
 pcagpio_detach(device_t self, int flags)
 {
-#ifdef PCAGPIO_DEBUG
 	struct pcagpio_softc *sc = device_private(self);
+	int i;
 
+	for (i = 0; i < sc->sc_nleds; i++)
+		led_detach(sc->sc_leds[i].led);
+
+#ifdef PCAGPIO_DEBUG
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);
 #endif
@@ -311,7 +316,7 @@ pcagpio_attach_led(struct pcagpio_softc 
 	l->mask = 1 << pin;
 	l->v_on = act ? l->mask : 0;
 	l->v_off = act ? 0 : l->mask;
-	led_attach(n, l, pcagpio_get, pcagpio_set);
+	l->led = led_attach(n, l, pcagpio_get, pcagpio_set);
 	if (def != -1) pcagpio_set(l, def);
 	DPRINTF("%s: %04x %04x %04x def %d\n",
 	__func__, l->mask, l->v_on, l->v_off, def);



CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:39:31 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Detach led's and sysmon in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/pcf8574.c

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



CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:39:31 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Detach led's and sysmon in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/pcf8574.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/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.1 src/sys/dev/i2c/pcf8574.c:1.2
--- src/sys/dev/i2c/pcf8574.c:1.1	Thu Oct 29 06:55:51 2020
+++ src/sys/dev/i2c/pcf8574.c	Sat Oct 31 14:39:31 2020
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.1 2020/10/29 06:55:51 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.2 2020/10/31 14:39:31 jdc Exp $");
 
 #include 
 #include 
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 
 
 struct pcf8574_led {
 	void *cookie;
+	struct led_device *led;
 	uint8_t mask, v_on, v_off;
 };
 
@@ -215,13 +216,19 @@ pcf8574_attach(device_t parent, device_t
 static int
 pcf8574_detach(device_t self, int flags)
 {
-#ifdef PCF8574_DEBUG
 	struct pcf8574_softc *sc = device_private(self);
+	int i;
+
+	if (sc->sc_sme != NULL)
+		sysmon_envsys_unregister(sc->sc_sme);
+
+	for (i = 0; i < sc->sc_nleds; i++)
+		led_detach(sc->sc_leds[i].led);
 
+#ifdef PCF8574_DEBUG
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);
 #endif
-
 	return 0;
 }
 



CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:38:54 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Detach led's in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/pcagpio.c

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



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

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 13:17:34 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c

Log Message:
Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching.  Pointed out by Michael van Elst.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/tda.c

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



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

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 13:17:34 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c

Log Message:
Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching.  Pointed out by Michael van Elst.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/tda.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10	Sat Oct 24 15:16:39 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -264,7 +264,7 @@ ecadc_detach(device_t self, int flags)
 	}
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	return 0;
 }

Index: src/sys/arch/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.13 src/sys/arch/sparc64/dev/tda.c:1.14
--- src/sys/arch/sparc64/dev/tda.c:1.13	Fri Mar  1 02:38:17 2019
+++ src/sys/arch/sparc64/dev/tda.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $	*/
+/*	$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -177,7 +177,7 @@ tda_detach(device_t self, int flags)
 	struct tda_softc *sc = device_private(self);
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);



CVS commit: src/sys/arch/sparc64/conf

2020-10-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 30 06:44:38 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add pcagpio and pcf8574io - hardware status monitors on V210/V240 and E250.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.232 src/sys/arch/sparc64/conf/GENERIC:1.233
--- src/sys/arch/sparc64/conf/GENERIC:1.232	Mon Oct 26 11:49:45 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Fri Oct 30 06:44:37 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.232 2020/10/26 11:49:45 martin Exp $
+# $NetBSD: GENERIC,v 1.233 2020/10/30 06:44:37 jdc Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.232 $"
+#ident		"GENERIC-$Revision: 1.233 $"
 
 maxusers	64
 
@@ -826,6 +826,8 @@ lmtemp* 	at iic? addr?
 tda*		at iic? addr?	# fan control on SB1000/2000
 dbcool* 	at iic? addr?	# SB25000
 seeprom*	at iic? addr?	# i2c-at24c64 fru's
+pcagpio* 	at iic? addr?	# V210/V240 GPIO's
+pcf8574io* 	at iic? addr?	# E250 GPIO's
 
 ### Other pseudo-devices
 



CVS commit: src/sys/arch/sparc64/conf

2020-10-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 30 06:44:38 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add pcagpio and pcf8574io - hardware status monitors on V210/V240 and E250.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/conf/GENERIC

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



CVS commit: src/sys/dev/i2c

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:55:51 UTC 2020

Modified Files:
src/sys/dev/i2c: files.i2c
Added Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Add a driver for the PCF8574 I/O expander, used as a GPIO in some sparc64
hardware.
The driver currently handles pins configured as LED or INDICATOR and adds
them to the LED and sysmon_envsys subsystems, respectively.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/dev/i2c/files.i2c
cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/pcf8574.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/dev/i2c/files.i2c
diff -u src/sys/dev/i2c/files.i2c:1.111 src/sys/dev/i2c/files.i2c:1.112
--- src/sys/dev/i2c/files.i2c:1.111	Fri Apr 24 12:38:31 2020
+++ src/sys/dev/i2c/files.i2c	Thu Oct 29 06:55:51 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i2c,v 1.111 2020/04/24 12:38:31 macallan Exp $
+#	$NetBSD: files.i2c,v 1.112 2020/10/29 06:55:51 jdc Exp $
 
 obsolete defflag	opt_i2cbus.h		I2C_SCAN
 define	i2cbus { }
@@ -395,3 +395,8 @@ file	dev/i2c/cwfg.ccwfg
 device	pcagpio: leds
 attach	pcagpio at iic
 file	dev/i2c/pcagpio.c			pcagpio
+
+# Philips PCF8574 IO expander
+device	pcf8574io: leds, sysmon_envsys
+attach	pcf8574io at iic
+file	dev/i2c/pcf8574.c			pcf8574io

Added files:

Index: src/sys/dev/i2c/pcf8574.c
diff -u /dev/null src/sys/dev/i2c/pcf8574.c:1.1
--- /dev/null	Thu Oct 29 06:55:51 2020
+++ src/sys/dev/i2c/pcf8574.c	Thu Oct 29 06:55:51 2020
@@ -0,0 +1,328 @@
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+/*
+ * A driver for Philips Semiconductor (NXP) PCF8574/PCF857A GPIO's.
+ * Uses device properties to connect pins to the appropriate subsystem.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.1 2020/10/29 06:55:51 jdc Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#ifdef PCF8574_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
+struct pcf8574_led {
+	void *cookie;
+	uint8_t mask, v_on, v_off;
+};
+
+#define PCF8574_NPINS	8
+struct pcf8574_softc {
+	device_t	sc_dev;
+	i2c_tag_t	sc_tag;
+	i2c_addr_t	sc_addr;
+	uint8_t		sc_state;
+	uint8_t		sc_mask;
+
+	int		sc_nleds;
+	struct pcf8574_led sc_leds[PCF8574_NPINS];
+
+	struct sysmon_envsys *sc_sme;
+	envsys_data_t	sc_sensor[PCF8574_NPINS];
+	int		sc_pin_sensor[PCF8574_NPINS];
+	int		sc_pin_active[PCF8574_NPINS];
+
+#ifdef PCF8574_DEBUG
+	callout_t	sc_timer;
+#endif
+};
+
+static int	pcf8574_match(device_t, cfdata_t, void *);
+static void	pcf8574_attach(device_t, device_t, void *);
+static int	pcf8574_detach(device_t, int);
+
+static int	pcf8574_read(struct pcf8574_softc *sc, uint8_t *val);
+static int	pcf8574_write(struct pcf8574_softc *sc, uint8_t val);
+static void	pcf8574_attach_led(
+			struct pcf8574_softc *, char *, int, int, int);
+void		pcf8574_refresh(struct sysmon_envsys *, envsys_data_t *);
+int		pcf8574_get_led(void *);
+void		pcf8574_set_led(void *, int);
+
+#ifdef PCF8574_DEBUG
+static void pcf8574_timeout(void *);
+#endif
+
+CFATTACH_DECL_NEW(pcf8574io, sizeof(struct pcf8574_softc),
+	pcf8574_match, pcf8574_attach, pcf8574_detach, NULL);
+
+static const struct device_compatible_entry compat_data[] = {
+	{ "i2c-pcf8574",		0 },
+	{ NULL,0 }
+};
+
+static int
+pcf8574_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct i2c_attach_args *ia = aux;
+	int match_result;
+
+	if (iic_use

CVS commit: src/sys/dev/i2c

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:55:51 UTC 2020

Modified Files:
src/sys/dev/i2c: files.i2c
Added Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Add a driver for the PCF8574 I/O expander, used as a GPIO in some sparc64
hardware.
The driver currently handles pins configured as LED or INDICATOR and adds
them to the LED and sysmon_envsys subsystems, respectively.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/dev/i2c/files.i2c
cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/pcf8574.c

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



CVS commit: src/sys/dev/i2c

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:50:53 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Handle the change in the sparc64 OFW patching, where we now encode the
GPIO pin type in the pin name (only LED types are currently handled).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcagpio.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/dev/i2c/pcagpio.c
diff -u src/sys/dev/i2c/pcagpio.c:1.4 src/sys/dev/i2c/pcagpio.c:1.5
--- src/sys/dev/i2c/pcagpio.c:1.4	Tue Oct 27 20:13:21 2020
+++ src/sys/dev/i2c/pcagpio.c	Thu Oct 29 06:50:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $ */
+/* $NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $");
 
 #include 
 #include 
@@ -184,7 +184,7 @@ pcagpio_attach(device_t parent, device_t
 	if (pins != NULL) {
 		int i, num, def;
 		char name[32];
-		const char *nptr;
+		const char *spptr, *nptr;
 		bool ok = TRUE, act;
 
 		for (i = 0; i < prop_array_count(pins); i++) {
@@ -192,16 +192,22 @@ pcagpio_attach(device_t parent, device_t
 			pin = prop_array_get(pins, i);
 			ok &= prop_dictionary_get_cstring_nocopy(pin, "name",
 			);
-			strncpy(name, nptr, 31);
 			ok &= prop_dictionary_get_uint32(pin, "pin", );
-			ok &= prop_dictionary_get_bool(
-			pin, "active_high", );
+			ok &= prop_dictionary_get_bool( pin, "active_high",
+			);
 			/* optional default state */
 			def = -1;
 			prop_dictionary_get_int32(pin, "default_state", );
-			if (ok) {		
+			if (!ok)
+continue;
+			/* Extract pin type from the name */
+			spptr = strstr(nptr, " ");
+			if (spptr == NULL)
+continue;
+			spptr += 1;
+			strncpy(name, spptr, 31);
+			if (!strncmp(nptr, "LED ", 4))
 pcagpio_attach_led(sc, name, num, act, def);
-			}
 		}
 	}
 }



CVS commit: src/sys/dev/i2c

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:50:53 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Handle the change in the sparc64 OFW patching, where we now encode the
GPIO pin type in the pin name (only LED types are currently handled).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcagpio.c

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



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:47:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.c ofw_patch.h

Log Message:
Add information about GPIO pin assignments and drive bays in the E250 and
v240.  Consolidate common code for v210/v240 and E250.
Modify the GPIO pin names to include a type (currently LED or INDICATOR)
which we can then handle in the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_patch.h

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



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:47:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.c ofw_patch.h

Log Message:
Add information about GPIO pin assignments and drive bays in the E250 and
v240.  Consolidate common code for v210/v240 and E250.
Modify the GPIO pin names to include a type (currently LED or INDICATOR)
which we can then handle in the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.226 src/sys/arch/sparc64/sparc64/autoconf.c:1.227
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.226	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1089,6 +1089,11 @@ device_register(device_t dev, void *aux)
 add_gpio_props_v210(dev, aux);
 			}
 		} 
+		if (device_is_a(dev, "pcf8574io")) {
+			if (!strcmp(machine_model, "SUNW,Ultra-250")) {
+add_gpio_props_e250(dev, aux);
+			}
+		} 
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1117,9 +1122,7 @@ device_register(device_t dev, void *aux)
 		0, periph->periph_lun);
 		if (device_is_a(busdev, "scsibus")) {
 			/* see if we're in a known SCA drivebay */
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
-add_drivebay_props_v210(dev, ofnode, aux);
-			}
+			add_drivebay_props(dev, ofnode, aux);
 		}
 		return;
 	} else if (device_is_a(dev, "wd")) {

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5	Sun Oct 25 07:46:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
 
 #include 
 
@@ -42,11 +42,10 @@ __KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,
 #include 
 
 static void
-add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
+add_gpio_pin(prop_array_t pins, const char *name, int num, int act, int def)
 {
 	prop_dictionary_t pin = prop_dictionary_create();
 	prop_dictionary_set_string(pin, "name", name);
-	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
 	prop_dictionary_set_uint32(pin, "pin", num);
 	prop_dictionary_set_bool(pin, "active_high", act);
 	if (def != -1)
@@ -62,7 +61,7 @@ create_i2c_dict(device_t busdev)
 	prop_array_t cfg = NULL;
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
- 	if (!cfg) {
+	if (!cfg) {
 		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
@@ -100,18 +99,89 @@ add_gpio_props_v210(device_t dev, void *
 	switch (ia->ia_addr) {
 		case 0x38:	/* front panel LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "indicator", 7, 0, -1);
-			add_gpio_LED(pins, "fault", 5, 0, 0);
-			add_gpio_LED(pins, "power", 4, 0, 1);
+			add_gpio_pin(pins, "LED indicator", 7, 0, -1);
+			add_gpio_pin(pins, "LED fault", 5, 0, 0);
+			add_gpio_pin(pins, "LED power", 4, 0, 1);
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x23:	/* drive bay LEDs */
+		case 0x23:	/* drive bay O/1 LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
-			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
-			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
-			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
+			add_gpio_pin(pins, "LED bay0_fault", 10, 0, 0);
+			add_gpio_pin(pins, "LED bay1_fault", 11, 0, 0);
+			add_gpio_pin(pins, "LED bay0_remove", 12, 0, 0);
+			add_gpio_pin(pins, "LED bay1_remove", 13, 0, 0);
+			prop_dictionary_set(dict, "pins", pins);
+			

CVS commit: src/sys/dev/i2c

2020-10-27 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Oct 27 20:13:21 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Add additional debugging output.
Track more chip state in the softc and check the chip state via a timer.
This allows us to easily observe changes caused by external events
(e.g. disk removal or PSU failure).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/pcagpio.c

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



CVS commit: src/sys/dev/i2c

2020-10-27 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Oct 27 20:13:21 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Add additional debugging output.
Track more chip state in the softc and check the chip state via a timer.
This allows us to easily observe changes caused by external events
(e.g. disk removal or PSU failure).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/pcagpio.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/dev/i2c/pcagpio.c
diff -u src/sys/dev/i2c/pcagpio.c:1.3 src/sys/dev/i2c/pcagpio.c:1.4
--- src/sys/dev/i2c/pcagpio.c:1.3	Sun Feb  2 06:43:14 2020
+++ src/sys/dev/i2c/pcagpio.c	Tue Oct 27 20:13:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcagpio.c,v 1.3 2020/02/02 06:43:14 macallan Exp $ */
+/* $NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,11 +31,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.3 2020/02/02 06:43:14 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $");
 
 #include 
 #include 
 #include 
+#ifdef PCAGPIO_DEBUG
+#include 
+#endif
 #include 
 #include 
 
@@ -56,6 +59,10 @@ __KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 
 
 static int	pcagpio_match(device_t, cfdata_t, void *);
 static void	pcagpio_attach(device_t, device_t, void *);
+static int	pcagpio_detach(device_t, int);
+#ifdef PCAGPIO_DEBUG
+static void	pcagpio_timeout(void *);
+#endif
 
 /* we can only pass one cookie to led_attach() but we need several values... */
 struct pcagpio_led {
@@ -72,6 +79,11 @@ struct pcagpio_softc {
 	uint32_t	sc_state;
 	struct pcagpio_led sc_leds[16];
 	int		sc_nleds;
+
+#ifdef PCAGPIO_DEBUG
+	uint32_t	sc_dir, sc_in;
+	callout_t	sc_timer;
+#endif
 };
 
 
@@ -83,7 +95,7 @@ static int	pcagpio_get(void *);
 static void	pcagpio_set(void *, int);
 
 CFATTACH_DECL_NEW(pcagpio, sizeof(struct pcagpio_softc),
-pcagpio_match, pcagpio_attach, NULL, NULL);
+pcagpio_match, pcagpio_attach, pcagpio_detach, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
 	{ "i2c-pca9555",	1 },
@@ -107,7 +119,7 @@ pcagpio_match(device_t parent, cfdata_t 
 
 #ifdef PCAGPIO_DEBUG
 static void
-printdir(uint32_t val, uint32_t mask, char letter)
+printdir(char* name, uint32_t val, uint32_t mask, char letter)
 {
 	char flags[17], bits[17];
 	uint32_t bit = 0x8000;
@@ -121,8 +133,8 @@ printdir(uint32_t val, uint32_t mask, ch
 	}
 	flags[16] = 0;
 	bits[16] = 0;
-	printf("dir: %s\n", flags);
-	printf("lvl: %s\n", bits);
+	printf("%s: dir: %s\n", name, flags);
+	printf("%s: lvl: %s\n", name, bits);
 }	
 #endif
 
@@ -151,16 +163,21 @@ pcagpio_attach(device_t parent, device_t
 	sc->sc_state = pcagpio_readreg(sc, PCAGPIO_OUTPUT);
 
 #ifdef PCAGPIO_DEBUG
-	uint32_t dir, in, out;
-	dir = pcagpio_readreg(sc, PCAGPIO_CONFIG);
-	in = pcagpio_readreg(sc, PCAGPIO_INPUT);
+	uint32_t in, out;
+	sc->sc_dir = pcagpio_readreg(sc, PCAGPIO_CONFIG);
+	sc->sc_in = pcagpio_readreg(sc, PCAGPIO_INPUT);
+	in = sc-> sc_in;
 	out = sc->sc_state;
 
-	out &= ~dir;
-	in &= dir;
+	out &= ~sc->sc_dir;
+	in &= sc->sc_dir;
 	
-	printdir(in, dir, 'I');
-	printdir(out, ~dir, 'O');
+	printdir(sc->sc_dev->dv_xname, in, sc->sc_dir, 'I');
+	printdir(sc->sc_dev->dv_xname, out, ~sc->sc_dir, 'O');
+
+	callout_init(>sc_timer, CALLOUT_MPSAFE);
+	callout_reset(>sc_timer, hz*20, pcagpio_timeout, sc);
+
 #endif
 
 	pins = prop_dictionary_get(dict, "pins");
@@ -189,6 +206,49 @@ pcagpio_attach(device_t parent, device_t
 	}
 }
 
+static int
+pcagpio_detach(device_t self, int flags)
+{
+#ifdef PCAGPIO_DEBUG
+	struct pcagpio_softc *sc = device_private(self);
+
+	callout_halt(>sc_timer, NULL);
+	callout_destroy(>sc_timer);
+#endif
+
+	return 0;
+}
+
+#ifdef PCAGPIO_DEBUG
+static void
+pcagpio_timeout(void *v)
+{
+	struct pcagpio_softc *sc = v;
+	uint32_t out, dir, in, o_out, o_in;
+
+	out = pcagpio_readreg(sc, PCAGPIO_OUTPUT);
+	dir = pcagpio_readreg(sc, PCAGPIO_CONFIG);
+	in = pcagpio_readreg(sc, PCAGPIO_INPUT);
+	if (out != sc->sc_state || dir != sc->sc_dir || in != sc->sc_in) {
+		aprint_normal_dev(sc->sc_dev, "status change\n");
+		o_out = sc->sc_state;
+		o_in = sc->sc_in;
+		o_out &= ~sc->sc_dir;
+		o_in &= sc->sc_dir;
+		printdir(sc->sc_dev->dv_xname, o_in, sc->sc_dir, 'I');
+		printdir(sc->sc_dev->dv_xname, o_out, ~sc->sc_dir, 'O');
+		sc->sc_state = out;
+		sc->sc_dir = dir;
+		sc->sc_in = in;
+		out &= ~sc->sc_dir;
+		in &= sc->sc_dir;
+		printdir(sc->sc_dev->dv_xname, in, sc->sc_dir, 'I');
+		printdir(sc->sc_dev->dv_xname, out, ~sc->sc_dir, 'O');
+	}
+	callout_reset(>sc_timer, hz*60, pcagpio_timeout, sc);
+}
+#endif
+
 static void
 pcagpio_writereg(struct pcagpio_softc *sc, int reg, uint32_t val)
 {



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-25 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 25 07:46:54 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Don't release the last reference to the "i2c-child-devices" dictionary in
the v210/v240 patches.
Fixes missing i2c devices there (pointed out by macallan@).
While here, add debug to show when we create the dictionary.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4	Sat Oct 24 13:47:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sun Oct 25 07:46:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
 
 #include 
 
@@ -63,6 +63,7 @@ create_i2c_dict(device_t busdev)
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
  	if (!cfg) {
+		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
 		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
@@ -171,8 +172,6 @@ add_env_sensors_v210(device_t busdev)
 	add_i2c_device(cfg, "hardware-monitor", "i2c-adm1026", 0x2e, 0);
 	/* LM75 at 0x4e */
 	add_i2c_device(cfg, "temperature-sensor", "i2c-lm75", 0x4e, 0);
-
-	prop_object_release(cfg);
 }
 
 /* Sensors and GPIO's for E450 and E250 */



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-25 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 25 07:46:54 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Don't release the last reference to the "i2c-child-devices" dictionary in
the v210/v240 patches.
Fixes missing i2c devices there (pointed out by macallan@).
While here, add debug to show when we create the dictionary.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c

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



Re: CVS commit: src/sys/arch/sparc64/dev

2020-10-24 Thread Julian Coleman
Hi Tobias,

> If you're interested there is an older version[1] of envctrl in the
> Attic that might be relevant to use for reference. It supported fan
> speed controls on E450. IIRC I got some of the magic constants from
> OpenSolaris. Sadly I don't own an E450 any more.
> 
> [1] 
> cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/arch/sparc64/dev/Attic/envctrl.c?rev=1.11=text/plain_with_tag=MAIN

Thank you - that's useful information!

Related to the magic offsets, I noticed that the value read from the sensor
was always lower than the value written.  However, it doesn't appear to be
a constant difference (I see about 15 for most values, but only 5 for the
minimum).  I think that it's OK to keep the higher value - it'll mean that
we run the fans slightly faster.  The CPU temperature on my E250 doesn't
reach the minimum threshold where the fan speed actually increases, so I
don't think that this will have any impact.

The GPIO values there helps to see what values I should be checking for too.

It would be good to merge this with the current code, but I only have an
E250 to test on, so I'll need to find a volunteer.

Regards,

Julian


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

2020-10-24 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 24 15:16:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Add support for automatically changing the CPU fan speed on the E250 in a
similar way to the SB1000/SB2000.
The fan control information was determined by experiment, as it's only
partially available in OFW.
Hardcode the missing information for E250 fan control into the driver
(it should be possible to support the E450 in future too).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/pcf8591_envctrl.c

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



  1   2   3   4   5   6   7   8   9   >