Re: CVS commit: src/sys/arch/macppc/conf

2024-01-17 Thread Valery Ushakov
On Thu, Jan 18, 2024 at 06:43:21 +1100, matthew green wrote:

> > Log Message:
> > macppc: enable FFS_EI in GENERIC
> >
> > I'd say it should be enabled for anything with USB.
> >
> > ok macallan
> 
> yay.  i think we should enable it basically everywhere that it
> is not a space issue.

I think the size impact should be trivial (though I didn't measure).
The option basically guards just a couple dozens of "bit test plus
bswap call" snippets.


> USB is just one common way, but i can also modify or create my own
> images anyway, and maybe copy them over the network to my machine
> with USB...or maybe i'll setup the disk on this machine's scsi for
> that machine ;)

Yeah.  I just didn't want to open that can of yaks to shave... :)


-uwe


re: CVS commit: src/sys/arch/macppc/conf

2024-01-17 Thread matthew green
> Log Message:
> macppc: enable FFS_EI in GENERIC
>
> I'd say it should be enabled for anything with USB.
>
> ok macallan

yay.  i think we should enable it basically everywhere that it
is not a space issue.  USB is just one common way, but i can
also modify or create my own images anyway, and maybe copy them
over the network to my machine with USB...or maybe i'll setup
the disk on this machine's scsi for that machine ;)


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

2024-01-17 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Jan 17 13:23:30 UTC 2024

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

Log Message:
macppc: enable FFS_EI in GENERIC

I'd say it should be enabled for anything with USB.

ok macallan


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.377 src/sys/arch/macppc/conf/GENERIC:1.378
--- src/sys/arch/macppc/conf/GENERIC:1.377	Thu Feb  9 14:09:49 2023
+++ src/sys/arch/macppc/conf/GENERIC	Wed Jan 17 13:23:30 2024
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.377 2023/02/09 14:09:49 abs Exp $
+# $NetBSD: GENERIC,v 1.378 2024/01/17 13:23:30 uwe Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.377 $"
+#ident 		"GENERIC-$Revision: 1.378 $"
 
 maxusers	32
 
@@ -84,7 +84,7 @@ include "conf/filesystems.config"
 
 # File system options
 options 	APPLE_UFS	# Apple UFS support in FFS
-#options 	FFS_EI		# FFS Endian Independent support
+options 	FFS_EI		# FFS Endian Independent support
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	QUOTA		# legacy UFS quotas
 options 	QUOTA2		# new, in-filesystem UFS quotas



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

2024-01-17 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Jan 17 13:23:30 UTC 2024

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

Log Message:
macppc: enable FFS_EI in GENERIC

I'd say it should be enabled for anything with USB.

ok macallan


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 src/sys/arch/macppc/conf/GENERIC

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



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

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Dec 28 04:43:55 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: rbus_machdep.c

Log Message:
macppc/cardbus: Belatedly catch up with battable resolution change

Fix pmap_extract() failures on models with cardslot, for direct-mapped
buffers allocated by PMAP_ALLOC_POOLPAGE().

This driver had corrupted battable[] over 11 years, since resolution of
battable was changed from 256MB to 8MB:

https://github.com/NetBSD/src/commit/413fb4c3c505a13900a9dff86f563fc58ff04005

Now, indexes for battable[] should be calculated by (va >> 23), but
rather, use oea_iobat_add() instead of directly modifying battable[].

TODO:
- Add some consistency checks to oea_iobat_add().
- Map reasonable VA space for cardbus(4), if OFW does not. Note that
  hardcoded value of 0x9000-0x9fff should be safe for now, not
  that elegant although. For macppc models, IIUC, RAM is *not* mapped to
  0x8000-0x, and VA reserved for kernel and copy{in,out} is
  0xc000-0xefff.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/macppc/macppc/rbus_machdep.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/macppc

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Dec 28 04:43:55 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: rbus_machdep.c

Log Message:
macppc/cardbus: Belatedly catch up with battable resolution change

Fix pmap_extract() failures on models with cardslot, for direct-mapped
buffers allocated by PMAP_ALLOC_POOLPAGE().

This driver had corrupted battable[] over 11 years, since resolution of
battable was changed from 256MB to 8MB:

https://github.com/NetBSD/src/commit/413fb4c3c505a13900a9dff86f563fc58ff04005

Now, indexes for battable[] should be calculated by (va >> 23), but
rather, use oea_iobat_add() instead of directly modifying battable[].

TODO:
- Add some consistency checks to oea_iobat_add().
- Map reasonable VA space for cardbus(4), if OFW does not. Note that
  hardcoded value of 0x9000-0x9fff should be safe for now, not
  that elegant although. For macppc models, IIUC, RAM is *not* mapped to
  0x8000-0x, and VA reserved for kernel and copy{in,out} is
  0xc000-0xefff.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/macppc/macppc/rbus_machdep.c

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

Modified files:

