CVS commit: [thorpej-i2c-spi-conf] src/sys/arch/macppc/dev

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 22:39:41 UTC 2021

Modified Files:
src/sys/arch/macppc/dev [thorpej-i2c-spi-conf]: pmu.c

Log Message:
Adapt the pmu driver to the new i2c device enumeration mechanism.  This
follows the OpenFirmware bindings for the most part, but has the i2c
addresses of children shifted left one bit as it would appear on the
wire (for the r/w bit).


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

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

Modified files:

Index: src/sys/arch/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.37 src/sys/arch/macppc/dev/pmu.c:1.37.2.1
--- src/sys/arch/macppc/dev/pmu.c:1.37	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/pmu.c	Sat May  8 22:39:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $ */
+/*	$NetBSD: pmu.c,v 1.37.2.1 2021/05/08 22:39:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.37.2.1 2021/05/08 22:39:41 thorpej Exp $");
 
 #include 
 #include 
@@ -90,6 +90,13 @@ struct pmu_softc {
 	struct sysmon_pswitch sc_powerbutton;
 	bus_space_tag_t sc_memt;
 	bus_space_handle_t sc_memh;
+
+	/*
+	 * We provide our own i2c device enumeration method, so we
+	 * need to provide our own devhandle_impl.
+	 */
+	struct devhandle_impl sc_devhandle_impl;
+
 	uint32_t sc_flags;
 #define PMU_HAS_BACKLIGHT_CONTROL	1
 	int sc_node;
@@ -235,6 +242,42 @@ static const char *has_two_smart_batteri
 	"PowerBook1,1",
 	NULL };
 
