1 /* 2 * Copyright (c) 2026 Justin Hibbits 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7 #include <sys/param.h> 8 #include <sys/systm.h> 9 #include <sys/kernel.h> 10 #include <sys/module.h> 11 #include <sys/bus.h> 12 #include <sys/rman.h> 13 #include <sys/malloc.h> 14 15 #include <dev/ofw/ofw_bus.h> 16 #include <dev/ofw/ofw_bus_subr.h> 17 18 #include <machine/bus.h> 19 20 #include "opt_platform.h" 21 22 #include <powerpc/mpc85xx/mpc85xx.h> 23 24 #include "fman.h" 25 26 struct fman_muram_softc { 27 struct resource *sc_mem; 28 vmem_t sc_vmem; 29 }; 30 31 static int 32 fman_muram_probe(device_t dev) 33 { 34 if (!ofw_bus_is_compatible(dev, "fsl,fman-muram")) 35 return (ENXIO); 36 37 device_set_desc(dev, "FMan MURAM"); 38 39 return (BUS_PROBE_DEFAULT); 40 } 41 42 static int 43 fman_muram_attach(device_t dev) 44 { 45 struct fman_muram_softc *sc = device_get_softc(dev); 46 47 sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 0, 48 RF_ACTIVE | RF_SHAREABLE); 49 50 if (sc->sc_mem == NULL) { 51 device_printf(dev, "cannot allocate memory\n"); 52 return (ENXIO); 53 } 54 sc->sc_vmem = vmem_create("MURAM", rman_get_bushandle(sc->sc_mem), 55 rman_get_size(sc->sc_mem), 56 } 57 58 static device_method_t muram_methods[] = { 59 /* Device interface */ 60 DEVMETHOD(device_probe, fman_muram_probe), 61 DEVMETHOD(device_attach, fman_muram_attach), 62 DEVMETHOD(device_detach, fman_muram_detach), 63 64 DEVMETHOD_END 65 }; 66 67 DEFINE_CLASS_0(fman_muram, fman_muram_driver, muram_methods, 68 sizeof(struct fman_muram_softc)); 69 EARLY_DRIVER_MODULE(fman_muram, fman, fman_muram_driver, 0, 0, 70 BUS_PASS_SUPPORTDEV); 71