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 searched online with "how to directly read /write spi in linux user space"
results:
The most popular way for SPI read/write in user space is through character device /dev/spidev but this way gives you only half-duplex access. An other way for SPI read/write in user space is through ioctl SPI_IOC_MESSAGE(N) request that gives you full-duplex access.
https://stackoverflow.com/questions/36626214/can-i-select-on-a-dev-spidev-file-descriptor
Maybe it can hep you