Module Name:src
Committed By: thorpej
Date: Fri May 14 03:11:49 UTC 2021
Modified Files:
src/sys/arch/sparc64/dev [thorpej-i2c-spi-conf]: jbus-i2c.c
Log Message:
Adapt jbusi2c to the new i2c device enumeration scheme.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/arch/sparc64/dev/jbus-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/arch/sparc64/dev/jbus-i2c.c
diff -u src/sys/arch/sparc64/dev/jbus-i2c.c:1.6 src/sys/arch/sparc64/dev/jbus-i2c.c:1.6.2.1
--- src/sys/arch/sparc64/dev/jbus-i2c.c:1.6 Sat Apr 24 23:36:49 2021
+++ src/sys/arch/sparc64/dev/jbus-i2c.c Fri May 14 03:11:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: jbus-i2c.c,v 1.6 2021/04/24 23:36:49 thorpej Exp $ */
+/* $NetBSD: jbus-i2c.c,v 1.6.2.1 2021/05/14 03:11:49 thorpej Exp $ */
/*
* Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include
-__KERNEL_RCSID(0, "$NetBSD: jbus-i2c.c,v 1.6 2021/04/24 23:36:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: jbus-i2c.c,v 1.6.2.1 2021/05/14 03:11:49 thorpej Exp $");
#include
#include
@@ -79,11 +79,8 @@ struct jbusi2c_softc {
struct i2c_controller sc_i2c;
bus_space_tag_t sc_bustag;
bus_space_handle_t sc_regh;
- int sc_node;
};
-static void jbusi2c_setup_i2c(struct jbusi2c_softc *);
-
CFATTACH_DECL_NEW(jbusi2c, sizeof(struct jbusi2c_softc),
jbusi2c_match, jbusi2c_attach, NULL, NULL);
@@ -112,11 +109,11 @@ jbusi2c_attach(device_t parent, device_t
{
struct jbusi2c_softc *sc = device_private(self);
struct mainbus_attach_args *ma = aux;
+ struct i2cbus_attach_args iba;
aprint_normal(": addr %" PRIx64 "\n", ma->ma_reg[0].ur_paddr);
sc->sc_dev = self;
- sc->sc_node = ma->ma_node;
sc->sc_bustag = ma->ma_bustag;
if (bus_space_map(sc->sc_bustag, ma->ma_reg[0].ur_paddr, 16, 0,
@@ -125,21 +122,6 @@ jbusi2c_attach(device_t parent, device_t
return;
}
- jbusi2c_setup_i2c(sc);
-}
-
-
-
-static void
-jbusi2c_setup_i2c(struct jbusi2c_softc *sc)
-{
- struct i2cbus_attach_args iba;
- prop_array_t cfg;
- prop_dictionary_t dev;
- prop_dictionary_t dict = device_properties(sc->sc_dev);
- int devs, regs[2], addr;
- char name[64], compat[256];
-
iic_tag_init(>sc_i2c);
sc->sc_i2c.ic_cookie = sc;
sc->sc_i2c.ic_send_start = jbusi2c_i2c_send_start;
@@ -148,37 +130,11 @@ jbusi2c_setup_i2c(struct jbusi2c_softc *
sc->sc_i2c.ic_read_byte = jbusi2c_i2c_read_byte;
sc->sc_i2c.ic_write_byte = jbusi2c_i2c_write_byte;
- /* round up i2c devices */
- devs = OF_child(sc->sc_node);
- cfg = prop_array_create();
- prop_dictionary_set(dict, "i2c-child-devices", cfg);
- prop_object_release(cfg);
- while (devs != 0) {
- if (OF_getprop(devs, "name", name, 256) <= 0)
- goto skip;
- memset(compat, 0, sizeof(compat));
- if (OF_getprop(devs, "compatible",
- compat, 255) <= 0)
- goto skip;
- if (OF_getprop(devs, "reg", regs, 8) <= 0)
- goto skip;
- if (regs[0] != 0) goto skip;
- addr = (regs[1] & 0xff) >> 1;
- DPRINTF("-> %s@%d,%x\n", name, regs[0], addr);
- dev = prop_dictionary_create();
- prop_dictionary_set_string(dev, "name", name);
- prop_dictionary_set_data(dev, "compatible", compat,
- strlen(compat)+1);
- prop_dictionary_set_uint32(dev, "addr", addr);
- prop_dictionary_set_uint64(dev, "cookie", devs);
- prop_array_add(cfg, dev);
- prop_object_release(dev);
- skip:
- devs = OF_peer(devs);
- }
memset(, 0, sizeof(iba));
iba.iba_tag = >sc_i2c;
- config_found(sc->sc_dev, , iicbus_print, CFARG_EOL);
+ config_found(sc->sc_dev, , iicbus_print,
+ CFARG_DEVHANDLE, device_handle(self),
+ CFARG_EOL);
}
static inline void