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/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/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: 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/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/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: 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: 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/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/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/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/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/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/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/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/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/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-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/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 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-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.

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/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/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: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/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.

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/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.

Modified files:

Index: src/sys/arch/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.9 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.9	Tue Jun 26 06:03:57 2018
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Oct 24 15:16:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.9 2018/06/26 06:03:57 thorpej Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,17 +19,25 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.9 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $");
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
+#include 
+
+#include 
 
 #include 
 #include 
 
+/* Translation tables contain 254 entries */
+#define XLATE_SIZE		256
+#define XLATE_MAX		(XLATE_SIZE - 2)
+
 #define PCF8591_CHANNELS	4
 
 #define PCF8591_CTRL_CH0	0x00
@@ -39,35 +47,48 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #define PCF8591_CTRL_AUTOINC	0x04
 #define PCF8591_CTRL_OSCILLATOR	0x40
 
+#define PCF8591_TEMP_SENS	0x00
+#define PCF8591_CPU_FAN_CTRL	0x01
+#define PCF8591_PS_FAN_CTRL	0x02
+
 struct ecadc_channel {
 	u_int		chan_num;
+	u_int		chan_type;
 	envsys_data_t	chan_sensor;
 	u_char		*chan_xlate;
 	int64_t		chan_factor;
 	int64_t		chan_min;
 	int64_t		chan_warn;
 	int64_t		chan_crit;
+	u_int8_t	chan_speed;
 };
 
 struct ecadc_softc {
 	device_t		sc_dev;
 	i2c_tag_t		sc_tag;
 	i2c_addr_t		sc_addr;
-	u_char			sc_ps_xlate[256];
-	u_char			sc_cpu_xlate[256];
+	u_char			sc_ps_xlate[XLATE_SIZE];
+	u_char			sc_cpu_xlate[XLATE_SIZE];
+	u_char			sc_cpu_fan_spd[XLATE_SIZE];
 	u_int			sc_nchan;
 	struct ecadc_channel	sc_channels[PCF8591_CHANNELS];
 	struct sysmon_envsys	*sc_sme;
+	int			sc_hastimer;
+	callout_t		sc_timer;
 };
 
 static int	ecadc_match(device_t, cfdata_t, void *);
 static void	ecadc_attach(device_t, device_t, void *);
+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 *, uint32_t *);
-
-CFATTACH_DECL_NEW(ecadc, sizeof(struct ecadc_softc),
-	ecadc_match, ecadc_attach, NULL, NULL);
+			sysmon_envsys_lim_t *, u_int32_t *);
+static void	ecadc_timeout(void *);
+static void	ecadc_fan_adjust(void *);
+
+CFATTACH_DECL3_NEW(ecadc, sizeof(struct ecadc_softc),
+	ecadc_match, ecadc_attach, ecadc_detach, NULL, NULL, NULL,
+	DVF_DETACH_SHUTDOWN);
 
 static const struct device_compatible_entry compat_data[] = {
 	{ "ecadc",		0 },
@@ -102,6 +123,9 @@ ecadc_attach(device_t parent, device_t s
 	u_int i;
 
 	sc->sc_dev = self;
+	sc->sc_nchan = 0;
+	sc->sc_hastimer = 0;
+
 	if ((len = OF_getprop(node, "thermisters", term,
 	sizeof(term))) < 0) {
 		aprint_error(": couldn't find \"thermisters\" property\n");
@@ -109,15 +133,14 @@ ecadc_attach(device_t parent, device_t s
 	}
 
 	if (OF_getprop(node, "cpu-temp-factors", >sc_cpu_xlate[2],
-	sizeof(sc->sc_cpu_xlate) - 2) < 0) {
+	XLATE_MAX) < 0) {
 		aprint_error(": couldn't find \"cpu-temp-factors\" property\n");
 		return;
 	}
 	sc->sc_cpu_xlate[0] = sc->sc_cpu_xlate[1] = sc->sc_cpu_xlate[2];
 
 	/* Only the Sun Enterprise 450 has these. */
-	OF_getprop(node, "ps-temp-factors", >sc_ps_xlate[2],
-	sizeof(sc->sc_ps_xlate) - 2);
+	OF_getprop(node, "ps-temp-factors", >sc_ps_xlate[2], XLATE_MAX);
 	sc->sc_ps_xlate[0] = sc->sc_ps_xlate[1] = sc->sc_ps_xlate[2];
 
 	cp = term;
@@ -139,6 +162,7 @@ ecadc_attach(device_t parent, device_t s
 			num = den = 1;
 
 		sc->sc_channels[sc->sc_nchan].chan_num = chan;
+		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_TEMP_SENS;
 
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_STEMP;
@@ -164,6 +188,27 @@ ecadc_attach(device_t parent, device_t s
 		sc->sc_nchan++;
 	}
 
+	/*
+	 * Fan speed changing information is missing from OFW
+	 * The E250 CPU fan is connected to the sensor at addr 0x4a, channel 1
+	 */
+	if (ia->ia_addr == 0x4a && !strcmp(machine_model, "SUNW,Ultra-250") &&
+	OF_getprop(node, "cpu-fan-speeds", >sc_cpu_fan_spd,
+	

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

2020-10-24 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 24 13:47:53 UTC 2020

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

Log Message:
Add E250 i2c devices missing from the OFW tree.
Normalise the spelling of "temperature".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3	Fri Oct 23 17:53:07 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sat Oct 24 13:47:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47: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.3 2020/10/23 17:53:07 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
 
 #include 
 
@@ -187,13 +187,13 @@ add_i2c_props_e450(device_t busdev, uint
 	/* Power supply 1 temperature. */
 	add_i2c_device(cfg, "PSU-1", "ecadc", 0x48, node);
 
-	/* Power supply 2 termperature. */
+	/* Power supply 2 temperature. */
 	add_i2c_device(cfg, "PSU-2", "ecadc", 0x49, node);
 
-	/* Power supply 3 tempterature. */
+	/* Power supply 3 temperature. */
 	add_i2c_device(cfg, "PSU-3", "ecadc", 0x4a, node);
 
-	/* Ambient tempterature. */
+	/* Ambient temperature. */
 	add_i2c_device(cfg, "ambient", "i2c-lm75", 0x4d, node);
 
 	/* CPU temperatures. */
@@ -206,15 +206,29 @@ void
 add_i2c_props_e250(device_t busdev, uint64_t node)
 {
 	prop_array_t cfg;
+	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
 	cfg = create_i2c_dict(busdev);
 
 	/* PSU temperature / CPU fan */
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
+
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
 
+	/* GPIO's */
+	for (i = 0x38; i <= 0x39; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+	for (i = 0x3d; i <= 0x3f; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+
+	/* NVRAM */
+	add_i2c_device(cfg, "nvram", "i2c-at24c02", 0x52, node);
+
+	/* RSC clock */
+	add_i2c_device(cfg, "rscrtc", "i2c-ds1307", 0x68, node);
+
 	prop_object_release(cfg);
 }
 



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

2020-10-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 23 17:53:07 UTC 2020

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

Log Message:
Add missing prop_object_release() to the E250/E450 patches.
Use the recently added (in r1.2) functions for SPARCle i2c devices too.
Simplify adding "compatible" entries and handle cases where there is none.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.2	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Fri Oct 23 17:53:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.2 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 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.2 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $");
 
 #include 
 
@@ -75,15 +75,14 @@ add_i2c_device(prop_array_t cfg, const c
 uint32_t addr, uint64_t node)
 {
 	prop_dictionary_t dev;
-	prop_data_t data;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding i2c device: %s (%s) @ 0x%x (%lx)\n",
-	name, compat, addr, node & 0x));
+	name, compat == NULL ? "NULL" : compat, addr, node & 0x));
 	dev = prop_dictionary_create();
 	prop_dictionary_set_string(dev, "name", name);
-	data = prop_data_create_copy(compat, strlen(compat) + 1);
-	prop_dictionary_set(dev, "compatible", data);
-	prop_object_release(data);
+	if (compat != NULL)
+		prop_dictionary_set_data(dev, "compatible", compat,
+		strlen(compat) + 1);
 	prop_dictionary_set_uint32(dev, "addr", addr);
 	prop_dictionary_set_uint64(dev, "cookie", node);
 	prop_array_add(cfg, dev);
@@ -146,20 +145,14 @@ add_drivebay_props_v210(device_t dev, in
 void
 add_spdmem_props_sparcle(device_t busdev)
 {
-	prop_dictionary_t props = device_properties(busdev);
-	prop_array_t cfg = prop_array_create();
+	prop_array_t cfg;
 	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
-	for (i = 0x50; i <= 0x51; i++) {
-		prop_dictionary_t spd = prop_dictionary_create();
-		prop_dictionary_set_string(spd, "name", "dimm-spd");
-		prop_dictionary_set_uint32(spd, "addr", i);
-		prop_dictionary_set_uint64(spd, "cookie", 0);
-		prop_array_add(cfg, spd);
-		prop_object_release(spd);
-	}
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
+
+	cfg = create_i2c_dict(busdev);
+	for (i = 0x50; i <= 0x51; i++)
+		add_i2c_device(cfg, "dimm-spd", NULL, i, 0);
 	prop_object_release(cfg);
 }
 
@@ -205,6 +198,8 @@ add_i2c_props_e450(device_t busdev, uint
 
 	/* CPU temperatures. */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 void
@@ -219,6 +214,8 @@ add_i2c_props_e250(device_t busdev, uint
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 /* Hardware specific device properties */



CVS commit: src/sys/arch/sparc64

2020-10-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 23 15:18:10 UTC 2020

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

Log Message:
Move E250 and E450 i2c patches from dev/pcfiic_ebus.c to sparc64/ofw_patch.c.
They are now co-located with the other OFW patch routines.
New i2c devices are created for E250/E450 and v210/v240, so create new
functions to avoid duplicate code.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/pcfiic_ebus.c
cvs rdiff -u -r1.225 -r1.226 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.2 -r1.3 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/dev/pcfiic_ebus.c
diff -u src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.6 src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.7
--- src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.6	Fri Jun 12 03:41:57 2020
+++ src/sys/arch/sparc64/dev/pcfiic_ebus.c	Fri Oct 23 15:18:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $	*/
+/*	$NetBSD: pcfiic_ebus.c,v 1.7 2020/10/23 15:18:10 jdc Exp $	*/
 /*	$OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7 2020/10/23 15:18:10 jdc Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -57,11 +57,6 @@ struct pcfiic_ebus_softc {
 CFATTACH_DECL_NEW(pcfiic, sizeof(struct pcfiic_ebus_softc),
 	pcfiic_ebus_match, pcfiic_ebus_attach, NULL, NULL);
 
-static prop_array_t create_dict(device_t);
-static void add_prop(prop_array_t, const char *, const char *, u_int, int);
-static void envctrl_props(prop_array_t, int);
-static void envctrltwo_props(prop_array_t, int);
-
 int
 pcfiic_ebus_match(device_t parent, struct cfdata *match, void *aux)
 {
@@ -103,6 +98,11 @@ pcfiic_ebus_attach(device_t parent, devi
 		return;
 	}
 
+	/* E450 and E250 have a different clock */
+	if ((strcmp(ea->ea_name, "SUNW,envctrl") == 0) ||
+	(strcmp(ea->ea_name, "SUNW,envctrltwo") == 0))
+		clock = PCF8584_CLK_12 | PCF8584_SCL_45;
+
 	sc->sc_dev = self;
 	if (OF_getprop(ea->ea_node, "compatible", compat, sizeof(compat)) > 0 &&
 	strcmp(compat, "SUNW,bbc-i2c") == 0) {
@@ -160,65 +160,5 @@ pcfiic_ebus_attach(device_t parent, devi
 	if (esc->esc_ih == NULL)
 		sc->sc_poll = 1;
 
-	if (strcmp(ea->ea_name, "SUNW,envctrl") == 0) {
-		envctrl_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
-	} else if (strcmp(ea->ea_name, "SUNW,envctrltwo") == 0) {
-		envctrltwo_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
-	} else
-		pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), clock, swapregs);
-}
-
-static prop_array_t
-create_dict(device_t parent)
-{
-	prop_dictionary_t props = device_properties(parent);
-	prop_array_t cfg = prop_dictionary_get(props, "i2c-child-devices");
-	if (cfg) return cfg;
-	cfg = prop_array_create();
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
-	prop_object_release(cfg);
-	return cfg;
-}
-
-static void
-add_prop(prop_array_t c, const char *name, const char *compat, u_int addr,
-	int node)
-{
-	prop_dictionary_t dev;
-
-	dev = prop_dictionary_create();
-	prop_dictionary_set_string(dev, "name", name);
-	prop_dictionary_set_data(dev, "compatible", compat, strlen(compat)+1);
-	prop_dictionary_set_uint32(dev, "addr", addr);
-	prop_dictionary_set_uint64(dev, "cookie", node);
-	prop_array_add(c, dev);
-	prop_object_release(dev);
-}
-
-static void
-envctrl_props(prop_array_t c, int node)
-{
-	/* Power supply 1 temperature. */
-	add_prop(c, "PSU-1", "ecadc", 0x48, node);
-
-	/* Power supply 2 termperature. */
-	add_prop(c, "PSU-2", "ecadc", 0x49, node);
-
-	/* Power supply 3 tempterature. */
-	add_prop(c, "PSU-3", "ecadc", 0x4a, node);
-
-	/* Ambient tempterature. */
-	add_prop(c, "ambient", "i2c-lm75", 0x4d, node);
-
-	/* CPU temperatures. */
-	add_prop(c, "CPU", "ecadc", 0x4f, node);
-}
-
-static void
-envctrltwo_props(prop_array_t c, int node)
-{
-	add_prop(c, "PSU", "ecadc", 0x4a, node);
-	add_prop(c, "CPU", "ecadc", 0x4f, node);
+	pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), clock, swapregs);
 }

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.225 src/sys/arch/sparc64/sparc64/autoconf.c:1.226
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.225	Sat Oct 17 08:10:31 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Fri Oct 23 15:18:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp 

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

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

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

Log Message:
Avoid declaring autoconf_debug twice when building with DEBUG.
Pointed out by palle@ - thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.1 -r1.2 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.224 src/sys/arch/sparc64/sparc64/autoconf.c:1.225
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.224	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -116,6 +116,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include "ksyms.h"
 
+int autoconf_debug = 0x0;
+
 struct evcnt intr_evcnts[] = {
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "spur"),
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev1"),

Index: src/sys/arch/sparc64/sparc64/ofw_patch.h
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1 src/sys/arch/sparc64/sparc64/ofw_patch.h:1.2
--- src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.h	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.h,v 1.1 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: ofw_patch.h,v 1.2 2020/10/17 08:10:31 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #define ACDB_BOOTDEV0x1
 #define ACDB_PROBE  0x2
 #define ACDB_BOOTARGS   0x4
-int autoconf_debug = 0x0;
+extern int autoconf_debug;
 #define DPRINTF(l, s)   do { if (autoconf_debug & l) printf s; } while (0)
 #else
 #define DPRINTF(l, s)



CVS commit: src/sys/arch/sparc64

2020-10-16 Thread Julian Coleman
{
-	struct scsipibus_attach_args *sa = aux;
-	int target = sa->sa_periph->periph_target;
-	char path[256]= "";
-
-	OF_package_to_path(ofnode, path, sizeof(path));
-
-	/* see if we're on the onboard controller's 1st channel */
-	if (strcmp(path, "/pci@1c,60/scsi@2") != 0)
-		return;
-	/* yes, yes we are */
-	if ( target < 2) {
-		prop_dictionary_t dict = device_properties(dev);
-		char name[16];
-
-		snprintf(name, sizeof(name), "bay%d", target);		
-		prop_dictionary_set_string(dict, "location", name);
-	}
-}
-
-/*
- * Add SPARCle spdmem devices (0x50 and 0x51) that are not in the OFW tree
- */
-static void
-add_spdmem_props_sparcle(device_t busdev)
-{
-	prop_dictionary_t props = device_properties(busdev);
-	prop_array_t cfg = prop_array_create();
-	int i;
-
-	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
-	for (i = 0x50; i <= 0x51; i++) {
-		prop_dictionary_t spd = prop_dictionary_create();
-		prop_dictionary_set_string(spd, "name", "dimm-spd");
-		prop_dictionary_set_uint32(spd, "addr", i);
-		prop_dictionary_set_uint64(spd, "cookie", 0);
-		prop_array_add(cfg, spd);
-		prop_object_release(spd);
-	}
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
-	prop_object_release(cfg);
-}
-
-/*
- * Add V210/V240 environmental sensors that are not in the OFW tree.
- */
-static void
-add_env_sensors_v210(device_t busdev)
-{
-	prop_dictionary_t props = device_properties(busdev);
-	prop_array_t cfg = NULL;
-	prop_dictionary_t sens;
-	prop_data_t data;
-	const char name_lm[] = "i2c-lm75";
-	const char name_adm[] = "i2c-adm1026";
-
-	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
-	cfg = prop_dictionary_get(props, "i2c-child-devices");
- 	if (!cfg) {
-		cfg = prop_array_create();
-		prop_dictionary_set(props, "i2c-child-devices", cfg);
-		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
-	}
-
-	/* ADM1026 at 0x2e */
-	sens = prop_dictionary_create();
-	prop_dictionary_set_uint32(sens, "addr", 0x2e);
-	prop_dictionary_set_uint64(sens, "cookie", 0);
-	prop_dictionary_set_string(sens, "name", "hardware-monitor");
-	data = prop_data_create_copy(_adm[0], sizeof(name_adm));
-	prop_dictionary_set(sens, "compatible", data);
-	prop_object_release(data);
-	prop_array_add(cfg, sens);
-	prop_object_release(sens);
-
-	/* LM75 at 0x4e */
-	sens = prop_dictionary_create();
-	prop_dictionary_set_uint32(sens, "addr", 0x4e);
-	prop_dictionary_set_uint64(sens, "cookie", 0);
-	prop_dictionary_set_string(sens, "name", "temperature-sensor");
-	data = prop_data_create_copy(_lm[0], sizeof(name_lm));
-	prop_dictionary_set(sens, "compatible", data);
-	prop_object_release(data);
-	prop_array_add(cfg, sens);
-	prop_object_release(sens);
-}
-
-/* Hardware specific device properties */
-static void
-set_hw_props(device_t dev)
-{
-	device_t busdev = device_parent(dev);
-
-	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
-	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
-		device_t busparent = device_parent(busdev);
-		prop_dictionary_t props = device_properties(dev);
-
-		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
-		device_is_a(dev, "adm1026hm") && props != NULL) {
-			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
-			prop_dictionary_set_bool(props, "multi_read", true);
-		}
-	}
-
-	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
-		device_t busparent = device_parent(busdev);
-		prop_dictionary_t props = device_properties(dev);
-		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
-		device_is_a(dev, "adm1026hm") && props != NULL) {
-			prop_dictionary_set_bool(props, "multi_read", true);
-		}
-	}
-}
-
-/* Static EDID definitions */
-static void
-set_static_edid(prop_dictionary_t dict)
-{
-	if (!strcmp(machine_model, "NATE,Meso-999")) {
-		prop_data_t edid;
-
-		DPRINTF(ACDB_PROBE, ("\nAdding EDID for Meso-999 "));
-		edid = prop_data_create_copy(edid_meso999,
-		sizeof(edid_meso999));
-		prop_dictionary_set(dict, "EDID:1", edid);
-		prop_object_release(edid);
-	}
-}
-
 /*
  * Called back during autoconfiguration for each device found
  */

Added files:

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u /dev/null src/sys/arch/sparc64/sparc64/ofw_patch.c:1.1
--- /dev/null	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Fri Oct 16 07:35:16 2020
@@ -0,0 +1,216 @@
+/*	$NetBSD: ofw_patch.c,v 1.1 2020/10/16 07:35:16 jdc Exp $ */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The Ne

CVS commit: src/sys/dev/pci

2020-10-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 11 21:41:57 UTC 2020

Modified Files:
src/sys/dev/pci: radeonfb.c

Log Message:
Handle EDID:N entries, where N is the port number, so that we can set up
the display on port1 when port0 has no EDID information.
Try harder not to return NULL from radeonfb_modelookup() because we use
the result without checking later.
While here, adjust RADEONFB_DEBUG output:
  don't print RADEON_PIXCLKS_CNTL (fixes a crash on sparc64 because it's
  not aligned)
  don't ignore the bottom 200 lines of the display (for no apparent reason))


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/pci/radeonfb.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/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.110 src/sys/dev/pci/radeonfb.c:1.111
--- src/sys/dev/pci/radeonfb.c:1.110	Mon Sep 28 05:43:58 2020
+++ src/sys/dev/pci/radeonfb.c	Sun Oct 11 21:41:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.110 2020/09/28 05:43:58 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.111 2020/10/11 21:41:57 jdc Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.110 2020/09/28 05:43:58 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.111 2020/10/11 21:41:57 jdc Exp $");
 
 #include 
 #include 
