Disable some I2C port at boot time??

Hi All,

  I have a question about I2C ports on a Beagleboard XM.

  I have successfully link a Sparkfun Real Time Clock (I2C-RTC) to port
I2C-2 on the BB via a 1.8V to 5.0V level shifter. The I2C-RTC uses I2C
address 0x68.

I have written a program that reads the data from the RTC which I
intend to use to set the system date/time when the BB is not connected
to the Internet.

  My program open the I2C port with:

    fd = Open(“/dev/i2c-2”, O_RDWD);

  I then use:

    rc = ioctl(fd, I2C_SLAVE, addr); where addr is 0x68 in this case

  This all worked fine when I first tried it, but when I rebooted the
BB and tried running my program again I received an EBUSY error from
the ioctl command. Using the i2cdetect –r 2 command I noticed that
port I2C-2 had a UU in the 0x68 position. I later found that this
means that the system kernel has detected the device and taken control
of it.

  Is there a way of preventing the system taking control of this port
during boot up so I can access it in UserSpace or should I be doing
this a different way altogether?

  Ernie

You shouldn’t disable it, just make your life easier and use the kernel module that already supports it. Some quick googling turns up for example: http://linux.die.net/man/4/rtc. Actually, the kernel already does what you want for you. From the aforementioned web page: “At boot time the kernel initializes its software clock by reading the RTC.”

Hi Connor,

         Thanks for your reply.

     I thought it kernel may be setting the time from the RTC, but I
test this.

     When I boot the system with the RTC connect but no connection to
the Internat the system time default to the date the system was built.

     Connecting it to the Internet and rebooting the time was set
correctly.

     So it does not look like it's picking up the time from the RTC.

     What logs could I look at to get any debug information.

        Ernie

Hi Connor,

          Thanks for your reply.

      I thought it kernel may be setting the time from the RTC, but I
test this.

      When I boot the system with the RTC connect but no connection to
the Internat the system time default to the date the system was built.

      Connecting it to the Internet and rebooting the time was set
correctly.

      So it does not look like it's picking up the time from the RTC.

      What logs could I look at to get any debug information.

More likely, the Linux kernel *is* getting the time from the RTC, but your
boot environment (Angstrom?) is not using it and setting the time itself.

Look for a message like this in your boot log:
   twl_rtc twl_rtc: setting system clock to 2011-10-08 23:35:08 UTC (1318116908)

Hi Gary,

  Thanks I'll have a look at the log when I go home toningt.

       Ernie

Gary,

   I rebooted the system without the network connected but with the
RTC connect.

   When the system is up and running the system time show the date &
time that the system was built.

   I checked the system log and this is what I found.

[ 9.323760] input: gpio-keys as /devices/platform/gpio-keys/input/
input1
[ 9.762939] twl_rtc twl_rtc: rtc core: registered twl_rtc as rtc0
[ 9.811584] rtc-ds1307 2-0068: rtc core: registered ds1307 as rtc1
[ 9.811614] rtc-ds1307 2-0068: 56 bytes nvram
[ 11.616058] smsc95xx v1.0.4

       Could you suggest what the problem is.

          Ernie