14b84206bSMichal Meloun /*-
24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
34b84206bSMichal Meloun *
44b84206bSMichal Meloun * Copyright (c) 2019 Michal Meloun <mmel@FreeBSD.org>
54b84206bSMichal Meloun * All rights reserved.
64b84206bSMichal Meloun *
74b84206bSMichal Meloun * Redistribution and use in source and binary forms, with or without
84b84206bSMichal Meloun * modification, are permitted provided that the following conditions
94b84206bSMichal Meloun * are met:
104b84206bSMichal Meloun * 1. Redistributions of source code must retain the above copyright
114b84206bSMichal Meloun * notice, this list of conditions and the following disclaimer.
124b84206bSMichal Meloun * 2. Redistributions in binary form must reproduce the above copyright
134b84206bSMichal Meloun * notice, this list of conditions and the following disclaimer in the
144b84206bSMichal Meloun * documentation and/or other materials provided with the distribution.
154b84206bSMichal Meloun *
164b84206bSMichal Meloun * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
174b84206bSMichal Meloun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
184b84206bSMichal Meloun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
194b84206bSMichal Meloun * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
204b84206bSMichal Meloun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
214b84206bSMichal Meloun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
224b84206bSMichal Meloun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
234b84206bSMichal Meloun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
244b84206bSMichal Meloun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
254b84206bSMichal Meloun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
264b84206bSMichal Meloun * SUCH DAMAGE.
274b84206bSMichal Meloun */
284b84206bSMichal Meloun
294b84206bSMichal Meloun #include <sys/param.h>
304b84206bSMichal Meloun #include <sys/bus.h>
314b84206bSMichal Meloun #include <sys/kernel.h>
324b84206bSMichal Meloun #include <sys/module.h>
334b84206bSMichal Meloun #include <sys/mutex.h>
344b84206bSMichal Meloun #include <sys/rman.h>
354b84206bSMichal Meloun #include <machine/bus.h>
364b84206bSMichal Meloun
374b84206bSMichal Meloun #include <dev/ofw/openfirm.h>
384b84206bSMichal Meloun #include <dev/ofw/ofw_bus.h>
394b84206bSMichal Meloun #include <dev/ofw/ofw_bus_subr.h>
404b84206bSMichal Meloun
41*62e8ccc3SEmmanuel Vadot #include <dev/syscon/syscon.h>
424b84206bSMichal Meloun #include <dev/fdt/simple_mfd.h>
434b84206bSMichal Meloun
444b84206bSMichal Meloun static struct ofw_compat_data compat_data[] = {
454b84206bSMichal Meloun {"marvell,cp110-icu", 1},
464b84206bSMichal Meloun {NULL, 0}
474b84206bSMichal Meloun };
484b84206bSMichal Meloun
494b84206bSMichal Meloun static int
mv_cp110_icu_bus_probe(device_t dev)504b84206bSMichal Meloun mv_cp110_icu_bus_probe(device_t dev)
514b84206bSMichal Meloun {
524b84206bSMichal Meloun
534b84206bSMichal Meloun if (!ofw_bus_status_okay(dev))
544b84206bSMichal Meloun return (ENXIO);
554b84206bSMichal Meloun if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
564b84206bSMichal Meloun return (ENXIO);
574b84206bSMichal Meloun
584b84206bSMichal Meloun device_set_desc(dev, "Marvell Interrupt Consolidation Unit Bus");
594b84206bSMichal Meloun return (BUS_PROBE_DEFAULT);
604b84206bSMichal Meloun }
614b84206bSMichal Meloun
624b84206bSMichal Meloun static device_method_t mv_cp110_icu_bus_methods[] = {
634b84206bSMichal Meloun DEVMETHOD(device_probe, mv_cp110_icu_bus_probe),
644b84206bSMichal Meloun
654b84206bSMichal Meloun DEVMETHOD_END
664b84206bSMichal Meloun };
674b84206bSMichal Meloun
684b84206bSMichal Meloun DEFINE_CLASS_1(mv_cp110_icu_bus, mv_cp110_icu_bus_driver,
694b84206bSMichal Meloun mv_cp110_icu_bus_methods, sizeof(struct simple_mfd_softc),
704b84206bSMichal Meloun simple_mfd_driver);
714b84206bSMichal Meloun
72a3b866cbSJohn Baldwin EARLY_DRIVER_MODULE(mv_cp110_icu_bus, simplebus, mv_cp110_icu_bus_driver, 0, 0,
73a3b866cbSJohn Baldwin BUS_PASS_INTERRUPT);
744b84206bSMichal Meloun MODULE_VERSION(mv_cp110_icu_bus, 1);
75