From nobody Wed Sep 7 07:59:41 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 4MMvmZ5CHrz4bs0L; Wed, 7 Sep 2022 07:59:42 +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 4MMvmZ0W8nz472Y; Wed, 7 Sep 2022 07:59:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662537582; 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=PVbDJ8kabrZegoG1TUwPUOLbOVBJJWVEX1azJzavtYo=; b=HqOZrDia1DeKUq4GiIuI9Wt4jb8cwP5CAAqmWzqL2RvqSlFEwPpkNrh+MEBM7H4yDbxqbP HdmGByEWpYijyo3A0sgXGLyMnEKDuMB5H7fDdn5tPaoQk+J6We9GKorJ2Gkc2A7xCxnhD8 hTGo08cdoIgCoTQrFjwOqVKINeElD606jY//2syQJDP0ENtK/jkpITwrwg/XKtEKp7k78j SnVomTa1mVFYIWeSAFiLhRD83fbjbJH4E1oS1bQ20N84hhF9BFHGRxzXl4/vQnIQUu380k lLRLudmyitDrg/jLA1dKimEMYPZPRFEAl10riebLgeEtic3l8Plqa/6MUwue9g== 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 4MMvmY5m18zS5F; Wed, 7 Sep 2022 07:59:41 +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 2877xfwp082018; Wed, 7 Sep 2022 07:59:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2877xf93082017; Wed, 7 Sep 2022 07:59:41 GMT (envelope-from git) Date: Wed, 7 Sep 2022 07:59:41 GMT Message-Id: <202209070759.2877xf93082017@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Kornel=20Dul=C4=99ba?= Subject: git: 4a4c6dc9a3e8 - main - Add ARMADA38X gateclk control 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: kd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a4c6dc9a3e8c28ca55f8e1f6b1f6252e1a8a618 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662537582; 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=PVbDJ8kabrZegoG1TUwPUOLbOVBJJWVEX1azJzavtYo=; b=VTlV3KUf9xddkAkaNBcS7NnjinL4N/KBMAmmvz5/805ECMO/cq4mu560g2Kc6trE9GD7ud O8LTZolFdKAxnbyIF9I1O7ALv/6mSeIC1jdswg1/aPRBm0VyohmOnE5+9Ila9YIHb6nQ/A sbonObubRe409CXEEc9AEAjaAP8/RemXAP4RV0YkZYFF0H9sevJb9jy4yXpW2peg6cJKJb IqeTJ1ZcRLy5HzQe+sAGMSnuizPDngRB8JZ60LFHMulwFBh2Da7yZuUWSIyPh7XU1Zq9CK oC0gKUDNeDKG0vgVCXtjwGEOp23t9N006oKkzfqR9Ox0Yvg7OQU7GeT8A+5PkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662537582; a=rsa-sha256; cv=none; b=C9UQUDKpBG/9WLzLnLzyfzlEmhsPoG+jH1z9YqYHnUsk92ei81MzGde/vBIxROKIjyXwXr 1XiWtokdeV5+1iNJWsWvg3Ia/2/6E9hiZYF7B8uzLGLMe5bWyqeawgho98JNGCHj3+3pMs M50AJoj6nHtC1cTr8rtr0UfcDrSNYO1y6GfmWJ63frfUKn7kvHH3Cbg3nPMRt5oyz6I24R Jc/IrP4aEvBX/V0adhl+0r4sIRiwiWIz5NmsVBLRcxI5aDZwMK0M6LgCs/Qpd1Dnlh/kQx jox8roIA/wCVDHmclLhI+9H6PAqoqVjEFTjCT05VTaHiEOBJbnyENfv9cHcroQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kd: URL: https://cgit.FreeBSD.org/src/commit/?id=4a4c6dc9a3e8c28ca55f8e1f6b1f6252e1a8a618 commit 4a4c6dc9a3e8c28ca55f8e1f6b1f6252e1a8a618 Author: Albert Jakieła AuthorDate: 2022-07-12 09:16:21 +0000 Commit: Kornel Dulęba CommitDate: 2022-09-07 07:44:58 +0000 Add ARMADA38X gateclk control This patch introduces basic gate control driver for Armada38x SoC. Each gate controls coreclk output to a given peripheral. Reviewed by: manu Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D36455 --- sys/arm/mv/clk/armada38x_gateclk.c | 294 +++++++++++++++++++++++++++++++++++++ sys/arm/mv/files.arm7 | 1 + 2 files changed, 295 insertions(+) diff --git a/sys/arm/mv/clk/armada38x_gateclk.c b/sys/arm/mv/clk/armada38x_gateclk.c new file mode 100644 index 000000000000..17928e327409 --- /dev/null +++ b/sys/arm/mv/clk/armada38x_gateclk.c @@ -0,0 +1,294 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2022 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 ``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 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "clkdev_if.h" + +struct armada38x_gateclk_softc +{ + struct clkdom *clkdom; + struct mtx mtx; + const char* parent; +}; + +static struct clk_gate_def gateclk_nodes[] = +{ + { + .clkdef = { + .name = "gateclk-audio", + .id = 0, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 0, + }, + { + .clkdef = { + .name = "gateclk-eth2", + .id = 2, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 2, + }, + { + .clkdef = { + .name = "gateclk-eth1", + .id = 3, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 3, + }, + { + .clkdef = { + .name = "gateclk-eth0", + .id = 4, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 4, + }, + { + .clkdef = { + .name = "gateclk-mdio", + .id = 4, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 4, + }, + { + .clkdef = { + .name = "gateclk-usb3h0", + .id = 9, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 9, + }, + { + .clkdef = { + .name = "gateclk-usb3h1", + .id = 10, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 10, + }, + { + .clkdef = { + .name = "gateclk-bm", + .id = 13, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 13, + }, + { + .clkdef = { + .name = "gateclk-crypto0z", + .id = 14, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 14, + }, + { + .clkdef = { + .name = "gateclk-sata0", + .id = 15, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 15, + }, + { + .clkdef = { + .name = "gateclk-crypto1z", + .id = 16, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 16, + }, + { + .clkdef = { + .name = "gateclk-sdio", + .id = 17, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 17, + }, + { + .clkdef = { + .name = "gateclk-usb2", + .id = 18, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 18, + }, + { + .clkdef = { + .name = "gateclk-crypto1", + .id = 21, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 21, + }, + { + .clkdef = { + .name = "gateclk-xor0", + .id = 22, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 22, + }, + { + .clkdef = { + .name = "gateclk-crypto0", + .id = 23, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 23, + }, + { + .clkdef = { + .name = "gateclk-xor1", + .id = 28, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 28, + }, + { + .clkdef = { + .name = "gateclk-sata1", + .id = 30, + .parent_cnt = 1, + .flags = 0, + }, + .shift = 30, + } +}; + +static int armada38x_gateclk_probe(device_t dev); +static int armada38x_gateclk_attach(device_t dev); + +static device_method_t armada38x_gateclk_methods[] = { + DEVMETHOD(device_probe, armada38x_gateclk_probe), + DEVMETHOD(device_attach, armada38x_gateclk_attach), + + DEVMETHOD_END +}; + +static driver_t armada38x_gateclk_driver = { + "armada38x_gateclk", + armada38x_gateclk_methods, + sizeof(struct armada38x_gateclk_softc), +}; + +EARLY_DRIVER_MODULE(armada38x_gateclk, simplebus, armada38x_gateclk_driver, 0, 0, + BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE + 1); + +static int +armada38x_gateclk_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if(!ofw_bus_is_compatible(dev, "marvell,armada-380-gating-clock")) + return (ENXIO); + + device_set_desc(dev, "ARMADA38X gateclk"); + + return (BUS_PROBE_DEFAULT); +} + +static int +armada38x_gateclk_attach(device_t dev) +{ + struct armada38x_gateclk_softc *sc; + phandle_t node; + int i, error; + clk_t clock; + + sc = device_get_softc(dev); + node = ofw_bus_get_node(dev); + + mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); + + sc->clkdom = clkdom_create(dev); + if (sc->clkdom == NULL) { + device_printf(dev, "Cannot create clock domain.\n"); + return (ENXIO); + } + + error = clk_get_by_ofw_index(dev, node, 0, &clock); + if (error > 0) + return (error); + + sc->parent = clk_get_name(clock); + + for (i = 0; i < nitems(gateclk_nodes); ++i) { + gateclk_nodes[i].clkdef.parent_names = &sc->parent; + error = clknode_gate_register(sc->clkdom, &gateclk_nodes[i]); + if (error != 0) { + device_printf(dev, "Cannot create gate nodes\n"); + return (error); + } + } + + if (clkdom_finit(sc->clkdom) != 0) + panic("Cannot finalize clock domain initialization.\n"); + + return (0); +} diff --git a/sys/arm/mv/files.arm7 b/sys/arm/mv/files.arm7 index 47354c68733a..4595c6ba8f2b 100644 --- a/sys/arm/mv/files.arm7 +++ b/sys/arm/mv/files.arm7 @@ -37,3 +37,4 @@ dev/ahci/ahci_mv_fdt.c optional ahci arm/mv/clk/armada38x_coreclk.c standard arm/mv/clk/armada38x_gen.c standard +arm/mv/clk/armada38x_gateclk.c standard