* [PATCH 1/1] rtc: pcf85063: add support for fixed clock
@ 2021-10-13 7:49 Alexander Stein
2021-10-13 20:30 ` kernel test robot
2021-10-15 19:12 ` Alexandre Belloni
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Stein @ 2021-10-13 7:49 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, Rob Herring
Cc: Alexander Stein, linux-rtc, devicetree
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(+)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] rtc: pcf85063: add support for fixed clock
2021-10-13 7:49 [PATCH 1/1] rtc: pcf85063: add support for fixed clock Alexander Stein
@ 2021-10-13 20:30 ` kernel test robot
2021-10-15 19:12 ` Alexandre Belloni
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-10-13 20:30 UTC (permalink / raw)
To: Alexander Stein, Alessandro Zummo, Alexandre Belloni, Rob Herring
Cc: kbuild-all, Alexander Stein, linux-rtc, devicetree
[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38817 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] rtc: pcf85063: add support for fixed clock
@ 2021-10-13 20:30 ` kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-10-13 20:30 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2975 bytes --]
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(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38817 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] rtc: pcf85063: add support for fixed clock
2021-10-13 7:49 [PATCH 1/1] rtc: pcf85063: add support for fixed clock Alexander Stein
2021-10-13 20:30 ` kernel test robot
@ 2021-10-15 19:12 ` Alexandre Belloni
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2021-10-15 19:12 UTC (permalink / raw)
To: Alessandro Zummo, Rob Herring, Alexander Stein
Cc: Alexandre Belloni, devicetree, linux-rtc
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,
--
Alexandre Belloni <alexandre.belloni@bootlin.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-15 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 7:49 [PATCH 1/1] rtc: pcf85063: add support for fixed clock Alexander Stein
2021-10-13 20:30 ` kernel test robot
2021-10-13 20:30 ` kernel test robot
2021-10-15 19:12 ` Alexandre Belloni
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.