All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Alessandro Zummo <a.zummo@towertech.it>
Cc: linux-rtc@vger.kernel.org
Subject: Re: [PATCHv2 1/5] rtc: m41t80: add support for fixed clock
Date: Fri, 21 May 2021 15:11:41 +0200	[thread overview]
Message-ID: <20210521131141.ss46m5en25kxo2v6@earth.universe> (raw)
In-Reply-To: <20210428222953.235280-2-sebastian.reichel@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 3926 bytes --]

Hi Alexandre/Alessandro,

Can you merge this patch? It received Reviewed-by from Rob Herring
and Saravana Kannan.

It is required for the last patch adding a DT for a new board, but
there is no compile-time dependency. Thus it can just go through your
tree (just like the second patch has been merged through DRM
already).

Thanks,

-- Sebastian

On Thu, Apr 29, 2021 at 12:29:49AM +0200, 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. For example when using
> the hardware watchdog the system will likely do arbitrary reboots.
> 
> Referencing the m41t62 directly results 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 an something (e.g. an unpatched kernel) disabled this
> incorrectly.
> 
> A workaround for this issue is describing the square wave pin
> as fixed-clock, which is registered early and basically how
> this pin is used on the i.MX6.
> 
> Suggested-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  Documentation/devicetree/bindings/rtc/rtc-m41t80.txt |  9 +++++++++
>  drivers/rtc/rtc-m41t80.c                             | 12 ++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt b/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt
> index c746cb221210..cdd196b1e9bd 100644
> --- a/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt
> +++ b/Documentation/devicetree/bindings/rtc/rtc-m41t80.txt
> @@ -21,10 +21,19 @@ Optional properties:
>                        clock name
>  - wakeup-source: Enables wake up of host system on alarm
>  
> +Optional child node:
> +- clock: Provide this if the square wave pin is used as boot-enabled fixed clock.
> +
>  Example:
>  	rtc@68 {
>  		compatible = "st,m41t80";
>  		reg = <0x68>;
>  		interrupt-parent = <&UIC0>;
>  		interrupts = <0x9 0x8>;
> +
> +		clock {
> +			compatible = "fixed-clock";
> +			#clock-cells = <0>;
> +			clock-frequency = <32768>;
> +		};
>  	};
> diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
> index 89128fc29ccc..b3ece42b6f90 100644
> --- a/drivers/rtc/rtc-m41t80.c
> +++ b/drivers/rtc/rtc-m41t80.c
> @@ -544,10 +544,22 @@ static struct clk *m41t80_sqw_register_clk(struct m41t80_data *m41t80)
>  {
>  	struct i2c_client *client = m41t80->client;
>  	struct device_node *node = client->dev.of_node;
> +	struct device_node *fixed_clock;
>  	struct clk *clk;
>  	struct clk_init_data init;
>  	int ret;
>  
> +	fixed_clock = of_get_child_by_name(node, "clock");
> +	if (fixed_clock) {
> +		/*
> +		 * skip registering square wave clock when a fixed
> +		 * clock has been registered. The fixed clock is
> +		 * registered automatically when being referenced.
> +		 */
> +		of_node_put(fixed_clock);
> +		return 0;
> +	}
> +
>  	/* First disable the clock */
>  	ret = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON);
>  	if (ret < 0)
> -- 
> 2.30.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2021-05-21 13:11 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 22:29 [PATCHv2 0/5] Support for GE B1x5v2 and B1x5Pv2 Sebastian Reichel
2021-04-28 22:29 ` Sebastian Reichel
2021-04-28 22:29 ` Sebastian Reichel
2021-04-28 22:29 ` Sebastian Reichel
2021-04-28 22:29 ` [PATCHv2 1/5] rtc: m41t80: add support for fixed clock Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-29  1:11   ` Saravana Kannan
2021-04-29  1:11     ` Saravana Kannan
2021-04-29  1:11     ` Saravana Kannan
2021-04-29  1:11     ` Saravana Kannan
2021-04-29  2:58   ` kernel test robot
2021-05-05 23:00   ` Rob Herring
2021-05-05 23:00     ` Rob Herring
2021-05-05 23:00     ` Rob Herring
2021-05-05 23:00     ` Rob Herring
2021-05-21 13:11   ` Sebastian Reichel [this message]
2021-04-28 22:29 ` [PATCHv2 2/5] drm/imx: Add 8 pixel alignment fix Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-05-10 14:47   ` Philipp Zabel
2021-05-10 14:47     ` Philipp Zabel
2021-05-10 14:47     ` Philipp Zabel
2021-05-10 14:47     ` Philipp Zabel
2021-04-28 22:29 ` [PATCHv2 3/5] dt-bindings: vendor-prefixes: add congatec Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-05-05 23:01   ` Rob Herring
2021-05-05 23:01     ` Rob Herring
2021-05-05 23:01     ` Rob Herring
2021-05-05 23:01     ` Rob Herring
2021-04-28 22:29 ` [PATCHv2 4/5] dt-bindings: arm: fsl: add GE B1x5pv2 boards Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-05-05 23:02   ` Rob Herring
2021-05-05 23:02     ` Rob Herring
2021-05-05 23:02     ` Rob Herring
2021-05-05 23:02     ` Rob Herring
2021-04-28 22:29 ` [PATCHv2 5/5] ARM: dts: imx6: Add GE B1x5v2 Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-04-28 22:29   ` Sebastian Reichel
2021-05-22 14:04   ` Shawn Guo
2021-05-22 14:04     ` Shawn Guo
2021-05-22 14:04     ` Shawn Guo
2021-05-22 14:04     ` Shawn Guo
2021-05-24 22:29 ` (subset) [PATCHv2 0/5] Support for GE B1x5v2 and B1x5Pv2 Alexandre Belloni
2021-05-24 22:29   ` Alexandre Belloni
2021-05-24 22:29   ` Alexandre Belloni
2021-05-24 22:29   ` Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210521131141.ss46m5en25kxo2v6@earth.universe \
    --to=sebastian.reichel@collabora.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.