Lines Matching +full:sys +full:- +full:syscon

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
30 * This is a generic syscon driver, whose purpose is to provide access to
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/bus.h>
39 #include <sys/kernel.h>
40 #include <sys/lock.h>
41 #include <sys/module.h>
42 #include <sys/mutex.h>
43 #include <sys/rman.h>
51 #include "syscon.h"
56 static uint32_t syscon_generic_unlocked_read_4(struct syscon *syscon,
58 static int syscon_generic_unlocked_write_4(struct syscon *syscon,
60 static int syscon_generic_unlocked_modify_4(struct syscon *syscon,
64 * Generic syscon driver (FDT)
67 {"syscon", 1},
71 #define SYSCON_LOCK(_sc) mtx_lock_spin(&(_sc)->mtx)
72 #define SYSCON_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx)
73 #define SYSCON_LOCK_INIT(_sc) mtx_init(&(_sc)->mtx, \
74 device_get_nameunit((_sc)->dev), "syscon", MTX_SPIN)
75 #define SYSCON_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx);
76 #define SYSCON_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED);
77 #define SYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED);
90 syscon_generic_unlocked_read_4(struct syscon *syscon, bus_size_t offset) in syscon_generic_unlocked_read_4() argument
95 sc = device_get_softc(syscon->pdev); in syscon_generic_unlocked_read_4()
97 val = bus_read_4(sc->mem_res, offset); in syscon_generic_unlocked_read_4()
102 syscon_generic_unlocked_write_4(struct syscon *syscon, bus_size_t offset, uint32_t val) in syscon_generic_unlocked_write_4() argument
106 sc = device_get_softc(syscon->pdev); in syscon_generic_unlocked_write_4()
108 bus_write_4(sc->mem_res, offset, val); in syscon_generic_unlocked_write_4()
113 syscon_generic_unlocked_modify_4(struct syscon *syscon, bus_size_t offset, in syscon_generic_unlocked_modify_4() argument
119 sc = device_get_softc(syscon->pdev); in syscon_generic_unlocked_modify_4()
121 val = bus_read_4(sc->mem_res, offset); in syscon_generic_unlocked_modify_4()
124 bus_write_4(sc->mem_res, offset, val); in syscon_generic_unlocked_modify_4()
152 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in syscon_generic_probe()
155 device_set_desc(dev, "syscon"); in syscon_generic_probe()
169 sc->dev = dev; in syscon_generic_attach()
172 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in syscon_generic_attach()
174 if (sc->mem_res == NULL) { in syscon_generic_attach()
180 sc->syscon = syscon_create_ofw_node(dev, &syscon_generic_class, in syscon_generic_attach()
182 if (sc->syscon == NULL) { in syscon_generic_attach()
183 device_printf(dev, "Failed to create/register syscon\n"); in syscon_generic_attach()
187 if (ofw_bus_is_compatible(dev, "simple-bus")) { in syscon_generic_attach()
188 rv = simplebus_attach_impl(sc->dev); in syscon_generic_attach()
194 sc->simplebus_attached = true; in syscon_generic_attach()
207 if (sc->syscon != NULL) { in syscon_generic_detach()
208 syscon_unregister(sc->syscon); in syscon_generic_detach()
209 free(sc->syscon, M_SYSCON); in syscon_generic_detach()
211 if (sc->simplebus_attached) in syscon_generic_detach()
215 if (sc->mem_res != NULL) in syscon_generic_detach()
216 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); in syscon_generic_detach()