From nobody Tue May 07 16:04:28 2024 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 4VYjlJ69pBz5J7Br; Tue, 07 May 2024 16:04:28 +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 4VYjlJ2TfKz4QBK; Tue, 7 May 2024 16:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715097868; 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=oX8Y19FHiyxUCi7loaudPbe7A9OI2O3o8LMw7yqhNi4=; b=FXKpPZ+/2WLx9Tk4sVCmtmTBfwC84hqptaAtZjBcNnFaoZ43KKJQ6y6H554YdhrNaKtP8u JMwzxvxKLcf/oIvDM3Oyvviesl154RqsHz+QG/13FChLEjk93NwdLc1a+bL+i1RmQoJxRW nEruiivpk22FQrixuoyGPynIGVjSXO64IOOKqAJTGG8xD0mn0v2cAb0VEKh/1h4OqIOMr5 zkQ28c+Edw0lln0CEq6/ybcj2VOBEZg6PaSUC2KYzMqIAcWMO8XUf8Nh1w24ghk4kNgFbx MT/HqtMiKDFEmEufrUCYUzDLV76QO8NQnvTSGnf/uf+/jspThhTkpRWgeQuMlA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715097868; a=rsa-sha256; cv=none; b=W25bsksUourDlQ95pWzuGeTNTHKERv/FrDN6eE7VgF/zMsRd8IcQMl1EbbeQucWzsH9Rcm xaZp7BifrSqmgKA7Xo9x5HG5WsYjidsrBAWoF5YTnQDcppUXXwy5AkVMocrxxUu6OH7IJH cc3s2aOrDKdr5OHE0HbwWUHmdHg9sN8QXuEEuhjx0+4AnQRZTQhEjDTg9/iV7KQZnsYexA I9gmqwW2y4C5NAj3thlWq2/EaJkN+coLniUv0YYb/37/fxWMCrjZZRBmlAucZl+1Ur52s4 0P/oduyXyyxfI7mubDtE0ZENuysttKeOUas4SRBx/kBsDHZZv5nT9wJl3DkVmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715097868; 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=oX8Y19FHiyxUCi7loaudPbe7A9OI2O3o8LMw7yqhNi4=; b=nnf8HKy/SFrhR6oUxX3l8sgqnU8dImV23j2b4AZMxpia6aUqG9jv+xpIKsY5r/5ipiP8s3 0wheTo7PNMZeOSAJggd0WyfDtMwFm3W+3kFsonoSIhTze7TaioGaBb7CYZ7ougtj9wrk1k roZaKHcTFzpQlx4+0Eue4Qn96ls/BAYoLJx2Sru62eefbCpd/cukZgQz6rKpitlsudig5F 6mNu+yB2kmQrJfFSaHe779fDBevrijuK5zdQ5xyr7ksmJWyR3pe4yDGnL8A3FTd7Ql/fmm oWqGvu/V7I3qknwmOsBfxXhdJckXbrTt2fgOiYiLQWsSTqllBUFDmTjul4heMw== 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 4VYjlJ23bSzp1M; Tue, 7 May 2024 16:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 447G4SBJ049642; Tue, 7 May 2024 16:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 447G4SUu049639; Tue, 7 May 2024 16:04:28 GMT (envelope-from git) Date: Tue, 7 May 2024 16:04:28 GMT Message-Id: <202405071604.447G4SUu049639@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: cf0876820717 - main - starfive: add a syscon driver 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf0876820717192b4900b56c027b01dad35bc837 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=cf0876820717192b4900b56c027b01dad35bc837 commit cf0876820717192b4900b56c027b01dad35bc837 Author: Mitchell Horne AuthorDate: 2024-03-05 23:57:30 +0000 Commit: Mitchell Horne CommitDate: 2024-05-07 16:02:57 +0000 starfive: add a syscon driver It serves the purpose of attaching syscon devices as early as possible; this is required for early attachment of the PLL clock driver. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44270 --- sys/riscv/starfive/files.starfive | 1 + sys/riscv/starfive/starfive_syscon.c | 87 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/sys/riscv/starfive/files.starfive b/sys/riscv/starfive/files.starfive index e69de29bb2d1..48ca738936da 100644 --- a/sys/riscv/starfive/files.starfive +++ b/sys/riscv/starfive/files.starfive @@ -0,0 +1 @@ +riscv/starfive/starfive_syscon.c standard diff --git a/sys/riscv/starfive/starfive_syscon.c b/sys/riscv/starfive/starfive_syscon.c new file mode 100644 index 000000000000..dfc8fa8ba5d9 --- /dev/null +++ b/sys/riscv/starfive/starfive_syscon.c @@ -0,0 +1,87 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 The FreeBSD Foundation + * + * This software was developed by Mitchell Horne under + * sponsorship from the FreeBSD Foundation. + */ + +/* + * StarFive syscon driver. + * + * On the JH7110, the PLL clock driver is a child of the sys-syscon device. + * This needs to probe very early (BUS_PASS_BUS + BUS_PASS_ORDER_EARLY). + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +enum starfive_syscon_type { + JH7110_SYSCON_SYS = 1, + JH7110_SYSCON_AON, + JH7110_SYSCON_STG, +}; + +static struct ofw_compat_data compat_data[] = { + { "starfive,jh7110-sys-syscon", JH7110_SYSCON_SYS }, + { "starfive,jh7110-aon-syscon", JH7110_SYSCON_AON }, + { "starfive,jh7110-stg-syscon", JH7110_SYSCON_STG }, + + { NULL, 0 } +}; + +static int +starfive_syscon_probe(device_t dev) +{ + enum starfive_syscon_type type; + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if (type == 0) + return (ENXIO); + + switch (type) { + case JH7110_SYSCON_SYS: + device_set_desc(dev, "JH7110 SYS syscon"); + break; + case JH7110_SYSCON_AON: + device_set_desc(dev, "JH7110 AON syscon"); + break; + case JH7110_SYSCON_STG: + device_set_desc(dev, "JH7110 STG syscon"); + break; + } + + return (BUS_PROBE_DEFAULT); +} + + +static device_method_t starfive_syscon_methods[] = { + DEVMETHOD(device_probe, starfive_syscon_probe), + + DEVMETHOD_END +}; + +DEFINE_CLASS_1(starfive_syscon, starfive_syscon_driver, starfive_syscon_methods, + sizeof(struct syscon_generic_softc), simple_mfd_driver); + +EARLY_DRIVER_MODULE(starfive_syscon, simplebus, starfive_syscon_driver, 0, 0, + BUS_PASS_BUS + BUS_PASS_ORDER_EARLY); +MODULE_VERSION(starfive_syscon, 1);