diff options
author | 2017-07-25 11:01:28 +0000 | |
---|---|---|
committer | 2017-07-25 11:01:28 +0000 | |
commit | fe5dbe476cf4c4896041a8fff255ac2e7a02e845 (patch) | |
tree | 8916ee8cf1227beaad9106ddf584b39134da555a | |
parent | Make WinSCP patterns for SSH_OLD_DHGEX more specific to exclude WinSCP (diff) | |
download | wireguard-openbsd-fe5dbe476cf4c4896041a8fff255ac2e7a02e845.tar.xz wireguard-openbsd-fe5dbe476cf4c4896041a8fff255ac2e7a02e845.zip |
rework octuctl and its children to attach via fdt
ok visa@
-rw-r--r-- | sys/arch/octeon/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/octeon/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/octeon/conf/files.octeon | 4 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octehci.c | 12 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octeon_iobus.c | 4 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octohci.c | 16 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octuctl.c | 65 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octuctlreg.h | 9 | ||||
-rw-r--r-- | sys/arch/octeon/dev/octuctlvar.h | 7 |
9 files changed, 66 insertions, 59 deletions
diff --git a/sys/arch/octeon/conf/GENERIC b/sys/arch/octeon/conf/GENERIC index e791f7b0c53..d0c1d7fc13d 100644 --- a/sys/arch/octeon/conf/GENERIC +++ b/sys/arch/octeon/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.35 2017/07/13 12:50:50 visa Exp $ +# $OpenBSD: GENERIC,v 1.36 2017/07/25 11:01:28 jmatthew Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -71,7 +71,7 @@ wd* at pciide? flags 0x0000 # USB Controllers dwctwo0 at iobus? irq 56 -octuctl0 at iobus? irq 56 +octuctl* at fdt? ehci0 at octuctl? ohci0 at octuctl? diff --git a/sys/arch/octeon/conf/RAMDISK b/sys/arch/octeon/conf/RAMDISK index 1486f8bf979..e1d0a45e2b8 100644 --- a/sys/arch/octeon/conf/RAMDISK +++ b/sys/arch/octeon/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.33 2017/07/13 12:50:50 visa Exp $ +# $OpenBSD: RAMDISK,v 1.34 2017/07/25 11:01:28 jmatthew Exp $ machine octeon mips64 maxusers 4 @@ -62,7 +62,7 @@ pciide* at pci? flags 0x0000 wd* at pciide? flags 0x0000 dwctwo0 at iobus0 irq 56 -octuctl0 at iobus0 irq 56 +octuctl* at fdt? ehci0 at octuctl? ohci0 at octuctl? diff --git a/sys/arch/octeon/conf/files.octeon b/sys/arch/octeon/conf/files.octeon index 5549c6be693..9dec1c6d164 100644 --- a/sys/arch/octeon/conf/files.octeon +++ b/sys/arch/octeon/conf/files.octeon @@ -1,4 +1,4 @@ -# $OpenBSD: files.octeon,v 1.39 2017/07/13 12:50:50 visa Exp $ +# $OpenBSD: files.octeon,v 1.40 2017/07/25 11:01:28 jmatthew Exp $ # Standard stanzas config(8) can't run without maxpartitions 16 @@ -81,7 +81,7 @@ attach dwctwo at iobus with octdwctwo file arch/octeon/dev/octdwctwo.c octdwctwo needs-flag device octuctl {} -attach octuctl at iobus +attach octuctl at fdt file arch/octeon/dev/octuctl.c octuctl needs-flag attach ehci at octuctl with octehci file arch/octeon/dev/octehci.c octehci diff --git a/sys/arch/octeon/dev/octehci.c b/sys/arch/octeon/dev/octehci.c index e2fc2bd295c..f556abe50a0 100644 --- a/sys/arch/octeon/dev/octehci.c +++ b/sys/arch/octeon/dev/octehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octehci.c,v 1.2 2017/02/06 15:49:08 visa Exp $ */ +/* $OpenBSD: octehci.c,v 1.3 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2015 Jonathan Matthew <jmatthew@openbsd.org> @@ -57,11 +57,7 @@ int octehci_match(struct device *parent, void *match, void *aux) { struct octuctl_attach_args *aa = aux; - - if (strcmp(aa->aa_name, "ehci") != 0) - return (0); - - return (1); + return (OF_is_compatible(aa->aa_node, "cavium,octeon-6335-ehci")); } void @@ -77,7 +73,7 @@ octehci_attach(struct device *parent, struct device *self, void *aux) sc->sc_ehci.sc_bus.pipe_size = sizeof(struct usbd_pipe); sc->sc_ehci.sc_bus.dmatag = aa->aa_dmat; - rc = bus_space_map(sc->sc_ehci.iot, UCTL_EHCI_BASE, UCTL_EHCI_SIZE, + rc = bus_space_map(sc->sc_ehci.iot, aa->aa_reg.addr, aa->aa_reg.size, 0, &sc->sc_ehci.ioh); KASSERT(rc == 0); @@ -106,7 +102,7 @@ octehci_attach(struct device *parent, struct device *self, void *aux) printf(": init failed, error=%d\n", rc); octeon_intr_disestablish(sc->sc_ih); bus_space_unmap(sc->sc_ehci.iot, sc->sc_ehci.ioh, - UCTL_EHCI_SIZE); + aa->aa_reg.size); splx(s); return; } diff --git a/sys/arch/octeon/dev/octeon_iobus.c b/sys/arch/octeon/dev/octeon_iobus.c index 0b485b06bf9..7966dbd72ec 100644 --- a/sys/arch/octeon/dev/octeon_iobus.c +++ b/sys/arch/octeon/dev/octeon_iobus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octeon_iobus.c,v 1.21 2017/07/15 06:35:42 visa Exp $ */ +/* $OpenBSD: octeon_iobus.c,v 1.22 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2000-2004 Opsycon AB (www.opsycon.se) @@ -53,7 +53,6 @@ #include <octeon/dev/iobusvar.h> #include <octeon/dev/cn30xxgmxreg.h> #include <octeon/dev/octhcireg.h> /* USBN_BASE */ -#include <octeon/dev/octuctlreg.h> int iobusmatch(struct device *, void *, void *); void iobusattach(struct device *, struct device *, void *); @@ -153,7 +152,6 @@ static const struct octeon_iobus_addrs iobus_addrs[] = { { "octrng", OCTEON_RNG_BASE }, { "dwctwo", USBN_BASE }, { "amdcf", OCTEON_AMDCF_BASE}, - { "octuctl", UCTL_BASE }, }; /* There can only be one. */ diff --git a/sys/arch/octeon/dev/octohci.c b/sys/arch/octeon/dev/octohci.c index e23489b7153..3befa9791a5 100644 --- a/sys/arch/octeon/dev/octohci.c +++ b/sys/arch/octeon/dev/octohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octohci.c,v 1.1 2016/03/18 05:38:10 jmatthew Exp $ */ +/* $OpenBSD: octohci.c,v 1.2 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2015 Jonathan Matthew <jmatthew@openbsd.org> @@ -39,6 +39,7 @@ struct octohci_softc { struct ohci_softc sc_ohci; void *sc_ih; + uint64_t sc_reg_size; }; int octohci_match(struct device *, void *, void *); @@ -57,11 +58,7 @@ int octohci_match(struct device *parent, void *match, void *aux) { struct octuctl_attach_args *aa = aux; - - if (strcmp(aa->aa_name, "ohci") != 0) - return (0); - - return (1); + return (OF_is_compatible(aa->aa_node, "cavium,octeon-6335-ohci")); } void @@ -78,9 +75,10 @@ octohci_attach(struct device *parent, struct device *self, void *aux) sc->sc_ohci.sc_bus.pipe_size = sizeof(struct usbd_pipe); sc->sc_ohci.sc_bus.dmatag = aa->aa_dmat; - rc = bus_space_map(sc->sc_ohci.iot, UCTL_OHCI_BASE, UCTL_OHCI_SIZE, + rc = bus_space_map(sc->sc_ohci.iot, aa->aa_reg.addr, aa->aa_reg.size, 0, &sc->sc_ohci.ioh); KASSERT(rc == 0); + sc->sc_reg_size = aa->aa_reg.size; port_ctl = bus_space_read_8(aa->aa_octuctl_bust, aa->aa_ioh, UCTL_OHCI_CTL); @@ -112,7 +110,7 @@ octohci_attach(struct device *parent, struct device *self, void *aux) failed: octeon_intr_disestablish(sc->sc_ih); - bus_space_unmap(sc->sc_ohci.iot, sc->sc_ohci.ioh, UCTL_OHCI_SIZE); + bus_space_unmap(sc->sc_ohci.iot, sc->sc_ohci.ioh, sc->sc_reg_size); splx(s); return; } @@ -135,7 +133,7 @@ octohci_attach_deferred(struct device *self) sc->sc_ohci.sc_bus.bdev.dv_xname, r); octeon_intr_disestablish(sc->sc_ih); bus_space_unmap(sc->sc_ohci.iot, sc->sc_ohci.ioh, - UCTL_OHCI_SIZE); + sc->sc_reg_size); } else { config_found(self, &sc->sc_ohci.sc_bus, usbctlprint); } diff --git a/sys/arch/octeon/dev/octuctl.c b/sys/arch/octeon/dev/octuctl.c index d2791409bf1..98448c75f77 100644 --- a/sys/arch/octeon/dev/octuctl.c +++ b/sys/arch/octeon/dev/octuctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octuctl.c,v 1.1 2016/03/18 05:38:10 jmatthew Exp $ */ +/* $OpenBSD: octuctl.c,v 1.2 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2015 Jonathan Matthew <jmatthew@openbsd.org> @@ -24,7 +24,7 @@ #include <machine/bus.h> #include <machine/octeonreg.h> #include <machine/octeonvar.h> -#include <machine/octeon_model.h> +#include <machine/fdt.h> #include <octeon/dev/iobusvar.h> #include <octeon/dev/octuctlreg.h> @@ -108,15 +108,9 @@ octuctl_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint32_t int octuctl_match(struct device *parent, void *match, void *aux) { - int id; - - id = octeon_get_chipid(); - switch (octeon_model_family(id)) { - case OCTEON_MODEL_FAMILY_CN61XX: - return (1); - default: - return (0); - } + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "cavium,octeon-6335-uctl"); } int @@ -202,20 +196,40 @@ octuctl_clock_setup(struct octuctl_softc *sc, uint64_t ctl) void octuctl_attach(struct device *parent, struct device *self, void *aux) { + struct fdt_attach_args *faa = aux; struct octuctl_softc *sc = (struct octuctl_softc *)self; - struct iobus_attach_args *aa = aux; struct octuctl_attach_args uaa; uint64_t port_ctl; uint64_t ctl; uint64_t preg; uint64_t txvref; - int rc; + uint32_t reg[4]; int port; + int node; + int rc; - sc->sc_iot = aa->aa_bust; - rc = bus_space_map(sc->sc_iot, UCTL_BASE, UCTL_SIZE, - 0, &sc->sc_ioh); - KASSERT(rc == 0); + if (faa->fa_nreg != 1) { + printf(": expected one IO space, got %d\n", faa->fa_nreg); + return; + } + + sc->sc_iot = faa->fa_iot; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, + 0, &sc->sc_ioh)) { + printf(": could not map IO space\n"); + return; + } + + rc = OF_getpropint(faa->fa_node, "#address-cells", 0); + if (rc != 2) { + printf(": expected #address-cells 2, got %d\n", rc); + return; + } + rc = OF_getpropint(faa->fa_node, "#size-cells", 0); + if (rc != 2) { + printf(": expected #size-cells 2, got %d\n", rc); + return; + } /* do clock setup if not already done */ bus_space_write_8(sc->sc_iot, sc->sc_ioh, UCTL_IF_ENA, @@ -237,14 +251,19 @@ octuctl_attach(struct device *parent, struct device *self, void *aux) printf("\n"); - uaa.aa_octuctl_bust = aa->aa_bust; + uaa.aa_octuctl_bust = sc->sc_iot; uaa.aa_bust = &octuctl_tag; - uaa.aa_dmat = aa->aa_dmat; + uaa.aa_dmat = faa->fa_dmat; uaa.aa_ioh = sc->sc_ioh; - uaa.aa_name = "ehci"; - config_found(self, &uaa, octuctlprint); + for (node = OF_child(faa->fa_node); node != 0; node = OF_peer(node)) { + if (OF_getproplen(node, "reg") != sizeof(reg)) + continue; - uaa.aa_name = "ohci"; - config_found(self, &uaa, octuctlprint); + OF_getpropintarray(node, "reg", reg, sizeof(reg)); + uaa.aa_reg.addr = (((uint64_t)reg[0]) << 32) | reg[1]; + uaa.aa_reg.size = (((uint64_t)reg[2]) << 32) | reg[3]; + uaa.aa_node = node; + config_found(self, &uaa, octuctlprint); + } } diff --git a/sys/arch/octeon/dev/octuctlreg.h b/sys/arch/octeon/dev/octuctlreg.h index 5ead56add38..08bb46668c2 100644 --- a/sys/arch/octeon/dev/octuctlreg.h +++ b/sys/arch/octeon/dev/octuctlreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: octuctlreg.h,v 1.1 2016/03/18 05:38:10 jmatthew Exp $ */ +/* $OpenBSD: octuctlreg.h,v 1.2 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2015 Jonathan Matthew <jmatthew@openbsd.org> @@ -22,13 +22,6 @@ /* * UCTL - octeon II usb controller interface */ -#define UCTL_BASE 0x000118006f000000ull -#define UCTL_SIZE 0x100 - -#define UCTL_EHCI_BASE 0x00016f0000000000ull -#define UCTL_EHCI_SIZE 0x100 -#define UCTL_OHCI_BASE 0x00016f0000000400ull -#define UCTL_OHCI_SIZE 0x100 #define UCTL_CLK_TARGET_FREQ 130000000ull diff --git a/sys/arch/octeon/dev/octuctlvar.h b/sys/arch/octeon/dev/octuctlvar.h index 56a8d189a26..21d6ecd9edb 100644 --- a/sys/arch/octeon/dev/octuctlvar.h +++ b/sys/arch/octeon/dev/octuctlvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: octuctlvar.h,v 1.1 2016/03/18 05:38:10 jmatthew Exp $ */ +/* $OpenBSD: octuctlvar.h,v 1.2 2017/07/25 11:01:28 jmatthew Exp $ */ /* * Copyright (c) 2015 Jonathan Matthew <jmatthew@openbsd.org> @@ -20,13 +20,16 @@ #define _OCTUCTLVAR_H_ #include <machine/bus.h> +#include <dev/ofw/openfirm.h> +#include <dev/ofw/fdt.h> struct octuctl_attach_args { - char *aa_name; bus_space_tag_t aa_octuctl_bust; bus_space_tag_t aa_bust; bus_dma_tag_t aa_dmat; bus_space_handle_t aa_ioh; + int aa_node; + struct fdt_reg aa_reg; }; #endif /* _OCTUCTLVAR_H_ */ |