Message ID | 20221229215319.14145-1-samuel@sholland.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2604257wrt; Thu, 29 Dec 2022 13:55:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuuPEF7mb4UjH2mvvzGujKKhRhudxllYjLctLFSgtw6JlVKJTbv7FMqDHG/81mexA9yy39z X-Received: by 2002:a17:90a:1048:b0:226:30c5:3e61 with SMTP id y8-20020a17090a104800b0022630c53e61mr3918280pjd.6.1672350935943; Thu, 29 Dec 2022 13:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672350935; cv=none; d=google.com; s=arc-20160816; b=Gu293CiVKnIXCHrtkEG8SZLAiZAynjccWNZ2gQvVSjh30DTG5R6CZuMD/LZO93zuey rVL+M71Kbgl/obYmDMBja7ctEautX/vsd7S/7iKSgTrmezc9IycENpQcd8p32l0f71D0 NJLg9iDmqx0ad0UzpgqZGt5V9jVy/oqlRWjDw5CAESWQCibViCfFgaE6CuYwpcz7NMYL 2LA+LGFZyxX/AHc6rFJMp1eBFVtz2rIZ8R6zFrCltJx19hBQl6dvZY8gY0HavvfpVkYX HkfLgU2Npyq+X9EKw0aeczKgEZ1sl3lN65a4M3I62yhsGj/NLxsMgdvCFscOe9ydYwfy zV2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=GmZbFK5G8r3n4tr/8fciPGSNCkBT0fjFOydO/VsJtnM=; b=IMTaJFp3czbINosB/bAS1Of46LRx4Sj2+wB/7A6h2AODaRLxxmlkqw/2HaG44UoB2e Mp4etNq0/nboVCLkePmjGTNoJlGCWUq9KhYYeXzqkF4MZ1N9vg2EekM4N+lPfvvMusvG i3eFeLeKDNm4Ng/H6DO8QSWyx1lLRORrEsgJcOAiMpDv4ZYS09dDmw3aYRNfKfQqXvZE CkJ57+Wg4YEZk81GC5cNHG32X7QDB47yB6mzdtmsEkA584GeVvuikeKUefoTVesgNOB0 PXEecmYjO1qj73ovxwoB5IFvyIlVuqNc/FQ1tgcjmCUImLt7umejGlWLCiiuqwT8FlPc f+Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=1IFGGQln; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=R4wlBjyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw18-20020a17090b4d1200b00212de1542cesi11233412pjb.92.2022.12.29.13.55.24; Thu, 29 Dec 2022 13:55:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=1IFGGQln; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=R4wlBjyS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233601AbiL2Vx1 (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Thu, 29 Dec 2022 16:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiL2VxZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Dec 2022 16:53:25 -0500 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BBAE1572B; Thu, 29 Dec 2022 13:53:25 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 26EAE32005B5; Thu, 29 Dec 2022 16:53:22 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 29 Dec 2022 16:53:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1672350801; x=1672437201; bh=GmZbFK5G8r3n4tr/8fciPGSNC kBT0fjFOydO/VsJtnM=; b=1IFGGQlnjZZHd4CGC3hCJ/2dUcS0HJG0PDg1NIZG3 UpZNmfRv32+SeQ+hbVeZmNPh1fc0dITzfjsVIQlE6ScS8vdThM+s75geDG2dJvGe LDRAlVfFfGOAZCp5i89RqF0XP4nXTkzklJ1h/IgEWnUZe5ZFomK5hTu799nWHpph 2gzlepUSfOORM439h5lCWz8Mc2SipRF0le86uxx2elSSuGCoNkx+MjU0MOXYmnbL tK1qMMXu2Cjt/tUPAMj0eC/lJJvIF9oUEYrc1ucfK4ylBJULuv3fOTVdDIkEEZ4S dP2C+pBI0T3HTg3TOmS66i7h5OS8c8W6G90ep8nMG04LQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1672350801; x=1672437201; bh=GmZbFK5G8r3n4tr/8fciPGSNCkBT0fjFOyd O/VsJtnM=; b=R4wlBjyS0eWG+v3T4OhIn4vIlyaoUbEWwqlbOG33EBFN+Q4+YQv +BDS6KbSPelxjKCdteUT8WQD8a6fhWY4BeZB2zbH8YZkZMwJoTz61jMC3wfNbGC6 WFxDotjrZTYPZCf0bJ/aAA0/RjlDjWKLZsDSpq5LQoYiW6l8yoAf67lfTZjkRuA/ 9GkQc9JhIV8CndXrP6HFynx+nfum6VLyPhZ60RUwjRzphAlMqo0BcpfoAmvY6Bxr 7Cb47dInTzKci0Z1JvWTqtHXWYdFDJ0YpIG7/Ik9t4JI3lQt2mpPNeTCUG9tgX5o 8zfe0F4fm+LvjvJtOVdcwpJDCFnjFxSbAJw== X-ME-Sender: <xms:UAyuYwkSDzvjMoZmemhcUzxxEdW4nYvOtjGHz_GBURF3JYLeKaWBMA> <xme:UAyuY_3f4GULYIw1le2TsFp8uXavGn2Dt8D6m9S6DkwHEHAnS7T2jhZQHIqyIq5mE 2HLLyeGACJa7wOF6A> X-ME-Received: <xmr:UAyuY-oEmUR3p4MNEZTd7lajrXQZH2zi3byGKZNEbjZEXLdLu8WO8ykWNKaATTMHNlWjDlfheVk4MdDHzfqJPkerO08nwGZBTVD3-XNj6iKgStGFVIK37eLduXnpFKZ5HF44eg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepkeehffethedtteffgfefteetjedvfeelueevudffgfeutdejvdehledv vdffhfevnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: <xmx:UAyuY8m_LGg3ws12hCkqHzVTtf-bgQySISiOAUNoflsOMmkZ8Aij_A> <xmx:UAyuY-0C7OZ8kVxhFYd_lHPBZ7IiE12h1lK7SLmhfc8Eqoq1DKwR8w> <xmx:UAyuYzvJgBaC7pVUVwSRiprpPcGfev2cGF8pL8orO_AAlYsEfHhuEg> <xmx:UQyuY3lj5vDw6tTSDkhmGwJUMVELCLAe_a9tMdI5op1QXVAbQ3LA3Q> Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 16:53:20 -0500 (EST) From: Samuel Holland <samuel@sholland.org> To: Alexandre Belloni <alexandre.belloni@bootlin.com>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com> Cc: Samuel Holland <samuel@sholland.org>, Maxime Ripard <mripard@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH] rtc: sun6i: Always export the internal oscillator Date: Thu, 29 Dec 2022 15:53:19 -0600 Message-Id: <20221229215319.14145-1-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753587054675085883?= X-GMAIL-MSGID: =?utf-8?q?1753587054675085883?= |
Series |
rtc: sun6i: Always export the internal oscillator
|
|
Commit Message
Samuel Holland
Dec. 29, 2022, 9:53 p.m. UTC
On all variants of the hardware, the internal oscillator is one possible
parent for the AR100 clock. It needs to be exported so we can model that
relationship correctly in the devicetree.
Fixes: c56afc1844d6 ("rtc: sun6i: Expose internal oscillator through device tree")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
This patch should be applied before [1] so this patch can be backported.
[1]: https://lore.kernel.org/linux-rtc/20221229184011.62925-2-samuel@sholland.org/
drivers/rtc/rtc-sun6i.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
Comments
On Thu, 29 Dec 2022 15:53:19 -0600 Samuel Holland <samuel@sholland.org> wrote: Hi Samuel, > On all variants of the hardware, the internal oscillator is one possible > parent for the AR100 clock. It needs to be exported so we can model that > relationship correctly in the devicetree. So do you plan to use this third clock on any SoCs that don't export it yet, like the R40 or V3s, or the older SoCs? This would then create a non-compatible DT change, wouldn't it? Since existing/older kernels cannot resolve clock index 2? Or would that not be used by kernels, or would not be fatal? Cheers, Andre > Fixes: c56afc1844d6 ("rtc: sun6i: Expose internal oscillator through device tree") > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > This patch should be applied before [1] so this patch can be backported. > [1]: https://lore.kernel.org/linux-rtc/20221229184011.62925-2-samuel@sholland.org/ > > drivers/rtc/rtc-sun6i.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c > index ed5516089e9a..7038f47d77ff 100644 > --- a/drivers/rtc/rtc-sun6i.c > +++ b/drivers/rtc/rtc-sun6i.c > @@ -136,7 +136,6 @@ struct sun6i_rtc_clk_data { > unsigned int fixed_prescaler : 16; > unsigned int has_prescaler : 1; > unsigned int has_out_clk : 1; > - unsigned int export_iosc : 1; > unsigned int has_losc_en : 1; > unsigned int has_auto_swt : 1; > }; > @@ -271,10 +270,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, > /* Yes, I know, this is ugly. */ > sun6i_rtc = rtc; > > - /* Only read IOSC name from device tree if it is exported */ > - if (rtc->data->export_iosc) > - of_property_read_string_index(node, "clock-output-names", 2, > - &iosc_name); > + of_property_read_string_index(node, "clock-output-names", 2, > + &iosc_name); > > rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL, > iosc_name, > @@ -315,13 +312,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, > goto err_register; > } > > - clk_data->num = 2; > + clk_data->num = 3; > clk_data->hws[0] = &rtc->hw; > clk_data->hws[1] = __clk_get_hw(rtc->ext_losc); > - if (rtc->data->export_iosc) { > - clk_data->hws[2] = rtc->int_osc; > - clk_data->num = 3; > - } > + clk_data->hws[2] = rtc->int_osc; > of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); > return; > > @@ -361,7 +355,6 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { > .fixed_prescaler = 32, > .has_prescaler = 1, > .has_out_clk = 1, > - .export_iosc = 1, > }; > > static void __init sun8i_h3_rtc_clk_init(struct device_node *node) > @@ -379,7 +372,6 @@ static const struct sun6i_rtc_clk_data sun50i_h6_rtc_data = { > .fixed_prescaler = 32, > .has_prescaler = 1, > .has_out_clk = 1, > - .export_iosc = 1, > .has_losc_en = 1, > .has_auto_swt = 1, > };
Hi Andre, On 12/29/22 17:17, Andre Przywara wrote: > On Thu, 29 Dec 2022 15:53:19 -0600 > Samuel Holland <samuel@sholland.org> wrote: > > Hi Samuel, > >> On all variants of the hardware, the internal oscillator is one possible >> parent for the AR100 clock. It needs to be exported so we can model that >> relationship correctly in the devicetree. > > So do you plan to use this third clock on any SoCs that don't export it > yet, like the R40 or V3s, or the older SoCs? This would then create a I am targeting A31 and A23/A33 with this change, so I can correct those devicetrees. Currently A31 has the wrong fourth parent for its AR100 clock, and A23/A33 models it completely wrong as a fixed-factor clock. I have ported Crust to A23/A33, and it sets the AR100 parent to IOSC at boot (just like on other SoCs), so it doesn't have to change the parent during suspend/resume. But because the AR100 clock is modeled wrong in Linux, Linux thinks the APB0 clock is running much faster than it really is, and sets a totally wrong divider in the RSB controller, which breaks the RSB bus. > non-compatible DT change, wouldn't it? Since existing/older kernels > cannot resolve clock index 2? With the current patch contents, I expect this change to be backported as far as 5.4. If I set ".export_iosc = 1" for A31 and A23/A33 instead of entirely removing the flag, it could be backported further. So that somewhat mitigates the issue. The other option would be to add IOSC as a fixed clock in the DT, and use that as the AR100 parent. We would still want to make this change now, so we could eventually clean up the DT. > Or would that not be used by kernels, or would not be fatal? It might not be fatal if the AR100 clock isn't set to its IOSC parent. I would have to test this. Regards, Samuel > > Cheers, > Andre > >> Fixes: c56afc1844d6 ("rtc: sun6i: Expose internal oscillator through device tree") >> Signed-off-by: Samuel Holland <samuel@sholland.org> >> --- >> This patch should be applied before [1] so this patch can be backported. >> [1]: https://lore.kernel.org/linux-rtc/20221229184011.62925-2-samuel@sholland.org/ >> >> drivers/rtc/rtc-sun6i.c | 16 ++++------------ >> 1 file changed, 4 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c >> index ed5516089e9a..7038f47d77ff 100644 >> --- a/drivers/rtc/rtc-sun6i.c >> +++ b/drivers/rtc/rtc-sun6i.c >> @@ -136,7 +136,6 @@ struct sun6i_rtc_clk_data { >> unsigned int fixed_prescaler : 16; >> unsigned int has_prescaler : 1; >> unsigned int has_out_clk : 1; >> - unsigned int export_iosc : 1; >> unsigned int has_losc_en : 1; >> unsigned int has_auto_swt : 1; >> }; >> @@ -271,10 +270,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, >> /* Yes, I know, this is ugly. */ >> sun6i_rtc = rtc; >> >> - /* Only read IOSC name from device tree if it is exported */ >> - if (rtc->data->export_iosc) >> - of_property_read_string_index(node, "clock-output-names", 2, >> - &iosc_name); >> + of_property_read_string_index(node, "clock-output-names", 2, >> + &iosc_name); >> >> rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL, >> iosc_name, >> @@ -315,13 +312,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, >> goto err_register; >> } >> >> - clk_data->num = 2; >> + clk_data->num = 3; >> clk_data->hws[0] = &rtc->hw; >> clk_data->hws[1] = __clk_get_hw(rtc->ext_losc); >> - if (rtc->data->export_iosc) { >> - clk_data->hws[2] = rtc->int_osc; >> - clk_data->num = 3; >> - } >> + clk_data->hws[2] = rtc->int_osc; >> of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); >> return; >> >> @@ -361,7 +355,6 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { >> .fixed_prescaler = 32, >> .has_prescaler = 1, >> .has_out_clk = 1, >> - .export_iosc = 1, >> }; >> >> static void __init sun8i_h3_rtc_clk_init(struct device_node *node) >> @@ -379,7 +372,6 @@ static const struct sun6i_rtc_clk_data sun50i_h6_rtc_data = { >> .fixed_prescaler = 32, >> .has_prescaler = 1, >> .has_out_clk = 1, >> - .export_iosc = 1, >> .has_losc_en = 1, >> .has_auto_swt = 1, >> }; >
Dne četrtek, 29. december 2022 ob 22:53:19 CET je Samuel Holland napisal(a): > On all variants of the hardware, the internal oscillator is one possible > parent for the AR100 clock. It needs to be exported so we can model that > relationship correctly in the devicetree. > > Fixes: c56afc1844d6 ("rtc: sun6i: Expose internal oscillator through device > tree") Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Best regards, Jernej
On Thu, 29 Dec 2022 15:53:19 -0600, Samuel Holland wrote: > On all variants of the hardware, the internal oscillator is one possible > parent for the AR100 clock. It needs to be exported so we can model that > relationship correctly in the devicetree. > > Applied, thanks! [1/1] rtc: sun6i: Always export the internal oscillator commit: 344f4030f6c50a9db2d03021884c4bf36191b53a Best regards,
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index ed5516089e9a..7038f47d77ff 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -136,7 +136,6 @@ struct sun6i_rtc_clk_data { unsigned int fixed_prescaler : 16; unsigned int has_prescaler : 1; unsigned int has_out_clk : 1; - unsigned int export_iosc : 1; unsigned int has_losc_en : 1; unsigned int has_auto_swt : 1; }; @@ -271,10 +270,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, /* Yes, I know, this is ugly. */ sun6i_rtc = rtc; - /* Only read IOSC name from device tree if it is exported */ - if (rtc->data->export_iosc) - of_property_read_string_index(node, "clock-output-names", 2, - &iosc_name); + of_property_read_string_index(node, "clock-output-names", 2, + &iosc_name); rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL, iosc_name, @@ -315,13 +312,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, goto err_register; } - clk_data->num = 2; + clk_data->num = 3; clk_data->hws[0] = &rtc->hw; clk_data->hws[1] = __clk_get_hw(rtc->ext_losc); - if (rtc->data->export_iosc) { - clk_data->hws[2] = rtc->int_osc; - clk_data->num = 3; - } + clk_data->hws[2] = rtc->int_osc; of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); return; @@ -361,7 +355,6 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { .fixed_prescaler = 32, .has_prescaler = 1, .has_out_clk = 1, - .export_iosc = 1, }; static void __init sun8i_h3_rtc_clk_init(struct device_node *node) @@ -379,7 +372,6 @@ static const struct sun6i_rtc_clk_data sun50i_h6_rtc_data = { .fixed_prescaler = 32, .has_prescaler = 1, .has_out_clk = 1, - .export_iosc = 1, .has_losc_en = 1, .has_auto_swt = 1, };