Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1725061pxb; Mon, 22 Feb 2021 09:18:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOg474oU/rYhRanjquuT08/wHn8ufrv1uHcSIT3IJlGAEMIpLhHo4Iwx8oTqFCAsMt6g+R X-Received: by 2002:a17:906:681a:: with SMTP id k26mr8176007ejr.450.1614014285019; Mon, 22 Feb 2021 09:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614014285; cv=none; d=google.com; s=arc-20160816; b=EEkTz5uNDrn6CQ5RchJfeatc5l+CjtQGBYfBHWxgayUKQKAehSjue5BAl9rH0IyyfX qoRDfMmy6ws/boCgX4di8sfIb8EDtuJ0HZF9L4KDaja75nac0/BDhv52wAuZ4Lm6X7mv Ji8iAexkX/GQCF4oP+R10iR4j6rAuuFp9lHA3wwsnEAapXB5TSvMM6lys5UjhoEiL2Q4 SN9uw5/34e+oHVlxQ0eYqkp3RCYz1S5lNxYQCR4D1vF3IrdE1hWKBBs5bOb2ecD35kk7 t0fnUaQENMvl8D/svAjVtJsMNHBoi5PPEZVLkBbTe0kUqPfEaZGTn/ugImIe+YUXrW4L 0Ppg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dWK0aT4sjrTXL+8lAq/yFrWoiSbWWsvNX6NBxgQjfms=; b=PAC8cel0uFD9HN6j0W4LTY7gu+SeGUqYxSUeb/25AOOr7SmZd9n0fwXeRyP/3eGlrA MonFOOCD+tXBFRfQ0iBDOH/GbSgn24CQZmSJQOR9tHWKxf4WcGAuMTg+NHLOtf2jSvT5 KT4dA5AM8zrlYHJ1mDUAUXYm8veU3oCuH+YfxABEeR5t4cI9VqCBBUpiqvlktAsQvTSl HA/LBleaLgK+41eU508atZcxv25G9+9UFoxLD2qdB+XZA81yJGS2aJ2gSr4EZPIUmf1n LtlUhiWQe+IlizZPu60blnlkTkKq/Q38Pfws47YEaLXMxYSi24xU5jYTGxg2LTPYq2JD IHGA== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si11446507edp.327.2021.02.22.09.17.41; Mon, 22 Feb 2021 09:18:05 -0800 (PST) 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbhBVROL (ORCPT + 99 others); Mon, 22 Feb 2021 12:14:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbhBVRNq (ORCPT ); Mon, 22 Feb 2021 12:13:46 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E59C06174A; Mon, 22 Feb 2021 09:13:06 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id BC0EB1F451E2 Received: by jupiter.universe (Postfix, from userid 1000) id 4E8464800D9; Mon, 22 Feb 2021 18:12:51 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: Rob Herring , Alexandre Belloni , Alessandro Zummo , David Airlie , Daniel Vetter , Miquel Raynal , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-mtd@lists.infradead.org, kernel@collabora.com Subject: [PATCHv1 1/6] rtc: m41t80: add support for protected clock Date: Mon, 22 Feb 2021 18:12:42 +0100 Message-Id: <20210222171247.97609-2-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210222171247.97609-1-sebastian.reichel@collabora.com> References: <20210222171247.97609-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Congatec's QMX6 system on module (SoM) uses a m41t62 as RTC. The modules SQW clock output defaults to 32768 Hz. This behaviour is used to provide the i.MX6 CKIL clock. Once the RTC driver is probed, the clock is disabled and all i.MX6 functionality depending on the 32 KHz clock has undefined behaviour. On systems using hardware watchdog it seems to likely trigger a lot earlier than configured. The proper solution would be to describe this dependency in DT, but that will result in a deadlock. The kernel will see, that i.MX6 system clock needs the RTC clock and do probe deferral. But the i.MX6 I2C module never becomes usable without the i.MX6 CKIL clock and thus the RTC's clock will not be probed. So from the kernel's perspective this is a chicken-and-egg problem. Technically everything is fine by not touching anything, since the RTC clock correctly enables the clock on reset (i.e. on battery backup power loss) and also the bootloader enables it in case a kernel without this support has been booted. The 'protected-clocks' property is already in use for some clocks that may not be touched because of firmware limitations and is described in Documentation/devicetree/bindings/clock/clock-bindings.txt. Signed-off-by: Sebastian Reichel --- Documentation/devicetree/bindings/rtc/rtc-m41t80.txt | 1 + drivers/rtc/rtc-m41t80.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt b/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt index c746cb221210..ea4bbf5c4282 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt @@ -19,6 +19,7 @@ Optional properties: - interrupts: rtc alarm interrupt. - clock-output-names: From common clock binding to override the default output clock name +- protected-clocks: Bool, if set operating system should not handle clock. - wakeup-source: Enables wake up of host system on alarm Example: diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 160dcf68e64e..3296583853a8 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c @@ -546,6 +546,9 @@ static struct clk *m41t80_sqw_register_clk(struct m41t80_data *m41t80) struct clk_init_data init; int ret; + if (of_property_read_bool(node, "protected-clocks")) + return 0; + /* First disable the clock */ ret = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); if (ret < 0) -- 2.30.0