1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2024 Arm Ltd 5 * Copyright (c) 2022 The FreeBSD Foundation 6 * 7 * Portions of this software were developed by Andrew Turner under sponsorship 8 * from the FreeBSD Foundation. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 #include <sys/param.h> 33 #include <sys/bus.h> 34 #include <sys/kernel.h> 35 #include <sys/lock.h> 36 #include <sys/module.h> 37 #include <sys/mutex.h> 38 39 #include <dev/ofw/ofw_bus.h> 40 #include <dev/ofw/ofw_bus_subr.h> 41 #include <dev/ofw/openfirm.h> 42 43 #include <arm64/spe/arm_spe_dev.h> 44 45 static device_probe_t arm_spe_fdt_probe; 46 47 static struct ofw_compat_data compat_data[] = { 48 {"arm,statistical-profiling-extension-v1", true}, 49 {NULL, false}, 50 }; 51 52 static device_method_t arm_spe_fdt_methods[] = { 53 /* Device interface */ 54 DEVMETHOD(device_probe, arm_spe_fdt_probe), 55 56 DEVMETHOD_END, 57 }; 58 59 DEFINE_CLASS_1(spe, arm_spe_fdt_driver, arm_spe_fdt_methods, 60 sizeof(struct arm_spe_softc), arm_spe_driver); 61 62 DRIVER_MODULE(spe, simplebus, arm_spe_fdt_driver, 0, 0); 63 64 static int 65 arm_spe_fdt_probe(device_t dev) 66 { 67 if (!ofw_bus_status_okay(dev)) 68 return (ENXIO); 69 70 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) 71 return (ENXIO); 72 73 device_set_desc(dev, "ARM Statistical Profiling Extension"); 74 return (BUS_PROBE_DEFAULT); 75 } 76