From patchwork Mon Jun 29 12:42:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 2486 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id CA7C21C0761 for ; Mon, 29 Jun 2026 15:00:06 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=baylibre.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-23984-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-23984-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id CC04B319A7A2 for ; Mon, 29 Jun 2026 12:45:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ACFC40910F; Mon, 29 Jun 2026 12:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="NJH64pyW" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C370D40862C for ; Mon, 29 Jun 2026 12:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782736965; cv=none; b=Z1TvWZBvsz3Gm3f4V/3chBe3NTxmDtY1eU9odHgoLLBYNYSWfJTeUR+BjdDsCSxviCeGVvr/JjzkZcfe8iBR8m1oc9YSeAmXeepYUe3+QnxAt5YlK/o8H/RBnnS23NwL0vraoJ1t91p8XcWyGG2tJq3p8gvKNy2HjoF0YzBMrtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782736965; c=relaxed/simple; bh=5CSoUIy/v6LOzSzkVQ2mOnhu7hJrrhe9yfYnkVNt/3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UeR21JPmdz3oyJiWPl/or7Us/sA637xbTIa/IPUv1kGyZ9pMozVN5Ump+sWuNqogJmcYWozG/kEEOHC0z2PuwlEoUGCkf3uqC5Fl0mIU9CH+9l//FJasHi/h6r9MtJADj1NtrbCqzTpXxHGbZ+hlHvQyftW/2wJ6PcZXVhaZonQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=NJH64pyW; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so23220435e9.1 for ; Mon, 29 Jun 2026 05:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1782736961; x=1783341761; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QvuvGrw74bcC43tNkUtjQENE+L2SxKO7K1MrIT8vI48=; b=NJH64pyWxgX1+TIMo8hUvSA1t0kl8XgcAk2AemSoKY+TzT7+u0/CUCJYDwu1Iar7iX gOfeJpJ+tR2dgZwGw++owA4eL4ztxgE1ZJQ/ACdIGk254CNdnMAiDpwe8wZCS2xCRTk/ jzc5iPCR1iaml87Mh74JWQ2zDRnwxUtrAuK826YGTEiyUO2RdtsqK+TT8DaCUWThsIHD WoOJhA4dpGmT1MeY9iyZIjXCkDW+KVs5yqqr+IRgOkVfyvsEIwk2/ibJk6Za6ku3ZQWf iJEYA8TOA5j0boxWJ2/OEhRx6Zpiwe12jhEU7ipyXZZLQ28/TEIo41EplExSCF1Aa+VX fX9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782736961; x=1783341761; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=QvuvGrw74bcC43tNkUtjQENE+L2SxKO7K1MrIT8vI48=; b=f9nYosAVJ9utj35iqoMvSvIfXQ7fiqLtJT/ZNd1EHvFOSY7qlySXeLCyPRODKYY8Kx lpT1M4qw2t53HLesGepymZo5IpPf7/zhGHYrXHOzBtchsDr3Psz2ynnCaazkp2h9Canb 1HYdvoOSK4rijthlkH8VdBdCfw53+jsl5v7VO7B9Z/2qxdFoqsXbG5wAyNGUrVpTRmyQ EniEx7TallmANGTFbr28VkvD3ySSo6VE/CpniE102Fq5CYp+ZDu2NKKlYvK7uBLsJSQy Ns+8mEixKH+h2aaRT4jBmQ120YJJ2u+6Y7N5MfmqfWeK8DxDLaBceTIn7Rrn3fseyEOP s2rg== X-Forwarded-Encrypted: i=1; AFNElJ/1IHHfNS2droHDu1MGdipzLt1U6vJeqR3wpjgb6wYNFfuM2Nay0yJ+h4zu5V/HDjjtlcVXVAVr237sCA==@lists.linux.dev X-Gm-Message-State: AOJu0Yw76JgOvoCknPgMDMbIqkGLzW1m0ocGuPXYpJJ/dH/NmhR8IyzB 1gLItccdAN8XxRPpyTO1B6HpsND8Pnoka1YNOBZ36q3G2jRgpBJq+pPhKD60mtTnJ+U= X-Gm-Gg: AfdE7cnP44D2tFcps8BK3T8xjEwVafn5oSZ0ZJeUwp1lkFzqDYmaOPumBLNUoYdUXt6 f3NGABPi2PoStHBcBTRWErZZ6CYCndlei4v6z8TmRnaV2gl7HFu1m/Kj2enOKqz4GaIx1S8zygA /lP9utet5/yp88zNMdgLmreV2YbSD+M+7LZlQeXuby2IxD963OhfrmAfvQUnuRk77jTLuIjU5X/ KlPWf5obqCplCyghULmV164oKHnJNIow20sWqttOCtuSfD76BCwnYjUrqycb3qJa1ay8jhvTS0h zSfBjv0fKR6A0QV7D3PZK1Ly5Il7g/QtXGJUdG/8LQSFSQiA8sGuV3igjioRQxuLmB8JCqEhy5z PGHwGcLtfnAbkO51q00Va45ExgNza+0ny07EVgbutiipqF1Kg7GQ3aK1VMmhOHpxIc7nq7Zt2vo IgGqwgPA4OM0Y= X-Received: by 2002:a05:600c:e555:10b0:492:4a70:faaa with SMTP id 5b1f17b1804b1-4926685af4cmr178735795e9.11.1782736961340; Mon, 29 Jun 2026 05:42:41 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:1d21:f5d5:2d3c:23a7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4926c00a34esm181463855e9.0.2026.06.29.05.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 05:42:40 -0700 (PDT) From: Jerome Brunet Date: Mon, 29 Jun 2026 14:42:10 +0200 Subject: [PATCH v2 6/6] clk: sunxi-ng: sun6i-rtc: add a733 support Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260629-a733-rtc-v2-6-7b72112784f8@baylibre.com> References: <20260629-a733-rtc-v2-0-7b72112784f8@baylibre.com> In-Reply-To: <20260629-a733-rtc-v2-0-7b72112784f8@baylibre.com> To: Junhui Liu , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Michael Turquette , Stephen Boyd , Maxime Ripard Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Jerome Brunet X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6063; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=5CSoUIy/v6LOzSzkVQ2mOnhu7hJrrhe9yfYnkVNt/3U=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBqQmgxq2HH6bfU6XRMG/P3wAg/3/Lz/I6SoI1Mq iWTTigZ2J6JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCakJoMQAKCRDm/A8cN/La hSYkD/450bshj2S5XxoAoJje9mK8Hi8e1BZOuGTkYPjAq8k3Um0UbnvoobjUeqO5KH+YrA9LBd3 x3g9eAg3ArRNrqV0WIvcGJapW4BU7ufAkJj8PAOXZBMMZ19K0p9CakT80ib2+TVC6YblC56I2tX pxKBdUNo5F6yFyZoBcyW2lr+b7QPej8EXlFFxq5K9xnAj5kn5QhWkDpIS5f7/ryHonSjS3SGTD8 PJw6ctyYz27PASy+HNF4tWOSs4s7HPNsGWg1GVHh5wSE8rv/RvZzOupwvTQ06S2IRulgWuNbKIS RIIVoxwRijTBSWpdxKMfSCkx1ZTOMs8dQwUwU1xrRbnrPFlizvWyupqXowx/P9yAyqP5UEBhjKZ i7c/01awneVW10zbHpE6BK1zR00AFp8dwwx5Mt3VZmPrM1/Yvo3lbWGJyu7KLY7HEhS7RbSV84d yUlQOblvMLk9cCNLMMBjBcO+Pp4JK0yj9/h84+y1H7md6hwzJ7qmdktIcWav43hAqTxDDxV/c6y 3xcXlLjU4i9DFB5Sbn8iF44HCo2Y+gDMyKw60Vi8/aSZl26yZwRiQUHfxo3rqdMcuTQlIt2Hfd3 uVqaD8OdMWMzRXUSolpIMWcbe7k26NPJMM54wnMTU0+hB6am9457nSvn38I+unrA/BTVw4j4W4L kbQ+TPKhpGhohyQ== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-2.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; PRECEDENCE_BULK(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[baylibre.com:email,tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo]; TAGGED_RCPT(0.00)[dt]; FUZZY_BLOCKED(0.00)[rspamd.com]; DMARC_NA(0.00)[baylibre.com]; RCPT_COUNT_TWELVE(0.00)[18]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[pigmoral.tech,bootlin.com,kernel.org,gmail.com,sholland.org,baylibre.com]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; TAGGED_FROM(0.00)[bounces-23984-noreply=patchwork.local]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jbrunet@baylibre.com,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: CA7C21C0761 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Add support for the sun60i a733 CCU RTC. Compared to the a523, this SoC has a different input oscillator divider which auto-detects the oscillator rate and select a divider to provide a fixed 32768Hz clock. It also provides several phy reference clocks with dedicated clock gates. Signed-off-by: Jerome Brunet --- drivers/clk/sunxi-ng/ccu-sun6i-rtc.c | 74 ++++++++++++++++++++++++++++++++++-- drivers/clk/sunxi-ng/ccu-sun6i-rtc.h | 2 +- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c index 25dd87e78eb7..2ec09e346472 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c +++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c @@ -42,11 +42,16 @@ #define LOSC_OUT_GATING_REG 0x60 #define DCXO_CTRL_REG 0x160 +#define DCXO_CTRL_DCXO_EN BIT(1) #define DCXO_CTRL_CLK16M_RC_EN BIT(0) +#define DCXO_GATING_REG 0x16c + struct sun6i_rtc_match_data { bool have_ext_osc32k : 1; bool have_iosc_calibration : 1; + bool have_dcxo_status : 1; + bool have_phy_ref_gates : 1; bool rtc_32k_single_parent : 1; const struct clk_parent_data *osc32k_fanout_parents; u8 osc32k_fanout_nparents; @@ -213,7 +218,12 @@ static struct ccu_mux osc32k_clk = { }, }; -/* This falls back to the global name for fwnodes without a named reference. */ +/* + * This falls back to the global name for fwnodes without a named reference. + * NOTE: osc24M name might be misleading the oscillator could also be a 26MHz + * or a 19.2MHz one starting with the a733. The original name is kept anyway + * in case anything is relying on it. + */ static const struct clk_parent_data osc24M[] = { { .fw_name = "hosc", .name = "osc24M" } }; @@ -227,8 +237,28 @@ static struct clk_fixed_factor osc24M_32k_div_clk = { 0), }; -static SUNXI_CCU_GATE_HW(osc24M_32k_clk, "osc24M-32k", &osc24M_32k_div_clk.hw, - LOSC_OUT_GATING_REG, BIT(16), 0); +static struct clk_div_table osc24M_32k_div_a733_table[] = { + { .val = 0, .div = 732 }, + { .val = 1, .div = 586 }, + { .val = 2, .div = 793 }, + { .val = 3, .div = 732 }, + { /* Sentinel */ }, +}; + +static struct ccu_div osc24M_32k_div_a733_clk = { + .enable = BIT(1), + .div = _SUNXI_CCU_DIV_TABLE(14, 2, osc24M_32k_div_a733_table), + .common = { + .reg = DCXO_CTRL_REG, + .hw.init = CLK_HW_INIT_PARENTS_DATA("osc24M-32k-div", + osc24M, + &ccu_rodiv_ops, + 0), + }, +}; + +static SUNXI_CCU_GATE(osc24M_32k_clk, "osc24M-32k", "osc24M-32k-div", + LOSC_OUT_GATING_REG, BIT(16), 0); static const struct clk_hw *rtc_32k_parents[] = { &osc32k_clk.common.hw, @@ -267,6 +297,15 @@ static struct ccu_mux osc32k_fanout_clk = { }, }; +static SUNXI_CCU_GATE_FW(hosc_serdes1_clk, "hosc-serdes1", "hosc", + DCXO_GATING_REG, BIT(5), 0); +static SUNXI_CCU_GATE_FW(hosc_serdes0_clk, "hosc-serdes0", "hosc", + DCXO_GATING_REG, BIT(4), 0); +static SUNXI_CCU_GATE_FW(hosc_hdmi_clk, "hosc-hdmi", "hosc", + DCXO_GATING_REG, BIT(1), 0); +static SUNXI_CCU_GATE_FW(hosc_ufs_clk, "hosc-ufs", "hosc", + DCXO_GATING_REG, BIT(0), 0); + static struct ccu_common *sun6i_rtc_ccu_clks[] = { &iosc_clk, &iosc_32k_clk, @@ -275,6 +314,11 @@ static struct ccu_common *sun6i_rtc_ccu_clks[] = { &osc24M_32k_clk.common, &rtc_32k_clk.common, &osc32k_fanout_clk.common, + &osc24M_32k_div_a733_clk.common, + &hosc_serdes1_clk.common, + &hosc_serdes0_clk.common, + &hosc_hdmi_clk.common, + &hosc_ufs_clk.common, }; static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clks = { @@ -288,6 +332,10 @@ static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clks = { [CLK_OSC24M_32K] = &osc24M_32k_clk.common.hw, [CLK_RTC_32K] = &rtc_32k_clk.common.hw, [CLK_OSC24M_32K_DIV] = &osc24M_32k_div_clk.hw, + [CLK_HOSC_UFS] = &hosc_ufs_clk.common.hw, + [CLK_HOSC_HDMI] = &hosc_hdmi_clk.common.hw, + [CLK_HOSC_SERDES0] = &hosc_serdes0_clk.common.hw, + [CLK_HOSC_SERDES1] = &hosc_serdes1_clk.common.hw, }, }; @@ -330,6 +378,15 @@ static const struct sun6i_rtc_match_data sun55i_a523_rtc_ccu_data = { .osc32k_fanout_nparents = ARRAY_SIZE(sun50i_r329_osc32k_fanout_parents), }; +static const struct sun6i_rtc_match_data sun60i_a733_rtc_ccu_data = { + .have_ext_osc32k = true, + .have_iosc_calibration = true, + .have_dcxo_status = true, + .have_phy_ref_gates = true, + .osc32k_fanout_parents = sun50i_r329_osc32k_fanout_parents, + .osc32k_fanout_nparents = ARRAY_SIZE(sun50i_r329_osc32k_fanout_parents), +}; + static const struct of_device_id sun6i_rtc_ccu_match[] = { { .compatible = "allwinner,sun50i-h616-rtc", @@ -343,6 +400,10 @@ static const struct of_device_id sun6i_rtc_ccu_match[] = { .compatible = "allwinner,sun55i-a523-rtc", .data = &sun55i_a523_rtc_ccu_data, }, + { + .compatible = "allwinner,sun60i-a733-rtc", + .data = &sun60i_a733_rtc_ccu_data, + }, {}, }; MODULE_DEVICE_TABLE(of, sun6i_rtc_ccu_match); @@ -375,6 +436,13 @@ int sun6i_rtc_ccu_probe(struct device *dev, void __iomem *reg) osc32k_fanout_init_data.parent_data = data->osc32k_fanout_parents; osc32k_fanout_init_data.num_parents = data->osc32k_fanout_nparents; + if (data->have_dcxo_status) + sun6i_rtc_ccu_hw_clks.hws[CLK_OSC24M_32K_DIV] = + &osc24M_32k_div_a733_clk.common.hw; + + if (!data->have_phy_ref_gates) + sun6i_rtc_ccu_hw_clks.num = CLK_OSC24M_32K_DIV + 1; + return devm_sunxi_ccu_probe(dev, reg, &sun6i_rtc_ccu_desc); } diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h index ab7b92b47f59..4f4f4cb00f1d 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h +++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h @@ -11,6 +11,6 @@ #define CLK_RTC_32K 6 #define CLK_OSC24M_32K_DIV 7 -#define CLK_NUMBER (CLK_OSC24M_32K_DIV + 1) +#define CLK_NUMBER (CLK_HOSC_SERDES1 + 1) #endif /* _CCU_SUN6I_RTC_H */