xref: /src/sys/dev/qcom_gcc/qcom_gcc_msm8916_reset.c (revision 4e3fdced7f78c067e048c4d9ec42341c30b7899d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2026 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 #include "qcom_gcc_msm8916.h"
51 
52 static int
qcom_gcc_msm8916_hwreset_assert(device_t dev,intptr_t id,bool reset)53 qcom_gcc_msm8916_hwreset_assert(device_t dev, intptr_t id, bool reset)
54 {
55 	device_printf(dev, "%s: invalid id (%d)\n", __func__, (uint32_t) id);
56 	return (EINVAL);
57 }
58 
59 static int
qcom_gcc_msm8916_hwreset_is_asserted(device_t dev,intptr_t id,bool * reset)60 qcom_gcc_msm8916_hwreset_is_asserted(device_t dev, intptr_t id, bool *reset)
61 {
62 	device_printf(dev, "%s: invalid id (%d)\n", __func__, (uint32_t) id);
63 	return (EINVAL);
64 }
65 
66 void
qcom_gcc_msm8916_hwreset_init(struct qcom_gcc_softc * sc)67 qcom_gcc_msm8916_hwreset_init(struct qcom_gcc_softc *sc)
68 {
69 	sc->sc_cb.hw_reset_assert = qcom_gcc_msm8916_hwreset_assert;
70 	sc->sc_cb.hw_reset_is_asserted = qcom_gcc_msm8916_hwreset_is_asserted;
71 }
72