Page MenuHomeFreeBSD

D13793.id37915.diff
No OneTemporary

D13793.id37915.diff

Index: share/man/man4/Makefile
===================================================================
--- share/man/man4/Makefile
+++ share/man/man4/Makefile
@@ -74,6 +74,7 @@
${_aw_mmc.4} \
${_aw_rtc.4} \
${_aw_sid.4} \
+ ${_aw_syscon.4} \
axe.4 \
axge.4 \
bce.4 \
@@ -765,6 +766,7 @@
_aw_mmc.4= aw_mmc.4
_aw_rtc.4= aw_rtc.4
_aw_sid.4= aw_sid.4
+_aw_syscon.4= aw_syscon.4
.endif
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
Index: share/man/man4/aw_syscon.4
===================================================================
--- /dev/null
+++ share/man/man4/aw_syscon.4
@@ -0,0 +1,60 @@
+.\"-
+.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd January 7, 2018
+.Dt AW_SYSCON 4
+.Os
+.Sh NAME
+.Nm aw_syscon
+.Nd driver for the system controller in Allwinner SoC
+.Sh DESCRIPTION
+The
+.Nm
+device driver provides support for the Allwinner system controller.
+This controller provides registers for tying together related functionality in a
+common space.
+.Nm
+is required for ethernet functionality on supported devices.
+.Sh HARDWARE
+The
+.Nm
+driver supports the system controller with one of the following compatible
+strings:
+.Pp
+.Bl -bullet -compact
+.It
+allwinner,sun50i-a64-system-controller
+.It
+allwinner,sun8i-a83t-system-controller
+.It
+allwinner,sun8i-h3-system-controller
+.El
+.Sh AUTHORS
+The
+.Nm
+device driver was written by
+.An Kyle Evans Aq Mt kevans@FreeBSD.org .
Index: sys/arm/allwinner/aw_syscon.c
===================================================================
--- /dev/null
+++ sys/arm/allwinner/aw_syscon.c
@@ -0,0 +1,82 @@
+/*-
+ * Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Allwinner syscon driver
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+#include <machine/bus.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/extres/syscon/syscon.h>
+#include <dev/extres/syscon/syscon_generic.h>
+
+static struct ofw_compat_data compat_data[] = {
+ {"allwinner,sun50i-a64-system-controller", 1},
+ {"allwinner,sun8i-a83t-system-controller", 1},
+ {"allwinner,sun8i-h3-system-controller", 1},
+ {NULL, 0}
+};
+
+static int
+aw_syscon_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+ if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+ return (ENXIO);
+
+ device_set_desc(dev, "Allwinner syscon");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static device_method_t aw_syscon_methods[] = {
+ DEVMETHOD(device_probe, aw_syscon_probe),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_1(aw_syscon, aw_syscon_driver, aw_syscon_methods,
+ sizeof(struct syscon_generic_softc), syscon_generic_driver);
+
+static devclass_t aw_syscon_devclass;
+/* aw_syscon needs to attach prior to if_awg */
+EARLY_DRIVER_MODULE(aw_syscon, simplebus, aw_syscon_driver, aw_syscon_devclass,
+ 0, 0, BUS_PASS_DEFAULT - 1000);
+MODULE_VERSION(aw_syscon, 1);
Index: sys/arm/allwinner/files.allwinner
===================================================================
--- sys/arm/allwinner/files.allwinner
+++ sys/arm/allwinner/files.allwinner
@@ -15,6 +15,7 @@
arm/allwinner/aw_nmi.c optional intrng
arm/allwinner/aw_rsb.c optional rsb | p2wi
arm/allwinner/aw_rtc.c standard
+arm/allwinner/aw_syscon.c optional ext_resources syscon
arm/allwinner/aw_ts.c standard
arm/allwinner/aw_usbphy.c optional ehci | ohci
arm/allwinner/aw_wdog.c standard
Index: sys/dev/extres/syscon/syscon_generic.h
===================================================================
--- /dev/null
+++ sys/dev/extres/syscon/syscon_generic.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright 2018 Kyle Evans <kevans@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef DEV_SYSCON_GENERIC_H
+#define DEV_SYSCON_GENERIC_H
+
+struct syscon_generic_softc {
+ device_t dev;
+ struct syscon *syscon;
+ struct resource *mem_res;
+ struct mtx mtx;
+};
+
+DECLARE_CLASS(syscon_generic_driver);
+
+#endif /* DEV_SYSCON_GENERIC_H */
Index: sys/dev/extres/syscon/syscon_generic.c
===================================================================
--- sys/dev/extres/syscon/syscon_generic.c
+++ sys/dev/extres/syscon/syscon_generic.c
@@ -48,6 +48,7 @@
#include "syscon_if.h"
#include "syscon.h"
+#include "syscon_generic.h"
MALLOC_DECLARE(M_SYSCON);
@@ -60,22 +61,15 @@
/*
* Generic syscon driver (FDT)
*/
-struct syscon_generic_softc {
- device_t dev;
- struct syscon *syscon;
- struct resource *mem_res;
- struct mtx mtx;
-};
-
static struct ofw_compat_data compat_data[] = {
{"syscon", 1},
{NULL, 0}
};
-#define SYSCON_LOCK(_sc) mtx_lock(&(_sc)->mtx)
-#define SYSCON_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
+#define SYSCON_LOCK(_sc) mtx_lock_spin(&(_sc)->mtx)
+#define SYSCON_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx)
#define SYSCON_LOCK_INIT(_sc) mtx_init(&(_sc)->mtx, \
- device_get_nameunit((_sc)->dev), "syscon", MTX_DEF)
+ device_get_nameunit((_sc)->dev), "syscon", MTX_SPIN)
#define SYSCON_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx);
#define SYSCON_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED);
#define SYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED);
@@ -156,8 +150,8 @@
sc = device_get_softc(dev);
sc->dev = dev;
-
rid = 0;
+
sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->mem_res == NULL) {
@@ -181,7 +175,6 @@
struct syscon_generic_softc *sc;
sc = device_get_softc(dev);
-
if (sc->syscon != NULL) {
syscon_unregister(sc->syscon);
free(sc->syscon, M_SYSCON);
@@ -206,11 +199,7 @@
DEFINE_CLASS_0(syscon_generic, syscon_generic_driver, syscon_generic_dmethods,
sizeof(struct syscon_generic_softc));
static devclass_t syscon_generic_devclass;
-/*
- * syscon_generic needs to attach before other devices that may require it, such
- * as if_awg, but later than others to give way for more specialized syscon
- * implementations.
- */
+
EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver,
- syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT - 1000);
+ syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT);
MODULE_VERSION(syscon_generic, 1);

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 30, 8:04 AM (1 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30580259
Default Alt Text
D13793.id37915.diff (10 KB)

Event Timeline