From nobody Mon Jul 18 09:50:05 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LmcdV1pdsz4WtC3; Mon, 18 Jul 2022 09:50:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LmcdT6SZQz3CLT; Mon, 18 Jul 2022 09:50:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658137805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kjDM/xeC5gtVKemaAlJX1cZOdXwC8wVeq7DOUbRgLWo=; b=iepMw3nWlomRuv/DiMFXg/sJLDqKbrg/NUCXONWPw1guMC4wkAKr42kQujqWrIdlIH0wfp n9UMMFuNrhh6pPOM74Yfv0hM2dXrundNAo2kdvCpOCr1BTVOj5F/RB7SKCP+IvRwEQTWUE QLI2CWLFajA1M8ZNJTZuVGG12jk2gdQbst8zJjZq/sjNofLQlB0cJwX8mndnRPPoSavYWp c8G0q3dJFkilc1ZwzLiEI7vh+o5mUDVcsnTGkxqE4ol0dGiwiJV/Ketfz+5ZbvhYDob0Os l0XxIkAtEvJSre6mUzvmQ/+fXsDTolNspMDm3S0UJ51T0qXBNh67jXumVKeUAw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LmcdT58Mzzb2M; Mon, 18 Jul 2022 09:50:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26I9o5RO033494; Mon, 18 Jul 2022 09:50:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26I9o5Cf033491; Mon, 18 Jul 2022 09:50:05 GMT (envelope-from git) Date: Mon, 18 Jul 2022 09:50:05 GMT Message-Id: <202207180950.26I9o5Cf033491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: ce28b75973d1 - stable/13 - arm64: NXP add LS1088a clockgen support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ce28b75973d14af0203cf69115cbaa3f7f604bf7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658137805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kjDM/xeC5gtVKemaAlJX1cZOdXwC8wVeq7DOUbRgLWo=; b=vuFV4tXCVpmekaVDn07fcqPqkLuwytPxh3LC1gHKuaQ8ocXNfDJvj98nDQAvN5belg4XZy 3resLgoOrYhyM+SCUs0DwBPtuMxxvZTht46v9D9vYOCjLHJ4lv5fQpruuZbRH8oyP9zJt8 6kHOo3ZkrvlJS+cfFbtqIISyKFFjI7pUeSaWVz7rWnuTB3YP7TlCkvzHf7XDbiGlqVY1n6 mgEVtFG4Q41278UfT5l1f5B3WxOh6B4GteALDY1X8DajiBSOr4w31Y6W2zVPsCQ0suPD9j lHL2sa+cD0sSuvpsGozasYCp18TZToChe2Cm28kTSpmlM/SHHgaADko3edGCPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658137805; a=rsa-sha256; cv=none; b=Gw8tjverutah+27+AKjUOx/faKyC5m5QGvES28065LHJB/P0YGbxPQWZdl9XcxCCjZREB0 8FcJvrgcuCIXp7WV8oNF/VFktsgcb3yjeXiap0Y/pPnx01AZw0ivxjar3AIBRXP/Lm9JHp pjprz7ssd2UCzuAsaWMttzSKggMEdqDtVFFE5r0HNmeaF2EilQe1g6ObS1YarWOlm3RhtJ chHRHyvq77JZhyUxXMYj15CIvuensSr+vgHtx3lcl/jpeBXOzFMI7soYME+GWwnU5DurOY z74qXxsVnynA40gIYiO8h2FhfH/l7De4Eqm9omJ21P4YVK1lOIhhXAz/tLnu3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=ce28b75973d14af0203cf69115cbaa3f7f604bf7 commit ce28b75973d14af0203cf69115cbaa3f7f604bf7 Author: Bjoern A. Zeeb AuthorDate: 2022-06-28 00:02:17 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-07-18 00:43:42 +0000 arm64: NXP add LS1088a clockgen support Add a driver for NXP LS1088a clockgen support which passes configuration information to QorIQ clockgen class. The implementaiton started off as copy of ls1028 support and was adjusted accordingly. Reviewed by: dgr_semihalf.com (earlier), mmel Sponsored by: Traverse Technologies (providing Ten64 HW for testing) Differential Revision: https://reviews.freebsd.org/D35617 (cherry picked from commit 8154df37a55948aca8358ade68b659d1aa71b755) --- sys/arm64/qoriq/clk/ls1088a_clkgen.c | 273 +++++++++++++++++++++++++++++++++++ sys/conf/files.arm64 | 1 + 2 files changed, 274 insertions(+) diff --git a/sys/arm64/qoriq/clk/ls1088a_clkgen.c b/sys/arm64/qoriq/clk/ls1088a_clkgen.c new file mode 100644 index 000000000000..06e893504c35 --- /dev/null +++ b/sys/arm64/qoriq/clk/ls1088a_clkgen.c @@ -0,0 +1,273 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Alstom Group. + * Copyright (c) 2021 Semihalf. + * Copyright (c) 2022 Bjoern A. Zeeb + * + * 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. + */ +/* + * Based on QorIQ LS1088A Reference Manual, Rev. 1, 11/2020. + * [LS1088ARM.pdf] + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +static uint8_t ls1088a_pltfrm_pll_divs[] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0 +}; + +static struct qoriq_clk_pll_def ls1088a_pltfrm_pll = { + .clkdef = { + .name = "ls1088a_platform_pll", + .id = QORIQ_CLK_ID(QORIQ_TYPE_PLATFORM_PLL, 0), + .flags = 0 + }, + .offset = 0x60080, + .shift = 1, + .mask = 0xFE, + .dividers = ls1088a_pltfrm_pll_divs, + .flags = QORIQ_CLK_PLL_HAS_KILL_BIT +}; + +static const uint8_t ls1088a_cga_pll_divs[] = { + 2, 3, 4, 0 +}; + +static struct qoriq_clk_pll_def ls1088a_cga_pll1 = { + .clkdef = { + .name = "ls1088a_cga_pll1", + .id = QORIQ_CLK_ID(QORIQ_TYPE_INTERNAL, 0), + .flags = 0 + }, + .offset = 0x80, + .shift = 1, + .mask = 0xFE, + .dividers = ls1088a_cga_pll_divs, + .flags = QORIQ_CLK_PLL_HAS_KILL_BIT +}; + +static struct qoriq_clk_pll_def ls1088a_cga_pll2 = { + .clkdef = { + .name = "ls1088a_cga_pll2", + .id = QORIQ_CLK_ID(QORIQ_TYPE_INTERNAL, 20), + .flags = 0 + }, + .offset = 0xA0, + .shift = 1, + .mask = 0xFE, + .dividers = ls1088a_cga_pll_divs, + .flags = QORIQ_CLK_PLL_HAS_KILL_BIT +}; + +static struct qoriq_clk_pll_def *ls1088a_cga_plls[] = { + &ls1088a_cga_pll1, + &ls1088a_cga_pll2 +}; + + +/* 4.7.2 Core Cluster a Clock Control/Status Register (CLKC1CSR - CLKC2CSR) */ +static const char *ls1088a_cmux0_parent_names[] = { + "ls1088a_cga_pll1", + "ls1088a_cga_pll1_div2", + "ls1088a_cga_pll1_div4", + NULL, + "ls1088a_cga_pll2", + "ls1088a_cga_pll2_div2", + "ls1088a_cga_pll2_div4" +}; + +static struct clk_mux_def ls1088a_cmux0 = { + .clkdef = { + .name = "ls1088a_cmux0", + .id = QORIQ_CLK_ID(QORIQ_TYPE_CMUX, 0), + .parent_names = ls1088a_cmux0_parent_names, + .parent_cnt = nitems(ls1088a_cmux0_parent_names), + .flags = 0 + }, + .offset = 0x70000, + .shift = 27, + .width = 4, + .mux_flags = 0 +}; + +static struct clk_mux_def ls1088a_cmux1 = { + .clkdef = { + .name = "ls1088a_cmux1", + .id = QORIQ_CLK_ID(QORIQ_TYPE_CMUX, 1), + .parent_names = ls1088a_cmux0_parent_names, + .parent_cnt = nitems(ls1088a_cmux0_parent_names), + .flags = 0 + }, + .offset = 0x70020, + .shift = 27, + .width = 4, + .mux_flags = 0 +}; + +/* 4.4.2 HWAaCSR (HWA1CSR - HWA3CSR) */ +static const char *ls1088a_hwaccel1_parent_names[] = { + "ls1088a_platform_pll", + "ls1088a_cga_pll1", + "ls1088a_cga_pll1_div2", + "ls1088a_cga_pll1_div3", + "ls1088a_cga_pll1_div4", + NULL, /* HWAMUX1 External Clock Source */ + "ls1088a_cga_pll2_div2", + "ls1088a_cga_pll2_div3" +}; + +static const char *ls1088a_hwaccel2_parent_names[] = { + "ls1088a_platform_pll", + "ls1088a_cga_pll2", + "ls1088a_cga_pll2_div2", + "ls1088a_cga_pll2_div3", + "ls1088a_cga_pll2_div4", + NULL, /* HWAMUX2 External Clock Source */ + "ls1088a_cga_pll1_div2", + "ls1088a_cga_pll1_div3" +}; + +static const char *ls1088a_hwaccel3_parent_names[] = { + "ls1088a_platform_pll", + NULL, + NULL, + NULL, + NULL, + NULL, /* HWAMUX3 External Clock Source */ + "ls1088a_cga_pll2_div2", + "ls1088a_cga_pll2_div3" +}; + +static struct clk_mux_def ls1088a_hwaccel1 = { + .clkdef = { + .name = "ls1088a_hwaccel1", + .id = QORIQ_CLK_ID(QORIQ_TYPE_HWACCEL, 0), + .parent_names = ls1088a_hwaccel1_parent_names, + .parent_cnt = nitems(ls1088a_hwaccel1_parent_names), + .flags = 0 + }, + .offset = 0x10, + .shift = 27, + .width = 4, + .mux_flags = 0 +}; + +static struct clk_mux_def ls1088a_hwaccel2 = { + .clkdef = { + .name = "ls1088a_hwaccel2", + .id = QORIQ_CLK_ID(QORIQ_TYPE_HWACCEL, 1), + .parent_names = ls1088a_hwaccel2_parent_names, + .parent_cnt = nitems(ls1088a_hwaccel2_parent_names), + .flags = 0 + }, + .offset = 0x30, + .shift = 27, + .width = 4, + .mux_flags = 0 +}; + +static struct clk_mux_def ls1088a_hwaccel3 = { + .clkdef = { + .name = "ls1088a_hwaccel3", + .id = QORIQ_CLK_ID(QORIQ_TYPE_HWACCEL, 2), + .parent_names = ls1088a_hwaccel3_parent_names, + .parent_cnt = nitems(ls1088a_hwaccel3_parent_names), + .flags = 0 + }, + .offset = 0x50, + .shift = 27, + .width = 4, + .mux_flags = 0 +}; + + +static struct clk_mux_def *ls1088a_mux_nodes[] = { + &ls1088a_cmux0, + &ls1088a_cmux1, + &ls1088a_hwaccel1, + &ls1088a_hwaccel2, + &ls1088a_hwaccel3 +}; + +static int +ls1088a_clkgen_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if(!ofw_bus_is_compatible(dev, "fsl,ls1088a-clockgen")) + return (ENXIO); + + device_set_desc(dev, "LS1088A clockgen"); + return (BUS_PROBE_DEFAULT); +} + +static int +ls1088a_clkgen_attach(device_t dev) +{ + struct qoriq_clkgen_softc *sc; + + sc = device_get_softc(dev); + + sc->pltfrm_pll_def = &ls1088a_pltfrm_pll; + sc->cga_pll = ls1088a_cga_plls; + sc->cga_pll_num = nitems(ls1088a_cga_plls); + sc->mux = ls1088a_mux_nodes; + sc->mux_num = nitems(ls1088a_mux_nodes); + sc->flags = QORIQ_LITTLE_ENDIAN; + + return (qoriq_clkgen_attach(dev)); +} + +static device_method_t ls1088a_clkgen_methods[] = { + DEVMETHOD(device_probe, ls1088a_clkgen_probe), + DEVMETHOD(device_attach, ls1088a_clkgen_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_1(ls1088a_clkgen, ls1088a_clkgen_driver, ls1088a_clkgen_methods, + sizeof(struct qoriq_clkgen_softc), qoriq_clkgen_driver); + +EARLY_DRIVER_MODULE(ls1088a_clkgen, simplebus, ls1088a_clkgen_driver, 0, 0, + BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 4bcc4ef122cd..bd5713533f32 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -507,6 +507,7 @@ arm64/qoriq/qoriq_dw_pci.c optional pci fdt SOC_NXP_LS arm64/qoriq/qoriq_therm.c optional pci fdt SOC_NXP_LS arm64/qoriq/qoriq_therm_if.m optional pci fdt SOC_NXP_LS arm64/qoriq/clk/ls1046a_clkgen.c optional clk SOC_NXP_LS +arm64/qoriq/clk/ls1088a_clkgen.c optional clk SOC_NXP_LS arm64/qoriq/clk/lx2160a_clkgen.c optional clk SOC_NXP_LS arm64/qoriq/clk/qoriq_clk_pll.c optional clk SOC_NXP_LS arm64/qoriq/clk/qoriq_clkgen.c optional clk SOC_NXP_LS