From patchwork Thu Jul 23 09:39:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 2795 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 5EB8E1C3E14 for ; Thu, 23 Jul 2026 11:57:17 +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-24734-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-24734-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 4FFB631F3FCD for ; Thu, 23 Jul 2026 09:43:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2270143551B; Thu, 23 Jul 2026 09:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="COPfxpvG" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 C08A5433E66 for ; Thu, 23 Jul 2026 09:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799611; cv=none; b=HZhRysfEcJ5LCszsvsY3ANW33f2/MvmxAGtP9dL2v0e5Olw4zCnWzvSIWCDhHwkfyntivTvF5MystJShP3Ni3P5tGc++zxCezwGUQuCG1EmQ24yyNQ67k6bIZ+niBsvwFNErPymIqvteSCy2V4dISq8aOzWHcbQZbkSx8Mylccg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799611; c=relaxed/simple; bh=h886BmU9pfC+RezdnkZ3J5Ik53qoiogLhSBSntAHgiM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SLA+HM2xYK6jaxZ6EhJXcRw09XJqz4MrPOdSdxDePEoPVTDuZCclkEexV7n0WIiBkIHFEFk4Xnu7EJJyMTkKKKqofn1YKZO4BrTKnKw8So5UeFva5IBlkl2DwKfHhFu5A+Y2nDsBX3lt5IzqClOcEDxcdIcwH0ygot9Yqx7usww= 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=COPfxpvG; arc=none smtp.client-ip=209.85.221.47 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-wr1-f47.google.com with SMTP id ffacd0b85a97d-47f64ca1c2dso94645f8f.2 for ; Thu, 23 Jul 2026 02:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1784799606; x=1785404406; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=unyjlYSQAHCuBkgYy9GiPNfKBr8X4sZKbeG1doQS/7s=; b=COPfxpvGb7uNbQJxR4RSAev81a+jJ+wIHdFZ8LVpmPkAlrc0dnCW1szTMHI2kEXnJL TDO5Gh2a0G+aUtQaqOObIsiOc61ciaN4WtIsIWZG7ua5Jewm3FCkwVZUhy+xbnmlhmNe Cx/azJMUt7EJpGiIBxGVH6/HPr24i4y/kUoVLznvLyq9nis1mvununszcSdjnWm2jW7Q 39H2rK8D0ibeE7OJwsVBJyXv/zhi31NFiyAckM8igExNeZUs80CKsIp3GnpftfSyJ4VZ g6sTW/Wt2h5C6Tn4Tk1gsCvrY9I7HXmfOiruhnh9qStr2bQkUgUymMqy47i3UubTv6+J GIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784799606; x=1785404406; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=unyjlYSQAHCuBkgYy9GiPNfKBr8X4sZKbeG1doQS/7s=; b=ktGrI+U3cGYfHd8xBcTXthMZFCfQBoxF4hhCZwjjeppkWLRGvYP+RU5SklCe83O1ay /b/lxUTRxfEa7C4YanFtuy6xXWfIodUC2KBH1hkWRocdl6lLcoTTwcfdz03SP9srNBbo 3CUBGap1jGNImpfu9axCOLQEskpihHJnbojAhVnSa7JQPhhoiIUoFZIiziKQ9gWNeWqM y6ITGcapgXAyTWU1WCbEevRrR9+TSHjMwWByujdtSX/mDV3766MQqitPZSCcIvcfAZh/ jBLAP1odaNvnG8jaNEbPX8e+qMuU8UDxe2gaN3CzdT83cAi7Kws1Hs7LLkwGp5XPuxAf zElg== X-Forwarded-Encrypted: i=1; AHgh+RoDHZSt/ItU6zo119nv6Oms2pfwWMRoHNTZXFMdPOAAGbpFBmbLRgP2+Gl/Q9HQD5+GNO3+OSor9A5Q5w==@lists.linux.dev X-Gm-Message-State: AOJu0YxhPj4zgaozmxQ+Tq+v4K7PxwQ2BdZ1I4MaVzHNypgmnOTOTLSA FvFbmAspqC18GSvyxYr4MxQzmR2vI3kjz7QGap0DvDIR9UygvbB/UWHw9C+vOQq0KDY= X-Gm-Gg: AR+sD105fhTUwn9xlBZSj7Gyktosra3gI96yAqwxeJNOXCAVqAvk8a0au2TNn+RHjgS kNW2kdI5Nmdi6MKrfo2o7VWAVCGF56u5qpHMw8ctODPewcilHFn+Sdu/LFYnLZ0f+RigDb244uT KasmEO2DiKLFzg+RnkF9DC7h7uLTuQhRpjhMDKYfw4WAhd9cDBbhgTJnPYUUYNvTY+QrPo3CifX 2Xv6SwjLkKttKJ9q9aF58FLVwSPPIwJ1l/BzMHAWEB+w/n5XU36Baznl7AyjR09nAx8SNJkLYKF DypOC5eMtL6pKD9D6f1QalBjo9usXokyyw/hNlDFb77r94hVaJvaWPDRVC3yYfdmtZq2m0TXwtz gI7PPM6TXNIe8u28L4hb0YvKqN+sqk5ZX1Xit71UBjv6ZYe1Msl3wJAvAmQlNoAmjMS0BF+qAU/ l7 X-Received: by 2002:a05:6000:27c2:b0:47f:920b:7fad with SMTP id ffacd0b85a97d-47f920b8051mr1216847f8f.51.1784799606034; Thu, 23 Jul 2026 02:40:06 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:3274:dbb5:2710:802b]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-47f85c6f076sm14217165f8f.34.2026.07.23.02.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 02:40:05 -0700 (PDT) From: Jerome Brunet Date: Thu, 23 Jul 2026 11:39:51 +0200 Subject: [PATCH v7 1/4] clk: sunxi-ng: mux: fix determine helper rate propagation Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260723-a733-rtc-v7-1-8fd68aab94ae@baylibre.com> References: <20260723-a733-rtc-v7-0-8fd68aab94ae@baylibre.com> In-Reply-To: <20260723-a733-rtc-v7-0-8fd68aab94ae@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=4256; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=h886BmU9pfC+RezdnkZ3J5Ik53qoiogLhSBSntAHgiM=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBqYeFtpYPA3bOOb2j0Z9hzyBatcOuHwPVa9K9nD Y0q6zTCxbCJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCamHhbQAKCRDm/A8cN/La hXFoEACQiqosl4kiv5gDmdbrtXdNvJ48ZH9JDp5cPQpUo/TJyNpAMmT5sefdW4IGUWqZ+oukkkf Z0pS8hwDD1kwY2rHFnt+6wyPhQo4y3SOvckimSFCONLnNQEz4UbUr7JBeYrugzt6/INv3wjUdf7 T8DBb6q3RKDzbncuWsX/QmFR5L2t92vuDCETY2IHpSI2p4S42P/XxptxLtMrkdvgM+mguKZOZ/5 nJAB8yCq8m3bJamX/PBrfI1yGBnvMXX2zGeIQR8xU4aCo01m6v1RZrta2SxmN25uK2E9mfRSPyA /+Pdlnt9zSCXfBjyM34JYxaNW9y4+hfDOwY+/qQoOViGeXM9My4IG1OqeLjhsoGjEZcprUweJUT cwHD/uc5xbvyTsNmfnub68J1scN71a3petL9skxO6u0AEmz9MMJn6sJJTTidPmNafxpkcgfY2Ez c8azmoaMNZMX+KDtlDXT6LYTWBCDZbTvyVHh7Krhnlnrh83p4MrlEv68EB+c6etnC9g5uQZY/92 tZ7rtUcBW03DB5w4mFXO+qEW4Ey1CA3UyCFcneniGBfr2w8cweBqgmUXxFnsFRoBDNfdJZz1EOX wqkIAohMIeAOvgigkj2icl0mrpqo/KjkcMMF+TmqHUQsYeRPxAYn/9HU2fVGNmgxeNMXB/mrUiO ktpwRCWZjUnHGGQ== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 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?= Applying the pre divider on the parent rate is wrong because, while handling rate propagation through determine_rate(), the framework will likely round the parent rate again while cycling through the possibilities, throwing away the prediv applied. This means, the parent rate will then be wrong when the prediv is unapplied from a parent rate on which it was never applied to begin with. The right way to do it is to unapply the prediv from the requested rate, which is the wanted rate at the input on the clock element, and pass this to framework to do its thing. Change the determine rate mux helper in this way. Fixes: 1c8d7af61b37 ("clk: sunxi-ng: convert from divider_round_rate_parent() to divider_determine_rate()") Signed-off-by: Jerome Brunet --- drivers/clk/sunxi-ng/ccu_mux.c | 57 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c index 09230728c400..4503c9780c39 100644 --- a/drivers/clk/sunxi-ng/ccu_mux.c +++ b/drivers/clk/sunxi-ng/ccu_mux.c @@ -92,66 +92,65 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common, struct clk_rate_request adj_req = *req; best_parent = clk_hw_get_parent(hw); - best_parent_rate = clk_hw_get_rate(best_parent); - + adj_req.best_parent_rate = clk_hw_get_rate(best_parent); adj_req.best_parent_hw = best_parent; - adj_req.best_parent_rate = ccu_mux_helper_apply_prediv(common, cm, -1, - best_parent_rate); + + /* + * This effectively treats the predivider as a postdivider. + * It stays mathematically correct and ensures whatever + * round() will do stays correct while walking the tree. + * It may query the parent rate too while handling rate + * propagation. + */ + adj_req.rate = ccu_mux_helper_unapply_prediv(common, cm, -1, + req->rate); ret = round(cm, &adj_req, data); if (ret) return ret; - best_rate = adj_req.rate; - /* - * best_parent_rate might have been modified by our clock. - * Unapply the pre-divider if there's one, and give - * the actual frequency the parent needs to run at. + * parent_rate might have been modified by our clock as part + * of the rate propagation mechanism. Same goes below. */ - best_parent_rate = ccu_mux_helper_unapply_prediv(common, cm, -1, - adj_req.best_parent_rate); + best_parent_rate = adj_req.best_parent_rate; + best_rate = ccu_mux_helper_apply_prediv(common, cm, -1, + adj_req.rate); goto out; } for (i = 0; i < clk_hw_get_num_parents(hw); i++) { struct clk_rate_request tmp_req = *req; - unsigned long parent_rate; + unsigned long rate; struct clk_hw *parent; parent = clk_hw_get_parent_by_index(hw, i); if (!parent) continue; - parent_rate = ccu_mux_helper_apply_prediv(common, cm, i, - clk_hw_get_rate(parent)); - tmp_req.best_parent_hw = parent; - tmp_req.best_parent_rate = parent_rate; + tmp_req.best_parent_rate = clk_hw_get_rate(parent); + tmp_req.rate = ccu_mux_helper_unapply_prediv(common, cm, i, + req->rate); ret = round(cm, &tmp_req, data); if (ret) continue; - /* - * parent_rate might have been modified by our clock. - * Unapply the pre-divider if there's one, and give - * the actual frequency the parent needs to run at. - */ - parent_rate = ccu_mux_helper_unapply_prediv(common, cm, i, - tmp_req.best_parent_rate); + rate = ccu_mux_helper_apply_prediv(common, cm, i, + tmp_req.rate); - if (tmp_req.rate == req->rate) { + if (rate == req->rate) { best_parent = parent; - best_parent_rate = parent_rate; - best_rate = tmp_req.rate; + best_parent_rate = tmp_req.best_parent_rate; + best_rate = rate; goto out; } - if (ccu_is_better_rate(common, req->rate, tmp_req.rate, best_rate)) { - best_rate = tmp_req.rate; - best_parent_rate = parent_rate; + if (ccu_is_better_rate(common, req->rate, rate, best_rate)) { + best_rate = rate; + best_parent_rate = tmp_req.best_parent_rate; best_parent = parent; } } From patchwork Thu Jul 23 09:39:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 2792 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 64E9F1C0BD0 for ; Thu, 23 Jul 2026 11:50:16 +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-24735-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-24735-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 0DD9A31F6ED0 for ; Thu, 23 Jul 2026 09:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 369E74343F1; Thu, 23 Jul 2026 09:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="eWVF1g5Y" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 10A99435509 for ; Thu, 23 Jul 2026 09:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799613; cv=none; b=r/YXOKANywyy7E6LkLJz5+lTJSU8P7YROPe3x+cUqKii32FBXVqc+aq3MwQJf4OUoCZMiiDccyeL256CjYIS+vvavO4BDKcmOnP9oi5dpmmvkCTqZwYo4mKhZc8VaW88Z6b4T7UomME7LcXlUrEojIT8MmcDpQf8UNmpMlgb7cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799613; c=relaxed/simple; bh=BJX69CI3rhPgFIC+UOKYakZAgmiE1nvMLkgOXW1N7vs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JfY0lP30N1qporkUH/YIEgWCaeVu4WZMRSh983JIcKR6LBfDEOVhoYn91cnVYsr/gkT0gN09FOrs61MGstpOJXxczwYDV8yb/kJR0wIvvVjaxhK75mLcZl0+lYCP8+WcqufwXjhhmWqQMqMopzyRueqARNrOu4W0Le8mkf6HnnU= 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=eWVF1g5Y; arc=none smtp.client-ip=209.85.221.52 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-wr1-f52.google.com with SMTP id ffacd0b85a97d-471eeac43bfso392262f8f.3 for ; Thu, 23 Jul 2026 02:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1784799608; x=1785404408; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ANuM1EedXU7mO5+fHrN+6vU75uZRwSQMOxEu7bukQuY=; b=eWVF1g5YEgsTILfCrMu+TsOomJrFzgZLwwN2pNyIXCd45n4GwoPRGwJXtFs9cU507E IxV+lbIP60xql054KGhTs3M0ZrMXt0i6UzhpSI6Nh3YFqm3X+v69orT+cruVw8RxMb1N 2bi5mGSuzFR7rt0pQ6VxZiJXCPKGaE4kHf22JpUV7NVogVJxxm6h5uKI5UUV65qPYCBs XY6R3fU45BUuKhDruY/N8ncEpp3732ITrgRQNUMGCZP7NlaYYigVvay50bksR4bMTQUF OdOaSESQ8Qr17xUSjv9j8/aikTGiK1a9qOv3jfsBW4m39nv4CPSL9W95SmDcs7hJ7m1/ y1JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784799608; x=1785404408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ANuM1EedXU7mO5+fHrN+6vU75uZRwSQMOxEu7bukQuY=; b=gEhNGC6OaK/ws7Sv52r6WamrbldKc3q+yoFI1kJl/6YAH3FbcnOKgxOcdN0EAgh4yq PmKt/iAEbnBDj7knSQDK6HXBe3jppTEF+yUsMQxBbG+NkbMxn3uzor2mZAlr5rkp6W+H owV0ofnXpjQeKmwzCV12+QpjOLz7tYHjV+hFAd/p7z3d5U91S6tKQl35CasW0ZHJpqlC BKOHQbIHWNfBbfjfDl9Xw3NcJlk3fbzCGBVJvvQxP97MovzKBlpYuEdpfZFwF4jDXSby W91WbhEre5RXWg+9Vz/SXlczqOZ0JdCeIOO2dcJr6fo6xYRXRBGuBF3/wQph/aPcJQa7 /cYg== X-Forwarded-Encrypted: i=1; AHgh+RrDOoMEvB4gz+gxoDEhuHNThnV7YBGBYMG3ZYwHE1d/+ABXowYvtrj4kz152Xai6ud1BP45o9CT6gzOtg==@lists.linux.dev X-Gm-Message-State: AOJu0Yy3OTr+ZDNl6mIPK/ZJy8POTDhxaT+gm34BrJUGJa1hM4u3pYYd FM1dPaahd2NMeI/2EW5JBQRRtRbbaghj9QbVyOFAkEbjuimyV0nCnXy7LSHYWdJ4nhs= X-Gm-Gg: AR+sD10opC9v7AjBPR7F/fK+g1Ea1JgT089NVVZJqSHT48MPdHC2ECnkr1MOSCRuXuB gbFnbgudIHeqFUmlpjL8mIskfFkiCw8UourVuY5+vebdpZIVirJiYcc9HmMnJ8QkNzQ9vYfJxEc 2UCD5bwgtkgOaUHkbjYufbPHOuX5N2E7I1XTITMXIECoYyygo4PR3O0VTomnTy9Vry79fYVEg3p Hog8tHcggtrFDMuspq1kHPTQYsmRUdaeuxZkCe3gg02gQcorcDYcA16oleVdnSVM3XakBg/1pnS BMbrEVCftxf8BAEFvCcSPOjrNOuyMyPweTkwbMojj7p3UAghN9cTBG7abJJINRyjpRsjtXl95ie F7MQ6lu21uehs30ijdH8EV50+LuUmWVrwNsMmIzzSb1VWmU6n7Gd5aA+mOXcFaNlPbkxuO9hhzk +k X-Received: by 2002:a05:6000:1883:b0:474:5a38:f650 with SMTP id ffacd0b85a97d-47f8d710ffemr2834486f8f.3.1784799608255; Thu, 23 Jul 2026 02:40:08 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:3274:dbb5:2710:802b]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-47f85b9a6d7sm15256235f8f.2.2026.07.23.02.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 02:40:07 -0700 (PDT) From: Jerome Brunet Date: Thu, 23 Jul 2026 11:39:52 +0200 Subject: [PATCH v7 2/4] clk: sunxi-ng: div: add read-only operation support Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260723-a733-rtc-v7-2-8fd68aab94ae@baylibre.com> References: <20260723-a733-rtc-v7-0-8fd68aab94ae@baylibre.com> In-Reply-To: <20260723-a733-rtc-v7-0-8fd68aab94ae@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=2289; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=BJX69CI3rhPgFIC+UOKYakZAgmiE1nvMLkgOXW1N7vs=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBqYeFuAonlP7DkbS7g2+GVMpDyLmLNQ/yrcz3K4 GDc7mIRf2aJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCamHhbgAKCRDm/A8cN/La hXuMD/4yhmqW9LF67++G2u3n2Ore+4UjWpvySCijqdBgw7p7SquucWZp1DLDI2TxsuNXpFv4Vu0 ZJ6wnSE7VhjkXU8frv89pskHWhdH/uQzwHyFfrUH+uS2J6S95Iha5zJ++bum+V3v4wZ6uzar1rh /2EhCsUEVeoG+74PZ5izkjZ4Im3XihSvPXs4zOGX8GGAEiMNRPY6pE5eOXlOG5XPfDqKZswX+GI wGZNcGXAzU9CY2B2/wTgy1bfmtZo9F09IeQ4YrZ+a6mTQl3Gb7qVk/JKr39p/Jyvd/tlMiZxkaJ 2qQZLF+SSPslhfmDmoxW8DGHtln+LI94LvPzjsO2HotayRJgELlH5DBiyE3vV/ZOFPUhHMx9PpA MsSr+nobCw9ddH2GmjXRDtQopTN8d80N8jROx5c2p3Jivgz8Hcg6AGZ9bl59BhKnImTIhtPsYGH ngyF3AyOUkZlSbu9cHSaS/9+HKDCiOlhH5GOpn/T8lhyQZns6+Ukw8CDbpUPK1JPYMrxNV4/6/M 6EWg730zZZ0S0jAvdeofo3VTd7PTXG2za6B+PVgJ3H5eOcX5OtZqIMFLlef8EEiIyFpB7LsyXUB 8+c1NEs6MA0n+m97jU9jrmh1yzs/9QvvoBFaaAbowrv2R+zAnTD+8FUHOvFz68EDYA/A44M4wrI t+Eb0dJFejElW5w== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 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 sunxi-ng read-only dividers. This will be useful to the a733 oscillator detection logic. Reviewed-by: Chen-Yu Tsai Signed-off-by: Jerome Brunet --- drivers/clk/sunxi-ng/ccu_div.c | 31 +++++++++++++++++++++++++++++-- drivers/clk/sunxi-ng/ccu_div.h | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c index 62d680ccb524..c385e0160f13 100644 --- a/drivers/clk/sunxi-ng/ccu_div.c +++ b/drivers/clk/sunxi-ng/ccu_div.c @@ -20,8 +20,22 @@ static int ccu_div_determine_rate_helper(struct ccu_mux_internal *mux, if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV) req->rate *= cd->fixed_post_div; - ret = divider_determine_rate(&cd->common.hw, req, cd->div.table, - cd->div.width, cd->div.flags); + if (cd->div.flags & CLK_DIVIDER_READ_ONLY) { + unsigned long val; + u32 reg; + + reg = readl(cd->common.base + cd->common.reg); + val = reg >> cd->div.shift; + val &= (1 << cd->div.width) - 1; + + ret = divider_ro_determine_rate(&cd->common.hw, req, cd->div.table, + cd->div.width, cd->div.flags, val); + + } else { + ret = divider_determine_rate(&cd->common.hw, req, cd->div.table, + cd->div.width, cd->div.flags); + } + if (ret) return ret; @@ -143,3 +157,16 @@ const struct clk_ops ccu_div_ops = { .set_rate = ccu_div_set_rate, }; EXPORT_SYMBOL_NS_GPL(ccu_div_ops, "SUNXI_CCU"); + +const struct clk_ops ccu_rodiv_ops = { + .disable = ccu_div_disable, + .enable = ccu_div_enable, + .is_enabled = ccu_div_is_enabled, + + .get_parent = ccu_div_get_parent, + .set_parent = ccu_div_set_parent, + + .determine_rate = ccu_div_determine_rate, + .recalc_rate = ccu_div_recalc_rate, +}; +EXPORT_SYMBOL_NS_GPL(ccu_rodiv_ops, "SUNXI_CCU"); diff --git a/drivers/clk/sunxi-ng/ccu_div.h b/drivers/clk/sunxi-ng/ccu_div.h index be00b3277e97..a30a92780a05 100644 --- a/drivers/clk/sunxi-ng/ccu_div.h +++ b/drivers/clk/sunxi-ng/ccu_div.h @@ -300,5 +300,6 @@ static inline struct ccu_div *hw_to_ccu_div(struct clk_hw *hw) } extern const struct clk_ops ccu_div_ops; +extern const struct clk_ops ccu_rodiv_ops; #endif /* _CCU_DIV_H_ */ From patchwork Thu Jul 23 09:39:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 2793 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id E5F871C0BD0 for ; Thu, 23 Jul 2026 11:50:35 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=baylibre.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-24736-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-24736-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id DA31730D12E1 for ; Thu, 23 Jul 2026 09:44:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C12543E9C5; Thu, 23 Jul 2026 09:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="GWd1LNf4" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 649244322E5 for ; Thu, 23 Jul 2026 09:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799614; cv=none; b=oZSG47UKAyiJtl7a5VXk4ScUZ8SPR1bNYMYSRO4GVvblz5cQp+sVzOcy66XuhjtyI8+nEFJ3b0kHOsjRIRENI7MPNzQ9OsE/WApnAZ+omp0ZswoeBiarJrQb0DrSUtKZ4Gi8r3Zb3i/BnWfYOjfSeK56UUJMZS9DzIrkPGXXpWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799614; c=relaxed/simple; bh=JBCNsbbmpvOyQAHYAiNtZ0xGeCHrftQkcKapQT6A/2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zr6fs9XxRJNiCDrQQcQBM4SNr8ITA23C3LSGXclpswYIEJfCdjvcPUJ+oJ0SXPKWytq08Ln2Kf5NXlUZ3ZIXpHRhWblH3KFWtrUq/BIUX/E2+g+IJZ00wE6YfITOx5N3iIg8LG6REEqiO3ZM/OXmNkr4DGkkC6NRzbL7zD50zMc= 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=GWd1LNf4; arc=none smtp.client-ip=209.85.128.42 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-f42.google.com with SMTP id 5b1f17b1804b1-49548e01d02so2393485e9.0 for ; Thu, 23 Jul 2026 02:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1784799610; x=1785404410; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZjvDxGaz/+Ym5ockvfd8pkGSRzvwp3SWGNBrqT7Ifz0=; b=GWd1LNf4HBU7ocSWaEkeeMu/8CrPB4+mI4KZGrGfE17AJx5yCtRhHOJWHVBD+3ynB9 dK1+e/kKLJKWfmyI1xKQfMlnIxHjtWwLDKT0njtAwGqXDYq6sAno7u7OAoPj3pTmEtZ3 73IEI/ENbNTs1PFtK1usiYor4Oatsi1X4Sc4gUKBzgj9h9t/TGdzRJsfPVEY0T1UhGwk fvRMXO/+7zwxAJIkgwfYCBlHs5J7EgGu/i4NjFCotYl/yANmIxZdfCZOQh2GzlAiJPM0 2aBaz0cRcDy1+wToDH9j7qTevis5dMFyTAHVnhFlHQpZoogtNEoOCCeulF0w6QHgUk0R 1Irw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784799610; x=1785404410; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZjvDxGaz/+Ym5ockvfd8pkGSRzvwp3SWGNBrqT7Ifz0=; b=RHZbfLxMT+ptOP50IajJ/3eLZWdB6e8MUVpPol6eex3kfbNy4KZejp4slEbTe74v/n rWFn+z8k9l0EgY/UooCFMm6IKn0Mn1HTd4KC7GUOG36VGf6WKvuUXI/l/Ev1Q8C0ECLo I4d2yVqRdb8TlNYccXn6cMN8USsVjZZt/u+0muNyiYx38nzMohHGx6AsCUwu9QFn4ipx mxudRuZ4k0rrHJ21NLvTYGxjIV3h4qKmW6memxkdp/dQ3BnxiH3F2rhBzTLJX54Vmv9Q FzJasdcJ2CJeKFyX1z4Y7h3S0gn2AI5frmr9pyFnB1AaC9tQ4F+tHTX6T93aSie0GZZE q50w== X-Forwarded-Encrypted: i=1; AHgh+Ro+ECEukIMqEitid/L06NBjKW+FtjguVc2itcEbQoTTiEOGTxDOt+U3kROKF05Sts9rxdUFKLO32kBzkw==@lists.linux.dev X-Gm-Message-State: AOJu0YxR00KO6ihSyY4Vluj3WzwMCsO8Ot4gAVhPIp8n+XInlMWYBGB6 ZXe7RJ92tzepZN1cdJEIzWr3QOORqCvGFnKK/jBWX1wZPwANmepMBZfK3svJ8Phjwpg= X-Gm-Gg: AR+sD13HrC408Pw/BvikXNdLJ+veCCX56GX/oOE8d7xT1i029qarIW5+IJww2qaGfp3 vCNfVCC4M9jAU4ZkVONnPkGkTKMmQS47vAcf+JVnSx5aHqLXNKLawrBb4FY7ZJwBlp+/Q7xc8QG ZLqWpS4mH6sgIjf7ax/ZQt69U/Hpa9Kvt2mdYA2k7ILVqvJ9ibAEFP9unCLtfo4blQ+6x3zD6eV puC3Tfvj7Ze9Kr59h+7xRgbwajgEyus9+AHEXc+SEI+au/Cm9lzZDZjLRj3RPyR0cef+zLfomn/ h3lMAzx/BBirIReNDBbhgVD+vqimYmoUNONz8lheAFn3zbQYxcBDwOKnmyF0yISYLxZCeDx/m7Y teOcSAbVAQwefqWI4Z2RGfFOF6kRJqWKV9OCzSE3vN82dPW8xdhBOJD+1zH+mKccYipL08xxnjs I++q6z5dqkad4= X-Received: by 2002:a05:600c:4ecd:b0:493:c77c:108a with SMTP id 5b1f17b1804b1-49573d218camr23593405e9.36.1784799610474; Thu, 23 Jul 2026 02:40:10 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:3274:dbb5:2710:802b]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-47f85c6f076sm14217894f8f.34.2026.07.23.02.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 02:40:10 -0700 (PDT) From: Jerome Brunet Date: Thu, 23 Jul 2026 11:39:53 +0200 Subject: [PATCH v7 3/4] clk: sunxi-ng: sun6i-rtc: split main oscillator div and gate Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260723-a733-rtc-v7-3-8fd68aab94ae@baylibre.com> References: <20260723-a733-rtc-v7-0-8fd68aab94ae@baylibre.com> In-Reply-To: <20260723-a733-rtc-v7-0-8fd68aab94ae@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=2641; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=JBCNsbbmpvOyQAHYAiNtZ0xGeCHrftQkcKapQT6A/2Y=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBqYeFvjq1VgqkrnRX4lgbpVG1CsAXk0OXhBpCAY 2cCxet3nn2JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCamHhbwAKCRDm/A8cN/La hf+4D/9zXNDTBscW+MTjTDh5NosjbTzIiSUcS/dzhnCjmVmQ22U54ZbigzSwc6euLyNEtodPs1C /83GyQHXZt+edY9PQwiZPYblQf+aVW1yKbeYf6FFTVVge5OGW3uMbf9OafZ444Ub/xyM7n9nGTL XW7lMm7/LwIzHt4uT1zqEwBFeGSWbtpq42X5f5XSAWzj0D/Sfg/UNEzJt+Rs+um4Vl4r6c13Ch2 jgSCFGwtao3MN98b2BVBehZnTVyzXa3tKeJ74cHMVt1fIqo42wGGN4MW6hIyGnpcKhRZVBUTPpj nImEEQ/hlmQBjgiMcaKdGtY/IN8KqnMZxLGR807JujAmNNxr2G6VLFHBf69hKJMuRSFapjHy3f+ 6g8EfwUeZcwlSHhe5v9kw7q4+t1Zn9dFcxPktxBOmr8jtipsQ+Foc6AxBT5/zYW3c/9kz7rr7hT /MHiWwdeMGFzyCU1iVvoPB8GrWdMpoL6V89Iin13MOxCvLchXPPD2prKYFPK6dxhZggyxOWl16M 87kPE9H1TtPTKfcVmm+e2FKcEVn4s/R8VC+ea3KAS9sOw8scj8hQZU7GuSCX+FTvMUZstkPhCzJ 9N08h3ySwaNa7DjKju7KfJTrOTYdqNgr4IKfsaevnZUUtEgvNDH5hQDqy7wzqNj2ezZl7zu5VEQ YE3e07IaksL7KFA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 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?= On the a733 the "osc24M-32k" clock has the same gate bits as the previously supported SoC but a different divider implementation. Instead of a fixed 750 divider, the divider is selected based on the rate of the oscillator. It can be seen as a simple read-only divider. On the A733 the gate and the divider are on different register which is not supported by sunxi combined clocks. These element will be split on the A733. Split them for the older SoC as well to keep on sharing the gate definition. Reviewed-by: Chen-Yu Tsai Signed-off-by: Jerome Brunet --- drivers/clk/sunxi-ng/ccu-sun6i-rtc.c | 20 +++++++++++--------- drivers/clk/sunxi-ng/ccu-sun6i-rtc.h | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c index b24c8b196e66..25dd87e78eb7 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c +++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c @@ -218,17 +218,18 @@ static const struct clk_parent_data osc24M[] = { { .fw_name = "hosc", .name = "osc24M" } }; -static struct ccu_gate osc24M_32k_clk = { - .enable = BIT(16), - .common = { - .reg = LOSC_OUT_GATING_REG, - .prediv = 750, - .features = CCU_FEATURE_ALL_PREDIV, - .hw.init = CLK_HW_INIT_PARENTS_DATA("osc24M-32k", osc24M, - &ccu_gate_ops, 0), - }, +static struct clk_fixed_factor osc24M_32k_div_clk = { + .mult = 1, + .div = 750, + .hw.init = CLK_HW_INIT_PARENTS_DATA("osc24M-32k-div", + osc24M, + &clk_fixed_factor_ops, + 0), }; +static SUNXI_CCU_GATE_HW(osc24M_32k_clk, "osc24M-32k", &osc24M_32k_div_clk.hw, + LOSC_OUT_GATING_REG, BIT(16), 0); + static const struct clk_hw *rtc_32k_parents[] = { &osc32k_clk.common.hw, &osc24M_32k_clk.common.hw @@ -286,6 +287,7 @@ static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clks = { [CLK_EXT_OSC32K_GATE] = &ext_osc32k_gate_clk.common.hw, [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, }, }; diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h index 9ae821fc2599..ab7b92b47f59 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h +++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h @@ -9,7 +9,8 @@ #define CLK_EXT_OSC32K_GATE 4 #define CLK_OSC24M_32K 5 #define CLK_RTC_32K 6 +#define CLK_OSC24M_32K_DIV 7 -#define CLK_NUMBER (CLK_RTC_32K + 1) +#define CLK_NUMBER (CLK_OSC24M_32K_DIV + 1) #endif /* _CCU_SUN6I_RTC_H */ From patchwork Thu Jul 23 09:39:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 2794 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id C28DA1C0BD0 for ; Thu, 23 Jul 2026 11:50:52 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=baylibre.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-24737-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-24737-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 2F70B30E5F57 for ; Thu, 23 Jul 2026 09:44:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A156E440A07; Thu, 23 Jul 2026 09:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="pHQVq1Jj" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 064B243E9FF for ; Thu, 23 Jul 2026 09:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799618; cv=none; b=kby+Z+5ELCzVbIic3jI7UA2b5EXOzigTl1PYs1nAMhdUxra649AWXETH0Y++V0ZJs8BTqAKD4sOjO4LwTo/qCxIHSQ+qht4eaEhHsigEi26TicvZvBo+cXm4SFhgf00aBxU1mvgopTbNuperdDGzQEQW/byoLLs/zMj+mtkY6gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799618; c=relaxed/simple; bh=ZxtEY0Po9koFr9SK/FxQWL9lGl95syc2R11eiKw1uuc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YHh8IAng3Ekvm28D4lQpgCk8OlnMyPwZfhzgsKMfyE3Ypb0ckdPjFoZTYyLj7NQthUaM/Hs+AyRa0nwerQXps/1UzRzYwSdpXZfGZsHQxmd0ER/8Dje9gxbDbCeLTjUMHhqhlYXE9MiwxLfl0k4QlQSocUsH70pNaQGBl31t8vQ= 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=pHQVq1Jj; arc=none smtp.client-ip=209.85.128.54 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-f54.google.com with SMTP id 5b1f17b1804b1-4953e04ef16so4778625e9.2 for ; Thu, 23 Jul 2026 02:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1784799613; x=1785404413; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Hhejqqk/YejfwiP6Ga/bYKh4OsY78ne2Bp/UpWOM4CI=; b=pHQVq1JjhxPv/5k+KHPWu8sCk6IzauZSB5PHav5coqGdt/PoUTgbhz9bgT91sqFSTG Gg8r291Wl/qi9m3qLoP30qiwceliegVpqRI1TyJgBu2BYPlMJ2lrfmaJ9hap1z/JHWb2 jhQO65oBDbxRd1w3VvLiRhASKhfy7piTLF+USiiot1yFZV1Tr1/CYi5Wr3DN50JYdo0H Hij8LLhc7V50QFM3v41meea6r2EDO6k2TuXYb4MiblELG63mFOi+fE2ISdxmYMo6iwKD MrNQvX4VE1HYSIe78m3Gb/czspayDazAOLhpKeJ7R5zjtfUQKM+14YD5hRbjl4hGcqAt evMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784799613; x=1785404413; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Hhejqqk/YejfwiP6Ga/bYKh4OsY78ne2Bp/UpWOM4CI=; b=ZP/1rCvc5VdqaqdzBonAjD4R2KMDs/WLKX0+Ne67p44nijowDJhrs0+lOmmJ44LyE7 GUsv/xNoSMrAlBxb7/jClVsNOo8PmdCJNkOr5AmcTtuvxw5DujNMpEMuTGDr3A4W0ASA F8HYzLVjrPAWaSS+l6/qZN/GlnbsYw8/XMptWNkRAJYOW5WVZQ3Shi+PM0gETYxhhhEH hpUBhjsIVQnlaYe2CrmL+t37xp8U0S8J3dlehFtz95T8CxtF1E6w4PHkPEEV0dpuHKUQ d9rZJlAALEcA8SuTNpUWvNIVm3pVo+AYVaYFWWYUluIY7YV/7iHM1M5lUVcTQwhiOg4G aFYA== X-Forwarded-Encrypted: i=1; AHgh+Rp8XqsAGfhglD5xU6rRfJ5r6OF8qzmoXwADAC83ucgD/v/l3JtzmWzSZONaAqIoiDkUVrkcMdU01Xzibw==@lists.linux.dev X-Gm-Message-State: AOJu0YxJT6btxi6iEDMtTXagMBoqT+9qESMvVSgyE+vfoJMGguqtot6F OTz1WHmWUdA760+KI+rivYB7gw9BYGWKfr7msBCowczLYiiOJG94wJVXH13729ajoHs= X-Gm-Gg: AR+sD10sMi07cUslb9ebQuSzP/Icm/bsgqN2XEfA1XWpxZ24bNmcx/WWaKd7sQFYxUn 7k8hxaNt2D747KAQs+6rcOmWf+Y/y/UQwe3c1jVs3pl37XJxDhNm2xejz/Sbr1rlFTZq6ZtTbMT dbFzlmPqgVQssb/9o9JHmVpp7LX/kQ4d3SdcH1Hm3qtdntwuf3aIiRb57DVn8zK24vyxjJyk8IL BYdqj8lqi7wTHkJTIUS7Q1Leu0NP64Nmsm/ksoY2YKw4Gh5fKENx98GEtVNiOEZqEkZTBRKodkg T8cCOOv4LGGaMmwzYVHQnw6o0z1OfwqP4Yxc91KhRES7ix3TksuhNzcZ+vGzBo5Evikgg1gp8T3 WzlgGFPwf+qQ9gCs+he/ujWiHOhGYhV8/X9ReSCQjO9tUnusA1464bkdwEOWqo0mKNkXKBAV5RQ gv X-Received: by 2002:a05:600c:1d21:b0:495:4856:2659 with SMTP id 5b1f17b1804b1-49573cca1b0mr23638405e9.9.1784799612784; Thu, 23 Jul 2026 02:40:12 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:3274:dbb5:2710:802b]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4956a4f24bcsm158047615e9.1.2026.07.23.02.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 02:40:12 -0700 (PDT) From: Jerome Brunet Date: Thu, 23 Jul 2026 11:39:54 +0200 Subject: [PATCH v7 4/4] 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: <20260723-a733-rtc-v7-4-8fd68aab94ae@baylibre.com> References: <20260723-a733-rtc-v7-0-8fd68aab94ae@baylibre.com> In-Reply-To: <20260723-a733-rtc-v7-0-8fd68aab94ae@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=6141; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=ZxtEY0Po9koFr9SK/FxQWL9lGl95syc2R11eiKw1uuc=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBqYeFwGSqTbtJvNIzd3HhhthCSgN4NGzqOMzbJW M0apMB3fCqJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCamHhcAAKCRDm/A8cN/La heDsD/9HQP7iuGP55hZHz1ZpmKRUvcOZL8sxSbG9MoY3tekyiDTBSVmcTb+vP1YcQdXgUQZsQVY fM6OrCU77nlndH8ofR47fnV5/C543J+IdjjW6bsP76vbXwpTV74y5XwUQ0ahZunbh5/iC+HEjDE 8Vlzl8WrGplwwHqCddqPkexkem7abHcS3UFX3gGk7KograpfM5FqiQAiLq70WtwmlN2rpEUuapQ 9HFV3vfZ9EebUD2kBQhJHjEDHktPjRebn/VGQ6/FfcgGphj4Rw5ZuVhcN/HThFMeN2ZYy0mu+oi p2oBldMsOxnUgp5CZLR5FvLXnWUOcuJvIPUzPXEzGuDpdiwxsF9SGzI62Zvk0TpfYEhABEdrp9S TMCYLVbMx0C9Oag9btZttNmQFTQHAS5F0GS8uDqujicn1OHh6vHdxQdaX8jeVgcqbI7kPAVI9tT rCpQ2zbBzAWgzzsfNNPfHJ1dlc+oSuYOY7PqInxPDG2wimTuVRAPBz37AUxqCYe46GFMrg7z7/K m3Urf44Je/jLHIAYLM06zMMO3dLztHfvbgn7rcmx3HkU3Zx189x8REkplZNzHzv8tXQmON3f3T1 VCkLjeoCWaCtzmO7Pxv1OInghaBnUq0u/ZUtQ1WvW2/EY9Me0dIHkY4QnVizMH8e9r9gKfBNqNI O09Nwa1TS7JZMLA== 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.234.253.10: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)[sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo,baylibre.com:email]; 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.234.253.10]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; TAGGED_FROM(0.00)[bounces-24737-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.234.224.0/19, country:SG]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: C28DA1C0BD0 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. Reviewed-by: Chen-Yu Tsai Signed-off-by: Jerome Brunet --- drivers/clk/sunxi-ng/ccu-sun6i-rtc.c | 77 ++++++++++++++++++++++++++++++++++-- drivers/clk/sunxi-ng/ccu-sun6i-rtc.h | 2 +- 2 files changed, 75 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..98ae10307f43 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c +++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c @@ -44,9 +44,15 @@ #define DCXO_CTRL_REG 0x160 #define DCXO_CTRL_CLK16M_RC_EN BIT(0) +#define DCXO_GATING_REG 0x16c + +#define CLK_NUMBER_NO_GATES (CLK_OSC24M_32K_DIV + 1) + 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 +219,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 +238,30 @@ 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_FLAGS(14, 2, + osc24M_32k_div_a733_table, + CLK_DIVIDER_READ_ONLY), + .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 +300,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 +317,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 +335,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 +381,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 +403,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 +439,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_NUMBER_NO_GATES; + 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 */