FreeBSD Bugzilla – Attachment 165547 Details for
Bug 206228
[patch] Add fdt_reset based on the fdt_clock implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add fdt_reset based on fdt_clock
fdt_reset.diff (text/plain), 8.79 KB, created by
Stanislav Galabov
on 2016-01-14 08:23:00 UTC
(
hide
)
Description:
Add fdt_reset based on fdt_clock
Filename:
MIME Type:
Creator:
Stanislav Galabov
Created:
2016-01-14 08:23:00 UTC
Size:
8.79 KB
patch
obsolete
>diff --git a/sys/conf/files b/sys/conf/files >index 12419ed..0ca8905 100644 >--- a/sys/conf/files >+++ b/sys/conf/files >@@ -1423,6 +1423,8 @@ dev/fdt/fdt_pinctrl_if.m optional fdt fdt_pinctrl > dev/fdt/fdt_regulator.c optional fdt fdt_regulator > dev/fdt/fdt_regulator_if.m optional fdt fdt_regulator > dev/fdt/fdt_regulator_fixed.c optional fdt fdt_regulator_fixed >+dev/fdt/fdt_reset.c optional fdt fdt_reset >+dev/fdt/fdt_reset_if.m optional fdt fdt_reset > dev/fdt/fdt_slicer.c optional fdt cfi | fdt nand > dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static \ > dependency "$S/boot/fdt/dts/${MACHINE}/${FDT_DTS_FILE}" >diff --git a/sys/dev/fdt/fdt_reset.c b/sys/dev/fdt/fdt_reset.c >new file mode 100644 >index 0000000..5912b22 >--- /dev/null >+++ b/sys/dev/fdt/fdt_reset.c >@@ -0,0 +1,125 @@ >+/*- >+ * Copyright (c) 2016 Stanislav Galabov >+ * Copyright (c) 2014 Ian Lepore <ian@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$ >+ */ >+ >+#include <sys/cdefs.h> >+#include <sys/param.h> >+#include <sys/kernel.h> >+#include <sys/lock.h> >+#include <sys/mutex.h> >+#include <sys/queue.h> >+#include <sys/systm.h> >+ >+#include <dev/ofw/ofw_bus.h> >+#include <dev/ofw/ofw_bus_subr.h> >+ >+#include "fdt_reset_if.h" >+#include <dev/fdt/fdt_reset.h> >+ >+/* >+ * Loop through all the tuples in the resets= property for a device, asserting >+ * or deasserting each reset. >+ * >+ * Be liberal about errors for now: warn about a failure to (de)assert but keep >+ * trying with any other resets in the list. Return ENXIO if any errors were >+ * found, and let the caller decide whether the problem is fatal. >+ */ >+static int >+assert_deassert_all(device_t consumer, boolean_t assert) >+{ >+ phandle_t rnode; >+ device_t resetdev; >+ int resetnum, err, i, ncells; >+ uint32_t *resets; >+ boolean_t anyerrors; >+ >+ rnode = ofw_bus_get_node(consumer); >+ ncells = OF_getencprop_alloc(rnode, "resets", sizeof(*resets), >+ (void **)&resets); >+ if (!assert && ncells < 2) { >+ device_printf(consumer, "Warning: No resets specified in fdt " >+ "data; device may not function."); >+ return (ENXIO); >+ } >+ anyerrors = false; >+ for (i = 0; i < ncells; i += 2) { >+ resetdev = OF_device_from_xref(resets[i]); >+ resetnum = resets[i + 1]; >+ if (resetdev == NULL) { >+ if (!assert) >+ device_printf(consumer, "Warning: can not find " >+ "driver for reset number %u; device may " >+ "not function\n", resetnum); >+ anyerrors = true; >+ continue; >+ } >+ if (assert) >+ err = FDT_RESET_ASSERT(resetdev, resetnum); >+ else >+ err = FDT_RESET_DEASSERT(resetdev, resetnum); >+ if (err != 0) { >+ if (!assert) >+ device_printf(consumer, "Warning: failed to " >+ "deassert reset number %u; device may not " >+ "function\n", resetnum); >+ anyerrors = true; >+ } >+ } >+ free(resets, M_OFWPROP); >+ return (anyerrors ? ENXIO : 0); >+} >+ >+int >+fdt_reset_assert_all(device_t consumer) >+{ >+ >+ return (assert_deassert_all(consumer, true)); >+} >+ >+int >+fdt_reset_deassert_all(device_t consumer) >+{ >+ >+ return (assert_deassert_all(consumer, false)); >+} >+ >+void >+fdt_reset_register_provider(device_t provider) >+{ >+ >+ OF_device_register_xref( >+ OF_xref_from_node(ofw_bus_get_node(provider)), provider); >+} >+ >+void >+fdt_reset_unregister_provider(device_t provider) >+{ >+ >+ OF_device_register_xref(OF_xref_from_device(provider), NULL); >+} >+ >diff --git a/sys/dev/fdt/fdt_reset.h b/sys/dev/fdt/fdt_reset.h >new file mode 100644 >index 0000000..195beaa >--- /dev/null >+++ b/sys/dev/fdt/fdt_reset.h >@@ -0,0 +1,49 @@ >+/*- >+ * Copyright (c) 2016 Stanislav Galabov >+ * Copyright (c) 2014 Ian Lepore <ian@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_FDT_RESET_H >+#define DEV_FDT_RESET_H >+ >+#include "fdt_reset_if.h" >+ >+/* >+ * Look up "resets" property in consumer's fdt data and assert or deassert all >+ * configured resets. >+ */ >+int fdt_reset_assert_all(device_t consumer); >+int fdt_reset_deassert_all(device_t consumer); >+ >+/* >+ * [Un]register the given device instance as a driver that implements the >+ * fdt_clock interface. >+ */ >+void fdt_reset_register_provider(device_t provider); >+void fdt_reset_unregister_provider(device_t provider); >+ >+#endif /* DEV_FDT_RESET_H */ >+ >diff --git a/sys/dev/fdt/fdt_reset_if.m b/sys/dev/fdt/fdt_reset_if.m >new file mode 100644 >index 0000000..2bde7b7 >--- /dev/null >+++ b/sys/dev/fdt/fdt_reset_if.m >@@ -0,0 +1,58 @@ >+#- >+# Copyright (c) 2016 Stanislav Galabov >+# Copyright (c) 2014 Ian Lepore >+# 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$ >+# >+ >+#include <sys/types.h> >+ >+# >+# This is the interface that fdt_reset drivers provide to other drivers. >+# In this context, reset refers to a reset signal provided to some other >+# hardware component within the system. They are most often found within >+# embedded processors that have on-chip IO controllers. >+# >+ >+INTERFACE fdt_reset; >+ >+# >+# Enable/assert/apply the specified reset. >+# Returns 0 on success or a standard errno value. >+# >+METHOD int assert { >+ device_t provider; >+ int index; >+}; >+ >+# >+# Disable/de-assert/remove the specified reset. >+# Returns 0 on success or a standard errno value. >+# >+METHOD int deassert { >+ device_t provider; >+ int index; >+}; >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 206228
: 165547