149755fc6SEmmanuel Vadot /*- 249755fc6SEmmanuel Vadot * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 349755fc6SEmmanuel Vadot * 449755fc6SEmmanuel Vadot * Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.org> 549755fc6SEmmanuel Vadot * 649755fc6SEmmanuel Vadot * Redistribution and use in source and binary forms, with or without 749755fc6SEmmanuel Vadot * modification, are permitted provided that the following conditions 849755fc6SEmmanuel Vadot * are met: 949755fc6SEmmanuel Vadot * 1. Redistributions of source code must retain the above copyright 1049755fc6SEmmanuel Vadot * notice, this list of conditions and the following disclaimer. 1149755fc6SEmmanuel Vadot * 2. Redistributions in binary form must reproduce the above copyright 1249755fc6SEmmanuel Vadot * notice, this list of conditions and the following disclaimer in the 1349755fc6SEmmanuel Vadot * documentation and/or other materials provided with the distribution. 1449755fc6SEmmanuel Vadot * 1549755fc6SEmmanuel Vadot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1649755fc6SEmmanuel Vadot * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1749755fc6SEmmanuel Vadot * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1849755fc6SEmmanuel Vadot * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1949755fc6SEmmanuel Vadot * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2049755fc6SEmmanuel Vadot * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2149755fc6SEmmanuel Vadot * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2249755fc6SEmmanuel Vadot * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2349755fc6SEmmanuel Vadot * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2449755fc6SEmmanuel Vadot * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2549755fc6SEmmanuel Vadot * SUCH DAMAGE. 2649755fc6SEmmanuel Vadot */ 2749755fc6SEmmanuel Vadot 2849755fc6SEmmanuel Vadot #include <sys/cdefs.h> 2949755fc6SEmmanuel Vadot __FBSDID("$FreeBSD$"); 3049755fc6SEmmanuel Vadot 3149755fc6SEmmanuel Vadot #include <sys/param.h> 3249755fc6SEmmanuel Vadot #include <sys/bus.h> 3349755fc6SEmmanuel Vadot #include <sys/kernel.h> 3449755fc6SEmmanuel Vadot #include <sys/module.h> 3549755fc6SEmmanuel Vadot #include <sys/mutex.h> 3649755fc6SEmmanuel Vadot #include <sys/rman.h> 3749755fc6SEmmanuel Vadot #include <machine/bus.h> 3849755fc6SEmmanuel Vadot 3949755fc6SEmmanuel Vadot #include <dev/ofw/openfirm.h> 4049755fc6SEmmanuel Vadot #include <dev/ofw/ofw_bus.h> 4149755fc6SEmmanuel Vadot #include <dev/ofw/ofw_bus_subr.h> 4249755fc6SEmmanuel Vadot 4349755fc6SEmmanuel Vadot #include <dev/extres/syscon/syscon.h> 4440c30bf3SGanbold Tsagaankhuu #include <dev/fdt/simple_mfd.h> 4549755fc6SEmmanuel Vadot 4649755fc6SEmmanuel Vadot static struct ofw_compat_data compat_data[] = { 47f69c06c3SMichal Meloun {"rockchip,rk3288-grf", 1}, 4849755fc6SEmmanuel Vadot {"rockchip,rk3328-grf", 1}, 4936ae7efeSEmmanuel Vadot {"rockchip,rk3399-grf", 1}, 5036ae7efeSEmmanuel Vadot {"rockchip,rk3399-pmugrf", 1}, 51*ace8bb34SGanbold Tsagaankhuu {"rockchip,rk3568-grf", 1}, 52*ace8bb34SGanbold Tsagaankhuu {"rockchip,rk3568-pmugrf", 1}, 53*ace8bb34SGanbold Tsagaankhuu {"rockchip,rk3568-usb2phy-grf", 1}, 54*ace8bb34SGanbold Tsagaankhuu {"rockchip,rk3566-pipegrf", 1}, 55*ace8bb34SGanbold Tsagaankhuu {"rockchip,rk3568-pipegrf", 1}, 56*ace8bb34SGanbold Tsagaankhuu {"rockchip,pipe-phy-grf", 1}, 5749755fc6SEmmanuel Vadot {NULL, 0} 5849755fc6SEmmanuel Vadot }; 5949755fc6SEmmanuel Vadot 6049755fc6SEmmanuel Vadot static int 6149755fc6SEmmanuel Vadot rk_grf_probe(device_t dev) 6249755fc6SEmmanuel Vadot { 6349755fc6SEmmanuel Vadot 6449755fc6SEmmanuel Vadot if (!ofw_bus_status_okay(dev)) 6549755fc6SEmmanuel Vadot return (ENXIO); 6649755fc6SEmmanuel Vadot if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) 6749755fc6SEmmanuel Vadot return (ENXIO); 6849755fc6SEmmanuel Vadot 6949755fc6SEmmanuel Vadot device_set_desc(dev, "RockChip General Register Files"); 7049755fc6SEmmanuel Vadot return (BUS_PROBE_DEFAULT); 7149755fc6SEmmanuel Vadot } 7249755fc6SEmmanuel Vadot 7349755fc6SEmmanuel Vadot static device_method_t rk_grf_methods[] = { 7449755fc6SEmmanuel Vadot DEVMETHOD(device_probe, rk_grf_probe), 7549755fc6SEmmanuel Vadot 7649755fc6SEmmanuel Vadot DEVMETHOD_END 7749755fc6SEmmanuel Vadot }; 7849755fc6SEmmanuel Vadot 7949755fc6SEmmanuel Vadot DEFINE_CLASS_1(rk_grf, rk_grf_driver, rk_grf_methods, 8040c30bf3SGanbold Tsagaankhuu sizeof(struct simple_mfd_softc), simple_mfd_driver); 8149755fc6SEmmanuel Vadot 82b2c1681aSJohn Baldwin EARLY_DRIVER_MODULE(rk_grf, simplebus, rk_grf_driver, 0, 0, 83b2c1681aSJohn Baldwin BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); 8449755fc6SEmmanuel Vadot MODULE_VERSION(rk_grf, 1); 85