Index: src/sys/arch/macppc/macppc/rbus_machdep.c
diff -u src/sys/arch/macppc/macppc/rbus_machdep.c:1.18 src/sys/arch/macppc/macppc/rbus_machdep.c:1.19
--- src/sys/arch/macppc/macppc/rbus_machdep.c:1.18	Fri Jul  1 18:43:05 2011
+++ src/sys/arch/macppc/macppc/rbus_machdep.c	Thu Dec 28 04:43:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rbus_machdep.c,v 1.18 2011/07/01 18:43:05 dyoung Exp $	*/
+/*	$NetBSD: rbus_machdep.c,v 1.19 2023/12/28 04:43:55 rin Exp $	*/
 
 /*
  * Copyright (c) 1999
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.18 2011/07/01 18:43:05 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.19 2023/12/28 04:43:55 rin Exp $");
 
 #include 
 #include 
@@ -92,8 +92,7 @@ rbus_pccbb_parent_mem(struct pci_attach_
 		size  = 0x1000;
 	}
 
-	battable[start >> 28].batl = BATL(start, BAT_I, BAT_PP_RW);
-	battable[start >> 28].batu = BATU(start, BAT_BL_256M, BAT_Vs);
+	oea_iobat_add(start, size);
 
 	return rbus_new_root_delegate(pa->pa_memt, start, size, 0);
 }



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

2023-10-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Oct  3 08:23:07 UTC 2023

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add xhci


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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/conf/POWERMAC_G5_11_2
diff -u src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.22 src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.23
--- src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.22	Sun Aug  7 02:52:27 2022
+++ src/sys/arch/macppc/conf/POWERMAC_G5_11_2	Tue Oct  3 08:23:07 2023
@@ -155,9 +155,13 @@ ukphy*	at mii? phy ?			# generic unknown
 # PCI USB controllers
 ohci*	at pci? dev ? function ?	# USB Open Host Controller
 ehci*	at pci? dev ? function ?	# USB Enhanced Host Controller
+# No G5 ships with USB 3.0 but xhci 1.0 cards have been confirmed working
+# in PCIe models
+xhci*	at pci? dev ? function ?	# USB 3.0
 
 usb*	at ohci?	# USB bus support
 usb*	at ehci?	# USB bus support
+usb*	at xhci?	# USB bus support
 uhub*	at usb?		# USB Hubs
 uhub*	at uhub? port ?
 uhidev*	at uhub? port ? configuration ? interface ?	# USB HID device



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

2023-10-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Oct  3 08:23:07 UTC 2023

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add xhci


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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

2023-05-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  9 10:49:47 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
check for proper error value from OF_finddevice()
should fix PR57394


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/macppc/mainbus.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/macppc/mainbus.c
diff -u src/sys/arch/macppc/macppc/mainbus.c:1.25 src/sys/arch/macppc/macppc/mainbus.c:1.26
--- src/sys/arch/macppc/macppc/mainbus.c:1.25	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/macppc/macppc/mainbus.c	Tue May  9 10:49:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $");
 
 #include 
 #include 
@@ -76,7 +76,13 @@ mainbus_attach(device_t parent, device_t
 	devhandle_t selfh = device_handle(self);
 
 	cpus = OF_finddevice("/cpus");
-	if (cpus != 0) {
+	/*
+	 * XXX
+	 * the canonical error value is -1 but I dimly remember some OF
+	 * variants returning 0 here, so check for both just in case.
+	 * It's not like this is a performance critical path.
+	 */
+	if ((cpus != -1) && (cpus != 0)) {
 		node = OF_child(cpus);
 		while (node != 0) {
 			ca.ca_name = "cpu";



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

2023-05-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  9 10:49:47 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: mainbus.c

Log Message:
check for proper error value from OF_finddevice()
should fix PR57394


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/macppc/mainbus.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/conf

2023-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 26 00:15:48 UTC 2023

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

Log Message:
do some cleanup
the gm driver has been commented out for 20 years, time to remove it
while there, remove ofb and the old ADB code which have been commented out
since 2007


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.375 src/sys/arch/macppc/conf/GENERIC:1.376
--- src/sys/arch/macppc/conf/GENERIC:1.375	Sun Aug  7 02:52:27 2022
+++ src/sys/arch/macppc/conf/GENERIC	Thu Jan 26 00:15:47 2023
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.375 2022/08/07 02:52:27 simonb Exp $
+# $NetBSD: GENERIC,v 1.376 2023/01/26 00:15:47 macallan Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.375 $"
+#ident 		"GENERIC-$Revision: 1.376 $"
 
 maxusers	32
 
@@ -206,7 +206,6 @@ epic*	at pci? dev ? function ?	# SMC EPI
 ex*	at pci? dev ? function ?	# 3Com 90x[BC]
 fxp*	at pci? dev ? function ?	# Intel EtherExpress PRO 10+/100B
 gem*	at pci? dev ? function ?	# gmac ethernet
-#gm*	at pci? dev ? function ?	# gmac ethernet (old)
 gsip*	at pci? dev ? function ?	# NS83820 Gigabit Ethernet
 mtd*	at pci? dev ? function ?	# Myson MTD803 3-in-1 Ethernet
 ne*	at pci? dev ? function ?	# NE2000-compatible Ethernet
@@ -242,12 +241,6 @@ siop*	at pci? dev ? function ?	# NCR 53c
 trm*	at pci? dev ? function ?	# Tekram DC-395U/UW/F, DC-315/U SCSI
 
 # Display devices
-# ofb*	at pci? dev ? function ?	# Generic Open Firmware Framebuffer
-#options 	OFB_FAKE_VGA_FB		# Allow X to mmap VGA regs
-# 
-# ofb is considered obsolete and machine-independent genfb should be used
-# instead.
-
 chipsfb*	at pci?	function ?	# C 65550
 gffb*		at pci?	function ?	# NVIDIA GeForce2 MX
 machfb*		at pci? function ?	# ATI Mach 64, Rage, Rage Pro
@@ -258,7 +251,6 @@ voodoofb*	at pci? function ?	# 3Dfx Vood
 
 # ATI Radeon. Still has problems on some hardware
 radeonfb*	at pci? function ?
-options 	RADEONFB_ALWAYS_ACCEL_PUTCHAR
 
 # generic PCI framebuffer, should work with everything supported by OF
 genfb*		at pci? function ?
@@ -332,18 +324,7 @@ nvram*	at obio?			# nvram
 options OBIO_SPEED_CONTROL		# CPU speed / voltage control via GPIOs
 	# and/or DFS, found on most *Book G4
 
-
-# the traditional ADB subsystem
-
-#adb*	at obio?			# Apple Desktop Bus
-#apm0	at adb?# APM emulation
-#aed*	at adb?# ADB Event Device
-#akbd*	at adb?# ADB keyboard
-#ams*	at adb?# ADB mouse
-#abtn*	at adb?
-
-# the new, improved ADB subsystem
-
+# ADB subsystem
 cuda*	at obio?		# CUDA, for Old World PowerMacs
 iic* 		at cuda?	# CUDA's IIC bus
 



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

2023-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 26 00:15:48 UTC 2023

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

Log Message:
do some cleanup
the gm driver has been commented out for 20 years, time to remove it
while there, remove ofb and the old ADB code which have been commented out
since 2007


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/sys/arch/macppc/conf/GENERIC

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



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

2023-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 12 01:19:21 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
don't attach on cascaded mpics for now - we don't really use them for anything
yet and apparently setup causes problems elsewhere, which needs investigation


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.14
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13	Wed Dec 28 06:50:23 2022
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Thu Jan 12 01:19:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $	*/
+/*	$NetBSD: pic_u3_ht.c,v 1.14 2023/01/12 01:19:21 macallan Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.14 2023/01/12 01:19:21 macallan Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"
@@ -138,8 +138,10 @@ int init_u3_ht(void)
 
 	u4 = OF_finddevice("/u4");
 	if (u4 == -1) {
+#ifdef U3HT_CASCADE
 		u4 = OF_finddevice("/u3");
 		if (u4 == -1)
+#endif
 			return FALSE;
 	}
 



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

2023-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 12 01:19:21 UTC 2023

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
don't attach on cascaded mpics for now - we don't really use them for anything
yet and apparently setup causes problems elsewhere, which needs investigation


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:50:23 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
support cascading:
- attach on both /u3 and /u4
- install IPI handling only if we're primary
- link to primary PIC if we're cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc/pic_u3_ht.c
diff -u src/sys/arch/macppc/macppc/pic_u3_ht.c:1.12 src/sys/arch/macppc/macppc/pic_u3_ht.c:1.13
--- src/sys/arch/macppc/macppc/pic_u3_ht.c:1.12	Sat Mar  6 07:29:05 2021
+++ src/sys/arch/macppc/macppc/pic_u3_ht.c	Wed Dec 28 06:50:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $	*/
+/*	$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $	*/
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.12 2021/03/06 07:29:05 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.13 2022/12/28 06:50:23 macallan Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"
@@ -79,7 +79,7 @@ struct u3_ht_ops {
 #define u3_ht_read(ptr,reg)		(ptr)->ht_read(ptr, reg)
 #define u3_ht_write(ptr,reg,val)	(ptr)->ht_write(ptr, reg, val)
 
-static struct u3_ht_ops *setup_u3_ht(uint32_t, uint32_t, int);
+static struct u3_ht_ops *setup_u3_ht(uint32_t, uint32_t, int, int);
 static int setup_u3_ht_workarounds(struct u3_ht_ops *);
 
 static void u3_ht_enable_irq(struct pic_ops *, int, int);
@@ -130,15 +130,18 @@ static void u3_ht_establish_ipi(int, int
 
 int init_u3_ht(void)
 {
-	int u4, pic;
+	int u4, pic, irq = -1;
 	uint32_t reg[2];
 	uint32_t base, len, tmp;
 	int bigendian;
 	volatile uint8_t *unin_reg;
 
 	u4 = OF_finddevice("/u4");
-	if (u4 == -1)
-		return FALSE;
+	if (u4 == -1) {
+		u4 = OF_finddevice("/u3");
+		if (u4 == -1)
+			return FALSE;
+	}
 
 	if (! of_compatible(u4, u3_compat))
 		return FALSE;
@@ -173,15 +176,21 @@ int init_u3_ht(void)
 	base = reg[0];
 	len = reg[1];
 
-	aprint_normal("found U3/U4 HT PIC at %08x\n", base);
+	if (OF_getprop(pic, "interrupts", reg, 8) > 4) {
+		/* this is a cascaded PIC */
+		irq = reg[0];
+		aprint_normal("found cascaded U3/U4 HT PIC at %08x, IRQ %d\n",
+		base, irq);
+	} else
+		aprint_normal("found U3/U4 HT PIC at %08x\n", base);
 
-	setup_u3_ht(base, len, bigendian);
+	setup_u3_ht(base, len, bigendian, irq);
 
 	return TRUE;
 }
 
 static struct u3_ht_ops *
-setup_u3_ht(uint32_t addr, uint32_t len, int bigendian)
+setup_u3_ht(uint32_t addr, uint32_t len, int bigendian, int cirq)
 {
 	struct u3_ht_ops *u3_ht;
 	struct pic_ops *pic;
@@ -264,16 +273,24 @@ setup_u3_ht(uint32_t addr, uint32_t len,
 		u3_ht_eoi(u3_ht, 0);
 	}
 
+	if (cirq > -1) {
+		/* we're subordinate to a normal openpic */
+		intr_establish_xname(cirq, IST_EDGE, IPL_HIGH,
+		pic_handle_intr, pic, "u3_ht");
+	}
 #ifdef MULTIPROCESSOR
-	ipiops.ppc_send_ipi = u3_ht_send_ipi;
-	ipiops.ppc_establish_ipi = u3_ht_establish_ipi;
-	ipiops.ppc_ipi_vector = IPI_VECTOR;
-
-	x = u3_ht_read(u3_ht, OPENPIC_IPI_VECTOR(1));
-	x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
-	x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
-	u3_ht_write(u3_ht, OPENPIC_IPI_VECTOR(1), x);
-	u3ht0 = u3_ht;
+	else {
+		/* only handle IPIs if we're the only openpic */
+		ipiops.ppc_send_ipi = u3_ht_send_ipi;
+		ipiops.ppc_establish_ipi = u3_ht_establish_ipi;
+		ipiops.ppc_ipi_vector = IPI_VECTOR;
+
+		x = u3_ht_read(u3_ht, OPENPIC_IPI_VECTOR(1));
+		x &= ~(OPENPIC_IMASK | OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK);
+		x |= (15 << OPENPIC_PRIORITY_SHIFT) | ipiops.ppc_ipi_vector;
+		u3_ht_write(u3_ht, OPENPIC_IPI_VECTOR(1), x);
+		u3ht0 = u3_ht;
+	}
 #endif /* MULTIPROCESSOR */
 
 	return u3_ht;



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

2022-12-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 06:50:23 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: pic_u3_ht.c

Log Message:
support cascading:
- attach on both /u3 and /u4
- install IPI handling only if we're primary
- link to primary PIC if we're cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/macppc/macppc/pic_u3_ht.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/macppc

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

Modified Files:
src/sys/arch/macppc/macppc: interrupts.c

Log Message:
first step towards MSI support on G5:
- allow both openpic and u3_ht to attach
- make sure openpic comes first, if we have both then u3_ht is cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/interrupts.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/macppc/interrupts.c
diff -u src/sys/arch/macppc/macppc/interrupts.c:1.8 src/sys/arch/macppc/macppc/interrupts.c:1.9
--- src/sys/arch/macppc/macppc/interrupts.c:1.8	Tue Jan 26 14:49:41 2021
+++ src/sys/arch/macppc/macppc/interrupts.c	Wed Dec 28 06:00:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $ */
+/*	$NetBSD: interrupts.c,v 1.9 2022/12/28 06:00:26 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.9 2022/12/28 06:00:26 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -108,9 +108,25 @@ init_openpic(int pass_through)
 
 #endif /* NPIC_OPENPIC > 0 */
 
+/*
+ * look for supported interrupt controllers
+ * there are several possible cases:
+ * - Ohare and Grand Central models have the same interrupt controller, Ohare
+ *   can have a 2nd cascaded one ( Powerbook 3400c with ethernet for example )
+ * - Heathrow is more or less Ohare with all the registers doubled to allow 64
+ *   IRQs
+ * - openpic covers all OpenPICs built into various mac-io found in some G3,
+ *   all G4 and most G5 models
+ * - u3_ht is an OpenPIC built into the CPC 9x5 bridges / memory controllers
+ *   found in G5s, it's got enough quirks to require its own driver. Some
+ *   models have both openpic and u3_ht, on those openpic handles IPIs and
+ *   normal IRQs while the u3_ht is cascaded and can be used for MSI. On G5s
+ *   that have no openpic the u3_ht handles all interrupts, IPIs and MSI
+ */
 void
 init_interrupt(void)
 {
+	int ok = 0;
 
 	pic_init();
 #if NPIC_OHARE > 0
@@ -121,20 +137,23 @@ init_interrupt(void)
 	if (init_heathrow())
 		goto done;
 #endif
-#if NPIC_U3_HT > 0
-	if (init_u3_ht())
-		goto done;
-#endif
 #if NPIC_OPENPIC > 0
 	if (init_openpic(0)) {
 #ifdef MULTIPROCESSOR
 		setup_openpic_ipi();
 #endif
-		goto done;
+		ok = 1;
 	}
 #endif
-	panic("%s: no supported interrupt controller found", __func__);
+#if NPIC_U3_HT > 0
+	if (init_u3_ht())
+		ok = 1;
+#endif
+	if (ok == 0)
+	panic("%s: no supported interrupt controller found", __func__);
+#if NPIC_OHARE + NPIC_HEATHROW > 0
 done:
+#endif
 	oea_install_extint(pic_ext_intr);
 
 #ifdef MULTIPROCESSOR



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

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

Modified Files:
src/sys/arch/macppc/macppc: interrupts.c

Log Message:
first step towards MSI support on G5:
- allow both openpic and u3_ht to attach
- make sure openpic comes first, if we have both then u3_ht is cascaded


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/macppc/interrupts.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/macppc

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:16:05 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
add comment to explain why we zero SPRG0 here
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/macppc/macppc/locore.S

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

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:16:05 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
add comment to explain why we zero SPRG0 here
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/macppc/macppc/locore.S

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/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.81 src/sys/arch/macppc/macppc/locore.S:1.82
--- src/sys/arch/macppc/macppc/locore.S:1.81	Sun Dec 18 01:10:57 2022
+++ src/sys/arch/macppc/macppc/locore.S	Sun Dec 18 01:16:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.81 2022/12/18 01:10:57 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.82 2022/12/18 01:16:05 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,6 +92,11 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+/* 
+ * Zero SPRG0 so we can catch usage of curcpu(), which just returns SPRG0,
+ * before it is set up properly. Console output uses locks now, which need
+ * working curcpu(), and macppc sets up its console *very* early.
+ */
 #ifdef DEBUG
 	li	%r0,0
 	mtsprg0	%r0



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

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:10:58 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
#ifdef DEBUG the previous change, it seems to cause trouble on qemu which
needs further investigation


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/macppc/macppc/locore.S

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/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.80 src/sys/arch/macppc/macppc/locore.S:1.81
--- src/sys/arch/macppc/macppc/locore.S:1.80	Wed Dec 14 13:04:24 2022
+++ src/sys/arch/macppc/macppc/locore.S	Sun Dec 18 01:10:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.80 2022/12/14 13:04:24 macallan Exp $	*/
+/*	$NetBSD: locore.S,v 1.81 2022/12/18 01:10:57 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,8 +92,10 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+#ifdef DEBUG
 	li	%r0,0
 	mtsprg0	%r0
+#endif
 
 	bl	_C_LABEL(ofwinit)		/* init OF */
 



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

2022-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Dec 18 01:10:58 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
#ifdef DEBUG the previous change, it seems to cause trouble on qemu which
needs further investigation


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/macppc/macppc/locore.S

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

2022-12-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 14 13:04:24 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Explicitly zero SPRG0 before doing anything else - it's used to store a pointer
to struct cpuinfo, this way we can catch attempts to use it before it's set
up properly


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/macppc/macppc/locore.S

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

2022-12-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 14 13:04:24 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: locore.S

Log Message:
Explicitly zero SPRG0 before doing anything else - it's used to store a pointer
to struct cpuinfo, this way we can catch attempts to use it before it's set
up properly


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/macppc/macppc/locore.S

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/macppc/locore.S
diff -u src/sys/arch/macppc/macppc/locore.S:1.79 src/sys/arch/macppc/macppc/locore.S:1.80
--- src/sys/arch/macppc/macppc/locore.S:1.79	Fri Feb 26 02:18:56 2021
+++ src/sys/arch/macppc/macppc/locore.S	Wed Dec 14 13:04:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.79 2021/02/26 02:18:56 thorpej Exp $	*/
+/*	$NetBSD: locore.S,v 1.80 2022/12/14 13:04:24 macallan Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -92,6 +92,9 @@ __start:
 	mr	%r13,%r6
 	mr	%r14,%r7
 
+	li	%r0,0
+	mtsprg0	%r0
+
 	bl	_C_LABEL(ofwinit)		/* init OF */
 
 	li	%r0,0



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

2022-08-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 13 09:34:47 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: disksubr.c

Log Message:
Do not try to create a fake MBR disklabel from the PMBR of a GPT disk.


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

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

Modified files:

Index: src/sys/arch/macppc/macppc/disksubr.c
diff -u src/sys/arch/macppc/macppc/disksubr.c:1.49 src/sys/arch/macppc/macppc/disksubr.c:1.50
--- src/sys/arch/macppc/macppc/disksubr.c:1.49	Fri Mar 14 21:59:41 2014
+++ src/sys/arch/macppc/macppc/disksubr.c	Sat Aug 13 09:34:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.49 2014/03/14 21:59:41 mrg Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.50 2022/08/13 09:34:47 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.49 2014/03/14 21:59:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.50 2022/08/13 09:34:47 martin Exp $");
 
 #include 
 #include 
@@ -497,6 +497,8 @@ read_dos_label(dev_t dev, void (*strat)(
 	bsdp = NULL;
 	for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
 		switch (dp->mbrp_type) {
+		case MBR_PTYPE_PMBR:
+			goto done;	/* do not fake anything for GPT disks */
 		case MBR_PTYPE_NETBSD:
 			bsdp = dp;
 			break;



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

2022-08-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug 13 09:34:47 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: disksubr.c

Log Message:
Do not try to create a fake MBR disklabel from the PMBR of a GPT disk.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/macppc/macppc/disksubr.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/conf

2022-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 17 10:01:18 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: std.macppc

Log Message:
std.macppc: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/macppc/conf/std.macppc

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/conf/std.macppc
diff -u src/sys/arch/macppc/conf/std.macppc:1.26 src/sys/arch/macppc/conf/std.macppc:1.27
--- src/sys/arch/macppc/conf/std.macppc:1.26	Thu Jul 14 11:10:02 2022
+++ src/sys/arch/macppc/conf/std.macppc	Sun Jul 17 10:01:18 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: std.macppc,v 1.26 2022/07/14 11:10:02 macallan Exp $
+#	$NetBSD: std.macppc,v 1.27 2022/07/17 10:01:18 riastradh Exp $
 #
 # Standard/required options for NetBSD/macppc.
 
@@ -22,7 +22,7 @@ options 	INTSTK=0x2000
 # pose as a USB keyboard
 options 	ADBKBD_EMUL_USB
 
-# default to console switching using Command-Fn, for tradition 
+# default to console switching using Command-Fn, for tradition
 options 	ADBKBD_LAYOUT="(KB_US | KB_APPLE)"
 options 	UKBD_LAYOUT="(KB_US | KB_APPLE)"
 



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

2022-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 17 10:01:18 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: std.macppc

Log Message:
std.macppc: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/macppc/conf/std.macppc

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

2022-07-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul 14 11:10:02 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: std.macppc std.macppc.g5

Log Message:
default to apple layout for both adb and usb keyboards


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/conf/std.macppc
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/conf/std.macppc.g5

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/conf/std.macppc
diff -u src/sys/arch/macppc/conf/std.macppc:1.25 src/sys/arch/macppc/conf/std.macppc:1.26
--- src/sys/arch/macppc/conf/std.macppc:1.25	Sat Aug 29 23:00:10 2020
+++ src/sys/arch/macppc/conf/std.macppc	Thu Jul 14 11:10:02 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: std.macppc,v 1.25 2020/08/29 23:00:10 macallan Exp $
+#	$NetBSD: std.macppc,v 1.26 2022/07/14 11:10:02 macallan Exp $
 #
 # Standard/required options for NetBSD/macppc.
 
@@ -21,7 +21,10 @@ options 	INTSTK=0x2000
 # HID devices - for them to coexist on the same mux we tell the adbkbd driver
 # pose as a USB keyboard
 options 	ADBKBD_EMUL_USB
-options 	UKBD_LAYOUT="(KB_US | KB_APPLE)"  # for ukbd driver
+
+# default to console switching using Command-Fn, for tradition 
+options 	ADBKBD_LAYOUT="(KB_US | KB_APPLE)"
+options 	UKBD_LAYOUT="(KB_US | KB_APPLE)"
 
 # Atheros HAL options
 include "external/isc/atheros_hal/conf/std.ath_hal"

Index: src/sys/arch/macppc/conf/std.macppc.g5
diff -u src/sys/arch/macppc/conf/std.macppc.g5:1.3 src/sys/arch/macppc/conf/std.macppc.g5:1.4
--- src/sys/arch/macppc/conf/std.macppc.g5:1.3	Thu Dec 11 05:42:18 2008
+++ src/sys/arch/macppc/conf/std.macppc.g5	Thu Jul 14 11:10:02 2022
@@ -16,5 +16,7 @@ options 	EXEC_SCRIPT	# shell script supp
 
 options 	INTSTK=0x2000
 
+options 	UKBD_LAYOUT="(KB_US | KB_APPLE)"
+
 # Atheros HAL options
 include "external/isc/atheros_hal/conf/std.ath_hal"



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

2022-07-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jul 14 11:10:02 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: std.macppc std.macppc.g5

Log Message:
default to apple layout for both adb and usb keyboards


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/conf/std.macppc
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/conf/std.macppc.g5

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/stand/ofwboot

2022-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 10 14:18:27 UTC 2022

Modified Files:
src/sys/arch/macppc/stand/ofwboot: loadfile_machdep.c

Log Message:
Fix order of hi / lo halves in the ofw_address_cells == 2 case.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.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/stand/ofwboot

2022-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 10 14:18:27 UTC 2022

Modified Files:
src/sys/arch/macppc/stand/ofwboot: loadfile_machdep.c

Log Message:
Fix order of hi / lo halves in the ofw_address_cells == 2 case.


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

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

Modified files:

Index: src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.c
diff -u src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.c:1.1 src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.c:1.2
--- src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.c:1.1	Sun Feb 28 20:27:40 2021
+++ src/sys/arch/macppc/stand/ofwboot/loadfile_machdep.c	Sun Jul 10 14:18:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: loadfile_machdep.c,v 1.1 2021/02/28 20:27:40 thorpej Exp $	*/
+/*	$NetBSD: loadfile_machdep.c,v 1.2 2022/07/10 14:18:27 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -56,14 +56,13 @@ ofw_claimphys(paddr_t pa, vsize_t size)
 	paddr_t result;
 
 	if (ofw_address_cells == 2) {
-		/* order of cells is phys.lo ... phys.hi */
-		*p++ = (uint32_t)pa;
 		*p++ = ((uint64_t)pa) >> 32;
+		*p++ = (uint32_t)pa;
 	} else {
 		*p++ = (uint32_t)pa;
 	}
 
-#if 0	/* No known Mac systems with 2, and spec is ambiguous about order. */
+#if 0	/* No known Mac systems with 2. */
 	if (ofw_size_cells == 2) {
 		*p++ = ((uint64_t)size) >> 32;
 		*p++ = (uint32_t)size;
@@ -80,10 +79,9 @@ ofw_claimphys(paddr_t pa, vsize_t size)
 	}
 
 	if (ofw_address_cells == 2) {
-		/* order of cells is base.lo ... base.hi */
 		uint64_t v;
-		v = *p++;
-		v |= (uint64_t)(*p++) << 32;
+		v = (uint64_t)(*p++) << 32;
+		v |= *p++;
 		result = (paddr_t)v;
 	} else {
 		result = *p++;
@@ -106,14 +104,13 @@ ofw_releasephys(paddr_t pa, vsize_t size
 	uint32_t *p = cells;
 
 	if (ofw_address_cells == 2) {
-		/* order of cells is phys.lo ... phys.hi */
-		*p++ = (uint32_t)pa;
 		*p++ = ((uint64_t)pa) >> 32;
+		*p++ = (uint32_t)pa;
 	} else {
 		*p++ = (uint32_t)pa;
 	}
 
-#if 0	/* No known Mac systems with 2, and spec is ambiguous about order. */
+#if 0	/* No known Mac systems with 2. */
 	if (ofw_size_cells == 2) {
 		*p++ = ((uint64_t)size) >> 32;
 		*p++ = (uint32_t)size;
@@ -184,9 +181,8 @@ ofw_map(vaddr_t va, paddr_t pa, vsize_t 
 	uint32_t *p = cells;
 
 	if (ofw_address_cells == 2) {
-		/* order of cells is phys.lo ... phys.hi */
-		*p++ = (uint32_t)pa;
 		*p++ = ((uint64_t)pa) >> 32;
+		*p++ = (uint32_t)pa;
 	} else {
 		*p++ = (uint32_t)pa;
 	}



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

2022-06-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 26 09:23:32 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
cpu_reboot: use cpu_halt_others() instead of a (simple) open coded
version of it.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/macppc/macppc/machdep.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/macppc

2022-06-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 26 09:23:32 UTC 2022

Modified Files:
src/sys/arch/macppc/macppc: machdep.c

Log Message:
cpu_reboot: use cpu_halt_others() instead of a (simple) open coded
version of it.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/arch/macppc/macppc/machdep.c

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

Modified files:

Index: src/sys/arch/macppc/macppc/machdep.c
diff -u src/sys/arch/macppc/macppc/machdep.c:1.174 src/sys/arch/macppc/macppc/machdep.c:1.175
--- src/sys/arch/macppc/macppc/machdep.c:1.174	Wed Mar 10 19:45:41 2021
+++ src/sys/arch/macppc/macppc/machdep.c	Sun Jun 26 09:23:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.174 2021/03/10 19:45:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175 2022/06/26 09:23:32 martin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -233,7 +233,7 @@ cpu_reboot(int howto, char *what)
 
 #ifdef MULTIPROCESSOR
 	/* Halt other CPU */
-	cpu_send_ipi(IPI_DST_NOTME, IPI_HALT);
+	cpu_halt_others();
 	delay(10);	/* XXX */
 #endif
 



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

2022-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jun 19 04:47:12 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
we also need WSDISPLAY_COMPAT_PCVT and _SYSCONS


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

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

2022-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jun 19 04:47:12 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
we also need WSDISPLAY_COMPAT_PCVT and _SYSCONS


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

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/conf/POWERMAC_G5
diff -u src/sys/arch/macppc/conf/POWERMAC_G5:1.53 src/sys/arch/macppc/conf/POWERMAC_G5:1.54
--- src/sys/arch/macppc/conf/POWERMAC_G5:1.53	Wed Jun 15 18:19:42 2022
+++ src/sys/arch/macppc/conf/POWERMAC_G5	Sun Jun 19 04:47:12 2022
@@ -102,6 +102,8 @@ options 	INET6		# IPV6
 # wscons options
 #options 	WSEMUL_SUN			# sun terminal emulation
 options 	WSEMUL_VT100			# VT100 / VT220 emulation
+options 	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls
+options 	WSDISPLAY_COMPAT_SYSCONS	# emulate some ioctls
 options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
 #options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
 options 	WS_DEFAULT_FG=WSCOL_BLACK



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

2022-06-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 15 18:19:42 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
uncomment WSDISPLAY_COMPAT_USL
while there, add obiofan


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

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/conf/POWERMAC_G5
diff -u src/sys/arch/macppc/conf/POWERMAC_G5:1.52 src/sys/arch/macppc/conf/POWERMAC_G5:1.53
--- src/sys/arch/macppc/conf/POWERMAC_G5:1.52	Sun May 22 13:20:44 2022
+++ src/sys/arch/macppc/conf/POWERMAC_G5	Wed Jun 15 18:19:42 2022
@@ -102,7 +102,7 @@ options 	INET6		# IPV6
 # wscons options
 #options 	WSEMUL_SUN			# sun terminal emulation
 options 	WSEMUL_VT100			# VT100 / VT220 emulation
-#options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
+options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
 #options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
 options 	WS_DEFAULT_FG=WSCOL_BLACK
 options 	WS_DEFAULT_BG=WSCOL_LIGHT_WHITE
@@ -157,6 +157,8 @@ fcu* 		at iic?
 smusat* 	at iic?
 deq* 		at iic?
 
+obiofan* 	at obio?	# PSU fan on PowerMac7,3
+
 pmu* 		at obio?	# Apple PMU
 
 # Audio support



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

2022-06-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 15 18:19:42 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
uncomment WSDISPLAY_COMPAT_USL
while there, add obiofan


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

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

2022-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 22 13:20:44 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5 POWERMAC_G5_11_2

Log Message:
Sync pseudo devs crypto and swcrypto with GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/conf/POWERMAC_G5
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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/conf/POWERMAC_G5
diff -u src/sys/arch/macppc/conf/POWERMAC_G5:1.51 src/sys/arch/macppc/conf/POWERMAC_G5:1.52
--- src/sys/arch/macppc/conf/POWERMAC_G5:1.51	Tue Feb 22 17:03:48 2022
+++ src/sys/arch/macppc/conf/POWERMAC_G5	Sun May 22 13:20:44 2022
@@ -226,8 +226,8 @@ sd*	at atapibus? drive ? flags 0x	# 
 uk*	at atapibus? drive ? flags 0x	# ATAPI unknown
 
 
-#pseudo-device 	crypto			# opencrypto framework
-	# (disabled, requires generic softints)
+pseudo-device 	crypto			# /dev/crypto device
+pseudo-device	swcrypto		# software crypto implementation
 pseudo-device	vnd			# disk-like interface to files
 #pseudo-device	md			# memory disk device
 pseudo-device	loop			# network loopback

Index: src/sys/arch/macppc/conf/POWERMAC_G5_11_2
diff -u src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.20 src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.21
--- src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.20	Tue Jul  7 02:39:59 2020
+++ src/sys/arch/macppc/conf/POWERMAC_G5_11_2	Sun May 22 13:20:44 2022
@@ -182,8 +182,8 @@ cd*	at atapibus? drive ? flags 0x	# 
 sd*	at atapibus? drive ? flags 0x	# ATAPI disk drives
 uk*	at atapibus? drive ? flags 0x	# ATAPI unknown
 
-#pseudo-device 	crypto			# opencrypto framework
-	# (disabled, requires generic softints)
+pseudo-device 	crypto			# /dev/crypto device
+pseudo-device	swcrypto		# software crypto implementation
 pseudo-device	vnd		4	# disk-like interface to files
 pseudo-device	md			# memory disk device
 pseudo-device	loop			# network loopback



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

2022-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 22 13:20:44 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5 POWERMAC_G5_11_2

Log Message:
Sync pseudo devs crypto and swcrypto with GENERIC


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/macppc/conf/POWERMAC_G5
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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

2022-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 22 17:03:48 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
Incllude POWERMAC_G5.local if it exists


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/macppc/conf/POWERMAC_G5

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/conf/POWERMAC_G5
diff -u src/sys/arch/macppc/conf/POWERMAC_G5:1.50 src/sys/arch/macppc/conf/POWERMAC_G5:1.51
--- src/sys/arch/macppc/conf/POWERMAC_G5:1.50	Sun Dec 26 16:08:20 2021
+++ src/sys/arch/macppc/conf/POWERMAC_G5	Tue Feb 22 17:03:48 2022
@@ -245,3 +245,5 @@ pseudo-device	bpfilter		# packet filter
 #options 	MEMORY_DISK_IS_ROOT		# Force root on ram-disk
 #options 	MEMORY_DISK_ROOT_SIZE=4096	# 2 Megabytes
 #options 	MEMORY_DISK_RBFLAGS=RB_SINGLE	# boot in single-user mode
+
+cinclude	"arch/macppc/conf/POWERMAC_G5.local"



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

2022-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 22 17:03:48 UTC 2022

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5

Log Message:
Incllude POWERMAC_G5.local if it exists


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/macppc/conf/POWERMAC_G5

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

2022-02-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 16 23:20:38 UTC 2022

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

Log Message:
macppc: Support *macppc* GENERIC.local, not evbarm GENERIC64.local.

Managed to fumble with a copypasta error of local commits, and
committed the one that didn't work instead of the one that did.


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.373 src/sys/arch/macppc/conf/GENERIC:1.374
--- src/sys/arch/macppc/conf/GENERIC:1.373	Wed Feb 16 20:14:40 2022
+++ src/sys/arch/macppc/conf/GENERIC	Wed Feb 16 23:20:38 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.373 2022/02/16 20:14:40 riastradh Exp $
+# $NetBSD: GENERIC,v 1.374 2022/02/16 23:20:38 riastradh Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.373 $"
+#ident 		"GENERIC-$Revision: 1.374 $"
 
 maxusers	32
 
@@ -570,4 +570,4 @@ include "dev/veriexec.config"
 #options PAX_MPROTECT=0			# PaX mprotect(2) restrictions
 
 # Pull in optional local configuration
-cinclude "arch/evbarm/conf/GENERIC64.local"
+cinclude "arch/macppc/conf/GENERIC.local"



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

2022-02-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 16 23:20:38 UTC 2022

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

Log Message:
macppc: Support *macppc* GENERIC.local, not evbarm GENERIC64.local.

Managed to fumble with a copypasta error of local commits, and
committed the one that didn't work instead of the one that did.


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/macppc/conf/GENERIC

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



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

2022-02-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 16 20:14:41 UTC 2022

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

Log Message:
macppc: Support GENERIC.local.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.372 src/sys/arch/macppc/conf/GENERIC:1.373
--- src/sys/arch/macppc/conf/GENERIC:1.372	Thu Jan 21 06:51:55 2021
+++ src/sys/arch/macppc/conf/GENERIC	Wed Feb 16 20:14:40 2022
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.372 2021/01/21 06:51:55 nia Exp $
+# $NetBSD: GENERIC,v 1.373 2022/02/16 20:14:40 riastradh Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.372 $"
+#ident 		"GENERIC-$Revision: 1.373 $"
 
 maxusers	32
 
@@ -568,3 +568,6 @@ pseudo-device   drvctl
 include "dev/veriexec.config"
 
 #options PAX_MPROTECT=0			# PaX mprotect(2) restrictions
+
+# Pull in optional local configuration
+cinclude "arch/evbarm/conf/GENERIC64.local"



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

2022-02-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 16 20:14:41 UTC 2022

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

Log Message:
macppc: Support GENERIC.local.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/sys/arch/macppc/conf/GENERIC

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



CVS commit: src/sys/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

2021-09-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep 10 23:32:17 UTC 2021

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

Log Message:
this driver allows to read the speeds of fans controlled via mac-io/fans/*
found in some G5, for example my 7,3
based on guesswork and observation


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 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/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.122 src/sys/arch/macppc/conf/files.macppc:1.123
--- src/sys/arch/macppc/conf/files.macppc:1.122	Fri Sep  3 17:18:39 2021
+++ src/sys/arch/macppc/conf/files.macppc	Fri Sep 10 23:32:17 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.122 2021/09/03 17:18:39 macallan Exp $
+#	$NetBSD: files.macppc,v 1.123 2021/09/10 23:32:17 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -335,3 +335,10 @@ defflag opt_lmu.h LMU_DEBUG
 device	fcu: sysmon_envsys, fancontrol
 attach	fcu at iic
 file	arch/macppc/dev/fcu.cfcu	needs-flag
+
+# fan control bits found in obio's space on some G5
+device 	obiofan: sysmon_envsys
+attach 	obiofan at obio
+file 	arch/macppc/dev/obiofan.c			obiofan
+defflag opt_obiofan.h OBIOFAN_DEBUG
+

Added files:

Index: src/sys/arch/macppc/dev/obiofan.c
diff -u /dev/null src/sys/arch/macppc/dev/obiofan.c:1.1
--- /dev/null	Fri Sep 10 23:32:17 2021
+++ src/sys/arch/macppc/dev/obiofan.c	Fri Sep 10 23:32:17 2021
@@ -0,0 +1,176 @@
+/*	$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	*/
+
+/*-
+ * Copyright (c) 2006 Michael Lorenz
+ * 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 "opt_obiofan.h"
+
+#ifdef OBIOFAN_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
+struct obiofan_softc {
+	device_t sc_dev;
+	struct sysmon_envsys	*sc_sme;
+	envsys_data_t		sc_sensors[4];
+	callout_t		sc_callout;
+	time_t			sc_stamp;
+	int 			sc_node;
+	int 			sc_reg, sc_shift;
+	int			sc_count, sc_rpm;
+};
+
+int obiofan_match(device_t, cfdata_t, void *);
+void obiofan_attach(device_t, device_t, void *);
+static void obiofan_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void obiofan_update(void *);
+
+CFATTACH_DECL_NEW(obiofan, sizeof(struct obiofan_softc), obiofan_match,
+	obiofan_attach, NULL, NULL);
+
+int
+obiofan_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct confargs *ca = aux;
+
+	if (strcmp(ca->ca_name, "fans") == 0)
+		return 1;
+
+	return 0;
+}
+
+void
+obiofan_attach(device_t parent, device_t self, void *aux)
+{
+	struct obiofan_softc *sc = device_private(self);
+	struct confargs *ca = aux;
+	char descr[32] = "fan";
+	int node = ca->ca_node, tc_node;
+	int regs[8], tc_regs[32];
+
+	printf("\n");
+
+	if (OF_getprop(node, "reg", regs, sizeof(regs)) <= 0)
+		return;
+
+	sc->sc_node = node;
+
+#ifdef OBIOFAN_DEBUG
+	int i;
+	for (i = 0; i < 7; i += 2)
+		printf("%02x: %08x\n", regs[i], obio_read_4(regs[i]));
+#endif
+
+	tc_node = OF_parent(node);
+
+	if (OF_getprop(tc_node, "platform-do-getTACHCount", tc_regs, 32) <= 0) {
+		aprint_error("no platform-do-getTACHCount\n");
+		return;
+	}
+
+	/*
+	 * XXX this is guesswork based on poking around & observation
+	 *
+	 * the parameter format seems to be:
+	 * reg[0] - node number for the fan, 

CVS commit: src/sys/arch/macppc

2021-09-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep 10 23:32:17 UTC 2021

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

Log Message:
this driver allows to read the speeds of fans controlled via mac-io/fans/*
found in some G5, for example my 7,3
based on guesswork and observation


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 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

2021-09-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep  3 17:18:40 UTC 2021

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

Log Message:
switch smu to common fan control code


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r1.14 -r1.15 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/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.121 src/sys/arch/macppc/conf/files.macppc:1.122
--- src/sys/arch/macppc/conf/files.macppc:1.121	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/conf/files.macppc	Fri Sep  3 17:18:39 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.121 2021/07/27 23:38:42 macallan Exp $
+#	$NetBSD: files.macppc,v 1.122 2021/09/03 17:18:39 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -180,7 +180,7 @@ define fancontrol
 file arch/macppc/dev/fancontrol.c		fancontrol
 defflag	opt_fancontrol.h	FANCONTROL_DEBUG
 
-device smu { } : fancontrol
+device smu { } : sysmon_envsys, fancontrol
 attach smu at mainbus
 file arch/macppc/dev/smu.c			smu needs-flag
 defflag	opt_smu.h	SMU_DEBUG

Index: src/sys/arch/macppc/dev/smu.c
diff -u src/sys/arch/macppc/dev/smu.c:1.14 src/sys/arch/macppc/dev/smu.c:1.15
--- src/sys/arch/macppc/dev/smu.c:1.14	Sat Aug  7 16:18:58 2021
+++ src/sys/arch/macppc/dev/smu.c	Fri Sep  3 17:18:40 2021
@@ -46,6 +46,7 @@
 
 #include 
 #include 
+#include 
 
 #include "opt_smu.h"
 
@@ -67,7 +68,9 @@ struct smu_fan {
 	int min_rpm;
 	int max_rpm;
 	int default_rpm;
+	int wanted_rpm;
 	int current_rpm;
+	int fault;
 	time_t last_update;
 };
 
@@ -82,19 +85,11 @@ struct smu_iicbus {
 #define SMU_MAX_IICBUS		3
 #define SMU_MAX_SME_SENSORS	(SMU_MAX_FANS + 8)
 
-struct smu_zone {
-	bool (*filter)(const envsys_data_t *);
-	int nfans;
-	int fans[SMU_MAX_FANS];
-	int threshold, step;
-	int duty;
-};
-
 
-#define SMU_ZONE_CPUS	0
-#define SMU_ZONE_DRIVES	1
-#define SMU_ZONE_SLOTS	2
-#define SMU_ZONES	3
+#define SMU_ZONE_CPU		0
+#define SMU_ZONE_CASE		1
+#define SMU_ZONE_DRIVEBAY	2
+#define SMU_ZONES		3
 
 #define C_TO_uK(n) (n * 100 + 27315)
 
@@ -123,7 +118,7 @@ struct smu_softc {
 	uint32_t cpu_m;
 	int32_t  cpu_b;
 
-	struct smu_zone sc_zones[SMU_ZONES];
+	fancontrol_zone_t sc_zones[SMU_ZONES];
 	lwp_t *sc_thread;
 	bool sc_dying;
 };
@@ -165,20 +160,19 @@ static int smu_dbell_gpio_intr(void *);
 static int smu_todr_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
 static int smu_todr_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
 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);
 
 static void smu_setup_zones(struct smu_softc *);
-static void smu_adjust_zone(struct smu_softc *, int);
 static void smu_adjust(void *);
+
 static bool is_cpu_sensor(const envsys_data_t *);
 static bool is_drive_sensor(const envsys_data_t *);
 static bool is_slots_sensor(const envsys_data_t *);
+static int smu_fan_get_rpm(void *, int);
+static int smu_fan_set_rpm(void *, int, int);
 
 int smu_get_datablock(int, uint8_t *, size_t);
 
@@ -299,9 +293,8 @@ static void
 smu_setup_fans(struct smu_softc *sc)
 {
 	struct smu_fan *fan;
-	struct sysctlnode *sysctl_fans, *sysctl_fan, *sysctl_node;
-	char type[32], sysctl_fan_name[32];
-	int node, i, j;
+	char type[32];
+	int node, i;
 	const char *fans[] = { "fans", "rpm-fans", 0 };
 	int n = 0;
 	
@@ -349,6 +342,8 @@ smu_setup_fans(struct smu_softc *sc)
 			fan->location, fan->reg, fan->zone, fan->rpm_ctl,
 			fan->min_rpm, fan->max_rpm, fan->default_rpm);
 
+			fan->wanted_rpm = fan->default_rpm;
+			fan->fault = 0; 
 			sc->sc_num_fans++;
 		}
 		n++;
@@ -356,88 +351,8 @@ smu_setup_fans(struct smu_softc *sc)
 
 	for (i = 0; i < sc->sc_num_fans; i++) {
 		fan = >sc_fans[i];
-		smu_fan_set_rpm(fan, fan->default_rpm);
-		smu_fan_get_rpm(fan, >current_rpm);
-	}
-
-	/* Create sysctl nodes for each fan */
-
-	sysctl_createv(NULL, 0, NULL, (void *) _fans,
-	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
-	CTLTYPE_NODE, "fans", NULL,
-	NULL, 0, NULL, 0,
-	CTL_MACHDEP,
-	sc->sc_sysctl_me->sysctl_num,
-	CTL_CREATE, CTL_EOL);
-
-	for (i = 0; i < sc->sc_num_fans; i++) {
-		fan = >sc_fans[i];
-
-		for (j = 0; j < strlen(fan->location); j++) {
-			sysctl_fan_name[j] = tolower(fan->location[j]);
-			if (sysctl_fan_name[j] == ' ')
-sysctl_fan_name[j] = '_';
-		}
-		sysctl_fan_name[j] = '\0';
-
-		sysctl_createv(NULL, 0, NULL, (void *) _fan,
-		CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
-		CTLTYPE_NODE, sysctl_fan_name, "fan 

CVS commit: src/sys/arch/macppc

2021-09-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep  3 17:18:40 UTC 2021

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

Log Message:
switch smu to common fan control code


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r1.14 -r1.15 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

2019-11-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Nov 23 05:13:11 UTC 2019

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

Log Message:
don't invalidate sensors every time we fail to read fan speeds


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/sys/arch/macppc/dev/psoc.c:1.3
--- src/sys/arch/macppc/dev/psoc.c:1.2	Fri Nov 22 05:16:54 2019
+++ src/sys/arch/macppc/dev/psoc.c	Sat Nov 23 05:13:11 2019
@@ -1,7 +1,7 @@
- /* $NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $ */
 
 /*-
- * Copyright (c) 2018 Michael Lorenz
+ * Copyright (c) 2019 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.3 2019/11/23 05:13:11 macallan Exp $");
 
 #include 
 #include 
@@ -159,7 +159,7 @@ psoc_sensors_refresh(struct sysmon_envsy
 {
 	struct psoc_softc *sc = sme->sme_cookie;
 	uint8_t cmd = 6;
-	uint8_t buf[0x28], *bptr;
+	uint8_t buf[0x28];
 	int error = 1, data;
 
 	if ( edata->private < 0x20) {
@@ -183,26 +183,24 @@ psoc_sensors_refresh(struct sysmon_envsy
 			psoc_dump(sc);
 #endif
 	} else {
-		cmd = 0x20;
+		cmd = edata->private;
 		iic_acquire_bus(sc->sc_i2c, 0);
 		error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, buf, 12, 0);
+			sc->sc_addr, , 1, buf, 3, 0);
 		iic_release_bus(sc->sc_i2c, 0);
 		if (error) return;
-		if (edata->private >= 0x20) {
-			bptr = [edata->private - 0x20];
-			switch (bptr[0] & 0xf0) {
-case 0x50:
-	data = bptr[edata->private - 0x20];
-	edata->value_cur = ((bptr[2] & 0x3f) << 6) | (bptr[1] & 0x3f);
-	break;
-case 0x60:
-	edata->value_cur = 0;
-	break;
-default:
-	error = -1;
-			}	
-		}
+		switch (buf[0] & 0xf0) {
+			case 0x50:
+data = buf[edata->private - 0x20];
+edata->value_cur = ((buf[2] & 0x3f) << 6) |
+		(buf[1] & 0x3f);
+break;
+			case 0x60:
+edata->value_cur = 0;
+break;
+			default:
+error = 0;
+		}	
 	}
 	if (error) {
 		edata->state = ENVSYS_SINVALID;



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

2019-11-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Nov 23 05:13:11 UTC 2019

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

Log Message:
don't invalidate sensors every time we fail to read fan speeds


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 22 05:16:54 UTC 2019

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

Log Message:
report fan speeds
disclaimer:
this is guesswork obtained from watching temperatures, listening to fan noise
and staring at register dumps. Use with caution.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.1 src/sys/arch/macppc/dev/psoc.c:1.2
--- src/sys/arch/macppc/dev/psoc.c:1.1	Fri Nov  1 17:51:56 2019
+++ src/sys/arch/macppc/dev/psoc.c	Fri Nov 22 05:16:54 2019
@@ -1,4 +1,4 @@
- /* $NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $ */
+ /* $NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -30,15 +30,19 @@
  * fan controller found in 1GHz TiBook
  *
  * register values from OF:
- * fan1 - 0x20 ( status ), 0x31 ( data)
+ * fan1 - 0x20 ( status ), 0x31 ( data )
  * fan2 - 0x26 ( status ), 0x45 ( data )
- * fan3 - 0x59
+ * fan status byte 0:
+ * 0x5* - fan is running, 0x6* - fan stopped
+ * byte 1: unknown, 0x80 seems always set, lower bits seem to fluctuate
+ * byte 2: lower 6 bit seem to indicate speed
+ * fan speed may be lower 6 bit of byte 2 and lower 6 of byte 1 
  * temperature sensors start at 6, two bytes each, first appears to be
  * the temperature in degrees Celsius
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.1 2019/11/01 17:51:56 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psoc.c,v 1.2 2019/11/22 05:16:54 macallan Exp $");
 
 #include 
 #include 
@@ -71,6 +75,8 @@ static void	psoc_attach(device_t, device
 
 static void	psoc_sensors_refresh(struct sysmon_envsys *, envsys_data_t *);
 
+static void	psoc_dump(struct psoc_softc *);
+
 CFATTACH_DECL_NEW(psoc, sizeof(struct psoc_softc),
 psoc_match, psoc_attach, NULL, NULL);
 
@@ -98,7 +104,7 @@ psoc_attach(device_t parent, device_t se
 	struct i2c_attach_args *ia = aux;
 	char path[256];
 	envsys_data_t *s;
-	int error, ih, r;
+	int error, ih, r, i;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -122,19 +128,8 @@ psoc_attach(device_t parent, device_t se
 	sc->sc_sme->sme_refresh = psoc_sensors_refresh;
 	sc->sc_nsensors = 0;
 
-	int i, j;
-	uint8_t data, cmd;
-	for (i = 0; i < 0x7f; i+= 8) {
-		printf("%02x:", i);
-		for (j = 0; j < 8; j++) {
-			cmd = i + j;
-			data = 0;
-			iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, , 1, 0);
-			printf(" %02x", data);
-		}
-		printf("\n");
-	}
+	psoc_dump(sc);
+
 	for (i = 0; i < 4; i++) {
 		r = i * 2 + 6;
 		s = >sc_sensors[sc->sc_nsensors];
@@ -145,8 +140,8 @@ psoc_attach(device_t parent, device_t se
 		sysmon_envsys_sensor_attach(sc->sc_sme, s);
 		sc->sc_nsensors++;
 	}
-#if 0
-	for (r = 0x31; r < 0x50; r += 0x14) {
+
+	for (r = 0x20; r < 0x2b; r += 0x06) {
 		s = >sc_sensors[sc->sc_nsensors];
 		s->state = ENVSYS_SINVALID;
 		s->units = ENVSYS_SFANRPM;
@@ -155,7 +150,7 @@ psoc_attach(device_t parent, device_t se
 		sysmon_envsys_sensor_attach(sc->sc_sme, s);
 		sc->sc_nsensors++;
 	}
-#endif
+
 	sysmon_envsys_register(sc->sc_sme);
 }
 
@@ -164,8 +159,8 @@ psoc_sensors_refresh(struct sysmon_envsy
 {
 	struct psoc_softc *sc = sme->sme_cookie;
 	uint8_t cmd = 6;
-	uint8_t buf[0x28];
-	int error = 1, data, i;
+	uint8_t buf[0x28], *bptr;
+	int error = 1, data;
 
 	if ( edata->private < 0x20) {
 		cmd = 0;
@@ -183,19 +178,30 @@ psoc_sensors_refresh(struct sysmon_envsy
 			/* Celsius -> microkelvin */
 			edata->value_cur = ((int)data * 100) + 27315;
 		}
+#ifdef PSOC_DEBUG
+		if (edata->private == 6)
+			psoc_dump(sc);
+#endif
 	} else {
-		cmd = 0x31;
+		cmd = 0x20;
 		iic_acquire_bus(sc->sc_i2c, 0);
 		error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,
-			sc->sc_addr, , 1, buf, 0x28, 0);
+			sc->sc_addr, , 1, buf, 12, 0);
 		iic_release_bus(sc->sc_i2c, 0);
 		if (error) return;
-		if (edata->private > 0) {
-			data = buf[edata->private - 0x20];
-			edata->value_cur = data;
-			for (i = 0; i < 14; i++)
-printf(" %02x", buf[edata->private - 0x31 + i]);
-			printf("\n");
+		if (edata->private >= 0x20) {
+			bptr = [edata->private - 0x20];
+			switch (bptr[0] & 0xf0) {
+case 0x50:
+	data = bptr[edata->private - 0x20];
+	edata->value_cur = ((bptr[2] & 0x3f) << 6) | (bptr[1] & 0x3f);
+	break;
+case 0x60:
+	edata->value_cur = 0;
+	break;
+default:
+	error = -1;
+			}	
 		}
 	}
 	if (error) {
@@ -204,3 +210,21 @@ psoc_sensors_refresh(struct sysmon_envsy
 		edata->state = ENVSYS_SVALID;
 	}
 }
+
+static void
+psoc_dump(struct psoc_softc *sc)
+{
+	int i, j;
+	uint8_t data, cmd;
+	for (i = 0x20; i < 0x5f; i+= 8) {
+		printf("%02x:", i);
+		for (j = 0; j < 8; j++) {
+			cmd = i + j;
+			data = 0;
+			iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP,

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

2019-11-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov 22 05:16:54 UTC 2019

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

Log Message:
report fan speeds
disclaimer:
this is guesswork obtained from watching temperatures, listening to fan noise
and staring at register dumps. Use with caution.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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/conf

2019-11-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Nov 12 17:27:59 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add missing usb at ehci
thanks Romain Dolbeau for noticing


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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/conf/POWERMAC_G5_11_2
diff -u src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.13 src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.14
--- src/sys/arch/macppc/conf/POWERMAC_G5_11_2:1.13	Wed Aug  1 20:04:12 2018
+++ src/sys/arch/macppc/conf/POWERMAC_G5_11_2	Tue Nov 12 17:27:59 2019
@@ -143,6 +143,7 @@ ohci*	at pci? dev ? function ?	# USB Ope
 ehci*	at pci? dev ? function ?	# USB Enhanced Host Controller
 
 usb*	at ohci?	# USB bus support
+usb*	at ehci?	# USB bus support
 uhub*	at usb?		# USB Hubs
 uhub*	at uhub? port ?
 uhidev*	at uhub? port ? configuration ? interface ?	# USB HID device



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

2019-11-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Nov 12 17:27:59 UTC 2019

Modified Files:
src/sys/arch/macppc/conf: POWERMAC_G5_11_2

Log Message:
add missing usb at ehci
thanks Romain Dolbeau for noticing


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/macppc/conf/POWERMAC_G5_11_2

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

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:55:12 UTC 2019

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

Log Message:
add psoc driver


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/macppc/conf/GENERIC

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



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

2019-11-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  1 17:55:12 UTC 2019

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

Log Message:
add psoc driver


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/sys/arch/macppc/conf/GENERIC

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

Modified files:

Index: src/sys/arch/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.357 src/sys/arch/macppc/conf/GENERIC:1.358
--- src/sys/arch/macppc/conf/GENERIC:1.357	Mon Sep 16 07:11:08 2019
+++ src/sys/arch/macppc/conf/GENERIC	Fri Nov  1 17:55:12 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.357 2019/09/16 07:11:08 macallan Exp $
+# $NetBSD: GENERIC,v 1.358 2019/11/01 17:55:12 macallan Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.357 $"
+#ident 		"GENERIC-$Revision: 1.358 $"
 
 maxusers	32
 
@@ -373,6 +373,7 @@ iic*	at ki2c?
 dbcool* 	at iic?		# dbCool thermal monitor & fan control
 deq* 		at iic?		# mixer/equalizer, used by snapper
 admtemp* 	at iic?		# temperature sensor found in Mini, G5
+psoc* 		at iic?		# fan controller found in TiBooks
 videopll*	at iic?		# for valkyriefb
 sgsmix* 	at iic?		# Additional mixer found in beige G3
 # use with awacs.



  1   2   >