IMX RTC: Difference between revisions

From Variscite Wiki
No edit summary
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_THUD_V1.1_DART-6UL as default
<!-- Set release according to "release" parameter in URL and use RELEASE_THUD_V1.1_DART-6UL as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_THUD_V1.1_DART-6UL}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_THUD_V1.1_DART-6UL}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Real Time Clock (RTC)}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Real Time Clock (RTC)}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
= Setting the RTC =
= Setting the RTC =
{{note|Please note that starting from kernel 5.x, RTC node in the device tree must not inclde the IRQ pin declaration if not actually connected.<br>If a wrong declation is present, hwclock command will fail.}}
{{note|Please note that starting from kernel 5.x the RTC node in the device tree must not include the IRQ pin declaration if it is not actually connected.<br>
If a wrong declaration is present the hwclock command will fail.}}


First set the system date & time:
First set the system date & time:
Line 47: Line 48:
</pre>
</pre>
For VAR-SOM-6UL on SymphonyBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
For VAR-SOM-6UL on SymphonyBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
|}}
|}}{{#ifeq: {{#var:SOC}} | mx7 |
{{#ifeq: {{#var:SOC}} | mx7 |
For VAR-SOM-MX7 on MX7CustomBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
For VAR-SOM-MX7 on MX7CustomBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
|}}
|}}{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
{{#ifexpr:{{#rpos:{{#var:HARDWARE_NAME}}|DART}}>-1|
{{#ifexpr:{{#rpos:{{#var:HARDWARE_NAME}}|DART}}>-1|
For {{#var:HARDWARE_NAME}} on DT8MCustomBoard, RTC IRQ#2 pin is already connected to pin J3.38 of the SoM.<br>
For {{#var:HARDWARE_NAME}} on DT8MCustomBoard, RTC IRQ#2 pin is already connected to pin J3.38 of the SoM.<br>
Line 61: Line 60:
<br>For SPEAR-MX8 on SP8CustomBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
<br>For SPEAR-MX8 on SP8CustomBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
|}}
|}}
|}}{{#ifeq: {{#var:SOC}} | mx93 |
For VAR-SOM-MX93 on SymphonyBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.
|}}
|}}


== Using rtcwake command ==
== Using rtcwake command ==
Assuming the your board implement RTC wakeup capabilities, to set the RTC to wakeup after 10 seconds type:
Assuming the your board implement RTC wakeup capabilities, ensure RTC and system time are synchronized
# hwclock -w
then set the RTC to wakeup after 10 seconds type:
  # echo enabled > /sys/class/rtc/rtc0/device/power/wakeup
  # echo enabled > /sys/class/rtc/rtc0/device/power/wakeup
  # rtcwake -m mem -d rtc0 -s 10
  # echo `date "+%s" -d "+ 10 seconds"` > /sys/class/rtc/rtc0/wakealarm
For more options, like waking up at a specific time, run:
and immediately suspend the machine
  # rtcwake --help
  # pm-suspend

Revision as of 14:43, 22 December 2022

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_THUD_V1.1_DART-6UL.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
DART-6UL - Real Time Clock (RTC)

Setting the RTC

Please note that starting from kernel 5.x the RTC node in the device tree must not include the IRQ pin declaration if it is not actually connected.
If a wrong declaration is present the hwclock command will fail.

First set the system date & time:

# date --set="20171231 23:59"

Then set the HW RTC using the system date & time:

# hwclock --systohc --utc

Power down your board, wait 5 minutes and power up again, then check you system date & time and verify it is correct:

# date

Wakeup using the RTC

All Variscite EVKs mount RTC ISL12057, however wakeup using the RTC requires hardware connection of ISL12057 IRQ2# pin to a SoC GPIO.
By default, the defconfig of latest kernels already enable the Intersil ISL12057 driver.
The kernel configuration item is available in Device Drivers -> Real Time Clock -> <*> Intersil ISL12057.

For DART-6UL on 6ULCustomBoard, RTC IRQ#2 pin is already connected to GPIO5_IO07, as declared in the file arch/arm/boot/dts/imx6ul-imx6ull-var-dart-6ulcustomboard.dtsi

rtc@0x68 {
	compatible = "dallas,ds1337";
	reg = <0x68>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_rtc>;
	interrupt-parent = <&gpio5>;
	interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
};

For VAR-SOM-6UL on ConcertoBoard, you can short pins J14.8 & J14.10 and edit arch/arm/boot/dts/imx6ul-imx6ull-var-som-concerto-board.dtsi to declare GPIO1_IO10 as IRQ#2 pin.

rtc@0x68 {
	compatible = "dallas,ds1337";
	reg = <0x68>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_rtc>;
	interrupt-parent = <&gpio1>;
	interrupts = <10 IRQ_TYPE_EDGE_FALLING>;
};

For VAR-SOM-6UL on SymphonyBoard, RTC IRQ#2 pin is not connected: RTC has no wakeup capabilities.

Using rtcwake command

Assuming the your board implement RTC wakeup capabilities, ensure RTC and system time are synchronized

# hwclock -w

then set the RTC to wakeup after 10 seconds type:

# echo enabled > /sys/class/rtc/rtc0/device/power/wakeup
# echo `date "+%s" -d "+ 10 seconds"` > /sys/class/rtc/rtc0/wakealarm

and immediately suspend the machine

# pm-suspend