BeagleBone - registering DS1307 RTC with kernel at boot up


Beginner question; I have a working ds1307 that I can talk to with

echo ds3232 0x68 >/sys/bus/i2c/devices/i2c-3/new_device

from there I can do wonderful things such as

hwclock -f /dev/rtc1 -s

As a beginner I’m tempted to quit while I’m ahead and script these at start up. However, I’d like to try and register these with the kernel ‘properly’.

I believe I need to add the device to arch/arm/mach-omap2/board-omap3beagle.c - is this correct?

and, if so according to then I guess I need to write in something like this, that was already in there?
(presumably I can’t just add my ds1307 into this structure - because it’s probably on another bus??)

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

and I should add something in somewhere in static void __init omap3_beagle_init(void) ?

Although, in here I see omap3_beagle_i2c_init();

so should I add something in static int __init omap3_beagle_i2c_init(void) instead?

What I type is the next question… my first guess for adding some i2c_board_info would be;


static struct i2c_board_info __initdata rtc_i2c_device[] = {
{ /* DS1307 RTC on i2c2 */
I2C_BOARD_INFO(“ds1307”, 0x68),
.type = “ds1339”,


(i just copied there)

I’m not confident about the call to i2c_register_board_info…

do i just add

i2c_register_board_info(2, rtc_i2c_device, ARRAY_SIZE(rtc_i2c_device));

to omap3_beagle_i2c_init()

As you can probably tell, I’ve not done this before. I’ve tried to help myself as much as I can, but i’m getting diminishing returns from the worlds favorite search engine now. Am I very far off the mark?



isn't there a specific board-file for the Bone? I see you use the
board-file for the Beagleboard while they have absolutely different

Here is what I did for making a DS1307 like device – rtc-beada built into Pandaboard kernel:

  1. Board file board-omap4panda.c


  • BeadaFrame RTC is connected as I2C slave device, and can be accessed at address 0x51
    static struct i2c_board_info __initdata panda_i2c_beada_rtc[] = {
    I2C_BOARD_INFO(“rtc-beada”, 0x51),
    I2C_BOARD_INFO(“tsc-beada”, 0x52),
    I2C_BOARD_INFO(“pwm-beada”, 0x53),

static int __init omap4_panda_i2c_init(void)
omap4_pmic_get_config(&omap4_panda_twldata, TWL_COMMON_PDATA_USB,
omap4_pmic_init(“twl6030”, &omap4_panda_twldata);
omap_register_i2c_bus(2, 100, panda_i2c_beada_rtc, ARRAY_SIZE(panda_i2c_beada_rtc));

  • Bus 3 is attached to the DVI port where devices like the pico DLP
  • projector don’t work reliably with 400kHz
    omap_register_i2c_bus(3, 100, panda_i2c_eeprom,
    omap_register_i2c_bus(4, 400, NULL, 0);
    return 0;
  1. .config file


EDIT: Of course, with a DS1307 just use “ds1307” instead. ← pre-coffee

Thanks everyone - that’s all really helpful. I’ll give myself a few marks for effort!

I thought I probably had the wrong board file, hence the question.

Thanks for the CONFIG hints too. I’m using ubuntu precise armhf 12.04… and looking at the config I had, it looked like most of it was there - but it looks like the rtc0/rtc1 business would have tripped me up.

I’ll let you now how I get on, post-coffee.