@@ -590,7 +590,10 @@ radeonfb_attach(device_t parent, device_
 	PRINTREG(RADEON_LVDS_GEN_CNTL);
 	PRINTREG(RADEON_DISP_HW_DEBUG);
 	if (!IS_AVIVO(sc)) {
+		/*
+		XXX: We can't print this, as it's not correctly aligned
 		PRINTREG(RADEON_PIXCLKS_CNTL);
+		*/
 		PRINTREG(RADEON_CRTC_H_SYNC_STRT_WID);
 		PRINTREG(RADEON_FP_H_SYNC_STRT_WID);
 		PRINTREG(RADEON_CRTC2_H_SYNC_STRT_WID);
@@ -927,10 +930,6 @@ radeonfb_attach(device_t parent, device_
 
 		dp->rd_vd.init_screen = radeonfb_init_screen;
 
-#ifdef RADEONFB_DEBUG
-		dp->rd_virty -= 200;
-#endif
-
 		dp->rd_console = 0;
 		prop_dictionary_get_bool(device_properties(sc->sc_dev),
 		"is_console", >rd_console);
@@ -1068,7 +1067,10 @@ radeonfb_attach(device_t parent, device_
 		PRINTREG(RADEON_TMDS_CNTL);
 		PRINTREG(RADEON_TMDS_TRANSMITTER_CNTL);
 		PRINTREG(RADEON_TMDS_PLL_CNTL);
+		/*
+		XXX: We can't print this, as it's not correctly aligned
 		PRINTREG(RADEON_PIXCLKS_CNTL);
+		*/
 	}
 	return;
 
@@ -1968,7 +1970,7 @@ nobios:
 	}
 
 	for (i = 0; i < 2; i++) {
-		char	edid[128];
+		char	edid[128], edid_port_str[7] = "EDID:";
 		uint8_t	ddc;
 		struct edid_info *eip = >sc_ports[i].rp_edid;
 		prop_data_t edid_data;
@@ -1981,10 +1983,17 @@ nobios:
 		DPRINTF(("   crtc = %d\n", sc->sc_ports[i].rp_number));
 
 		sc->sc_ports[i].rp_edid_valid = 0;
-		/* first look for static EDID data */
-		if ((edid_data = prop_dictionary_get(device_properties(
-		  sc->sc_dev), "EDID")) != NULL) {
-
+		/*
+		 * First look for static EDID data
+		 * Try "EDID:port" then "EDID"
+		 */
+		snprintf(_port_str[5], 2, "%d", i);
+		edid_data = prop_dictionary_get(device_properties(
+		sc->sc_dev), edid_port_str);
+		if (edid_data == NULL)
+			edid_data = prop_dictionary_get(device_properties(
+			  sc->sc_dev), "EDID");
+		if (edid_data != NULL) {
 			aprint_debug_dev(sc->sc_dev, "using static EDID\n");
 			memcpy(edid, prop_data_value(edid_data), 128);
 			if (edid_parse(edid, eip) == 0) {
@@ -2078,12 +2087,17 @@ const struct videomode *
 radeonfb_modelookup(const char *name)
 {
 	int	i;
+	/* Use a default mode in case we don't find a matching mode */
+	const char *vm = "1024x768x60";
+	const struct videomode *vmp = NULL;
 
 	for (i = 0; i < videomode_count; i++) {
 		if (!strcmp(name, videomode_list[i].name))
 			return _list[i];
+		if (!strcmp(vm, videomode_list[i].name))
+			vmp = _list[i];
 	}
-	return NULL;
+	return vmp;
 }
 
 void



CVS commit: src/sys/arch/sparc64

2020-10-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 11 19:39:23 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
src/sys/arch/sparc64/sparc64: autoconf.c
Added Files:
src/sys/arch/sparc64/sparc64: static_edid.c static_edid.h

Log Message:
Add a static EDID entry for the Mesostation-999.
Use the same logic as macppc for adding the entry.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r1.222 -r1.223 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/sparc64/static_edid.c \
src/sys/arch/sparc64/sparc64/static_edid.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/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.159 src/sys/arch/sparc64/conf/files.sparc64:1.160
--- src/sys/arch/sparc64/conf/files.sparc64:1.159	Mon May 11 15:56:15 2020
+++ src/sys/arch/sparc64/conf/files.sparc64	Sun Oct 11 19:39:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.159 2020/05/11 15:56:15 jdc Exp $
+#	$NetBSD: files.sparc64,v 1.160 2020/10/11 19:39:22 jdc Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -257,6 +257,7 @@ file	arch/sparc64/sparc64/kobj_machdep.c
 file	arch/sparc64/sparc64/machdep.c
 file	arch/sparc64/sparc64/process_machdep.c
 file	arch/sparc64/sparc64/procfs_machdep.c	procfs
+file	arch/sparc64/sparc64/static_edid.c
 file	arch/sparc/sparc/openprom.c
 file	arch/sparc/sparc/openfirm.c
 file	arch/sparc64/sparc64/ofw_machdep.c

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.222 src/sys/arch/sparc64/sparc64/autoconf.c:1.223
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.222	Thu Jul 23 16:08:02 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Oct 11 19:39:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1205,6 +1206,21 @@ set_hw_props(device_t dev)
 	}
 }
 
+/* Static EDID definitions */
+static void
+set_static_edid(prop_dictionary_t dict)
+{
+	if (!strcmp(machine_model, "NATE,Meso-999")) {
+		prop_data_t edid;
+
+		DPRINTF(ACDB_PROBE, ("\nAdding EDID for Meso-999 "));
+		edid = prop_data_create_copy(edid_meso999,
+		sizeof(edid_meso999));
+		prop_dictionary_set(dict, "EDID:1", edid);
+		prop_object_release(edid);
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1508,7 +1524,10 @@ noether:
 			if (OF_getprop(node, "width", , sizeof(width))
 			!= 4) {
 instance = OF_open(name);
+			}
+		}
 #endif
+		set_static_edid(dict);
 	}
 
 	set_hw_props(dev);

Added files:

Index: src/sys/arch/sparc64/sparc64/static_edid.c
diff -u /dev/null src/sys/arch/sparc64/sparc64/static_edid.c:1.1
--- /dev/null	Sun Oct 11 19:39:23 2020
+++ src/sys/arch/sparc64/sparc64/static_edid.c	Sun Oct 11 19:39:22 2020
@@ -0,0 +1,58 @@
+/*	$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $ */
+
+/*-
+ * 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 LIABILI

CVS commit: src/sys/dev/pci

2020-10-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 10 08:29:32 UTC 2020

Modified Files:
src/sys/dev/pci: machfb.c

Log Message:
Don't change a videomode that's been setup in the firmware.
Extend the register debugging output (and hopefully make it easier to read).


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/pci/machfb.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/pci/machfb.c
diff -u src/sys/dev/pci/machfb.c:1.102 src/sys/dev/pci/machfb.c:1.103
--- src/sys/dev/pci/machfb.c:1.102	Fri Aug  7 23:31:07 2020
+++ src/sys/dev/pci/machfb.c	Sat Oct 10 08:29:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machfb.c,v 1.102 2020/08/07 23:31:07 macallan Exp $	*/
+/*	$NetBSD: machfb.c,v 1.103 2020/10/10 08:29:32 jdc Exp $	*/
 
 /*
  * Copyright (c) 2002 Bang Jun-Young
@@ -34,7 +34,7 @@
 
 #include 
 __KERNEL_RCSID(0,
-	"$NetBSD: machfb.c,v 1.102 2020/08/07 23:31:07 macallan Exp $");
+	"$NetBSD: machfb.c,v 1.103 2020/10/10 08:29:32 jdc Exp $");
 
 #include 
 #include 
@@ -233,6 +233,7 @@ static int	mach64_ref_freq(void);
 
 #ifdef MACHFB_DEBUG
 static void	mach64_get_mode(struct mach64_softc *, struct videomode *);
+static void	mach64_print_reg(struct mach64_softc *);
 #endif
 
 static int	mach64_calc_crtcregs(struct mach64_softc *,
@@ -413,6 +414,7 @@ mach64_attach(device_t parent, device_t 
 	struct mach64_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
 	struct rasops_info *ri;
+	const char *mptr = NULL;
 	prop_data_t edid_data;
 	const struct videomode *mode = NULL;
 	int bar, id, expected_id;
@@ -509,6 +511,7 @@ mach64_attach(device_t parent, device_t 
 	(int)sc->sc_rom.vb_size >> 10, (uint32_t)sc->sc_rom.vb_base);
 #ifdef MACHFB_DEBUG
 	mach64_get_mode(sc, NULL);
+	mach64_print_reg(sc);
 #endif
 
 	prop_dictionary_get_uint32(device_properties(self), "width", );
@@ -517,8 +520,12 @@ mach64_attach(device_t parent, device_t 
 	default_mode.hdisplay = width;
 	default_mode.vdisplay = height;
 
+	prop_dictionary_get_cstring_nocopy(device_properties(sc->sc_dev),
+	"videomode", );
+
 	memset(>sc_ei, 0, sizeof(sc->sc_ei));
-	if ((edid_data = prop_dictionary_get(device_properties(self), "EDID"))
+	if (mptr == NULL &&
+	(edid_data = prop_dictionary_get(device_properties(self), "EDID"))
 	!= NULL) {
 
 		sc->sc_edid_size = uimin(1024, prop_data_size(edid_data));
@@ -923,8 +930,8 @@ mach64_get_mode(struct mach64_softc *sc,
 {
 	int htotal, hdisplay, hsync_start, hsync_end;
 	int vtotal, vdisplay, vsync_start, vsync_end;
-	int gen_ctl, clk_ctl, clock;
-	int ref_freq, ref_div, mclk_fb_div, vclk_post_div, vclk_fb_div;
+	int clk_ctl, clock;
+	int ref_freq, ref_div, vclk_post_div, vclk_fb_div;
 	int nhsync, nvsync;
 	int post_div, dot_clock, vrefresh, vrefresh2;
 
@@ -932,27 +939,13 @@ mach64_get_mode(struct mach64_softc *sc,
 	hsync_end = regr(sc, CRTC_H_SYNC_STRT_WID);
 	vdisplay = regr(sc, CRTC_V_TOTAL_DISP);
 	vsync_end = regr(sc, CRTC_V_SYNC_STRT_WID);
-	gen_ctl = regr(sc, CRTC_GEN_CNTL);
 	clk_ctl = regr(sc, CLOCK_CNTL);
 	clock = clk_ctl & 3;
 	ref_div = regrb_pll(sc, PLL_REF_DIV);
-	mclk_fb_div = regrb_pll(sc, MCLK_FB_DIV);
 	vclk_post_div = regrb_pll(sc, VCLK_POST_DIV);
 	vclk_fb_div = regrb_pll(sc, VCLK0_FB_DIV + clock);
 	ref_freq = mach64_ref_freq();
 
-	aprint_normal_dev(sc->sc_dev, "CRTC registers:\n");
-	aprint_normal("\th total: 0x%08x  h sync: 0x%08x\n",
-	hdisplay, hsync_end);
-	aprint_normal("\tv total: 0x%08x  v sync: 0x%08x\n",
-	vdisplay, vsync_end);
-	aprint_normal("\t g cntl: 0x%08x  c cntl: 0x%08x\n",
-	gen_ctl, clk_ctl);
-	aprint_normal("\t rfreq %d  rdiv: %d\n", ref_freq, ref_div);
-	aprint_normal_dev(sc->sc_dev, "PLL registers:\n");
-	aprint_normal("\t m div: 0x%02x  p div: 0x%02x  v%d div: 0x%02x\n",
-	mclk_fb_div, vclk_post_div, clock, vclk_fb_div);
-
 	htotal = ((hdisplay & 0x01ff) + 1) << 3;
 	hdisplay = (((hdisplay & 0x1ff) >> 16) + 1) << 3;
 	if (hsync_end & CRTC_HSYNC_NEG)
@@ -1015,6 +1008,55 @@ mach64_get_mode(struct mach64_softc *sc,
 			mode->flags |= VID_NVSYNC;
 	}
 }
+
+static void
+mach64_print_reg(struct mach64_softc *sc)
+{
+	struct reglist {
+		int offset;
+		const char *name;
+	};
+	static const struct reglist reglist_tab[] = {
+		{ 0x, "CRTC_H_TOTAL_DISP" },
+		{ 0x0004, "CRTC_H_SYNC_STRT_WID" },
+		{ 0x0008, "CRTC_V_TOTAL_DISP" },
+		{ 0x000C, "CRTC_V_SYNC_STRT_WID" },
+		{ 0x0010, "CRTC_VLINE_CRNT_VLINE" },
+		{ 0x0014, "CRTC_OFF_PITCH" },
+		{ 0x001C, "CRTC_GEN_CNTL" },
+		{ 0x0090, "CLOCK_CNTL" },
+		{ 0, NULL }
+	};
+	static const struct reglist plllist_tab[] = {
+		{ 0x02, "PLL_REF_DIV" },
+		{ 0x03, "PLL_GEN_CNTL" },
+		{ 0x04, "MCLK_FB_DIV" },
+		{ 0x05, "PLL_VCLK_CNTL" },
+		{ 0x06, "VCLK_POST_DIV" },
+		{ 0x07, "VCLK0_FB_DIV" },
+		{ 0x08, "VCLK1_FB_DIV" },
+		{ 0x09, "VCLK2_FB_DIV" },
+		{ 0x0A, "VCLK3_FB_DIV" },
+		{ 0x0B, "PLL_XCLK_CNTL" },
+		{ 0x10, 

CVS commit: src/sys/dev/pci

2020-08-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Aug  7 18:26:33 UTC 2020

Modified Files:
src/sys/dev/pci: machfb.c

Log Message:
Also set the bits for horizontal sync start delay.  This makes machfb work
correctly for some modes (e.g. 1152x720).
Modify mach64_get_mode() to get the mode from the chip registers (only used
with debug on).
Whilst here tidy up some other debug output.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/pci/machfb.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/pci/machfb.c
diff -u src/sys/dev/pci/machfb.c:1.100 src/sys/dev/pci/machfb.c:1.101
--- src/sys/dev/pci/machfb.c:1.100	Thu Jul 30 21:29:20 2020
+++ src/sys/dev/pci/machfb.c	Fri Aug  7 18:26:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: machfb.c,v 1.100 2020/07/30 21:29:20 macallan Exp $	*/
+/*	$NetBSD: machfb.c,v 1.101 2020/08/07 18:26:33 jdc Exp $	*/
 
 /*
  * Copyright (c) 2002 Bang Jun-Young
@@ -34,7 +34,7 @@
 
 #include 
 __KERNEL_RCSID(0,
-	"$NetBSD: machfb.c,v 1.100 2020/07/30 21:29:20 macallan Exp $");
+	"$NetBSD: machfb.c,v 1.101 2020/08/07 18:26:33 jdc Exp $");
 
 #include 
 #include 
@@ -228,8 +228,9 @@ CFATTACH_DECL_NEW(machfb, sizeof(struct 
 static void	mach64_init(struct mach64_softc *);
 static int	mach64_get_memsize(struct mach64_softc *);
 static int	mach64_get_max_ramdac(struct mach64_softc *);
+static int	mach64_ref_freq(void);
 
-#if 0
+#ifdef MACHFB_DEBUG
 static void	mach64_get_mode(struct mach64_softc *, struct videomode *);
 #endif
 
@@ -505,6 +506,9 @@ mach64_attach(device_t parent, device_t 
 
 	printf("%s: %d KB ROM at 0x%08x\n", device_xname(sc->sc_dev),
 	(int)sc->sc_rom.vb_size >> 10, (uint32_t)sc->sc_rom.vb_base);
+#ifdef MACHFB_DEBUG
+	mach64_get_mode(sc, NULL);
+#endif
 
 	prop_dictionary_get_uint32(device_properties(self), "width", );
 	prop_dictionary_get_uint32(device_properties(self), "height", );
@@ -556,23 +560,13 @@ mach64_attach(device_t parent, device_t 
 	else
 		sc->memtype = regr(sc, CONFIG_STAT0) & 0x07;
 
-	/*
-	 * XXX is there any way to calculate reference frequency from
-	 * known values?
-	 */
-	if ((mach64_chip_id == PCI_PRODUCT_ATI_RAGE_XL_PCI) ||
-	((mach64_chip_id >= PCI_PRODUCT_ATI_RAGE_LT_PRO_PCI) &&
-	(mach64_chip_id <= PCI_PRODUCT_ATI_RAGE_LT_PRO))) {
-		aprint_normal_dev(sc->sc_dev, "ref_freq=29.498MHz\n");
-		sc->ref_freq = 29498;
-	} else
-		sc->ref_freq = 14318;
+	sc->ref_freq = mach64_ref_freq();
 
 	reg = regr(sc, CLOCK_CNTL);
-	aprint_debug("CLOCK_CNTL: %08x\n", reg);
 	sc->sc_clock = reg & 3;
-	aprint_debug("using clock %d\n", sc->sc_clock);
+	DPRINTF("using clock %d\n", sc->sc_clock);
 
+	DPRINTF("ref_freq: %d\n", sc->ref_freq);
 	sc->ref_div = regrb_pll(sc, PLL_REF_DIV);
 	DPRINTF("ref_div: %d\n", sc->ref_div);
 	sc->mclk_fb_div = regrb_pll(sc, MCLK_FB_DIV);
@@ -636,8 +630,9 @@ mach64_attach(device_t parent, device_t 
 sizeof(struct videomode));
 sc->sc_setmode = 1;
 			} else {
-aprint_error_dev(sc->sc_dev,
-"unable to use preferred mode\n");
+aprint_normal_dev(sc->sc_dev,
+"unable to use EDID preferred mode "
+"(%d x %d)\n", m->hdisplay, m->vdisplay);
 			}
 		}
 		/*
@@ -905,32 +900,118 @@ mach64_get_max_ramdac(struct mach64_soft
 		return 8;
 }
 
-#if 0
-static void
-mach64_get_mode(struct mach64_softc *sc, struct videomode *mode)
+static int
+mach64_ref_freq(void)
 {
-	struct mach64_crtcregs crtc;
-
-	crtc.h_total_disp = regr(sc, CRTC_H_TOTAL_DISP);
-	crtc.h_sync_strt_wid = regr(sc, CRTC_H_SYNC_STRT_WID);
-	crtc.v_total_disp = regr(sc, CRTC_V_TOTAL_DISP);
-	crtc.v_sync_strt_wid = regr(sc, CRTC_V_SYNC_STRT_WID);
-
-	mode->htotal = ((crtc.h_total_disp & 0x) + 1) << 3;
-	mode->hdisplay = ((crtc.h_total_disp >> 16) + 1) << 3;
-	mode->hsync_start = ((crtc.h_sync_strt_wid & 0x) + 1) << 3;
-	mode->hsync_end = ((crtc.h_sync_strt_wid >> 16) << 3) +
-	mode->hsync_start;
-	mode->vtotal = (crtc.v_total_disp & 0x) + 1;
-	mode->vdisplay = (crtc.v_total_disp >> 16) + 1;
-	mode->vsync_start = (crtc.v_sync_strt_wid & 0x) + 1;
-	mode->vsync_end = (crtc.v_sync_strt_wid >> 16) + mode->vsync_start;
+	/*
+	 * There doesn't seem to be any way to calculate the reference
+	 * frequency from known values
+	 */
+	if ((mach64_chip_id == PCI_PRODUCT_ATI_RAGE_XL_PCI) ||
+	((mach64_chip_id >= PCI_PRODUCT_ATI_RAGE_LT_PRO_PCI) &&
+	(mach64_chip_id <= PCI_PRODUCT_ATI_RAGE_L_MOB_M1_PCI)))
+		return 29498;
+	else
+		return 14318;
+}
 
 #ifdef MACHFB_DEBUG
-	printf("mach64_get_mode: %d %d %d %d %d %d %d %d\n",
-	mode->hdisplay, mode->hsync_start, mode->hsync_end, mode->htotal,
-	mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal);
-#endif
+static void
+mach64_get_mode(struct mach64_softc *sc, struct videomode *mode)
+{
+	int htotal, hdisplay, hsync_start, hsync_end;
+	int vtotal, vdisplay, vsync_start, vsync_end;
+	int gen_ctl, clk_ctl, 

CVS commit: src/sys/dev/scsipi

2020-07-27 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jul 27 15:41:03 UTC 2020

Modified Files:
src/sys/dev/scsipi: if_se.c

Log Message:
Improve the workqueue and callout handling.  Prompted by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/scsipi/if_se.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/scsipi/if_se.c
diff -u src/sys/dev/scsipi/if_se.c:1.110 src/sys/dev/scsipi/if_se.c:1.111
--- src/sys/dev/scsipi/if_se.c:1.110	Wed Jul 22 17:18:10 2020
+++ src/sys/dev/scsipi/if_se.c	Mon Jul 27 15:41:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_se.c,v 1.110 2020/07/22 17:18:10 riastradh Exp $	*/
+/*	$NetBSD: if_se.c,v 1.111 2020/07/27 15:41:03 jdc Exp $	*/
 
 /*
  * Copyright (c) 1997 Ian W. Dall 
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.110 2020/07/22 17:18:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.111 2020/07/27 15:41:03 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -332,6 +332,7 @@ seattach(device_t parent, device_t self,
 
 	sc->sc_attach_state = 0;
 	callout_init(>sc_recv_ch, CALLOUT_MPSAFE);
+	callout_setfunc(>sc_recv_ch, se_recv_callout, (void *)sc);
 	mutex_init(>sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
 
 	/*
@@ -415,7 +416,6 @@ sedetach(device_t self, int flags)
 		mutex_enter(>sc_iflock);
 		ifp->if_flags &= ~IFF_RUNNING;
 		se_disable(sc);
-		callout_halt(>sc_recv_ch, NULL);
 		ether_ifdetach(ifp);
 		if_detach(ifp);
 		mutex_exit(>sc_iflock);
@@ -464,18 +464,13 @@ static void
 se_ifstart(struct ifnet *ifp)
 {
 	struct se_softc *sc = ifp->if_softc;
-	int i = 100;
 
 	mutex_enter(>sc_iflock);
-	while (i && sc->sc_send_work_pending == true) {
-		i--;
-		delay(10);
-	}
-	if (i) {
+	if (!sc->sc_send_work_pending)  {
 		sc->sc_send_work_pending = true;
 		workqueue_enqueue(sc->sc_send_wq, >sc_send_work, NULL);
-	} else
-		if_statinc(ifp, if_oerrors);
+	} 
+	/* else: nothing to do - work is already queued */
 	mutex_exit(>sc_iflock);
 }
 
@@ -575,8 +570,7 @@ sedone(struct scsipi_xfer *xs, int error
 		/* scsipi_free_xs will call start. Harmless. */
 		if (error) {
 			/* Reschedule after a delay */
-			callout_reset(>sc_recv_ch, se_poll,
-			se_recv_callout, (void *)sc);
+			callout_schedule(>sc_recv_ch, se_poll);
 		} else {
 			int n, ntimeo;
 			n = se_read(sc, xs->data, xs->datalen - xs->resid);
@@ -597,8 +591,7 @@ sedone(struct scsipi_xfer *xs, int error
 	  se_poll: ntimeo);
 			}
 			sc->sc_last_timeout = ntimeo;
-			callout_reset(>sc_recv_ch, ntimeo,
-			se_recv_callout, (void *)sc);
+			callout_schedule(>sc_recv_ch, ntimeo);
 		}
 	}
 }
@@ -618,8 +611,8 @@ se_recv_callout(void *v)
 
 	mutex_enter(>sc_iflock);
 	if (sc->sc_recv_work_pending == true) {
-		callout_reset(>sc_recv_ch, se_poll,
-		se_recv_callout, (void *)sc);
+		callout_schedule(>sc_recv_ch, se_poll);
+		mutex_exit(>sc_iflock);
 		return;
 	}
 
@@ -660,8 +653,7 @@ se_recv(struct se_softc *sc)
 	sc->sc_rbuf, RBUF_LEN, SERETRIES, SETIMEOUT, NULL,
 	XS_CTL_NOSLEEP | XS_CTL_DATA_IN);
 	if (error)
-		callout_reset(>sc_recv_ch, se_poll,
-		se_recv_callout, (void *)sc);
+		callout_schedule(>sc_recv_ch, se_poll);
 }
 
 /*
@@ -923,12 +915,19 @@ se_init(struct se_softc *sc)
 	if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_UP) {
 		ifp->if_flags |= IFF_RUNNING;
 		mutex_enter(>sc_iflock);
-		sc->sc_recv_work_pending = true;
-		workqueue_enqueue(sc->sc_recv_wq, >sc_recv_work, NULL);
+		if (!sc->sc_recv_work_pending)  {
+			sc->sc_recv_work_pending = true;
+			workqueue_enqueue(sc->sc_recv_wq, >sc_recv_work,
+			NULL);
+		} 
 		mutex_exit(>sc_iflock);
 		ifp->if_flags &= ~IFF_OACTIVE;
 		mutex_enter(>sc_iflock);
-		workqueue_enqueue(sc->sc_send_wq, >sc_send_work, NULL);
+		if (!sc->sc_send_work_pending)  {
+			sc->sc_send_work_pending = true;
+			workqueue_enqueue(sc->sc_send_wq, >sc_send_work,
+			NULL);
+		} 
 		mutex_exit(>sc_iflock);
 	}
 	return (error);
@@ -1019,7 +1018,7 @@ se_stop(struct se_softc *sc)
 {
 
 	/* Don't schedule any reads */
-	callout_stop(>sc_recv_ch);
+	callout_halt(>sc_recv_ch, >sc_iflock);
 
 	/* Wait for the workqueues to finish */
 	mutex_enter(>sc_iflock);



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

2020-07-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jul 23 16:08:03 UTC 2020

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

Log Message:
Move machine-specific fixes into separate functions to improve readability.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 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/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.221 src/sys/arch/sparc64/sparc64/autoconf.c:1.222
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.221	Sun Jul  5 09:56:06 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Jul 23 16:08:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -,6 +,101 @@ add_drivebay_props_v210(device_t dev, in
 }
 
 /*
+ * Add SPARCle spdmem devices (0x50 and 0x51) that are not in the OFW tree
+ */
+static void
+add_spdmem_props_sparcle(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = prop_array_create();
+	int i;
+
+	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
+	for (i = 0x50; i <= 0x51; i++) {
+		prop_dictionary_t spd = prop_dictionary_create();
+		prop_dictionary_set_string(spd, "name", "dimm-spd");
+		prop_dictionary_set_uint32(spd, "addr", i);
+		prop_dictionary_set_uint64(spd, "cookie", 0);
+		prop_array_add(cfg, spd);
+		prop_object_release(spd);
+	}
+	prop_dictionary_set(props, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+}
+
+/*
+ * Add V210/V240 environmental sensors that are not in the OFW tree.
+ */
+static void
+add_env_sensors_v210(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = NULL;
+	prop_dictionary_t sens;
+	prop_data_t data;
+	const char name_lm[] = "i2c-lm75";
+	const char name_adm[] = "i2c-adm1026";
+
+	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
+	cfg = prop_dictionary_get(props, "i2c-child-devices");
+ 	if (!cfg) {
+		cfg = prop_array_create();
+		prop_dictionary_set(props, "i2c-child-devices", cfg);
+		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
+	}
+
+	/* ADM1026 at 0x2e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x2e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "hardware-monitor");
+	data = prop_data_create_copy(_adm[0], sizeof(name_adm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+
+	/* LM75 at 0x4e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x4e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "temperature-sensor");
+	data = prop_data_create_copy(_lm[0], sizeof(name_lm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+}
+
+/* Hardware specific device properties */
+static void
+set_hw_props(device_t dev)
+{
+	device_t busdev = device_parent(dev);
+
+	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+
+	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+}
+
+/*
  * Called back during autoconfiguration for each device found
  */
 void
@@ -1155,7 +1250,8 @@ device_register(device_t dev, void *aux)
 
 		ofnode = (int)ia->ia_cookie;
 		if (device_is_a(dev, "pcagpio")) {
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+			if (!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+			!strcmp(machine_model, "SUNW,Sun-Fire-V210")) {
 add_gpio_props_v210(dev, aux);
 			}
 		} 
@@ -1344,82 +1440,13 @@ noether:
 			}
 		}
 
