Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3577257pxj; Tue, 15 Jun 2021 04:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPnWQhIjR63Kw/QEdNxiz2mrTzWSjzT4jZm4T9F9HlDB+pXrMQn6+DnVSS/SHn7HIdx921 X-Received: by 2002:a5d:85c1:: with SMTP id e1mr17447158ios.18.1623755377399; Tue, 15 Jun 2021 04:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623755377; cv=none; d=google.com; s=arc-20160816; b=U/gxtBjqRZ6SdSrvv2f7QWb5WX0rwYrzDdRYl3HOF+diUw9XvUGuXCnUluj9xLaRH8 JgS3GtQEUWlC55QClkdx2sjDaeKv75Y5pMWTKEnmqGL6AQeYPfcRseFUNH4K9yCKN33G TGnJnNB+sbjfgAAPSmusRwEKcwAL81zXqpQPeJRkP4TLipOVOLCypEudMKYPHt+HnRLd MLCfInCN5WIHsZAYn8Ao0/Fa5GwBAqvBh/3bQoc6jGaq0gTMSHXHLRyMu7NGd5j2/jqL ESJ8leCXmWqoW8z7tRlPS66XLtmIqeaAFvXki7mPI01JcRAbTgp08n7ccz+2sCassDjK aqUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=5apNX74MU2Gy4bPUBY6yg0XDT5KxjjR0k6S7PCzGAPo=; b=v8jwZ3HimLibauoT1UgWnG7GDR3r1kh3Cuaq+CCOdqe5eoAUeFGGi91ulF6bvSMl0M imLbF2NvljsCN2XAE6wsOkX4pgzXUTnKkCvDpGSTC84uhVYroV0hRebCmCyeKWtXXP8b awljxa4IwE/jJRBYQXb4wni3Ex3abKJYM+B95/q8xo/LdqtTBypk/r4yYhaR9WFLyBlQ GmjIPyLud7cdmSrxKvSdQGX4xItjmvU2hB1WBAVmmoI5uK1PTyS2VICLkPdC1qx1KQHm vYbbcLHyYRoZ//s6pkO8mk8OkVOxZ2beXo509zZxhUvB9OJRf0Kr0WqGHykOXt67FcfN gtzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si18222895ioc.104.2021.06.15.04.09.24; Tue, 15 Jun 2021 04:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbhFOLJa (ORCPT + 99 others); Tue, 15 Jun 2021 07:09:30 -0400 Received: from foss.arm.com ([217.140.110.172]:60512 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbhFOLJS (ORCPT ); Tue, 15 Jun 2021 07:09:18 -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 9C1321396; Tue, 15 Jun 2021 04:07:13 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 816D93F719; Tue, 15 Jun 2021 04:07:11 -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 v7 06/19] rtc: sun6i: Add support for RTCs without external LOSCs Date: Tue, 15 Jun 2021 12:06:23 +0100 Message-Id: <20210615110636.23403-7-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210615110636.23403-1-andre.przywara@arm.com> References: <20210615110636.23403-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 --- 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 54bd47fb0a5f..1fabb3c69041 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.5