From nobody Sat Nov 16 19:04:28 2024 X-Original-To: dev-commits-src-main@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 4XrNbw4lldz5dhZp; Sat, 16 Nov 2024 19: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XrNbw3vw9z4Z5N; Sat, 16 Nov 2024 19: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=1731783868; 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=qNIBiYs3CJqEDf6Rrpcu543g3SbwKXBHATuB4fLx/bw=; b=vIi9aLAC8iCeY9SmRKZNLmmaOmCX+Ld9SBZ9VoUzD/CXaJCKGO1A05sCqnbTKDs+/H8x7T GyyB3BoeQ2jEY1cq1aWJrl41dDN+4Y5+aP1F3Lt/v63Svc+eyKKbz1GY0OLunPRoAcwNRV k1iSkXi0lNZ+5BcBCGCh80CNuYqdyhpMnhrCHjs1VyS4Qu25PU3n6D6l8qEyRTOTjqgWvd Jj5/jnunQB+tQFaRTw8IBPIA6lLe1A8qpfAKYCEyeaYrDf27Ooug5SsmJZ4AQgU/lNFRO0 gvIN/oMbNcdI/2B16rn9+pHOPP9DpNMFlb3Me3dnhHe10m+zMO0YCVwtcG+zlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731783868; 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=qNIBiYs3CJqEDf6Rrpcu543g3SbwKXBHATuB4fLx/bw=; b=ponJ7zK1MQEPR71luhfZCeTAGpbKt3l/Ge5MY4RPB7T0MW/NVve/zxmxvlm5pG6fRnxC42 bh1MLFdDuB7NS08An5whU0ohL8dgsM56YY9nT9igSsOuE0ydJ0Z2wyfn4DkUec0HV9uWQo TxuuDEZjbqQRwCwX6EwxzKJuVLYbvMqWuQ0XGx6DNSVaOCJ1LTtDleXFDHkr0EcqMp9K63 7eDJnOaZ3gAksEUGcUgaZ4meic4tMXgQy0TCHnApFZo/aZuLzrUIMkw57WYNVJP3QGC3Pt 1SWCUc0LnyLua4EvTanbIjlvhC3DXB/fJvwHTww35ljyyxLwjdIIAgX+eKAzZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731783868; a=rsa-sha256; cv=none; b=uthB00qT7k3vUYEs7gGXHZ6vz1yPspe/VIw+llBw+HtAhJmlJhzl9Xy1n7TL2k8EcR0nUd mUE7WYY4QkjHyHpyqHHNFv8xC96uBzQk0EtAeYX1T3mQPebSpC1Gm0JjFXBo/exyTDEydX 6glWlXC9BP6MmClMFOmZK3kpvdAjQTEGHDKjlja1nKa7aDBBSlxacGcArX4Iy1A270D8x2 39NwD3gecg7BAXGZiNwkq9aloNm3ny7GpmUfc2dfsKbR9rwIXvqDeNEaJVCFyC0BrNFT3n qcssbgbXIdG6ouRioAIqn19Z4j5SdmIyPnEC8GaD+hJRjr3y0dqN6/ZfW2V7sA== 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 4XrNbw3W4gzK9W; Sat, 16 Nov 2024 19:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AGJ4S05020809; Sat, 16 Nov 2024 19:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AGJ4SH6020806; Sat, 16 Nov 2024 19:04:28 GMT (envelope-from git) Date: Sat, 16 Nov 2024 19:04:28 GMT Message-Id: <202411161904.4AGJ4SH6020806@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: 9ddd516b8862 - main - riscv: enable allwinner RTC List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 9ddd516b886218af809dbf40eeda1ed388e2879c Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9ddd516b886218af809dbf40eeda1ed388e2879c commit 9ddd516b886218af809dbf40eeda1ed388e2879c Author: Mitchell Horne AuthorDate: 2024-11-15 17:20:35 +0000 Commit: Mitchell Horne CommitDate: 2024-11-16 19:04:04 +0000 riscv: enable allwinner RTC For the Allwinner D1 (Nehza) SBC. This RTC driver is also a clock provider, which registers two fixed clocks. In all the devices we currently support, the names of the clocks are present in the "clock-output-names" property of the device tree. This is not the case for the D1 DTS, as this property does not appear in upstream. Therefore the clock definitions are statically assigned a name, which is overridden when specified. Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47514 --- sys/arm/allwinner/aw_rtc.c | 24 ++++++++++++++++-------- sys/riscv/allwinner/files.allwinner | 1 + sys/riscv/conf/std.allwinner | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sys/arm/allwinner/aw_rtc.c b/sys/arm/allwinner/aw_rtc.c index 9938601f17ce..a13c0e7d926e 100644 --- a/sys/arm/allwinner/aw_rtc.c +++ b/sys/arm/allwinner/aw_rtc.c @@ -134,6 +134,7 @@ static struct ofw_compat_data compat_data[] = { { "allwinner,sun7i-a20-rtc", (uintptr_t) &a20_conf }, { "allwinner,sun6i-a31-rtc", (uintptr_t) &a31_conf }, { "allwinner,sun8i-h3-rtc", (uintptr_t) &h3_conf }, + { "allwinner,sun20i-d1-rtc", (uintptr_t) &h3_conf }, { "allwinner,sun50i-h5-rtc", (uintptr_t) &h3_conf }, { "allwinner,sun50i-h6-rtc", (uintptr_t) &h3_conf }, { NULL, 0 } @@ -147,11 +148,13 @@ struct aw_rtc_softc { static struct clk_fixed_def aw_rtc_osc32k = { .clkdef.id = 0, + .clkdef.name = "osc32k", .freq = 32768, }; static struct clk_fixed_def aw_rtc_iosc = { .clkdef.id = 2, + .clkdef.name = "iosc", }; static void aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev); @@ -249,24 +252,29 @@ aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev) { phandle_t node; int nclocks; + /* + * If the device tree gives us specific output names for the clocks, + * use them. + */ node = ofw_bus_get_node(dev); nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", &clknames); - /* No clocks to export */ - if (nclocks <= 0) - return; + if (nclocks > 0) { + if (nclocks != 3) { + device_printf(dev, + "Found %d clocks instead of 3, aborting\n", + nclocks); + return; + } - if (nclocks != 3) { - device_printf(dev, "Having only %d clocks instead of 3, aborting\n", nclocks); - return; + aw_rtc_osc32k.clkdef.name = clknames[0]; + aw_rtc_iosc.clkdef.name = clknames[2]; } clkdom = clkdom_create(dev); - aw_rtc_osc32k.clkdef.name = clknames[0]; if (clknode_fixed_register(clkdom, &aw_rtc_osc32k) != 0) device_printf(dev, "Cannot register osc32k clock\n"); - aw_rtc_iosc.clkdef.name = clknames[2]; aw_rtc_iosc.freq = sc->conf->iosc_freq; if (clknode_fixed_register(clkdom, &aw_rtc_iosc) != 0) device_printf(dev, "Cannot register iosc clock\n"); diff --git a/sys/riscv/allwinner/files.allwinner b/sys/riscv/allwinner/files.allwinner index ee7ad9be1e70..e4849e53e339 100644 --- a/sys/riscv/allwinner/files.allwinner +++ b/sys/riscv/allwinner/files.allwinner @@ -1,2 +1,3 @@ +arm/allwinner/aw_rtc.c optional aw_rtc fdt arm/allwinner/aw_wdog.c optional aw_wdog diff --git a/sys/riscv/conf/std.allwinner b/sys/riscv/conf/std.allwinner index a781164d0632..2071d15c3b24 100644 --- a/sys/riscv/conf/std.allwinner +++ b/sys/riscv/conf/std.allwinner @@ -2,6 +2,7 @@ # Allwinner SoC support # +device aw_rtc # Allwinner Real-time Clock device aw_wdog # Allwinner Watchdog files "../allwinner/files.allwinner"