Hello everyone,
I want to add RTC function to imx8 maaxboard,
We used another board with SPI interface and rtc chip M41T93RMY6F on the motherboard.
I found that there is a kernel driver file for the chip M41T93RMY6F.
and so
problem:
1.
I need to configure the kernel to select spi rtc M41T93RMY6F support, right?
So after the kernel is configured, should spi rtc work properly?
2. After the kernel is started, how to configure or read/set the time or date in the user space?
3. Or directly use hwclock command to set/read rtc? No other settings or configurations are needed after the kernel is started?
4. Any user space application source code?
thank you very much.
Solved! Go to Solution.
hi
step 1
I have successfully added the rtc spi m41t39 in maaxbaord.
237 pinctrl_ecspi1: ecspi1grp {
238 fsl,pins = <
239 MX8MQ_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x16
240 MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x16
241 MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x16
242 MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1816
243 >;
244 };
&ecspi1{
fsl,spi-num-chipselects = < 1 >;
cs-gpios = <&gpio5 9 0 > ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1 >;
status = "okay";
#address-cells=<1>;
#size-cells=<0>;
rtc@0x00{
#address-cellss=<1>;
#size-cells=<1>;
compatible = "rtc-m41t93";
spi-max-frequency = <5000000>;
reg = <0>;
};
};
step 2. config m41t39 in kernel config.
NOT use module, need to build in kernel. because if use module. every time after kernel start up, the module should insert and the time should reset again so that it seems does not work.
I got some doc from technical supporter:
and changed dts as below:
237 pinctrl_ecspi1: ecspi1grp {
238 fsl,pins = <
239 MX8MQ_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x16
240 MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x16
241 MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x16
242 MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1816
243 >;
244 };
&ecspi1{
fsl,spi-num-chipselects = < 1 >;
cs-gpios = <&gpio5 13 0 > ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1 >;
status = "okay";
#address-cells=<1>;
#size-cells=<0>;
rtc@0x00{
#address-cellss=<1>;
#size-cells=<1>;
compatible = "rtc-m41t93";
spi-max-frequency = <20000000>;
reg = <0>;
};
};
but error:
dmesg | grep rtc
[ 1.038658] imx-drm display-subsystem: bound imx-dcss-crtc.0 (ops dcss_crtc_ops)
[ 2.414482] rtc-m41t93 spi0.0: rtc core: registered rtc-m41t93 as rtc0
[ 2.422484] snvs_rtc 30370000.snvs:snvs-rtc-lp: rtc core: registered 30370000.snvs:snvs-rtc-lp as rtc1
[ 2.894506] rtc-m41t93 spi0.0: hctosys: unable to read the hardware clock
---
I am at sure how to register SPI rtc driver, in the driver file : the .name =rtc-m41t93. but there is not "compatible"
any suggestions?
Thank you.
attached file is reference file from maxxbaord
Hi jin1
nxp has special service for helping customers with software porting :
https://contact.nxp.com/new-prof-svcs-sw-tech
Best regards
igor
Hi jin1
for external rtc examples one can look at below link
https://variwiki.com/index.php?title=IMX_RTC
https://github.com/varigit/linux-imx/blob/imx_4.19.35_1.1.0_var01/arch/arm/boot/dts/imx6q-var-dt6cus...
Best regards
igor
thank you very much.
another thing:
the new forum is not convenient than before. after you replied, I can not received in my email new. before I could received replying every time.
I read your posted help doc.
it's not for Imx8mq.
I do not find simliar RTC node in imx8qm device tree in maaxboard(em-sbc-imx8m.dts) or imx8mq-evk board(fsl-imx8mq-evk.dts)
I asked the technical supporter ,and get the pin
J10 in board in maaxboard
original GPIO processor ball SPI function (another ball No. from different Doc, maybe wrong)
19 GPIO3_IO06 G20 ECSSPI1_MOSI. A4
21 GPIO3_IO07. J20 ECSSPI1_MISO B4
23 GPIO3_IO00 G19 ECSSPI1_SCLK D5
24 GPIO3_IO01 H19 ECS SPI1_SS0 D4
I am another sure how to add SPI node in device tree.
any more help?
----
attched is em-sbc-imx8m.dts file
Hi jin1
i.MX8MQ has ecspi, i2c modules similar to i.MX6 series. So modifications
can be performed in the same way.
Best regards
igor
I find a patch at here:
should be work for SPI? please have a look.
I am going to try.
Thank you
https://patchwork.kernel.org/patch/10782611/
diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 892063a7c26c..45b9d4a8b0da 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -26,6 +26,9 @@
serial1 = &uart2;
serial2 = &uart3;
serial3 = &uart4;
+ spi0 = &ecspi1;
+ spi1 = &ecspi2;
+ spi2 = &ecspi3;
};
ckil: clock-ckil {
@@ -381,6 +384,42 @@
#size-cells = <1>;
ranges = <0x30800000 0x30800000 0x400000>;
+ ecspi1: spi@30820000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "fsl,imx8mq-ecspi", "fsl,imx51-ecspi";
+ reg = <0x0 0x30820000 0x0 0x10000>;
+ interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk IMX8MQ_CLK_ECSPI1_ROOT>,
+ <&clk IMX8MQ_CLK_ECSPI1_ROOT>;
+ clock-names = "ipg", "per";
+ status = "disabled";
+ };
+
+ ecspi2: spi@30830000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "fsl,imx8mq-ecspi", "fsl,imx51-ecspi";
+ reg = <0x0 0x30830000 0x0 0x10000>;
+ interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk IMX8MQ_CLK_ECSPI2_ROOT>,
+ <&clk IMX8MQ_CLK_ECSPI2_ROOT>;
+ clock-names = "ipg", "per";
+ status = "disabled";
+ };
+
+ ecspi3: spi@30840000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "fsl,imx8mq-ecspi", "fsl,imx51-ecspi";
+ reg = <0x0 0x30840000 0x0 0x10000>;
+ interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk IMX8MQ_CLK_ECSPI3_ROOT>,
+ <&clk IMX8MQ_CLK_ECSPI3_ROOT>;
+ clock-names = "ipg", "per";
+ status = "disabled";
+ };
+
uart1: serial@30860000 {
compatible = "fsl,imx8mq-uart",
"fsl,imx6q-uart";
thank you very much.
I am trying to add it
add something like this: in fsl-imx8mq.dtsi
right?
784 ecspi1: ecspi@30820000 {
785 compatible = "fsl,imx6ul-ecspi", "fsl,imx51-ecspi";
786 reg = <0x0 0x30820000 0x0 0x10000>;
787 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
788 clocks = <&clk IMX8MQ_CLK_ECSPI1_ROOT>,
789 <&clk IMX8MQ_CLK_ECSPI1_ROOT>;
790 clock-names = "ipg", "per";
791 status = "okay";
792 rtc@68 {
793 compatible = "rtc-m41t93";
794 reg = <0x68>;
795 };
796
797 };
test results using the rtc node as upper
-sh-4.4# dmesg | grep rtc
[ 1.043095] imx-drm display-subsystem: bound imx-dcss-crtc.0 (ops dcss_crtc_ops)
[ 2.045533] spi_master spi0: /ecspi@30820000/rtc@68 has no valid 'spi-max-frequency' property (-22)
[ 2.054696] spi_master spi0: Failed to create SPI device for /ecspi@30820000/rtc@68
[ 2.435732] snvs_rtc 30370000.snvs:snvs-rtc-lp: rtc core: registered 30370000.snvs:snvs-rtc-lp as rtc0
[ 2.883123] snvs_rtc 30370000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0)
my dts for spi rtc
I used your reference file and changed(add) dts in em-sbc-imx8m.dts
as below:
237 pinctrl_ecspi1: ecspi1grp {
238 fsl,pins = <
239 MX8MQ_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x16
240 MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x16
241 MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x16
242 MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1816
243 >;
244 };
&ecspi1{
fsl,spi-num-chipselects = < 1 >;
cs-gpios = <&gpio5 13 0 > ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1 >;
status = "okay";
#address-cells=<1>;
#size-cells=<0>;
rtc@0x00{
#address-cellss=<1>;
#size-cells=<1>;
compatible = "rtc-m41t93";
spi-max-frequency = <20000000>;
reg = <0>;
};
};
but error:
dmesg | grep rtc
[ 1.038658] imx-drm display-subsystem: bound imx-dcss-crtc.0 (ops dcss_crtc_ops)
[ 2.414482] rtc-m41t93 spi0.0: rtc core: registered rtc-m41t93 as rtc0
[ 2.422484] snvs_rtc 30370000.snvs:snvs-rtc-lp: rtc core: registered 30370000.snvs:snvs-rtc-lp as rtc1
[ 2.894506] rtc-m41t93 spi0.0: hctosys: unable to read the hardware clock
hi
step 1
I have successfully added the rtc spi m41t39 in maaxbaord.
237 pinctrl_ecspi1: ecspi1grp {
238 fsl,pins = <
239 MX8MQ_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x16
240 MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x16
241 MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x16
242 MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x1816
243 >;
244 };
&ecspi1{
fsl,spi-num-chipselects = < 1 >;
cs-gpios = <&gpio5 9 0 > ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1 >;
status = "okay";
#address-cells=<1>;
#size-cells=<0>;
rtc@0x00{
#address-cellss=<1>;
#size-cells=<1>;
compatible = "rtc-m41t93";
spi-max-frequency = <5000000>;
reg = <0>;
};
};
step 2. config m41t39 in kernel config.
NOT use module, need to build in kernel. because if use module. every time after kernel start up, the module should insert and the time should reset again so that it seems does not work.