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

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 13:06:06 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Output is always 16bit, the internal audio data type may differ.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.65 src/sys/arch/macppc/dev/snapper.c:1.66
--- src/sys/arch/macppc/dev/snapper.c:1.65	Thu Jun  2 16:22:27 2022
+++ src/sys/arch/macppc/dev/snapper.c	Mon Dec 11 13:06:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.65 2022/06/02 16:22:27 macallan Exp $	*/
+/*	$NetBSD: snapper.c,v 1.66 2023/12/11 13:06:06 mlelstv Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.65 2022/06/02 16:22:27 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.66 2023/12/11 13:06:06 mlelstv Exp $");
 
 #include 
 #include 
@@ -187,7 +187,7 @@ snapper_volume(audio_filter_arg_t *arg)
 {
 	struct snapper_softc *sc;
 	const aint_t *src;
-	aint_t *dst;
+	int16_t *dst;
 	u_int sample_count;
 	u_int i;
 



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

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 13:06:06 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Output is always 16bit, the internal audio data type may differ.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/macppc/dev/snapper.c

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



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 10:59:24 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: zs.c

Log Message:
pass NULL to the second dbdma_alloc() expected argement.
it was not adjusted after it acquired one 7 years ago.

fixes ZS_TXDMA enabled build for macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/zs.c

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



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 10:59:24 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: zs.c

Log Message:
pass NULL to the second dbdma_alloc() expected argement.
it was not adjusted after it acquired one 7 years ago.

fixes ZS_TXDMA enabled build for macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/zs.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/macppc/dev/zs.c
diff -u src/sys/arch/macppc/dev/zs.c:1.58 src/sys/arch/macppc/dev/zs.c:1.59
--- src/sys/arch/macppc/dev/zs.c:1.58	Sat Sep 23 12:48:23 2023
+++ src/sys/arch/macppc/dev/zs.c	Sun Sep 24 10:59:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.58 2023/09/23 12:48:23 andvar Exp $	*/
+/*	$NetBSD: zs.c,v 1.59 2023/09/24 10:59:24 andvar Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998 Bill Studenmund
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.58 2023/09/23 12:48:23 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.59 2023/09/24 10:59:24 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -259,7 +259,7 @@ zsc_attach(device_t parent, device_t sel
 #ifdef ZS_TXDMA
 		zsc->zsc_txdmareg[channel] = mapiodev(regs[2], regs[3], false);
 		zsc->zsc_txdmacmd[channel] =
-			dbdma_alloc(sizeof(dbdma_command_t) * 3);
+			dbdma_alloc(sizeof(dbdma_command_t) * 3, NULL);
 		memset(zsc->zsc_txdmacmd[channel], 0,
 			sizeof(dbdma_command_t) * 3);
 		dbdma_reset(zsc->zsc_txdmareg[channel]);



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 10:51:28 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: valkyriefb.c

Log Message:
define i variable in for loop.
valkyriefb_attach() doesn't have one defined in the function scope.

fixes VALKYRIEFB_DEBUG enabled build for macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/valkyriefb.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/macppc/dev/valkyriefb.c
diff -u src/sys/arch/macppc/dev/valkyriefb.c:1.8 src/sys/arch/macppc/dev/valkyriefb.c:1.9
--- src/sys/arch/macppc/dev/valkyriefb.c:1.8	Wed Feb 16 23:49:26 2022
+++ src/sys/arch/macppc/dev/valkyriefb.c	Sun Sep 24 10:51:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: valkyriefb.c,v 1.8 2022/02/16 23:49:26 riastradh Exp $	*/
+/*	$NetBSD: valkyriefb.c,v 1.9 2023/09/24 10:51:28 andvar Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: valkyriefb.c,v 1.8 2022/02/16 23:49:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: valkyriefb.c,v 1.9 2023/09/24 10:51:28 andvar Exp $");
 
 #include 
 #include 
@@ -209,7 +209,7 @@ valkyriefb_attach(device_t parent, devic
 	aprint_verbose_dev(sc->sc_dev, "waiting for videopll...\n");
 	sc->sc_base = (uint8_t *)ca->ca_reg[0];
 #ifdef VALKYRIEFB_DEBUG
-	for (i = 0; i < 0x40; i += 8) {
+	for (int i = 0; i < 0x40; i += 8) {
 		aprint_error_dev(sc->sc_dev, "%02x: %02x\n", i,
 		valkyriefb_read_reg(sc, i));
 	}



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 10:51:28 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: valkyriefb.c

Log Message:
define i variable in for loop.
valkyriefb_attach() doesn't have one defined in the function scope.

fixes VALKYRIEFB_DEBUG enabled build for macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/valkyriefb.c

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



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 08:20:06 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: mesh.c

Log Message:
define i variable in for loop.
mesh_msgin() doesn't have one defined in the function scope.

fixes MESH_DEBUG enabled build for macppc.


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

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



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

2023-09-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Sep 24 08:20:06 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: mesh.c

Log Message:
define i variable in for loop.
mesh_msgin() doesn't have one defined in the function scope.

fixes MESH_DEBUG enabled build for macppc.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/macppc/dev/mesh.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/macppc/dev/mesh.c
diff -u src/sys/arch/macppc/dev/mesh.c:1.42 src/sys/arch/macppc/dev/mesh.c:1.43
--- src/sys/arch/macppc/dev/mesh.c:1.42	Sat Aug  7 16:18:57 2021
+++ src/sys/arch/macppc/dev/mesh.c	Sun Sep 24 08:20:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mesh.c,v 1.42 2021/08/07 16:18:57 thorpej Exp $	*/
+/*	$NetBSD: mesh.c,v 1.43 2023/09/24 08:20:06 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2000	Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mesh.c,v 1.42 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mesh.c,v 1.43 2023/09/24 08:20:06 andvar Exp $");
 
 #include 
 #include 
@@ -694,7 +694,7 @@ mesh_msgin(struct mesh_softc *sc, struct
 gotit:
 #ifdef MESH_DEBUG
 	printf("msgin:");
-	for (i = 0; i < sc->sc_imsglen; i++)
+	for (int i = 0; i < sc->sc_imsglen; i++)
 		printf(" 0x%02x", sc->sc_imsg[i]);
 	printf("\n");
 #endif



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

2023-09-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  6 08:14:42 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: cuda.c

Log Message:
yet another tsleep/wakeup -> cv_*


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/dev/cuda.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/macppc/dev/cuda.c
diff -u src/sys/arch/macppc/dev/cuda.c:1.29 src/sys/arch/macppc/dev/cuda.c:1.30
--- src/sys/arch/macppc/dev/cuda.c:1.29	Sat Aug  7 16:18:57 2021
+++ src/sys/arch/macppc/dev/cuda.c	Wed Sep  6 08:14:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cuda.c,v 1.29 2021/08/07 16:18:57 thorpej Exp $ */
+/*	$NetBSD: cuda.c,v 1.30 2023/09/06 08:14:42 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.29 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.30 2023/09/06 08:14:42 macallan Exp $");
 
 #include 
 #include 
@@ -93,7 +93,8 @@ struct cuda_softc {
 	/* time */
 	uint32_t sc_tod;
 	uint32_t sc_autopoll;
-	uint32_t sc_todev;
+	kcondvar_t sc_todev;
+	kmutex_t sc_todevmtx;
 	/* ADB */
 	void (*sc_adb_handler)(void *, int, uint8_t *);
 	void *sc_adb_cookie;
