Message ID | 20211013074954.997445-1-alexander.stein@ew.tq-group.com |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [1/1] rtc: pcf85063: add support for fixed clock | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | warning | total: 0 errors, 2 warnings, 37 lines checked |
Hi Alexander, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on abelloni/rtc-next] [also build test WARNING on v5.15-rc5 next-20211013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Alexander-Stein/rtc-pcf85063-add-support-for-fixed-clock/20211013-155115 base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next config: x86_64-randconfig-s022-20211013 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-dirty # https://github.com/0day-ci/linux/commit/9f6ceaac6d87d4d5a2a35d209d3e630ff2bdeb4b git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Alexander-Stein/rtc-pcf85063-add-support-for-fixed-clock/20211013-155115 git checkout 9f6ceaac6d87d4d5a2a35d209d3e630ff2bdeb4b # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) >> drivers/rtc/rtc-pcf85063.c:492:24: sparse: sparse: Using plain integer as NULL pointer vim +492 drivers/rtc/rtc-pcf85063.c 476 477 static struct clk *pcf85063_clkout_register_clk(struct pcf85063 *pcf85063) 478 { 479 struct clk *clk; 480 struct clk_init_data init; 481 struct device_node *node = pcf85063->rtc->dev.parent->of_node; 482 struct device_node *fixed_clock; 483 484 fixed_clock = of_get_child_by_name(node, "clock"); 485 if (fixed_clock) { 486 /* 487 * skip registering square wave clock when a fixed 488 * clock has been registered. The fixed clock is 489 * registered automatically when being referenced. 490 */ 491 of_node_put(fixed_clock); > 492 return 0; 493 } 494 495 init.name = "pcf85063-clkout"; 496 init.ops = &pcf85063_clkout_ops; 497 init.flags = 0; 498 init.parent_names = NULL; 499 init.num_parents = 0; 500 pcf85063->clkout_hw.init = &init; 501 502 /* optional override of the clockname */ 503 of_property_read_string(node, "clock-output-names", &init.name); 504 505 /* register the clock */ 506 clk = devm_clk_register(&pcf85063->rtc->dev, &pcf85063->clkout_hw); 507 508 if (!IS_ERR(clk)) 509 of_clk_add_provider(node, of_clk_src_simple_get, clk); 510 511 return clk; 512 } 513 #endif 514 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Wed, 13 Oct 2021 09:49:54 +0200, Alexander Stein wrote: > 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. > > [...] Applied, thanks! [1/1] rtc: pcf85063: add support for fixed clock commit: 4c8a7b80d5f3c924fbe08b24634fb67a97f96465 Best regards,
diff --git a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt index 627bb533eff7..6439682c9319 100644 --- a/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt +++ b/Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt @@ -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>; + }; }; diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index 14da4ab30104..137ad56f2d71 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c @@ -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;
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 f765e349c3e1 ("rtc: m41t80: add support for fixed clock"). Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> --- As mentioned in the commit message this addesses the same problem as on Congatec's board, although we use a different RTC. I also shamelessly reused most of the commit message. .../devicetree/bindings/rtc/nxp,pcf85063.txt | 9 +++++++++ drivers/rtc/rtc-pcf85063.c | 12 ++++++++++++ 2 files changed, 21 insertions(+)