+static bool
+pmu_i2c_get_address(int node, uint32_t *addrp)
+{
+	uint32_t reg;
+
+	if (of_getprop_uint32(node, "reg", ) == -1) {
+		return false;
+	}
+
+	*addrp = (reg & 0xff) >> 1;
+	return true;
+}
+
+static int
+pmu_i2c_enumerate_devices(device_t dev, devhandle_t call_handle, void *v)
+{
+	/*
+	 * This follows the OpenFirmware I2C binding for the most
+	 * part, but has the address shifted left for the READ bit.
+	 */
+	return of_i2c_enumerate_devices_ext(dev, call_handle, v,
+	pmu_i2c_get_address);
+}
+
+static device_call_t
+pmu_devhandle_lookup_device_call(devhandle_t handle, const char *name,
+devhandle_t *call_handlep)
+{
+	if (strcmp(name, "i2c-enumerate-devices") == 0) {
+		return pmu_i2c_enumerate_devices;
+	}
+
+	/* Defer everything else to the "super". */
+	return NULL;
+}
+
 static int
 pmu_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -267,7 +310,6 @@ pmu_attach(device_t parent, device_t sel
 	uint8_t cmd[2] = {2, 0};
 	uint8_t resp[16];
 	char name[256], model[32];
-	prop_dictionary_t dict = device_properties(self);
 
 	extint_node = of_getnode_byname(OF_parent(ca->ca_node), "extint-gpio1");
 	if (extint_node) {
@@ -340,50 +382,28 @@ pmu_attach(device_t parent, device_t sel
 			goto next;
 
 		if (strncmp(name, "pmu-i2c", 8) == 0) {
-			int devs;
-			uint32_t addr;
-			char compat[256];
-			prop_array_t cfg;
-			prop_dictionary_t dev;
-			prop_data_t data;
-
-			aprint_normal_dev(self, "initializing IIC bus\n");
-
-			cfg = prop_array_create();
-			prop_dictionary_set(dict, "i2c-child-devices", cfg);
-			prop_object_release(cfg);
-
-			/* look for i2c devices */
-			devs = OF_child(node);
-			while (devs != 0) {
-if (OF_getprop(devs, "name", name, 256) <= 0)
-	goto skip;
-if (OF_getprop(devs, "compatible",
-compat, 256) <= 0)
-	goto skip;
-if (OF_getprop(devs, "reg", , 4) <= 0)
-	goto skip;
-addr = (addr & 0xff) >> 1;
-DPRINTF("-> %s@%x\n", name, addr);
-dev = prop_dictionary_create();
-prop_dictionary_set_string(dev, "name", name);
-data = prop_data_create_copy(compat, strlen(compat)+1);
-prop_dictionary_set(dev, "compatible", data);
-prop_object_release(data);
-prop_dictionary_set_uint32(dev, "addr", addr);
-prop_dictionary_set_uint64(dev, "cookie", devs);
-prop_array_add(cfg, dev);
-prop_object_release(dev);
-			skip:
-devs = OF_peer(devs);
-			}
-			memset(, 0, sizeof(iba));
-			iba.iba_tag = >sc_i2c;
+			/*
+			 * Give the OFW node to the i2c bus instance,
+			 * but provide our own devhandle_impl, because
+			 * we have our own device enumeration method.
+			 */
+			devhandle_t devhandle = devhandle_from_of(node);
+			devhandle_impl_inherit(>sc_devhandle_impl,
+			devhandle.impl);
+			sc->sc_devhandle_impl.lookup_device_call =
+			pmu_devhandle_lookup_device_call;
+			devhandle.impl = >sc_devhandle_impl;
+
+			/* fill in the i2c tag */
 			iic_tag_init(>sc_i2c);
 			sc->sc_i2c.ic_cookie = sc;
 			sc->sc_i2c.ic_exec = pmu_i2c_exec;
+
+			memset(, 0, sizeof(iba));
+			iba.iba_tag = >sc_i2c;
 			config_found(sc->sc_dev, , iicbus_print,
 			CFARG_IATTR, "i2cbus",
+			CFARG_DEVHANDLE, devhandle,
 			CFARG_EOL);
 			goto next;
 		}



CVS commit: [thorpej-i2c-spi-conf] src/sys/arch/macppc/dev

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 21:58:12 UTC 2021

Modified Files:
src/sys/arch/macppc/dev [thorpej-i2c-spi-conf]: ki2c.c ki2cvar.h

Log Message:
Adapt the Keywest i2c controller driver to the new i2c device enumeration
mechanism.  We need to provide our own enumeration callback because these
controllers do not use the standard OpenFirmware bindings.

The Keywest controller supports 2 physical i2c busses on a single controller,
so we logically split it up that way now, rather than encoding the channel in
in the i2c address as was done previously.

Different systems have different I2C device tree topologies.

Some systems use a scheme like this:

/u3@0,f800/i2c@f8001000/temp-monitor@98
/u3@0,f800/i2c@f8001000/fan@15e

Here, we see the channel encoded in bit #8 of the address.

Other systems use a scheme like this:

/ht@0,f200/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0
/ht@0,f200/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0/codec@8c

/u4@0,f800/i2c@f8001000/i2c-bus@1
/u4@0,f800/i2c@f8001000/i2c-bus@1/temp-monitor@94

Here, a separate device tree node represents the channel.
Note that in BOTH cases, the I2C address of the devices are
shifted left by 1 (as it would be on the wire to leave room
for the read/write bit).


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.2.1 src/sys/arch/macppc/dev/ki2c.c
cvs rdiff -u -r1.5 -r1.5.20.1 src/sys/arch/macppc/dev/ki2cvar.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/ki2c.c
diff -u src/sys/arch/macppc/dev/ki2c.c:1.31 src/sys/arch/macppc/dev/ki2c.c:1.31.2.1
--- src/sys/arch/macppc/dev/ki2c.c:1.31	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/ki2c.c	Sat May  8 21:58:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ki2c.c,v 1.31 2021/04/24 23:36:41 thorpej Exp $	*/
+/*	$NetBSD: ki2c.c,v 1.31.2.1 2021/05/08 21:58:12 thorpej Exp $	*/
 /*	Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp	*/
 
 /*-
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -38,35 +39,220 @@
 #include "opt_ki2c.h"
 #include 
 
+#include "locators.h"
+
 #ifdef KI2C_DEBUG
 #define DPRINTF printf
 #else
 #define DPRINTF while (0) printf
 #endif
 
-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);
-inline void ki2c_writereg(struct ki2c_softc *, int, uint8_t);
-u_int ki2c_getmode(struct ki2c_softc *);
-void ki2c_setmode(struct ki2c_softc *, u_int);
-u_int ki2c_getspeed(struct ki2c_softc *);
-void ki2c_setspeed(struct ki2c_softc *, u_int);
-int ki2c_intr(struct ki2c_softc *);
-int ki2c_poll(struct ki2c_softc *, int);
-int ki2c_start(struct ki2c_softc *, int, int, void *, int);
-int ki2c_read(struct ki2c_softc *, int, int, void *, int);
-int ki2c_write(struct ki2c_softc *, int, int, void *, int);
+static int	ki2c_match(device_t, cfdata_t, void *);
+static void	ki2c_attach(device_t, device_t, void *);
+static int	ki2c_intr(struct ki2c_softc *);
 
 /* I2C glue */
-static int ki2c_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t,
-		void *, size_t, int);
-
+static int	ki2c_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
+		size_t, void *, size_t, int);
+static int	ki2c_i2c_acquire_bus(void *, int);
+static void	ki2c_i2c_release_bus(void *, int);
 
 CFATTACH_DECL_NEW(ki2c, sizeof(struct ki2c_softc), ki2c_match, ki2c_attach,
 	NULL, NULL);
 
-int
+static prop_dictionary_t
+ki2c_i2c_device_props(struct ki2c_softc *sc, int node)
+{
+	prop_dictionary_t props = prop_dictionary_create();
+	uint32_t reg;
+	char descr[32], num[8];
+
+	/* We're fetching descriptions for sensors. */
+
+	for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+		if (of_getprop_uint32(node, "reg", ) == -1) {
+			continue;
+		}
+		if (OF_getprop(node, "location", descr, sizeof(descr)) <= 0) {
+			continue;
+		}
+		snprintf(num, sizeof(num), "s%02x", reg);
+
+		aprint_debug_dev(sc->sc_dev,
+		"%s: sensor %s -> %s\n", __func__, num, descr);
+
+		prop_dictionary_set_string(props, num, descr);
+	}
+
+	return props;
+}
+
+static bool
+ki2c_i2c_enumerate_device(struct ki2c_softc *sc, device_t dev, int node,
+const char *name, uint32_t addr,
+struct i2c_enumerate_devices_args * const args)
+{
+	int compat_size;
+	prop_dictionary_t props;
+	char compat_buf[32];
+	char *compat;
+	bool cbrv;
+
+	compat_size = OF_getproplen(node, "compatible");
+	if (compat_size <= 0) {
+		/* some i2c device nodes don't have 'compatible' */
+		aprint_debug_dev(sc->sc_dev,
+		"no compatible property for phandle %d; using '%s'\n",
+		node, name);
+		compat = compat_buf;
+		strlcpy(compat, name, sizeof(compat));
+		compat_size = strlen(compat) + 1;
+	} else {
+		compat = kmem_tmpbuf_alloc(compat_size, compat_buf,
+		sizeof(compat_buf), KM_SLEEP);
+		

CVS commit: src/tools/gcc

2021-05-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  8 19:36:28 UTC 2021

Modified Files:
src/tools/gcc: Makefile

Log Message:
Disable again initfini; breaks some archs and not worth dealing with when
we have both gcc's active in the tree.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/tools/gcc/Makefile

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

Modified files:

Index: src/tools/gcc/Makefile
diff -u src/tools/gcc/Makefile:1.103 src/tools/gcc/Makefile:1.104
--- src/tools/gcc/Makefile:1.103	Fri May  7 19:00:04 2021
+++ src/tools/gcc/Makefile	Sat May  8 15:36:28 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.103 2021/05/07 23:00:04 christos Exp $
+#	$NetBSD: Makefile,v 1.104 2021/05/08 19:36:28 christos Exp $
 
 .include 
 
@@ -37,7 +37,6 @@ COMMON_CONFIGURE_ARGS=	--target=${MACHIN
 			--with-system-zlib \
 			--without-isl \
 			--enable-__cxa_atexit \
-			--enable-initfini-array=yes \
 			--enable-libstdcxx-time=rt \
 			--enable-libstdcxx-threads \
 			--with-diagnostics-color=auto-if-env



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 16:56:10 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: adadc.c fcu.c

Log Message:
ia->ia_cookie -> devhandle_to_of(device_handle(self))


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/dev/i2c/adadc.c
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/dev/i2c/fcu.c

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

Modified files:

Index: src/sys/dev/i2c/adadc.c
diff -u src/sys/dev/i2c/adadc.c:1.10 src/sys/dev/i2c/adadc.c:1.10.4.1
--- src/sys/dev/i2c/adadc.c:1.10	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/adadc.c	Sat May  8 16:56:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: adadc.c,v 1.10 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: adadc.c,v 1.10.4.1 2021/05/08 16:56:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.10 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.10.4.1 2021/05/08 16:56:10 thorpej Exp $");
 
 #include 
 #include 
@@ -128,6 +128,7 @@ adadc_attach(device_t parent, device_t s
 	struct i2c_attach_args *ia = aux;
 	envsys_data_t *s;
 	int error, ch;
+	int phandle;
 	uint32_t eeprom[40];
 	char loc[256];
 	int which_cpu;
@@ -151,8 +152,8 @@ adadc_attach(device_t parent, device_t s
 	 * should probably just expose the temperature and four ENVSYS_INTEGERs
 	 */
 	which_cpu = 0;
-	ch = OF_child(ia->ia_cookie);
-	while (ch != 0) {
+	phandle = devhandle_to_of(device_handle(self));
+	for (ch = OF_child(phandle); ch != 0; ch = OF_peer(ch)) {
 		if (OF_getprop(ch, "location", loc, 32) > 0) {
 			int reg = 0;
 			OF_getprop(ch, "reg", , sizeof(reg));
@@ -185,7 +186,6 @@ adadc_attach(device_t parent, device_t s
 			sysmon_envsys_sensor_attach(sc->sc_sme, s);
 			sc->sc_nsensors++;
 		}
-		ch = OF_peer(ch);
 	}
 	aprint_debug_dev(self, "monitoring CPU %d\n", which_cpu);
 	error = get_cpuid(which_cpu, (uint8_t *)eeprom);

Index: src/sys/dev/i2c/fcu.c
diff -u src/sys/dev/i2c/fcu.c:1.12 src/sys/dev/i2c/fcu.c:1.12.4.1
--- src/sys/dev/i2c/fcu.c:1.12	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/fcu.c	Sat May  8 16:56:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.12 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: fcu.c,v 1.12.4.1 2021/05/08 16:56:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.12 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.12.4.1 2021/05/08 16:56:10 thorpej Exp $");
 
 #include 
 #include 
@@ -141,6 +141,7 @@ fcu_attach(device_t parent, device_t sel
 	struct fcu_softc *sc = device_private(self);
 	struct i2c_attach_args *ia = aux;
 	int have_eeprom1 = 1;
+	int phandle;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -185,11 +186,11 @@ fcu_attach(device_t parent, device_t sel
 	sc->sc_nfans = 0;
 
 	/* round up sensors */
+	phandle = devhandle_to_of(device_handle(self));
 	int ch;
 
 	sc->sc_nsensors = 0;
-	ch = OF_child(ia->ia_cookie);
-	while (ch != 0) {
+	for (ch = OF_child(phandle); ch != 0; ch = OF_peer(ch)) {
 		char type[32], descr[32];
 		uint32_t reg;
 
@@ -198,7 +199,7 @@ fcu_attach(device_t parent, device_t sel
 		s->state = ENVSYS_SINVALID;
 
 		if (OF_getprop(ch, "device_type", type, 32) <= 0)
-			goto next;
+			continue;
 
 		if (strcmp(type, "fan-rpm-control") == 0) {
 			s->units = ENVSYS_SFANRPM;
@@ -214,15 +215,15 @@ fcu_attach(device_t parent, device_t sel
 			s->units = ENVSYS_INDICATOR;
 		} else {
 			/* ignore other types for now */
-			goto next;
+			continue;
 		}
 
 		if (OF_getprop(ch, "reg", , sizeof(reg)) <= 0)
-			goto next;
+			continue;
 		s->private = reg;
 
 		if (OF_getprop(ch, "location", descr, 32) <= 0)
-			goto next;
+			continue;
 		strcpy(s->desc, descr);
 
 		if (s->units == ENVSYS_SFANRPM) {
@@ -304,8 +305,6 @@ fcu_attach(device_t parent, device_t sel
 		}
 		sysmon_envsys_sensor_attach(sc->sc_sme, s);
 		sc->sc_nsensors++;
-next:
-		ch = OF_peer(ch);
 	}		
 	sysmon_envsys_register(sc->sc_sme);
 



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 16:46:43 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: ac100.c anxedp.c as3722.c
axp20x.c axppmic.c cwfg.c es8316ac.c fan53555.c max77620.c
pca9685.c pcf8563.c rkpmic.c sy8106a.c tcagpio.c tcakp.c tda19988.c
tps65217pmic.c twl4030.c

Log Message:
ia->ia_cookie -> devhandle_to_of(device_handle(self))


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/dev/i2c/ac100.c \
src/sys/dev/i2c/tda19988.c
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/dev/i2c/anxedp.c \
src/sys/dev/i2c/pca9685.c src/sys/dev/i2c/twl4030.c
cvs rdiff -u -r1.23 -r1.23.2.1 src/sys/dev/i2c/as3722.c
cvs rdiff -u -r1.20 -r1.20.2.1 src/sys/dev/i2c/axp20x.c
cvs rdiff -u -r1.34 -r1.34.2.1 src/sys/dev/i2c/axppmic.c
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/dev/i2c/cwfg.c
cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/dev/i2c/es8316ac.c
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/dev/i2c/fan53555.c
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/dev/i2c/max77620.c
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/dev/i2c/pcf8563.c
cvs rdiff -u -r1.13 -r1.13.2.1 src/sys/dev/i2c/rkpmic.c
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/dev/i2c/sy8106a.c \
src/sys/dev/i2c/tcagpio.c
cvs rdiff -u -r1.16 -r1.16.2.1 src/sys/dev/i2c/tcakp.c
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dev/i2c/tps65217pmic.c

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

Modified files:

Index: src/sys/dev/i2c/ac100.c
diff -u src/sys/dev/i2c/ac100.c:1.7 src/sys/dev/i2c/ac100.c:1.7.4.1
--- src/sys/dev/i2c/ac100.c:1.7	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/ac100.c	Sat May  8 16:46:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ac100.c,v 1.7 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: ac100.c,v 1.7.4.1 2021/05/08 16:46:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.7 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac100.c,v 1.7.4.1 2021/05/08 16:46:43 thorpej Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ ac100_attach(device_t parent, device_t s
 	sc->sc_todr.cookie = sc;
 
 #ifdef FDT
-	const int phandle = ia->ia_cookie;
+	const int phandle = devhandle_to_of(device_handle(self));
 	const int rtc_phandle = of_find_firstchild_byname(phandle, "rtc");
 	if (rtc_phandle > 0)
 		fdtbus_todr_attach(self, rtc_phandle, >sc_todr);
Index: src/sys/dev/i2c/tda19988.c
diff -u src/sys/dev/i2c/tda19988.c:1.7 src/sys/dev/i2c/tda19988.c:1.7.4.1
--- src/sys/dev/i2c/tda19988.c:1.7	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/tda19988.c	Sat May  8 16:46:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tda19988.c,v 1.7 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: tda19988.c,v 1.7.4.1 2021/05/08 16:46:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Oleksandr Tymoshenko 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda19988.c,v 1.7 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda19988.c,v 1.7.4.1 2021/05/08 16:46:43 thorpej Exp $");
 
 /*
 * NXP TDA19988 HDMI encoder 
@@ -904,7 +904,7 @@ tda19988_attach(device_t parent, device_
 {
 	struct tda19988_softc *sc = device_private(self);
 	struct i2c_attach_args * const ia = aux;
-	const int phandle = ia->ia_cookie;
+	const int phandle = devhandle_to_of(device_handle(self));
 
 	sc->sc_dev = self;
 	sc->sc_phandle = phandle;

Index: src/sys/dev/i2c/anxedp.c
diff -u src/sys/dev/i2c/anxedp.c:1.6 src/sys/dev/i2c/anxedp.c:1.6.4.1
--- src/sys/dev/i2c/anxedp.c:1.6	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/anxedp.c	Sat May  8 16:46:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: anxedp.c,v 1.6 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: anxedp.c,v 1.6.4.1 2021/05/08 16:46:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: anxedp.c,v 1.6 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: anxedp.c,v 1.6.4.1 2021/05/08 16:46:43 thorpej Exp $");
 
 #include 
 #include 
@@ -434,7 +434,7 @@ anxedp_attach(device_t parent, device_t 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
 	sc->sc_addr = ia->ia_addr;
-	sc->sc_phandle = ia->ia_cookie;
+	sc->sc_phandle = devhandle_to_of(device_handle(self));
 
 	aprint_naive("\n");
 	aprint_normal(": eDP TX\n");
Index: src/sys/dev/i2c/pca9685.c
diff -u src/sys/dev/i2c/pca9685.c:1.6 src/sys/dev/i2c/pca9685.c:1.6.4.1
--- src/sys/dev/i2c/pca9685.c:1.6	Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/pca9685.c	Sat May  8 16:46:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pca9685.c,v 1.6 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: pca9685.c,v 1.6.4.1 2021/05/08 16:46:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018, 2019 Jason R. Thorpe
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pca9685.c,v 1.6 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pca9685.c,v 1.6.4.1 

CVS commit: [thorpej-i2c-spi-conf] src/sys

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 15:51:31 UTC 2021

Modified Files:
src/sys/arch/macppc/dev [thorpej-i2c-spi-conf]: cuda.c
src/sys/arch/sandpoint/sandpoint [thorpej-i2c-spi-conf]: autoconf.c
src/sys/dev/acpi [thorpej-i2c-spi-conf]: acpi_i2c.c
src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2cvar.h
src/sys/dev/ofw [thorpej-i2c-spi-conf]: ofw_i2c_subr.c

Log Message:
There are no more consumers of i2c attach args "cookie" and "cookietype",
so garbage-collect them.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/arch/macppc/dev/cuda.c
cvs rdiff -u -r1.29.6.1 -r1.29.6.2 \
src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.11.4.1 -r1.11.4.2 src/sys/dev/acpi/acpi_i2c.c
cvs rdiff -u -r1.24.2.2 -r1.24.2.3 src/sys/dev/i2c/i2cvar.h
cvs rdiff -u -r1.1.6.1 -r1.1.6.2 src/sys/dev/ofw/ofw_i2c_subr.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.28.2.1 src/sys/arch/macppc/dev/cuda.c:1.28.2.2
--- src/sys/arch/macppc/dev/cuda.c:1.28.2.1	Sat May  8 11:40:02 2021
+++ src/sys/arch/macppc/dev/cuda.c	Sat May  8 15:51:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cuda.c,v 1.28.2.1 2021/05/08 11:40:02 thorpej Exp $ */
+/*	$NetBSD: cuda.c,v 1.28.2.2 2021/05/08 15:51:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.28.2.1 2021/05/08 11:40:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.28.2.2 2021/05/08 15:51:30 thorpej Exp $");
 
 #include 
 #include 
@@ -195,8 +195,6 @@ cuda_i2c_enumerate_devices(device_t dev,
 		args->ia->ia_prop = props;
 		/* Child gets no handle. */
 		devhandle_invalidate(>ia->ia_devhandle);
-		args->ia->ia_cookie = 0;			/* XXX */
-		args->ia->ia_cookietype = I2C_COOKIE_NONE;	/* XXX */
 
 		cbrv = args->callback(dev, args);
 

Index: src/sys/arch/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.6.1 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.6.2
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.6.1	Sun Apr 25 23:19:16 2021
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c	Sat May  8 15:51:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.29.6.1 2021/04/25 23:19:16 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.29.6.2 2021/05/08 15:51:30 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29.6.1 2021/04/25 23:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29.6.2 2021/05/08 15:51:30 thorpej Exp $");
 
 #include 
 #include 
@@ -190,8 +190,6 @@ sandpoint_i2c_enumerate_devices(device_t
 		args->ia->ia_prop = props;
 		/* no devhandle for child devices. */
 		devhandle_invalidate(>ia->ia_devhandle);
-		args->ia->ia_cookie = 0;			/* XXX */
-		args->ia->ia_cookietype = I2C_COOKIE_NONE;	/* XXX */
 
 		cbrv = args->callback(dev, args);
 

Index: src/sys/dev/acpi/acpi_i2c.c
diff -u src/sys/dev/acpi/acpi_i2c.c:1.11.4.1 src/sys/dev/acpi/acpi_i2c.c:1.11.4.2
--- src/sys/dev/acpi/acpi_i2c.c:1.11.4.1	Sun Apr 25 21:49:56 2021
+++ src/sys/dev/acpi/acpi_i2c.c	Sat May  8 15:51:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.11.4.1 2021/04/25 21:49:56 thorpej Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.11.4.2 2021/05/08 15:51:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2017, 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.11.4.1 2021/04/25 21:49:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.11.4.2 2021/05/08 15:51:30 thorpej Exp $");
 
 #include 
 #include 
@@ -105,8 +105,6 @@ acpi_i2c_enumerate_device(device_t dev, 
 	args->ia->ia_clist_size = clist_size;
 	args->ia->ia_prop = props;
 	args->ia->ia_devhandle = devhandle_from_acpi(ad->ad_handle);
-	args->ia->ia_cookie = (uint64_t)ad->ad_handle;	/* XXX */
-	args->ia->ia_cookietype = I2C_COOKIE_ACPI;	/* XXX */
 
 	cbrv = args->callback(dev, args);
 

Index: src/sys/dev/i2c/i2cvar.h
diff -u src/sys/dev/i2c/i2cvar.h:1.24.2.2 src/sys/dev/i2c/i2cvar.h:1.24.2.3
--- src/sys/dev/i2c/i2cvar.h:1.24.2.2	Sat May  8 14:23:15 2021
+++ src/sys/dev/i2c/i2cvar.h	Sat May  8 15:51:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cvar.h,v 1.24.2.2 2021/05/08 14:23:15 thorpej Exp $	*/
+/*	$NetBSD: i2cvar.h,v 1.24.2.3 2021/05/08 15:51:31 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -134,13 +134,6 @@ struct i2cbus_attach_args {
 	int iba_bus;			/* bus number (optional) */
 };
 
-/* Type of value stored in "ia_cookie" */
-enum i2c_cookie_type {
-	I2C_COOKIE_NONE,		/* Cookie is not valid */
-	I2C_COOKIE_OF,			/* Cookie is an OF node phandle */
-	I2C_COOKIE_ACPI,		/* Cookie is an ACPI handle */
-};
-
 /* Used to attach devices on the i2c bus. */
 struct 

CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 15:44:12 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: ihidev.c ihidev.h

Log Message:
Rather than using the "cookie" from the i2c_attach_args, use the
device handle that's already associated with our device_t.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dev/i2c/ihidev.c
cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/dev/i2c/ihidev.h

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

Modified files:

Index: src/sys/dev/i2c/ihidev.c
diff -u src/sys/dev/i2c/ihidev.c:1.19 src/sys/dev/i2c/ihidev.c:1.19.2.1
--- src/sys/dev/i2c/ihidev.c:1.19	Sat Apr 24 23:36:54 2021
+++ src/sys/dev/i2c/ihidev.c	Sat May  8 15:44:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.19 2021/04/24 23:36:54 thorpej Exp $ */
+/* $NetBSD: ihidev.c,v 1.19.2.1 2021/05/08 15:44:12 thorpej Exp $ */
 /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
 
 /*-
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.19 2021/04/24 23:36:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.19.2.1 2021/05/08 15:44:12 thorpej Exp $");
 
 #include 
 #include 
@@ -162,8 +162,7 @@ ihidev_attach(device_t parent, device_t 
 	sc->sc_addr = ia->ia_addr;
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 
-	sc->sc_phandle = ia->ia_cookie;
-	if (ia->ia_cookietype != I2C_COOKIE_ACPI) {
+	if (devhandle_type(device_handle(self)) != DEVHANDLE_TYPE_ACPI) {
 		aprint_error(": unsupported device tree type\n");
 		return;
 	}
@@ -651,7 +650,7 @@ static bool
 ihiddev_intr_init(struct ihidev_softc *sc)
 {
 #if NACPICA > 0
-	ACPI_HANDLE hdl = (void *)(uintptr_t)sc->sc_phandle;
+	ACPI_HANDLE hdl = devhandle_to_acpi(device_handle(sc->sc_dev));
 	struct acpi_resources res;
 	ACPI_STATUS rv;
 	char buf[100];
@@ -675,7 +674,7 @@ ihiddev_intr_init(struct ihidev_softc *s
 
 	acpi_resource_cleanup();
 
-	sc->sc_ih = acpi_intr_establish(sc->sc_dev, sc->sc_phandle, IPL_TTY,
+	sc->sc_ih = acpi_intr_establish(sc->sc_dev, (uint64_t)hdl, IPL_TTY,
 	false, ihidev_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(sc->sc_dev, "can't establish interrupt\n");
@@ -977,7 +976,7 @@ ihidev_set_report(struct device *dev, in
 static bool
 ihidev_acpi_get_info(struct ihidev_softc *sc)
 {   
-	ACPI_HANDLE hdl = (void *)(uintptr_t)sc->sc_phandle;
+	ACPI_HANDLE hdl = devhandle_to_acpi(device_handle(sc->sc_dev));
 	ACPI_STATUS status;
 	ACPI_INTEGER val;
 

Index: src/sys/dev/i2c/ihidev.h
diff -u src/sys/dev/i2c/ihidev.h:1.4 src/sys/dev/i2c/ihidev.h:1.4.10.1
--- src/sys/dev/i2c/ihidev.h:1.4	Thu Jan  9 04:04:01 2020
+++ src/sys/dev/i2c/ihidev.h	Sat May  8 15:44:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.h,v 1.4 2020/01/09 04:04:01 thorpej Exp $ */
+/* $NetBSD: ihidev.h,v 1.4.10.1 2021/05/08 15:44:12 thorpej Exp $ */
 /* $OpenBSD ihidev.h,v 1.4 2016/01/31 18:24:35 jcs Exp $ */
 
 /*-
@@ -97,7 +97,6 @@ struct ihidev_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_tag;
 	i2c_addr_t	sc_addr;
-	uint64_t	sc_phandle;
 
 	void *		sc_ih;
 	void *		sc_sih;



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 15:10:44 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2cmux.c i2cmuxvar.h

Log Message:
Use device_enumerate_children() to eliminate all of the ACPI-specific
code and most of the FDT-specific code from the iicmux driver.


To generate a diff of this commit:
cvs rdiff -u -r1.5.2.2 -r1.5.2.3 src/sys/dev/i2c/i2cmux.c
cvs rdiff -u -r1.3.4.1 -r1.3.4.2 src/sys/dev/i2c/i2cmuxvar.h

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

Modified files:

Index: src/sys/dev/i2c/i2cmux.c
diff -u src/sys/dev/i2c/i2cmux.c:1.5.2.2 src/sys/dev/i2c/i2cmux.c:1.5.2.3
--- src/sys/dev/i2c/i2cmux.c:1.5.2.2	Sat May  8 14:23:15 2021
+++ src/sys/dev/i2c/i2cmux.c	Sat May  8 15:10:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cmux.c,v 1.5.2.2 2021/05/08 14:23:15 thorpej Exp $	*/
+/*	$NetBSD: i2cmux.c,v 1.5.2.3 2021/05/08 15:10:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.2 2021/05/08 14:23:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.3 2021/05/08 15:10:44 thorpej Exp $");
 
 #include 
 #include 
@@ -157,98 +157,53 @@ iicmux_attach_bus(struct iicmux_softc * 
 	CFARG_EOL);
 }
 
-#if defined(I2CMUX_USE_FDT)
-static int
-iicmux_fdt_count_children(struct iicmux_softc * const sc)
+static bool
+iicmux_count_busses_callback(device_t self, devhandle_t devhandle,
+void *v __unused)
 {
-	int phandle = devhandle_to_of(sc->sc_i2c_mux_devhandle);
-	char name[32];
-	int child, count;
-
- restart:
-	for (child = OF_child(phandle), count = 0; child;
-	 child = OF_peer(child)) {
-		if (OF_getprop(child, "name", name, sizeof(name)) <= 0) {
-			continue;
+	struct iicmux_softc *sc = device_private(self);
+
+#if defined(I2CMUX_USE_FDT)
+	if (devhandle_type(devhandle) == DEVHANDLE_TYPE_OF) {
+		char name[32];
+
+		if (OF_getprop(devhandle_to_of(devhandle), "name", name,
+			   sizeof(name)) <= 0) {
+			/* Skip this DT node (shouldn't happen). */
+			return true;	/* keep enumerating */
 		}
 		if (strcmp(name, "i2c-mux") == 0) {
-			phandle = child;
-			goto restart;
+			/*
+			 * This DT node is the actual mux node; reset the
+			 * our devhandle and restart enumeration.
+			 */
+			device_set_handle(self, devhandle);
+			sc->sc_nbusses = -1;
+			return false;	/* stop enumerating */
 		}
-		count++;
 	}
+#endif /* I2CMUX_USE_FDT */
 
-	/* phandle may have changed. */
-	sc->sc_i2c_mux_devhandle = devhandle_from_of(phandle);
-	return count;
+	sc->sc_nbusses++;
+	return true;			/* keep enumerating */
 }
 
-static void
-iicmux_attach_fdt(struct iicmux_softc * const sc)
+static bool
+iicmux_attach_busses_callback(device_t self, devhandle_t devhandle, void *v)
 {
-	int phandle = devhandle_to_of(sc->sc_i2c_mux_devhandle);
-
-	sc->sc_nbusses = iicmux_fdt_count_children(sc);
-	if (sc->sc_nbusses == 0) {
-		return;
-	}
+	struct iicmux_softc *sc = device_private(self);
+	int * const idxp = v;
 
-	/* sc_i2c_mux_devhandle may have changed. */
-	phandle = devhandle_to_of(sc->sc_i2c_mux_devhandle);
+	KASSERT(*idxp < sc->sc_nbusses);
+	iicmux_attach_bus(sc, devhandle, (*idxp)++);
 
-	sc->sc_busses = kmem_zalloc(sizeof(*sc->sc_busses) * sc->sc_nbusses,
-	KM_SLEEP);
-
-	int child, idx;
-	for (child = OF_child(phandle), idx = 0; child;
-	 child = OF_peer(child), idx++) {
-		KASSERT(idx < sc->sc_nbusses);
-		iicmux_attach_bus(sc, devhandle_from_of(child), idx);
-	}
+	return true;			/* keep enumerating */
 }
-#endif /* I2CMUX_USE_FDT */
-
-#if defined(I2CMUX_USE_ACPI)
-static void
-iicmux_attach_acpi(struct iicmux_softc * const sc)
-{
-	ACPI_HANDLE hdl = devhandle_to_acpi(sc->sc_i2c_mux_devhandle);
-	struct acpi_devnode *devnode, *ad;
-	int idx;
-
-	devnode = acpi_match_node(hdl);
-	KASSERT(devnode != NULL);
-
-	/* Count child busses */
-	sc->sc_nbusses = 0;
-	SIMPLEQ_FOREACH(ad, >ad_child_head, ad_child_list) {
-		if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE ||
-		!acpi_device_present(ad->ad_handle)) {
-			continue;
-		}
-		sc->sc_nbusses++;
-	}
-
-	sc->sc_busses = kmem_zalloc(sizeof(*sc->sc_busses) * sc->sc_nbusses,
-	KM_SLEEP);
-
-	/* Attach child busses */
-	idx = 0;
-	SIMPLEQ_FOREACH(ad, >ad_child_head, ad_child_list) {
-		if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE ||
-		!acpi_device_present(ad->ad_handle)) {
-			continue;
-		}
-		iicmux_attach_bus(sc, devhandle_from_acpi(ad->ad_handle), idx);
-		idx++;
-	}
-}
-#endif /* I2CMUX_USE_ACPI */
 
 void
 iicmux_attach(struct iicmux_softc * const sc)
 {
-	devhandle_t devhandle = device_handle(sc->sc_dev);
+	int error, idx;
 
 	/*
 	 * We expect sc->sc_config and sc->sc_i2c_parent to be initialized
@@ -258,14 +213,6 @@ iicmux_attach(struct iicmux_softc * cons
 	KASSERT(sc->sc_i2c_parent != NULL);
 
 	/*
-	 * We start out assuming that the i2c bus nodes are children of
-	 * our own node.  We'll adjust later 

CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 14:49:14 UTC 2021

Modified Files:
src/usr.bin/aiomixer: draw.c

Log Message:
aiomixer: bound the drawn area to the screen size, rather than replacing it


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/aiomixer/draw.c

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

Modified files:

Index: src/usr.bin/aiomixer/draw.c
diff -u src/usr.bin/aiomixer/draw.c:1.5 src/usr.bin/aiomixer/draw.c:1.6
--- src/usr.bin/aiomixer/draw.c:1.5	Sat May  8 14:38:26 2021
+++ src/usr.bin/aiomixer/draw.c	Sat May  8 14:49:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: draw.c,v 1.5 2021/05/08 14:38:26 nia Exp $ */
+/* $NetBSD: draw.c,v 1.6 2021/05/08 14:49:13 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -134,10 +134,14 @@ draw_screen(struct aiomixer *aio)
 	wnoutrefresh(stdscr);
 	wnoutrefresh(aio->header);
 	wnoutrefresh(aio->classbar);
+	max_y = aio->classes[aio->curclass].height + 1;
+	max_y -= aio->class_scroll_y;
+	if (max_y > (getmaxy(stdscr) - 3))
+		max_y = getmaxy(stdscr) - 3;
 	pnoutrefresh(aio->classes[aio->curclass].widgetpad,
 	aio->class_scroll_y, 0,
 	3, 0,
-	getmaxy(stdscr) - 3, getmaxx(stdscr));
+	max_y, getmaxx(stdscr));
 	doupdate();
 }
 



CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 14:38:26 UTC 2021

Modified Files:
src/usr.bin/aiomixer: draw.c

Log Message:
aiomixer: do not adjust class widget pad height, draw to end of screen

ncurses refuses to paint pads if the height argument extends beyond
the bounds of the screen. it's probably not good for our curses either.

libcurses wresize() refuses to resize a pad beyond the bounds of the
screen even if it was created with a larger size. this is probably
a bug.

found by uwe


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/aiomixer/draw.c

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

Modified files:

Index: src/usr.bin/aiomixer/draw.c
diff -u src/usr.bin/aiomixer/draw.c:1.4 src/usr.bin/aiomixer/draw.c:1.5
--- src/usr.bin/aiomixer/draw.c:1.4	Sat May  8 13:28:45 2021
+++ src/usr.bin/aiomixer/draw.c	Sat May  8 14:38:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: draw.c,v 1.4 2021/05/08 13:28:45 nia Exp $ */
+/* $NetBSD: draw.c,v 1.5 2021/05/08 14:38:26 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -137,7 +137,7 @@ draw_screen(struct aiomixer *aio)
 	pnoutrefresh(aio->classes[aio->curclass].widgetpad,
 	aio->class_scroll_y, 0,
 	3, 0,
-	1 + aio->classes[aio->curclass].height, getmaxx(stdscr));
+	getmaxy(stdscr) - 3, getmaxx(stdscr));
 	doupdate();
 }
 
@@ -360,7 +360,13 @@ create_widgets(struct aiomixer *aio)
 			control->widget_y = class->height;
 			class->height += control->height;
 		}
+#ifdef notyet
+		/*
+		 * NetBSD curses wresize() bounds the pad to the height of
+		 * the screen even though it's already taller. Probably a bug.
+		 */
 		wresize(class->widgetpad, class->height, getmaxx(stdscr));
+#endif
 	}
 
 	aio->last_max_x = getmaxx(stdscr);



CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 14:23:15 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: files.i2c i2c_subr.c i2cmux.c
i2cvar.h

Log Message:
- Add an optional bus number to i2cbus_attach_args, and a corresponding
  optional "bus" locator to the i2cbus interface attribute.
- Add a iicbus_print_multi() routine, which is like iicbus_print(),
  but also prints the bus number.
- Use these new features in the iicmux driver rather than winging it.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.115.4.1 src/sys/dev/i2c/files.i2c
cvs rdiff -u -r1.1 -r1.1.72.1 src/sys/dev/i2c/i2c_subr.c
cvs rdiff -u -r1.5.2.1 -r1.5.2.2 src/sys/dev/i2c/i2cmux.c
cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/dev/i2c/i2cvar.h

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

Modified files:

Index: src/sys/dev/i2c/files.i2c
diff -u src/sys/dev/i2c/files.i2c:1.115 src/sys/dev/i2c/files.i2c:1.115.4.1
--- src/sys/dev/i2c/files.i2c:1.115	Mon Jan  4 22:09:35 2021
+++ src/sys/dev/i2c/files.i2c	Sat May  8 14:23:15 2021
@@ -1,7 +1,7 @@
-#	$NetBSD: files.i2c,v 1.115 2021/01/04 22:09:35 thorpej Exp $
+#	$NetBSD: files.i2c,v 1.115.4.1 2021/05/08 14:23:15 thorpej Exp $
 
 obsolete defflag	opt_i2cbus.h		I2C_SCAN
-define	i2cbus { }
+define	i2cbus { [bus = -1] }
 define	i2cexec
 
 device	iic { [addr = -1] } : i2c_bitbang

Index: src/sys/dev/i2c/i2c_subr.c
diff -u src/sys/dev/i2c/i2c_subr.c:1.1 src/sys/dev/i2c/i2c_subr.c:1.1.72.1
--- src/sys/dev/i2c/i2c_subr.c:1.1	Mon Oct  3 22:27:23 2011
+++ src/sys/dev/i2c/i2c_subr.c	Sat May  8 14:23:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c_subr.c,v 1.1 2011/10/03 22:27:23 jmcneill Exp $	*/
+/*	$NetBSD: i2c_subr.c,v 1.1.72.1 2021/05/08 14:23:15 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c_subr.c,v 1.1 2011/10/03 22:27:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c_subr.c,v 1.1.72.1 2021/05/08 14:23:15 thorpej Exp $");
 
 #include 
 #include 
@@ -46,9 +46,22 @@ __KERNEL_RCSID(0, "$NetBSD: i2c_subr.c,v
 int
 iicbus_print(void *aux, const char *pnp)
 {
+	/* struct i2cbus_attach_args * const iba = aux; */
 
 	if (pnp != NULL)
 		aprint_normal("iic at %s", pnp);
 
 	return UNCONF;
 }
+
+int
+iicbus_print_multi(void *aux, const char *pnp)
+{
+	struct i2cbus_attach_args * const iba = aux;
+
+	if (pnp != NULL)
+		aprint_normal("iic at %s", pnp);
+	aprint_normal(" bus %d", iba->iba_bus);
+
+	return UNCONF;
+}

Index: src/sys/dev/i2c/i2cmux.c
diff -u src/sys/dev/i2c/i2cmux.c:1.5.2.1 src/sys/dev/i2c/i2cmux.c:1.5.2.2
--- src/sys/dev/i2c/i2cmux.c:1.5.2.1	Sat May  8 02:44:22 2021
+++ src/sys/dev/i2c/i2cmux.c	Sat May  8 14:23:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cmux.c,v 1.5.2.1 2021/05/08 02:44:22 thorpej Exp $	*/
+/*	$NetBSD: i2cmux.c,v 1.5.2.2 2021/05/08 14:23:15 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.1 2021/05/08 02:44:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.5.2.2 2021/05/08 14:23:15 thorpej Exp $");
 
 #include 
 #include 
@@ -40,6 +40,8 @@ __KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1
 #include 
 #include 
 
+#include "locators.h"
+
 /*
  * i2c mux
  *
@@ -110,20 +112,6 @@ iicmux_exec(void * const v, i2c_op_t con
 
 /*/
 
-/* XXX iicbus_print() should be able to do this. */
-static int
-iicmux_print(void * const aux, const char * const pnp)
-{
-	i2c_tag_t const tag = aux;
-	struct iicmux_bus * const bus = tag->ic_cookie;
-	int rv;
-
-	rv = iicbus_print(aux, pnp);
-	aprint_normal(" bus %d", bus->busidx);
-
-	return rv;
-}
-
 static void
 iicmux_attach_bus(struct iicmux_softc * const sc, devhandle_t devhandle,
 int const busidx)
@@ -147,31 +135,26 @@ iicmux_attach_bus(struct iicmux_softc * 
 	bus->controller.ic_release_bus = iicmux_release_bus;
 	bus->controller.ic_exec = iicmux_exec;
 
-	switch (devhandle_type(devhandle)) {
 #if defined(I2CMUX_USE_FDT)
-	case DEVHANDLE_TYPE_OF:
+	if (devhandle_type(devhandle) == DEVHANDLE_TYPE_OF) {
 		fdtbus_register_i2c_controller(>controller,
 		devhandle_to_of(devhandle));
-
-		fdtbus_attach_i2cbus(sc->sc_dev, devhandle_to_of(devhandle),
-		>controller, iicmux_print);
-		break;
+	}
 #endif /* I2CMUX_USE_FDT */
 
-	case DEVHANDLE_TYPE_INVALID:
-		aprint_error_dev(sc->sc_dev, "invalid bus device handle\n");
-		return;
-
-	default: {
-		struct i2cbus_attach_args iba = {
-			.iba_tag = >controller,
-		};
-		config_found(sc->sc_dev, , iicmux_print,
-		CFARG_DEVHANDLE, devhandle,
-		CFARG_EOL);
-		break;
-	}
-	}
+	struct i2cbus_attach_args iba = {
+		.iba_tag = >controller,
+		.iba_bus = bus->busidx,
+	};
+
+	int locs[I2CBUSCF_NLOCS];
+	locs[I2CBUSCF_BUS] = bus->busidx;
+
+	config_found(sc->sc_dev, , 

CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Chris Pinnock
Module Name:src
Committed By:   cjep
Date:   Sat May  8 14:11:37 UTC 2021

Modified Files:
src/usr.bin/aiomixer: Makefile

Log Message:
Also include terminfo for platforms with static libraries (e.g. sun2). From 
uwe/nia.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/aiomixer/Makefile

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

Modified files:

Index: src/usr.bin/aiomixer/Makefile
diff -u src/usr.bin/aiomixer/Makefile:1.1 src/usr.bin/aiomixer/Makefile:1.2
--- src/usr.bin/aiomixer/Makefile:1.1	Fri May  7 16:29:24 2021
+++ src/usr.bin/aiomixer/Makefile	Sat May  8 14:11:37 2021
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.1 2021/05/07 16:29:24 nia Exp $
+# $NetBSD: Makefile,v 1.2 2021/05/08 14:11:37 cjep Exp $
 
 PROG=	aiomixer
 SRCS+=	main.c draw.c parse.c
 
-LDADD+=	-lcurses
-DPADD+=	$(LIBCURSES)
+LDADD+=	-lcurses -lterminfo
+DPADD+=	${LIBCURSES} ${LIBTERMINFO}
 
 WARNS= 6
 



CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 13:28:45 UTC 2021

Modified Files:
src/usr.bin/aiomixer: draw.c

Log Message:
aiomixer: fix background banding with slightly older libcurses

reported by uwe


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/aiomixer/draw.c

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

Modified files:

Index: src/usr.bin/aiomixer/draw.c
diff -u src/usr.bin/aiomixer/draw.c:1.3 src/usr.bin/aiomixer/draw.c:1.4
--- src/usr.bin/aiomixer/draw.c:1.3	Fri May  7 19:37:03 2021
+++ src/usr.bin/aiomixer/draw.c	Sat May  8 13:28:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: draw.c,v 1.3 2021/05/07 19:37:03 nia Exp $ */
+/* $NetBSD: draw.c,v 1.4 2021/05/08 13:28:45 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -113,6 +113,8 @@ draw_control(struct aiomixer *aio,
 		aio->channels_unlocked, selected);
 		break;
 	}
+
+	wprintw(control->widgetpad, "\n");
 }
 
 void



CVS commit: src/sys/arch/hppa/include

2021-05-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  8 13:10:29 UTC 2021

Modified Files:
src/sys/arch/hppa/include: param.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/hppa/include/param.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/hppa/include/param.h
diff -u src/sys/arch/hppa/include/param.h:1.27 src/sys/arch/hppa/include/param.h:1.28
--- src/sys/arch/hppa/include/param.h:1.27	Fri May  1 08:21:27 2020
+++ src/sys/arch/hppa/include/param.h	Sat May  8 13:10:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.27 2020/05/01 08:21:27 isaki Exp $	*/
+/*	$NetBSD: param.h,v 1.28 2021/05/08 13:10:29 skrll Exp $	*/
 
 /*	$OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $	*/
 
@@ -41,11 +41,11 @@
 
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
-#define	PGOFSET		(NBPG-1)	/* byte offset into page */
+#define	PGOFSET		(NBPG - 1)	/* byte offset into page */
 
 #define	SEGSHIFT	(PGSHIFT + (PGSHIFT-PTESHIFT))	/* LOG2(NBSEG) */
 #define NBSEG		(1 << SEGSHIFT)	/* bytes/segment (quadrant) */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
+#define	SEGOFSET	(NBSEG - 1)	/* byte offset into segment */
 
 #define	KERNBASE	0x	/* start of kernel virtual */
 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
@@ -61,7 +61,7 @@
 #define	USPACE		(UPAGES * NBPG)	/* pages for user struct and kstack */
 
 #ifndef	MSGBUFSIZE
-#define	MSGBUFSIZE	(2*NBPG)	/* default message buffer size */
+#define	MSGBUFSIZE	(2 * NBPG)	/* default message buffer size */
 #endif
 
 /*



CVS commit: src/sys/arch/mips/include

2021-05-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  8 13:09:58 UTC 2021

Modified Files:
src/sys/arch/mips/include: mips_param.h

Log Message:
KNG


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/mips/include/mips_param.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/mips/include/mips_param.h
diff -u src/sys/arch/mips/include/mips_param.h:1.48 src/sys/arch/mips/include/mips_param.h:1.49
--- src/sys/arch/mips/include/mips_param.h:1.48	Mon Apr 26 13:29:51 2021
+++ src/sys/arch/mips/include/mips_param.h	Sat May  8 13:09:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_param.h,v 1.48 2021/04/26 13:29:51 christos Exp $	*/
+/*	$NetBSD: mips_param.h,v 1.49 2021/05/08 13:09:58 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
 
 #define	SEGSHIFT	(PGSHIFT + PTPLENGTH)	/* LOG2(NBSEG) */
 #define	NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
+#define	SEGOFSET	(NBSEG - 1)	/* byte offset into segment */
 
 #ifdef _LP64
 #define	SEGLENGTH	(PGSHIFT - 3)



CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 13:03:41 UTC 2021

Modified Files:
src/usr.bin/aiomixer: parse.c

Log Message:
aiomixer: try to make sure the first pane is always "outputs"

In QEMU with an ac97 audio device, "inputs" is the first pane,
which is significantly less important especially when you don't
have input in QEMU most of the time.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/aiomixer/parse.c

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

Modified files:

Index: src/usr.bin/aiomixer/parse.c
diff -u src/usr.bin/aiomixer/parse.c:1.2 src/usr.bin/aiomixer/parse.c:1.3
--- src/usr.bin/aiomixer/parse.c:1.2	Sat May  8 12:53:15 2021
+++ src/usr.bin/aiomixer/parse.c	Sat May  8 13:03:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.2 2021/05/08 12:53:15 nia Exp $ */
+/* $NetBSD: parse.c,v 1.3 2021/05/08 13:03:40 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,6 +36,7 @@
 
 static struct aiomixer_class *get_class(struct aiomixer *, int);
 static int compare_control(const void *, const void *);
+static int compare_class(const void *, const void *);
 
 static struct aiomixer_class *
 get_class(struct aiomixer *aio, int class)
@@ -68,6 +69,20 @@ compare_control(const void *pa, const vo
 	return 0;
 }
 
+static int
+compare_class(const void *pa, const void *pb)
+{
+	const struct aiomixer_class *a = (const struct aiomixer_class *)pa;
+	const struct aiomixer_class *b = (const struct aiomixer_class *)pb;
+
+	if (strcmp(a->name, AudioCoutputs) == 0)
+		return -1;
+	if (strcmp(b->name, AudioCoutputs) == 0)
+		return 1;
+
+	return strcmp(a->name, b->name);
+}
+
 int
 aiomixer_parse(struct aiomixer *aio)
 {
@@ -106,6 +121,9 @@ aiomixer_parse(struct aiomixer *aio)
 		control = >controls[class->numcontrols++];
 		control->info = info;
 	}
+	qsort(aio->classes, aio->numclasses,
+	sizeof(struct aiomixer_class),
+	compare_class);
 	for (i = 0; i < aio->numclasses; ++i) {
 		class = >classes[i];
 		qsort(class->controls, class->numcontrols,



CVS commit: src/usr.bin/aiomixer

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 12:53:15 UTC 2021

Modified Files:
src/usr.bin/aiomixer: parse.c

Log Message:
aiomixer: Fix sorting of ac97 controls


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/aiomixer/parse.c

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

Modified files:

Index: src/usr.bin/aiomixer/parse.c
diff -u src/usr.bin/aiomixer/parse.c:1.1 src/usr.bin/aiomixer/parse.c:1.2
--- src/usr.bin/aiomixer/parse.c:1.1	Fri May  7 16:29:24 2021
+++ src/usr.bin/aiomixer/parse.c	Sat May  8 12:53:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.1 2021/05/07 16:29:24 nia Exp $ */
+/* $NetBSD: parse.c,v 1.2 2021/05/08 12:53:15 nia Exp $ */
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -56,14 +56,16 @@ compare_control(const void *pa, const vo
 	const struct aiomixer_control *a = (const struct aiomixer_control *)pa;
 	const struct aiomixer_control *b = (const struct aiomixer_control *)pb;
 
-	if (a->info.prev != AUDIO_MIXER_LAST &&
+	if (a->info.prev != AUDIO_MIXER_LAST ||
 	b->info.prev != AUDIO_MIXER_LAST) {
 		if (b->info.prev == a->info.index)
 			return -1;
 		if (a->info.prev == b->info.index)
 			return 1;
+	} else {
+		return strcmp(a->info.label.name, b->info.label.name);
 	}
-	return strcmp(a->info.label.name, b->info.label.name);
+	return 0;
 }
 
 int



CVS commit: src/doc

2021-05-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat May  8 12:45:04 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
doc: imported aiomixer


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

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2803 src/doc/CHANGES:1.2804
--- src/doc/CHANGES:1.2803	Wed May  5 10:25:36 2021
+++ src/doc/CHANGES	Sat May  8 12:45:04 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2803 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2804 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -370,3 +370,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		(see resolv.conf(5)), which means that hostnames that
 		contain invalid characters will not resolve. [christos 20210430]
 	evbarm: Add support for Allwinner V3s SoCs. [jmcneill 20210505]
+	aiomixer(1): Added aiomixer, a curses-based mixer for NetBSD's
+		audio API.



CVS commit: src/doc

2021-05-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  8 12:27:21 UTC 2021

Modified Files:
src/doc: HACKS

Log Message:
mention gdb hack discovered by rin.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.216 src/doc/HACKS:1.217
--- src/doc/HACKS:1.216	Tue Dec 15 20:35:39 2020
+++ src/doc/HACKS	Sat May  8 08:27:21 2021
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.216 2020/12/16 01:35:39 rin Exp $
+# $NetBSD: HACKS,v 1.217 2021/05/08 12:27:21 christos Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -1000,3 +1000,14 @@ descr	GCC 9.4 and 8.3 miscompile aes_ccm
 	mac68k (Quadra 840AV, 68040). Whereas -O0 and -O2 work but -O1 fails
 	for sun3 (TME, 68020 emulator) and sun2 (TME, 68010 emulator).
 kcah
+
+port	alpha
+hack	compile __realpath in gdb/gnulib/canonicalize-lgpl.c with -O0 (PR/56153)
+cdate	Sat May  8 08:24:49 EDT 2021
+mdate	Sat May  8 08:24:49 EDT 2021
+who	christos
+file	src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c: 1.2
+descr	For alpha gcc-9 and gcc-10 miscompile the malloca macro leading to
+allocation from the stack and freeing with regular free which causes
+	a crash.
+kcah



CVS commit: src/external/gpl3/gdb/dist/gnulib/import

2021-05-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  8 12:23:47 UTC 2021

Modified Files:
src/external/gpl3/gdb/dist/gnulib/import: canonicalize-lgpl.c

Log Message:
PR/56153: Rin Okuyama: alpha miscompiles malloca() macro.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c

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

Modified files:

Index: src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c
diff -u src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c:1.1.1.1 src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c:1.2
--- src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c:1.1.1.1	Mon Sep 14 21:43:50 2020
+++ src/external/gpl3/gdb/dist/gnulib/import/canonicalize-lgpl.c	Sat May  8 08:23:47 2021
@@ -114,6 +114,13 @@ alloc_failed (void)
holds the same value as the value returned.  */
 
 char *
+#ifdef __alpha__
+/*
+ * toolchain/56153
+ * GCC 10 and 9 miscompile malloca() macro for alpha.
+ */
+__attribute__((optimize("O0")))
+#endif
 __realpath (const char *name, char *resolved)
 {
   char *rpath, *dest, *extra_buf = NULL;



CVS commit: [thorpej-i2c-spi-conf] src/sys/arch/macppc/dev

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 11:40:02 UTC 2021

Modified Files:
src/sys/arch/macppc/dev [thorpej-i2c-spi-conf]: cuda.c videopll.c

Log Message:
Children of the "cuda" i2c controller don't appear in the OF device tree,
so we need to supply our own "i2c-enumerate-devices" method.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/arch/macppc/dev/cuda.c
cvs rdiff -u -r1.3 -r1.3.18.1 src/sys/arch/macppc/dev/videopll.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.28 src/sys/arch/macppc/dev/cuda.c:1.28.2.1
--- src/sys/arch/macppc/dev/cuda.c:1.28	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/cuda.c	Sat May  8 11:40:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cuda.c,v 1.28 2021/04/24 23:36:41 thorpej Exp $ */
+/*	$NetBSD: cuda.c,v 1.28.2.1 2021/05/08 11:40:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.28 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.28.2.1 2021/05/08 11:40:02 thorpej Exp $");
 
 #include 
 #include 
@@ -72,6 +72,8 @@ typedef struct _cuda_handler {
 	void *cookie;
 } CudaHandler;
 
+#define	CUDA_MAX_I2C_DEVICES	2
+
 struct cuda_softc {
 	device_t sc_dev;
 	void *sc_ih;
@@ -81,6 +83,20 @@ struct cuda_softc {
 	struct i2c_controller sc_i2c;
 	bus_space_tag_t sc_memt;
 	bus_space_handle_t sc_memh;
+
+	/*
+	 * We provide our own i2c device enumeration method, so we
+	 * need to provide our own devhandle_impl.
+	 */
+	struct devhandle_impl sc_devhandle_impl;
+
+	struct {
+		const char *name;
+		const char *compatible;
+		i2c_addr_t addr;
+	} sc_i2c_devices[CUDA_MAX_I2C_DEVICES];
+	int sc_ni2c_devices;
+
 	int sc_node;
 	int sc_state;
 	int sc_waiting;
@@ -147,6 +163,65 @@ static	int cuda_adb_set_handler(void *, 
 static int cuda_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t,
 		void *, size_t, int);
 
+static void
+cuda_add_i2c_device(struct cuda_softc *sc, const char *name,
+const char *compatible, i2c_addr_t addr)
+{
+	KASSERT(sc->sc_ni2c_devices < CUDA_MAX_I2C_DEVICES);
+	sc->sc_i2c_devices[sc->sc_ni2c_devices].name = name;
+	sc->sc_i2c_devices[sc->sc_ni2c_devices].compatible = compatible;
+	sc->sc_i2c_devices[sc->sc_ni2c_devices].addr = addr;
+	sc->sc_ni2c_devices++;
+}
+
+static int
+cuda_i2c_enumerate_devices(device_t dev, devhandle_t call_handle, void *v)
+{
+	struct i2c_enumerate_devices_args *args = v;
+	prop_dictionary_t props;
+	int i;
+	bool cbrv;
+
+	/* dev is the "iicbus" instance.  Cuda softc is in args. */
+	struct cuda_softc *sc = args->ia->ia_tag->ic_cookie;
+
+	for (i = 0; i < sc->sc_ni2c_devices; i++) {
+		props = prop_dictionary_create();
+
+		args->ia->ia_addr = sc->sc_i2c_devices[i].addr;
+		args->ia->ia_name = sc->sc_i2c_devices[i].name;
+		args->ia->ia_clist = sc->sc_i2c_devices[i].compatible;
+		args->ia->ia_clist_size = strlen(args->ia->ia_clist) + 1;
+		args->ia->ia_prop = props;
+		/* Child gets no handle. */
+		devhandle_invalidate(>ia->ia_devhandle);
+		args->ia->ia_cookie = 0;			/* XXX */
+		args->ia->ia_cookietype = I2C_COOKIE_NONE;	/* XXX */
+
+		cbrv = args->callback(dev, args);
+
+		prop_object_release(props);
+
+		if (!cbrv) {
+			break;	/* callback decides if we continue */
+		}
+	}
+
+	return 0;
+}
+
+static device_call_t
+cuda_devhandle_lookup_device_call(devhandle_t handle, const char *name,
+devhandle_t *call_handlep)
+{
+	if (strcmp(name, "i2c-enumerate-devices") == 0) {
+		return cuda_i2c_enumerate_devices;
+	}
+
+	/* Defer everything else to the "super". */
+	return NULL;
+}
+
 static int
 cuda_match(device_t parent, struct cfdata *cf, void *aux)
 {
@@ -172,9 +247,6 @@ cuda_attach(device_t parent, device_t se
 	struct cuda_softc *sc = device_private(self);
 	struct i2cbus_attach_args iba;
 	static struct cuda_attach_args caa;
-	prop_dictionary_t dict = device_properties(self);
-	prop_dictionary_t dev;
-	prop_array_t cfg;
 	int irq = ca->ca_intr[0];
 	int node, i, child;
 	char name[32];
@@ -252,37 +324,41 @@ cuda_attach(device_t parent, device_t se
 #if notyet
 	config_found(self, , cuda_print, CFARG_EOL);
 #endif
-	cfg = prop_array_create();
-	prop_dictionary_set(dict, "i2c-child-devices", cfg);
-	prop_object_release(cfg);
-
 	/* we don't have OF nodes for i2c devices so we have to make our own */
-
 	node = OF_finddevice("/valkyrie");
 	if (node != -1) {
-		dev = prop_dictionary_create();
-		prop_dictionary_set_string(dev, "name", "videopll");
-		prop_dictionary_set_uint32(dev, "addr", 0x50);
-		prop_array_add(cfg, dev);
-		prop_object_release(dev);
+		/* XXX a real "compatible" string would be nice... */
+		cuda_add_i2c_device(sc, "videopll",
+		"aapl,valkyrie-videopll", 0x50);
 	}
 
 	node = OF_finddevice("/perch");
 	if (node != -1) {
-		dev = 

CVS commit: [thorpej-i2c-spi-conf] src/sys/dev/i2c

2021-05-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 11:34:38 UTC 2021

Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: i2c.c

Log Message:
iic_print_direct(): In the "not configured" case, parenthetically print
the first element of the compat list, if we got a compat list.


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

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

Modified files:

Index: src/sys/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.78.2.1 src/sys/dev/i2c/i2c.c:1.78.2.2
--- src/sys/dev/i2c/i2c.c:1.78.2.1	Sun Apr 25 21:45:15 2021
+++ src/sys/dev/i2c/i2c.c	Sat May  8 11:34:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.78.2.1 2021/04/25 21:45:15 thorpej Exp $	*/
+/*	$NetBSD: i2c.c,v 1.78.2.2 2021/05/08 11:34:38 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.78.2.1 2021/04/25 21:45:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.78.2.2 2021/05/08 11:34:38 thorpej Exp $");
 
 #include 
 #include 
@@ -135,8 +135,11 @@ iic_print_direct(void *aux, const char *
 	struct i2c_attach_args *ia = aux;
 
 	if (pnp != NULL)
-		aprint_normal("%s at %s addr 0x%02x",
+		aprint_normal("%s%s%s%s at %s addr 0x%02x",
 			  ia->ia_name ? ia->ia_name : "(unknown)",
+			  ia->ia_clist ? " (" : "",
+			  ia->ia_clist ? ia->ia_clist : "",
+			  ia->ia_clist ? ")" : "",
 			  pnp, ia->ia_addr);
 	else
 		aprint_normal(" addr 0x%02x", ia->ia_addr);



CVS commit: [netbsd-9] src/doc

2021-05-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May  8 10:29:10 UTC 2021

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

Log Message:
Ticket #1269


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.79 -r1.1.2.80 src/doc/CHANGES-9.2

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

Modified files:

Index: src/doc/CHANGES-9.2
diff -u src/doc/CHANGES-9.2:1.1.2.79 src/doc/CHANGES-9.2:1.1.2.80
--- src/doc/CHANGES-9.2:1.1.2.79	Wed May  5 17:03:08 2021
+++ src/doc/CHANGES-9.2	Sat May  8 10:29:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.2,v 1.1.2.79 2021/05/05 17:03:08 martin Exp $
+# $NetBSD: CHANGES-9.2,v 1.1.2.80 2021/05/08 10:29:10 martin Exp $
 
 A complete list of changes from the NetBSD 9.1 release to the NetBSD 9.2
 release:
@@ -3084,3 +3084,9 @@ sys/dev/audio/audio.c1.95
 	audio: do not prefer surround formats.
 	[nia, ticket #1268]
 
+etc/etc.mac68k/ttys1.21
+
+	mac68k: turn on constty instead of ttyE0 and change default TERM
+	to vt100 for console and constty.
+	[rin, ticket #1269]
+



CVS commit: [netbsd-9] src/etc/etc.mac68k

2021-05-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May  8 10:27:47 UTC 2021

Modified Files:
src/etc/etc.mac68k [netbsd-9]: ttys

Log Message:
Pull up following revision(s) (requested by rin in ticket #1269):

etc/etc.mac68k/ttys: revision 1.21

Turn on constty instead of ttyE0 as done for majority of other ports
in order to make both framebuffer and serial consoles happy.

Also, change TERM from vt220 to vt100 for console and constty
in accordance with other ports.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.36.1 src/etc/etc.mac68k/ttys

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

Modified files:

Index: src/etc/etc.mac68k/ttys
diff -u src/etc/etc.mac68k/ttys:1.20 src/etc/etc.mac68k/ttys:1.20.36.1
--- src/etc/etc.mac68k/ttys:1.20	Wed Jun 13 20:49:14 2012
+++ src/etc/etc.mac68k/ttys	Sat May  8 10:27:47 2021
@@ -1,16 +1,16 @@
 #
-#	$NetBSD: ttys,v 1.20 2012/06/13 20:49:14 martin Exp $
+#	$NetBSD: ttys,v 1.20.36.1 2021/05/08 10:27:47 martin Exp $
 #	from: @(#)ttys	5.1 (Berkeley) 4/17/89
 #
 # name	gettytype	status		comments
 #
 # If the console is marked insecure, single-user requires
 # the root password.
-console	"/usr/libexec/getty Pc"		vt220	off secure
-constty	"/usr/libexec/getty Pc"		vt220	off secure
+console	"/usr/libexec/getty Pc"		vt100	off secure
+constty	"/usr/libexec/getty Pc"		vt100	on secure
 
 # Define the console that we actually run getty on.
-ttyE0	"/usr/libexec/getty Pc"		wsvt25	on secure
+ttyE0	"/usr/libexec/getty Pc"		wsvt25	off secure
 
 # Mac Build-in serial ports
 ttyZ0	"/usr/libexec/getty std.9600"	unknown off secure



CVS commit: src/etc/etc.mac68k

2021-05-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  8 10:08:33 UTC 2021

Modified Files:
src/etc/etc.mac68k: ttys

Log Message:
Turn on constty instead of ttyE0 as done for majority of other ports
in order to make both framebuffer and serial consoles happy.

Also, change TERM from vt220 to vt100 for console and constty
in accordance with other ports.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/etc/etc.mac68k/ttys

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

Modified files:

Index: src/etc/etc.mac68k/ttys
diff -u src/etc/etc.mac68k/ttys:1.20 src/etc/etc.mac68k/ttys:1.21
--- src/etc/etc.mac68k/ttys:1.20	Wed Jun 13 20:49:14 2012
+++ src/etc/etc.mac68k/ttys	Sat May  8 10:08:33 2021
@@ -1,16 +1,16 @@
 #
-#	$NetBSD: ttys,v 1.20 2012/06/13 20:49:14 martin Exp $
+#	$NetBSD: ttys,v 1.21 2021/05/08 10:08:33 rin Exp $
 #	from: @(#)ttys	5.1 (Berkeley) 4/17/89
 #
 # name	gettytype	status		comments
 #
 # If the console is marked insecure, single-user requires
 # the root password.
-console	"/usr/libexec/getty Pc"		vt220	off secure
-constty	"/usr/libexec/getty Pc"		vt220	off secure
+console	"/usr/libexec/getty Pc"		vt100	off secure
+constty	"/usr/libexec/getty Pc"		vt100	on secure
 
 # Define the console that we actually run getty on.
-ttyE0	"/usr/libexec/getty Pc"		wsvt25	on secure
+ttyE0	"/usr/libexec/getty Pc"		wsvt25	off secure
 
 # Mac Build-in serial ports
 ttyZ0	"/usr/libexec/getty std.9600"	unknown off secure



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

2021-05-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  8 09:23:37 UTC 2021

Modified Files:
src/distrib/sets/lists/debug: mi

Log Message:
Add missing aiomixer.debug to fix debug build.

XXX
I *really* hope someone(TM) invent better replacement of
distrib/sets/lists...


To generate a diff of this commit:
cvs rdiff -u -r1.351 -r1.352 src/distrib/sets/lists/debug/mi

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.351 src/distrib/sets/lists/debug/mi:1.352
--- src/distrib/sets/lists/debug/mi:1.351	Fri Apr 23 22:50:06 2021
+++ src/distrib/sets/lists/debug/mi	Sat May  8 09:23:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.351 2021/04/23 22:50:06 mrg Exp $
+# $NetBSD: mi,v 1.352 2021/05/08 09:23:37 rin Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -460,6 +460,7 @@
 ./usr/libdata/debug/usr/bin/addftinfo.debug	comp-groff-debug	groff,debug
 ./usr/libdata/debug/usr/bin/addr2line.debug	comp-debug-debug	binutils,debug
 ./usr/libdata/debug/usr/bin/agrep.debug		comp-util-debug		debug
+./usr/libdata/debug/usr/bin/aiomixer.debug	comp-audio-debug	debug
 ./usr/libdata/debug/usr/bin/apply.debug		comp-util-debug		debug
 ./usr/libdata/debug/usr/bin/apropos.debug	comp-man-debug		debug
 ./usr/libdata/debug/usr/bin/ar.debug		comp-util-debug		binutils,debug



CVS commit: src/sys/arch/vax/vsa

2021-05-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  8 09:03:30 UTC 2021

Modified Files:
src/sys/arch/vax/vsa: tc_vsbus.c

Log Message:
Catch up with this commit:

http://www.nerv.org/netbsd/?q=id:20210507T165558Z.d4aba9e0e053181f2a98ee4ee43012b50949921b

by which per slot tcs_used flag was obsoleted.

No need to initialize __BIT(0) of sc_slots_used here; it is zero anyway
before calling tcattach().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/vax/vsa/tc_vsbus.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/vax/vsa/tc_vsbus.c
diff -u src/sys/arch/vax/vsa/tc_vsbus.c:1.9 src/sys/arch/vax/vsa/tc_vsbus.c:1.10
--- src/sys/arch/vax/vsa/tc_vsbus.c:1.9	Fri Jun  9 18:02:40 2017
+++ src/sys/arch/vax/vsa/tc_vsbus.c	Sat May  8 09:03:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tc_vsbus.c,v 1.9 2017/06/09 18:02:40 flxd Exp $	*/
+/*	$NetBSD: tc_vsbus.c,v 1.10 2021/05/08 09:03:30 rin Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.9 2017/06/09 18:02:40 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.10 2021/05/08 09:03:30 rin Exp $");
 
 #include 
 #include 
@@ -252,7 +252,6 @@ tc_vsbus_attach(device_t parent, device_
 	/* Pass pre-mapped space for TC drivers not bus_space'ified yet. */
 	sc->sc_slots[0].tcs_addr = (tc_addr_t)bus_space_vaddr(bst, bsh_slot);
 	sc->sc_slots[0].tcs_cookie = sc;
-	sc->sc_slots[0].tcs_used = 0;
 
 	tba.tba_busname = "tc";
 	/* Tag with custom methods for pre-mapped bus_space. */