Skip to content

Commit

Permalink
rtc: pcf85063: add support for fixed clock
Browse files Browse the repository at this point in the history
TQ-Systems' TQMa8Mx module (SoM) uses a pcf85063 as RTC. The default output
is 32768Hz. This is to provide the i.MX8M CKIL clock. Once the RTC driver
is probed, the clock is disabled and all i.MX8M functionality depending on
the 32 KHz clock will halt. In our case the whole system halts and a power
cycle is required.

Referencing the pcf85063 directly results in a deadlock. The kernel
will see, that i.MX8M system clock needs the RTC clock and do probe
deferral. But the i.MX8M I2C module never becomes usable without the
i.MX8M 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).

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.MX8M.

This addresses the exact same issue as in commit f765e34 ("rtc:
m41t80: add support for fixed clock").

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
  • Loading branch information
tq-steina authored and intel-lab-lkp committed Oct 13, 2021
1 parent 7caadcf commit 9f6ceaa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ Optional property:
expressed in femto Farad (fF). Valid values are 7000 and 12500.
Default value (if no value is specified) is 7000fF.

Optional child node:
- clock: Provide this if the square wave pin is used as boot-enabled fixed clock.

Example:

pcf85063: rtc@51 {
compatible = "nxp,pcf85063";
reg = <0x51>;
quartz-load-femtofarads = <12500>;

clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <32768>;
};
};
12 changes: 12 additions & 0 deletions drivers/rtc/rtc-pcf85063.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,18 @@ static struct clk *pcf85063_clkout_register_clk(struct pcf85063 *pcf85063)
struct clk *clk;
struct clk_init_data init;
struct device_node *node = pcf85063->rtc->dev.parent->of_node;
struct device_node *fixed_clock;

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;
}

init.name = "pcf85063-clkout";
init.ops = &pcf85063_clkout_ops;
Expand Down

0 comments on commit 9f6ceaa

Please sign in to comment.