diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/armv7/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/crosec.c | 4 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exiic.c | 131 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exiicvar.h | 27 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/files.exynos | 4 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/tps65090.c | 4 |
7 files changed, 64 insertions, 114 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index 48c98dab856..fa6f795ebcd 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.74 2017/03/05 20:53:19 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.75 2017/03/06 06:50:47 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -121,7 +121,7 @@ exsysreg* at fdt? early 1 exmct* at fdt? early 1 exdog* at fdt? exgpio* at fdt? early 1 -exiic* at exynos? +exiic* at fdt? iic* at exiic? exehci* at fdt? usb* at exehci? diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 515fccfeb11..2e90f5c9b23 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.69 2017/03/05 21:03:17 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.70 2017/03/06 06:50:47 kettenis Exp $ machine armv7 arm @@ -117,7 +117,7 @@ exsysreg* at fdt? early 1 exmct* at fdt? early 1 exdog* at fdt? exgpio* at fdt? early 1 -exiic* at exynos? +exiic* at fdt? iic* at exiic? exehci* at fdt? usb* at exehci? diff --git a/sys/arch/armv7/exynos/crosec.c b/sys/arch/armv7/exynos/crosec.c index 8507847f1cc..5b52060887f 100644 --- a/sys/arch/armv7/exynos/crosec.c +++ b/sys/arch/armv7/exynos/crosec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crosec.c,v 1.2 2016/06/10 06:42:53 jsg Exp $ */ +/* $OpenBSD: crosec.c,v 1.3 2017/03/06 06:50:47 kettenis Exp $ */ /* * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> * @@ -55,7 +55,7 @@ cros_ec_match(struct device *parent, void *match, void *aux) { struct i2c_attach_args *ia = aux; - if (strcmp(ia->ia_name, "crosec") == 0) + if (strcmp(ia->ia_name, "google,cros-ec-i2c") == 0) return 1; return 0; } diff --git a/sys/arch/armv7/exynos/exiic.c b/sys/arch/armv7/exynos/exiic.c index c69c94563d7..3b6db80fec7 100644 --- a/sys/arch/armv7/exynos/exiic.c +++ b/sys/arch/armv7/exynos/exiic.c @@ -15,18 +15,19 @@ */ #include <sys/param.h> -#include <sys/device.h> -#include <sys/kernel.h> -#include <sys/kthread.h> -#include <sys/malloc.h> #include <sys/systm.h> +#include <sys/device.h> +#include <sys/rwlock.h> + #include <machine/bus.h> -#if NFDT > 0 #include <machine/fdt.h> -#endif -#include <armv7/armv7/armv7var.h> -#include <armv7/exynos/exiicvar.h> +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_pinctrl.h> +#include <dev/ofw/fdt.h> + +#include <dev/i2c/i2cvar.h> + #include <armv7/exynos/exclockvar.h> /* registers */ @@ -66,7 +67,7 @@ struct exiic_softc { bus_space_handle_t sc_ioh; bus_size_t sc_ios; void *sc_ih; - int unit; + int sc_node; struct rwlock sc_buslock; struct i2c_controller i2c_tag; @@ -75,10 +76,10 @@ struct exiic_softc { uint16_t intr_status; }; -int exiic_match(struct device *parent, void *v, void *aux); +int exiic_match(struct device *, void *, void *); void exiic_attach(struct device *, struct device *, void *); int exiic_detach(struct device *, int); -void exiic_bus_scan(struct device *, struct i2cbus_attach_args *, void *); +void exiic_scan(struct device *, struct i2cbus_attach_args *, void *); void exiic_setspeed(struct exiic_softc *, int); int exiic_intr(void *); int exiic_wait_intr(struct exiic_softc *, int, int); @@ -103,9 +104,6 @@ int exiic_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t, struct cfattach exiic_ca = { - sizeof(struct exiic_softc), NULL, exiic_attach, exiic_detach -}; -struct cfattach exiic_fdt_ca = { sizeof(struct exiic_softc), exiic_match, exiic_attach, exiic_detach }; @@ -114,47 +112,27 @@ struct cfdriver exiic_cd = { }; int -exiic_match(struct device *parent, void *v, void *aux) +exiic_match(struct device *parent, void *match, void *aux) { -#if NFDT > 0 - struct armv7_attach_args *aa = aux; + struct fdt_attach_args *faa = aux; - if (fdt_node_compatible("samsung,s3c2440-i2c", aa->aa_node)) - return 1; -#endif - - return 0; + return OF_is_compatible(faa->fa_node, "samsung,s3c2440-i2c"); } void -exiic_attach(struct device *parent, struct device *self, void *args) +exiic_attach(struct device *parent, struct device *self, void *aux) { struct exiic_softc *sc = (struct exiic_softc *)self; - struct armv7_attach_args *aa = args; - struct armv7mem mem; - - sc->sc_iot = aa->aa_iot; -#if NFDT > 0 - if (aa->aa_node) { - struct fdt_reg reg; - static int unit = 0; - - sc->unit = unit++; - if (fdt_get_reg(aa->aa_node, 0, ®)) - panic("%s: could not extract memory data from FDT", - __func__); - mem.addr = reg.addr; - mem.size = reg.size; - } else -#endif - { - mem.addr = aa->aa_dev->mem[0].addr; - mem.size = aa->aa_dev->mem[0].size; - sc->unit = aa->aa_dev->unit; - } - if (bus_space_map(sc->sc_iot, mem.addr, mem.size, 0, &sc->sc_ioh)) + struct fdt_attach_args *faa = aux; + struct i2cbus_attach_args iba; + + pinctrl_byname(faa->fa_node, "default"); + + sc->sc_iot = faa->fa_iot; + sc->sc_node = faa->fa_node; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) panic("%s: bus_space_map failed!", __func__); - sc->sc_ios = mem.size; #if 0 sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_BIO, @@ -165,8 +143,6 @@ exiic_attach(struct device *parent, struct device *self, void *args) rw_init(&sc->sc_buslock, sc->sc_dev.dv_xname); - struct i2cbus_attach_args iba; - sc->i2c_tag.ic_cookie = sc; sc->i2c_tag.ic_acquire_bus = exiic_i2c_acquire_bus; sc->i2c_tag.ic_release_bus = exiic_i2c_release_bus; @@ -175,40 +151,41 @@ exiic_attach(struct device *parent, struct device *self, void *args) bzero(&iba, sizeof iba); iba.iba_name = "iic"; iba.iba_tag = &sc->i2c_tag; - iba.iba_bus_scan = exiic_bus_scan; - iba.iba_bus_scan_arg = sc; + iba.iba_bus_scan = exiic_scan; + iba.iba_bus_scan_arg = &sc->sc_node; config_found(&sc->sc_dev, &iba, NULL); } void -exiic_bus_scan(struct device *self, struct i2cbus_attach_args *iba, void *arg) +exiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux) { - struct exiic_softc *sc = (struct exiic_softc *)arg; + int iba_node = *(int *)aux; + extern int iic_print(void *, const char *); struct i2c_attach_args ia; - - /* XXX: We currently only attach cros-ec on I2C4. We'll use FDT later. */ - if (sc->unit != 4) - return; - - char *name = "crosec"; - int addr = 0x1e; - - memset(&ia, 0, sizeof(ia)); - ia.ia_tag = iba->iba_tag; - ia.ia_addr = addr; - ia.ia_size = 1; - ia.ia_name = name; - config_found(self, &ia, iicbus_print); - - name = "tps65090"; - addr = 0x48; - - memset(&ia, 0, sizeof(ia)); - ia.ia_tag = iba->iba_tag; - ia.ia_addr = addr; - ia.ia_size = 1; - ia.ia_name = name; - config_found(self, &ia, iicbus_print); + char name[32]; + uint32_t reg[1]; + int node; + + for (node = OF_child(iba_node); node; node = OF_peer(node)) { + memset(name, 0, sizeof(name)); + memset(reg, 0, sizeof(reg)); + + if (OF_getprop(node, "compatible", name, sizeof(name)) == -1) + continue; + if (name[0] == '\0') + continue; + + if (OF_getprop(node, "reg", ®, sizeof(reg)) != sizeof(reg)) + continue; + + memset(&ia, 0, sizeof(ia)); + ia.ia_tag = iba->iba_tag; + ia.ia_addr = bemtoh32(®[0]); + ia.ia_name = name; + ia.ia_cookie = &node; + + config_found(self, &ia, iic_print); + } } void diff --git a/sys/arch/armv7/exynos/exiicvar.h b/sys/arch/armv7/exynos/exiicvar.h deleted file mode 100644 index 8a70257be22..00000000000 --- a/sys/arch/armv7/exynos/exiicvar.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef EXIICVAR_H -#define EXIICVAR_H - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/systm.h> -#include <sys/rwlock.h> - -#include <dev/i2c/i2cvar.h> - -#endif diff --git a/sys/arch/armv7/exynos/files.exynos b/sys/arch/armv7/exynos/files.exynos index d8a02f5f6ff..d9f5f328b96 100644 --- a/sys/arch/armv7/exynos/files.exynos +++ b/sys/arch/armv7/exynos/files.exynos @@ -1,4 +1,4 @@ -# $OpenBSD: files.exynos,v 1.7 2017/03/05 20:53:19 kettenis Exp $ +# $OpenBSD: files.exynos,v 1.8 2017/03/06 06:50:47 kettenis Exp $ define exynos {} device exynos: exynos @@ -42,7 +42,7 @@ attach exgpio at fdt file arch/armv7/exynos/exgpio.c exgpio device exiic: i2cbus -attach exiic at exynos +attach exiic at fdt file arch/armv7/exynos/exiic.c exiic device exehci: usbus diff --git a/sys/arch/armv7/exynos/tps65090.c b/sys/arch/armv7/exynos/tps65090.c index ca80e304b7e..8197a8654f0 100644 --- a/sys/arch/armv7/exynos/tps65090.c +++ b/sys/arch/armv7/exynos/tps65090.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tps65090.c,v 1.2 2015/07/19 02:41:39 bmercer Exp $ */ +/* $OpenBSD: tps65090.c,v 1.3 2017/03/06 06:50:47 kettenis Exp $ */ /* * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> * @@ -97,7 +97,7 @@ tps65090_match(struct device *parent, void *match, void *aux) { struct i2c_attach_args *ia = aux; - if (strcmp(ia->ia_name, "tps65090") == 0) + if (strcmp(ia->ia_name, "ti,tps65090") == 0) return (1); return (0); } |