1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021, Adrian Chadd <adrian@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
11 * disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <sys/param.h>
29 #include <sys/kernel.h>
30 #include <sys/malloc.h>
31 #include <sys/module.h>
32 #include <sys/sglist.h>
33 #include <sys/random.h>
34 #include <sys/stdatomic.h>
35 #include <sys/mutex.h>
36
37 #include <machine/bus.h>
38 #include <machine/resource.h>
39 #include <sys/bus.h>
40
41 #include <dev/fdt/fdt_common.h>
42 #include <dev/ofw/ofw_bus.h>
43 #include <dev/ofw/ofw_bus_subr.h>
44
45 #include <dev/hwreset/hwreset.h>
46
47 #include "hwreset_if.h"
48
49 #include "qcom_gcc_var.h"
50
51 int
qcom_gcc_hwreset_assert(device_t dev,intptr_t id,bool reset)52 qcom_gcc_hwreset_assert(device_t dev, intptr_t id, bool reset)
53 {
54 struct qcom_gcc_softc *sc = device_get_softc(dev);
55 return (sc->sc_cb.hw_reset_assert(dev, id, reset));
56 }
57
58 int
qcom_gcc_hwreset_is_asserted(device_t dev,intptr_t id,bool * reset)59 qcom_gcc_hwreset_is_asserted(device_t dev, intptr_t id, bool *reset)
60 {
61 struct qcom_gcc_softc *sc = device_get_softc(dev);
62
63 return (sc->sc_cb.hw_reset_is_asserted(dev, id, reset));
64 }
65