@@ -197,6 +198,9 @@ cuda_attach(device_t parent, device_t se
 	sc->sc_error = 0;
 	sc->sc_i2c_read_len = 0;
 
+	cv_init(>sc_todev, "cuda_event");
+	mutex_init(>sc_todevmtx, MUTEX_DEFAULT, IPL_NONE);
+
 	if (bus_space_map(sc->sc_memt, ca->ca_reg[0] + ca->ca_baseaddr,
 	ca->ca_reg[1], 0, >sc_memh) != 0) {
 
@@ -728,7 +732,8 @@ cuda_error_handler(void *cookie, int len
 	 * byte 3 seems to be the failed command
 	 */
 	sc->sc_error = 1;
-	wakeup(>sc_todev);
+	DPRINTF("cuda error %02x %02x %02x %02x\n", data[0], data[1], data[2], data[3]);
+	cv_signal(>sc_todev);
 	return 0;
 }
 
@@ -763,7 +768,7 @@ cuda_todr_handler(void *cookie, int len,
 			sc->sc_iic_done = len;
 			break;
 	}
-	wakeup(>sc_todev);
+	cv_signal(>sc_todev);
 	return 0;
 }
 
@@ -781,7 +786,10 @@ cuda_todr_get(todr_chip_handle_t tch, st
 		cuda_send(sc, 0, 2, cmd);
 
 		while ((sc->sc_tod == 0) && (cnt < 10)) {
-			tsleep(>sc_todev, 0, "todr", 10);
+			mutex_enter(>sc_todevmtx);
+			cv_timedwait(>sc_todev, >sc_todevmtx, hz);
+			mutex_exit(>sc_todevmtx);
+
 			cnt++;
 		}
 
@@ -817,7 +825,9 @@ cuda_todr_set(todr_chip_handle_t tch, st
 	sc->sc_tod = 0;
 	if (cuda_send(sc, 0, 6, cmd) == 0) {
 		while (sc->sc_tod == 0) {
-			tsleep(>sc_todev, 0, "todr", 10);
+			mutex_enter(>sc_todevmtx);
+			cv_timedwait(>sc_todev, >sc_todevmtx, hz);
+			mutex_exit(>sc_todevmtx);
 		}
 		return 0;
 	}
@@ -874,8 +884,11 @@ cuda_autopoll(void *cookie, int flag)
 	while(sc->sc_autopoll == -1) {
 		if (sc->sc_polling || cold) {
 			cuda_poll(sc);
-		} else
-			tsleep(>sc_todev, 0, "autopoll", 100);
+		} else {
+			mutex_enter(>sc_todevmtx);
+			cv_timedwait(>sc_todev, >sc_todevmtx, hz);
+			mutex_exit(>sc_todevmtx);
+		}
 	}
 }
 	
@@ -962,8 +975,11 @@ cuda_i2c_exec(void *cookie, i2c_op_t op,
 	while ((sc->sc_iic_done == 0) && (sc->sc_error == 0)) {
 		if (sc->sc_polling || cold) {
 			cuda_poll(sc);
-		} else
-			tsleep(>sc_todev, 0, "i2c", 1000);
+		} else {
+			mutex_enter(>sc_todevmtx);
+			cv_timedwait(>sc_todev, >sc_todevmtx, hz);
+			mutex_exit(>sc_todevmtx);
+		}
 	}
 
 	if (sc->sc_error) {
@@ -988,8 +1004,11 @@ cuda_i2c_exec(void *cookie, i2c_op_t op,
 		while ((sc->sc_iic_done == 0) && (sc->sc_error == 0)) {
 			if (sc->sc_polling || cold) {
 cuda_poll(sc);
-			} else
-tsleep(>sc_todev, 0, "i2c", 1000);
+			} else {
+mutex_enter(>sc_todevmtx);
+cv_timedwait(>sc_todev, >sc_todevmtx, hz);
+mutex_exit(>sc_todevmtx);
+			}
 		}
 
 		if (sc->sc_error) {



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

2023-09-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  6 08:14:42 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: cuda.c

Log Message:
yet another tsleep/wakeup -> cv_*


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/dev/cuda.c

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



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

2023-08-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 30 08:38:51 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: awacs.c

Log Message:
don't abuse the interrupt lock for waits in the event thread


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/dev/awacs.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/macppc/dev/awacs.c
diff -u src/sys/arch/macppc/dev/awacs.c:1.51 src/sys/arch/macppc/dev/awacs.c:1.52
--- src/sys/arch/macppc/dev/awacs.c:1.51	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/dev/awacs.c	Wed Aug 30 08:38:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: awacs.c,v 1.51 2021/03/05 07:15:53 rin Exp $	*/
+/*	$NetBSD: awacs.c,v 1.52 2023/08/30 08:38:51 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.51 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.52 2023/08/30 08:38:51 macallan Exp $");
 
 #include 
 #include 
@@ -102,6 +102,7 @@ struct awacs_softc {
 	struct dbdma_command *sc_idmacmd;
 
 	kmutex_t sc_lock;
+	kmutex_t sc_event_lock;
 	kmutex_t sc_intr_lock;
 };
 
@@ -375,6 +376,7 @@ awacs_attach(device_t parent, device_t s
 	intr_xname);
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(>sc_event_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO);
 
 	cv_init(>sc_event, "awacs_wait");
@@ -1274,9 +1276,10 @@ awacs_thread(void *cookie)
 {
 	struct awacs_softc *sc = cookie;
 	
-	mutex_enter(>sc_intr_lock);
 	while (1) {
-		cv_timedwait(>sc_event, >sc_intr_lock, hz);
+		mutex_enter(>sc_event_lock);
+		cv_timedwait(>sc_event, >sc_event_lock, hz);
+		mutex_exit(>sc_event_lock);
 		if (sc->sc_output_wanted == sc->sc_output_mask)
 			continue;
 



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

2023-08-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 30 08:38:51 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: awacs.c

Log Message:
don't abuse the interrupt lock for waits in the event thread


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/dev/awacs.c

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



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

2023-08-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 30 07:42:41 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
remove ancient #if 0 block
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/macppc/dev/pmu.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/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.40 src/sys/arch/macppc/dev/pmu.c:1.41
--- src/sys/arch/macppc/dev/pmu.c:1.40	Tue Aug 22 06:43:34 2023
+++ src/sys/arch/macppc/dev/pmu.c	Wed Aug 30 07:42:41 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.40 2023/08/22 06:43:34 macallan Exp $ */
+/*	$NetBSD: pmu.c,v 1.41 2023/08/30 07:42:41 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.40 2023/08/22 06:43:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.41 2023/08/30 07:42:41 macallan Exp $");
 
 #include 
 #include 
@@ -762,21 +762,6 @@ done:
 	return 1;
 }
 
-#if 0
-static int
-pmu_error_handler(void *cookie, int len, uint8_t *data)
-{
-	struct pmu_softc *sc = cookie;
-
-	/* 
-	 * something went wrong
-	 * byte 3 seems to be the failed command
-	 */
-	sc->sc_error = 1;
-	wakeup(>sc_todev);
-	return 0;
-}
-#endif
 #define DIFF19041970 2082844800
 
 static int



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

2023-08-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 30 07:42:41 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
remove ancient #if 0 block
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/macppc/dev/pmu.c

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



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

2023-08-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Aug 22 06:43:34 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
tsleep()/wakeup() -> cv_*


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/macppc/dev/pmu.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/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.39 src/sys/arch/macppc/dev/pmu.c:1.40
--- src/sys/arch/macppc/dev/pmu.c:1.39	Sat Aug  7 16:18:58 2021
+++ src/sys/arch/macppc/dev/pmu.c	Tue Aug 22 06:43:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.39 2021/08/07 16:18:58 thorpej Exp $ */
+/*	$NetBSD: pmu.c,v 1.40 2023/08/22 06:43:34 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.39 2021/08/07 16:18:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.40 2023/08/22 06:43:34 macallan Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.39
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -105,7 +106,8 @@ struct pmu_softc {
 	lwp_t *sc_thread;
 	int sc_pending;
 	/* signalling the event thread */
-	int sc_event;
+	kcondvar_t sc_event;
+	kmutex_t sc_evmtx;
 	/* ADB */
 	void (*sc_adb_handler)(void *, int, uint8_t *);
 	void *sc_adb_cookie;
@@ -296,6 +298,9 @@ pmu_attach(device_t parent, device_t sel
 	sc->sc_button = 0;
 	sc->sc_env_mask = 0xff;
 
+	cv_init(>sc_event, "pmu_event");
+	mutex_init(>sc_evmtx, MUTEX_DEFAULT, IPL_NONE);
+	
 	/*
 	 * core99 PowerMacs like to send environment messages with the lid
 	 * switch bit set - since that doesn't make any sense here and it
@@ -699,14 +704,14 @@ pmu_intr(void *arg)
 		DPRINTF("brightness: %d volume %d\n", resp[2], resp[3]);
 		sc->sc_brightness_wanted = resp[2];
 		sc->sc_volume_wanted = resp[3];
-		wakeup(>sc_event);
+		cv_signal(>sc_event);
 		goto done;
 	}
 	if (resp[1] & PMU_INT_PCEJECT) {
 		/* deal with PCMCIA eject buttons */
 		DPRINTF("card eject %d\n", resp[3]);
 		atomic_or_32(>sc_pending, (resp[3] & 3));
-		wakeup(>sc_event);
+		cv_signal(>sc_event);
 		goto done;
 	}
 	if (resp[1] & PMU_INT_BATTERY) {
@@ -719,7 +724,7 @@ pmu_intr(void *arg)
 	}
 	if (resp[1] & PMU_INT_ENVIRONMENT) {
 		uint8_t diff;
-#ifdef PMU_VERBOSE
+#ifdef PMU_DEBUG
 		/* deal with environment messages */
 		printf("environment:");
 		for (i = 2; i < len; i++)
@@ -732,12 +737,12 @@ pmu_intr(void *arg)
 		if (diff & PMU_ENV_LID_CLOSED) {
 			sc->sc_lid_closed = (resp[2] & PMU_ENV_LID_CLOSED) != 0;
 			atomic_or_32(>sc_pending, PMU_EV_LID);
-			wakeup(>sc_event);
+			cv_signal(>sc_event);
 		}
 		if (diff & PMU_ENV_POWER_BUTTON) {
 			sc->sc_button = (resp[2] & PMU_ENV_POWER_BUTTON) != 0;
 			atomic_or_32(>sc_pending, PMU_EV_BUTTON);
-			wakeup(>sc_event);
+			cv_signal(>sc_event);
 		}
 		goto done;
 	}
@@ -1054,7 +1059,8 @@ pmu_thread(void *cookie)
 	int ticks = hz, i;
 	
 	while (1) {
-		tsleep(>sc_event, PWAIT, "wait", ticks);
+		mutex_enter(>sc_evmtx);
+		cv_timedwait(>sc_event, >sc_evmtx, ticks);
 		if ((sc->sc_pending & 3) != 0) {
 			DPRINTF("eject %d\n", sc->sc_pending & 3);
 			for (i = 1; i < 3; i++) {
@@ -1062,7 +1068,7 @@ pmu_thread(void *cookie)
 	pmu_eject_card(sc, i);
 			}
 		}
-
+		mutex_exit(>sc_evmtx);
 		/* see if we need to update brightness */
 		if (sc->sc_brightness_wanted != sc->sc_brightness) {
 			pmu_update_brightness(sc);



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

2023-08-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Aug 22 06:43:34 UTC 2023

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
tsleep()/wakeup() -> cv_*


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/macppc/dev/pmu.c

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



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:34:42 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: obio.c

Log Message:
one more skiplist entry...


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/macppc/dev/obio.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/macppc/dev/obio.c
diff -u src/sys/arch/macppc/dev/obio.c:1.52 src/sys/arch/macppc/dev/obio.c:1.53
--- src/sys/arch/macppc/dev/obio.c:1.52	Wed Dec 28 07:12:36 2022
+++ src/sys/arch/macppc/dev/obio.c	Wed Dec 28 07:34:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: obio.c,v 1.52 2022/12/28 07:12:36 macallan Exp $	*/
+/*	$NetBSD: obio.c,v 1.53 2022/12/28 07:34:42 macallan Exp $	*/
 
 /*-
  * Copyright (C) 1998	Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.52 2022/12/28 07:12:36 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.53 2022/12/28 07:34:42 macallan Exp $");
 
 #include 
 #include 
@@ -281,6 +281,7 @@ static const char * const skiplist[] = {
 	"interrupt-controller",
 	"chrp,open-pic",
 	"open-pic",
+	"mpic",
 	"gpio",
 	"escc-legacy",
 	"timer",



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:34:42 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: obio.c

Log Message:
one more skiplist entry...


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

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



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:18:29 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: uni-n.c

Log Message:
don't complain about mpic and dart not being configured
mpic is handled elsewhere, dart is an iommu we don't use yet


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

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



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:18:29 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: uni-n.c

Log Message:
don't complain about mpic and dart not being configured
mpic is handled elsewhere, dart is an iommu we don't use yet


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/dev/uni-n.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/macppc/dev/uni-n.c
diff -u src/sys/arch/macppc/dev/uni-n.c:1.12 src/sys/arch/macppc/dev/uni-n.c:1.13
--- src/sys/arch/macppc/dev/uni-n.c:1.12	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/macppc/dev/uni-n.c	Wed Dec 28 07:18:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uni-n.c,v 1.12 2022/01/22 11:49:16 thorpej Exp $	*/
+/*	$NetBSD: uni-n.c,v 1.13 2022/12/28 07:18:29 macallan Exp $	*/
 
 /*-
  * Copyright (C) 2005 Michael Lorenz.
@@ -31,7 +31,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.12 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.13 2022/12/28 07:18:29 macallan Exp $");
 
 #include 
 #include 
@@ -63,6 +63,17 @@ CFATTACH_DECL_NEW(uni_n, sizeof(struct u
 static uint8_t eeprom[2][160];
 #endif
 
+static const char *skiplist[] = {
+	"openpic",
+	"chrp,open-pic",
+	"open-pic",
+	"mpic",
+	"dart",
+	"u3-dart",
+	"u4-dart",
+	NULL
+};
+
 int
 uni_n_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -108,7 +119,7 @@ uni_n_attach(device_t parent, device_t s
 #if NFCU > 0
 	/*
 	 * zero out eeprom blocks, then see if we have valid data
-	 * doing this here because the EEPROMs are dangling from out i2c bus
+	 * doing this here because the EEPROMs are dangling from our i2c bus
 	 * but we can get all the data just from looking at the properties
 	 */
 	memset(eeprom, 0, sizeof(eeprom));
@@ -116,6 +127,7 @@ uni_n_attach(device_t parent, device_t s
 	OF_getprop(cpuid, "cpuid", eeprom[0], sizeof(eeprom[0]));
 	if (eeprom[0][1] != 0)
 		aprint_normal_dev(self, "found EEPROM data for CPU 0\n");
+
 	cpuid = OF_finddevice("/u3/i2c/cpuid@a2");
 	OF_getprop(cpuid, "cpuid", eeprom[1], sizeof(eeprom[1]));
 	if (eeprom[1][1] != 0)
@@ -131,6 +143,7 @@ uni_n_attach(device_t parent, device_t s
 
 	devhandle_t selfh = device_handle(self);
 	for (child = OF_child(node); child; child = OF_peer(child)) {
+		if (of_compatible(child, skiplist)) continue;
 		namelen = OF_getprop(child, "name", name, sizeof(name));
 		if (namelen < 0)
 			continue;



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:12:36 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: obio.c

Log Message:
suppress 'not configured' message for mpic on G5s


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/dev/obio.c

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



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 07:12:36 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: obio.c

Log Message:
suppress 'not configured' message for mpic on G5s


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/dev/obio.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/macppc/dev/obio.c
diff -u src/sys/arch/macppc/dev/obio.c:1.51 src/sys/arch/macppc/dev/obio.c:1.52
--- src/sys/arch/macppc/dev/obio.c:1.51	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/macppc/dev/obio.c	Wed Dec 28 07:12:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: obio.c,v 1.51 2022/01/22 11:49:16 thorpej Exp $	*/
+/*	$NetBSD: obio.c,v 1.52 2022/12/28 07:12:36 macallan Exp $	*/
 
 /*-
  * Copyright (C) 1998	Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.51 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.52 2022/12/28 07:12:36 macallan Exp $");
 
 #include 
 #include 
@@ -279,6 +279,8 @@ obio_attach(device_t parent, device_t se
 
 static const char * const skiplist[] = {
 	"interrupt-controller",
+	"chrp,open-pic",
+	"open-pic",
 	"gpio",
 	"escc-legacy",
 	"timer",



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 11:08:29 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: if_gm.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/if_gm.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/macppc/dev/if_gm.c
diff -u src/sys/arch/macppc/dev/if_gm.c:1.58 src/sys/arch/macppc/dev/if_gm.c:1.59
--- src/sys/arch/macppc/dev/if_gm.c:1.58	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/dev/if_gm.c	Sun Sep 18 11:08:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gm.c,v 1.58 2021/03/05 07:15:53 rin Exp $	*/
+/*	$NetBSD: if_gm.c,v 1.59 2022/09/18 11:08:29 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.58 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.59 2022/09/18 11:08:29 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -75,6 +75,7 @@ struct gmac_softc {
 	struct gmac_dma *sc_txlist;
 	struct gmac_dma *sc_rxlist;
 	int sc_txnext;
+	bool sc_txbusy;
 	int sc_rxlast;
 	void *sc_txbuf[NTXBUF];
 	void *sc_rxbuf[NRXBUF];
@@ -337,7 +338,7 @@ gmac_tint(struct gmac_softc *sc)
 {
 	struct ifnet *ifp = >sc_if;
 
-	ifp->if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 	ifp->if_timer = 0;
 	if_schedule_deferred_start(ifp);
 }
@@ -446,13 +447,10 @@ gmac_start(struct ifnet *ifp)
 	int i, tlen;
 	volatile struct gmac_dma *dp;
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
-	for (;;) {
-		if (ifp->if_flags & IFF_OACTIVE)
-			break;
-
+	while (!sc->sc_txbusy) {
 		IFQ_DEQUEUE(>if_snd, m);
 		if (m == 0)
 			break;
@@ -489,7 +487,7 @@ gmac_start(struct ifnet *ifp)
 		if (i == NTXBUF)
 			i = 0;
 		if (i == gmac_read_reg(sc, GMAC_TXDMACOMPLETE)) {
-			ifp->if_flags |= IFF_OACTIVE;
+			sc->sc_txbusy = true;
 			break;
 		}
 	}
@@ -732,7 +730,7 @@ gmac_init(struct gmac_softc *sc)
 	gmac_write_reg(sc, GMAC_INTMASK, ~(GMAC_INT_TXEMPTY | GMAC_INT_RXDONE));
 
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 	ifp->if_timer = 0;
 
 	callout_reset(>sc_tick_ch, 1, gmac_mii_tick, sc);



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 11:08:29 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: if_gm.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/if_gm.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 10:59:22 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: if_bm.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/macppc/dev/if_bm.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/macppc/dev/if_bm.c
diff -u src/sys/arch/macppc/dev/if_bm.c:1.64 src/sys/arch/macppc/dev/if_bm.c:1.65
--- src/sys/arch/macppc/dev/if_bm.c:1.64	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/dev/if_bm.c	Sun Sep 18 10:59:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bm.c,v 1.64 2021/03/05 07:15:53 rin Exp $	*/
+/*	$NetBSD: if_bm.c,v 1.65 2022/09/18 10:59:22 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 1998, 1999, 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.64 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.65 2022/09/18 10:59:22 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -90,6 +90,7 @@ struct bmac_softc {
 	void *sc_rxbuf;
 	int sc_rxlast;
 	int sc_flags;
+	bool sc_txbusy;
 	struct mii_data sc_mii;
 	u_char sc_enaddr[6];
 };
@@ -382,7 +383,7 @@ bmac_init(struct bmac_softc *sc)
 	bmac_write_reg(sc, INTDISABLE, NormalIntEvents);
 
 	ifp->if_flags |= IFF_RUNNING;
-	ifp->if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 	ifp->if_timer = 0;
 
 	data = sc->sc_txbuf;
@@ -440,7 +441,7 @@ bmac_intr(void *v)
 #endif
 
 	if (stat & IntFrameSent) {
-		sc->sc_if.if_flags &= ~IFF_OACTIVE;
+		sc->sc_txbusy = false;
 		sc->sc_if.if_timer = 0;
 		if_statinc(>sc_if, if_opackets);
 		if_schedule_deferred_start(>sc_if);
@@ -561,13 +562,10 @@ bmac_start(struct ifnet *ifp)
 	struct mbuf *m;
 	int tlen;
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
-	while (1) {
-		if (ifp->if_flags & IFF_OACTIVE)
-			return;
-
+	while (!sc->sc_txbusy) {
 		IFQ_DEQUEUE(>if_snd, m);
 		if (m == 0)
 			break;
@@ -577,7 +575,7 @@ bmac_start(struct ifnet *ifp)
 		 */
 		bpf_mtap(ifp, m, BPF_D_OUT);
 
-		ifp->if_flags |= IFF_OACTIVE;
+		sc->sc_txbusy = true;
 		tlen = bmac_put(sc, sc->sc_txbuf, m);
 
 		/* 5 seconds to watch for failing to transmit */



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 10:59:22 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: if_bm.c

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/macppc/dev/if_bm.c

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



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 10:54:53 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: am79c950.c if_mcvar.h

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/macppc/dev/am79c950.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/dev/if_mcvar.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/macppc/dev/am79c950.c
diff -u src/sys/arch/macppc/dev/am79c950.c:1.50 src/sys/arch/macppc/dev/am79c950.c:1.51
--- src/sys/arch/macppc/dev/am79c950.c:1.50	Tue Oct 20 18:17:58 2020
+++ src/sys/arch/macppc/dev/am79c950.c	Sun Sep 18 10:54:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $	*/
+/*	$NetBSD: am79c950.c,v 1.51 2022/09/18 10:54:52 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.51 2022/09/18 10:54:52 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -250,13 +250,10 @@ mcstart(struct ifnet *ifp)
 	struct mc_softc	*sc = ifp->if_softc;
 	struct mbuf	*m;
 
-	if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 
-	while (1) {
-		if (ifp->if_flags & IFF_OACTIVE)
-			return;
-
+	while (!sc->sc_txbusy) {
 		IF_DEQUEUE(>if_snd, m);
 		if (m == 0)
 			return;
@@ -268,7 +265,7 @@ mcstart(struct ifnet *ifp)
 		bpf_mtap(ifp, m, BPF_D_OUT);
 
 		/* Copy the mbuf chain into the transmit buffer. */
-		ifp->if_flags |= IFF_OACTIVE;
+		sc->sc_txbusy = true;
 		maceput(sc, m);
 
 		if_statinc(ifp, if_opackets);		/* # of pkts */
@@ -348,7 +345,7 @@ mcinit(struct mc_softc *sc)
 
 	/* Flag interface as "running" */
 	sc->sc_if.if_flags |= IFF_RUNNING;
-	sc->sc_if.if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 
 	splx(s);
 	return 0;
@@ -515,7 +512,7 @@ mc_tint(struct mc_softc *sc)
 	}
 	IF_STAT_PUTREF(>sc_if);
 
-	sc->sc_if.if_flags &= ~IFF_OACTIVE;
+	sc->sc_txbusy = false;
 	sc->sc_if.if_timer = 0;
 	if_schedule_deferred_start(>sc_if);
 }

Index: src/sys/arch/macppc/dev/if_mcvar.h
diff -u src/sys/arch/macppc/dev/if_mcvar.h:1.13 src/sys/arch/macppc/dev/if_mcvar.h:1.14
--- src/sys/arch/macppc/dev/if_mcvar.h:1.13	Tue Jul 26 08:36:02 2011
+++ src/sys/arch/macppc/dev/if_mcvar.h	Sun Sep 18 10:54:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcvar.h,v 1.13 2011/07/26 08:36:02 macallan Exp $	*/
+/*	$NetBSD: if_mcvar.h,v 1.14 2022/09/18 10:54:52 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang 
@@ -86,6 +86,7 @@ struct mc_softc {
 	u_char		*sc_txbuf, *sc_rxbuf;
 	int		sc_txbuf_phys, sc_rxbuf_phys;
 	int		sc_tail;
+	bool		sc_txbusy;
 
 	int		sc_node;
 	dbdma_regmap_t	*sc_txdma;



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

2022-09-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 18 10:54:53 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: am79c950.c if_mcvar.h

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/macppc/dev/am79c950.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/dev/if_mcvar.h

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



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

2022-06-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jun 29 17:59:40 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: ki2c.c

Log Message:
Use old limit of 32 + 32 bytes to keep combining buffer on stack.
There are no devices on this platform that need more and for larger
values, the driver should be better rewritten.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/macppc/dev/ki2c.c

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



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

2022-06-29 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jun 29 17:59:40 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: ki2c.c

Log Message:
Use old limit of 32 + 32 bytes to keep combining buffer on stack.
There are no devices on this platform that need more and for larger
values, the driver should be better rewritten.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/macppc/dev/ki2c.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/macppc/dev/ki2c.c
diff -u src/sys/arch/macppc/dev/ki2c.c:1.32 src/sys/arch/macppc/dev/ki2c.c:1.33
--- src/sys/arch/macppc/dev/ki2c.c:1.32	Sat Aug  7 16:18:57 2021
+++ src/sys/arch/macppc/dev/ki2c.c	Wed Jun 29 17:59:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ki2c.c,v 1.32 2021/08/07 16:18:57 thorpej Exp $	*/
+/*	$NetBSD: ki2c.c,v 1.33 2022/06/29 17:59:40 mlelstv Exp $	*/
 /*	Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp	*/
 
 /*-
@@ -44,6 +44,9 @@
 #define DPRINTF while (0) printf
 #endif
 
+#define KI2C_EXEC_MAX_CMDLEN	32
+#define KI2C_EXEC_MAX_BUFLEN	32
+
 int ki2c_match(device_t, cfdata_t, void *);
 void ki2c_attach(device_t, device_t, void *);
 inline uint8_t ki2c_readreg(struct ki2c_softc *, int);
@@ -393,7 +396,7 @@ ki2c_i2c_exec(void *cookie, i2c_op_t op,
 	int i;
 	size_t w_len;
 	uint8_t *wp;
-	uint8_t wrbuf[I2C_EXEC_MAX_CMDLEN + I2C_EXEC_MAX_CMDLEN];
+	uint8_t wrbuf[KI2C_EXEC_MAX_CMDLEN + KI2C_EXEC_MAX_CMDLEN];
 	uint8_t channel;
 
 	/*
@@ -404,6 +407,13 @@ ki2c_i2c_exec(void *cookie, i2c_op_t op,
 	if (cmdlen == 0 && buflen == 0)
 		return -1;
 
+	/*
+	 * Transaction could be much larger now. Bail if it exceeds our
+	 * small combining buffer, we don't expect such devices.
+	 */
+	if (cmdlen + buflen > sizeof(wrbuf))
+		return -1;
+
 	channel = (addr & 0xf80) ? 0x10 : 0x00;
 	addr &= 0x7f;
 	



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

2022-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun  2 16:22:27 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
check platform-do-*-mute properties to find out the resp. GPIO's polarity
now this works properly on pmac7,3


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.64 src/sys/arch/macppc/dev/snapper.c:1.65
--- src/sys/arch/macppc/dev/snapper.c:1.64	Wed Jun  1 06:05:47 2022
+++ src/sys/arch/macppc/dev/snapper.c	Thu Jun  2 16:22:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.64 2022/06/01 06:05:47 martin Exp $	*/
+/*	$NetBSD: snapper.c,v 1.65 2022/06/02 16:22:27 macallan Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.64 2022/06/01 06:05:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.65 2022/06/02 16:22:27 macallan Exp $");
 
 #include 
 #include 
@@ -1962,9 +1962,9 @@ gpio_write(bus_size_t addr, int val)
 	obio_write_1(addr, data);
 }
 
-#define headphone_active 0	/* XXX OF */
-#define lineout_active 0	/* XXX OF */
-#define amp_active 0		/* XXX OF */
+int headphone_active = 0;
+int lineout_active = 0;
+int amp_active = 0;
 
 static void
 snapper_mute_speaker(struct snapper_softc *sc, int mute)
@@ -1977,9 +1977,9 @@ snapper_mute_speaker(struct snapper_soft
 		if (mute)
 			x = amp_active;		/* mute */
 		else
-			x = !amp_active;	/* unmute */
-		if (x != gpio_read(amp_mute))
-			gpio_write(amp_mute, x);
+			x = amp_active ^ 1;	/* unmute */
+
+		gpio_write(amp_mute, x);
 
 		DPRINTF("%d\n", gpio_read(amp_mute));
 	}
@@ -1996,9 +1996,9 @@ snapper_mute_headphone(struct snapper_so
 		if (mute)
 			x = headphone_active;	/* mute */
 		else
-			x = !headphone_active;	/* unmute */
-		if (x != gpio_read(headphone_mute))
-			gpio_write(headphone_mute, x);
+			x = headphone_active ^ 1;	/* unmute */
+
+		gpio_write(headphone_mute, x);
 
 		DPRINTF("%d\n", gpio_read(headphone_mute));
 	}
@@ -2015,9 +2015,9 @@ snapper_mute_lineout(struct snapper_soft
 		if (mute)
 			x = lineout_active;	/* mute */
 		else
-			x = !lineout_active;	/* unmute */
-		if (x != gpio_read(lineout_mute))
-			gpio_write(lineout_mute, x);
+			x = lineout_active ^ 1;	/* unmute */
+
+		gpio_write(lineout_mute, x);
 
 		DPRINTF("%d\n", gpio_read(lineout_mute));
 	}
@@ -2134,7 +2134,7 @@ snapper_init(struct snapper_softc *sc, i
 {
 	int gpio;
 	int headphone_detect_intr, lineout_detect_intr;
-	uint32_t gpio_base, reg[1], fcreg;
+	uint32_t gpio_base, reg[1], fcreg, buf[8];
 	char intr_xname[INTRDEVNAMEBUF];
 #ifdef SNAPPER_DEBUG
 	char fcr[32];
@@ -2182,12 +2182,26 @@ snapper_init(struct snapper_softc *sc, i
 
 		/* gpio5 */
 		if (strcmp(audio_gpio, "headphone-mute") == 0 ||
-		strcmp(name, "headphone-mute") == 0)
+		strcmp(name, "headphone-mute") == 0) {
 			headphone_mute = addr;
+			if (OF_getprop(gpio,
+			"platform-do-headphone-mute", buf, 20) == 20) {
+headphone_active = buf[3] & 1;
+DPRINTF("platform-do-headphone-mute %d\n",
+headphone_active);
+			}
+		}
 		/* gpio6 */
 		if (strcmp(audio_gpio, "amp-mute") == 0 ||
-		strcmp(name, "amp-mute") == 0)
+		strcmp(name, "amp-mute") == 0) {
 			amp_mute = addr;
+			if (OF_getprop(gpio,
+			"platform-do-amp-mute", buf, 20) == 20) {
+amp_active = buf[3] & 1;
+DPRINTF("platform-do-amp-mute %d\n",
+amp_active);
+			}
+		}
 		/* extint-gpio15 */
 		if (strcmp(audio_gpio, "headphone-detect") == 0 ||
 		strcmp(name, "headphone-detect") == 0) {
@@ -2201,8 +2215,15 @@ snapper_init(struct snapper_softc *sc, i
 		}
 		if (strcmp(audio_gpio, "lineout-mute") == 0 ||
 		strcmp(name, "lineout-mute") == 0 ||
-		strcmp(name, "line-output-mute") == 0)
+		strcmp(name, "line-output-mute") == 0) {
 			lineout_mute = addr;
+			if (OF_getprop(gpio,
+			"platform-do-lineout-mute", buf, 20) == 20) {
+lineout_active = buf[3] & 1;
+DPRINTF("platform-do-lineout-mute %d\n",
+lineout_active);
+			}
+		}
 		if (strcmp(audio_gpio, "lineout-detect") == 0 ||
 		strcmp(name, "lineout-detect") == 0 ||
 		strcmp(name, "line-output-detect") == 0) {
@@ -2242,8 +2263,8 @@ snapper_init(struct snapper_softc *sc, i
 	if (headphone_detect_intr != -1) {
 		snprintf(intr_xname, sizeof(intr_xname), "%s headphone",
 		device_xname(sc->sc_dev));
-		intr_establish_xname(headphone_detect_intr, IST_EDGE, IPL_AUDIO,
-		snapper_cint, sc, intr_xname);
+		intr_establish_xname(headphone_detect_intr, IST_EDGE,
+		IPL_AUDIO, snapper_cint, sc, intr_xname);
 	}
 
 	if (lineout_detect_intr != -1) {



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

2022-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun  2 16:22:27 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
check platform-do-*-mute properties to find out the resp. GPIO's polarity
now this works properly on pmac7,3


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/macppc/dev/snapper.c

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



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

2022-06-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 06:05:47 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Revert previous, the mask is intented to be like sc_output_mask, a bitmask
of active ports.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.63 src/sys/arch/macppc/dev/snapper.c:1.64
--- src/sys/arch/macppc/dev/snapper.c:1.63	Wed Jun  1 05:47:37 2022
+++ src/sys/arch/macppc/dev/snapper.c	Wed Jun  1 06:05:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.63 2022/06/01 05:47:37 martin Exp $	*/
+/*	$NetBSD: snapper.c,v 1.64 2022/06/01 06:05:47 martin Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.63 2022/06/01 05:47:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.64 2022/06/01 06:05:47 martin Exp $");
 
 #include 
 #include 
@@ -1274,11 +1274,11 @@ snapper_query_devinfo(void *h, mixer_dev
 		dip->prev = dip->next = AUDIO_MIXER_LAST;
 		dip->un.s.num_mem = 3;
 		strcpy(dip->un.s.member[0].label.name, AudioNspeaker);
-		dip->un.s.member[0].mask = (1 << 1)|(1 << 2);
+		dip->un.s.member[0].mask = 1 << 0;
 		strcpy(dip->un.s.member[1].label.name, AudioNheadphone);
-		dip->un.s.member[1].mask = (1 << 0)|(1 << 2);
+		dip->un.s.member[1].mask = 1 << 1;
 		strcpy(dip->un.s.member[2].label.name, AudioNline);
-		dip->un.s.member[2].mask = (1 << 0)|(1 << 1);
+		dip->un.s.member[2].mask = 1 << 2;
 		return 0;
 
 	case SNAPPER_VOL_OUTPUT:



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

2022-06-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 06:05:47 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Revert previous, the mask is intented to be like sc_output_mask, a bitmask
of active ports.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/macppc/dev/snapper.c

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



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

2022-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 05:47:37 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
In SNAPPER_OUTPUT_SELECT the "mask" is a bitmap of muted outputs, not
active outputs.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.62 src/sys/arch/macppc/dev/snapper.c:1.63
--- src/sys/arch/macppc/dev/snapper.c:1.62	Wed Jun  1 05:42:52 2022
+++ src/sys/arch/macppc/dev/snapper.c	Wed Jun  1 05:47:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.62 2022/06/01 05:42:52 martin Exp $	*/
+/*	$NetBSD: snapper.c,v 1.63 2022/06/01 05:47:37 martin Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.62 2022/06/01 05:42:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.63 2022/06/01 05:47:37 martin Exp $");
 
 #include 
 #include 
@@ -1274,11 +1274,11 @@ snapper_query_devinfo(void *h, mixer_dev
 		dip->prev = dip->next = AUDIO_MIXER_LAST;
 		dip->un.s.num_mem = 3;
 		strcpy(dip->un.s.member[0].label.name, AudioNspeaker);
-		dip->un.s.member[0].mask = 1 << 0;
+		dip->un.s.member[0].mask = (1 << 1)|(1 << 2);
 		strcpy(dip->un.s.member[1].label.name, AudioNheadphone);
-		dip->un.s.member[1].mask = 1 << 1;
+		dip->un.s.member[1].mask = (1 << 0)|(1 << 2);
 		strcpy(dip->un.s.member[2].label.name, AudioNline);
-		dip->un.s.member[2].mask = 1 << 2;
+		dip->un.s.member[2].mask = (1 << 0)|(1 << 1);
 		return 0;
 
 	case SNAPPER_VOL_OUTPUT:



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

2022-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 05:47:37 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
In SNAPPER_OUTPUT_SELECT the "mask" is a bitmap of muted outputs, not
active outputs.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/macppc/dev/snapper.c

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



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

2022-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 05:42:52 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Recognize the OF labels used for line output and headphone output on a
G5 powermac 7,3.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.61 src/sys/arch/macppc/dev/snapper.c:1.62
--- src/sys/arch/macppc/dev/snapper.c:1.61	Sat Aug  7 16:18:58 2021
+++ src/sys/arch/macppc/dev/snapper.c	Wed Jun  1 05:42:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.61 2021/08/07 16:18:58 thorpej Exp $	*/
+/*	$NetBSD: snapper.c,v 1.62 2022/06/01 05:42:52 martin Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.61 2021/08/07 16:18:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.62 2022/06/01 05:42:52 martin Exp $");
 
 #include 
 #include 
@@ -2200,10 +2200,12 @@ snapper_init(struct snapper_softc *sc, i
 			}
 		}
 		if (strcmp(audio_gpio, "lineout-mute") == 0 ||
-		strcmp(name, "lineout-mute") == 0)
+		strcmp(name, "lineout-mute") == 0 ||
+		strcmp(name, "line-output-mute") == 0)
 			lineout_mute = addr;
 		if (strcmp(audio_gpio, "lineout-detect") == 0 ||
-		strcmp(name, "lineout-detect") == 0) {
+		strcmp(name, "lineout-detect") == 0 ||
+		strcmp(name, "line-output-detect") == 0) {
 			uint32_t act = 0;
 			lineout_detect = addr;
 			OF_getprop(gpio, "audio-gpio-active-state", , 4);



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

2022-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jun  1 05:42:52 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
Recognize the OF labels used for line output and headphone output on a
G5 powermac 7,3.


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

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



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

2022-02-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Feb 11 04:23:19 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: apm.c

Log Message:
Remove some #ifdef __OpenBSD__ code that's not complete and thus doesn't
serve much point in existing here.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/macppc/dev/apm.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/macppc/dev/apm.c
diff -u src/sys/arch/macppc/dev/apm.c:1.31 src/sys/arch/macppc/dev/apm.c:1.32
--- src/sys/arch/macppc/dev/apm.c:1.31	Sun Sep 26 16:36:19 2021
+++ src/sys/arch/macppc/dev/apm.c	Fri Feb 11 04:23:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apm.c,v 1.31 2021/09/26 16:36:19 thorpej Exp $	*/
+/*	$NetBSD: apm.c,v 1.32 2022/02/11 04:23:18 thorpej Exp $	*/
 /*	$OpenBSD: apm.c,v 1.5 2002/06/07 07:13:59 miod Exp $	*/
 
 /*-
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.31 2021/09/26 16:36:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.32 2022/02/11 04:23:18 thorpej Exp $");
 
 #include "apm.h"
 
@@ -49,18 +49,10 @@ __KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.31
 #include 
 #include 
 #include 
-#ifdef __OpenBSD__
-#include 
-#endif
-#ifdef __NetBSD__
 #include 
 #include 
 #include 
-#endif
 
-#ifdef __OpenBSD__
-#include 
-#endif
 #include 
 #include 
 
@@ -77,9 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.31
 
 struct apm_softc {
 	struct selinfo sc_rsel;
-#ifdef __OpenBSD__
-	struct klist sc_note;
-#endif
 	intsc_flags;
 	int	event_count;
 	int	event_ptr;
@@ -93,31 +82,19 @@ struct apm_softc {
  * APM module.  This is both the APM thread itself, as well as
  * user context.
  */
-#ifdef __NetBSD__
 #define	APM_LOCK(apmsc)		mutex_enter(&(apmsc)->sc_lock)
 #define	APM_UNLOCK(apmsc)	mutex_exit(&(apmsc)->sc_lock)
-#else
-#define APM_LOCK(apmsc)
-#define APM_UNLOCK(apmsc)
-#endif
 
 int apmmatch(device_t, cfdata_t, void *);
 void apmattach(device_t, device_t, void *);
 
-#ifdef __NetBSD__
 #if 0
 static int	apm_record_event(struct apm_softc *, u_int);
 #endif
-#endif
 
 CFATTACH_DECL_NEW(apm, sizeof(struct apm_softc),
 apmmatch, apmattach, NULL, NULL);
 
-#ifdef __OpenBSD__
-struct cfdriver apm_cd = {
-	NULL, "apm", DV_DULL
-};
-#else
 extern struct cfdriver apm_cd;
 
 dev_type_open(apmopen);
@@ -140,7 +117,6 @@ const struct cdevsw apm_cdevsw = {
 	.d_discard = nodiscard,
 	.d_flag = 0
 };
-#endif
 
 int	apm_evindex;
 
@@ -365,7 +341,6 @@ apmioctl(dev_t dev, u_long cmd, void *da
 	return error;
 }
 
-#ifdef __NetBSD__
 #if 0
 /*
  * return 0 if the user will notice and handle the event,
@@ -410,7 +385,6 @@ apmpoll(dev_t dev, int events, struct lw
 
 	return (revents);
 }
-#endif
 
 static void
 filt_apmrdetach(struct knote *kn)



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

2022-02-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Feb 11 04:23:19 UTC 2022

Modified Files:
src/sys/arch/macppc/dev: apm.c

Log Message:
Remove some #ifdef __OpenBSD__ code that's not complete and thus doesn't
serve much point in existing here.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/macppc/dev/apm.c

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



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

2021-09-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 11 16:29:18 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: obiofan.c

Log Message:
fix license copypasta
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/obiofan.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/macppc/dev/obiofan.c
diff -u src/sys/arch/macppc/dev/obiofan.c:1.1 src/sys/arch/macppc/dev/obiofan.c:1.2
--- src/sys/arch/macppc/dev/obiofan.c:1.1	Fri Sep 10 23:32:17 2021
+++ src/sys/arch/macppc/dev/obiofan.c	Sat Sep 11 16:29:18 2021
@@ -1,8 +1,7 @@
-/*	$NetBSD: obiofan.c,v 1.1 2021/09/10 23:32:17 macallan Exp $	*/
-/*	Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp	*/
+/*	$NetBSD: obiofan.c,v 1.2 2021/09/11 16:29:18 macallan Exp $	*/
 
 /*-
- * Copyright (c) 2006 Michael Lorenz
+ * Copyright (c) 2021 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without



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

2021-09-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 11 16:29:18 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: obiofan.c

Log Message:
fix license copypasta
NFC


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

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



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

2021-08-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Aug  9 04:07:29 UTC 2021

Added Files:
src/sys/arch/macppc/dev: smuiic.c smuiicvar.h

Log Message:
Fix CVS eff-up.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.10 src/sys/arch/macppc/dev/smuiic.c
cvs rdiff -u -r0 -r1.3 src/sys/arch/macppc/dev/smuiicvar.h

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

Added files:

Index: src/sys/arch/macppc/dev/smuiic.c
diff -u /dev/null src/sys/arch/macppc/dev/smuiic.c:1.10
--- /dev/null	Mon Aug  9 04:07:29 2021
+++ src/sys/arch/macppc/dev/smuiic.c	Mon Aug  9 04:07:29 2021
@@ -0,0 +1,135 @@
+/*	$NetBSD: smuiic.c,v 1.10 2021/08/09 04:07:29 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2013 Phileas Fogg
+ * All rights reserved.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+struct smuiic_softc {
+	device_t sc_dev;
+	int sc_node;
+	struct i2c_controller *sc_i2c;
+};
+
+static int smuiic_match(device_t, struct cfdata *, void *);
+static void smuiic_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(smuiic, sizeof(struct smuiic_softc),
+smuiic_match, smuiic_attach, NULL, NULL);
+
+static int
+smuiic_match(device_t parent, struct cfdata *cf, void *aux)
+{
+	struct smu_iicbus_confargs *ca = aux;
+
+	if (strcmp(ca->ca_name, "i2c-bus") == 0)
+		return 5;
+	if (strcmp(ca->ca_name, "i2c") == 0)
+		return 5;
+	
+	return 0;
+}
+
+static void
+smuiic_attach(device_t parent, device_t self, void *aux)
+{
+	struct smu_iicbus_confargs *ca = aux;
+	struct smuiic_softc *sc = device_private(self);
+	struct i2cbus_attach_args iba;
+	prop_dictionary_t dict = device_properties(self);
+	int devs, devc;
+	uint32_t addr;
+	char compat[256];
+	prop_array_t cfg;
+	prop_dictionary_t dev;
+	prop_data_t data;
+	char name[32], descr[32], num[8];
+
+	sc->sc_dev = self;
+	sc->sc_node = ca->ca_node;
+	sc->sc_i2c = ca->ca_tag;
+	printf("\n");
+
+	cfg = prop_array_create();
+	prop_dictionary_set(dict, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+
+	/* look for i2c devices */
+	devs = OF_child(sc->sc_node);
+	while (devs != 0) {
+		if (OF_getprop(devs, "name", name, 256) <= 0)
+			goto skip;
+		if (OF_getprop(devs, "compatible",
+		compat, 256) <= 0)
+			goto skip;
+		if (OF_getprop(devs, "reg", , 4) <= 0)
+			goto skip;
+		addr = (addr & 0xff) >> 1;
+		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);
+		prop_dictionary_set_uint32(dev, "addr", addr);
+		prop_dictionary_set_uint64(dev, "cookie", devs);
+		devc = OF_child(devs);
+		while (devc != 0) {
+			int reg;
+			if (OF_getprop(devc, "reg", , 4) < 4) goto nope;
+			if (OF_getprop(devc, "location", descr, 32) <= 0)
+goto nope;
+			printf("found '%s' at %02x\n", descr, reg);
+			snprintf(num, 7, "s%02x", reg);
+			prop_dictionary_set_string(dev, num, descr);
+		nope:
+			devc = OF_peer(devc);
+		}
+		prop_array_add(cfg, dev);
+		prop_object_release(dev);
+	skip:
+		devs = OF_peer(devs);
+	}
+
+	memset(, 0, sizeof(iba));
+	iba.iba_tag = sc->sc_i2c;
+
+	config_found(sc->sc_dev, , iicbus_print, CFARGS_NONE);
+}

Index: src/sys/arch/macppc/dev/smuiicvar.h
diff -u /dev/null src/sys/arch/macppc/dev/smuiicvar.h:1.3
--- /dev/null	Mon Aug  9 04:07:29 2021
+++ src/sys/arch/macppc/dev/smuiicvar.h	Mon Aug  9 04:07:29 2021
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2013 Phileas Fogg
+ * All rights reserved.
+ *
+ * 

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

2021-08-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Aug  9 04:07:29 UTC 2021

Added Files:
src/sys/arch/macppc/dev: smuiic.c smuiicvar.h

Log Message:
Fix CVS eff-up.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.10 src/sys/arch/macppc/dev/smuiic.c
cvs rdiff -u -r0 -r1.3 src/sys/arch/macppc/dev/smuiicvar.h

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



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

2021-08-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Aug  7 06:04:26 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/macppc/dev/pmu.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/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.37 src/sys/arch/macppc/dev/pmu.c:1.38
--- src/sys/arch/macppc/dev/pmu.c:1.37	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/pmu.c	Sat Aug  7 06:04:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $ */
+/*	$NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $");
 
 #include 
 #include 
@@ -340,7 +340,7 @@ pmu_attach(device_t parent, device_t sel
 			goto next;
 
 		if (strncmp(name, "pmu-i2c", 8) == 0) {
-			int devs;
+			int devs, sensors;
 			uint32_t addr;
 			char compat[256];
 			prop_array_t cfg;
@@ -372,6 +372,20 @@ pmu_attach(device_t parent, device_t sel
 prop_object_release(data);
 prop_dictionary_set_uint32(dev, "addr", addr);
 prop_dictionary_set_uint64(dev, "cookie", devs);
+sensors = OF_child(devs);
+while (sensors != 0) {
+	int reg;
+	char loc[64];
+	char pname[8];
+	if (OF_getprop(sensors, "reg", , 4) != 4)
+		goto nope;
+	if (OF_getprop(sensors, "location", loc, 63) <= 0)
+		goto nope;
+	snprintf(pname, 7, "s%02x", reg);
+	prop_dictionary_set_string(dev, pname, loc);
+nope:
+	sensors = OF_peer(sensors);
+}
 prop_array_add(cfg, dev);
 prop_object_release(dev);
 			skip:
@@ -818,7 +832,7 @@ pmu_poweroff(void)
 	if (pmu_send(sc, PMU_POWER_OFF, 4, cmd, 16, resp) >= 0)
 		while (1);
 }
-
+	
 void
 pmu_restart(void)
 {



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

2021-08-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Aug  7 06:04:26 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/macppc/dev/pmu.c

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



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

2021-07-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 30 22:07:14 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h fcu.c

Log Message:
make thermal zone parameters configurable by sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fancontrol.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/fcu.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/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.2 src/sys/arch/macppc/dev/fancontrol.c:1.3
--- src/sys/arch/macppc/dev/fancontrol.c:1.2	Wed Jul 28 00:36:00 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -27,13 +27,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -60,6 +61,10 @@ fancontrol_adjust_zone(fancontrol_zone_t
 		return -1;
 	}
 
+	if (z->Tmin < 30) z->Tmin = 30;
+	if (z->Tmin > 60) z->Tmin = 60;
+	if (z->Tmax > 95) z->Tmax = 95;
+	if (z->Tmax < (z->Tmin + 10)) z->Tmax = z->Tmin + 10;
 	temp = (temp - 27315) / 100;
 	diff = temp - z->Tmin;
 	DPRINTF("%s %d %d\n", z->name, temp, z->Tmin);
@@ -76,3 +81,39 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	}
 	return 0;
 }
+
+int
+fancontrol_init_zone(fancontrol_zone_t *z, struct sysctlnode *me)
+{
+	struct sysctlnode *zone_node, *node;
+
+	if (z->nfans <= 0) return 0;
+
+	sysctl_createv(NULL, 0, NULL, (void *) _node,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_NODE, z->name, NULL,
+	NULL, 0, NULL, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) ,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmin", "minimum temperature",
+	NULL, 0, (void *)>Tmin, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) ,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmax", "maximum temperature",
+	NULL, 0, (void *)>Tmax, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	return 0;
+}

Index: src/sys/arch/macppc/dev/fancontrolvar.h
diff -u src/sys/arch/macppc/dev/fancontrolvar.h:1.1 src/sys/arch/macppc/dev/fancontrolvar.h:1.2
--- src/sys/arch/macppc/dev/fancontrolvar.h:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrolvar.h	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrolvar.h,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrolvar.h,v 1.2 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -48,5 +48,6 @@ typedef struct _fancontrol_zone {
 } fancontrol_zone_t; 
 
 int fancontrol_adjust_zone(fancontrol_zone_t *);
+int fancontrol_init_zone(fancontrol_zone_t *, struct sysctlnode *);
 
 #endif /* FANCONTROLVAR_H */

Index: src/sys/arch/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.3 src/sys/arch/macppc/dev/fcu.c:1.4
--- src/sys/arch/macppc/dev/fcu.c:1.3	Wed Jul 28 00:59:10 2021
+++ src/sys/arch/macppc/dev/fcu.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -78,8 +79,8 @@ struct fcu_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
-
-	struct sysmon_envsys *sc_sme;
+	struct sysctlnode 	*sc_sysctl_me;
+	struct sysmon_envsys	*sc_sme;
 	envsys_data_t		sc_sensors[32];
 	int			sc_nsensors;
 	fancontrol_zone_t	sc_zones[FCU_ZONE_COUNT];
@@ -132,7 +133,7 @@ fcu_attach(device_t parent, device_t sel
 {
 	struct fcu_softc *sc = device_private(self);
 	struct i2c_attach_args *ia = aux;
-	int have_eeprom1 = 1;
+	int have_eeprom1 = 1, i;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -141,6 +142,12 @@ fcu_attach(device_t parent, device_t sel
 	aprint_naive("\n");
 	aprint_normal(": Fan Control Unit\n");
 
+	sysctl_createv(NULL, 0, NULL, (void *) >sc_sysctl_me,
+	CTLFLAG_READWRITE,
+	CTLTYPE_NODE, 

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

2021-07-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 30 22:07:14 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h fcu.c

Log Message:
make thermal zone parameters configurable by sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fancontrol.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/fcu.c

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



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

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:59:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fcu.c

Log Message:
check temperatures a bit more often
while there, explain why the delay is variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fcu.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/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.2 src/sys/arch/macppc/dev/fcu.c:1.3
--- src/sys/arch/macppc/dev/fcu.c:1.2	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fcu.c	Wed Jul 28 00:59:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
 
 #include 
 #include 
@@ -490,7 +490,13 @@ fcu_adjust(void *cookie)
 		sc->sc_pwm = FALSE;
 		for (i = 0; i < FCU_ZONE_COUNT; i++)
 			fancontrol_adjust_zone(>sc_zones[i]);
-		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 5000), NULL);
+		/*
+		 * take a shorter nap if we're in the proccess of adjusting a
+		 * PWM fan, which relies on measuring speed and then changing
+		 * its duty cycle until we're reasonable close to the target
+		 * speed
+		 */
+		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 2000), NULL);
 	}
 	kthread_exit(0);
 }



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

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:59:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fcu.c

Log Message:
check temperatures a bit more often
while there, explain why the delay is variable


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

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



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

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:36:00 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c

Log Message:
adjust comments, break a long line
NFC


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

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



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

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:36:00 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c

Log Message:
adjust comments, break a long line
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrol.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/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.1 src/sys/arch/macppc/dev/fancontrol.c:1.2
--- src/sys/arch/macppc/dev/fancontrol.c:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Wed Jul 28 00:36:00 2021
@@ -1,7 +1,7 @@
-/* $NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
 
 /*-
- * Copyright (c) 2018 Michael Lorenz
+ * Copyright (c) 2021 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
 
 #include 
 #include 
@@ -66,11 +66,12 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	if (diff < 0) diff = 0;
 	diff = (100 * diff) / (z->Tmax - z->Tmin);
 
-	/* now adjust each fan to the new duty cycle */
+	/* now adjust each fan to the new speed */
 	for (i = 0; i < z->nfans; i++) {
 		step = (z->fans[i].max_rpm - z->fans[i].min_rpm) / 100;
 		speed = z->fans[i].min_rpm + diff * step;
-		DPRINTF("diff %d base %d %d sp %d\n", diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
+		DPRINTF("diff %d base %d %d sp %d\n",
+		diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
 		z->set_rpm(z->cookie, z->fans[i].num, speed);
 	}
 	return 0;



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

2021-07-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul  2 10:14:07 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
port-macppc/56289: kernel spinout on macppc when runing ATF tests with LOCKDEBUG

Move call to snapper_set_rate from trigger_output to commit_settings,
since the intr lock is not held when calling the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.59 src/sys/arch/macppc/dev/snapper.c:1.60
--- src/sys/arch/macppc/dev/snapper.c:1.59	Mon Apr 26 14:01:47 2021
+++ src/sys/arch/macppc/dev/snapper.c	Fri Jul  2 10:14:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.59 2021/04/26 14:01:47 thorpej Exp $	*/
+/*	$NetBSD: snapper.c,v 1.60 2021/07/02 10:14:07 jmcneill Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.59 2021/04/26 14:01:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.60 2021/07/02 10:14:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -133,6 +133,7 @@ static int snapper_query_format(void *, 
 static int snapper_set_format(void *, int,
 const audio_params_t *, const audio_params_t *,
 audio_filter_reg_t *, audio_filter_reg_t *);
+static int snapper_commit_settings(void *);
 static int snapper_round_blocksize(void *, int, int, const audio_params_t *);
 static int snapper_halt_output(void *);
 static int snapper_halt_input(void *);
@@ -232,6 +233,7 @@ CFATTACH_DECL_NEW(snapper, sizeof(struct
 const struct audio_hw_if snapper_hw_if = {
 	.query_format		= snapper_query_format,
 	.set_format		= snapper_set_format,
+	.commit_settings	= snapper_commit_settings,
 	.round_blocksize	= snapper_round_blocksize,
 	.halt_output		= snapper_halt_output,
 	.halt_input		= snapper_halt_input,
@@ -1013,6 +1015,17 @@ snapper_set_format(void *h, int setmode,
 }
 
 static int
+snapper_commit_settings(void *h)
+{
+	struct snapper_softc *sc;
+
+	DPRINTF("commit_settings\n");
+	sc = h;
+
+	return snapper_set_rate(sc);
+}
+
+static int
 snapper_round_blocksize(void *h, int size, int mode,
 			const audio_params_t *param)
 {
@@ -1408,14 +1421,10 @@ snapper_trigger_output(void *h, void *st
 	struct dbdma_command *cmd;
 	vaddr_t va;
 	int i, len, intmode;
-	int res;
 
 	DPRINTF("trigger_output %p %p 0x%x\n", start, end, bsize);
 	sc = h;
 
-	if ((res = snapper_set_rate(sc)) != 0)
-		return res;
-
 	cmd = sc->sc_odmacmd;
 	sc->sc_ointr = intr;
 	sc->sc_oarg = arg;
@@ -1463,14 +1472,10 @@ snapper_trigger_input(void *h, void *sta
 	struct dbdma_command *cmd;
 	vaddr_t va;
 	int i, len, intmode;
-	int res;
 
 	DPRINTF("trigger_input %p %p 0x%x\n", start, end, bsize);
 	sc = h;
 
-	if ((res = snapper_set_rate(sc)) != 0)
-		return res;
-
 	cmd = sc->sc_idmacmd;
 	sc->sc_iintr = intr;
 	sc->sc_iarg = arg;



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

2021-07-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul  2 10:14:07 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
port-macppc/56289: kernel spinout on macppc when runing ATF tests with LOCKDEBUG

Move call to snapper_set_rate from trigger_output to commit_settings,
since the intr lock is not held when calling the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/macppc/dev/snapper.c

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



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 23:00:47 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
do ii2 locking dance in psoc_dump()


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/dev/psoc.c

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



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 23:00:47 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
do ii2 locking dance in psoc_dump()


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/dev/psoc.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/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.7 src/sys/arch/macppc/dev/psoc.c:1.8
--- src/sys/arch/macppc/dev/psoc.c:1.7	Fri Jun 18 22:57:18 2021
+++ src/sys/arch/macppc/dev/psoc.c	Fri Jun 18 23:00:47 2021
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.7 2021/06/18 22:57:18 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.8 2021/06/18 23:00:47 macallan Exp $ */
 
 /*-
  * Copyright (c) 2019 Michael Lorenz
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.7 2021/06/18 22:57:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.8 2021/06/18 23:00:47 macallan Exp $");
 
 #include 
 #include 
@@ -221,6 +221,8 @@ psoc_dump(struct psoc_softc *sc)
 {
 	int i, j;
 	uint8_t data, cmd;
+
+	iic_acquire_bus(sc->sc_i2c, 0);
 	for (i = 0x20; i < 0x5f; i+= 8) {
 		printf("%02x:", i);
 		for (j = 0; j < 8; j++) {
@@ -232,4 +234,5 @@ psoc_dump(struct psoc_softc *sc)
 		}
 		printf("\n");
 	}
+	iic_release_bus(sc->sc_i2c, 0);
 }



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 22:57:18 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
use opt_psoc.h, suppress some debug output in !PSOC_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/dev/psoc.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/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.6 src/sys/arch/macppc/dev/psoc.c:1.7
--- src/sys/arch/macppc/dev/psoc.c:1.6	Wed Jan 27 02:17:28 2021
+++ src/sys/arch/macppc/dev/psoc.c	Fri Jun 18 22:57:18 2021
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.6 2021/01/27 02:17:28 thorpej Exp $ */
+ /* $NetBSD: psoc.c,v 1.7 2021/06/18 22:57:18 macallan Exp $ */
 
 /*-
  * Copyright (c) 2019 Michael Lorenz
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.6 2021/01/27 02:17:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.7 2021/06/18 22:57:18 macallan Exp $");
 
 #include 
 #include 
@@ -57,6 +57,13 @@ __KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.6
 
 #include 
 
+#include "opt_psoc.h"
+#ifdef PSOC_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
 struct psoc_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
@@ -117,10 +124,10 @@ psoc_attach(device_t parent, device_t se
 
 	error = OF_package_to_path(sc->sc_node, path, 256);
 	path[error] = 0;
-	printf("path [%s]\n", path);
+	DPRINTF("path [%s]\n", path);
 	ih = OF_open("fan");
 	OF_call_method_1("fan-init", ih, 0);
-	printf("ih %08x\n", ih);
+	DPRINTF("ih %08x\n", ih);
 
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sme->sme_name = device_xname(self);



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 22:57:18 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: psoc.c

Log Message:
use opt_psoc.h, suppress some debug output in !PSOC_DEBUG


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

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



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 22:52:04 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
use opt_lmu.h
while there, remove an obsolete comment


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/lmu.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/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.8 src/sys/arch/macppc/dev/lmu.c:1.9
--- src/sys/arch/macppc/dev/lmu.c:1.8	Wed Jan 27 02:17:28 2021
+++ src/sys/arch/macppc/dev/lmu.c	Fri Jun 18 22:52:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lmu.c,v 1.8 2021/01/27 02:17:28 thorpej Exp $ */
+/* $NetBSD: lmu.c,v 1.9 2021/06/18 22:52:04 macallan Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.8 2021/01/27 02:17:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.9 2021/06/18 22:52:04 macallan Exp $");
 
 #include 
 #include 
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.8 
 #include 
 
 #include 
+#include "opt_lmu.h"
 
 #ifdef LMU_DEBUG
 #define DPRINTF printf
@@ -208,7 +209,6 @@ lmu_attach(device_t parent, device_t sel
 
 	sysmon_envsys_register(sc->sc_sme);
 
-	/* TODO: make this adjustable via sysctl */
 	sc->sc_thresh = 300;
 	sc->sc_hyst = 30;
 	sc->sc_level = 16;



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

2021-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 18 22:52:04 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
use opt_lmu.h
while there, remove an obsolete comment


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/lmu.c

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



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

2021-04-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Apr 26 14:01:47 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
snapper carries multiple interface attributes, so be explicit about
"onewirebus" when attaching to it.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.58 src/sys/arch/macppc/dev/snapper.c:1.59
--- src/sys/arch/macppc/dev/snapper.c:1.58	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/snapper.c	Mon Apr 26 14:01:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.58 2021/04/24 23:36:41 thorpej Exp $	*/
+/*	$NetBSD: snapper.c,v 1.59 2021/04/26 14:01:47 thorpej Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.58 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.59 2021/04/26 14:01:47 thorpej Exp $");
 
 #include 
 #include 
@@ -2301,6 +2301,7 @@ snapper_setup_ow(struct snapper_softc *s
 	memset(, 0, sizeof(oba));
 	oba.oba_bus = >sc_ow_bus;
 	sc->sc_ow_dev = config_found(sc->sc_dev, , onewirebus_print,
+	CFARG_IATTR, "onewirebus",
 	CFARG_EOL);
 
 }



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

2021-04-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Apr 26 14:01:47 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
snapper carries multiple interface attributes, so be explicit about
"onewirebus" when attaching to it.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/macppc/dev/snapper.c

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



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

2021-03-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 11 19:36:11 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
add basic support for iMac G5 audio:
- match AOAShasta
- deal with headphone gpios labeled as lineout in OF
- set sc_mode to SNAPPER_IS_PCM3052 - OF makes it look like an unlabeled
  TAS3004
TODO:
- actually support pcm3052 instead of treating it like a sw codec


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/macppc/dev/snapper.c

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



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

2021-03-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 11 19:36:11 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
add basic support for iMac G5 audio:
- match AOAShasta
- deal with headphone gpios labeled as lineout in OF
- set sc_mode to SNAPPER_IS_PCM3052 - OF makes it look like an unlabeled
  TAS3004
TODO:
- actually support pcm3052 instead of treating it like a sw codec


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.56 src/sys/arch/macppc/dev/snapper.c:1.57
--- src/sys/arch/macppc/dev/snapper.c:1.56	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/dev/snapper.c	Thu Mar 11 19:36:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.56 2021/03/05 07:15:53 rin Exp $	*/
+/*	$NetBSD: snapper.c,v 1.57 2021/03/11 19:36:11 macallan Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.56 2021/03/05 07:15:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.57 2021/03/11 19:36:11 macallan Exp $");
 
 #include 
 #include 
@@ -158,6 +158,7 @@ static int gpio_read(bus_size_t);
 static void gpio_write(bus_size_t, int);
 static void snapper_mute_speaker(struct snapper_softc *, int);
 static void snapper_mute_headphone(struct snapper_softc *, int);
+static void snapper_mute_lineout(struct snapper_softc *, int);
 static int snapper_cint(void *);
 static int tas3004_init(struct snapper_softc *);
 static void snapper_init(struct snapper_softc *, int);
@@ -519,11 +520,14 @@ static const struct audio_format onyx_fo
 #define ONYX_NFORMATS	__arraycount(onyx_formats)
 
 static bus_size_t amp_mute;
-static bus_size_t headphone_mute;
+static bus_size_t headphone_mute = 0;
 static bus_size_t audio_hw_reset;
-static bus_size_t headphone_detect;
+static bus_size_t headphone_detect = 0;
+static bus_size_t lineout_detect = 0;
+static bus_size_t lineout_mute= 0;
 static bus_size_t owaddr = -1;
-static uint8_t headphone_detect_active;
+static uint8_t headphone_detect_active = 0;
+static uint8_t lineout_detect_active = 0;
 
 
 /* I2S registers */
@@ -692,6 +696,9 @@ snapper_match(device_t parent, struct cf
 
 	if (strcmp(compat, "AOAK2") == 0)
 		return 1;
+
+	if (strcmp(compat, "AOAShasta") == 0)
+		return 1;
 		
 	if (strcmp(compat, "AOAbase") == 0)
 		return 1;
@@ -870,8 +877,17 @@ snapper_defer(device_t dev)
 		if (codec[0] == 0) {
 			if (sc->sc_deqaddr == 0x34) {
 sc->sc_mode = SNAPPER_IS_TAS3001;
-			} else
+			} else {
+int root = OF_finddevice("/");
+char model[32];
 sc->sc_mode = SNAPPER_IS_TAS3004;
+if (OF_getprop(root, "model", model, 32) > 0) {
+	printf("model %s\n", model);
+	if (strcmp(model, "PowerMac8,1") == 0) {
+		sc->sc_mode = SNAPPER_IS_PCM3052;
+	}
+}
+			}
 		} else if (strcmp(codec, "tas3004") == 0) {
 			sc->sc_mode = SNAPPER_IS_TAS3004;
 		} else if (strcmp(codec, "pcm3052") == 0) {
@@ -1077,10 +1093,13 @@ snapper_set_port(void *h, mixer_ctrl_t *
 
 		snapper_mute_speaker(sc, 1);
 		snapper_mute_headphone(sc, 1);
+		snapper_mute_lineout(sc, 1);
 		if (mc->un.mask & 1 << 0)
 			snapper_mute_speaker(sc, 0);
 		if (mc->un.mask & 1 << 1)
 			snapper_mute_headphone(sc, 0);
+		if (mc->un.mask & 1 << 2)
+			snapper_mute_lineout(sc, 0);
 
 		sc->sc_output_mask = mc->un.mask;
 		return 0;
@@ -1240,11 +1259,13 @@ snapper_query_devinfo(void *h, mixer_dev
 		strcpy(dip->label.name, AudioNoutput);
 		dip->type = AUDIO_MIXER_SET;
 		dip->prev = dip->next = AUDIO_MIXER_LAST;
-		dip->un.s.num_mem = 2;
+		dip->un.s.num_mem = 3;
 		strcpy(dip->un.s.member[0].label.name, AudioNspeaker);
 		dip->un.s.member[0].mask = 1 << 0;
 		strcpy(dip->un.s.member[1].label.name, AudioNheadphone);
 		dip->un.s.member[1].mask = 1 << 1;
+		strcpy(dip->un.s.member[2].label.name, AudioNline);
+		dip->un.s.member[2].mask = 1 << 2;
 		return 0;
 
 	case SNAPPER_VOL_OUTPUT:
@@ -1937,6 +1958,7 @@ gpio_write(bus_size_t addr, int val)
 }
 
 #define headphone_active 0	/* XXX OF */
+#define lineout_active 0	/* XXX OF */
 #define amp_active 0		/* XXX OF */
 
 static void
@@ -1977,30 +1999,68 @@ snapper_mute_headphone(struct snapper_so
 	}
 }
 
+static void
+snapper_mute_lineout(struct snapper_softc *sc, int mute)
+{
+	u_int x;
+
+	if (lineout_mute != 0) {
+		DPRINTF("lineoutmute %d --> ", gpio_read(lineout_mute));
+
+		if (mute)
+			x = lineout_active;	/* mute */
+		else
+			x = !lineout_active;	/* unmute */
+		if (x != gpio_read(lineout_mute))
+			gpio_write(lineout_mute, x);
+
+		DPRINTF("%d\n", gpio_read(lineout_mute));
+	}
+}
+
 static int
 snapper_cint(void *v)
 {
-	struct snapper_softc *sc;
+	struct snapper_softc *sc = v;
 	u_int sense;
+	int mask 

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

2021-03-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Mar  9 01:17:37 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
add support for the CPU temperature sensor found in iMac G5s


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

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



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

2021-03-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Mar  9 01:17:37 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
add support for the CPU temperature sensor found in iMac G5s


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/macppc/dev/smu.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/macppc/dev/smu.c
diff -u src/sys/arch/macppc/dev/smu.c:1.11 src/sys/arch/macppc/dev/smu.c:1.12
--- src/sys/arch/macppc/dev/smu.c:1.11	Fri Mar  5 07:15:53 2021
+++ src/sys/arch/macppc/dev/smu.c	Tue Mar  9 01:17:37 2021
@@ -80,7 +80,7 @@ struct smu_iicbus {
 
 #define SMU_MAX_FANS		8
 #define SMU_MAX_IICBUS		3
-#define SMU_MAX_SME_SENSORS	SMU_MAX_FANS
+#define SMU_MAX_SME_SENSORS	(SMU_MAX_FANS + 8)
 
 struct smu_zone {
 	bool (*filter)(const envsys_data_t *);
@@ -120,6 +120,8 @@ struct smu_softc {
 
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t sc_sme_sensors[SMU_MAX_SME_SENSORS];
+	uint32_t cpu_m;
+	int32_t  cpu_b;
 
 	struct smu_zone sc_zones[SMU_ZONES];
 	lwp_t *sc_thread;
@@ -130,7 +132,7 @@ struct smu_softc {
 #define SMU_CMD_RTC	0x8e
 #define SMU_CMD_I2C	0x9a
 #define SMU_CMD_POWER	0xaa
-#define SMU_ADC		0xd8
+#define SMU_CMD_ADC	0xd8
 #define SMU_MISC	0xee
 #define  SMU_MISC_GET_DATA	0x02
 #define  SMU_MISC_LED_CTRL	0x04
@@ -165,6 +167,8 @@ static int smu_todr_settime_ymdhms(todr_
 static int smu_fan_update_rpm(struct smu_fan *);
 static int smu_fan_get_rpm(struct smu_fan *, int *);
 static int smu_fan_set_rpm(struct smu_fan *, int);
+static int smu_read_adc(struct smu_softc *, int);
+
 static int smu_iicbus_exec(void *, i2c_op_t, i2c_addr_t, const void *,
 size_t, void *, size_t, int);
 static int smu_sysctl_fan_rpm(SYSCTLFN_ARGS);
@@ -199,6 +203,7 @@ smu_attach(device_t parent, device_t sel
 {
 	struct confargs *ca = aux;
 	struct smu_softc *sc = device_private(self);
+	uint16_t data[4];
 
 	sc->sc_dev = self;
 	sc->sc_node = ca->ca_node;
@@ -227,6 +232,13 @@ smu_attach(device_t parent, device_t sel
 	sc->sc_todr.cookie = sc;
 	todr_attach(>sc_todr);
 
+	/* calibration data */
+	memset(data, 0, 8);	
+	smu_get_datablock(SMU_CPUTEMP_CAL, (void *)data, 8);
+	DPRINTF("data %04x %04x %04x %04x\n", data[0], data[1], data[2], data[3]);
+	sc->cpu_m = data[2]; 
+	sc->cpu_b = (int16_t)data[3];
+
 	smu_setup_sme(sc);
 
 	smu_setup_zones(sc);
@@ -476,7 +488,8 @@ smu_setup_sme(struct smu_softc *sc)
 {
 	struct smu_fan *fan;
 	envsys_data_t *sme_sensor;
-	int i;
+	int i, sensors, child, reg;
+	char loc[32], type[32];
 
 	sc->sc_sme = sysmon_envsys_create();
 
@@ -494,7 +507,26 @@ smu_setup_sme(struct smu_softc *sc)
 			return;
 		}
 	}
-
+	sensors = OF_finddevice("/smu/sensors");
+	child = OF_child(sensors);
+	while (child != 0) {
+		sme_sensor = >sc_sme_sensors[i];
+		if (OF_getprop(child, "location", loc, 32) == 0) goto next;
+		if (OF_getprop(child, "device_type", type, 32) == 0) goto next;
+		if (OF_getprop(child, "reg", , 4) == 0) goto next;
+		if (strcmp(type, "temp-sensor") == 0) {
+			sme_sensor->units = ENVSYS_STEMP;
+			sme_sensor->state = ENVSYS_SINVALID;
+			strncpy(sme_sensor->desc, loc, sizeof(sme_sensor->desc));
+			sme_sensor->private = reg;
+			sysmon_envsys_sensor_attach(sc->sc_sme, sme_sensor);
+			i++;
+			printf("%s: %s@%x\n", loc, type, reg); 
+		}
+next:
+		child = OF_peer(child);
+	}
+		
 	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
 	sc->sc_sme->sme_cookie = sc;
 	sc->sc_sme->sme_refresh = smu_sme_refresh;
@@ -535,6 +567,19 @@ smu_sme_refresh(struct sysmon_envsys *sm
 			edata->value_cur = fan->current_rpm;
 			edata->state = ENVSYS_SVALID;
 		}
+	} else if (edata->private > 0) {
+		/* this works only for the CPU diode */
+		int64_t r = smu_read_adc(sc, edata->private);
+		if (r != -1) {
+			r = r * sc->cpu_m;
+			r >>= 3;
+			r += (int64_t)sc->cpu_b << 9;
+			r <<= 1;
+			r *= 15625;
+			r /= 1024;
+			edata->value_cur = r + 27315;
+			edata->state = ENVSYS_SVALID;
+		}
 	}
 }
 
@@ -771,6 +816,23 @@ smu_fan_set_rpm(struct smu_fan *fan, int
 }
 
 static int
+smu_read_adc(struct smu_softc *sc, int id)
+{
+	struct smu_cmd cmd;
+	int ret;
+
+	cmd.cmd = SMU_CMD_ADC;
+	cmd.len = 1;
+	cmd.data[0] = id;
+
+	ret = smu_do_cmd(sc, , 800);
+	if (ret == 0) {
+		return cmd.data[0] << 8 | cmd.data[1];
+	}
+	return -1;
+}
+
+static int
 smu_iicbus_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, const void *send,
 size_t send_len, void *recv, size_t recv_len, int flags)
 {



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

2021-02-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 25 20:51:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
more node name adjustments
also, pass sensor names if we can find them
now we find and currectly use the hard drive temperature sensor on my iMac G5


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/dev/smuiic.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/macppc/dev/smuiic.c
diff -u src/sys/arch/macppc/dev/smuiic.c:1.5 src/sys/arch/macppc/dev/smuiic.c:1.6
--- src/sys/arch/macppc/dev/smuiic.c:1.5	Thu Jul  2 12:47:19 2020
+++ src/sys/arch/macppc/dev/smuiic.c	Thu Feb 25 20:51:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: smuiic.c,v 1.5 2020/07/02 12:47:19 macallan Exp $ */
+/*	$NetBSD: smuiic.c,v 1.6 2021/02/25 20:51:10 macallan Exp $ */
 
 /*-
  * Copyright (c) 2013 Phileas Fogg
@@ -62,6 +62,8 @@ smuiic_match(device_t parent, struct cfd
 
 	if (strcmp(ca->ca_name, "i2c-bus") == 0)
 		return 5;
+	if (strcmp(ca->ca_name, "i2c") == 0)
+		return 5;
 	
 	return 0;
 }
@@ -73,13 +75,13 @@ smuiic_attach(device_t parent, device_t 
 	struct smuiic_softc *sc = device_private(self);
 	struct i2cbus_attach_args iba;
 	prop_dictionary_t dict = device_properties(self);
-	int devs;
+	int devs, devc;
 	uint32_t addr;
 	char compat[256];
 	prop_array_t cfg;
 	prop_dictionary_t dev;
 	prop_data_t data;
-	char name[32];
+	char name[32], descr[32], num[8];
 
 	sc->sc_dev = self;
 	sc->sc_node = ca->ca_node;
@@ -108,6 +110,18 @@ smuiic_attach(device_t parent, device_t 
 		prop_object_release(data);
 		prop_dictionary_set_uint32(dev, "addr", addr);
 		prop_dictionary_set_uint64(dev, "cookie", devs);
+		devc = OF_child(devs);
+		while (devc != 0) {
+			int reg;
+			if (OF_getprop(devc, "reg", , 4) < 4) goto nope;
+			if (OF_getprop(devc, "location", descr, 32) <= 0)
+goto nope;
+			printf("found '%s' at %02x\n", descr, reg);
+			snprintf(num, 7, "s%02x", reg);
+			prop_dictionary_set_string(dev, num, descr);
+		nope:
+			devc = OF_peer(devc);
+		}
 		prop_array_add(cfg, dev);
 		prop_object_release(dev);
 	skip:



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

2021-02-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 25 20:51:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
more node name adjustments
also, pass sensor names if we can find them
now we find and currectly use the hard drive temperature sensor on my iMac G5


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

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



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

2021-02-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 25 20:49:08 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
deal with node name inconsistencies between PowerMac10,x and 8,x
Now we find fans and iic devices on iMac G5


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/macppc/dev/smu.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/macppc/dev/smu.c
diff -u src/sys/arch/macppc/dev/smu.c:1.9 src/sys/arch/macppc/dev/smu.c:1.10
--- src/sys/arch/macppc/dev/smu.c:1.9	Sat Jul  4 11:55:18 2020
+++ src/sys/arch/macppc/dev/smu.c	Thu Feb 25 20:49:08 2021
@@ -289,51 +289,56 @@ smu_setup_fans(struct smu_softc *sc)
 	struct sysctlnode *sysctl_fans, *sysctl_fan, *sysctl_node;
 	char type[32], sysctl_fan_name[32];
 	int node, i, j;
+	const char *fans[] = { "fans", "rpm-fans", 0 };
+	int n = 0;
+	
+	while (fans[n][0] != 0) {
+		node = of_getnode_byname(sc->sc_node, fans[n]);
+		for (node = OF_child(node);
+		(node != 0) && (sc->sc_num_fans < SMU_MAX_FANS);
+		node = OF_peer(node)) {
+			fan = >sc_fans[sc->sc_num_fans];
+			fan->sc = sc;
+
+			memset(fan->location, 0, sizeof(fan->location));
+			OF_getprop(node, "location", fan->location,
+			sizeof(fan->location));
+
+			if (OF_getprop(node, "reg", >reg,
+			sizeof(fan->reg)) <= 0)
+continue;
+
+			if (OF_getprop(node, "zone", >zone	,
+			sizeof(fan->zone)) <= 0)
+continue;
+
+			memset(type, 0, sizeof(type));
+			OF_getprop(node, "device_type", type, sizeof(type));
+			if (strcmp(type, "fan-rpm-control") == 0)
+fan->rpm_ctl = 1;
+			else
+fan->rpm_ctl = 0;
+
+			if (OF_getprop(node, "min-value", >min_rpm,
+			sizeof(fan->min_rpm)) <= 0)
+fan->min_rpm = 0;
+
+			if (OF_getprop(node, "max-value", >max_rpm,
+			sizeof(fan->max_rpm)) <= 0)
+fan->max_rpm = 0x;
+
+			if (OF_getprop(node, "unmanage-value", >default_rpm,
+			sizeof(fan->default_rpm)) <= 0)
+fan->default_rpm = fan->max_rpm;
+
+			DPRINTF("fan: location %s reg %x zone %d rpm_ctl %d "
+			"min_rpm %d max_rpm %d default_rpm %d\n",
+			fan->location, fan->reg, fan->zone, fan->rpm_ctl,
+			fan->min_rpm, fan->max_rpm, fan->default_rpm);
 
-	node = of_getnode_byname(sc->sc_node, "fans");
-	for (node = OF_child(node);
-	(node != 0) && (sc->sc_num_fans < SMU_MAX_FANS);
-	node = OF_peer(node)) {
-		fan = >sc_fans[sc->sc_num_fans];
-		fan->sc = sc;
-
-		memset(fan->location, 0, sizeof(fan->location));
-		OF_getprop(node, "location", fan->location,
-		sizeof(fan->location));
-
-		if (OF_getprop(node, "reg", >reg,
-		sizeof(fan->reg)) <= 0)
-			continue;
-
-		if (OF_getprop(node, "zone", >zone,
-		sizeof(fan->zone)) <= 0)
-			continue;
-
-		memset(type, 0, sizeof(type));
-		OF_getprop(node, "device_type", type, sizeof(type));
-		if (strcmp(type, "fan-rpm-control") == 0)
-			fan->rpm_ctl = 1;
-		else
-			fan->rpm_ctl = 0;
-
-		if (OF_getprop(node, "min-value", >min_rpm,
-		sizeof(fan->min_rpm)) <= 0)
-			fan->min_rpm = 0;
-
-		if (OF_getprop(node, "max-value", >max_rpm,
-		sizeof(fan->max_rpm)) <= 0)
-			fan->max_rpm = 0x;
-
-		if (OF_getprop(node, "unmanage-value", >default_rpm,
-		sizeof(fan->default_rpm)) <= 0)
-			fan->default_rpm = fan->max_rpm;
-
-		DPRINTF("fan: location %s reg %x zone %d rpm_ctl %d "
-		"min_rpm %d max_rpm %d default_rpm %d\n",
-		fan->location, fan->reg, fan->zone, fan->rpm_ctl,
-		fan->min_rpm, fan->max_rpm, fan->default_rpm);
-
-		sc->sc_num_fans++;
+			sc->sc_num_fans++;
+		}
+		n++;
 	}
 
 	for (i = 0; i < sc->sc_num_fans; i++) {
@@ -433,12 +438,14 @@ smu_setup_iicbus(struct smu_softc *sc)
 	char name[32];
 
 	node = of_getnode_byname(sc->sc_node, "smu-i2c-control");
+	if (node == 0) node = sc->sc_node;
 	for (node = OF_child(node);
 	(node != 0) && (sc->sc_num_iicbus < SMU_MAX_IICBUS);
 	node = OF_peer(node)) {
 		memset(name, 0, sizeof(name));
 		OF_getprop(node, "name", name, sizeof(name));
-		if (strcmp(name, "i2c-bus") != 0)
+		if ((strcmp(name, "i2c-bus") != 0) &&
+		(strcmp(name, "i2c") != 0))
 			continue;
 
 		iicbus = >sc_iicbus[sc->sc_num_iicbus];
@@ -862,7 +869,8 @@ smu_setup_zones(struct smu_softc *sc)
 	z->nfans = 0;
 	for (i = 0; i < SMU_MAX_FANS; i++) {
 		f = >sc_fans[i];
-		if (strstr(f->location, "CPU") != NULL) {
+		if ((strstr(f->location, "CPU") != NULL) || 
+		(strstr(f->location, "System") != NULL)) {
 			z->fans[z->nfans] = i;
 			z->nfans++;
 		}
@@ -878,7 +886,8 @@ smu_setup_zones(struct smu_softc *sc)
 	z->nfans = 0;
 	for (i = 0; i < SMU_MAX_FANS; i++) {
 		f = >sc_fans[i];
-		if (strstr(f->location, "DRIVE") != NULL) {
+		if ((strstr(f->location, "DRIVE") != NULL) ||
+		(strstr(f->location, "Drive") != NULL)) {
 			z->fans[z->nfans] = i;
 			z->nfans++;
 		}
@@ -959,7 +968,7 @@ smu_adjust(void *cookie)
 	while (!sc->sc_dying) {
 		for 

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

2021-02-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 25 20:49:08 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
deal with node name inconsistencies between PowerMac10,x and 8,x
Now we find fans and iic devices on iMac G5


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

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



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

2021-02-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb  6 07:20:36 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: awacs.c

Log Message:
Calling halt_{input,output} is done by the MI audio layer if necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/dev/awacs.c

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



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

2021-02-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb  6 07:20:36 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: awacs.c

Log Message:
Calling halt_{input,output} is done by the MI audio layer if necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/dev/awacs.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/macppc/dev/awacs.c
diff -u src/sys/arch/macppc/dev/awacs.c:1.49 src/sys/arch/macppc/dev/awacs.c:1.50
--- src/sys/arch/macppc/dev/awacs.c:1.49	Tue Jan 26 14:49:41 2021
+++ src/sys/arch/macppc/dev/awacs.c	Sat Feb  6 07:20:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: awacs.c,v 1.49 2021/01/26 14:49:41 thorpej Exp $	*/
+/*	$NetBSD: awacs.c,v 1.50 2021/02/06 07:20:36 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.49 2021/01/26 14:49:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.50 2021/02/06 07:20:36 isaki Exp $");
 
 #include 
 #include 
@@ -110,7 +110,6 @@ static void awacs_attach(device_t, devic
 static int awacs_intr(void *);
 static int awacs_status_intr(void *);
 
-static void awacs_close(void *);
 static int awacs_query_format(void *, audio_format_query_t *);
 static int awacs_set_format(void *, int,
 		 const audio_params_t *, const audio_params_t *,
@@ -154,7 +153,6 @@ CFATTACH_DECL_NEW(awacs, sizeof(struct a
 awacs_match, awacs_attach, NULL, NULL);
 
 const struct audio_hw_if awacs_hw_if = {
-	.close			= awacs_close,
 	.query_format		= awacs_query_format,
 	.set_format		= awacs_set_format,
 	.round_blocksize	= awacs_round_blocksize,
@@ -620,22 +618,6 @@ awacs_intr(void *v)
 	return 1;
 }
 
-/*
- * Close function is called at splaudio().
- */
-static void
-awacs_close(void *h)
-{
-	struct awacs_softc *sc;
-
-	sc = h;
-	awacs_halt_output(sc);
-	awacs_halt_input(sc);
-
-	sc->sc_ointr = 0;
-	sc->sc_iintr = 0;
-}
-
 static int
 awacs_query_format(void *h, audio_format_query_t *afp)
 {
@@ -678,6 +660,7 @@ awacs_halt_output(void *h)
 	sc = h;
 	dbdma_stop(sc->sc_odma);
 	dbdma_reset(sc->sc_odma);
+	sc->sc_ointr = NULL;
 	return 0;
 }
 
@@ -689,6 +672,7 @@ awacs_halt_input(void *h)
 	sc = h;
 	dbdma_stop(sc->sc_idma);
 	dbdma_reset(sc->sc_idma);
+	sc->sc_iintr = NULL;
 	return 0;
 }
 



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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:17:28 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: deq.c lmu.c psoc.c smusat.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/dev/lmu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/dev/psoc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/smusat.c

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



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

2021-01-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 27 02:17:28 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: deq.c lmu.c psoc.c smusat.c

Log Message:
Use DEVICE_COMPAT_EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/macppc/dev/lmu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/dev/psoc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/smusat.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/macppc/dev/deq.c
diff -u src/sys/arch/macppc/dev/deq.c:1.19 src/sys/arch/macppc/dev/deq.c:1.20
--- src/sys/arch/macppc/dev/deq.c:1.19	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/macppc/dev/deq.c	Wed Jan 27 02:17:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: deq.c,v 1.19 2021/01/25 14:20:39 thorpej Exp $	*/
+/*	$NetBSD: deq.c,v 1.20 2021/01/27 02:17:27 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 2005 Michael Lorenz
@@ -32,7 +32,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.19 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.20 2021/01/27 02:17:27 thorpej Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ static const struct device_compatible_en
 	{ .compat = "pcm3052" },
 	{ .compat = "cs8416" },
 	{ .compat = "codec" },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 int

Index: src/sys/arch/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.7 src/sys/arch/macppc/dev/lmu.c:1.8
--- src/sys/arch/macppc/dev/lmu.c:1.7	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/macppc/dev/lmu.c	Wed Jan 27 02:17:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lmu.c,v 1.7 2021/01/25 14:20:39 thorpej Exp $ */
+/* $NetBSD: lmu.c,v 1.8 2021/01/27 02:17:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.7 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.8 2021/01/27 02:17:28 thorpej Exp $");
 
 #include 
 #include 
@@ -83,7 +83,7 @@ CFATTACH_DECL_NEW(lmu, sizeof(struct lmu
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "lmu-micro" },
 	{ .compat = "lmu-controller" },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 /* time between polling the light sensors */

Index: src/sys/arch/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.5 src/sys/arch/macppc/dev/psoc.c:1.6
--- src/sys/arch/macppc/dev/psoc.c:1.5	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/macppc/dev/psoc.c	Wed Jan 27 02:17:28 2021
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.5 2021/01/25 14:20:39 thorpej Exp $ */
+ /* $NetBSD: psoc.c,v 1.6 2021/01/27 02:17:28 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Michael Lorenz
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.5 2021/01/25 14:20:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.6 2021/01/27 02:17:28 thorpej Exp $");
 
 #include 
 #include 
@@ -82,7 +82,7 @@ CFATTACH_DECL_NEW(psoc, sizeof(struct ps
 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "Psoc" },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 static int

Index: src/sys/arch/macppc/dev/smusat.c
diff -u src/sys/arch/macppc/dev/smusat.c:1.8 src/sys/arch/macppc/dev/smusat.c:1.9
--- src/sys/arch/macppc/dev/smusat.c:1.8	Mon Jan 25 14:20:39 2021
+++ src/sys/arch/macppc/dev/smusat.c	Wed Jan 27 02:17:28 2021
@@ -108,7 +108,7 @@ CFATTACH_DECL_NEW(smusat, sizeof(struct 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "sat" },
 	{ .compat = "smu-sat" },
-	{ }
+	DEVICE_COMPAT_EOL
 };
 
 static int



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

2021-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 17 21:02:33 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: deq.c lmu.c psoc.c smusat.c

Log Message:
Use designated initializers and a consistent termination style in
compat_data[].


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/dev/lmu.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/psoc.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/dev/smusat.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/macppc/dev/deq.c
diff -u src/sys/arch/macppc/dev/deq.c:1.17 src/sys/arch/macppc/dev/deq.c:1.18
--- src/sys/arch/macppc/dev/deq.c:1.17	Fri Sep 20 17:25:11 2019
+++ src/sys/arch/macppc/dev/deq.c	Sun Jan 17 21:02:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: deq.c,v 1.17 2019/09/20 17:25:11 macallan Exp $	*/
+/*	$NetBSD: deq.c,v 1.18 2021/01/17 21:02:33 thorpej Exp $	*/
 
 /*-
  * Copyright (C) 2005 Michael Lorenz
@@ -32,7 +32,7 @@
  */
  
 #include 
-__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.17 2019/09/20 17:25:11 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: deq.c,v 1.18 2021/01/17 21:02:33 thorpej Exp $");
 
 #include 
 #include 
@@ -53,12 +53,13 @@ CFATTACH_DECL_NEW(deq, sizeof(struct deq
 deq_match, deq_attach, NULL, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
-	{ "deq",		0 },
-	{ "tas3004",		0 },
-	{ "pcm3052",		0 },
-	{ "cs8416",		0 },
-	{ "codec",		0 },
-	{ NULL,			0 }
+	{ .compat = "deq" },
+	{ .compat = "tas3004" },
+	{ .compat = "pcm3052" },
+	{ .compat = "cs8416" },
+	{ .compat = "codec" },
+
+	{ 0 }
 };
 
 int

Index: src/sys/arch/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.5 src/sys/arch/macppc/dev/lmu.c:1.6
--- src/sys/arch/macppc/dev/lmu.c:1.5	Sat Sep 12 18:12:53 2020
+++ src/sys/arch/macppc/dev/lmu.c	Sun Jan 17 21:02:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lmu.c,v 1.5 2020/09/12 18:12:53 macallan Exp $ */
+/* $NetBSD: lmu.c,v 1.6 2021/01/17 21:02:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.5 2020/09/12 18:12:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.6 2021/01/17 21:02:33 thorpej Exp $");
 
 #include 
 #include 
@@ -81,9 +81,10 @@ CFATTACH_DECL_NEW(lmu, sizeof(struct lmu
 lmu_match, lmu_attach, NULL, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
-	{ "lmu-micro",		0 },
-	{ "lmu-controller",	0 },
-	{ NULL,			0 }
+	{ .compat = "lmu-micro" },
+	{ .compat = "lmu-controller" },
+
+	{ 0 }
 };
 
 /* time between polling the light sensors */

Index: src/sys/arch/macppc/dev/psoc.c
diff -u src/sys/arch/macppc/dev/psoc.c:1.3 src/sys/arch/macppc/dev/psoc.c:1.4
--- src/sys/arch/macppc/dev/psoc.c:1.3	Sat Nov 23 05:13:11 2019
+++ src/sys/arch/macppc/dev/psoc.c	Sun Jan 17 21:02:33 2021
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.4 2021/01/17 21:02:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Michael Lorenz
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.4 2021/01/17 21:02:33 thorpej Exp $");
 
 #include 
 #include 
@@ -81,8 +81,9 @@ CFATTACH_DECL_NEW(psoc, sizeof(struct ps
 psoc_match, psoc_attach, NULL, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
-	{ "Psoc",		0 },
-	{ NULL,			0 }
+	{ .compat = "Psoc" },
+
+	{ 0 }
 };
 
 static int

Index: src/sys/arch/macppc/dev/smusat.c
diff -u src/sys/arch/macppc/dev/smusat.c:1.6 src/sys/arch/macppc/dev/smusat.c:1.7
--- src/sys/arch/macppc/dev/smusat.c:1.6	Tue Jun 26 06:03:57 2018
+++ src/sys/arch/macppc/dev/smusat.c	Sun Jan 17 21:02:33 2021
@@ -106,9 +106,10 @@ CFATTACH_DECL_NEW(smusat, sizeof(struct 
 smusat_match, smusat_attach, NULL, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
-	{ "sat",		0 },
-	{ "smu-sat",		0 },
-	{ NULL,			0 }
+	{ .compat = "sat" },
+	{ .compat = "smu-sat" },
+
+	{ 0 }
 };
 
 static int



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

2021-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 17 21:02:33 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: deq.c lmu.c psoc.c smusat.c

Log Message:
Use designated initializers and a consistent termination style in
compat_data[].


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/macppc/dev/deq.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/macppc/dev/lmu.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/psoc.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/dev/smusat.c

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



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

2020-12-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec 19 21:54:42 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: aed.c apm.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/macppc/dev/aed.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/macppc/dev/apm.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/macppc/dev/aed.c
diff -u src/sys/arch/macppc/dev/aed.c:1.30 src/sys/arch/macppc/dev/aed.c:1.31
--- src/sys/arch/macppc/dev/aed.c:1.30	Wed Oct 25 08:12:37 2017
+++ src/sys/arch/macppc/dev/aed.c	Sat Dec 19 21:54:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aed.c,v 1.30 2017/10/25 08:12:37 maya Exp $	*/
+/*	$NetBSD: aed.c,v 1.31 2020/12/19 21:54:42 thorpej Exp $	*/
 
 /*
  * Copyright (C) 1994	Bradley A. Grantham
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aed.c,v 1.30 2017/10/25 08:12:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aed.c,v 1.31 2020/12/19 21:54:42 thorpej Exp $");
 
 #include 
 #include 
@@ -590,7 +590,7 @@ filt_aedrdetach(struct knote *kn)
 	int s;
 
 	s = spladb();
-	SLIST_REMOVE(_sc->sc_selinfo.sel_klist, kn, knote, kn_selnext);
+	selremove_knote(_sc->sc_selinfo, kn);
 	splx(s);
 }
 
@@ -619,17 +619,14 @@ static const struct filterops aed_seltru
 int
 aedkqfilter(dev_t dev, struct knote *kn)
 {
-	struct klist *klist;
 	int s;
 
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
-		klist = _sc->sc_selinfo.sel_klist;
 		kn->kn_fop = _filtops;
 		break;
 
 	case EVFILT_WRITE:
-		klist = _sc->sc_selinfo.sel_klist;
 		kn->kn_fop = _seltrue_filtops;
 		break;
 
@@ -640,7 +637,7 @@ aedkqfilter(dev_t dev, struct knote *kn)
 	kn->kn_hook = NULL;
 
 	s = spladb();
-	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+	selrecord_knote(_sc->sc_selinfo, kn);
 	splx(s);
 
 	return (0);

Index: src/sys/arch/macppc/dev/apm.c
diff -u src/sys/arch/macppc/dev/apm.c:1.28 src/sys/arch/macppc/dev/apm.c:1.29
--- src/sys/arch/macppc/dev/apm.c:1.28	Fri Oct 30 22:20:38 2020
+++ src/sys/arch/macppc/dev/apm.c	Sat Dec 19 21:54:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: apm.c,v 1.28 2020/10/30 22:20:38 christos Exp $	*/
+/*	$NetBSD: apm.c,v 1.29 2020/12/19 21:54:42 thorpej Exp $	*/
 /*	$OpenBSD: apm.c,v 1.5 2002/06/07 07:13:59 miod Exp $	*/
 
 /*-
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.28 2020/10/30 22:20:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.29 2020/12/19 21:54:42 thorpej Exp $");
 
 #include "apm.h"
 
@@ -418,7 +418,7 @@ filt_apmrdetach(struct knote *kn)
 	struct apm_softc *sc = (struct apm_softc *)kn->kn_hook;
 
 	APM_LOCK(sc);
-	SLIST_REMOVE(>sc_rsel.sel_klist, kn, knote, kn_selnext);
+	selremove_knote(>sc_rsel, kn);
 	APM_UNLOCK(sc);
 }
 
@@ -442,11 +442,9 @@ int
 apmkqfilter(dev_t dev, struct knote *kn)
 {
 	struct apm_softc *sc = device_lookup_private(_cd,APMUNIT(dev));
-	struct klist *klist;
 
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
-		klist = >sc_rsel.sel_klist;
 		kn->kn_fop = _filtops;
 		break;
 	default:
@@ -456,7 +454,7 @@ apmkqfilter(dev_t dev, struct knote *kn)
 	kn->kn_hook = sc;
 
 	APM_LOCK(sc);
-	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+	selrecord_knote(>sc_rsel, kn);
 	APM_UNLOCK(sc);
 
 	return (0);



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

2020-12-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec 19 21:54:42 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: aed.c apm.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/macppc/dev/aed.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/macppc/dev/apm.c

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



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

2020-09-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 12 18:12:53 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
respond to keyboard brightness control PMF events


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/macppc/dev/lmu.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/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.4 src/sys/arch/macppc/dev/lmu.c:1.5
--- src/sys/arch/macppc/dev/lmu.c:1.4	Thu Apr 23 12:56:40 2020
+++ src/sys/arch/macppc/dev/lmu.c	Sat Sep 12 18:12:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lmu.c,v 1.4 2020/04/23 12:56:40 macallan Exp $ */
+/* $NetBSD: lmu.c,v 1.5 2020/09/12 18:12:53 macallan Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.4 2020/04/23 12:56:40 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.5 2020/09/12 18:12:53 macallan Exp $");
 
 #include 
 #include 
@@ -123,6 +123,26 @@ lmu_video_off(device_t dev)
 	sc->sc_video_state = false;
 }
 
+static void
+lmu_kbd_brightness_up(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_level = __MIN(16, sc->sc_level + 2);
+	sc->sc_target = sc->sc_level;
+	callout_schedule(>sc_adjust, LMU_FADE);
+}
+
+static void
+lmu_kbd_brightness_down(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_level = __MAX(0, sc->sc_level - 2);
+	sc->sc_target = sc->sc_level;
+	callout_schedule(>sc_adjust, LMU_FADE);
+}
+
 static int
 lmu_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -162,6 +182,10 @@ lmu_attach(device_t parent, device_t sel
 	lmu_video_on, true);
 	pmf_event_register(sc->sc_dev, PMFE_DISPLAY_OFF,
 	lmu_video_off, true);
+	pmf_event_register(sc->sc_dev, PMFE_KEYBOARD_BRIGHTNESS_UP,
+	lmu_kbd_brightness_up, true);
+	pmf_event_register(sc->sc_dev, PMFE_KEYBOARD_BRIGHTNESS_DOWN,
+	lmu_kbd_brightness_down, true);
 
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sme->sme_name = device_xname(self);



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

2020-09-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 12 18:12:53 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
respond to keyboard brightness control PMF events


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

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



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

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 08:58:03 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: cuda.c pmu.c

Log Message:
Adapt to new proplib API


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/dev/cuda.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/macppc/dev/pmu.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/macppc/dev/cuda.c
diff -u src/sys/arch/macppc/dev/cuda.c:1.25 src/sys/arch/macppc/dev/cuda.c:1.26
--- src/sys/arch/macppc/dev/cuda.c:1.25	Tue Jul 14 08:52:00 2020
+++ src/sys/arch/macppc/dev/cuda.c	Tue Jul 14 08:58:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cuda.c,v 1.25 2020/07/14 08:52:00 martin Exp $ */
+/*	$NetBSD: cuda.c,v 1.26 2020/07/14 08:58:03 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.25 2020/07/14 08:52:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.26 2020/07/14 08:58:03 martin Exp $");
 
 #include 
 #include 
@@ -259,7 +259,7 @@ cuda_attach(device_t parent, device_t se
 	node = OF_finddevice("/valkyrie");
 	if (node != -1) {
 		dev = prop_dictionary_create();
-		prop_dictionary_set_cstring(dev, "name", "videopll");
+		prop_dictionary_set_string(dev, "name", "videopll");
 		prop_dictionary_set_uint32(dev, "addr", 0x50);
 		prop_array_add(cfg, dev);
 		prop_object_release(dev);

Index: src/sys/arch/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.33 src/sys/arch/macppc/dev/pmu.c:1.34
--- src/sys/arch/macppc/dev/pmu.c:1.33	Sun Dec 22 23:23:30 2019
+++ src/sys/arch/macppc/dev/pmu.c	Tue Jul 14 08:58:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.33 2019/12/22 23:23:30 thorpej Exp $ */
+/*	$NetBSD: pmu.c,v 1.34 2020/07/14 08:58:03 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.33 2019/12/22 23:23:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.34 2020/07/14 08:58:03 martin Exp $");
 
 #include 
 #include 
@@ -365,8 +365,8 @@ pmu_attach(device_t parent, device_t sel
 addr = (addr & 0xff) >> 1;
 DPRINTF("-> %s@%x\n", name, addr);
 dev = prop_dictionary_create();
-prop_dictionary_set_cstring(dev, "name", name);
-data = prop_data_create_data(compat, strlen(compat)+1);
+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);
 prop_dictionary_set_uint32(dev, "addr", addr);



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

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 08:58:03 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: cuda.c pmu.c

Log Message:
Adapt to new proplib API


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/dev/cuda.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/macppc/dev/pmu.c

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



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

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 08:52:00 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: cuda.c

Log Message:
Adapt to new proplib API


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/macppc/dev/cuda.c

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



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

2020-07-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jul 14 08:52:00 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: cuda.c

Log Message:
Adapt to new proplib API


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/macppc/dev/cuda.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/macppc/dev/cuda.c
diff -u src/sys/arch/macppc/dev/cuda.c:1.24 src/sys/arch/macppc/dev/cuda.c:1.25
--- src/sys/arch/macppc/dev/cuda.c:1.24	Sun Dec 22 23:23:30 2019
+++ src/sys/arch/macppc/dev/cuda.c	Tue Jul 14 08:52:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cuda.c,v 1.24 2019/12/22 23:23:30 thorpej Exp $ */
+/*	$NetBSD: cuda.c,v 1.25 2020/07/14 08:52:00 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.24 2019/12/22 23:23:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.25 2020/07/14 08:52:00 martin Exp $");
 
 #include 
 #include 
@@ -268,7 +268,7 @@ cuda_attach(device_t parent, device_t se
 	node = OF_finddevice("/perch");
 	if (node != -1) {
 		dev = prop_dictionary_create();
-		prop_dictionary_set_cstring(dev, "name", "sgsmix");
+		prop_dictionary_set_string(dev, "name", "sgsmix");
 		prop_dictionary_set_uint32(dev, "addr", 0x8a);
 		prop_array_add(cfg, dev);
 		prop_object_release(dev);



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

2020-07-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul  4 11:55:18 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
- Adjust location of \n in attach message.
- Convert to aprint_*(9).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/smu.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/macppc/dev/smu.c
diff -u src/sys/arch/macppc/dev/smu.c:1.8 src/sys/arch/macppc/dev/smu.c:1.9
--- src/sys/arch/macppc/dev/smu.c:1.8	Sun Dec 22 23:23:30 2019
+++ src/sys/arch/macppc/dev/smu.c	Sat Jul  4 11:55:18 2020
@@ -217,6 +217,8 @@ smu_attach(device_t parent, device_t sel
 		return;
 	}
 
+	aprint_normal("\n");
+
 	smu_setup_fans(sc);
 	smu_setup_iicbus(sc);
 
@@ -227,7 +229,6 @@ smu_attach(device_t parent, device_t sel
 
 	smu_setup_sme(sc);
 
-	printf("\n");
 	smu_setup_zones(sc);
 }
 
@@ -866,7 +867,8 @@ smu_setup_zones(struct smu_softc *sc)
 			z->nfans++;
 		}
 	}
-	printf("using %d fans for CPU zone\n", z->nfans);
+	aprint_normal_dev(sc->sc_dev,
+	"using %d fans for CPU zone\n", z->nfans);
 	z->threshold = C_TO_uK(45);
 	z->duty = 150;
 	z->step = 3;	
@@ -881,7 +883,8 @@ smu_setup_zones(struct smu_softc *sc)
 			z->nfans++;
 		}
 	}
-	printf("using %d fans for drive bay zone\n", z->nfans);
+	aprint_normal_dev(sc->sc_dev,
+	"using %d fans for drive bay zone\n", z->nfans);
 	z->threshold = C_TO_uK(40);
 	z->duty = 150;
 	z->step = 2;
@@ -897,7 +900,8 @@ smu_setup_zones(struct smu_softc *sc)
 			z->nfans++;
 		}
 	}
-	printf("using %d fans for expansion slots zone\n", z->nfans);
+	aprint_normal_dev(sc->sc_dev,
+	"using %d fans for expansion slots zone\n", z->nfans);
 	z->threshold = C_TO_uK(40);
 	z->duty = 150;
 	z->step = 2;



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

2020-07-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul  4 11:55:18 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smu.c

Log Message:
- Adjust location of \n in attach message.
- Convert to aprint_*(9).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/dev/smu.c

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



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

2020-07-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul  2 12:47:19 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
add $NetBSD:


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

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



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

2020-07-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul  2 12:47:19 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
add $NetBSD:


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/macppc/dev/smuiic.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/macppc/dev/smuiic.c
diff -u src/sys/arch/macppc/dev/smuiic.c:1.4 src/sys/arch/macppc/dev/smuiic.c:1.5
--- src/sys/arch/macppc/dev/smuiic.c:1.4	Thu Jul  2 12:45:27 2020
+++ src/sys/arch/macppc/dev/smuiic.c	Thu Jul  2 12:47:19 2020
@@ -1,3 +1,5 @@
+/*	$NetBSD: smuiic.c,v 1.5 2020/07/02 12:47:19 macallan Exp $ */
+
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.



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

2020-07-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul  2 12:45:27 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
proplib API catchup


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

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



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

2020-07-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul  2 12:45:27 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: smuiic.c

Log Message:
proplib API catchup


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/smuiic.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/macppc/dev/smuiic.c
diff -u src/sys/arch/macppc/dev/smuiic.c:1.3 src/sys/arch/macppc/dev/smuiic.c:1.4
--- src/sys/arch/macppc/dev/smuiic.c:1.3	Fri Apr 20 18:22:50 2018
+++ src/sys/arch/macppc/dev/smuiic.c	Thu Jul  2 12:45:27 2020
@@ -100,8 +100,8 @@ smuiic_attach(device_t parent, device_t 
 			goto skip;
 		addr = (addr & 0xff) >> 1;
 		dev = prop_dictionary_create();
-		prop_dictionary_set_cstring(dev, "name", name);
-		data = prop_data_create_data(compat, strlen(compat)+1);
+		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);
 		prop_dictionary_set_uint32(dev, "addr", addr);



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

2020-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 12 06:44:57 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: ki2c.c

Log Message:
more proplib API catchup


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/dev/ki2c.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/macppc/dev/ki2c.c
diff -u src/sys/arch/macppc/dev/ki2c.c:1.29 src/sys/arch/macppc/dev/ki2c.c:1.30
--- src/sys/arch/macppc/dev/ki2c.c:1.29	Thu Jan  9 18:49:06 2020
+++ src/sys/arch/macppc/dev/ki2c.c	Fri Jun 12 06:44:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ki2c.c,v 1.29 2020/01/09 18:49:06 macallan Exp $	*/
+/*	$NetBSD: ki2c.c,v 1.30 2020/06/12 06:44:57 macallan Exp $	*/
 /*	Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp	*/
 
 /*-
@@ -173,8 +173,8 @@ ki2c_attach(device_t parent, device_t se
 			addr = addr >> 1;
 			DPRINTF("-> %s@%x\n", name, addr);
 			dev = prop_dictionary_create();
-			prop_dictionary_set_cstring(dev, "name", name);
-			data = prop_data_create_data(compat, strlen(compat)+1);
+			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);
 			prop_dictionary_set_uint32(dev, "addr", addr);
@@ -187,7 +187,7 @@ ki2c_attach(device_t parent, device_t se
 	goto nope;
 DPRINTF("found '%s' at %02x\n", descr, reg);
 snprintf(num, 7, "s%02x", reg);
-prop_dictionary_set_cstring(dev, num, descr);
+prop_dictionary_set_string(dev, num, descr);
 			nope:
 devc = OF_peer(devc);
 			}



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

2020-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun 12 06:44:57 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: ki2c.c

Log Message:
more proplib API catchup


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/dev/ki2c.c

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



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

2020-04-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 23 12:56:40 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
make this work properly:
- get rid of cargo-culted register assignments, I found the right ones by
  experiment, now both light sensors report sane values
- keyboard brightness seems to max out at 16, act like it
- do what MacOS does and fade keyboard brightness instead of just switching
- add sysctls to configure keyboard brightness and environmental light
  thresholds
- don't poll the chip more often than once a second


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/lmu.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/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.3 src/sys/arch/macppc/dev/lmu.c:1.4
--- src/sys/arch/macppc/dev/lmu.c:1.3	Thu Apr 23 09:47:31 2020
+++ src/sys/arch/macppc/dev/lmu.c	Thu Apr 23 12:56:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $ */
+/* $NetBSD: lmu.c,v 1.4 2020/04/23 12:56:40 macallan Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.4 2020/04/23 12:56:40 macallan Exp $");
 
 #include 
 #include 
@@ -40,11 +40,18 @@ __KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.3 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 #include 
 
+#ifdef LMU_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
 struct lmu_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
@@ -54,7 +61,9 @@ struct lmu_softc {
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t	sc_sensors[2];
 	callout_t	sc_adjust;
-	int		sc_thresh, sc_hyst, sc_level;
+	int		sc_thresh, sc_hyst, sc_level, sc_target, sc_current;
+	int		sc_lux[2];
+	time_t		sc_last;
 	int		sc_lid_state, sc_video_state;
 };
 
@@ -65,6 +74,8 @@ static void	lmu_sensors_refresh(struct s
 static void	lmu_set_brightness(struct lmu_softc *, int);
 static int	lmu_get_brightness(struct lmu_softc *, int);
 static void	lmu_adjust(void *);
+static int 	lmu_sysctl(SYSCTLFN_ARGS);
+static int 	lmu_sysctl_thresh(SYSCTLFN_ARGS);
 
 CFATTACH_DECL_NEW(lmu, sizeof(struct lmu_softc),
 lmu_match, lmu_attach, NULL, NULL);
@@ -75,6 +86,11 @@ static const struct device_compatible_en
 	{ NULL,			0 }
 };
 
+/* time between polling the light sensors */
+#define LMU_POLL	(hz * 2)
+/* time between updates to keyboard brightness */
+#define LMU_FADE	(hz / 16)
+
 static void
 lmu_lid_open(device_t dev)
 {
@@ -125,11 +141,13 @@ lmu_attach(device_t parent, device_t sel
 	struct lmu_softc *sc = device_private(self);
 	struct i2c_attach_args *ia = aux;
 	envsys_data_t *s;
+	const struct sysctlnode *me;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
 	sc->sc_addr = ia->ia_addr;
 	sc->sc_node = ia->ia_cookie;
+	sc->sc_last = 0;
 
 	aprint_naive("\n");
 	aprint_normal(": ambient light sensor\n");
@@ -161,7 +179,7 @@ lmu_attach(device_t parent, device_t sel
 	s->state = ENVSYS_SINVALID;
 	s->units = ENVSYS_LUX;
 	strcpy(s->desc, "left");
-	s->private = 2;
+	s->private = 1;
 	sysmon_envsys_sensor_attach(sc->sc_sme, s);
 
 	sysmon_envsys_register(sc->sc_sme);
@@ -169,7 +187,30 @@ lmu_attach(device_t parent, device_t sel
 	/* TODO: make this adjustable via sysctl */
 	sc->sc_thresh = 300;
 	sc->sc_hyst = 30;
-	sc->sc_level = 100;
+	sc->sc_level = 16;
+	sc->sc_target = 0;
+	sc->sc_current = 0;
+
+	sysctl_createv(NULL, 0, NULL, ,
+		CTLFLAG_READWRITE,
+		CTLTYPE_NODE, "lmu",
+		SYSCTL_DESCR("LMU driver"),
+		NULL, 0, NULL, 0,
+		CTL_HW, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, NULL,
+		CTLFLAG_READWRITE,
+		CTLTYPE_INT, "level",
+		SYSCTL_DESCR("keyboard brightness"),
+		lmu_sysctl, 0, (void *)sc, 0,
+		CTL_HW, me->sysctl_num, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, NULL,
+		CTLFLAG_READWRITE,
+		CTLTYPE_INT, "threshold",
+		SYSCTL_DESCR("environmental light threshold"),
+		lmu_sysctl_thresh, 1, (void *)sc, 0,
+		CTL_HW, me->sysctl_num, CTL_CREATE, CTL_EOL);
 
 	callout_init(>sc_adjust, 0);
 	callout_setfunc(>sc_adjust, lmu_adjust, sc);
@@ -193,28 +234,38 @@ lmu_sensors_refresh(struct sysmon_envsys
 static int
 lmu_get_brightness(struct lmu_softc *sc, int reg)
 {
-	int error;
-	uint16_t buf;
-	uint8_t cmd = reg;
+	int error, i;
+	uint16_t buf[2];
+	uint8_t cmd = 0;
+
+	if (reg > 1) return -1;
+	if (time_second == sc->sc_last)
+		return sc->sc_lux[reg];
 
 	iic_acquire_bus(sc->sc_i2c, 0);
 	error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-		sc->sc_addr, , 1, , 2, 0);
+		sc->sc_addr, , 1, buf, 4, 0);
 	iic_release_bus(sc->sc_i2c, 0);
 	if (error) return -1;
-	return be16toh(buf);
+	sc->sc_last = time_second;
+
+	for (i = 0; i < 2; i++)
+		sc->sc_lux[i] = be16toh(buf[i]);
+
+	DPRINTF("<%d %04x %04x>", reg, buf[0], buf[1]);
+	
+	return 

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

2020-04-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 23 12:56:40 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
make this work properly:
- get rid of cargo-culted register assignments, I found the right ones by
  experiment, now both light sensors report sane values
- keyboard brightness seems to max out at 16, act like it
- do what MacOS does and fade keyboard brightness instead of just switching
- add sysctls to configure keyboard brightness and environmental light
  thresholds
- don't poll the chip more often than once a second


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

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



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

2020-04-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 23 09:47:31 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
drop openfirm.h include


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

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



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

2020-04-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 23 09:47:31 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
drop openfirm.h include


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/lmu.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/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.2 src/sys/arch/macppc/dev/lmu.c:1.3
--- src/sys/arch/macppc/dev/lmu.c:1.2	Thu Feb  6 02:17:24 2020
+++ src/sys/arch/macppc/dev/lmu.c	Thu Apr 23 09:47:31 2020
@@ -1,4 +1,4 @@
- /* $NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $ */
+/* $NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $");
 
 #include 
 #include 
@@ -41,8 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.2 
 #include 
 #include 
 
-#include 
-
 #include 
 
 #include 
@@ -56,7 +54,7 @@ struct lmu_softc {
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t	sc_sensors[2];
 	callout_t	sc_adjust;
-	int sc_thresh, sc_hyst, sc_level;
+	int		sc_thresh, sc_hyst, sc_level;
 	int		sc_lid_state, sc_video_state;
 };
 



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

2020-04-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 11 01:42:56 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
don't try to read a 32bit property into a uint8_t.
Now headphone detection works properly on machines which have the gpio's
polarity reversed, like Quicksilver and TiBook.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.53 src/sys/arch/macppc/dev/snapper.c:1.54
--- src/sys/arch/macppc/dev/snapper.c:1.53	Fri Sep 20 21:24:34 2019
+++ src/sys/arch/macppc/dev/snapper.c	Sat Apr 11 01:42:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.53 2019/09/20 21:24:34 macallan Exp $	*/
+/*	$NetBSD: snapper.c,v 1.54 2020/04/11 01:42:56 macallan Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.53 2019/09/20 21:24:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.54 2020/04/11 01:42:56 macallan Exp $");
 
 #include 
 #include 
@@ -497,7 +497,7 @@ static bus_size_t amp_mute;
 static bus_size_t headphone_mute;
 static bus_size_t audio_hw_reset;
 static bus_size_t headphone_detect;
-static uint8_t headphone_detect_active;
+static uint8_t headphone_detect_active = 0;
 
 
 /* I2S registers */
@@ -2091,9 +2091,10 @@ snapper_init(struct snapper_softc *sc, i
 		/* extint-gpio15 */
 		if (strcmp(audio_gpio, "headphone-detect") == 0 ||
 		strcmp(name, "headphone-detect") == 0) {
+			uint32_t act;
 			headphone_detect = addr;
-			OF_getprop(gpio, "audio-gpio-active-state",
-			_detect_active, 4);
+			OF_getprop(gpio, "audio-gpio-active-state", , 4);
+			headphone_detect_active = act;
 			if (OF_getprop(gpio, "interrupts", intr, 8) == 8) {
 headphone_detect_intr = intr[0];
 			}



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

2020-04-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 11 01:42:56 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
don't try to read a 32bit property into a uint8_t.
Now headphone detection works properly on machines which have the gpio's
polarity reversed, like Quicksilver and TiBook.


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

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



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

2020-02-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb  6 02:17:24 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
listen to PMF events in order to turn off keyboard lights when the lid is
closed or the screen is blanked


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

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



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

2020-02-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb  6 02:17:24 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: lmu.c

Log Message:
listen to PMF events in order to turn off keyboard lights when the lid is
closed or the screen is blanked


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/lmu.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/macppc/dev/lmu.c
diff -u src/sys/arch/macppc/dev/lmu.c:1.1 src/sys/arch/macppc/dev/lmu.c:1.2
--- src/sys/arch/macppc/dev/lmu.c:1.1	Fri Jan 10 06:24:17 2020
+++ src/sys/arch/macppc/dev/lmu.c	Thu Feb  6 02:17:24 2020
@@ -1,4 +1,4 @@
- /* $NetBSD: lmu.c,v 1.1 2020/01/10 06:24:17 macallan Exp $ */
+ /* $NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.1 2020/01/10 06:24:17 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $");
 
 #include 
 #include 
@@ -56,7 +56,8 @@ struct lmu_softc {
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t	sc_sensors[2];
 	callout_t	sc_adjust;
-	int sc_thresh, sc_hyst;
+	int sc_thresh, sc_hyst, sc_level;
+	int		sc_lid_state, sc_video_state;
 };
 
 static int	lmu_match(device_t, cfdata_t, void *);
@@ -76,6 +77,38 @@ static const struct device_compatible_en
 	{ NULL,			0 }
 };
 
+static void
+lmu_lid_open(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_lid_state = true;
+}
+
+static void
+lmu_lid_close(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_lid_state = false;
+}
+
+static void
+lmu_video_on(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_video_state = true;
+}
+
+static void
+lmu_video_off(device_t dev)
+{
+	struct lmu_softc * const sc = device_private(dev);
+
+	sc->sc_video_state = false;
+}
+
 static int
 lmu_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -103,6 +136,17 @@ lmu_attach(device_t parent, device_t sel
 	aprint_naive("\n");
 	aprint_normal(": ambient light sensor\n");
 
+	sc->sc_lid_state = true;
+	pmf_event_register(sc->sc_dev, PMFE_CHASSIS_LID_OPEN,
+	lmu_lid_open, true);
+	pmf_event_register(sc->sc_dev, PMFE_CHASSIS_LID_CLOSE,
+	lmu_lid_close, true);
+	sc->sc_video_state = true;
+	pmf_event_register(sc->sc_dev, PMFE_DISPLAY_ON,
+	lmu_video_on, true);
+	pmf_event_register(sc->sc_dev, PMFE_DISPLAY_OFF,
+	lmu_video_off, true);
+
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sme->sme_name = device_xname(self);
 	sc->sc_sme->sme_cookie = sc;
@@ -127,6 +171,7 @@ lmu_attach(device_t parent, device_t sel
 	/* TODO: make this adjustable via sysctl */
 	sc->sc_thresh = 300;
 	sc->sc_hyst = 30;
+	sc->sc_level = 100;
 
 	callout_init(>sc_adjust, 0);
 	callout_setfunc(>sc_adjust, lmu_adjust, sc);
@@ -189,10 +234,11 @@ lmu_adjust(void *cookie)
 	right = lmu_get_brightness(sc, 0);
 	b = left > right ? left : right;
 
-	if (b > (sc->sc_thresh + sc->sc_hyst)) {
+	if ((b > (sc->sc_thresh + sc->sc_hyst)) ||
+	   !(sc->sc_lid_state && sc->sc_video_state)) {
 		lmu_set_brightness(sc, 0);
 	} else if (b < sc->sc_thresh) {
-		lmu_set_brightness(sc, 100);
+		lmu_set_brightness(sc, sc->sc_level);
 	}
 
 	callout_schedule(>sc_adjust, hz * 2);	



  1   2   3   4   >