From nobody Fri Jul 04 16:00:11 2025 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 4bYdd76MZnz61QbJ; Fri, 04 Jul 2025 16:00:11 +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 4bYdd75RJtz3chX; Fri, 04 Jul 2025 16:00:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751644811; 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=Kb90C8pHz0UmFTO8MxWLjBchhl5QJR+tjJ+0D9i2UJU=; b=deJ+iZ/cX0NxbfYcmbu7f1/DLltVqpmOmawUAa5YsF71Q+4mqAhCRwgpiq6VBOrST4+ZXw ROYt+N6ZX39h/zrI0GsI8GCxuMjf11VJFLmxv+DOQs8+MrSLCKfMuOemwVACkypON/RhCp M+ug5x1x7k574KVeKcDcLeAl3vsQ3OvJ8sCBpNbKDfx2XvAegt69w6dwL7sokpD2ozE5+B woEGOEB800PXL24xM6eettx9DbixA4QNb/6H+e7+2SAmh9jH84RRlQSAgy8fwOjUWEPE6n aWYDPWVyxW+We1iU8gM71UJLz9AXa+L1pTP4TEkRVG854FeGlufHZ31Zm78VCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751644811; 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=Kb90C8pHz0UmFTO8MxWLjBchhl5QJR+tjJ+0D9i2UJU=; b=lhrdRYeW0KEJbJISSUPMohNQeQvYw2bAdVsylcWLIwQEgeUL5IcVQW0B8TwLdxfFLCKOOD v5KNuZufkbycQevKQBPuaLwP7rbylBmMPntySsfL6Z6vNK+O0oJ4C3hXNZJwHbYkeeOJ5m +eMYt7KtRctOmED0QDfNPgLK8q5SBMitwWD9kFuVXxy+zehSAwPjOl3cklL4HulWgdNECN IFfcY7TVV1rO8bjgX7Tq3nEfiqdoAm02+6DcTYCyvg314eMLux1Y5Bpg7t8TqEgTVu4vdN NS9EOHHGwUYegnIESE1ZiHW7/PD9ZBuBox2aX+Z77ol4H9zEz2HCEIbkGlJg8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751644811; a=rsa-sha256; cv=none; b=lgnJrVp9g+dEPAniUwPm8n7fJgQVY7Dtq0ZUNGL5c+p+J3SJw/Il5wGwkOjeUkdYvhU+c7 010tsCC88PeW3ZHsqTr1dwvAfcqpGKC7WIwnjMkdrPbWEgfpF453i8P3WYOTGz4zxfdU/X Vo9xT23bm9vXpqOPSTwZqiNoNQa7ce1uE0DQ2H/wcTcC30wm1VlB25tjbrvmF5imo/uVWw 8314onEaBr1P4hwrgCltogZijEm+KuwIZCtKPy7FiatfXYWCYnl9yeab9If4fFxqA58YKW grLyC7vOyUxB0ZXSH/rD3gJkeBEoeFdlRWjzOaMhQ63Pxg3Cv0hyqW/7+viUKQ== 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 4bYdd75149zwmn; Fri, 04 Jul 2025 16:00:11 +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 564G0B7W093816; Fri, 4 Jul 2025 16:00:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 564G0BYK093811; Fri, 4 Jul 2025 16:00:11 GMT (envelope-from git) Date: Fri, 4 Jul 2025 16:00:11 GMT Message-Id: <202507041600.564G0BYK093811@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: deaae83da057 - 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: deaae83da0571af7c97acf8f1444a00350e21e3a Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=deaae83da0571af7c97acf8f1444a00350e21e3a commit deaae83da0571af7c97acf8f1444a00350e21e3a Author: Mitchell Horne AuthorDate: 2025-07-04 15:54:48 +0000 Commit: Mitchell Horne CommitDate: 2025-07-04 15:55:55 +0000 riscv: enable allwinner RTC (Second attempt.) 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. The driver also supports the older A10/A20 models, which don't export any clocks. Ensure this case is handled properly. Reviewed by: mmel Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D50369 --- sys/arm/allwinner/aw_rtc.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/sys/arm/allwinner/aw_rtc.c b/sys/arm/allwinner/aw_rtc.c index 9938601f17ce..4af57ab879e8 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); @@ -250,23 +253,33 @@ aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev) { int nclocks; 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 != 3) { - device_printf(dev, "Having only %d clocks instead of 3, aborting\n", nclocks); + /* Nothing to do. */ + if (!OF_hasprop(node, "clocks")) return; + + /* + * If the device tree gives us specific output names for the clocks, + * use them. + */ + nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", &clknames); + if (nclocks > 0) { + if (nclocks != 3) { + device_printf(dev, + "Found %d clocks names 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");