···11-# $OpenBSD: GENERIC,v 1.299 2025/08/15 13:35:49 kettenis Exp $
11+# $OpenBSD: GENERIC,v 1.300 2025/08/20 12:01:02 kettenis Exp $
22#
33# GENERIC machine description file
44#
···243243sdmmc* at bcmsdhost?
244244bcmstbgpio* at fdt? early 1
245245bcmstbpinctrl* at fdt? early 1
246246+bcmstbreset* at fdt? early 1
246247bcmtemp* at fdt?
247248bcmtmon* at fdt? early 1
248249bse* at fdt?
+2-1
sys/arch/arm64/conf/RAMDISK
···11-# $OpenBSD: RAMDISK,v 1.226 2025/08/15 13:35:49 kettenis Exp $
11+# $OpenBSD: RAMDISK,v 1.227 2025/08/20 12:01:02 kettenis Exp $
2233machine arm64
44maxusers 4
···179179sdmmc* at bcmsdhost?
180180bcmstbgpio* at fdt? early 1
181181bcmstbpinctrl* at fdt? early 1
182182+bcmstbreset* at fdt? early 1
182183bse* at fdt?
183184bse* at acpi?
184185dwctwo* at fdt?
+111
sys/dev/fdt/bcmstbreset.c
···11+/* $OpenBSD: bcmstbreset.c,v 1.1 2025/08/20 12:01:02 kettenis Exp $ */
22+/*
33+ * Copyright (c) 2025 Mark Kettenis <kettenis@openbsd.org>
44+ *
55+ * Permission to use, copy, modify, and distribute this software for any
66+ * purpose with or without fee is hereby granted, provided that the above
77+ * copyright notice and this permission notice appear in all copies.
88+ *
99+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1010+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1111+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1212+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1313+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1414+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1515+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1616+ */
1717+1818+#include <sys/param.h>
1919+#include <sys/systm.h>
2020+#include <sys/device.h>
2121+2222+#include <machine/intr.h>
2323+#include <machine/bus.h>
2424+#include <machine/fdt.h>
2525+2626+#include <dev/ofw/openfirm.h>
2727+#include <dev/ofw/ofw_clock.h>
2828+#include <dev/ofw/fdt.h>
2929+3030+/* Registers. */
3131+#define SW_INIT_SET(_bank) (0x00 + (_bank) * 24)
3232+#define SW_INIT_CLR(_bank) (0x04 + (_bank) * 24)
3333+3434+#define HREAD4(sc, reg) \
3535+ (bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg)))
3636+#define HWRITE4(sc, reg, val) \
3737+ bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
3838+3939+struct bcmstbreset_softc {
4040+ struct device sc_dev;
4141+ bus_space_tag_t sc_iot;
4242+ bus_space_handle_t sc_ioh;
4343+ u_int sc_nbanks;
4444+4545+ struct reset_device sc_rd;
4646+};
4747+4848+int bcmstbreset_match(struct device *, void *, void *);
4949+void bcmstbreset_attach(struct device *, struct device *, void *);
5050+5151+const struct cfattach bcmstbreset_ca = {
5252+ sizeof (struct bcmstbreset_softc),
5353+ bcmstbreset_match, bcmstbreset_attach
5454+};
5555+5656+struct cfdriver bcmstbreset_cd = {
5757+ NULL, "bcmstbreset", DV_DULL
5858+};
5959+6060+void bcmstbreset_reset(void *, uint32_t *, int);
6161+6262+int
6363+bcmstbreset_match(struct device *parent, void *match, void *aux)
6464+{
6565+ struct fdt_attach_args *faa = aux;
6666+6767+ return OF_is_compatible(faa->fa_node, "brcm,brcmstb-reset");
6868+}
6969+7070+void
7171+bcmstbreset_attach(struct device *parent, struct device *self, void *aux)
7272+{
7373+ struct bcmstbreset_softc *sc = (struct bcmstbreset_softc *)self;
7474+ struct fdt_attach_args *faa = aux;
7575+7676+ if (faa->fa_nreg < 1) {
7777+ printf(": no registers\n");
7878+ return;
7979+ }
8080+8181+ sc->sc_iot = faa->fa_iot;
8282+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
8383+ faa->fa_reg[0].size, 0, &sc->sc_ioh)) {
8484+ printf(": can't map registers\n");
8585+ return;
8686+ }
8787+ sc->sc_nbanks = faa->fa_reg[0].size / 24;
8888+8989+ printf("\n");
9090+9191+ sc->sc_rd.rd_node = faa->fa_node;
9292+ sc->sc_rd.rd_cookie = sc;
9393+ sc->sc_rd.rd_reset = bcmstbreset_reset;
9494+ reset_register(&sc->sc_rd);
9595+}
9696+9797+void
9898+bcmstbreset_reset(void *cookie, uint32_t *cells, int assert)
9999+{
100100+ struct bcmstbreset_softc *sc = cookie;
101101+ uint32_t bank = cells[0] / 32;;
102102+ uint32_t bit = cells[0] % 32;
103103+104104+ if (bank >= sc->sc_nbanks)
105105+ return;
106106+107107+ if (assert)
108108+ HWRITE4(sc, SW_INIT_SET(bank), 1U << bit);
109109+ else
110110+ HWRITE4(sc, SW_INIT_CLR(bank), 1U << bit);
111111+}
+5-1
sys/dev/fdt/files.fdt
···11-# $OpenBSD: files.fdt,v 1.211 2025/08/15 13:35:49 kettenis Exp $
11+# $OpenBSD: files.fdt,v 1.212 2025/08/20 12:01:02 kettenis Exp $
22#
33# Config file and device description for machine-independent FDT code.
44# Included by ports that need it.
···151151device bcmstbpinctrl
152152attach bcmstbpinctrl at fdt
153153file dev/fdt/bcmstbpinctrl.c bcmstbpinctrl
154154+155155+device bcmstbreset
156156+attach bcmstbreset at fdt
157157+file dev/fdt/bcmstbreset.c bcmstbreset
154158155159device bcmtemp
156160attach bcmtemp at fdt