From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 363B0C432BE for ; Mon, 2 Aug 2021 00:41:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B0CD60F70 for ; Mon, 2 Aug 2021 00:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbhHBAlH (ORCPT ); Sun, 1 Aug 2021 20:41:07 -0400 Received: from foss.arm.com ([217.140.110.172]:57262 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232218AbhHBAlF (ORCPT ); Sun, 1 Aug 2021 20:41:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 834D2D6E; Sun, 1 Aug 2021 17:40:56 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A04C3F66F; Sun, 1 Aug 2021 17:40:54 -0700 (PDT) From: Andre Przywara To: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec Cc: Rob Herring , Icenowy Zheng , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ondrej Jirman , Alessandro Zummo , Alexandre Belloni , linux-rtc@vger.kernel.org Subject: [PATCH v9 06/11] rtc: sun6i: Add support for RTCs without external LOSCs Date: Mon, 2 Aug 2021 01:39:47 +0100 Message-Id: <20210802003952.19942-7-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210802003952.19942-1-andre.przywara@arm.com> References: <20210802003952.19942-1-andre.przywara@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some newer Allwinner RTCs (for instance the one in the H616 SoC) lack a pin for an external 32768 Hz oscillator. As a consequence, this LOSC can't be selected as the RTC clock source, and we must rely on the internal RC oscillator. To allow additions of clocks to the RTC node, add a feature bit to ignore any provided clocks for now (the current code would think this is the external LOSC). Later DTs and code can then for instance add the PLL based clock input, and older kernel won't get confused. Signed-off-by: Andre Przywara Acked-by: Jernej Skrabec --- drivers/rtc/rtc-sun6i.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 752bea949050..fe1bee3a4ec6 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -134,6 +134,7 @@ struct sun6i_rtc_clk_data { unsigned int export_iosc : 1; unsigned int has_losc_en : 1; unsigned int has_auto_swt : 1; + unsigned int no_ext_losc : 1; }; #define RTC_LINEAR_DAY BIT(0) @@ -256,7 +257,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, } /* Switch to the external, more precise, oscillator, if present */ - if (of_get_property(node, "clocks", NULL)) { + if (!rtc->data->no_ext_losc && of_get_property(node, "clocks", NULL)) { reg |= SUN6I_LOSC_CTRL_EXT_OSC; if (rtc->data->has_losc_en) reg |= SUN6I_LOSC_CTRL_EXT_LOSC_EN; @@ -282,14 +283,19 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, } parents[0] = clk_hw_get_name(rtc->int_osc); - /* If there is no external oscillator, this will be NULL and ... */ - parents[1] = of_clk_get_parent_name(node, 0); + if (rtc->data->no_ext_losc) { + parents[1] = NULL; + init.num_parents = 1; + } else { + /* If there is no external oscillator, this will be NULL and */ + parents[1] = of_clk_get_parent_name(node, 0); + /* ... number of clock parents will be 1. */ + init.num_parents = of_clk_get_parent_count(node) + 1; + } rtc->hw.init = &init; init.parent_names = parents; - /* ... number of clock parents will be 1. */ - init.num_parents = of_clk_get_parent_count(node) + 1; of_property_read_string_index(node, "clock-output-names", 0, &init.name); -- 2.17.6