Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1882906pxb; Mon, 22 Feb 2021 13:36:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMe+W15acAUAlDtJsVpRmDAM5di0rVettfvqDfV4MTrskJsuAfSCdto0JgL62nkXn3ViiO X-Received: by 2002:a05:6402:1641:: with SMTP id s1mr25223424edx.272.1614029762038; Mon, 22 Feb 2021 13:36:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614029762; cv=none; d=google.com; s=arc-20160816; b=pmRHmlKOGlVONwXhdNUtKvykLMDKUerfeA8LUurzIp6jFqkJ5KZRuOWTrdnq8fm2VW /EvRzxCOoa0WqdTqwyrBN/y7/P8U/CBmu6PONV8SAH7Db2Hr1QnpfXKcqJMZLOe4VD3E heBQ2zKp8C5F2B8rl2BDSu4hsrmht8xWxpwwPw1UAHkvUw9b5H1MrPXFc/9oZReAnIGf 4/xQR/Asf3ciSW2Kg8SHzDTX1U9iqvYwyU86ZHR9woip3uGcQgp01TJSTUGRRTkPxCmT VswXAv3VA5vWL2g/LPvFSZ8figjmvPHbtqHUqL9JuSWEEcIMCWoKujDmEkRlMIOTcRVd rQqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=aChLGfv1Z5fwr9ITPUvGKPNvoITVz68zIyBKogddcVI=; b=viVSdvAB1iGmXF8gLgJuroGm8/5Nn9TpcvZEDKdpTqQG7qGkKHgNK/nKG8zC2qYkfP KF5erDBu3FFJsCayUrUGfNDJfu6fYMX9g5NtLdTa2ArIq+9Lmjkhnse3jcdWj6DXZ/Ou Hersz+SFXd0jJJdwL02U06Tg7+0wGUAGcGEv+tYoXzrIbNZ6wsoV485sErIJGwNHUffj g4h7Kf/dcUwkcn0V/sgSJaGej/JL8mCzBMnmfUJ1puysbfT7zATSOq16VhbR/4bfoj3J I/ZKto9hCXApO/lrDGqsrQldJ3NtEBOgu61Adk1r1bxKSvoN+GtSfmtS5rewO/vMcQwG 1dOA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si9635309edv.517.2021.02.22.13.35.39; Mon, 22 Feb 2021 13:36:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbhBVVVg (ORCPT + 99 others); Mon, 22 Feb 2021 16:21:36 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:44567 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbhBVVVf (ORCPT ); Mon, 22 Feb 2021 16:21:35 -0500 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 92EC9240004; Mon, 22 Feb 2021 21:20:45 +0000 (UTC) Date: Mon, 22 Feb 2021 22:20:45 +0100 From: Alexandre Belloni To: Sebastian Reichel Cc: Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rob Herring , 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: Re: [PATCHv1 1/6] rtc: m41t80: add support for protected clock Message-ID: References: <20210222171247.97609-1-sebastian.reichel@collabora.com> <20210222171247.97609-2-sebastian.reichel@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210222171247.97609-2-sebastian.reichel@collabora.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/02/2021 18:12:42+0100, Sebastian Reichel wrote: > 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. > Reading the previous paragraph, I was going to suggest describing the dependency and wondering whether this would cause a circular dependency. I guess this will keep being an issue for clocks on an I2C or SPI bus... > 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 Acked-by: Alexandre Belloni > --- > 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 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com