Index: sys/arm64/conf/GENERIC =================================================================== --- sys/arm64/conf/GENERIC +++ sys/arm64/conf/GENERIC @@ -333,6 +333,7 @@ device syscon device aw_syscon device qoriq_clk +device ls1046a_clk # IO Domains device rk_iodomain Index: sys/arm64/qoriq/clk/ls1046a_clkgen.c =================================================================== --- /dev/null +++ sys/arm64/qoriq/clk/ls1046a_clkgen.c @@ -0,0 +1,174 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Alstom Group. + * Copyright (c) 2020 Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Driver providing information about device to the QorIQ driver. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +const char *ls1046a_hwa1_parents[] = { + 0, + 0, + "cg-cgapll1-1", + "cg-cgapll1-2", + "cg-cgapll1-3", + "cg-pltfrm-0", + "cg-cgapll2-1", + "cg-cgapll2-2" +}; + +const char *ls1046a_hwa2_parents[] = { + 0, + "cg-cgapll2-0", + "cg-cgapll2-1", + "cg-cgapll2-2", + 0, + 0, + "cg-cgapll2-1" +}; + +const char *ls1046a_fman_srcs[] = { + "cg-hwaccel-0" +}; + +const char *ls1046a_cmux_srcs[] = { + "cg-cgapll1-0", + 0, + "cg-cgapll1-1", + 0, + "cg-cgapll2-0", + 0, + "cg-cgapll2-1" +}; + +struct clk_mux_def ls1046a_hwa_defs[] = { + { + .clkdef = { + .parent_names = ls1046a_hwa1_parents, + .parent_cnt = nitems(ls1046a_hwa1_parents) + }, + .offset = 0x10, + .shift = 27, + .width = 4 + }, + { + .clkdef = { + .parent_names = ls1046a_hwa2_parents, + .parent_cnt = nitems(ls1046a_hwa2_parents) + }, + .offset = 0x30, + .shift = 27, + .width = 4 + } +}; + +struct clk_mux_def ls1046a_cmux_defs[] = { + { + .clkdef = { + .parent_names = ls1046a_cmux_srcs, + .parent_cnt = nitems(ls1046a_cmux_srcs) + }, + .offset = 0, + .shift = 27, + .width = 4 + } +}; + +struct qoriq_clk_info ls1046a_info = { + .hwaccel_defs = ls1046a_hwa_defs, + .num_hwaccel = 2, + .fman_src = ls1046a_fman_srcs, + .num_fman = 1, + .cmux_defs = ls1046a_cmux_defs, + .num_cmux = 1, + .num_cgapll = 2 +}; + +static int ls1046a_clkgen_probe(device_t); +static int ls1046a_clkgen_attach(device_t); + +static device_method_t ls1046a_clkgen_methods[] = { + DEVMETHOD(device_probe, ls1046a_clkgen_probe), + DEVMETHOD(device_attach, ls1046a_clkgen_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_1(ls1046a_clkgen, ls1046a_clkgen_driver, ls1046a_clkgen_methods, + sizeof(struct qoriq_clkgen_softc), qoriq_clkgen_driver); + +static devclass_t ls1046a_clkgen_devclass; + +EARLY_DRIVER_MODULE(ls1046a_clkgen, simplebus, ls1046a_clkgen_driver, + ls1046a_clkgen_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); + +static int +ls1046a_clkgen_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "fsl,ls1046a-clockgen")) + return (ENXIO); + + device_set_desc(dev, "LS1046A clockgen."); + return (BUS_PROBE_DEFAULT); +} + +static int +ls1046a_clkgen_attach(device_t dev) +{ + struct qoriq_clkgen_softc *sc; + + sc = device_get_softc(dev); + + sc->info = &ls1046a_info; + + return (qoriq_clkgen_attach(dev)); +} Index: sys/conf/files.arm64 =================================================================== --- sys/conf/files.arm64 +++ sys/conf/files.arm64 @@ -193,6 +193,7 @@ arm64/intel/firmware.c optional soc_intel_stratix10 arm64/intel/stratix10-soc-fpga-mgr.c optional soc_intel_stratix10 arm64/intel/stratix10-svc.c optional soc_intel_stratix10 +arm64/qoriq/clk/ls1046a_clkgen.c optional fdt qoriq_clk ls1046a_clk arm64/qoriq/clk/qoriq_clkgen.c optional fdt qoriq_clk arm64/qualcomm/qcom_gcc.c optional qcom_gcc fdt contrib/vchiq/interface/compat/vchi_bsd.c optional vchiq soc_brcm_bcm2837 \