You are here

Enabling RTC and other I2C peripherals

1 post / 0 new
N7BTW
Enabling RTC and other I2C peripherals
I've contributed some patches over time to enable support for a DS3231 I2C RTC at least on the GL-AR750. Commonly available boards also include an AT24C32 EEPROM. I've successfully tested all that and got it working, but I just realized I never actually finished the project. Specifically, to enable any I2C devices, I need to inform the I2C bus driver that it exists.

In the case of the commonly-available DS3231/AT24C32 board, one must issue these commands to enable both devices:
echo ds3231 0x68 > /sys/devices/platform/i2c/i2c-0/new_device
echo 24c32  0x57 > /sys/devices/platform/i2c/i2c-0/new_device
A quick check of dmesg afterward will show the devices actually registered, e.g.:
[ 2324.473559] rtc-ds1307 0-0068: registered as rtc0
[ 2324.479576] rtc-ds1307 0-0068: setting system clock to 2025-02-13T23:39:37 UTC (1739489977)
[ 2324.489354] i2c i2c-0: new_device: Instantiated device ds3231 at 0x68
[ 2338.495985] at24 0-0057: supply vcc not found, using dummy regulator
[ 2338.503692] at24 0-0057: 4096 byte 24c32 EEPROM, writable, 1 bytes/write
[ 2338.510730] i2c i2c-0: new_device: Instantiated device 24c32 at 0x57
I had put those commands in /etc/rc.local, but now I realize that's not persistent across firmware upgrades :D

What's the right place to put these commands? I can't really justify patching them into the firmware itself because we don't *know* that these devices will exist on a particular user's device, and at the given I2C addresses.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer