This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x RTC DS3231 initialization

Hi, 

I am using:

  • Beaglebone white
  • Ezlinux sdk: root@user-virtual-machine:/home/user/ti-sdk-am335x-evm-07.00.00.00/board-support/linux-3.12.10-ti2013.12.01#
  • and DS3231 Real Time Clock breakboard from Adafruit

Until now, I was able to detect the DS3231 at the I2C bus:

root@Teste01:~# i2cdetect -y -r 1


0    1 2  3 4  5  6  7  8  9  a  b  c  d  e  f
00:            -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I have enabled the DS3232 driver at menuconfig.

I have added the following code at am335x-bone-common.dtsi:

i2c1_pins: pinmux_i2c1_pins {
			pinctrl-single,pins = <
				0x158 (PIN_INPUT_PULLUP | MUX_MODE2)	/* spi0_d1.i2c1_sda */
				0x15c (PIN_INPUT_PULLUP | MUX_MODE2)	/* spi0_cs0.i2c1_scl */
			>;
		};

and

i2c1: i2c@4802a000 {
			pinctrl-names = "default";
			pinctrl-0 = <&i2c1_pins>;
			status = "okay";
			clock-frequency = <400000>;

			/* Set OPP50 (0.95V) for VDD core */
			sleep-sequence = /bits/ 8 <
				0x02 0x24 0x0b 0x6d /* Password unlock 1 */
				0x02 0x24 0x10 0x02 /* Set DCDC3 to 0.95V */
				0x02 0x24 0x0b 0x6d /* Password unlock 2 */
				0x02 0x24 0x10 0x02 /* Set DCDC3 to 0.95V */
				0x02 0x24 0x0b 0x6c /* Password unlock 1 */
				0x02 0x24 0x11 0x86 /* Apply DCDC changes */
				0x02 0x24 0x0b 0x6c /* Password unlock 2 */
				0x02 0x24 0x11 0x86 /* Apply DCDC changes */
			>;

			/* Set OPP100 (1.10V) for VDD core */
			wake-sequence = /bits/ 8 <
				0x02 0x24 0x0b 0x6d /* Password unlock 1 */
				0x02 0x24 0x10 0x08 /* Set DCDC3 to 1.1V */
				0x02 0x24 0x0b 0x6d /* Password unlock 2 */
				0x02 0x24 0x10 0x08 /* Set DCDC3 to 1.1V */
				0x02 0x24 0x0b 0x6c /* Password unlock 1 */
				0x02 0x24 0x11 0x86 /* Apply DCDC changes */
				0x02 0x24 0x0b 0x6c /* Password unlock 2 */
				0x02 0x24 0x11 0x86 /* Apply DCDC changes */
			>;

			DS3232: DS3232@68 {
				compatible = "Dallas/Maxim,DS3232";
				reg = <0x68>;
			};

		};

And I have added the following highlighted code at board-omap3beagle.c (I have not found board-am335xevm.c as advised in other posts):

static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
       {
               I2C_BOARD_INFO("eeprom", 0x50),
       },
       {
               I2C_BOARD_INFO("ds3231", 0x68),
       },
};

So I try to instantiate and I get an error:

root@PRC4-01:~# echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
-sh: echo: write error: Invalid argument

What am I doing wrong? Do I have to add something more at the device tree to get DS3232 driver working and linked to the i2c-1? 

Thanks in advance and best regards!

  • I will forward this to the software team.
  • Hi,

    There is no need to modify the board file ( board-omap3beagle.c  or  board-am335xevm.c) it is replaced by the .dts in kernel 3.12.  Your DTS file seems correct. Maybe change:

      DS3232: DS3232@68 {

                   compatible = "Dallas/Maxim,DS3232";

                   reg = <0x68>;

               };

    to

     ds3232: ds3232@68 {

                   compatible = "ds3232";

                   reg = <0x68>;

               };

    Make sure to add CONFIG_RTC_DRV_DS3232=y in arch/arm/configs/tisdk_am335x-evm_defconfig.

    Best Regards,

    Yordan

  • Thanks for your answer, Yordan!

    I have made the two modifications you suggested, but  I still get the error:

    root@PRC4-01:~# echo ds3232 0x68 > /sys/bus/i2c/devices/i2c-1/new_device
    -sh: echo: write error: Invalid argument
    root@PRC4-01:~# echo ds3232 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
    -sh: echo: write error: Invalid argument

    Do you have more advices?

    Best regards!

  • Hi,

    Does i2cdetect sees the RTC on address 68h?

    Best Regards,
    Yordan
  • Yes , it does:

    root@Teste-01:~# i2cdetect -y -r 1
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

    Thanks!
  • Hi, 

    Even seeing the device with the i2cdetec as in the last post, I am getting the following messages during the boot process:

    [    0.273517] omap_i2c 44e0b000.i2c: could not find pctldev for node /pinmux@44e10800/pinmux_i2c0_pins, deferring probe

    [    0.273548] platform 44e0b000.i2c: Driver omap_i2c requests probe deferral

    [    0.273575] omap_i2c 4802a000.i2c: could not find pctldev for node /pinmux@44e10800/pinmux_i2c1_pins, deferring probe

    [    0.273591] platform 4802a000.i2c: Driver omap_i2c requests probe deferral

    [    1.493869] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz

    [    1.502761] rtc-ds3232 1-0068: rtc core: registered ds3232 as rtc1

    [    1.509401] rtc-ds3232 1-0068: unable to request IRQ

    [    1.514954] rtc-ds3232: probe of 1-0068 failed with error -22

    [    1.521142] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 400 kHz

     

    Do you know what is wrong? Do I have to enable or disable some more options?

    Best Regards!

     

  • Hi,

    I gave up using DS3232 driver and tried DS1307 driver.

    Now, RTC1 is created and it is associated to the DS3231.

    The RTC is working!
  • Thanks for updating the thread.

    Best Regards,
    Yordan