From nobody Fri Jul 24 21:52:57 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 C179F434417 for ; Thu, 23 Jul 2026 09:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799610; cv=none; b=s1jhIIV5vGgYsDF8rtphRb2r3dumDaAeVBAUQDkste9jtkv8GNYpzmokycLlFQBLUOJhxDzTW4t9ZiGf/jG/1oQC1dj6TNCLxFrqgLcECbKWpDSn6RZ0bcTpD+JHoWd6M2+u/doDpKOncpk7/2akJBwsqMqvw6oEiY5x2plkU5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799610; c=relaxed/simple; bh=h886BmU9pfC+RezdnkZ3J5Ik53qoiogLhSBSntAHgiM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aPCcu4rr7K6+8kSMMZ4+g7ZGPm7v0gd9OCTI7tR8R7JTr1zI7kVjZAoxAitJvGLfQbQosMWAr3cADxMqnK6UqkQ58Sxy31/11pOrQ//XpGnUIhlzSLytbFcc8luIpJsPB+fRn5LFmQJ63tP8docmlO5CINQwD2JbEa5LDQDMOKI= 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=bCJb+jGM; arc=none smtp.client-ip=209.85.221.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="bCJb+jGM" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4798bea72f9so275519f8f.1 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=vger.kernel.org; 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=bCJb+jGM4e75C0tl4U9GuebKlWX0JSaGGcVCex7o1S8xjnQhwjnG+maVPNkSSQN8Gl y4Fa8IZD/ifNhTdiVWgr5G7TiQI6r8QyaNDd0jNhmd3K1hjh7spUzB766Tj6iAmtrInU ZjHlDtYAVxW50o62dFxs8vbvDfXCSUntSN8aQEPgp0LWbcOIwFflWu332tZ8/SGCSO75 01Fz6+kte/g3umzoefaAA+v1fJXFmKAdF/Cah9oiFPAiof7HpWX6iTcBAUcWQ5E0G3sm Q53dBrugmDzY+WCvk68/PVsh+3HI6sOi8KyIRy37qF4p+Xm/0wxLSB0lzIuRdemx4+O4 GJOg== 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=UotA/SfW9ueKKQqcyZjwr1Gydquizd6VYo4RmzhcW25DEazLbMSCfRYCbqx3d9PQxn pFckLTRFjS+xOLWCzQjApezxkt/1kiI5I5RRLsj9VjcGUwri1XbOsBrwho5a5LR/OhD6 nOBbG+hu1HhErUjw+cLkWWRUnwQ14Y4mH6xtvnZ3yyLBVcBU6k2ahv/0wogBuS+gPOA9 KsY7ChtyCLxVNSCS+ICLk7TjBoXTMX3q3Q2AMxdQYMzEfUcMST+8G2QPb7XTvt5um9bR jfOLlekuu895RVi9Ks0k6H3IOYFuzVR5TqaUCcuGIqIykkhrIEIihWoNB7GFo4f8sx+o VRhQ== X-Forwarded-Encrypted: i=1; AHgh+RoX2dyO7H7d9gYBM/oNe4xjtevJUG4NloUcRt39zLH04133R00GeVSqZxAEsuJKB2UGLc1wUpN2X5AjYrY=@vger.kernel.org X-Gm-Message-State: AOJu0YxbfKeUBoH/T5SfaYbKurkYcKqsatlzxbOMnyJmaYdFPiSW1lII EivTtm+U5YY/MTxvgW2axMofZdnxzp06oN6pYzNHyTHkHbm9y43NvyKNkcDg24c3rrM= X-Gm-Gg: AR+sD10tCB5HQj1SWCCh4nAEUrh1fIkFsluvWllilIhz9cxipUYsHKN8uoZyYR2twOf drkuGqriSFGcaw/J15rfYhyjGzNmVI8Y5N1j1i3E0oIPPUqvDmXuEz2/16jYdfHGP+Ab9kcLZCg MNRJrlRrBUTR/f/a6ormLwI3khySJIMqYvOstXyCmFe2xdwbsSpzMwAhzMVXJgcSrdrIcPi0cqB s8xxUg6N7E7+1cKSN2TcG91Gh8C8L1cLNqzWOZqxACswWf7tyiaTbSFtr3iDLRwnsyVNZA7AjQd hFBLgrzlz+cIvw1SxSr4cP4hZvlNesrUJkZfD5MmPTYpWHPl9Rrfv2toqP95diitU/Bvz3ZhmsQ KD/3Nz6K8AGWui4M9AyFzd1DlSCactbYpmzbzbgswMGtjpLBPajOE5QN8ob11QzKXGr2yDwFhWp SJ 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 *co= mmon, struct clk_rate_request adj_req =3D *req; =20 best_parent =3D clk_hw_get_parent(hw); - best_parent_rate =3D clk_hw_get_rate(best_parent); - + adj_req.best_parent_rate =3D clk_hw_get_rate(best_parent); adj_req.best_parent_hw =3D best_parent; - adj_req.best_parent_rate =3D 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 =3D ccu_mux_helper_unapply_prediv(common, cm, -1, + req->rate); =20 ret =3D round(cm, &adj_req, data); if (ret) return ret; =20 - best_rate =3D 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 =3D ccu_mux_helper_unapply_prediv(common, cm, -1, - adj_req.best_parent_rate); + best_parent_rate =3D adj_req.best_parent_rate; + best_rate =3D ccu_mux_helper_apply_prediv(common, cm, -1, + adj_req.rate); =20 goto out; } =20 for (i =3D 0; i < clk_hw_get_num_parents(hw); i++) { struct clk_rate_request tmp_req =3D *req; - unsigned long parent_rate; + unsigned long rate; struct clk_hw *parent; =20 parent =3D clk_hw_get_parent_by_index(hw, i); if (!parent) continue; =20 - parent_rate =3D ccu_mux_helper_apply_prediv(common, cm, i, - clk_hw_get_rate(parent)); - tmp_req.best_parent_hw =3D parent; - tmp_req.best_parent_rate =3D parent_rate; + tmp_req.best_parent_rate =3D clk_hw_get_rate(parent); + tmp_req.rate =3D ccu_mux_helper_unapply_prediv(common, cm, i, + req->rate); =20 ret =3D round(cm, &tmp_req, data); if (ret) continue; =20 - /* - * 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 =3D ccu_mux_helper_unapply_prediv(common, cm, i, - tmp_req.best_parent_rate); + rate =3D ccu_mux_helper_apply_prediv(common, cm, i, + tmp_req.rate); =20 - if (tmp_req.rate =3D=3D req->rate) { + if (rate =3D=3D req->rate) { best_parent =3D parent; - best_parent_rate =3D parent_rate; - best_rate =3D tmp_req.rate; + best_parent_rate =3D tmp_req.best_parent_rate; + best_rate =3D rate; goto out; } =20 - if (ccu_is_better_rate(common, req->rate, tmp_req.rate, best_rate)) { - best_rate =3D tmp_req.rate; - best_parent_rate =3D parent_rate; + if (ccu_is_better_rate(common, req->rate, rate, best_rate)) { + best_rate =3D rate; + best_parent_rate =3D tmp_req.best_parent_rate; best_parent =3D parent; } } --=20 2.47.3 From nobody Fri Jul 24 21:52:57 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 2E73B43550C for ; Thu, 23 Jul 2026 09:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799612; cv=none; b=P/WBZeeuL6n2A4HBeHooXJmvECukIOkF7IzXhm6a+bJts7sm+kBmSKzEiHKaCZ7UbGnvLLnSepT6l9UeUU5Ss60TCVWOeBjANuoTnzMuSJNsLwyD/a5eNWFnJqWP+9vzbZwjL7ugmawKaIPgNFdPuvdNJVol3Nb7EKs48jvrCpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799612; c=relaxed/simple; bh=BJX69CI3rhPgFIC+UOKYakZAgmiE1nvMLkgOXW1N7vs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AtTau/81ULJhA62jJoW2paOYnD76VSemlg7pFSxd6VSnxPW6b8/5eCZzpPLNLCxgBdpwEFvXeRnYj0pED6O6XkCRJx7/6YSXplGl3t+quNUdXxG2j2gZj81Px1e6kQK/PYvgPwddWevu3NlFJ3QVE1p37VHSyleGTwS1AyliHRo= 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=lPLYaH6z; arc=none smtp.client-ip=209.85.221.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="lPLYaH6z" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47f633e6058so352374f8f.0 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=vger.kernel.org; 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=lPLYaH6zPzYd9vZtVEreChvHFwkppqjdm/CMRTxFxt4bZLAIj+7ZelkdyS4UUux+JA +0IbkPNTaWao5qNm3xXCL7A2LWV9igXzdja7B7F10fXF8oHHKGeYzqo2ilScBdkSRuDf b7hZztVqIdHNlHSoGoZt8fkPGq2ap5AGR0xMOkjbAwSwDwITqF/LH/jZQM2pbXUw4fQl z2vSB93EBpiYYg5LIzsQb3WKYP54Fbzl64RLZPH5qEWl0I4YAsogIFqscfwrLUv90xdT cLe5XvoqvW0R//LgJ7XJipEtkYuuqa8w2djrmLaZndVsdtL5IuLH2V8rCKIjl8Na/Mv3 eaXw== 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=g5eklCZZFadrUeNFLwJjXcPYUfiSnbzva2xDvY78C6kTcluK3d7418YToVZbTwaUOp Ong1bKu1/PRPnLDgOaF67t/BkUNZ+Zz+SpseQ68nb3FygfHkb3D71TTXWrFqPoWiGrlP BVcN7xrGbFgMoeJzDOqAg3XN/OYoDQvjrKwKNrXO0MF8WUzdycnIn0/uuW+3HoZDx5Dj umvqCL6smlv7Meme3nNGjQPgEiEFugNNwtfsnJdSayZQlyzgEy0GMxiM74wOhabeUylS 6UcGi5MB1jv8rCawJ1MyQnj/bVC+DwKrwyKtPV5IWgW0WT4qeVhSeTTN1zWJtgO8+T8R U7DQ== X-Forwarded-Encrypted: i=1; AHgh+Rog2Oh8DyDjTHK77Genfqnf0sonfuf3BrgILrZMPPyODG21ErQrcCv3DfuEqMLmEmBb2d1nuJU9Px5v68I=@vger.kernel.org X-Gm-Message-State: AOJu0YyZlpbpJ5kSC9Cz6nsfyKRWk4yqIkeQE2rDDZxgAKcTzGVdcOJ3 mTXaXBAF/o05LtQ5wW0jC2DWEOB3bFHk4d0bl2KUFOAm/Ul50DIv7VzhBZib6xrZAPk= X-Gm-Gg: AR+sD12pnqqe4qHPtaTXbrWmOCHgRICTjMMKrW+03eF69VYe7WgYX0Y1Qm+8YVw9tN4 E3J41T5j6Tc8dc/Ao+MYjqPRYzfxMTeExUM6Ie9inL/MR03+bucPm7M6ClWUzyR9EzIK0S9c8Au g+EbrqJ77ROGw9a7OZwIL8RnNZm6a0XsXrGcMaS7XR9/YWAcq8YTUt/rhb3SkeZethGTUSJVfiN osLiocbDnnXISFnb8rJLWla0qkaK2Vsw1DxESnDu8SgGulLpnsz6whKh8l0vWBMKv5g5/VtyeOF zVNSxpd8URZFgF1ha3QJJJ2se7RZDWMn6q1uKqN8HFyA6xWq04nbZhxJtWvUcVmvnWMEgggON+s 2deTwyf0MF8hiOuq80+9VertnSPd8mjOynGdLr37iVbUpzrpYdTqhdWVQCYThMNyXhITC2PR9Sd p0 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 *=3D cd->fixed_post_div; =20 - ret =3D 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 =3D readl(cd->common.base + cd->common.reg); + val =3D reg >> cd->div.shift; + val &=3D (1 << cd->div.width) - 1; + + ret =3D divider_ro_determine_rate(&cd->common.hw, req, cd->div.table, + cd->div.width, cd->div.flags, val); + + } else { + ret =3D divider_determine_rate(&cd->common.hw, req, cd->div.table, + cd->div.width, cd->div.flags); + } + if (ret) return ret; =20 @@ -143,3 +157,16 @@ const struct clk_ops ccu_div_ops =3D { .set_rate =3D ccu_div_set_rate, }; EXPORT_SYMBOL_NS_GPL(ccu_div_ops, "SUNXI_CCU"); + +const struct clk_ops ccu_rodiv_ops =3D { + .disable =3D ccu_div_disable, + .enable =3D ccu_div_enable, + .is_enabled =3D ccu_div_is_enabled, + + .get_parent =3D ccu_div_get_parent, + .set_parent =3D ccu_div_set_parent, + + .determine_rate =3D ccu_div_determine_rate, + .recalc_rate =3D 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) } =20 extern const struct clk_ops ccu_div_ops; +extern const struct clk_ops ccu_rodiv_ops; =20 #endif /* _CCU_DIV_H_ */ --=20 2.47.3 From nobody Fri Jul 24 21:52:57 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 A727A437118 for ; Thu, 23 Jul 2026 09:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784799614; cv=none; b=gl4KxGz4+usSlr3ye3mMCTMDrb1Xz2h4QnicIkThge3WH2yoj6sHRScgmEB/5v1fLhp9Ai3khEw9SlyJe65Ywz1jgRS1GdfLbMquK3Eg7TiKNo9a8UyQUUUWO3nn3ZppOC/2CE1YfDwrg9eFquzpY8Jrhd9CMwAPK0AEATEhoWE= 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=I6ZKG45r; arc=none smtp.client-ip=209.85.128.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="I6ZKG45r" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49548e01d02so2393515e9.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=vger.kernel.org; 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=I6ZKG45r9lSxmnsIBBW+WTfARHgr2knBeW99sFU55aaTq/fH7in0WJ3x6cH4+cvxj1 i+C+fglAf5mjy/dtFKOtKg64xwgEQVBcT36wV8TRhjeD9TxkDifw9/a7/G6ugdog3vxU atYDWP/3SFjcH/6tdgzConLkBnTq6Um2Qi9x+KryeXIZjp+v/cyTtwYVpUmS4/BbXf/Q k3VNflON95vMyAQcgZQ4TxvBsf2PtQpIpbGQ0oJAS82U3wFlHhg3/8kkngb6YG319sA5 HAHm07K7Iwzy+edDCHPiOy9kP/E71r5E5gIGWG2PYDSsQEa6iSeET3TM1+IFpSZnUBMm lZag== 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=VLc6NCWZHLAK4CR57D3Cdnrc6KSMBAR+k4zYQK4QF3qj+w30DN17ZNDA13BqaNJPbl OCLMV9YEMkna6/c3JLhdDfaLVusrotKiYGL529E6S8rnsbgrktfmYwoy94LeXlSDGTnV DMbB81NQj0PqY4IV/HzHG3TGXFx+r68wfXUK9kSAqXDEMSEDTPpKvu7FgbpluVC6CSDJ C1HvjBMa4f4L8hG1ztvWAyeL4f3PXrn2IOchwwGbL7hF+yKcL7/XUvDW9Mqf5yEY2t05 jHZWDzkqIrXXSntHFQdff85Du+lsCvbRcDKxImK2gzZakZwTc9M5Q2KfRDX5Vtqm3YXv gsOg== X-Forwarded-Encrypted: i=1; AHgh+RoHFbEJOR4EeWHHem50hdnIOQFhFRRVnU7FI8C6oXlu6Dchx/mJi6mh29uOO1qVOKhIhLrEOfyEHQUmdUs=@vger.kernel.org X-Gm-Message-State: AOJu0YyfTXFkp0HYPzygr6hDH/9TkseTbW+Kg2yQ52bPyLewTryclSqc UInJa8Hzb4wJLVnJjuGDMbi6pBkupkODsAePJJClouDiW9o/KQ2/VNjVFKez//R0wR0= X-Gm-Gg: AR+sD12JZmogAwhAH0yL/J4Qw0mBtDo11FVEpb+kaDRcezJboC34Cy44ba+by9qE417 1b5JUEgLaBHUBKxmlPw+U/XVjVBh/yQXCnvzD4+t/ImAmLoah05OU5frsfYUWzzNRHmhyDfnOlf K4diyU5vL7/lVeFPxFPnwjtofTuOGuUGmEri4UNx22x+kLevjtax1L2jyV1egXkP6R4ks89Xjd8 Lu3GrK31tQr4sRV0ajMPmQpk7YUg1Y65nMK0Rf5ZlOVKTLDL5lbbX5GJZ6tTpwhvYPR4hb/qNNA /c6GcTiPLUew5Uw1tvy7ay3F8OD153FCyTshV86HmoSMqbi0h4Cbd1ewowdK8jj3bzXwTLQTGxT QjV+GOKwHcp4/DT6L7N4jkhojCcVh5kVFAACsIjhwCMDNknsEr7O/De0KDHnu6+g94NsUeL0c2e 2H5ftivMrlsi0= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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/cc= u-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[] =3D { { .fw_name =3D "hosc", .name =3D "osc24M" } }; =20 -static struct ccu_gate osc24M_32k_clk =3D { - .enable =3D BIT(16), - .common =3D { - .reg =3D LOSC_OUT_GATING_REG, - .prediv =3D 750, - .features =3D CCU_FEATURE_ALL_PREDIV, - .hw.init =3D CLK_HW_INIT_PARENTS_DATA("osc24M-32k", osc24M, - &ccu_gate_ops, 0), - }, +static struct clk_fixed_factor osc24M_32k_div_clk =3D { + .mult =3D 1, + .div =3D 750, + .hw.init =3D CLK_HW_INIT_PARENTS_DATA("osc24M-32k-div", + osc24M, + &clk_fixed_factor_ops, + 0), }; =20 +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[] =3D { &osc32k_clk.common.hw, &osc24M_32k_clk.common.hw @@ -286,6 +287,7 @@ static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clks= =3D { [CLK_EXT_OSC32K_GATE] =3D &ext_osc32k_gate_clk.common.hw, [CLK_OSC24M_32K] =3D &osc24M_32k_clk.common.hw, [CLK_RTC_32K] =3D &rtc_32k_clk.common.hw, + [CLK_OSC24M_32K_DIV] =3D &osc24M_32k_div_clk.hw, }, }; =20 diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h b/drivers/clk/sunxi-ng/cc= u-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 =20 -#define CLK_NUMBER (CLK_RTC_32K + 1) +#define CLK_NUMBER (CLK_OSC24M_32K_DIV + 1) =20 #endif /* _CCU_SUN6I_RTC_H */ --=20 2.47.3 From nobody Fri Jul 24 21:52:57 2026 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 C6E11429CF9 for ; Thu, 23 Jul 2026 09:40:14 +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=1784799618; cv=none; b=usDDIl3aeD7d6dAJjfOHxPZS82h8yzSoXwFtMFDvobHCS1crwCXV0BR04rW6hgdpmw/wwKEd62+DW6exU7FBiav6aKnCqI2Y/yLG3wjm/jxATScLxFI4LJfusczzlvC/XQxx2rfcDabscCJReVz7vkEw4r5x5L4sJ2fqiBAzKCY= 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=CA+j/qPY; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="CA+j/qPY" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4954dff6536so3565045e9.0 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=vger.kernel.org; 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=CA+j/qPYPAvnuEKso71/zs8nPLcbJTPWrAp9pxgjuf8Y9Bj2XOVFRad1ELsUBLz1mW CE6aE3UvZNCSuWW4Hi87hNiSgx4lytPxc5DtNx+btAAo6h+dxnxCS0RRVSSk5rb1Zv4t 38+ISRCaKWqDM6iyQiduUfKaMBtCN1DAfPHc3TdyJAXQQgAWovfYwVwGxddapT8htZQH Zt9ATXvdVlnCw/l+vnVcwxtOKuFxBM1T8X6E84O1iLlAvg92dEgOEM5GfVyws3kIK56r LLmEtN7Nlx4TKer74RKDJu9WOvGXum07z9vjINmjcTSo46DKQSfPqfqT+yZSmFCHBDHb iMsQ== 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=Rcs0NtpaR+xhwOh8aTs+SZtbvZ7CXqq90PbfFOLesGyFlkHwb36DGnnkfpfhSX4ogT ODS0QkKDgKy56UBqbUfmwI8sUE+TTk4D0QDUjVHywOnofzAMZShgppM/34v7k+regU56 70DJ+5r25st0crE6L+c0bFcBTMtfcuvWaF4NjmKgmh0M5rpVy4gaeOKMoieIT/5TSs7Z CVmPH0lgF0e/d7s483zC/qsDTMpdQA7++MiZfK8HvgsojQW/NR/jsLjWa2kp2tKNvdL0 uELZJM/9jRMSnrni2Zb9UL4SxH1vUqBqziots/TZicNf6GC4GRPdRqHMxNPd4IP/jMD+ /7+g== X-Forwarded-Encrypted: i=1; AHgh+RqtB/Uri8cqsKDsDly+oG+V2CNT8VUcYnso8I/KGO/gg0M88mc5ER4c9QSpaRatPCQc69l8rxwofE11kIk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy419pVffuw79m2wvt+iq8VZMSP5+nS1UqnDWoEIgEoGYSpo4UJ J0vHGlUtUvtsWcsnAJW5WM9D4uxVQjvqNO/AjsdWnurmaMVwgSkFY+qwHBdNMUifUKM= X-Gm-Gg: AR+sD117H5IU4u1m/WyD026HAvxng9Pho8V1AwEucQUDTIaiDF1DCMp9Ip/ctd2WTUV BV4j+Rs/b3I5PrU8Elv9nyeABHedfsH0rt/fAewGKwrzOakbJzq/1UmtAv4a5A+EDAcIhSsb+h6 k4Gx0T6lgXLdYLLALGyJrYBgeF4nIiEVlhJ+P4KMR52DyBb3EE7PaChTxiWYK7+tZdJCQ9qwg7T ikSSX2NokuWQL/BpQqHDMyojJii3lAEeIw6IXRcqQPLzdCGXegW2aQP+sZ2K2oVbCNrWFspPs2+ vC4vtsZLUVPUmeOf4KBuJp4DdkOKx13+J3K9d/fYxRpPl7mNt+tB1GtruuDMlY9t1C5u/J0k+RH NB+vnbJlWdRsvbGvacq+Tkv56CKRDkBEj/0I+SkMjOr6vR8xAQ9da3fVznzP/O7y0nlhBKz2M8y mM 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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/cc= u-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) =20 +#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 =3D { }, }; =20 -/* This falls back to the global name for fwnodes without a named referenc= e. */ +/* + * This falls back to the global name for fwnodes without a named referenc= e. + * NOTE: osc24M name might be misleading the oscillator could also be a 26= MHz + * or a 19.2MHz one starting with the a733. The original name is kept anyw= ay + * in case anything is relying on it. + */ static const struct clk_parent_data osc24M[] =3D { { .fw_name =3D "hosc", .name =3D "osc24M" } }; @@ -227,8 +238,30 @@ static struct clk_fixed_factor osc24M_32k_div_clk =3D { 0), }; =20 -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[] =3D { + { .val =3D 0, .div =3D 732 }, + { .val =3D 1, .div =3D 586 }, + { .val =3D 2, .div =3D 793 }, + { .val =3D 3, .div =3D 732 }, + { /* Sentinel */ }, +}; + +static struct ccu_div osc24M_32k_div_a733_clk =3D { + .enable =3D BIT(1), + .div =3D _SUNXI_CCU_DIV_TABLE_FLAGS(14, 2, + osc24M_32k_div_a733_table, + CLK_DIVIDER_READ_ONLY), + .common =3D { + .reg =3D DCXO_CTRL_REG, + .hw.init =3D 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); =20 static const struct clk_hw *rtc_32k_parents[] =3D { &osc32k_clk.common.hw, @@ -267,6 +300,15 @@ static struct ccu_mux osc32k_fanout_clk =3D { }, }; =20 +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[] =3D { &iosc_clk, &iosc_32k_clk, @@ -275,6 +317,11 @@ static struct ccu_common *sun6i_rtc_ccu_clks[] =3D { &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, }; =20 static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clks =3D { @@ -288,6 +335,10 @@ static struct clk_hw_onecell_data sun6i_rtc_ccu_hw_clk= s =3D { [CLK_OSC24M_32K] =3D &osc24M_32k_clk.common.hw, [CLK_RTC_32K] =3D &rtc_32k_clk.common.hw, [CLK_OSC24M_32K_DIV] =3D &osc24M_32k_div_clk.hw, + [CLK_HOSC_UFS] =3D &hosc_ufs_clk.common.hw, + [CLK_HOSC_HDMI] =3D &hosc_hdmi_clk.common.hw, + [CLK_HOSC_SERDES0] =3D &hosc_serdes0_clk.common.hw, + [CLK_HOSC_SERDES1] =3D &hosc_serdes1_clk.common.hw, }, }; =20 @@ -330,6 +381,15 @@ static const struct sun6i_rtc_match_data sun55i_a523_r= tc_ccu_data =3D { .osc32k_fanout_nparents =3D ARRAY_SIZE(sun50i_r329_osc32k_fanout_parents), }; =20 +static const struct sun6i_rtc_match_data sun60i_a733_rtc_ccu_data =3D { + .have_ext_osc32k =3D true, + .have_iosc_calibration =3D true, + .have_dcxo_status =3D true, + .have_phy_ref_gates =3D true, + .osc32k_fanout_parents =3D sun50i_r329_osc32k_fanout_parents, + .osc32k_fanout_nparents =3D ARRAY_SIZE(sun50i_r329_osc32k_fanout_parents), +}; + static const struct of_device_id sun6i_rtc_ccu_match[] =3D { { .compatible =3D "allwinner,sun50i-h616-rtc", @@ -343,6 +403,10 @@ static const struct of_device_id sun6i_rtc_ccu_match[]= =3D { .compatible =3D "allwinner,sun55i-a523-rtc", .data =3D &sun55i_a523_rtc_ccu_data, }, + { + .compatible =3D "allwinner,sun60i-a733-rtc", + .data =3D &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 __iom= em *reg) osc32k_fanout_init_data.parent_data =3D data->osc32k_fanout_parents; osc32k_fanout_init_data.num_parents =3D data->osc32k_fanout_nparents; =20 + if (data->have_dcxo_status) + sun6i_rtc_ccu_hw_clks.hws[CLK_OSC24M_32K_DIV] =3D + &osc24M_32k_div_a733_clk.common.hw; + + if (!data->have_phy_ref_gates) + sun6i_rtc_ccu_hw_clks.num =3D CLK_NUMBER_NO_GATES; + return devm_sunxi_ccu_probe(dev, reg, &sun6i_rtc_ccu_desc); } =20 diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.h b/drivers/clk/sunxi-ng/cc= u-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 =20 -#define CLK_NUMBER (CLK_OSC24M_32K_DIV + 1) +#define CLK_NUMBER (CLK_HOSC_SERDES1 + 1) =20 #endif /* _CCU_SUN6I_RTC_H */ --=20 2.47.3