Path: blob/main/sys/riscv/starfive/starfive_syscon.c
39507 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2024 The FreeBSD Foundation4*5* This software was developed by Mitchell Horne <[email protected]> under6* sponsorship from the FreeBSD Foundation.7*/89/*10* StarFive syscon driver.11*12* On the JH7110, the PLL clock driver is a child of the sys-syscon device.13* This needs to probe very early (BUS_PASS_BUS + BUS_PASS_ORDER_EARLY).14*/1516#include <sys/param.h>17#include <sys/bus.h>18#include <sys/kernel.h>19#include <sys/module.h>20#include <sys/mutex.h>2122#include <machine/bus.h>2324#include <dev/ofw/openfirm.h>25#include <dev/ofw/ofw_bus.h>26#include <dev/ofw/ofw_bus_subr.h>2728#include <dev/syscon/syscon.h>29#include <dev/syscon/syscon_generic.h>3031#include <dev/fdt/simple_mfd.h>3233enum starfive_syscon_type {34JH7110_SYSCON_SYS = 1,35JH7110_SYSCON_AON,36JH7110_SYSCON_STG,37};3839static struct ofw_compat_data compat_data[] = {40{ "starfive,jh7110-sys-syscon", JH7110_SYSCON_SYS },41{ "starfive,jh7110-aon-syscon", JH7110_SYSCON_AON },42{ "starfive,jh7110-stg-syscon", JH7110_SYSCON_STG },4344{ NULL, 0 }45};4647static int48starfive_syscon_probe(device_t dev)49{50enum starfive_syscon_type type;5152if (!ofw_bus_status_okay(dev))53return (ENXIO);5455type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;56if (type == 0)57return (ENXIO);5859switch (type) {60case JH7110_SYSCON_SYS:61device_set_desc(dev, "JH7110 SYS syscon");62break;63case JH7110_SYSCON_AON:64device_set_desc(dev, "JH7110 AON syscon");65break;66case JH7110_SYSCON_STG:67device_set_desc(dev, "JH7110 STG syscon");68break;69}7071return (BUS_PROBE_DEFAULT);72}737475static device_method_t starfive_syscon_methods[] = {76DEVMETHOD(device_probe, starfive_syscon_probe),7778DEVMETHOD_END79};8081DEFINE_CLASS_1(starfive_syscon, starfive_syscon_driver, starfive_syscon_methods,82sizeof(struct syscon_generic_softc), simple_mfd_driver);8384EARLY_DRIVER_MODULE(starfive_syscon, simplebus, starfive_syscon_driver, 0, 0,85BUS_PASS_BUS + BUS_PASS_ORDER_EARLY);86MODULE_VERSION(starfive_syscon, 1);878889