Module Name:    src
Committed By:   thorpej
Date:           Sun Sep 12 23:13:02 UTC 2021

Modified Files:
        src/sys/arch/sparc64/dev [thorpej-i2c-spi-conf2]: pcfiic_ebus.c
        src/sys/dev/ic [thorpej-i2c-spi-conf2]: pcf8584.c

Log Message:
- Improve some comments.
- Update pcfiic_i2c_exec() for the channel split (might fix an issue
  spotted by tnn@ in testing).


To generate a diff of this commit:
cvs rdiff -u -r1.7.16.1 -r1.7.16.2 src/sys/arch/sparc64/dev/pcfiic_ebus.c
cvs rdiff -u -r1.19.2.1 -r1.19.2.2 src/sys/dev/ic/pcf8584.c

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

Modified files:

Index: src/sys/arch/sparc64/dev/pcfiic_ebus.c
diff -u src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.7.16.1 src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.7.16.2
--- src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.7.16.1	Mon Aug  9 00:30:08 2021
+++ src/sys/arch/sparc64/dev/pcfiic_ebus.c	Sun Sep 12 23:13:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcfiic_ebus.c,v 1.7.16.1 2021/08/09 00:30:08 thorpej Exp $	*/
+/*	$NetBSD: pcfiic_ebus.c,v 1.7.16.2 2021/09/12 23:13:02 thorpej Exp $	*/
 /*	$OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7.16.1 2021/08/09 00:30:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7.16.2 2021/09/12 23:13:02 thorpej Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -167,7 +167,13 @@ bbc_initialize_channels(struct pcfiic_eb
 
 	nchannels = popcount(busmap);
 	if (nchannels == 0) {
-		/* No child devices. */
+		/*
+		 * No child devices in the device tree.  This is fine;
+		 * the generic code will just assume a single channel
+		 * and attach a bus instance, but our MUX will still
+		 * get programmed correctly because we've initialized
+		 * the acquire/release bus funcitons.
+		 */
 		return;
 	}
 

Index: src/sys/dev/ic/pcf8584.c
diff -u src/sys/dev/ic/pcf8584.c:1.19.2.1 src/sys/dev/ic/pcf8584.c:1.19.2.2
--- src/sys/dev/ic/pcf8584.c:1.19.2.1	Mon Aug  9 01:29:52 2021
+++ src/sys/dev/ic/pcf8584.c	Sun Sep 12 23:13:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8584.c,v 1.19.2.1 2021/08/09 01:29:52 thorpej Exp $	*/
+/*	$NetBSD: pcf8584.c,v 1.19.2.2 2021/09/12 23:13:02 thorpej Exp $	*/
 /*	$OpenBSD: pcf8584.c,v 1.9 2007/10/20 18:46:21 kettenis Exp $ */
 
 /*
@@ -120,9 +120,17 @@ pcfiic_attach(struct pcfiic_softc *sc, i
 
 	printf("\n");
 
+	/*
+	 * Sun has a clone of this chip that also has an
+	 * associated MUX, which means we treat this as
+	 * a multi-channel controller.  If the front-end
+	 * did not already allocate channels for us, then
+	 * assume we're just a simple single-channel device.
+	 */
+
 	if (sc->sc_channels == NULL) {
 		KASSERT(sc->sc_nchannels == 0);
-		ch = kmem_alloc(sizeof(*sc->sc_channels), KM_SLEEP);
+		ch = kmem_alloc(sizeof(*ch), KM_SLEEP);
 		ch->ch_channel = 0;
 		ch->ch_devhandle = device_handle(sc->sc_dev);
 
@@ -139,6 +147,7 @@ pcfiic_attach(struct pcfiic_softc *sc, i
 		ch->ch_sc = sc;
 		iic_tag_init(&ch->ch_i2c);
 		ch->ch_i2c.ic_cookie = ch;
+		ch->ch_i2c.ic_channel = ch->ch_channel;
 		ch->ch_i2c.ic_exec = pcfiic_i2c_exec;
 		ch->ch_i2c.ic_acquire_bus = sc->sc_acquire_bus;
 		ch->ch_i2c.ic_release_bus = sc->sc_release_bus;
@@ -165,7 +174,8 @@ int
 pcfiic_i2c_exec(void *arg, i2c_op_t op, i2c_addr_t addr,
     const void *cmdbuf, size_t cmdlen, void *buf, size_t len, int flags)
 {
-	struct pcfiic_softc	*sc = arg;
+	struct pcfiic_channel	*ch = arg;
+	struct pcfiic_softc	*sc = ch->ch_sc;
 	int			ret = 0;
 
 #if 0

Reply via email to