-		/*
-		 * Add SPARCle spdmem devices (0x50 and 0x51) that the
-		 * firmware does not know about.
-		 */
-		if (!strcmp(machine_model, 

CVS commit: src/sys/dev/scsipi

2020-06-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jun 22 17:38:27 UTC 2020

Modified Files:
src/sys/dev/scsipi: if_se.c

Log Message:
Add sedetach() and also use it to remove duplicate code from seattach().
Correct a comment about sedone().


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/scsipi/if_se.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/scsipi/if_se.c
diff -u src/sys/dev/scsipi/if_se.c:1.106 src/sys/dev/scsipi/if_se.c:1.107
--- src/sys/dev/scsipi/if_se.c:1.106	Mon Jun 22 16:05:20 2020
+++ src/sys/dev/scsipi/if_se.c	Mon Jun 22 17:38:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_se.c,v 1.106 2020/06/22 16:05:20 jdc Exp $	*/
+/*	$NetBSD: if_se.c,v 1.107 2020/06/22 17:38:27 jdc Exp $	*/
 
 /*
  * Copyright (c) 1997 Ian W. Dall 
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.106 2020/06/22 16:05:20 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.107 2020/06/22 17:38:27 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -198,10 +198,12 @@ struct se_softc {
 	int sc_flags;
 	int sc_last_timeout;
 	int sc_enabled;
+	int sc_attach_state;
 };
 
 static int	sematch(device_t, cfdata_t, void *);
 static void	seattach(device_t, device_t, void *);
+static int	sedetach(device_t, int);
 
 static void	se_ifstart(struct ifnet *);
 
@@ -240,7 +242,7 @@ int	se_enable(struct se_softc *);
 void	se_disable(struct se_softc *);
 
 CFATTACH_DECL_NEW(se, sizeof(struct se_softc),
-sematch, seattach, NULL, NULL);
+sematch, seattach, sedetach, NULL);
 
 extern struct cfdriver se_cd;
 
@@ -267,7 +269,7 @@ const struct scsipi_periphsw se_switch =
 	NULL,			/* Use default error handler */
 	NULL,			/* have no queue */
 	NULL,			/* have no async handler */
-	sedone,			/* deal with stats at interrupt time */
+	sedone,			/* deal with send/recv completion */
 };
 
 const struct scsipi_inquiry_pattern se_patterns[] = {
@@ -330,6 +332,7 @@ seattach(device_t parent, device_t self,
 	printf("\n");
 	SC_DEBUG(periph, SCSIPI_DB2, ("seattach: "));
 
+	sc->sc_attach_state = 0;
 	callout_init(>sc_recv_ch, CALLOUT_MPSAFE);
 	mutex_init(>sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
 
@@ -363,43 +366,82 @@ seattach(device_t parent, device_t self,
 	IFQ_SET_READY(>if_snd);
 
 	se_get_addr(sc, myaddr);
+	sc->sc_attach_state = 1;
 
 	/* Attach the interface. */
 	rv = if_initialize(ifp);
 	if (rv != 0) {
-		free(sc->sc_tbuf, M_DEVBUF);
-		callout_destroy(>sc_recv_ch);
-		mutex_destroy(>sc_iflock);
+		sedetach(sc->sc_dev, 0);
 		return; /* Error */
 	}
+	
 	snprintf(wqname, sizeof(wqname), "%sRx", device_xname(sc->sc_dev));
 	rv = workqueue_create(>sc_recv_wq, wqname, se_recv_worker, sc,
 	PRI_SOFTNET, IPL_NET, WQ_MPSAFE);
 	if (rv != 0) {
 		aprint_error_dev(sc->sc_dev,
-		"unable to create recv workqueue\n");
-		free(sc->sc_tbuf, M_DEVBUF);
-		callout_destroy(>sc_recv_ch);
-		mutex_destroy(>sc_iflock);
+		"unable to create recv Rx workqueue\n");
+		sedetach(sc->sc_dev, 0);
 		return; /* Error */
 	}
 	sc->sc_recv_work_pending = false;
+	sc->sc_attach_state = 2;
+
 	snprintf(wqname, sizeof(wqname), "%sTx", device_xname(sc->sc_dev));
 	rv = workqueue_create(>sc_send_wq, wqname, se_send_worker, ifp,
 	PRI_SOFTNET, IPL_NET, WQ_MPSAFE);
 	if (rv != 0) {
 		aprint_error_dev(sc->sc_dev,
-		"unable to create send workqueue\n");
-		free(sc->sc_tbuf, M_DEVBUF);
-		callout_destroy(>sc_recv_ch);
-		mutex_destroy(>sc_iflock);
-		workqueue_destroy(sc->sc_send_wq);
+		"unable to create send Tx workqueue\n");
+		sedetach(sc->sc_dev, 0);
 		return; /* Error */
 	}
 	sc->sc_send_work_pending = false;
+	sc->sc_attach_state = 3;
+
 	sc->sc_ipq = if_percpuq_create(>sc_ethercom.ec_if);
 	ether_ifattach(ifp, myaddr);
 	if_register(ifp);
+	sc->sc_attach_state = 4;
+}
+
+static int
+sedetach(device_t self, int flags)
+{
+	struct se_softc *sc = device_private(self);
+	struct ifnet *ifp = >sc_ethercom.ec_if;
+
+	switch(sc->sc_attach_state) {
+	case 4:
+		se_stop(sc);
+		mutex_enter(>sc_iflock);
+		ifp->if_flags &= ~IFF_RUNNING;
+		se_disable(sc);
+		callout_halt(>sc_recv_ch, NULL);
+		ether_ifdetach(ifp);
+		if_detach(ifp);
+		mutex_exit(>sc_iflock);
+		if_percpuq_destroy(sc->sc_ipq);
+		/*FALLTHROUGH*/
+	case 3:
+		workqueue_destroy(sc->sc_send_wq);
+		/*FALLTHROUGH*/
+	case 2:
+		workqueue_destroy(sc->sc_recv_wq);
+		/*FALLTHROUGH*/
+	case 1:
+		free(sc->sc_rbuf, M_DEVBUF);
+		free(sc->sc_tbuf, M_DEVBUF);
+		callout_destroy(>sc_recv_ch);
+		mutex_destroy(>sc_iflock);
+		break;
+	default:
+		aprint_error_dev(sc->sc_dev, "detach failed (state %d)\n",
+		sc->sc_attach_state);
+		return 1;
+		break;
+	}
+	return 0;
 }
 
 /*



CVS commit: src/sys/dev/scsipi

2020-06-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jun 22 16:05:20 UTC 2020

Modified Files:
src/sys/dev/scsipi: if_se.c

Log Message:
Use workqueues so that we don't call into the scsipi subsystem via
a softint from the network stack.
Don't recurse through scsipi_command() when we have multiple packets
in the send queue - use a loop instead.  This means that we no longer
need sestart(), as we can now handle everything in sedone().
Fix a couple of XXX's.
Rework the locking logic slightly from the previous revision.
Now this works with DIAGNOSTIC+LOCKDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/scsipi/if_se.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/scsipi/if_se.c
diff -u src/sys/dev/scsipi/if_se.c:1.105 src/sys/dev/scsipi/if_se.c:1.106
--- src/sys/dev/scsipi/if_se.c:1.105	Fri Jun 19 10:30:27 2020
+++ src/sys/dev/scsipi/if_se.c	Mon Jun 22 16:05:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_se.c,v 1.105 2020/06/19 10:30:27 jdc Exp $	*/
+/*	$NetBSD: if_se.c,v 1.106 2020/06/22 16:05:20 jdc Exp $	*/
 
 /*
  * Copyright (c) 1997 Ian W. Dall 
@@ -49,7 +49,7 @@
  * This driver is also a bit unusual. It must look like a network
  * interface and it must also appear to be a scsi device to the scsi
  * system. Hence there are cases where there are two entry points. eg
- * sestart is to be called from the scsi subsytem and se_ifstart from
+ * sedone is to be called from the scsi subsytem and se_ifstart from
  * the network interface subsystem.  In addition, to facilitate scsi
  * commands issued by userland programs, there are open, close and
  * ioctl entry points. This allows a user program to, for example,
@@ -59,10 +59,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.105 2020/06/19 10:30:27 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.106 2020/06/22 16:05:20 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
+#include "opt_net_mpsafe.h"
 #include "opt_atalk.h"
 #endif
 
@@ -85,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -177,10 +179,12 @@ struct se_softc {
 	struct ethercom sc_ethercom;	/* Ethernet common part */
 	struct scsipi_periph *sc_periph;/* contains our targ, lun, etc. */
 
-	struct callout sc_ifstart_ch;
 	struct callout sc_recv_ch;
 	struct kmutex sc_iflock;
 	struct if_percpuq *sc_ipq;
+	struct workqueue *sc_recv_wq, *sc_send_wq;
+	struct work sc_recv_work, sc_send_work;
+	int sc_recv_work_pending, sc_send_work_pending;
 
 	char *sc_tbuf;
 	char *sc_rbuf;
@@ -200,7 +204,6 @@ static int	sematch(device_t, cfdata_t, v
 static void	seattach(device_t, device_t, void *);
 
 static void	se_ifstart(struct ifnet *);
-static void	sestart(struct scsipi_periph *);
 
 static void	sedone(struct scsipi_xfer *, int);
 static int	se_ioctl(struct ifnet *, u_long, void *);
@@ -209,10 +212,12 @@ static void	sewatchdog(struct ifnet *);
 #if 0
 static inline uint16_t ether_cmp(void *, void *);
 #endif
-static void	se_recv(void *);
+static void	se_recv_callout(void *);
+static void	se_recv_worker(struct work *wk, void *cookie);
+static void	se_recv(struct se_softc *);
 static struct mbuf *se_get(struct se_softc *, char *, int);
 static int	se_read(struct se_softc *, char *, int);
-static int	se_reset(struct se_softc *);
+static void	se_reset(struct se_softc *);
 static int	se_add_proto(struct se_softc *, int);
 static int	se_get_addr(struct se_softc *, uint8_t *);
 static int	se_set_media(struct se_softc *, int);
@@ -228,7 +233,7 @@ static inline int se_scsipi_cmd(struct s
 			int cmdlen, u_char *data_addr, int datalen,
 			int retries, int timeout, struct buf *bp,
 			int flags);
-static void	se_delayed_ifstart(void *);
+static void	se_send_worker(struct work *wk, void *cookie);
 static int	se_set_mode(struct se_softc *, int, int);
 
 int	se_enable(struct se_softc *);
@@ -260,7 +265,7 @@ const struct cdevsw se_cdevsw = {
 
 const struct scsipi_periphsw se_switch = {
 	NULL,			/* Use default error handler */
-	sestart,		/* have a queue, served by this */
+	NULL,			/* have no queue */
 	NULL,			/* have no async handler */
 	sedone,			/* deal with stats at interrupt time */
 };
@@ -317,6 +322,7 @@ seattach(device_t parent, device_t self,
 	struct scsipi_periph *periph = sa->sa_periph;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	uint8_t myaddr[ETHER_ADDR_LEN];
+	char wqname[MAXCOMLEN];
 	int rv;
 
 	sc->sc_dev = self;
@@ -324,7 +330,6 @@ seattach(device_t parent, device_t self,
 	printf("\n");
 	SC_DEBUG(periph, SCSIPI_DB2, ("seattach: "));
 
-	callout_init(>sc_ifstart_ch, CALLOUT_MPSAFE);
 	callout_init(>sc_recv_ch, CALLOUT_MPSAFE);
 	mutex_init(>sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
 
@@ -335,21 +340,17 @@ seattach(device_t parent, device_t self,
 	periph->periph_dev = sc->sc_dev;
 	periph->periph_switch = _switch;
 
-	/* XXX increase openings? */
-
 	

CVS commit: src/sys/dev/scsipi

2020-06-19 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 19 10:30:27 UTC 2020

Modified Files:
src/sys/dev/scsipi: if_se.c

Log Message:
First pass at making this work again.
Remove spl and add some locking around network access (needs more work).
Make sure that we consistently use the channel lock for scsipi commands.
Remove the preference for send over receive, as this can lead to deadlocks
- we only advertise 1 opening, but we can try to send before the receive is
complete in this case.
Don't use XS_CTL_ASYNC because we don't provide a buffer.
Tested on UP sparc and compile-tested on atari.
Tested with LOCKDEBUG.
Still fails with DIAGNOSTIC because we can call into the scsipi routines
from a softint.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/scsipi/if_se.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/scsipi/if_se.c
diff -u src/sys/dev/scsipi/if_se.c:1.104 src/sys/dev/scsipi/if_se.c:1.105
--- src/sys/dev/scsipi/if_se.c:1.104	Wed Jan 29 05:59:50 2020
+++ src/sys/dev/scsipi/if_se.c	Fri Jun 19 10:30:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_se.c,v 1.104 2020/01/29 05:59:50 thorpej Exp $	*/
+/*	$NetBSD: if_se.c,v 1.105 2020/06/19 10:30:27 jdc Exp $	*/
 
 /*
  * Copyright (c) 1997 Ian W. Dall 
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.104 2020/01/29 05:59:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.105 2020/06/19 10:30:27 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -83,6 +83,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -142,7 +144,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.
 #define SE_POLL0 10		/* default in milliseconds */
 int se_poll = 0;		/* Delay in ticks set at attach time */
 int se_poll0 = 0;
+#ifdef SE_DEBUG
 int se_max_received = 0;	/* Instrumentation */
+#endif
 
 #define	PROTOCMD(p, d) \
 	((d) = (p))
@@ -175,6 +179,8 @@ struct se_softc {
 
 	struct callout sc_ifstart_ch;
 	struct callout sc_recv_ch;
+	struct kmutex sc_iflock;
+	struct if_percpuq *sc_ipq;
 
 	char *sc_tbuf;
 	char *sc_rbuf;
@@ -186,7 +192,6 @@ struct se_softc {
 #define PROTO_AARP	0x10
 	int sc_debug;
 	int sc_flags;
-#define SE_NEED_RECV 0x1
 	int sc_last_timeout;
 	int sc_enabled;
 };
@@ -250,7 +255,7 @@ const struct cdevsw se_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = nodiscard,
-	.d_flag = D_OTHER
+	.d_flag = D_OTHER | D_MPSAFE
 };
 
 const struct scsipi_periphsw se_switch = {
@@ -319,8 +324,9 @@ seattach(device_t parent, device_t self,
 	printf("\n");
 	SC_DEBUG(periph, SCSIPI_DB2, ("seattach: "));
 
-	callout_init(>sc_ifstart_ch, 0);
-	callout_init(>sc_recv_ch, 0);
+	callout_init(>sc_ifstart_ch, CALLOUT_MPSAFE);
+	callout_init(>sc_recv_ch, CALLOUT_MPSAFE);
+	mutex_init(>sc_iflock, MUTEX_DEFAULT, IPL_SOFTNET);
 
 	/*
 	 * Store information needed to contact our base driver
@@ -360,13 +366,17 @@ seattach(device_t parent, device_t self,
 		free(sc->sc_tbuf, M_DEVBUF);
 		callout_destroy(>sc_ifstart_ch);
 		callout_destroy(>sc_recv_ch);
+		mutex_destroy(>sc_iflock);
 		return; /* Error */
 	}
+	sc->sc_ipq = if_percpuq_create(>sc_ethercom.ec_if);
 	ether_ifattach(ifp, myaddr);
 	if_register(ifp);
 }
 
-
+/*
+ * Send a command to the device
+ */
 static inline int
 se_scsipi_cmd(struct scsipi_periph *periph, struct scsipi_generic *cmd,
 int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
@@ -374,21 +384,24 @@ se_scsipi_cmd(struct scsipi_periph *peri
 {
 	int error;
 
+	KASSERT(!mutex_owned(chan_mtx(periph->periph_channel)));
+
 	error = scsipi_command(periph, cmd, cmdlen, data_addr,
 	datalen, retries, timeout, bp, flags);
 	return (error);
 }
 
-/* Start routine for calling from scsi sub system */
+/*
+ * Start routine for calling from scsi sub system
+ * Called with the channel lock held
+ */
 static void
 sestart(struct scsipi_periph *periph)
 {
 	struct se_softc *sc = device_private(periph->periph_dev);
 	struct ifnet *ifp = >sc_ethercom.ec_if;
-	int s = splnet();
 
 	se_ifstart(ifp);
-	(void) splx(s);
 }
 
 static void
@@ -396,19 +409,18 @@ se_delayed_ifstart(void *v)
 {
 	struct ifnet *ifp = v;
 	struct se_softc *sc = ifp->if_softc;
-	int s;
 
-	s = splnet();
+	mutex_enter(chan_mtx(sc->sc_periph->periph_channel));
 	if (sc->sc_enabled) {
 		ifp->if_flags &= ~IFF_OACTIVE;
 		se_ifstart(ifp);
 	}
-	splx(s);
+	mutex_exit(chan_mtx(sc->sc_periph->periph_channel));
 }
 
 /*
  * Start transmission on the interface.
- * Always called at splnet().
+ * Must be called with the scsipi channel lock held
  */
 static void
 se_ifstart(struct ifnet *ifp)
@@ -426,6 +438,9 @@ se_ifstart(struct ifnet *ifp)
 	IFQ_DEQUEUE(>if_snd, m0);
 	if (m0 == 0)
 		return;
+
+	KASSERT(mutex_owned(chan_mtx(sc->sc_periph->periph_channel)));
+
 	/* If BPF is listening on this interface, let it see the

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

2020-06-12 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jun 13 05:31:29 UTC 2020

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

Log Message:
Initialise the mutex before we use it.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc/dev/tctrl.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/tctrl.c
diff -u src/sys/arch/sparc/dev/tctrl.c:1.61 src/sys/arch/sparc/dev/tctrl.c:1.62
--- src/sys/arch/sparc/dev/tctrl.c:1.61	Wed Oct 25 08:12:37 2017
+++ src/sys/arch/sparc/dev/tctrl.c	Sat Jun 13 05:31:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tctrl.c,v 1.61 2017/10/25 08:12:37 maya Exp $	*/
+/*	$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.61 2017/10/25 08:12:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $");
 
 #include 
 #include 
@@ -260,6 +260,8 @@ tctrl_attach(device_t parent, device_t s
 
 	sc->sc_tft_on = 1;
 
+	mutex_init(>sc_requestlock, MUTEX_DEFAULT, IPL_NONE);
+
 	/* clear any pending data.
 	 */
 	for (i = 0; i < 1; i++) {
@@ -312,7 +314,6 @@ tctrl_attach(device_t parent, device_t s
 	sc->sc_ext_pending = 0;
 		sc->sc_ext_pending = 0;
 
-	mutex_init(>sc_requestlock, MUTEX_DEFAULT, IPL_NONE);
 	selinit(>sc_rsel);
 
 	/* setup sensors and register the power button */



CVS commit: [netbsd-9] src/doc

2020-06-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jun 11 11:04:12 UTC 2020

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

Log Message:
Tickets #957 & #958.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.64 -r1.1.2.65 src/doc/CHANGES-9.1

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.1
diff -u src/doc/CHANGES-9.1:1.1.2.64 src/doc/CHANGES-9.1:1.1.2.65
--- src/doc/CHANGES-9.1:1.1.2.64	Sun Jun  7 19:08:12 2020
+++ src/doc/CHANGES-9.1	Thu Jun 11 11:04:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.64 2020/06/07 19:08:12 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.65 2020/06/11 11:04:11 jdc Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -2886,3 +2886,16 @@ sys/arch/arm/include/arm32/param.h		1.30
 	_ARCH_ARM_6 has a split of 2:2 and others have a split of 3:1.
 	[skrll, ticket #951]
 
+src/sys/dev/usb/if_otus.c			1.45 (via patch)
+
+	Stricter bounds check for some packet length we get from the usb chip,
+	to make sure we do not corrupt kernel memory.
+	Pointed out by Ilja Van Sprundel.
+	[martin, ticket #957]
+
+src/sys/dev/usb/if_run.c			1.41
+
+	Better bounds checking for oversized packets, to avoid kernel memory
+	corruption. Pointed out by Ilja Van Sprundel.
+	[martin, ticket #958]
+



CVS commit: [netbsd-9] src/sys/dev/usb

2020-06-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jun 11 11:03:22 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: if_run.c

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

src/sys/dev/usb/if_run.c: revision 1.41

Better bounds checking for oversized packets, to avoid kernel memory
corruption. Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.32.4.1 src/sys/dev/usb/if_run.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/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.32 src/sys/dev/usb/if_run.c:1.32.4.1
--- src/sys/dev/usb/if_run.c:1.32	Tue Jan 22 06:47:20 2019
+++ src/sys/dev/usb/if_run.c	Thu Jun 11 11:03:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $	*/
+/*	$NetBSD: if_run.c,v 1.32.4.1 2020/06/11 11:03:22 jdc Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.32 2019/01/22 06:47:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.32.4.1 2020/06/11 11:03:22 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2255,7 +2255,8 @@ run_rx_frame(struct run_softc *sc, uint8
 		return;
 	}
 	if (len > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(len <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



CVS commit: [netbsd-9] src/sys/dev/usb

2020-06-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jun 11 11:01:20 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-9]: if_otus.c

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

src/sys/dev/usb/if_otus.c: revision 1.45 (via patch)

Stricter bounds check for some packet length we get from the usb chip,
to make sure we do not corrupt kernel memory.
Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/usb/if_otus.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/if_otus.c
diff -u src/sys/dev/usb/if_otus.c:1.38 src/sys/dev/usb/if_otus.c:1.38.2.1
--- src/sys/dev/usb/if_otus.c:1.38	Tue May 28 07:41:50 2019
+++ src/sys/dev/usb/if_otus.c	Thu Jun 11 11:01:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_otus.c,v 1.38 2019/05/28 07:41:50 msaitoh Exp $	*/
+/*	$NetBSD: if_otus.c,v 1.38.2.1 2020/06/11 11:01:20 jdc Exp $	*/
 /*	$OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.38 2019/05/28 07:41:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.38.2.1 2020/06/11 11:01:20 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1745,6 +1745,10 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 	}
 	/* Compute MPDU's length. */
 	mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail);
+	if (__predict_false(mlen < IEEE80211_CRC_LEN)) {
+		ifp->if_ierrors++;
+		return;
+	}
 	mlen -= IEEE80211_CRC_LEN;	/* strip 802.11 FCS */
 	/* Make sure there's room for an 802.11 header. */
 	/*
@@ -1765,7 +1769,8 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 		return;
 	}
 	if (align + mlen > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(align + mlen <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



CVS commit: src

2020-05-19 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue May 19 06:26:37 UTC 2020

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4/man4.sparc64: Makefile

Log Message:
Add tadpmu to Makefile and set list.


To generate a diff of this commit:
cvs rdiff -u -r1.1690 -r1.1691 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/man4.sparc64/Makefile

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/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1690 src/distrib/sets/lists/man/mi:1.1691
--- src/distrib/sets/lists/man/mi:1.1690	Sat May 16 19:05:05 2020
+++ src/distrib/sets/lists/man/mi	Tue May 19 06:26:37 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1690 2020/05/16 19:05:05 christos Exp $
+# $NetBSD: mi,v 1.1691 2020/05/19 06:26:37 jdc Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1775,6 +1775,7 @@
 ./usr/share/man/cat4/sparc64/lom.0		man-sys-catman		.cat
 ./usr/share/man/cat4/sparc64/sab.0		man-sys-catman		.cat
 ./usr/share/man/cat4/sparc64/sabtty.0		man-sys-catman		.cat
+./usr/share/man/cat4/sparc64/tadpmu.0		man-sys-catman		.cat
 ./usr/share/man/cat4/sparc64/tda.0		man-sys-catman		.cat
 ./usr/share/man/cat4/spc.0			man-sys-catman		.cat
 ./usr/share/man/cat4/spdmem.0			man-sys-catman		.cat
@@ -4907,6 +4908,7 @@
 ./usr/share/man/html4/sparc64/lom.html		man-sys-htmlman		html
 ./usr/share/man/html4/sparc64/sab.html		man-sys-htmlman		html
 ./usr/share/man/html4/sparc64/sabtty.html	man-sys-htmlman		html
+./usr/share/man/html4/sparc64/tadpmu.html	man-sys-htmlman		html
 ./usr/share/man/html4/sparc64/tda.html		man-sys-htmlman		html
 ./usr/share/man/html4/spc.html			man-sys-htmlman		html
 ./usr/share/man/html4/spdmem.html		man-sys-htmlman		html
@@ -7949,6 +7951,7 @@
 ./usr/share/man/man4/sparc64/lom.4		man-sys-man		.man
 ./usr/share/man/man4/sparc64/sab.4		man-sys-man		.man
 ./usr/share/man/man4/sparc64/sabtty.4		man-sys-man		.man
+./usr/share/man/man4/sparc64/tadpmu.4		man-sys-man		.man
 ./usr/share/man/man4/sparc64/tda.4		man-sys-man		.man
 ./usr/share/man/man4/spc.4			man-sys-man		.man
 ./usr/share/man/man4/spdmem.4			man-sys-man		.man

Index: src/share/man/man4/man4.sparc64/Makefile
diff -u src/share/man/man4/man4.sparc64/Makefile:1.7 src/share/man/man4/man4.sparc64/Makefile:1.8
--- src/share/man/man4/man4.sparc64/Makefile:1.7	Sun Feb  3 14:51:57 2013
+++ src/share/man/man4/man4.sparc64/Makefile	Tue May 19 06:26:37 2020
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.7 2013/02/03 14:51:57 jdc Exp $
+# $NetBSD: Makefile,v 1.8 2020/05/19 06:26:37 jdc Exp $
 
 MANSUBDIR=/sparc64
 
-MAN=	envctrl.4 ffb.4 fdc.4 intro.4 lom.4 sab.4 tda.4
+MAN=	envctrl.4 ffb.4 fdc.4 intro.4 lom.4 sab.4 tadpmu.4 tda.4
 
 MLINKS+=	sab.4 sabtty.4
 



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

2020-05-18 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 18 08:40:45 UTC 2020

Added Files:
src/share/man/man4/man4.sparc64: tadpmu.4

Log Message:
Add a basic manual page for tadpmu.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/man/man4/man4.sparc64/tadpmu.4

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

Added files:

Index: src/share/man/man4/man4.sparc64/tadpmu.4
diff -u /dev/null src/share/man/man4/man4.sparc64/tadpmu.4:1.1
--- /dev/null	Mon May 18 08:40:45 2020
+++ src/share/man/man4/man4.sparc64/tadpmu.4	Mon May 18 08:40:44 2020
@@ -0,0 +1,54 @@
+.\"	$NetBSD: tadpmu.4,v 1.1 2020/05/18 08:40:44 jdc Exp $
+.\"
+.\" 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.
+.\"
+.Dd May 16, 2020
+.Dt TADPMU 4 sparc64
+.Os
+.Sh NAME
+.Nm tda
+.Nd Tadpole PMU 
+.Sh SYNOPSIS
+.Cd "Tadpole PMU Version 1.33"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides basic support for the Tadpole PMU found in Tadpole SPARCle
+and Viper systems.
+The status of the AC adapter, battery and fan are reported via the
+.Xr envstat 8
+interface, and AC adapter and lid switch events are reported via the
+.Xr sysmon_pswitch 9 interface.
+.Sh SEE ALSO
+.Xr envstat 8
+.Sh BUGS
+The battery status is reported by reading the battery voltage.
+Pp.
+The points at which the battery level becomes warning and critical are
+reported by the PMU, but are not directly correlated with battery voltage,
+so might be misreported by the driver.



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

2020-05-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat May 16 07:16:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: tadpmu.c tadpmureg.h tadpmuvar.h

Log Message:
Extend the monitoring to battery state, with capacity based on voltage.
Add more PMU definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/tadpmu.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/tadpmureg.h \
src/sys/arch/sparc64/dev/tadpmuvar.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/dev/tadpmu.c
diff -u src/sys/arch/sparc64/dev/tadpmu.c:1.4 src/sys/arch/sparc64/dev/tadpmu.c:1.5
--- src/sys/arch/sparc64/dev/tadpmu.c:1.4	Sun Oct 14 05:08:39 2018
+++ src/sys/arch/sparc64/dev/tadpmu.c	Sat May 16 07:16:14 2020
@@ -1,4 +1,4 @@
-/*/* $NetBSD: tadpmu.c,v 1.4 2018/10/14 05:08:39 macallan Exp $ */
+/*/* $NetBSD: tadpmu.c,v 1.5 2020/05/16 07:16:14 jdc Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz 
@@ -26,7 +26,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* a driver for the PMU found in Tadpole Wiper and possibly SPARCle laptops */
+/* a driver for the PMU found in Tadpole Viper and SPARCle laptops */
 
 #include "opt_tadpmu.h"
 #ifdef HAVE_TADPMU
@@ -56,13 +56,16 @@
 static bus_space_tag_t tadpmu_iot;
 static bus_space_handle_t tadpmu_hcmd;
 static bus_space_handle_t tadpmu_hdata;
-static struct sysmon_envsys *tadpmu_sme;
-static envsys_data_t tadpmu_sensors[5];
+static struct sysmon_envsys *tadpmu_sens_sme;
+static struct sysmon_envsys *tadpmu_acad_sme;
+static struct sysmon_envsys *tadpmu_batt_sme;
+static envsys_data_t tadpmu_sensors[8];
 static uint8_t idata = 0xff;
 static uint8_t ivalid = 0;
+static uint8_t ev_data = 0;
 static wchan_t tadpmu, tadpmuev;
-static struct sysmon_pswitch tadpmu_pbutton, tadpmu_lidswitch;
-static kmutex_t tadpmu_lock;
+static struct sysmon_pswitch tadpmu_pbutton, tadpmu_lidswitch, tadpmu_dcpower;
+static kmutex_t tadpmu_lock, data_lock;
 static lwp_t *tadpmu_thread;
 static int tadpmu_dying = 0;
 
@@ -202,10 +205,52 @@ tadpmu_send(uint8_t v)
 	}
 }
 
+static uint32_t
+tadpmu_battery_capacity(uint8_t gstat)
+{
+	uint8_t res;
+
+	if (gstat == GENSTAT_STATE_BATTERY_FULL) {
+		return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	}
+
+	mutex_enter(_lock);
+	tadpmu_flush();
+	tadpmu_send_cmd(CMD_READ_VBATT);
+	res = tadpmu_recv();
+	mutex_exit(_lock);
+
+	if (gstat & GENSTAT_STATE_BATTERY_DISCHARGE) {
+		if (res < TADPMU_BATT_DIS_CAP_CRIT)
+			return ENVSYS_BATTERY_CAPACITY_CRITICAL;
+		if (res < TADPMU_BATT_DIS_CAP_WARN)
+			return ENVSYS_BATTERY_CAPACITY_WARNING;
+		if (res < TADPMU_BATT_DIS_CAP_LOW)
+			return ENVSYS_BATTERY_CAPACITY_LOW;
+		else
+			return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	} else if (gstat == GENSTAT_STATE_BATTERY_CHARGE) {
+		if (res < TADPMU_BATT_CHG_CAP_CRIT)
+			return ENVSYS_BATTERY_CAPACITY_CRITICAL;
+		else if (res < TADPMU_BATT_CHG_CAP_WARN)
+			return ENVSYS_BATTERY_CAPACITY_WARNING;
+		else if (res < TADPMU_BATT_CHG_CAP_LOW)
+			return ENVSYS_BATTERY_CAPACITY_LOW;
+		else
+			return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	} else {
+		DPRINTF("%s unknown battery state %02x\n",
+		__func__, gstat);
+		return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	}
+}
+
+/* The data to read is calculated from the command and the units */
 static void
 tadpmu_sensors_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
 {
 	int res;
+
 	if (edata->private > 0) {
 		mutex_enter(_lock);
 		tadpmu_flush();
@@ -214,8 +259,27 @@ tadpmu_sensors_refresh(struct sysmon_env
 		mutex_exit(_lock);
 		if (edata->units == ENVSYS_STEMP) {
 			edata->value_cur = res * 100 + 27315;
+		} else if (edata->units == ENVSYS_SVOLTS_DC) {
+			edata->value_cur = res * 10;
+		} else if (edata->units == ENVSYS_BATTERY_CHARGE) {
+			if (res & GENSTAT_BATTERY_CHARGING)
+edata->value_cur = ENVSYS_INDICATOR_TRUE;
+			else
+edata->value_cur = ENVSYS_INDICATOR_FALSE;
+		} else if (edata->units == ENVSYS_BATTERY_CAPACITY) {
+			edata->value_cur = tadpmu_battery_capacity(res);
 		} else {
-			edata->value_cur = res;
+			if (edata->units == ENVSYS_INDICATOR &&
+			edata->private == CMD_READ_GENSTAT) {
+if (res & GENSTAT_DC_PRESENT)
+	edata->value_cur =
+	ENVSYS_INDICATOR_TRUE;
+else
+	edata->value_cur =
+	ENVSYS_INDICATOR_FALSE;
+			} else {
+edata->value_cur = res;
+			}
 		}
 		edata->state = ENVSYS_SVALID;
 	} else {
@@ -226,27 +290,73 @@ tadpmu_sensors_refresh(struct sysmon_env
 static void
 tadpmu_events(void *cookie)
 {
-	uint8_t res, ores = 0;
+	uint8_t events, gs, vb;
+
 	while (!tadpmu_dying) {
 		mutex_enter(_lock);
 		tadpmu_flush();
 		tadpmu_send_cmd(CMD_READ_GENSTAT);
-		res = tadpmu_recv();
+		gs = tadpmu_recv();
+		tadpmu_send_cmd(CMD_READ_VBATT);
+		vb = tadpmu_recv();
 		mutex_exit(_lock);
-		res &= GENSTAT_LID_CLOSED;
-		if (res != ores) {
-			ores = res;
+
+		mutex_enter(_lock);
+		events = 

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

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 18:29:59 UTC 2020

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

Log Message:
Add "wb at ebus" and sdmmc, ld for the SD card reader on SPARCle.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 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.226 src/sys/arch/sparc64/conf/GENERIC:1.227
--- src/sys/arch/sparc64/conf/GENERIC:1.226	Sat Mar 28 08:35:36 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Mon May 11 18:29:59 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.226 2020/03/28 08:35:36 isaki Exp $
+# $NetBSD: GENERIC,v 1.227 2020/05/11 18:29:59 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.226 $"
+#ident		"GENERIC-$Revision: 1.227 $"
 
 maxusers	64
 
@@ -281,6 +281,11 @@ options 	PMS_SYNAPTICS_TOUCHPAD	# Enable
 wskbd*		at pckbd? console ?
 wsmouse*	at pms? mux 0
 
+## Tadpole SPARCle SD card
+wb* 		at ebus?		# Winbond W83L518D SD/MMC reader
+sdmmc* 		at wb?
+ld* 		at sdmmc?
+
 ## Magma Serial/Parallel driver (not tested)
 #magma*	at sbus? slot ? offset ?
 #mtty*	at magma?



CVS commit: src/sys/arch/sparc64

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 15:56:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
Added Files:
src/sys/arch/sparc64/dev: wb_ebus.c

Log Message:
Add an ebus frontend for the Winbond W83l518D SD card reader as found on
Tadpole SPARCLE latops.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/wb_ebus.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/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.158 src/sys/arch/sparc64/conf/files.sparc64:1.159
--- src/sys/arch/sparc64/conf/files.sparc64:1.158	Sun Jan 27 02:08:38 2019
+++ src/sys/arch/sparc64/conf/files.sparc64	Mon May 11 15:56:15 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.158 2019/01/27 02:08:38 pgoyette Exp $
+#	$NetBSD: files.sparc64,v 1.159 2020/05/11 15:56:15 jdc Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -140,6 +140,10 @@ file	arch/sparc64/dev/fdc.c			fdc | fd n
 attach	audiocs at ebus with audiocs_ebus
 file	dev/ebus/cs4231_ebus.c			audiocs_ebus
 
+include	"dev/sdmmc/files.sdmmc"
+attach	wb at ebus with wb_ebus
+file	arch/sparc64/dev/wb_ebus.c		wb_ebus
+
 # PCMCIA bus (references fdc)
 include "dev/pcmcia/files.pcmcia"
 

Added files:

Index: src/sys/arch/sparc64/dev/wb_ebus.c
diff -u /dev/null src/sys/arch/sparc64/dev/wb_ebus.c:1.1
--- /dev/null	Mon May 11 15:56:15 2020
+++ src/sys/arch/sparc64/dev/wb_ebus.c	Mon May 11 15:56:15 2020
@@ -0,0 +1,86 @@
+/*	$NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $	*/
+
+/*
+ * 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.
+ */
+
+#include 
+__RCSID("$NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static int	wb_ebus_match(device_t, cfdata_t , void *);
+static void	wb_ebus_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(wb_ebus, sizeof(struct wb_softc),
+	wb_ebus_match, wb_ebus_attach, NULL, NULL);
+
+static int
+wb_ebus_match(device_t parent, cfdata_t match, void *aux) 
+{
+	struct ebus_attach_args *ea = aux;
+
+	return (strcmp(ea->ea_name, "TAD,wb-sdcard") == 0);
+}
+
+static void
+wb_ebus_attach(device_t parent, device_t self, void *aux)
+{
+	struct wb_softc *sc = device_private(self);
+	struct ebus_attach_args *ea = aux;
+
+	sc->wb_dev = self;
+
+	if (bus_space_map(ea->ea_bustag, EBUS_ADDR_FROM_REG(>ea_reg[0]),
+	ea->ea_reg[0].size, 0, >wb_ioh) == 0)
+		sc->wb_iot = ea->ea_bustag;
+	else {
+		aprint_error(": can't map register space\n");
+return;
+	}
+
+	bus_intr_establish(sc->wb_iot, ea->ea_intr[0], IPL_BIO, wb_intr, sc);
+
+	aprint_normal("\n");
+
+	sc->wb_type = WB_DEVNO_SD;
+	sc->wb_quirks = WB_QUIRK_1BIT;	/* 4bit bus width always fails */
+	wb_attach(sc);
+}



CVS commit: src/sys/dev/ic

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 14:55:20 UTC 2020

Modified Files:
src/sys/dev/ic: w83l518d.c w83l518d_sdmmc.c w83l518dvar.h

Log Message:
Make the driver endian-independent.
Add a quirk so that the bus front end can specify 1-bit only mode.
Remove unused isa includes.
Change the error returned for unsupported opcodes to ENOTSUP, so that
we can pass this back to sdmmc_mem, where it's handled since r1.72 of
  src/sys/dev/sdmmc/sdmmc_mem.c


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/w83l518d.c \
src/sys/dev/ic/w83l518dvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/w83l518d_sdmmc.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/w83l518d.c
diff -u src/sys/dev/ic/w83l518d.c:1.2 src/sys/dev/ic/w83l518d.c:1.3
--- src/sys/dev/ic/w83l518d.c:1.2	Thu Aug 19 14:58:22 2010
+++ src/sys/dev/ic/w83l518d.c	Mon May 11 14:55:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
+/* $NetBSD: w83l518d.c,v 1.3 2020/05/11 14:55:20 jdc Exp $ */
 
 /*
  * Copyright (c) 2009 Jared D. McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.3 2020/05/11 14:55:20 jdc Exp $");
 
 #include 
 #include 
@@ -39,9 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v
 
 #include 
 
-#include 
-#include 
-
 #include 
 #include 
 #include 
Index: src/sys/dev/ic/w83l518dvar.h
diff -u src/sys/dev/ic/w83l518dvar.h:1.2 src/sys/dev/ic/w83l518dvar.h:1.3
--- src/sys/dev/ic/w83l518dvar.h:1.2	Thu Aug 19 14:58:22 2010
+++ src/sys/dev/ic/w83l518dvar.h	Mon May 11 14:55:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518dvar.h,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
+/* $NetBSD: w83l518dvar.h,v 1.3 2020/05/11 14:55:20 jdc Exp $ */
 
 /*
  * Copyright (c) 2009 Jared D. McNeill 
@@ -44,6 +44,10 @@ struct wb_softc {
 	uint8_t			wb_sdmmc_clk;
 	uint8_t			wb_sdmmc_intsts;
 	callout_t		wb_sdmmc_callout;
+
+	/* quirks */
+#define	WB_QUIRK_1BIT	(1U << 0)
+	int			wb_quirks;
 };
 
 void	wb_attach(struct wb_softc *);

Index: src/sys/dev/ic/w83l518d_sdmmc.c
diff -u src/sys/dev/ic/w83l518d_sdmmc.c:1.3 src/sys/dev/ic/w83l518d_sdmmc.c:1.4
--- src/sys/dev/ic/w83l518d_sdmmc.c:1.3	Thu Oct  7 12:06:09 2010
+++ src/sys/dev/ic/w83l518d_sdmmc.c	Mon May 11 14:55:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518d_sdmmc.c,v 1.3 2010/10/07 12:06:09 kiyohara Exp $ */
+/* $NetBSD: w83l518d_sdmmc.c,v 1.4 2020/05/11 14:55:20 jdc Exp $ */
 
 /*
  * Copyright (c) 2009 Jared D. McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.3 2010/10/07 12:06:09 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.4 2020/05/11 14:55:20 jdc Exp $");
 
 #include 
 #include 
@@ -43,9 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: w83l518d_sdm
 #include 
 #include 
 
-#include 
-#include 
-
 #include 
 #include 
 #include 
@@ -185,7 +182,8 @@ wb_sdmmc_attach(struct wb_softc *wb)
 	saa.saa_sch = wb;
 	saa.saa_clkmin = 375;
 	saa.saa_clkmax = 24000;
-	saa.saa_caps = SMC_CAPS_4BIT_MODE;
+	if (!ISSET(wb->wb_quirks, WB_QUIRK_1BIT))
+		saa.saa_caps = SMC_CAPS_4BIT_MODE;
 
 	wb->wb_sdmmc_dev = config_found(wb->wb_dev, , NULL);
 }
@@ -268,7 +266,7 @@ wb_sdmmc_write_protect(sdmmc_chipset_han
 static int
 wb_sdmmc_bus_power(sdmmc_chipset_handle_t sch, uint32_t ocr)
 {
-	REPORT(sch, "TRACE: sdmmc/bus_power(wb, ocr=%d)\n", ocr);
+	REPORT(sch, "TRACE: sdmmc/bus_power(wb, ocr=%x)\n", ocr);
 
 	return 0;
 }
@@ -334,10 +332,19 @@ wb_sdmmc_rsp_read_long(struct wb_softc *
 	}
 
 	for (i = 12; i >= 0; i -= 4) {
+#if BYTE_ORDER == LITTLE_ENDIAN
 		p[3] = wb_idx_read(wb, WB_INDEX_RESP(i + 0));
 		p[2] = wb_idx_read(wb, WB_INDEX_RESP(i + 1));
 		p[1] = wb_idx_read(wb, WB_INDEX_RESP(i + 2));
 		p[0] = wb_idx_read(wb, WB_INDEX_RESP(i + 3));
+#else
+		p[0] = wb_idx_read(wb, WB_INDEX_RESP(i + 0));
+		p[1] = wb_idx_read(wb, WB_INDEX_RESP(i + 1));
+		p[2] = wb_idx_read(wb, WB_INDEX_RESP(i + 2));
+		p[3] = wb_idx_read(wb, WB_INDEX_RESP(i + 3));
+#endif
+		REPORT(wb, "TRACE: sdmmc/read_long (%d) 0x%08x\n",
+		(12 - i) / 4, cmd->c_resp[(12 - i) / 4]);
 		p += 4;
 	}
 }
@@ -352,10 +359,19 @@ wb_sdmmc_rsp_read_short(struct wb_softc 
 		return;
 	}
 
+#if BYTE_ORDER == LITTLE_ENDIAN
 	p[3] = wb_idx_read(wb, WB_INDEX_RESP(12));
 	p[2] = wb_idx_read(wb, WB_INDEX_RESP(13));
 	p[1] = wb_idx_read(wb, WB_INDEX_RESP(14));
 	p[0] = wb_idx_read(wb, WB_INDEX_RESP(15));
+#else
+	p[0] = wb_idx_read(wb, WB_INDEX_RESP(12));
+	p[1] = wb_idx_read(wb, WB_INDEX_RESP(13));
+	p[2] = wb_idx_read(wb, WB_INDEX_RESP(14));
+	p[3] = wb_idx_read(wb, WB_INDEX_RESP(15));
+#endif
+	REPORT(wb, "TRACE: sdmmc/read_short 0x%08x\n",
+	cmd->c_resp[0]);
 }
 
 static int
@@ -430,8 +446,9 @@ wb_sdmmc_exec_command(sdmmc_chipset_hand
 	int s;
 
 	REPORT(wb, "TRACE: sdmmc/exec_command(wb, cmd) "
-	

CVS commit: src/sys/dev/sdmmc

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 09:51:47 UTC 2020

Modified Files:
src/sys/dev/sdmmc: sdmmc_mem.c

Log Message:
If the controller doesn't support switch func (opcode 6) then skip
setting this but continue with other settings.  This allows us to use
a card, albeit at a lower speed.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/sdmmc/sdmmc_mem.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/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.71 src/sys/dev/sdmmc/sdmmc_mem.c:1.72
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.71	Sat Jan  4 22:28:26 2020
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Mon May 11 09:51:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_mem.c,v 1.71 2020/01/04 22:28:26 mlelstv Exp $	*/
+/*	$NetBSD: sdmmc_mem.c,v 1.72 2020/05/11 09:51:47 jdc Exp $	*/
 /*	$OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.71 2020/01/04 22:28:26 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.72 2020/05/11 09:51:47 jdc Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -833,9 +833,14 @@ sdmmc_mem_sd_init(struct sdmmc_softc *sc
 		DPRINTF(("%s: switch func mode 0\n", SDMMCDEVNAME(sc)));
 		error = sdmmc_mem_sd_switch(sf, 0, 1, 0, );
 		if (error) {
-			aprint_error_dev(sc->sc_dev,
-			"switch func mode 0 failed\n");
-			return error;
+			if (error == ENOTSUP) {
+/* Not supported by controller */
+goto skipswitchfuncs;
+			} else {
+aprint_error_dev(sc->sc_dev,
+"switch func mode 0 failed\n");
+return error;
+			}
 		}
 
 		support_func = SFUNC_STATUS_GROUP(, 1);
@@ -887,6 +892,7 @@ sdmmc_mem_sd_init(struct sdmmc_softc *sc
 			delay(25);
 		}
 	}
+skipswitchfuncs:
 
 	/* update bus clock */
 	if (sc->sc_busclk > sf->csd.tran_speed)



CVS commit: src/sys/dev/sun

2020-05-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun May  3 06:31:02 UTC 2020

Modified Files:
src/sys/dev/sun: disksubr.c

Log Message:
If the sector size is 0, return early in readdisklabel().
Prevents a panic trying to use a 0-sized buffer, which can happen if we run
(e.g.) `scsictl /dev/cd0c identify` with no medium in the CD drive.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sun/disksubr.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/sun/disksubr.c
diff -u src/sys/dev/sun/disksubr.c:1.16 src/sys/dev/sun/disksubr.c:1.17
--- src/sys/dev/sun/disksubr.c:1.16	Wed Apr  3 22:10:52 2019
+++ src/sys/dev/sun/disksubr.c	Sun May  3 06:31:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $ */
+/*	$NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $");
 
 #include 
 #include 
@@ -104,6 +104,8 @@ readdisklabel(dev_t dev, void (*strat)(s
 			lp->d_partitions[RAW_PART].p_size = 0x1fff;
 		lp->d_partitions[RAW_PART].p_offset = 0;
 	}
+	if (lp->d_secsize == 0)
+		return ("sector size 0");
 
 	/* obtain buffer to probe drive with */
 	bp = geteblk((int)lp->d_secsize);



CVS commit: src/sys/dev/scsipi

2020-05-02 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat May  2 06:45:53 UTC 2020

Modified Files:
src/sys/dev/scsipi: scsiconf.c

Log Message:
Don't attempt to read opcodes and their timeouts at attach time for
old devices.  The MAINTENANCE IN command was introduced with SCSI-3
and sending it to older peripherals can cause timeouts or them not
to respond to further requests.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.286 src/sys/dev/scsipi/scsiconf.c:1.287
--- src/sys/dev/scsipi/scsiconf.c:1.286	Wed Feb 19 16:04:39 2020
+++ src/sys/dev/scsipi/scsiconf.c	Sat May  2 06:45:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.286 2020/02/19 16:04:39 riastradh Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.287 2020/05/02 06:45:53 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.286 2020/02/19 16:04:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.287 2020/05/02 06:45:53 jdc Exp $");
 
 #include 
 #include 
@@ -1018,10 +1018,14 @@ scsi_probe_device(struct scsibus_softc *
 		scsipi_insert_periph(chan, periph);
 
 		/*
-		 * determine supported opcodes and
-		 * timeouts if available
+		 * Determine supported opcodes and timeouts if available.
+		 * Only do this on peripherals reporting SCSI version 3
+		 * or greater - this command isn't in the SCSI-2 spec. and
+		 * it causes either timeouts or peripherals disappearing
+		 * when sent to some SCSI-1 or SCSI-2 peripherals.
 		 */
-		scsipi_get_opcodeinfo(periph);
+		if (periph->periph_version >= 3)
+			scsipi_get_opcodeinfo(periph);
 
 		/*
 		 * XXX Can't assign periph_dev here, because we'll



CVS commit: src/sys/dev/i2c

2019-12-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 11 21:00:11 UTC 2019

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

Log Message:
Chip matching improvements:
  only match for currently known addresses
  don't generate messages when matching
Tested on Sun Blade 2500 by martin@.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/adm1026.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/adm1026reg.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/i2c/adm1026.c
diff -u src/sys/dev/i2c/adm1026.c:1.5 src/sys/dev/i2c/adm1026.c:1.6
--- src/sys/dev/i2c/adm1026.c:1.5	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/adm1026.c	Wed Dec 11 21:00:11 2019
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.5 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.6 2019/12/11 21:00:11 jdc Exp $");
 
 #include 
 #include 
@@ -99,11 +99,11 @@ struct adm1026_softc {
 };
 
 static int adm1026_match(device_t, cfdata_t, void *);
-static int adm1026_ident(struct adm1026_softc *sc);
+static int adm1026_ident(struct adm1026_softc *, int);
 static void adm1026_attach(device_t, device_t, void *);
 static int adm1026_detach(device_t, int);
-bool adm1026_pmf_suspend(device_t dev, const pmf_qual_t *qual);
-bool adm1026_pmf_resume(device_t dev, const pmf_qual_t *qual);
+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);
@@ -141,15 +141,14 @@ adm1026_match(device_t parent, cfdata_t 
 	if (iic_use_direct_match(ia, cf, compat_data, _result))
 		return match_result;
 
-	if ((ia->ia_addr & ADM1026_ADDRMASK) == ADM1026_ADDR &&
-	adm1026_ident())
+	if (ia->ia_addr == ADM1026_ADDR1 && adm1026_ident(, 1))
 		return I2C_MATCH_ADDRESS_AND_PROBE;
 
 	return 0;
 }
 
 static int
-adm1026_ident(struct adm1026_softc *sc)
+adm1026_ident(struct adm1026_softc *sc, int probe_only)
 {
 	uint8_t val;
 	int err;
@@ -157,14 +156,16 @@ adm1026_ident(struct adm1026_softc *sc)
 	/* Manufacturer ID and revision/stepping */
 	err = adm1026_read_reg(sc, ADM1026_ID, );
 	if (err || val != ADM1026_MANF_ID) {
-		aprint_verbose("adm1026_ident: "
-		"manufacturer ID invalid or missing\n");
+		if (!probe_only)
+			aprint_verbose("adm1026_ident: "
+			"manufacturer ID invalid or missing\n");
 		return 0;
 	}
 	err = adm1026_read_reg(sc, ADM1026_REV, >sc_rev);
 	if (err || ADM1026_REVISION(sc->sc_rev) != ADM1026_MANF_REV) {
-		aprint_verbose("adm1026_ident: "
-		"manufacturer revision invalid or missing\n");
+		if (!probe_only)
+			aprint_verbose("adm1026_ident: "
+			"manufacturer revision invalid or missing\n");
 		return 0;
 	}
 	return 1;
@@ -191,7 +192,7 @@ adm1026_attach(device_t parent, device_t
 	else
 		div2_val = -1;
 
-	(void) adm1026_ident(sc);
+	(void) adm1026_ident(sc, 0);
 	aprint_normal(": ADM1026 hardware monitor: rev. 0x%x, step. 0x%x\n",
 	ADM1026_REVISION(sc->sc_rev), ADM1026_STEPPING(sc->sc_rev));
 

Index: src/sys/dev/i2c/adm1026reg.h
diff -u src/sys/dev/i2c/adm1026reg.h:1.2 src/sys/dev/i2c/adm1026reg.h:1.3
--- src/sys/dev/i2c/adm1026reg.h:1.2	Sun Oct 13 07:44:51 2019
+++ src/sys/dev/i2c/adm1026reg.h	Wed Dec 11 21:00:11 2019
@@ -37,10 +37,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1026reg.h,v 1.2 2019/10/13 07:44:51 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026reg.h,v 1.3 2019/12/11 21:00:11 jdc Exp $");
 
-#define	ADM1026_ADDRMASK	0x2f	/* 010 11xx */
-#define ADM1026_ADDR		0x2c
+#define ADM1026_ADDR1		0x2c
 
 #define ADM1026_CONF1		0x00
 #define ADM1026_CONF2		0x01



CVS commit: src/sys/arch/sandpoint/sandpoint

2019-04-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Apr  7 15:44:44 UTC 2019

Modified Files:
src/sys/arch/sandpoint/sandpoint: com_eumb.c

Log Message:
Call com_init_regs() in eumbcnattach() to set up com port register mapping.
Fixes broken console output after changes to remove COM_REGMAP.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/sandpoint/com_eumb.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/sandpoint/sandpoint/com_eumb.c
diff -u src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.9 src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.10
--- src/sys/arch/sandpoint/sandpoint/com_eumb.c:1.9	Sat Dec  8 17:46:12 2018
+++ src/sys/arch/sandpoint/sandpoint/com_eumb.c	Sun Apr  7 15:44:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: com_eumb.c,v 1.9 2018/12/08 17:46:12 thorpej Exp $ */
+/* $NetBSD: com_eumb.c,v 1.10 2019/04/07 15:44:44 jdc Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_eumb.c,v 1.9 2018/12/08 17:46:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_eumb.c,v 1.10 2019/04/07 15:44:44 jdc Exp $");
 
 #include 
 #include 
@@ -111,6 +111,9 @@ eumbcnattach(bus_space_tag_t tag,
 int conaddr, int conspeed, int confreq, int contype, int conmode)
 {
 	static int attached = 0;
+	bus_space_handle_t dummy_bsh; /* XXX see com.c:comcnattach() */
+
+	memset(_bsh, 0, sizeof(dummy_bsh));
 
 	if (attached)
 		return 0;
@@ -119,5 +122,6 @@ eumbcnattach(bus_space_tag_t tag,
 	cnregs.cr_iot = tag;
 	cnregs.cr_iobase = conaddr;
 	cnregs.cr_nports = COM_NPORTS;
+	com_init_regs(, tag, dummy_bsh, conaddr);
 	return comcnattach1(, conspeed, confreq, contype, conmode);
 }



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

2018-03-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 26 10:54:31 UTC 2018

Modified Files:
src/share/man/man4/man4.sparc64: ffb.4

Log Message:
Note that EDID is only read on series 2 and 3 cards.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/man4.sparc64/ffb.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.sparc64/ffb.4
diff -u src/share/man/man4/man4.sparc64/ffb.4:1.2 src/share/man/man4/man4.sparc64/ffb.4:1.3
--- src/share/man/man4/man4.sparc64/ffb.4:1.2	Sat Apr  9 21:53:58 2011
+++ src/share/man/man4/man4.sparc64/ffb.4	Mon Mar 26 10:54:31 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ffb.4,v 1.2 2011/04/09 21:53:58 wiz Exp $
+.\"	$NetBSD: ffb.4,v 1.3 2018/03/26 10:54:31 jdc Exp $
 .\"
 .\" Copyright (c) 2011 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -156,8 +156,12 @@ The
 .Nm
 driver supports reading
 .Dv EDID
-data from connected monitors, and will automatically set a resolution that is
-supported by both the card and the monitor if the
+data from connected monitors on
+.Sq Series 2
+and
+.Sq Series 3
+cards, and will automatically set a resolution that is supported by both the
+card and the monitor if the
 .Dv EDID
 data can be read.
 This can be overridden for the console frame buffer, by setting the



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

2018-03-26 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Mar 26 10:31:10 UTC 2018

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

Log Message:
Correct a typo in the openprom variable name.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc64/dev/ffb.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/ffb.c
diff -u src/sys/arch/sparc64/dev/ffb.c:1.61 src/sys/arch/sparc64/dev/ffb.c:1.62
--- src/sys/arch/sparc64/dev/ffb.c:1.61	Fri May 19 19:25:53 2017
+++ src/sys/arch/sparc64/dev/ffb.c	Mon Mar 26 10:31:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffb.c,v 1.61 2017/05/19 19:25:53 macallan Exp $	*/
+/*	$NetBSD: ffb.c,v 1.62 2018/03/26 10:31:10 jdc Exp $	*/
 /*	$OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.61 2017/05/19 19:25:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.62 2018/03/26 10:31:10 jdc Exp $");
 
 #include 
 #include 
@@ -260,7 +260,7 @@ ffb_attach(device_t self)
 
 	/* Check if a console resolution ":r" is set. */
 	if (sc->sc_console) {
-		out_dev = prom_getpropstring(sc->sc_node, "output_device");
+		out_dev = prom_getpropstring(sc->sc_node, "output-device");
 		if (out_dev != NULL && strlen(out_dev) != 0 &&
 		strstr(out_dev, ":r") != NULL)
 			try_edid = 0;



CVS commit: src/sys/dev/ic

2016-05-17 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue May 17 14:44:53 UTC 2016

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

Log Message:
PR kern/46083

Track the start of each packet, so that we set the "Start of Frame" bit in
all the relevant transmit descriptors when enqueing multiple packets.

Patch from Valery Ushakov, slightly modified by me to handle debug output.

Tested on macppc/6.x and sparc64/7.99.x.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/ic/gem.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/gem.c
diff -u src/sys/dev/ic/gem.c:1.104 src/sys/dev/ic/gem.c:1.105
--- src/sys/dev/ic/gem.c:1.104	Tue Feb  9 08:32:10 2016
+++ src/sys/dev/ic/gem.c	Tue May 17 14:44:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: gem.c,v 1.104 2016/02/09 08:32:10 ozaki-r Exp $ */
+/*	$NetBSD: gem.c,v 1.105 2016/05/17 14:44:53 jdc Exp $ */
 
 /*
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.104 2016/02/09 08:32:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.105 2016/05/17 14:44:53 jdc Exp $");
 
 #include "opt_inet.h"
 
@@ -1362,6 +1362,9 @@ gem_start(struct ifnet *ifp)
 	struct gem_txsoft *txs;
 	bus_dmamap_t dmamap;
 	int error, firsttx, nexttx = -1, lasttx = -1, ofree, seg;
+#ifdef GEM_DEBUG
+	int otxnext;
+#endif
 	uint64_t flags = 0;
 
 	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
@@ -1372,10 +1375,12 @@ gem_start(struct ifnet *ifp)
 	 * the first descriptor we'll use.
 	 */
 	ofree = sc->sc_txfree;
-	firsttx = sc->sc_txnext;
+#ifdef GEM_DEBUG
+	otxnext = sc->sc_txnext;
+#endif
 
 	DPRINTF(sc, ("%s: gem_start: txfree %d, txnext %d\n",
-	device_xname(sc->sc_dev), ofree, firsttx));
+	device_xname(sc->sc_dev), ofree, otxnext));
 
 	/*
 	 * Loop through the send queue, setting up transmit descriptors
@@ -1480,7 +1485,8 @@ gem_start(struct ifnet *ifp)
 		/*
 		 * Initialize the transmit descriptors.
 		 */
-		for (nexttx = sc->sc_txnext, seg = 0;
+		firsttx = sc->sc_txnext;
+		for (nexttx = firsttx, seg = 0;
 		 seg < dmamap->dm_nsegs;
 		 seg++, nexttx = GEM_NEXTTX(nexttx)) {
 
@@ -1602,7 +1608,7 @@ gem_start(struct ifnet *ifp)
 
 	if (sc->sc_txfree != ofree) {
 		DPRINTF(sc, ("%s: packets enqueued, IC on %d, OWN on %d\n",
-		device_xname(sc->sc_dev), lasttx, firsttx));
+		device_xname(sc->sc_dev), lasttx, otxnext));
 		/*
 		 * The entire packet chain is set up.
 		 * Kick the transmitter.



CVS commit: src/sys/dev/ic

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:24:56 UTC 2016

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

Log Message:
Always take the bus lock (avoids collisions when drivers set I2C_F_POLL).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/pcf8584.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/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.14 src/sys/dev/ic/pcf8584.c:1.15
--- src/sys/dev/ic/pcf8584.c:1.14	Mon Jan  4 10:00:33 2016
+++ src/sys/dev/ic/pcf8584.c	Mon Jan 11 18:24:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.14 2016/01/04 10:00:33 jdc Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.15 2016/01/11 18:24:56 jdc Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -116,9 +116,6 @@ pcfiic_i2c_acquire_bus(void *arg, int fl
 {
 	struct pcfiic_softc	*sc = arg;
 
-	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
-		return (0);
-
 	rw_enter(>sc_lock, RW_WRITER);
 	return 0;
 }
@@ -128,9 +125,6 @@ pcfiic_i2c_release_bus(void *arg, int fl
 {
 	struct pcfiic_softc	*sc = arg;
 
-	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
-		return;
-
 	rw_exit(>sc_lock);
 }
 



CVS commit: src/sys/dev/i2c

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:23:53 UTC 2016

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

Log Message:
Increase the number of read retries (to 5).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.1 src/sys/dev/i2c/adm1026.c:1.2
--- src/sys/dev/i2c/adm1026.c:1.1	Wed Dec 16 07:56:48 2015
+++ src/sys/dev/i2c/adm1026.c	Mon Jan 11 18:23:52 2016
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.1 2015/12/16 07:56:48 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.2 2016/01/11 18:23:52 jdc Exp $");
 
 #include 
 #include 
@@ -492,7 +492,7 @@ adm1026_read_volt(struct adm1026_softc *
 static int
 adm1026_read_reg(struct adm1026_softc *sc, uint8_t reg, uint8_t *val)
 {
-#define ADM1026_READ_RETRIES	4
+#define ADM1026_READ_RETRIES	5
 	int i, j, err = 0;
 	uint8_t creg, cval, tmp[ADM1026_READ_RETRIES + 1];
 



CVS commit: src/sys/dev/i2c

2016-01-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan 11 18:23:11 UTC 2016

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

Log Message:
Don't use I2C_F_POLL when getting/setting limits.
Save/restore the correct values for LM77.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/i2c/lm75.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/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.28 src/sys/dev/i2c/lm75.c:1.29
--- src/sys/dev/i2c/lm75.c:1.28	Sun Jan  3 17:27:57 2016
+++ src/sys/dev/i2c/lm75.c	Mon Jan 11 18:23:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $	*/
+/*	$NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.29 2016/01/11 18:23:11 jdc Exp $");
 
 #include 
 #include 
@@ -206,16 +206,16 @@ lmtemp_attach(device_t parent, device_t 
 	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
 
 	/* Read temperature limit(s) and remember initial value(s). */
-	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, >sc_smax, 1)
-	!= 0) {
-		aprint_error_dev(self, "unable to read Tos register\n");
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
-		return;
-	}
-	sc->sc_tmax = sc->sc_smax;
 	if (i == lmtemp_lm77) {
+		if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT,
+		>sc_scrit, 1) != 0) {
+			aprint_error_dev(self,
+			"unable to read low register\n");
+			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			return;
+		}
 		if (lmtemp_temp_read(sc, LM77_REG_TLOW_SET_POINT,
-		>sc_smax, 1) != 0) {
+		>sc_smin, 1) != 0) {
 			aprint_error_dev(self,
 			"unable to read low register\n");
 			iic_release_bus(sc->sc_tag, I2C_F_POLL);
@@ -228,7 +228,15 @@ lmtemp_attach(device_t parent, device_t 
 			iic_release_bus(sc->sc_tag, I2C_F_POLL);
 			return;
 		}
+	} else {	/* LM75 or compatible */
+		if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT,
+		>sc_smax, 1) != 0) {
+			aprint_error_dev(self, "unable to read Tos register\n");
+			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			return;
+		}
 	}
+	sc->sc_tmax = sc->sc_smax;
 
 	if (i == lmtemp_lm75)
 		lmtemp_setup_sysctl(sc);
@@ -349,12 +357,12 @@ lmtemp_getlim_lm75(struct sysmon_envsys 
 
 	*props &= ~(PROP_CRITMAX);
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, , 0) == 0) {
 		limits->sel_critmax = val;
 		*props |= PROP_CRITMAX;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -366,7 +374,7 @@ lmtemp_getlim_lm77(struct sysmon_envsys 
 
 	*props &= ~(PROP_CRITMAX | PROP_WARNMAX | PROP_WARNMIN);
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (lmtemp_temp_read(sc, LM77_REG_TCRIT_SET_POINT, , 0) == 0) {
 		limits->sel_critmax = val;
 		*props |= PROP_CRITMAX;
@@ -379,7 +387,7 @@ lmtemp_getlim_lm77(struct sysmon_envsys 
 		limits->sel_warnmin = val;
 		*props |= PROP_WARNMIN;
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static void
@@ -394,11 +402,11 @@ lmtemp_setlim_lm75(struct sysmon_envsys 
 			limit = sc->sc_smax;
 		else
 			limit = limits->sel_critmax;
-		iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+		iic_acquire_bus(sc->sc_tag, 0);
 		lmtemp_temp_write(sc, LM75_REG_THYST_SET_POINT,
 		limit - 500, 0);
 		lmtemp_temp_write(sc, LM75_REG_TOS_SET_POINT, limit, 0);
-		iic_release_bus(sc->sc_tag, I2C_F_POLL);
+		iic_release_bus(sc->sc_tag, 0);
 
 		/* Synchronise sysctl */
 		sc->sc_tmax = (limit - 27315) / 100;
@@ -412,10 +420,10 @@ lmtemp_setlim_lm77(struct sysmon_envsys 
 	struct lmtemp_softc *sc = sme->sme_cookie;
 	int32_t limit;
 
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+	iic_acquire_bus(sc->sc_tag, 0);
 	if (*props & PROP_CRITMAX) {
 		if (limits == NULL)	/* Restore defaults */
-			limit = sc->sc_smax;
+			limit = sc->sc_scrit;
 		else
 			limit = limits->sel_critmax;
 		lmtemp_temp_write(sc, LM77_REG_TCRIT_SET_POINT, limit, 0);
@@ -429,12 +437,12 @@ lmtemp_setlim_lm77(struct sysmon_envsys 
 	}
 	if (*props & PROP_WARNMIN) {
 		if (limits == NULL)	/* Restore defaults */
-			limit = sc->sc_smax;
+			limit = sc->sc_smin;
 		else
 			limit = limits->sel_warnmin;
 		lmtemp_temp_write(sc, LM77_REG_TLOW_SET_POINT, limit, 0);
 	}
-	iic_release_bus(sc->sc_tag, I2C_F_POLL);
+	iic_release_bus(sc->sc_tag, 0);
 }
 
 static uint32_t



CVS commit: src/lib/libcurses

2016-01-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan 10 08:11:07 UTC 2016

Modified Files:
src/lib/libcurses: refresh.c

Log Message:
Clear the "forced" flag after updating a line, otherwise we'll always do
complete line redraws.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/lib/libcurses/refresh.c

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

Modified files:

Index: src/lib/libcurses/refresh.c
diff -u src/lib/libcurses/refresh.c:1.79 src/lib/libcurses/refresh.c:1.80
--- src/lib/libcurses/refresh.c:1.79	Thu Feb 20 09:42:42 2014
+++ src/lib/libcurses/refresh.c	Sun Jan 10 08:11:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: refresh.c,v 1.79 2014/02/20 09:42:42 blymn Exp $	*/
+/*	$NetBSD: refresh.c,v 1.80 2016/01/10 08:11:06 jdc Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c	8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.79 2014/02/20 09:42:42 blymn Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.80 2016/01/10 08:11:06 jdc Exp $");
 #endif
 #endif/* not lint */
 
@@ -396,7 +396,7 @@ _cursesi_wnoutrefresh(SCREEN *screen, WI
 	"_wnoutrefresh: "
 	"line %d notdirty\n", wy);
 #endif
-	wlp->flags &= ~__ISDIRTY;
+	wlp->flags &= ~(__ISDIRTY | __ISFORCED);
 }
 			}
 		}



CVS commit: src/sys/dev/i2c

2016-01-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan 10 14:03:11 UTC 2016

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

Log Message:
Correct previous - external temperature 2 is read from the 2.5V register,
not the Vccp2 register.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/lm87.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/lm87.c
diff -u src/sys/dev/i2c/lm87.c:1.6 src/sys/dev/i2c/lm87.c:1.7
--- src/sys/dev/i2c/lm87.c:1.6	Sun Jan 10 10:20:08 2016
+++ src/sys/dev/i2c/lm87.c	Sun Jan 10 14:03:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm87.c,v 1.6 2016/01/10 10:20:08 jdc Exp $	*/
+/*	$NetBSD: lm87.c,v 1.7 2016/01/10 14:03:11 jdc Exp $	*/
 /*	$OpenBSD: lm87.c,v 1.20 2008/11/10 05:19:48 cnst Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.6 2016/01/10 10:20:08 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.7 2016/01/10 14:03:11 jdc Exp $");
 
 #include 
 #include 
@@ -121,7 +121,7 @@ struct lmenv_softc {
 
 	int	sc_fan1_div, sc_fan2_div;
 	int	sc_family;
-	int	sc_channel;
+	uint8_t	sc_channel;
 
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t sc_sensor[LMENV_NUM_SENSORS];
@@ -271,9 +271,15 @@ lmenv_attach(device_t parent, device_t s
 
 	/* Initialize sensor data. */
 	sc->sc_sensor[LMENV_2_5V].state = ENVSYS_SINVALID;
-	sc->sc_sensor[LMENV_2_5V].units = ENVSYS_SVOLTS_DC;
-	strlcpy(sc->sc_sensor[LMENV_2_5V].desc, "+2.5Vin",
-	sizeof(sc->sc_sensor[LMENV_2_5V].desc));
+	if (sc->sc_channel & LM87_CHANNEL_TEMP2) {
+		sc->sc_sensor[LMENV_INT_TEMP].units = ENVSYS_STEMP;
+		strlcpy(sc->sc_sensor[LMENV_2_5V].desc, "External 2",
+		sizeof(sc->sc_sensor[LMENV_2_5V].desc));
+	} else {
+		sc->sc_sensor[LMENV_2_5V].units = ENVSYS_SVOLTS_DC;
+		strlcpy(sc->sc_sensor[LMENV_2_5V].desc, "+2.5Vin",
+		sizeof(sc->sc_sensor[LMENV_2_5V].desc));
+	}
 
 	sc->sc_sensor[LMENV_VCCP1].state = ENVSYS_SINVALID;
 	sc->sc_sensor[LMENV_VCCP1].units = ENVSYS_SVOLTS_DC;
@@ -296,11 +302,7 @@ lmenv_attach(device_t parent, device_t s
 	sizeof(sc->sc_sensor[LMENV_12V].desc));
 
 	sc->sc_sensor[LMENV_VCCP2].state = ENVSYS_SINVALID;
-	if (sc->sc_channel & LM87_CHANNEL_TEMP2) {
-		sc->sc_sensor[LMENV_INT_TEMP].units = ENVSYS_STEMP;
-		strlcpy(sc->sc_sensor[LMENV_VCCP2].desc, "External 2",
-		sizeof(sc->sc_sensor[LMENV_VCCP2].desc));
-	} else {
+	if (!(sc->sc_channel & LM87_CHANNEL_TEMP2)) {
 		sc->sc_sensor[LMENV_VCCP2].units = ENVSYS_SVOLTS_DC;
 		strlcpy(sc->sc_sensor[LMENV_VCCP2].desc, "Vccp2",
 		sizeof(sc->sc_sensor[LMENV_VCCP2].desc));
@@ -380,9 +382,15 @@ lmenv_refresh(struct sysmon_envsys *sme,
 
 	switch (edata->sensor) {
 	case LMENV_2_5V:
-		/* If monitoring external temperature 2, this isn't monitored */
+		/* Might be external temperature 2 */
 		if (sc->sc_channel & LM87_CHANNEL_TEMP2) {
-			edata->state = ENVSYS_SINVALID;
+			if (data == 0x80)
+edata->state = ENVSYS_SINVALID;
+			else {
+edata->value_cur =
+(int8_t)data * 100 + 27315;
+edata->state = ENVSYS_SVALID;
+			}
 			break;
 		}
 		edata->value_cur = 250 * data / 192;
@@ -401,15 +409,9 @@ lmenv_refresh(struct sysmon_envsys *sme,
 		edata->state = ENVSYS_SVALID;
 		break;
 	case LMENV_VCCP2:
-		/* Might be external temperature 2 */
+		/* If monitoring external temperature 2, this isn't monitored */
 		if (sc->sc_channel & LM87_CHANNEL_TEMP2) {
-			if (data == 0x80)
-edata->state = ENVSYS_SINVALID;
-			else {
-edata->value_cur =
-(int8_t)data * 100 + 27315;
-edata->state = ENVSYS_SVALID;
-			}
+			edata->state = ENVSYS_SINVALID;
 			break;
 		}
 		edata->value_cur = 270 * data / 192;



CVS commit: src/sys/dev/i2c

2016-01-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan 10 10:20:08 UTC 2016

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

Log Message:
Add missing register definitions.
Handle LM87 external temperature 2 input, and Vcc input scaling (5V or 3.3V).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/lm87.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/lm87.c
diff -u src/sys/dev/i2c/lm87.c:1.5 src/sys/dev/i2c/lm87.c:1.6
--- src/sys/dev/i2c/lm87.c:1.5	Sun Sep 27 13:02:21 2015
+++ src/sys/dev/i2c/lm87.c	Sun Jan 10 10:20:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm87.c,v 1.5 2015/09/27 13:02:21 phx Exp $	*/
+/*	$NetBSD: lm87.c,v 1.6 2016/01/10 10:20:08 jdc Exp $	*/
 /*	$OpenBSD: lm87.c,v 1.20 2008/11/10 05:19:48 cnst Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.5 2015/09/27 13:02:21 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.6 2016/01/10 10:20:08 jdc Exp $");
 
 #include 
 #include 
@@ -28,25 +28,66 @@ __KERNEL_RCSID(0, "$NetBSD: lm87.c,v 1.5
 #include 
 
 /* LM87 registers */
-#define LM87_2_5V	0x20
-#define LM87_VCCP1	0x21
-#define LM87_VCC	0x22
-#define LM87_5V		0x23
-#define LM87_12V	0x24
-#define LM87_VCCP2	0x25
-#define LM87_EXT_TEMP	0x26
-#define LM87_INT_TEMP	0x27
-#define LM87_FAN1	0x28
-#define LM87_FAN2	0x29
-#define LM87_COMPANY_ID	0x3e
-#define LM87_REVISION	0x3f
-#define LM87_CONFIG1	0x40
+#define LM87_INT_HHIGH_L	0x13	/* Hardware int high limit (lockable) */
+#define LM87_EXT_HHIGH_L	0x14	/* Hardware ext high limit (lockable) */
+#define LM87_TEST		0x15
+#define LM87_CHANNEL		0x16	/* Dual purpose pin and scaling */
+#define LM87_INT_HHIGH		0x17	/* Hardware int temp high limit */
+#define LM87_EXT_HHIGH		0x18	/* Hardware ext temp high limit */
+#define LM87_DAC_DATA		0x19	/* DAC output scaling */
+#define LM87_AIN1_LOW		0x1a	/* Analog in 1 low limit */
+#define LM87_AIN2_LOW		0x1b	/* Analog in 2 low limit */
+#define LM87_2_5V		0x20	/* +2.5V or ext temp 2 reading */
+#define LM87_VCCP1		0x21	/* Vccp1 reading */
+#define LM87_VCC		0x22	/* +Vcc reading */
+#define LM87_5V			0x23	/* +5V reading */
+#define LM87_12V		0x24	/* +12V reading */
+#define LM87_VCCP2		0x25	/* Vccp2 reading */
+#define LM87_EXT_TEMP		0x26	/* External tempurature 1 reading */
+#define LM87_INT_TEMP		0x27	/* Internal temperature reading */
+#define LM87_FAN1		0x28	/* Fan1 or AIN1 reading */
+#define LM87_FAN2		0x29	/* Fan2 or AIN2 reading */
+#define LM87_2_5V_HIGH		0x2b	/* +2.5V or ext temp 2 high limit */
+#define LM87_2_5V_LOW		0x2c	/* +2.5V or ext temp 2 low limit */
+#define LM87_VCCP1_HIGH		0x2d	/* Vccp1 high limit */
+#define LM87_VCCP1_LOW		0x2e	/* Vccp1 low limit */
+#define LM87_VCC_HIGH		0x2f	/* +3.3V (Vcc) high limit */
+#define LM87_VCC_LOW		0x30	/* +3.3V (Vcc) low limit */
+#define LM87_5V_HIGH		0x31	/* +5V high limit */
+#define LM87_5V_LOW		0x32	/* +5V low limit */
+#define LM87_12V_HIGH		0x33	/* +12V high limit */
+#define LM87_12V_LOW		0x34	/* +12V low limit */
+#define LM87_VCCP2_HIGH		0x35	/* Vccp2 high limit */
+#define LM87_VCCP2_LOW		0x36	/* Vccp2 low limit */
+#define LM87_EXT_HIGH		0x37	/* External tempurature 1 high limit */
+#define LM87_EXT_LOW		0x38	/* External tempurature low limit */
+#define LM87_INT_HIGH		0x39	/* Internal tempurature 1 high limit */
+#define LM87_INT_LOW		0x3a	/* Internal tempurature low limit */
+#define LM87_FAN1_HIGH		0x3b	/* Fan 1 count or AIN1 high limit */
+#define LM87_FAN2_HIGH		0x3c	/* Fan 2 count or AIN2 high limit */
+#define LM87_COMPANY_ID		0x3e	/* Company ID */
+#define LM87_REVISION		0x3f	/* Revision */
+#define LM87_CONFIG1		0x40	/* Configuration 1 */
+#define LM87_INT_STAT1		0x41	/* Interrupt status 1 */
+#define LM87_INT_STAT2		0x42	/* Interrupt status 2 */
+#define LM87_INT_MASK1		0x43	/* Interrupt mask 1 */
+#define LM87_INT_MASK2		0x44	/* Interrupt mask 2 */
+#define LM87_CI_CLEAR		0x46	/* Chassis intrusion */
+#define LM87_FANDIV		0x47	/* Fan divisor + VID 0-3 */
+#define LM87_VID4		0x48	/* VID4 */
+#define LM87_CONFIG2		0x4a	/* Configuration 2 */
+#define LM87_INT_MIRR1		0x4c	/* Interrupt status 1 mirror */
+#define LM87_INT_MIRR2		0x4d	/* Interrupt status 2 mirror */
+#define LM87_ALERT		0x80	/* SMB Alert enable */
+
+/* Register contents */
 #define  LM87_CONFIG1_START	0x01
 #define  LM87_CONFIG1_INTCLR	0x08
-#define LM87_CHANNEL	0x16
+
 #define  LM87_CHANNEL_AIN1	0x01
 #define  LM87_CHANNEL_AIN2	0x02
-#define LM87_FANDIV	0x47
+#define  LM87_CHANNEL_TEMP2	0x04
+#define  LM87_CHANNEL_VCC5	0x08
 
 struct lmenv_id {
 	u_int8_t id, family;
@@ -80,6 +121,7 @@ struct lmenv_softc {
 
 	int	sc_fan1_div, sc_fan2_div;
 	int	sc_family;
+	int	sc_channel;
 
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t sc_sensor[LMENV_NUM_SENSORS];
@@ -151,7 +193,7 @@ lmenv_attach(device_t parent, device_t s
 {
 	struct lmenv_softc *sc = device_private(self);
 	struct i2c_attach_args *ia 

CVS commit: src/lib/libcurses

2016-01-09 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jan  9 19:05:13 UTC 2016

Modified Files:
src/lib/libcurses: setterm.c

Log Message:
Remove extra new line in debugging output.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/lib/libcurses/setterm.c

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

Modified files:

Index: src/lib/libcurses/setterm.c
diff -u src/lib/libcurses/setterm.c:1.53 src/lib/libcurses/setterm.c:1.54
--- src/lib/libcurses/setterm.c:1.53	Tue Nov 24 01:59:32 2015
+++ src/lib/libcurses/setterm.c	Sat Jan  9 19:05:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: setterm.c,v 1.53 2015/11/24 01:59:32 christos Exp $	*/
+/*	$NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setterm.c	8.8 (Berkeley) 10/25/94";
 #else
-__RCSID("$NetBSD: setterm.c,v 1.53 2015/11/24 01:59:32 christos Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,7 @@ _cursesi_setterm(char *type, SCREEN *scr
 
 #ifdef DEBUG
 	__CTRACE(__CTRACE_INIT,
-	"setterm: LINES = %d, COLS = %d\n, TABSIZE = %d\n",
+	"setterm: LINES = %d, COLS = %d, TABSIZE = %d\n",
 	LINES, COLS, TABSIZE);
 #endif
 



CVS commit: src/lib/libcurses

2016-01-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jan  7 07:36:35 UTC 2016

Modified Files:
src/lib/libcurses: add_wch.c

Log Message:
Add missing new line in debug print.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libcurses/add_wch.c

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

Modified files:

Index: src/lib/libcurses/add_wch.c
diff -u src/lib/libcurses/add_wch.c:1.4 src/lib/libcurses/add_wch.c:1.5
--- src/lib/libcurses/add_wch.c:1.4	Sat Nov  9 11:16:59 2013
+++ src/lib/libcurses/add_wch.c	Thu Jan  7 07:36:35 2016
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wch.c,v 1.4 2013/11/09 11:16:59 blymn Exp $ */
+/*   $NetBSD: add_wch.c,v 1.5 2016/01/07 07:36:35 jdc Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: add_wch.c,v 1.4 2013/11/09 11:16:59 blymn Exp $");
+__RCSID("$NetBSD: add_wch.c,v 1.5 2016/01/07 07:36:35 jdc Exp $");
 #endif /* not lint */
 
 #include 
@@ -116,7 +116,7 @@ wadd_wch(WINDOW *win, const cchar_t *wch
 	for (i = 0; i < win->maxy; i++) {
 		assert(win->alines[i]->sentinel == SENTINEL_VALUE);
 	}
-	__CTRACE(__CTRACE_INPUT, "wadd_wch: win(%p)", win);
+	__CTRACE(__CTRACE_INPUT, "wadd_wch: win(%p)\n", win);
 #endif
 	lnp = win->alines[y];
 	return _cursesi_addwchar(win, , , , wch, 1);



CVS commit: src/lib/libcurses

2016-01-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jan  7 07:37:09 UTC 2016

Modified Files:
src/lib/libcurses: touchwin.c

Log Message:
Display force flag in debug print.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/touchwin.c

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

Modified files:

Index: src/lib/libcurses/touchwin.c
diff -u src/lib/libcurses/touchwin.c:1.27 src/lib/libcurses/touchwin.c:1.28
--- src/lib/libcurses/touchwin.c:1.27	Fri Dec  6 11:23:47 2013
+++ src/lib/libcurses/touchwin.c	Thu Jan  7 07:37:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: touchwin.c,v 1.27 2013/12/06 11:23:47 blymn Exp $	*/
+/*	$NetBSD: touchwin.c,v 1.28 2016/01/07 07:37:08 jdc Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)touchwin.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: touchwin.c,v 1.27 2013/12/06 11:23:47 blymn Exp $");
+__RCSID("$NetBSD: touchwin.c,v 1.28 2016/01/07 07:37:08 jdc Exp $");
 #endif
 #endif/* not lint */
 
@@ -207,8 +207,8 @@ static int
 _cursesi_touchline_force(WINDOW *win, int y, int sx, int ex, int force)
 {
 #ifdef DEBUG
-	__CTRACE(__CTRACE_LINE, "__touchline: (%p, %d, %d, %d)\n",
-	win, y, sx, ex);
+	__CTRACE(__CTRACE_LINE, "__touchline: (%p, %d, %d, %d, %d)\n",
+	win, y, sx, ex, force);
 	__CTRACE(__CTRACE_LINE, "__touchline: first = %d, last = %d\n",
 	*win->alines[y]->firstchp, *win->alines[y]->lastchp);
 #endif



CVS commit: src/sys/dev/ic

2016-01-04 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jan  4 10:00:33 UTC 2016

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

Log Message:
Redo r1.12 - process cmd and value buffers in pcfiic_xmit().
Avoids allocating a temporary buffer for writes using both buffers.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/pcf8584.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/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.13 src/sys/dev/ic/pcf8584.c:1.14
--- src/sys/dev/ic/pcf8584.c:1.13	Sun Jan  3 17:32:17 2016
+++ src/sys/dev/ic/pcf8584.c	Mon Jan  4 10:00:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.13 2016/01/03 17:32:17 jdc Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.14 2016/01/04 10:00:33 jdc Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -31,7 +31,7 @@
 #include 
 #include 
 
-/* Internal egisters */
+/* Internal registers */
 #define PCF8584_S0		0x00
 #define PCF8584_S1		0x01
 #define PCF8584_S2		0x02
@@ -44,7 +44,7 @@ int		pcfiic_i2c_exec(void *, i2c_op_t, i
 		size_t, void *, size_t, int);
 
 int		pcfiic_xmit(struct pcfiic_softc *, u_int8_t, const u_int8_t *,
-		size_t);
+		size_t, const u_int8_t *, size_t);
 int		pcfiic_recv(struct pcfiic_softc *, u_int8_t, u_int8_t *,
 		size_t);
 
@@ -157,21 +157,9 @@ pcfiic_i2c_exec(void *arg, i2c_op_t op, 
 	 * If we are reading, write address, cmdbuf, then read address, buf.
 	 */
 	if (I2C_OP_WRITE_P(op)) {
-		if (len > 0) {
-			uint8_t *tmp;
-
-			tmp = malloc(cmdlen + len, M_DEVBUF,
-			   flags & I2C_F_POLL ? M_NOWAIT : M_WAITOK);
-			if (tmp == NULL)
-return (1);
-			memcpy(tmp, cmdbuf, cmdlen);
-			memcpy(tmp + cmdlen, buf, len);
-			ret = pcfiic_xmit(sc, addr & 0x7f, tmp, cmdlen + len);
-			free(tmp, M_DEVBUF);
-		} else
-			ret = pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen);
+		ret = pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen, buf, len);
 	} else {
-		if (pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen) != 0)
+		if (pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen, NULL, 0) != 0)
 			return (1);
 		ret = pcfiic_recv(sc, addr & 0x7f, buf, len);
 	}
@@ -179,8 +167,8 @@ pcfiic_i2c_exec(void *arg, i2c_op_t op, 
 }
 
 int
-pcfiic_xmit(struct pcfiic_softc *sc, u_int8_t addr, const u_int8_t *buf,
-size_t len)
+pcfiic_xmit(struct pcfiic_softc *sc, u_int8_t addr, const u_int8_t *cmdbuf,
+size_t cmdlen, const u_int8_t *buf, size_t len)
 {
 	int			i, err = 0;
 	volatile u_int8_t	r;
@@ -191,7 +179,7 @@ pcfiic_xmit(struct pcfiic_softc *sc, u_i
 	pcfiic_write(sc, PCF8584_S0, addr << 1);
 	pcfiic_write(sc, PCF8584_S1, PCF8584_CMD_START);
 
-	for (i = 0; i <= len; i++) {
+	for (i = 0; i <= cmdlen + len; i++) {
 		if (pcfiic_wait_pin(sc, ) != 0) {
 			pcfiic_write(sc, PCF8584_S1, PCF8584_CMD_STOP);
 			return (1);
@@ -202,8 +190,10 @@ pcfiic_xmit(struct pcfiic_softc *sc, u_i
 			break;
 		}
 
-		if (i < len)
-			pcfiic_write(sc, PCF8584_S0, buf[i]);
+		if (i < cmdlen)
+			pcfiic_write(sc, PCF8584_S0, cmdbuf[i]);
+		else if (i < cmdlen + len)
+			pcfiic_write(sc, PCF8584_S0, buf[i - cmdlen]);
 	}
 	pcfiic_write(sc, PCF8584_S1, PCF8584_CMD_STOP);
 	return (err);



CVS commit: src/share/man/man4

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 21:58:17 UTC 2016

Modified Files:
src/share/man/man4: admtemp.4

Log Message:
Correct email address (pointed out by wiz@).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/admtemp.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/admtemp.4
diff -u src/share/man/man4/admtemp.4:1.5 src/share/man/man4/admtemp.4:1.6
--- src/share/man/man4/admtemp.4:1.5	Sun Jan  3 17:27:39 2016
+++ src/share/man/man4/admtemp.4	Sun Jan  3 21:58:17 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: admtemp.4,v 1.5 2016/01/03 17:27:39 jdc Exp $
+.\"	$NetBSD: admtemp.4,v 1.6 2016/01/03 21:58:17 jdc Exp $
 .\"
 .\"	$OpenBSD: admtemp.4,v 1.8 2007/05/31 19:19:48 jmc Exp $
 .\"
@@ -78,7 +78,7 @@ The
 driver was written by
 .An Theo de Raadt Aq Mt dera...@openbsd.org .
 Extended precision temperatures, and limit display and setting were added by
-.An Julian Coleman Aq Mt jcole...@netbsd.org .
+.An Julian Coleman Aq Mt j...@netbsd.org .
 .Sh BUGS
 Limit sensors occasionally read as 0xff.
 If this occurs, the



CVS commit: src/share/man/man4

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:27:39 UTC 2016

Modified Files:
src/share/man/man4: admtemp.4

Log Message:
Mention supported chips and their differences.
Mention display and setting of chip temperature limits.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/admtemp.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/admtemp.4
diff -u src/share/man/man4/admtemp.4:1.4 src/share/man/man4/admtemp.4:1.5
--- src/share/man/man4/admtemp.4:1.4	Tue Mar 18 18:20:39 2014
+++ src/share/man/man4/admtemp.4	Sun Jan  3 17:27:39 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: admtemp.4,v 1.4 2014/03/18 18:20:39 riastradh Exp $
+.\"	$NetBSD: admtemp.4,v 1.5 2016/01/03 17:27:39 jdc Exp $
 .\"
 .\"	$OpenBSD: admtemp.4,v 1.8 2007/05/31 19:19:48 jmc Exp $
 .\"
@@ -16,7 +16,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd October 29, 2008
+.Dd December 31, 2015
 .Dt ADMTEMP 4
 .Os
 .Sh NAME
@@ -29,16 +29,44 @@ The
 .Nm
 driver provides support for the Analog Devices ADM1021,
 Analog Devices ADM1023, Analog Devices ADM1032, Genesys Logic GL523SM,
-Global Mixed-mode Technology G781, Maxim 1617, and Xeon embedded
-temperature sensors.
-The device possesses internal and external temperature sensors.
-These values are made available through the
-.Xr envstat 8
-interface.
+Global Mixed-mode Technology G781, Texas Instruments LM84, Maxim 1617,
+Maxim 1617A, Philips Semiconductors NE1617A, and Xeon embedded temperature
+sensors.
+The device possesses internal and external temperature sensors, and
+programmable low and high temperature limits, with a temperature range of
+-65 to +127 degC and a resolution of 1 degC.
 .Pp
 On i386 machines, this driver also supports the Xeon embedded
 I2C temperature probes.
 In this case, however, only one temperature value is provided.
+.Pp
+Exceeding the temperature limits causes the device to assert an Alarm signal,
+which can be used by other hardware to detect critical conditions.
+.Pp
+Some sensors differ from the ADM1021, MAX1617 and NE1617A:
+.Bl -item -offset indent
+.It
+The ADM1021A, ADM1023, ADM1032, and G781 have a temperature range of 0 to
++127 degC and a resolution of 1 degC.
+.It
+The LM84 has no low temperature limits.
+.It
+The ADM1023, ADM1032, and G781 have extended precision remote temperature
+sensors, with a range of 0 to +127.875 degC and a resolution of 0.125 degC.
+.It
+The ADM1032 and G781 have additional high temperature limits with a range of
+0 to +127 degC and a resolution of 1 degC.
+If these are exceeded, a separate Therm signal is asserted.
+.El
+.Pp
+The sensor and limit values are made available through the
+.Xr envstat 8
+interface.
+For devices without additional high temperature limits, the limits that are
+displayed and set are the critical limits.
+For devices with additional high temperature limits, high and low temperature
+warning limits and high temperature critical limits are displayed and can be
+set.
 .Sh SEE ALSO
 .Xr iic 4 ,
 .Xr intro 4 ,
@@ -49,3 +77,10 @@ The
 .Nm
 driver was written by
 .An Theo de Raadt Aq Mt dera...@openbsd.org .
+Extended precision temperatures, and limit display and setting were added by
+.An Julian Coleman Aq Mt jcole...@netbsd.org .
+.Sh BUGS
+Limit sensors occasionally read as 0xff.
+If this occurs, the
+.Nm
+driver will ignore that limit.



CVS commit: src/sys/dev/i2c

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:27:26 UTC 2016

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

Log Message:
Add display and setting of chip temperature limits for envsys(4).
Different chips are recognised where possible, and the appropriate limits
are displayed/settable.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/sys/dev/i2c/adm1021.c:1.11
--- src/sys/dev/i2c/adm1021.c:1.10	Mon Dec  7 20:59:44 2015
+++ src/sys/dev/i2c/adm1021.c	Sun Jan  3 17:27:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: adm1021.c,v 1.10 2015/12/07 20:59:44 jdc Exp $ */
+/*	$NetBSD: adm1021.c,v 1.11 2016/01/03 17:27:26 jdc Exp $ */
 /*	$OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $	*/
 
 /*
@@ -17,8 +17,28 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+/*
+ * Driver for ADM1021 and compatible temperature sensors, including ADM1021,
+ * ADM1021A, ADM1023, ADM1032, GL523SM, G781, LM84, MAX1617, MAX1617A,
+ * NE1617A, and Xeon embedded temperature sensors.
+ *
+ * Some sensors differ from the ADM1021/MAX1617/NE1617A:
+ * ADM1021A ADM1023 ADM1032 G781 LM84 MAX1617A
+ *   company/revision reg  XX   X   X X
+ *   no negative temps XX   X   X
+ *   11-bit remote temp X   X   X
+ *   no low limits   X
+ *   therm (high) limitsX   X
+ *
+ * Registers 0x00 to 0x0f have separate read/write addresses, but
+ * registers 0x10 and above have the same read/write address.
+ * The 11-bit (extended) temperature consists of a separate register with
+ * 3 valid bits that are always added to the external temperature (even if
+ * the temperature is negative).
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.10 2015/12/07 20:59:44 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.11 2016/01/03 17:27:26 jdc Exp $");
 
 #include 
 #include 
@@ -27,40 +47,102 @@ __KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 
 
 #include 
 
+/* Registers */
+#define ADM1021_INT_TEMP	0x00	/* Internal temperature value */
+#define ADM1021_EXT_TEMP	0x01	/* External temperature value */
+#define ADM1021_STATUS		0x02	/* Status */
+#define ADM1021_CONFIG_READ	0x03	/* Read configuration */
+#define ADM1021_CONV_RATE_READ	0x04	/* Read conversion rate */
+#define ADM1021_INT_HIGH_READ	0x05	/* Read internal high limit */
+#define ADM1021_INT_LOW_READ	0x06	/* Read internal low limit */
+#define ADM1021_EXT_HIGH_READ	0x07	/* Read external high limit */
+#define ADM1021_EXT_LOW_READ	0x08	/* Read external low limit */
+#define ADM1021_CONFIG_WRITE	0x09	/* Write configuration */
+#define ADM1021_CONV_RATE_WRITE 0x0a	/* Write conversion rate */
+#define ADM1021_INT_HIGH_WRITE	0x0b	/* Write internal high limit */
+#define ADM1021_INT_LOW_WRITE	0x0c	/* Write internal low limit */
+#define ADM1021_EXT_HIGH_WRITE	0x0d	/* Write external high limit */
+#define ADM1021_EXT_LOW_WRITE	0x0e	/* Write external low limit */
+#define ADM1021_ONE_SHOT	0x0f	/* One shot command */
+#define ADM1023_EXT_TEMP2	0x10	/* R/W external temp low byte */
+#define ADM1023_EXT_TEMP_OFF	0x11	/* R/W external temp offset */
+#define ADM1023_EXT_TEMP_OFF2	0x12	/* R/W external temp off low byte */
+#define ADM1023_EXT_HIGH2	0x13	/* R/W external high lim low byte */
+#define ADM1023_EXT_LOW2	0x14	/* R/W external low lim low byte */
+#define ADM1032_EXT_THERM	0x19	/* R/W external Therm (high) limit */
+#define ADM1032_INT_THERM	0x20	/* R/W internal Therm (high) limit */
+#define ADM1032_THERM_HYST	0x21	/* R/W Therm hysteris */
+#define ADM1032_ALERT_QUEUE	0x22	/* R/W consecutive alert queue */
+#define ADM1021_COMPANY		0xfe	/* Company ID */
+#define ADM1021_DIE_REVISION	0xff	/* Die revision code */
 
-/* ADM 1021 registers */
-#define ADM1021_INT_TEMP	0x00
-#define ADM1021_EXT_TEMP	0x01
-#define ADM1021_STATUS		0x02
-#define ADM1021_STATUS_INVAL	0x7f
-#define ADM1021_STATUS_NOEXT	0x40
-#define ADM1021_CONFIG_READ	0x03
-#define ADM1021_CONFIG_WRITE	0x09
+/* Register values */
 #define ADM1021_CONFIG_RUN	0x40
-#define ADM1021_COMPANY		0xfe	/* contains 0x41 */
-#define ADM1021_DIE_REVISION	0xff
+
+#define ADM1021_STATUS_INVAL	0x7f
+#define ADM1021_STATUS_NOEXT	0x40	/* External diode is open-circuit */
+
+#define ADM1023_EXT2_SHIFT	5
+#define ADM1023_EXT2_MASK	0x07
+
+#define ADM1021_COMPANY_ADM	0x41	/* 'A' */
+#define ADM1021_COMPANY_GMT	0x47	/* 'G' */
+#define ADM1021_COMPANY_MAXIM	0x4d	/* 'M' */
+
+#define ADM1021_REV_1021	0x00
+#define ADM1021_REV_1021A	0x30
+#define ADM1021_REV_MASK	0xf0
 
 /* Sensors */
 #define ADMTEMP_INT		0
 #define ADMTEMP_EXT		1
 #define ADMTEMP_NUM_SENSORS	2
 
+#define ADMTEMP_MAX_NEG		-65
+#define ADMTEMP_MAX_POS		127
+#define 

CVS commit: src/sys/dev/i2c

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:28:33 UTC 2016

Modified Files:
src/sys/dev/i2c: lm75reg.h

Log Message:
Add LM75A ID register (for completeness).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/lm75reg.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/i2c/lm75reg.h
diff -u src/sys/dev/i2c/lm75reg.h:1.4 src/sys/dev/i2c/lm75reg.h:1.5
--- src/sys/dev/i2c/lm75reg.h:1.4	Wed Aug  7 19:38:45 2013
+++ src/sys/dev/i2c/lm75reg.h	Sun Jan  3 17:28:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75reg.h,v 1.4 2013/08/07 19:38:45 soren Exp $	*/
+/*	$NetBSD: lm75reg.h,v 1.5 2016/01/03 17:28:33 jdc Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -66,6 +66,7 @@
 #define	LM75_REG_CONFIG			0x01
 #define	LM75_REG_THYST_SET_POINT	0x02
 #define	LM75_REG_TOS_SET_POINT		0x03
+#define	LM75_REG_ID			0x07	/* LM75A only */
 
 #define	LM77_REG_TCRIT_SET_POINT	0x03
 #define	LM77_REG_TLOW_SET_POINT		0x04



CVS commit: src/share/man/man4

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:28:46 UTC 2016

Modified Files:
src/share/man/man4: lmtemp.4

Log Message:
Mention supported chips and their differences.
Mention display and setting of chip temperature limits.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/share/man/man4/lmtemp.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/lmtemp.4
diff -u src/share/man/man4/lmtemp.4:1.3 src/share/man/man4/lmtemp.4:1.4
--- src/share/man/man4/lmtemp.4:1.3	Mon Oct  8 17:56:59 2012
+++ src/share/man/man4/lmtemp.4	Sun Jan  3 17:28:46 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: lmtemp.4,v 1.3 2012/10/08 17:56:59 njoly Exp $
+.\"	$NetBSD: lmtemp.4,v 1.4 2016/01/03 17:28:46 jdc Exp $
 .\"
 .\" Copyright (c) 2005 KIYOHARA Takashi
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 4, 2008
+.Dd January 1, 2016
 .Dt LMTEMP 4
 .Os
 .Sh NAME
@@ -37,18 +37,13 @@ The
 .Nm
 driver provides support for the
 .Tn National Semiconductor
-LM on iicbus series temperatures and register compatible chips to be used
-with the
-.Xr envsys 4
-API.
-The
-.Nm
-supports ranges of the temperature between +125 from -55.
+LM on iicbus series temperature sensors and register compatible chips.
 .Pp
 Each device is specified by the value of the address and flags.
-.Bl -column "Temperature" "0x48 - 0x4f" "flags" -offset indent
-.It Sy "Temperature" Ta Sy "addr" Ta Sy "flags"
+.Bl -column "Device" "0x48 - 0x4f" "flags" -offset indent
+.It Sy "Device" Ta Sy "addr" Ta Sy "flags"
 .It Li "LM75" Ta "0x48 - 0x4f" Ta "0x"
+.It Li "LM75A" Ta "0x48 - 0x4f" Ta "0x"
 .It Li "DS75" Ta "0x48 - 0x4f" Ta "0x0001"
 .It Li "LM77" Ta "0x48 - 0x4b" Ta "0x0002"
 .El
@@ -56,17 +51,27 @@ Each device is specified by the value of
 Chips supported by the
 .Nm
 driver include:
-.Bl -item -offset indent
-.It
-.Tn National Semiconductor
-.Em LM75
-.It
-.Tn National Semiconductor
-.Em LM77
-.It
-.Tn Dallas Semiconductor
-.Em DS75
+.Bl -column "National Semiconductor LM75" "-55 \(en +125" "Resolution" \
+-offset indent
+.It Sy "Device" Ta Sy "Range" Ta Sy "Resolution"
+.It Li "National Semiconductor LM75" Ta "-55 \(en +125" Ta "0.5 degC"
+.It Li "Texas Instruments LM75A" Ta "-55 \(en +125" Ta "0.5 degC"
+.It Li "Dallas Semiconductor DS75" Ta "-55 \(en +125" Ta "0.0625 degC"
+.It Li "National Semiconductor LM77" Ta "-55 \(en +130" Ta "0.5 degC"
 .El
+.Pp
+The LM75, LM75A, and DS75 have a programmable high temperature limit.
+When this is exceeded, the device asserts an over-temperature output.
+.Pp
+The LM77 has programmable low and high temperature limits.
+Exceeding either of these causes the device to assert an interrupt output.
+It also has a programmable critical high temperature limit, and
+exceeding this causes the device to assert a separate critical alarm
+output.
+.Pp
+The sensor and limit values are made available through the
+.Xr envstat 8
+interface.
 .Sh SEE ALSO
 .Xr envsys 4 ,
 .Xr envstat 8



CVS commit: src/sys/dev/i2c

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:27:57 UTC 2016

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

Log Message:
Add display and setting of chip temperature limit(s) for envsys(4).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/i2c/lm75.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/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.27 src/sys/dev/i2c/lm75.c:1.28
--- src/sys/dev/i2c/lm75.c:1.27	Fri Jan  1 20:13:50 2016
+++ src/sys/dev/i2c/lm75.c	Sun Jan  3 17:27:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75.c,v 1.27 2016/01/01 20:13:50 jdc Exp $	*/
+/*	$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.27 2016/01/01 20:13:50 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.28 2016/01/03 17:27:57 jdc Exp $");
 
 #include 
 #include 
@@ -57,8 +57,10 @@ struct lmtemp_softc {
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t sc_sensor;
 	int sc_tmax;
+	uint32_t sc_smax, sc_smin, sc_scrit;
 
 	uint32_t (*sc_lmtemp_decode)(const uint8_t *, int);
+	void (*sc_lmtemp_encode)(const uint32_t, uint8_t *, int);
 };
 
 static int  lmtemp_match(device_t, cfdata_t, void *);
@@ -68,14 +70,25 @@ CFATTACH_DECL_NEW(lmtemp, sizeof(struct 
 	lmtemp_match, lmtemp_attach, NULL, NULL);
 
 static void	lmtemp_refresh(struct sysmon_envsys *, envsys_data_t *);
-
 static int	lmtemp_config_write(struct lmtemp_softc *, uint8_t);
-static int	lmtemp_temp_write(struct lmtemp_softc *, int, uint16_t);
+static int	lmtemp_temp_write(struct lmtemp_softc *, uint8_t, uint32_t,
+int);
 static int	lmtemp_temp_read(struct lmtemp_softc *, uint8_t, uint32_t *,
 int);
 static uint32_t lmtemp_decode_lm75(const uint8_t *, int);
 static uint32_t lmtemp_decode_ds75(const uint8_t *, int);
 static uint32_t lmtemp_decode_lm77(const uint8_t *, int);
+static void	lmtemp_encode_lm75(const uint32_t, uint8_t *, int);
+static void	lmtemp_encode_ds75(const uint32_t, uint8_t *, int);
+static void	lmtemp_encode_lm77(const uint32_t, uint8_t *, int);
+static void	lmtemp_getlim_lm75(struct sysmon_envsys *, envsys_data_t *,
+sysmon_envsys_lim_t *, uint32_t *);
+static void	lmtemp_getlim_lm77(struct sysmon_envsys *, envsys_data_t *,
+sysmon_envsys_lim_t *, uint32_t *);
+static void	lmtemp_setlim_lm75(struct sysmon_envsys *, envsys_data_t *,
+sysmon_envsys_lim_t *, uint32_t *);
+static void	lmtemp_setlim_lm77(struct sysmon_envsys *, envsys_data_t *,
+sysmon_envsys_lim_t *, uint32_t *);
 
 static void	lmtemp_setup_sysctl(struct lmtemp_softc *);
 static int	sysctl_lm75_temp(SYSCTLFN_ARGS);
@@ -100,16 +113,24 @@ static const struct {
 	int lmtemp_addrmask;
 	int lmtemp_addr;
 	uint32_t (*lmtemp_decode)(const uint8_t *, int);
+	void (*lmtemp_encode)(const uint32_t, uint8_t *, int);
+	void (*lmtemp_getlim)(struct sysmon_envsys *, envsys_data_t *,
+		sysmon_envsys_lim_t *, uint32_t *);
+	void (*lmtemp_setlim)(struct sysmon_envsys *, envsys_data_t *,
+		sysmon_envsys_lim_t *, uint32_t *);
 } lmtemptbl[] = {
-	{ lmtemp_lm75,	"LM75",
-	LM75_ADDRMASK,	LM75_ADDR,	lmtemp_decode_lm75 },
-	{ lmtemp_ds75,	"DS75",
-	LM75_ADDRMASK,	LM75_ADDR,	lmtemp_decode_ds75 },
-	{ lmtemp_lm77,	"LM77",
-	LM77_ADDRMASK,	LM77_ADDR,	lmtemp_decode_lm77 },
-
-	{ -1,		NULL,
-	0,			0,		NULL }
+	{ lmtemp_lm75,	"LM75",	LM75_ADDRMASK,	LM75_ADDR,
+	lmtemp_decode_lm75,	lmtemp_encode_lm75,
+	lmtemp_getlim_lm75,	lmtemp_setlim_lm75 },
+	{ lmtemp_ds75,	"DS75",	LM75_ADDRMASK,	LM75_ADDR,
+	lmtemp_decode_ds75,	lmtemp_encode_ds75,
+	lmtemp_getlim_lm75,	lmtemp_setlim_lm75 },
+	{ lmtemp_lm77,	"LM77",	LM77_ADDRMASK,	LM77_ADDR,
+	lmtemp_decode_lm77, lmtemp_encode_lm77,
+	lmtemp_getlim_lm77,	lmtemp_setlim_lm77 },
+	{ -1,		NULL,	 0,		0,
+	NULL,		NULL,
+	NULL,		NULL }
 };
 
 static int
@@ -180,15 +201,34 @@ lmtemp_attach(device_t parent, device_t 
 	}
 
 	sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode;
+	sc->sc_lmtemp_encode = lmtemptbl[i].lmtemp_encode;
 
 	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
 
-	/* Read temperature limit and remember initial value. */
-	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, >sc_tmax, 1)
+	/* Read temperature limit(s) and remember initial value(s). */
+	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, >sc_smax, 1)
 	!= 0) {
+		aprint_error_dev(self, "unable to read Tos register\n");
 		iic_release_bus(sc->sc_tag, I2C_F_POLL);
 		return;
 	}
+	sc->sc_tmax = sc->sc_smax;
+	if (i == lmtemp_lm77) {
+		if (lmtemp_temp_read(sc, LM77_REG_TLOW_SET_POINT,
+		>sc_smax, 1) != 0) {
+			aprint_error_dev(self,
+			"unable to read low register\n");
+			iic_release_bus(sc->sc_tag, I2C_F_POLL);
+			return;
+		}
+		if (lmtemp_temp_read(sc, LM77_REG_THIGH_SET_POINT,
+		>sc_smax, 1) != 0) {
+			aprint_error_dev(self,
+			"unable to read 

CVS commit: src/sys

2016-01-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jan  3 17:32:17 UTC 2016

Modified Files:
src/sys/arch/sparc64/dev: pcfiic_ebus.c
src/sys/dev/ic: pcf8584.c pcf8584reg.h pcf8584var.h

Log Message:
Remove duplicate register definitions and merge them all into pcf8584reg.h.
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/pcfiic_ebus.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/pcf8584.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/pcf8584reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/pcf8584var.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/dev/pcfiic_ebus.c
diff -u src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.4 src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.5
--- src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.4	Sun Feb  3 17:46:28 2013
+++ src/sys/arch/sparc64/dev/pcfiic_ebus.c	Sun Jan  3 17:32:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcfiic_ebus.c,v 1.4 2013/02/03 17:46:28 jdc Exp $	*/
+/*	$NetBSD: pcfiic_ebus.c,v 1.5 2016/01/03 17:32:17 jdc Exp $	*/
 /*	$OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.4 2013/02/03 17:46:28 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.5 2016/01/03 17:32:17 jdc Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.
 #include 
 
 #include 
+#include 
 
 int	pcfiic_ebus_match(device_t, struct cfdata *, void *);
 void	pcfiic_ebus_attach(device_t, device_t, void *);
@@ -94,7 +95,7 @@ pcfiic_ebus_attach(device_t parent, devi
 	struct ebus_attach_args		*ea = aux;
 	charcompat[32];
 	u_int64_t			addr;
-	u_int8_t			clock = PCF_CLOCK_12 | PCF_FREQ_90;
+	u_int8_t			clock = PCF8584_CLK_12 | PCF8584_SCL_90;
 	intswapregs = 0;
 
 	if (ea->ea_nreg < 1 || ea->ea_nreg > 2) {
@@ -113,9 +114,9 @@ pcfiic_ebus_attach(device_t parent, devi
 		int clk = prom_getpropint(findroot(), "clock-frequency", 0);
 
 		if (clk < 10500)
-			clock = PCF_CLOCK_3 | PCF_FREQ_90;
+			clock = PCF8584_CLK_3 | PCF8584_SCL_90;
 		else if (clk < 16000)
-			clock = PCF_CLOCK_4_43 | PCF_FREQ_90;
+			clock = PCF8584_CLK_4_43 | PCF8584_SCL_90;
 		swapregs = 1;
 	}
 
@@ -161,10 +162,10 @@ pcfiic_ebus_attach(device_t parent, devi
 
 	if (strcmp(ea->ea_name, "SUNW,envctrl") == 0) {
 		envctrl_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF_CLOCK_12 | PCF_FREQ_45, 0);
+		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
 	} else if (strcmp(ea->ea_name, "SUNW,envctrltwo") == 0) {
 		envctrltwo_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF_CLOCK_12 | PCF_FREQ_45, 0);
+		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
 	} else
 		pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), clock, swapregs);
 }

Index: src/sys/dev/ic/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.12 src/sys/dev/ic/pcf8584.c:1.13
--- src/sys/dev/ic/pcf8584.c:1.12	Wed Dec 16 08:04:58 2015
+++ src/sys/dev/ic/pcf8584.c	Sun Jan  3 17:32:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.12 2015/12/16 08:04:58 jdc Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.13 2016/01/03 17:32:17 jdc Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -29,36 +29,13 @@
 #include 
 
 #include 
+#include 
 
-#define PCF_S0			0x00
-#define PCF_S1			0x01
-#define PCF_S2			0x02
-#define PCF_S3			0x03
-
-#define PCF_CTRL_ACK		(1<<0)
-#define PCF_CTRL_STO		(1<<1)
-#define PCF_CTRL_STA		(1<<2)
-#define PCF_CTRL_ENI		(1<<3)
-#define PCF_CTRL_ES2		(1<<4)
-#define PCF_CTRL_ES1		(1<<5)
-#define PCF_CTRL_ESO		(1<<6)
-#define PCF_CTRL_PIN		(1<<7)
-
-#define PCF_CTRL_START		(PCF_CTRL_PIN | PCF_CTRL_ESO | \
-PCF_CTRL_STA | PCF_CTRL_ACK)
-#define PCF_CTRL_STOP		(PCF_CTRL_PIN | PCF_CTRL_ESO | \
-PCF_CTRL_STO | PCF_CTRL_ACK)
-#define PCF_CTRL_REPSTART	(PCF_CTRL_ESO | PCF_CTRL_STA | PCF_CTRL_ACK)
-#define PCF_CTRL_IDLE		(PCF_CTRL_PIN | PCF_CTRL_ESO | PCF_CTRL_ACK)
-
-#define PCF_STAT_nBB		(1<<0)
-#define PCF_STAT_LAB		(1<<1)
-#define PCF_STAT_AAS		(1<<2)
-#define PCF_STAT_AD0		(1<<3)
-#define PCF_STAT_LRB		(1<<3)
-#define PCF_STAT_BER		(1<<4)
-#define PCF_STAT_STS		(1<<5)
-#define PCF_STAT_PIN		(1<<7)
+/* Internal egisters */
+#define PCF8584_S0		0x00
+#define PCF8584_S1		0x01
+#define PCF8584_S2		0x02
+#define PCF8584_S3		0x03
 
 void		pcfiic_init(struct pcfiic_softc *);
 int		pcfiic_i2c_acquire_bus(void *, int);
@@ -74,22 +51,22 @@ int		pcfiic_recv(struct pcfiic_softc *, 
 u_int8_t	pcfiic_read(struct pcfiic_softc *, bus_size_t);
 void		pcfiic_write(struct pcfiic_softc *, bus_size_t, u_int8_t);
 void		pcfiic_choose_bus(struct pcfiic_softc *, u_int8_t);
-int		pcfiic_wait_nBB(struct pcfiic_softc *);
+int		pcfiic_wait_BBN(struct pcfiic_softc *);
 int		pcfiic_wait_pin(struct pcfiic_softc *, volatile u_int8_t *);

CVS commit: src/sys/dev/i2c

2016-01-01 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jan  1 20:13:50 UTC 2016

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

Log Message:
Read the Tos limit from the chip, instead of assuming 80'C, in case
firmware has altered it.  Make the *decode functions return temperatures
in either uK or C for envsys and sysctl, respectively.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/i2c/lm75.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/lm75.c
diff -u src/sys/dev/i2c/lm75.c:1.26 src/sys/dev/i2c/lm75.c:1.27
--- src/sys/dev/i2c/lm75.c:1.26	Sun Sep 27 13:02:21 2015
+++ src/sys/dev/i2c/lm75.c	Fri Jan  1 20:13:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm75.c,v 1.26 2015/09/27 13:02:21 phx Exp $	*/
+/*	$NetBSD: lm75.c,v 1.27 2016/01/01 20:13:50 jdc Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.26 2015/09/27 13:02:21 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.27 2016/01/01 20:13:50 jdc Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ struct lmtemp_softc {
 	envsys_data_t sc_sensor;
 	int sc_tmax;
 
-	uint32_t (*sc_lmtemp_decode)(const uint8_t *);
+	uint32_t (*sc_lmtemp_decode)(const uint8_t *, int);
 };
 
 static int  lmtemp_match(device_t, cfdata_t, void *);
@@ -71,9 +71,11 @@ static void	lmtemp_refresh(struct sysmon
 
 static int	lmtemp_config_write(struct lmtemp_softc *, uint8_t);
 static int	lmtemp_temp_write(struct lmtemp_softc *, int, uint16_t);
-static uint32_t lmtemp_decode_lm75(const uint8_t *);
-static uint32_t lmtemp_decode_ds75(const uint8_t *);
-static uint32_t lmtemp_decode_lm77(const uint8_t *);
+static int	lmtemp_temp_read(struct lmtemp_softc *, uint8_t, uint32_t *,
+int);
+static uint32_t lmtemp_decode_lm75(const uint8_t *, int);
+static uint32_t lmtemp_decode_ds75(const uint8_t *, int);
+static uint32_t lmtemp_decode_lm77(const uint8_t *, int);
 
 static void	lmtemp_setup_sysctl(struct lmtemp_softc *);
 static int	sysctl_lm75_temp(SYSCTLFN_ARGS);
@@ -97,7 +99,7 @@ static const struct {
 	const char *lmtemp_name;
 	int lmtemp_addrmask;
 	int lmtemp_addr;
-	uint32_t (*lmtemp_decode)(const uint8_t *);
+	uint32_t (*lmtemp_decode)(const uint8_t *, int);
 } lmtemptbl[] = {
 	{ lmtemp_lm75,	"LM75",
 	LM75_ADDRMASK,	LM75_ADDR,	lmtemp_decode_lm75 },
@@ -177,16 +179,21 @@ lmtemp_attach(device_t parent, device_t 
 			lmtemptbl[i].lmtemp_name);
 	}
 
-	/*
-	 * according to the LM75 data sheet 80C is the default, so leave it
-	 * there to avoid unexpected behaviour
-	 */
-	sc->sc_tmax = 80;
+	sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode;
+
+	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
+
+	/* Read temperature limit and remember initial value. */
+	if (lmtemp_temp_read(sc, LM75_REG_TOS_SET_POINT, >sc_tmax, 1)
+	!= 0) {
+		iic_release_bus(sc->sc_tag, I2C_F_POLL);
+		return;
+	}
+
 	if (i == lmtemp_lm75)
 		lmtemp_setup_sysctl(sc);
 
 	/* Set the configuration of the LM75 to defaults. */
-	iic_acquire_bus(sc->sc_tag, I2C_F_POLL);
 	if (lmtemp_config_write(sc, LM75_CONFIG_FAULT_QUEUE_4) != 0) {
 		aprint_error_dev(self, "unable to write config register\n");
 		iic_release_bus(sc->sc_tag, I2C_F_POLL);
@@ -206,8 +213,6 @@ lmtemp_attach(device_t parent, device_t 
 		return;
 	}
 
-	sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode;
-
 	/* Hook into system monitor. */
 	sc->sc_sme->sme_name = device_xname(self);
 	sc->sc_sme->sme_cookie = sc;
@@ -245,7 +250,8 @@ lmtemp_temp_write(struct lmtemp_softc *s
 }
 
 static int
-lmtemp_temp_read(struct lmtemp_softc *sc, uint8_t which, uint32_t *valp)
+lmtemp_temp_read(struct lmtemp_softc *sc, uint8_t which, uint32_t *valp,
+int degc)
 {
 	int error;
 	uint8_t cmdbuf[1];
@@ -258,7 +264,7 @@ lmtemp_temp_read(struct lmtemp_softc *sc
 	if (error)
 		return error;
 
-	*valp = sc->sc_lmtemp_decode(buf);
+	*valp = sc->sc_lmtemp_decode(buf, degc);
 	return 0;
 }
 
@@ -268,7 +274,7 @@ lmtemp_refresh_sensor_data(struct lmtemp
 	uint32_t val;
 	int error;
 
-	error = lmtemp_temp_read(sc, LM75_REG_TEMP, );
+	error = lmtemp_temp_read(sc, LM75_REG_TEMP, , 0);
 	if (error) {
 #if 0
 		aprint_error_dev(sc->sc_dev, "unable to read temperature, error = %d\n",
@@ -293,7 +299,7 @@ lmtemp_refresh(struct sysmon_envsys *sme
 }
 
 static uint32_t
-lmtemp_decode_lm75(const uint8_t *buf)
+lmtemp_decode_lm75(const uint8_t *buf, int degc)
 {
 	int temp;
 	uint32_t val;
@@ -305,14 +311,17 @@ lmtemp_decode_lm75(const uint8_t *buf)
 	temp = (int8_t) buf[0];
 	temp = (temp << 1) + ((buf[1] >> 7) & 0x1);
 
-	/* Temp is given in 1/2 deg. C, we convert to uK. */
-	val = temp * 50 + 27315;
+	/* Temp is given in 1/2 deg. C, we convert to C or uK. */
+	if (degc)
+		val = temp / 2;
+	else
+		val = temp * 50 + 27315;
 
 	return val;
 }
 
 static uint32_t
-lmtemp_decode_ds75(const uint8_t *buf)
+lmtemp_decode_ds75(const uint8_t *buf, int degc)
 {
 

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

2015-12-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 30 09:16:17 UTC 2015

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

Log Message:
Restrict the check for fully specified interrupts to machines with psycho
controllers only, and adjust comments to note this.

See also the mail thread starting at:
  http://mail-index.NetBSD.org/port-sparc64/2015/12/03/msg002488.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/sparc64/sparc64/ofw_machdep.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_machdep.c
diff -u src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.44 src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.45
--- src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.44	Mon Mar  2 14:17:06 2015
+++ src/sys/arch/sparc64/sparc64/ofw_machdep.c	Wed Dec 30 09:16:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_machdep.c,v 1.44 2015/03/02 14:17:06 nakayama Exp $	*/
+/*	$NetBSD: ofw_machdep.c,v 1.45 2015/12/30 09:16:17 jdc Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.44 2015/03/02 14:17:06 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.45 2015/12/30 09:16:17 jdc Exp $");
 
 #include 
 #include 
@@ -738,22 +738,22 @@ OF_mapintr(int node, int *interrupt, int
 	int phc_node;
 	int rc = -1;
 
+	phc_node = find_pci_host_node(node);
+
 	/* 
-	 * Don't try to map interrupts for onboard devices, or if the
-	 * interrupt is already fully specified.
-	 * XXX This should be done differently (i.e. by matching
-	 * the node name) - but we need access to a machine where
-	 * a change is testable - hence the printf below.
+	 * On machines with psycho PCI controllers, we don't need to map
+	 * interrupts if they are already fully specified (0x20 to 0x3f
+	 * for onboard devices and IGN 0x7c0 for psycho0/psycho1).
 	 */
 	if (*interrupt & 0x20 || *interrupt & 0x7c0) {
-		char name[40];
-
-		OF_getprop(node, "name", , sizeof(name));
-		printf("\nATTENTION: if you see this message, please mail "
-		"the output of \"dmesg\" and \"ofctl -p\" to "
-		"port-spar...@netbsd.org!\n"
-		"Not mapping interrupt for node %s (%x)\n", name, node);
-		return validlen;
+		char model[40];
+		
+		if (OF_getprop(phc_node, "model", , sizeof(model)) > 10
+		&& !strcmp(model, "SUNW,psycho")) {
+			DPRINTF(("OF_mapintr: interrupt %x already mapped\n",
+			*interrupt));
+			return validlen;
+		}
 	}
 
 	/*
@@ -775,8 +775,6 @@ OF_mapintr(int node, int *interrupt, int
 		return (-1);
 	}
 
-	phc_node = find_pci_host_node(node);
-
 	while (node) {
 #ifdef DEBUG
 		char name[40];



CVS commit: src/sys/dev

2015-12-19 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec 19 19:59:53 UTC 2015

Modified Files:
src/sys/dev: DEVNAMES

Log Message:
Remove references to drivers (adt7463c, adt7467c, adm1030c) that were
superceded by dbcool.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/dev/DEVNAMES

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/DEVNAMES
diff -u src/sys/dev/DEVNAMES:1.294 src/sys/dev/DEVNAMES:1.295
--- src/sys/dev/DEVNAMES:1.294	Thu Aug 27 14:04:07 2015
+++ src/sys/dev/DEVNAMES	Sat Dec 19 19:59:52 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: DEVNAMES,v 1.294 2015/08/27 14:04:07 nonaka Exp $
+#	$NetBSD: DEVNAMES,v 1.295 2015/12/19 19:59:52 jdc Exp $
 #
 # This file contains all used device names and defined attributes in
 # alphabetical order. New devices added to the system somewhere should first
@@ -39,9 +39,6 @@ adb			mac68k
 adb			macppc
 adc			hpcsh
 ade			alpha
-adt7463c		MI
-adt7467c		MI
-adm1030c		MI
 adv			MI
 adw			MI
 ae			evbmips



CVS commit: src/sys/dev

2015-12-19 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec 19 20:01:35 UTC 2015

Modified Files:
src/sys/dev: DEVNAMES

Log Message:
Add adm1026hm (MI).


To generate a diff of this commit:
cvs rdiff -u -r1.295 -r1.296 src/sys/dev/DEVNAMES

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/DEVNAMES
diff -u src/sys/dev/DEVNAMES:1.295 src/sys/dev/DEVNAMES:1.296
--- src/sys/dev/DEVNAMES:1.295	Sat Dec 19 19:59:52 2015
+++ src/sys/dev/DEVNAMES	Sat Dec 19 20:01:35 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: DEVNAMES,v 1.295 2015/12/19 19:59:52 jdc Exp $
+#	$NetBSD: DEVNAMES,v 1.296 2015/12/19 20:01:35 jdc Exp $
 #
 # This file contains all used device names and defined attributes in
 # alphabetical order. New devices added to the system somewhere should first
@@ -39,6 +39,7 @@ adb			mac68k
 adb			macppc
 adc			hpcsh
 ade			alpha
+adm1026hm		MI
 adv			MI
 adw			MI
 ae			evbmips



CVS commit: src/share/man/man4

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:24:30 UTC 2015

Added Files:
src/share/man/man4: adm1026hm.4
Removed Files:
src/share/man/man4: adm1026tm.4

Log Message:
Correct the name of the manual page (pointed out by wiz).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/share/man/man4/adm1026hm.4
cvs rdiff -u -r1.2 -r0 src/share/man/man4/adm1026tm.4

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

Added files:

Index: src/share/man/man4/adm1026hm.4
diff -u /dev/null src/share/man/man4/adm1026hm.4:1.1
--- /dev/null	Wed Dec 16 08:24:30 2015
+++ src/share/man/man4/adm1026hm.4	Wed Dec 16 08:24:30 2015
@@ -0,0 +1,83 @@
+.\"	$NetBSD: adm1026hm.4,v 1.1 2015/12/16 08:24:30 jdc Exp $
+.\"
+.\" Copyright (c) 2015 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.
+.\"
+.Dd December 11, 2015
+.Dt ADM1026HM 4
+.Os
+.Sh NAME
+.Nm adm1026hm
+.Nd Analog Devices ADM1026 complete thermal system management controller
+.Sh SYNOPSIS
+.Cd "adm1026hm* at iic0 addr 0x2e: ADM1026 hardware monitor: rev. 0x4, step. 0x5"
+.Cd "adm1026hm*: 8 fans, 3 temperatures, 15 voltages"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the Analog Devices ADM1026 hardware monitor.
+The chip possesses 8 fan speed sensors, 3 temperature sensors,
+and 17 voltage sensors.
+The number of each sensor type configured by the driver depends on the
+chip configuration.
+.Pp
+The values of the sensors are made available through the
+.Xr envstat 8
+interface.
+.Bl -column "V3.3 standby" "uV DC" "Description" -offset indent
+.It Sy "Sensor" Ta Sy "Units" Ta Sy "Description"
+.It Li "fan N" Ta "RPM" Ta "Fan 0-7"
+.It Li "internal" Ta "C" Ta "Internal temperature"
+.It Li "external N" Ta "C" Ta "External temperature 1\(en2"
+.It Li "Vbatt" Ta "mV DC" Ta "Battery voltage"
+.It Li "V3.3 standby" Ta "mV DC" Ta "3.3V standby voltage"
+.It Li "V3.3 main" Ta "mV DC" Ta "3.3V main voltage"
+.It Li "V5.0" Ta "mV DC" Ta "5.0V supply voltage"
+.It Li "V+12" Ta "mV DC" Ta "+12V supply voltage"
+.It Li "V-12" Ta "mV DC" Ta "-12V supply voltage"
+.It Li "V3.3 N" Ta "mV DC" Ta "Analog in (3.3V reference) 0\(en5"
+.It Li "V2.5 N" Ta "mV DC" Ta "Analog in (2.5V reference) 0\(en3"
+.El
+.Sh SEE ALSO
+.Xr iic 4 ,
+.Xr intro 4 ,
+.Xr envstat 8
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Julian Coleman Aq Mt jcole...@netbsd.org .
+.Sh BUGS
+It's not possible to determine if either a sensor is not connected,
+or the monitored device is producing no output.
+Therefore, unconnected sensors will show outputs of 0.
+.Pp
+The
+.Nm
+driver does not support checking or altering limit values, interrupt output,
+nor the built-in EEPROM.



CVS commit: src/sys/dev/ic

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:04:58 UTC 2015

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

Log Message:
Allow pcfiic to handle i2c writes using cmdbuf for the register, and buf for
the value to be written.  Prior to this, we would send an empty write command
to the correct i2c address, plus an empty write command to the device at the
i2c address of the first byte of buf.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/pcf8584.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/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.11 src/sys/dev/ic/pcf8584.c:1.12
--- src/sys/dev/ic/pcf8584.c:1.11	Mon Jan 20 22:02:32 2014
+++ src/sys/dev/ic/pcf8584.c	Wed Dec 16 08:04:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.11 2014/01/20 22:02:32 jdc Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.12 2015/12/16 08:04:58 jdc Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -175,14 +175,28 @@ pcfiic_i2c_exec(void *arg, i2c_op_t op, 
 	if (sc->sc_master)
 		pcfiic_choose_bus(sc, addr >> 7);
 
-	if (pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen) != 0)
-		return (1);
-
-	if (len > 0) {
-		if (I2C_OP_WRITE_P(op))
-			ret = pcfiic_xmit(sc, addr & 0x7f, buf, len);
-		else
-			ret = pcfiic_recv(sc, addr & 0x7f, buf, len);
+	/*
+	 * If we are writing, write address, cmdbuf, buf.
+	 * If we are reading, write address, cmdbuf, then read address, buf.
+	 */
+	if (I2C_OP_WRITE_P(op)) {
+		if (len > 0) {
+			uint8_t *tmp;
+
+			tmp = malloc(cmdlen + len, M_DEVBUF,
+			   flags & I2C_F_POLL ? M_NOWAIT : M_WAITOK);
+			if (tmp == NULL)
+return (1);
+			memcpy(tmp, cmdbuf, cmdlen);
+			memcpy(tmp + cmdlen, buf, len);
+			ret = pcfiic_xmit(sc, addr & 0x7f, tmp, cmdlen + len);
+			free(tmp, M_DEVBUF);
+		} else
+			ret = pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen);
+	} else {
+		if (pcfiic_xmit(sc, addr & 0x7f, cmdbuf, cmdlen) != 0)
+			return (1);
+		ret = pcfiic_recv(sc, addr & 0x7f, buf, len);
 	}
 	return (ret);
 }



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

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:00:00 UTC 2015

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

Log Message:
Add adm1026hm* for V210, V240, and V440 environmental monitoring.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 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.182 src/sys/arch/sparc64/conf/GENERIC:1.183
--- src/sys/arch/sparc64/conf/GENERIC:1.182	Sat Sep 26 11:16:13 2015
+++ src/sys/arch/sparc64/conf/GENERIC	Wed Dec 16 08:00:00 2015
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.182 2015/09/26 11:16:13 maxv Exp $
+# $NetBSD: GENERIC,v 1.183 2015/12/16 08:00:00 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.182 $"
+#ident 		"GENERIC-$Revision: 1.183 $"
 
 maxusers	64
 
@@ -950,6 +950,7 @@ iic*		at alipm?
 
 spdmem*		at iic? addr?
 admtemp*	at iic? addr?
+adm1026hm*	at iic? addr?
 ecadc*		at iic? addr?	# envctrl/envctrltwo on E250/E450
 lmtemp*		at iic? addr?
 tda*		at iic? addr?	# fan control on SB1000/2000



CVS commit: src/sys/dev/i2c

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:05:38 UTC 2015

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

Log Message:
Add direct configuration support via compatible names.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/i2c/dbcool.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/dbcool.c
diff -u src/sys/dev/i2c/dbcool.c:1.43 src/sys/dev/i2c/dbcool.c:1.44
--- src/sys/dev/i2c/dbcool.c:1.43	Thu Apr 23 23:23:00 2015
+++ src/sys/dev/i2c/dbcool.c	Wed Dec 16 08:05:38 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $ */
+/*	$NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $");
 
 #include 
 #include 
@@ -731,6 +731,10 @@ static char dbcool_cur_behav[16];
 CFATTACH_DECL_NEW(dbcool, sizeof(struct dbcool_softc),
 dbcool_match, dbcool_attach, dbcool_detach, NULL);
 
+static const char * dbcool_compats[] = {
+	"i2c-adm1031",
+	NULL
+};
 int
 dbcool_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -742,12 +746,19 @@ dbcool_match(device_t parent, cfdata_t c
 	dc.dc_readreg = dbcool_readreg;
 	dc.dc_writereg = dbcool_writereg;
 
-	/* no probing if we attach to iic, but verify chip id  and address */
-	if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
-		return 0;
-	if (dbcool_chip_ident() >= 0)
-		return 1;
-
+	/* Direct config - match compats */
+	if (ia->ia_name) {
+		if (ia->ia_ncompat > 0) {
+			if (iic_compat_match(ia, dbcool_compats))
+return 1;
+		}
+	/* Indirect config - check address and chip ID */
+	} else {
+		if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
+			return 0;
+		if (dbcool_chip_ident() >= 0)
+			return 1;
+	}
 	return 0;
 }
 



CVS commit: src/doc

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:08:22 UTC 2015

Modified Files:
src/doc: CHANGES

Log Message:
Mention new ADM1026 i2c driver.


To generate a diff of this commit:
cvs rdiff -u -r1.2117 -r1.2118 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.2117 src/doc/CHANGES:1.2118
--- src/doc/CHANGES:1.2117	Sat Dec 12 23:43:36 2015
+++ src/doc/CHANGES	Wed Dec 16 08:08:22 2015
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2117 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2118 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -225,3 +225,5 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	dhcpcd: Import dhcpcd 6.9.4. [roy 20151130]
 	openssl: Import openssl 1.0.1q [christos 20151206]
 	ip6addrctl: Import from FreeBSD [christos 20151212]
+	adm1026hm(4): Add driver for ADM1026 i2c hardware monitor
+		[jdc 20151216]



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

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:01:19 UTC 2015

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

Log Message:
Add V210/V240 environmental sensors that are not in the OFW tree.
Add device properties for adm1026hm on V210, V240, and V440.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 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/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.206 src/sys/arch/sparc64/sparc64/autoconf.c:1.207
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.206	Sun Dec 13 11:51:37 2015
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Wed Dec 16 08:01:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $ */
+/*	$NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1142,6 +1142,58 @@ noether:
 			prop_object_release(cfg);
 			
 		}
+
+		/*
+		 * Add V210/V240 environmental sensors that are not in
+		 * the OFW tree.
+		 */
+		if (device_is_a(busdev, "pcfiic") &&
+		(!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+		!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+			prop_dictionary_t props = device_properties(busdev);
+			prop_array_t cfg = NULL;
+			prop_dictionary_t sens;
+			prop_data_t data;
+			const char name_lm[] = "i2c-lm75";
+			const char name_adm[] = "i2c-adm1026";
+
+			DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ",
+			machine_model));
+			cfg = prop_dictionary_get(props, "i2c-child-devices");
+ 			if (!cfg) {
+cfg = prop_array_create();
+prop_dictionary_set(props, "i2c-child-devices",
+cfg);
+prop_dictionary_set_bool(props,
+"i2c-indirect-config", false);
+			}
+
+			/* ADM1026 at 0x2e */
+			sens = prop_dictionary_create();
+			prop_dictionary_set_uint32(sens, "addr", 0x2e);
+			prop_dictionary_set_uint64(sens, "cookie", 0);
+			prop_dictionary_set_cstring(sens, "name",
+			"hardware-monitor");
+			data = prop_data_create_data(_adm[0],
+			sizeof(name_adm));
+			prop_dictionary_set(sens, "compatible", data);
+			prop_object_release(data);
+			prop_array_add(cfg, sens);
+			prop_object_release(sens);
+
+			/* LM75 at 0x4e */
+			sens = prop_dictionary_create();
+			prop_dictionary_set_uint32(sens, "addr", 0x4e);
+			prop_dictionary_set_uint64(sens, "cookie", 0);
+			prop_dictionary_set_cstring(sens, "name",
+			"temperature-sensor");
+			data = prop_data_create_data(_lm[0],
+			sizeof(name_lm));
+			prop_dictionary_set(sens, "compatible", data);
+			prop_object_release(data);
+			prop_array_add(cfg, sens);
+			prop_object_release(sens);
+		}
 	}
 
 	/* set properties for PCI framebuffers */
@@ -1205,6 +1257,27 @@ noether:
 instance = OF_open(name);
 #endif
 	}
+
+	/* Hardware specific device properties */
+	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
 }
 
 /*



CVS commit: src/share/man/man4

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:20:03 UTC 2015

Modified Files:
src/share/man/man4: Makefile

Log Message:
Add manual page for ADM1026.


To generate a diff of this commit:
cvs rdiff -u -r1.624 -r1.625 src/share/man/man4/Makefile

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/Makefile
diff -u src/share/man/man4/Makefile:1.624 src/share/man/man4/Makefile:1.625
--- src/share/man/man4/Makefile:1.624	Wed Oct 14 04:22:45 2015
+++ src/share/man/man4/Makefile	Wed Dec 16 08:20:03 2015
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.624 2015/10/14 04:22:45 nonaka Exp $
+#	$NetBSD: Makefile,v 1.625 2015/12/16 08:20:03 jdc Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
 	adbbt.4 adbkbd.4 adbms.4 \
-	adc.4 admtemp.4 adv.4 adw.4 age.4 agp.4 agr.4 ahb.4 ahc.4 \
+	adc.4 adm1026hm.4 admtemp.4 adv.4 adw.4 age.4 agp.4 agr.4 ahb.4 ahc.4 \
 	ahcisata.4 ahd.4 \
 	aibs.4 alc.4 ale.4 alipm.4 altmem.4 altq.4 amdpm.4 amdtemp.4 amhphy.4 \
 	amr.4 aps.4 asus.4 \



CVS commit: src

2015-12-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 07:59:01 UTC 2015

Modified Files:
src/distrib/sets/lists/man: mi
Added Files:
src/share/man/man4: adm1026tm.4

Log Message:
Add manual page for ADM1026.


To generate a diff of this commit:
cvs rdiff -u -r1.1514 -r1.1515 src/distrib/sets/lists/man/mi
cvs rdiff -u -r0 -r1.1 src/share/man/man4/adm1026tm.4

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/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1514 src/distrib/sets/lists/man/mi:1.1515
--- src/distrib/sets/lists/man/mi:1.1514	Sun Dec 13 21:09:01 2015
+++ src/distrib/sets/lists/man/mi	Wed Dec 16 07:59:01 2015
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1514 2015/12/13 21:09:01 rjs Exp $
+# $NetBSD: mi,v 1.1515 2015/12/16 07:59:01 jdc Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -720,6 +720,7 @@
 ./usr/share/man/cat4/adbkbd.0			man-sys-catman		.cat
 ./usr/share/man/cat4/adbms.0			man-sys-catman		.cat
 ./usr/share/man/cat4/adc.0			man-sys-catman		.cat
+./usr/share/man/cat4/adm1026hm.0		man-sys-catman		.cat
 ./usr/share/man/cat4/adm1027.0			man-sys-catman		.cat
 ./usr/share/man/cat4/adm1030.0			man-sys-catman		.cat
 ./usr/share/man/cat4/admtemp.0			man-sys-catman		.cat
@@ -3828,6 +3829,7 @@
 ./usr/share/man/html4/adbkbd.html		man-sys-htmlman		html
 ./usr/share/man/html4/adbms.html		man-sys-htmlman		html
 ./usr/share/man/html4/adc.html			man-sys-htmlman		html
+./usr/share/man/html4/adm1026hm.html		man-sys-htmlman		html
 ./usr/share/man/html4/adm1027.html		man-sys-htmlman		html
 ./usr/share/man/html4/adm1030.html		man-sys-htmlman		html
 ./usr/share/man/html4/admtemp.html		man-sys-htmlman		html
@@ -6630,6 +6632,7 @@
 ./usr/share/man/man4/adbkbd.4			man-sys-man		.man
 ./usr/share/man/man4/adbms.4			man-sys-man		.man
 ./usr/share/man/man4/adc.4			man-sys-man		.man
+./usr/share/man/man4/adm1026hm.4		man-sys-man		.man
 ./usr/share/man/man4/adm1027.4			man-sys-man		.man
 ./usr/share/man/man4/adm1030.4			man-sys-man		.man
 ./usr/share/man/man4/admtemp.4			man-sys-man		.man

Added files:

Index: src/share/man/man4/adm1026tm.4
diff -u /dev/null src/share/man/man4/adm1026tm.4:1.1
--- /dev/null	Wed Dec 16 07:59:01 2015
+++ src/share/man/man4/adm1026tm.4	Wed Dec 16 07:59:01 2015
@@ -0,0 +1,83 @@
+.\"	$NetBSD: adm1026tm.4,v 1.1 2015/12/16 07:59:01 jdc Exp $
+.\"
+.\" Copyright (c) 2015 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.
+.\"
+.Dd December 11, 2015
+.Dt ADM1026HM
+.Os
+.Sh NAME
+.Nm adm1026hm
+.Nd Analog Devices ADM1026 complete thermal system management controller
+.Sh SYNOPSIS
+.Cd "adm1026hm* at iic0 addr 0x2e: ADM1026 hardware monitor: rev. 0x4, step. 0x5"
+.Cd "adm1026hm*: 8 fans, 3 temperatures, 15 voltages"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the Analog Devices ADM1026 hardware monitor.
+The chip possesses 8 fan speed sensors, 3 temperature sensors,
+and 17 voltage sensors.
+The number of each sensor type configured by the driver depends on the
+chip configuration.
+.Pp
+The values of the sensors are made available through the
+.Xr envstat 8
+interface.
+.Bl -column "V3.3 standby" "uV DC" "Description" -offset indent
+.It Sy "Sensor" Ta Sy "Units" T

CVS commit: src/sys/dev/i2c

2015-12-15 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 07:56:48 UTC 2015

Modified Files:
src/sys/dev/i2c: files.i2c
Added Files:
src/sys/dev/i2c: adm1026.c adm1026reg.h

Log Message:
Add a driver for the ADM1026 Thermal System Management Fan Controller
i2c chip.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/i2c/adm1026.c src/sys/dev/i2c/adm1026reg.h
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/i2c/files.i2c

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.68 src/sys/dev/i2c/files.i2c:1.69
--- src/sys/dev/i2c/files.i2c:1.68	Sat Nov 21 10:57:32 2015
+++ src/sys/dev/i2c/files.i2c	Wed Dec 16 07:56:48 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i2c,v 1.68 2015/11/21 10:57:32 jmcneill Exp $
+#	$NetBSD: files.i2c,v 1.69 2015/12/16 07:56:48 jdc Exp $
 
 obsolete defflag	opt_i2cbus.h		I2C_SCAN
 define	i2cbus { }
@@ -176,6 +176,11 @@ device	admtemp: sysmon_envsys
 attach	admtemp at iic
 file	dev/i2c/adm1021.c		admtemp
 
+# ADM1026 hardware monitor
+device	adm1026hm: sysmon_envsys
+attach	adm1026hm at iic
+file	dev/i2c/adm1026.c		adm1026hm
+
 # SMSC LPC47M192 hardware monitor
 device	smscmon: sysmon_envsys
 attach	smscmon at iic

Added files:

Index: src/sys/dev/i2c/adm1026.c
diff -u /dev/null src/sys/dev/i2c/adm1026.c:1.1
--- /dev/null	Wed Dec 16 07:56:48 2015
+++ src/sys/dev/i2c/adm1026.c	Wed Dec 16 07:56:48 2015
@@ -0,0 +1,553 @@
+/*-
+ * Copyright (c) 2015 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.1 2015/12/16 07:56:48 jdc Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+/* Voltage/analog sensors descriptions and registers */
+struct adm1026_volts_info {
+	const char* desc;
+	int incr;
+	uint8_t reg, check_tdm2;
+};
+
+/* Voltage maximums (in mV) from datasheet table 7 divided by 255 increments */
+static struct adm1026_volts_info adm1026_volts_table[] = {
+	{ "Vbatt", 15624, ADM1026_VBAT_VAL, 0 },
+	{ "V3.3 standby", 17345, ADM1026_33VSTBY_VAL, 0 },
+	{ "V3.3 main", 17345, ADM1026_33VMAIN_VAL, 0 },
+	{ "V5.0", 26016, ADM1026_50V_VAL, 0 },
+	{ "Vccp", 11718, ADM1026_VCCP_VAL, 0 },
+	{ "V+12", 62502, ADM1026_12V_VAL, 0 },
+	{ "V-12", -62502, ADM1026_N12V_VAL, 0 },
+	{ "V3.0 0", 11718, ADM1026_AIN_VAL(0), 0 },
+	{ "V3.0 1", 11718, ADM1026_AIN_VAL(1), 0 },
+	{ "V3.0 2", 11718, ADM1026_AIN_VAL(2), 0 },
+	{ "V3.0 3", 11718, ADM1026_AIN_VAL(3), 0 },
+	{ "V3.0 4", 11718, ADM1026_AIN_VAL(4), 0 },
+	{ "V3.0 5", 11718, ADM1026_AIN_VAL(5), 0 },
+	{ "V2.5 0", 9765, ADM1026_AIN_VAL(6), 0 },
+	{ "V2.5 1", 9765, ADM1026_AIN_VAL(7), 0 },
+	{ "V2.5 2", 9765, ADM1026_AIN8_VAL, 1 },
+	{ "V2.5 3", 9765, ADM1026_TDM2_AIN9_VAL, 1 }
+};
+
+/* Maximum number of each type of sensor */
+#define ADM1026_MAX_FANS	8
+#define ADM1026_MAX_TEMPS	3
+#define ADM1026_MAX_VOLTS	(sizeof(adm1026_volts_table) / \
+sizeof (adm1026_volts_table[0]))
+
+/* Map sensor to/from sysmon numbers */
+#define ADM1026_FAN_NUM(x)	(x)
+#define ADM1026_TEMP_NUM(x)	(x + sc->sc_nfans)
+#define ADM1026_VOLT_NUM(x)	(x + sc->sc_nfans + sc->sc_ntemps)
+#define ADM1026_NUM_FAN(x)	(x)
+#define ADM1026_NUM_TEMP(x)	(x - sc->sc_nfans)
+#define ADM1026_NUM_VOLT

CVS commit: src/sys/dev/sysmon

2015-12-13 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec 13 17:41:48 UTC 2015

Modified Files:
src/sys/dev/sysmon: sysmon_envsys.c

Log Message:
Note the sensor number in the error output.  Useful for drivers adding
multiple sensors.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/dev/sysmon/sysmon_envsys.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/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.137 src/sys/dev/sysmon/sysmon_envsys.c:1.138
--- src/sys/dev/sysmon/sysmon_envsys.c:1.137	Sat Apr 25 23:40:09 2015
+++ src/sys/dev/sysmon/sysmon_envsys.c	Sun Dec 13 17:41:48 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $");
 
 #include 
 #include 
@@ -1656,8 +1656,8 @@ sme_update_sensor_dictionary(prop_object
 
 	sdt = sme_find_table_entry(SME_DESC_STATES, edata->state);
 	if (sdt == NULL) {
-		printf("sme_update_sensor_dictionary: can not update sensor "
-		"state %d unknown\n", edata->state);
+		printf("sme_update_sensor_dictionary: cannot update sensor %d "
+		"state %d unknown\n", edata->sensor, edata->state);
 		return EINVAL;
 	}
 



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

2015-11-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Nov 23 21:40:14 UTC 2015

Modified Files:
src/sys/arch/sparc64/dev: schizo.c schizoreg.h schizovar.h

Log Message:
Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc64/dev/schizo.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/schizoreg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/schizovar.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/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.33 src/sys/arch/sparc64/dev/schizo.c:1.34
--- src/sys/arch/sparc64/dev/schizo.c:1.33	Fri Oct  2 05:22:52 2015
+++ src/sys/arch/sparc64/dev/schizo.c	Mon Nov 23 21:40:14 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.33 2015/10/02 05:22:52 msaitoh Exp $	*/
+/*	$NetBSD: schizo.c,v 1.34 2015/11/23 21:40:14 jdc Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.33 2015/10/02 05:22:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.34 2015/11/23 21:40:14 jdc Exp $");
 
 #include 
 #include 
@@ -74,6 +74,10 @@ static	int	schizo_match(device_t, cfdata
 static	void	schizo_attach(device_t, device_t, void *);
 static	int	schizo_print(void *aux, const char *p);
 
+#ifdef DEBUG
+void schizo_print_regs(int unit, int what);
+#endif
+
 CFATTACH_DECL_NEW(schizo, sizeof(struct schizo_softc),
 schizo_match, schizo_attach, NULL, NULL);
 
@@ -143,8 +147,8 @@ schizo_attach(device_t parent, device_t 
 	struct schizo_pbm *pbm;
 	struct iommu_state *is;
 	struct pcibus_attach_args pba;
-	uint64_t reg, eccctrl;
-	int *busranges = NULL, nranges;
+	uint64_t reg, eccctrl, ino_bitmap;
+	int *busranges = NULL, nranges, *ino_bitmaps = NULL, nbitmaps;
 	char *str;
 	bool no_sc;
 
@@ -180,6 +184,9 @@ schizo_attach(device_t parent, device_t 
 	if (pbm == NULL)
 		panic("schizo: can't alloc schizo pbm");
 
+#ifdef DEBUG
+	sc->sc_pbm = pbm;
+#endif
 	pbm->sp_sc = sc;
 	pbm->sp_regt = sc->sc_bustag;
 
@@ -194,11 +201,25 @@ schizo_attach(device_t parent, device_t 
 	if (bus_space_map(sc->sc_bustag, ma->ma_reg[0].ur_paddr,
 			  ma->ma_reg[0].ur_len,
 			  BUS_SPACE_MAP_LINEAR, >sp_intrh)) {
-		aprint_error(": failed to interrupt map registers\n");
+		aprint_error(": failed to map interrupt registers\n");
 		kmem_free(pbm, sizeof(*pbm));
 		return;
 	}
 
+#ifdef DEBUG
+	/*
+	 * Map ichip registers
+	 */
+	if (sc->sc_tomatillo)
+		if (bus_space_map(sc->sc_bustag, ma->ma_reg[3].ur_paddr,
+			  ma->ma_reg[3].ur_len,
+			  BUS_SPACE_MAP_LINEAR, >sp_ichiph)) {
+			aprint_error(": failed to map ichip registers\n");
+			kmem_free(pbm, sizeof(*pbm));
+			return;
+		}
+#endif
+
 	if (prom_getprop(sc->sc_node, "ranges", sizeof(struct schizo_range),
 	>sp_nrange, (void **)>sp_range))
 		panic("schizo: can't get ranges");
@@ -207,7 +228,7 @@ schizo_attach(device_t parent, device_t 
 	(void **)))
 		panic("schizo: can't get bus-range");
 
-	aprint_normal(": \"%s\", version %d, ign %x, bus %c %d to %d\n",
+	aprint_normal(": %s, version %d, ign %x, bus %c %d to %d\n",
 	sc->sc_tomatillo ? "Tomatillo" : "Schizo", sc->sc_ver,
 	sc->sc_ign, pbm->sp_bus_a ? 'A' : 'B', busranges[0], busranges[1]);
 	aprint_naive("\n");
@@ -304,20 +325,34 @@ schizo_attach(device_t parent, device_t 
 	SCZ_PCIDIAG_D_INTSYNC);
 	schizo_pbm_write(pbm, SCZ_PCI_DIAG, reg);
 
-	if (pbm->sp_bus_a)
+	if (prom_getprop(sc->sc_node, "ino-bitmap", sizeof(int), ,
+	(void **)_bitmaps)) {
+		/* No property - set defaults (double map UE, CE, SERR). */
+		if (pbm->sp_bus_a)
+			ino_bitmap = 1UL << SCZ_PCIERR_A_INO;
+		else
+			ino_bitmap = 1UL << SCZ_PCIERR_B_INO;
+		ino_bitmap |= (1UL << SCZ_UE_INO) | (1UL << SCZ_CE_INO) |
+		(1UL << SCZ_SERR_INO);
+	} else
+		ino_bitmap = (uint64_t) ino_bitmaps[1] << 32 | ino_bitmaps[0];
+	DPRINTF(SDB_INTR, ("ino_bitmap=0x%016" PRIx64 "\n", ino_bitmap));
+
+	if (ino_bitmap & (1UL << SCZ_PCIERR_A_INO))
 		schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
 		   pbm, SCZ_PCIERR_A_INO, "pci_a");
-	else
+	if (ino_bitmap & (1UL << SCZ_PCIERR_B_INO))
 		schizo_set_intr(sc, pbm, PIL_HIGH, schizo_pci_error,
 		   pbm, SCZ_PCIERR_B_INO, "pci_b");
-
-	/* double mapped */
-	schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ue, sc, SCZ_UE_INO,
-	"ue");
-	schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ce, sc, SCZ_CE_INO,
-	"ce");
-	schizo_set_intr(sc, pbm, PIL_HIGH, schizo_safari_error, sc,
-	SCZ_SERR_INO, "safari");
+	if (ino_bitmap & (1UL << SCZ_UE_INO))
+		schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ue, sc, SCZ_UE_INO,
+		"ue");
+	if (ino_bitmap & (1UL << SCZ_CE_INO))
+		schizo_set_intr(sc, pbm, PIL_HIGH, schizo_ce, sc, 

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

2015-08-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Aug 16 10:58:54 UTC 2015

Modified Files:
src/sys/arch/sparc/stand/bootblk: bootblk.fth genlfs.cf

Log Message:
Make these compile again after changes to LFS.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc/stand/bootblk/bootblk.fth
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/stand/bootblk/genlfs.cf

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/stand/bootblk/bootblk.fth
diff -u src/sys/arch/sparc/stand/bootblk/bootblk.fth:1.13 src/sys/arch/sparc/stand/bootblk/bootblk.fth:1.14
--- src/sys/arch/sparc/stand/bootblk/bootblk.fth:1.13	Thu Jun 24 00:54:12 2010
+++ src/sys/arch/sparc/stand/bootblk/bootblk.fth	Sun Aug 16 10:58:54 2015
@@ -1,4 +1,4 @@
-\	$NetBSD: bootblk.fth,v 1.13 2010/06/24 00:54:12 eeh Exp $
+\	$NetBSD: bootblk.fth,v 1.14 2015/08/16 10:58:54 jdc Exp $
 \
 \	IEEE 1275 Open Firmware Boot Block
 \
@@ -605,7 +605,7 @@ create cur-blockno -1 l, -1 l,		\ Curren
boot-debug?  if  . LFS v2 cr  then
init-lfs-common
' lfs_bsize  to  fs-bsize
-   ' ifile_SIZEOF  to  /ifile
+   ' ifile32_SIZEOF  to  /ifile
' if2_daddr  to  if_daddr
 ;   
 
@@ -890,7 +890,7 @@ create cur-blockno -1 l, -1 l,		\ Curren
 
 : do-boot ( bootfile -- )
. NetBSD IEEE 1275 Multi-FS Bootblock cr
-   . Version $NetBSD: bootblk.fth,v 1.13 2010/06/24 00:54:12 eeh Exp $ cr
+   . Version $NetBSD: bootblk.fth,v 1.14 2015/08/16 10:58:54 jdc Exp $ cr
boot-path load-file ( -- load-base )
dup 0  if   init-program  evaluate  then
 ; 

Index: src/sys/arch/sparc/stand/bootblk/genlfs.cf
diff -u src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.2 src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.3
--- src/sys/arch/sparc/stand/bootblk/genlfs.cf:1.2	Mon Jun 10 10:26:22 2013
+++ src/sys/arch/sparc/stand/bootblk/genlfs.cf	Sun Aug 16 10:58:54 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: genlfs.cf,v 1.2 2013/06/10 10:26:22 hannken Exp $
+#	$NetBSD: genlfs.cf,v 1.3 2015/08/16 10:58:54 jdc Exp $
 
 #	Copyright (c) 2010 Eduardo Horvath.
 #	All rights reserved.
@@ -63,16 +63,16 @@ member	if1_version	if_version
 member 	if1_daddr	if_daddr
 
 #
-# LFS v2 ifile
+# LFS v2 ifile32
 #
-struct	ifile
+struct	ifile32
 member	if2_version	if_version
 member 	if2_daddr	if_daddr
 
 #
 # LFS v1 dinode
 #
-struct  ulfs1_dinode
+struct  lfs32_dinode
 member	di_inumber	di_inumber
 
 define	lfs_magic_value		LFS_MAGIC



CVS commit: src/sys/dev/usb

2014-08-04 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Aug  4 19:59:37 UTC 2014

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
ATMEL WN210 is actually ID 0x4102 (spotted by mlelstv).


To generate a diff of this commit:
cvs rdiff -u -r1.679 -r1.680 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.679 src/sys/dev/usb/usbdevs:1.680
--- src/sys/dev/usb/usbdevs:1.679	Sat Aug  2 17:55:00 2014
+++ src/sys/dev/usb/usbdevs	Mon Aug  4 19:59:37 2014
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.679 2014/08/02 17:55:00 nonaka Exp $
+$NetBSD: usbdevs,v 1.680 2014/08/04 19:59:37 jdc Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -945,7 +945,7 @@ product ATI2 205		0xa001	USB Cable 205
 
 /* Atmel Comp. products */
 product ATMEL UHB124		0x3301	UHB124 hub
-product ATMEL WN210		0x3301	W-Buddie WN210
+product ATMEL WN210		0x4102	W-Buddie WN210
 product ATMEL DWL900AP		0x5601	DWL-900AP Wireless access point
 product ATMEL SAM_BA		0x6124	ARM SAM-BA programming port
 product ATMEL DWL120		0x7602	DWL-120 Wireless adapter



  1   2   3   4   5   >