Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1454663pxv; Fri, 23 Jul 2021 08:41:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+nrTzeySvbIpOfMwg+K0ulYYQXzUjD128+ASpBYE7nxWsoKSWXb7PmhIbQoB5y3frp00o X-Received: by 2002:a17:906:3942:: with SMTP id g2mr5409983eje.317.1627054897443; Fri, 23 Jul 2021 08:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627054897; cv=none; d=google.com; s=arc-20160816; b=vx7NbjVii75MLIZm1lMiihsX/59hta27CFJPFOV5KqnFAbSDE2102jvEhm8Wmqp5q7 3jC2UlCaKi3S8mYt7gBXd05SPV6vzT6WflokeiDVjzP1rpTLynRfSfMeKfQpBEKyhu74 jinUUWxd5Q/VRH6gGFH0jGpTArjRXbRcaVJPjUcGEIp0868O/eZFua+5k6ZxLVso3I29 Jl4C8aGKs7GiSdNFwAmpz5tVOtgyrMTvzQjoyBZUDTtNWvq2GkO+Am3YTdwfmw8cyfiN FWuJ7taOMrXDUE36DrmoqFbgFf4kdXvjXr5PVISM00uwFZK2b/nD6BODmYyeSfZWzoa8 kcNw== 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=smJ3wtoJ2Vxj7Kk1kLj7GO7vytk+w/NlafOPmEXPfEA=; b=npgzru3h6+5deZy2W9AF7nhUReqk+ZXtQdHjt/0ABZRThzyP7FDFok85KV/I0pAowl 4NyhsfDMgCnHBOSEqUjDrWT61tGEnpQvSJT2UHC687d4zacawPVG2aNYNV9uCqCluAPU 8kEujh9HjQQ0KE9xBQFWTA49WIS9eIpPdeXqNFpRlvz5RxBIxQITCuHqdmctHjHfbzCE VnykuyPJNp7pZFiFIjpNkTONfe1FO9huO0Waz0UoNT3vnwTX4rPCQPpj5vA99hDGuUyb YF3lsUNzOjP8hwzY2S/dgv+ZFi1bSmsXJT60o2SDFSBRIga24LIR3xpDtyl5VV3gIXcV nh9w== 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 f27si41180541ejf.63.2021.07.23.08.41.13; Fri, 23 Jul 2021 08:41: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 S235671AbhGWO7B (ORCPT + 99 others); Fri, 23 Jul 2021 10:59:01 -0400 Received: from foss.arm.com ([217.140.110.172]:47746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235652AbhGWO64 (ORCPT ); Fri, 23 Jul 2021 10:58:56 -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 2ADB5142F; Fri, 23 Jul 2021 08:39:29 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 177B33F73D; Fri, 23 Jul 2021 08:39:26 -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 v8 06/11] rtc: sun6i: Add support for RTCs without external LOSCs Date: Fri, 23 Jul 2021 16:38:33 +0100 Message-Id: <20210723153838.6785-7-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210723153838.6785-1-andre.przywara@arm.com> References: <20210723153838.6785-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 f0ee20bfdccb..ef2b1027ce4c 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