Accessing RTC I2C chip connecting to FPGA through GPIO

772 views Asked by At

I need to get data from a RTC device (stm41t83) through I2C. The device is directly connected to two pins of a GPIO. I tried to use the i2c-gpio driver with the piece of code below,

#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c-gpio.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>

#define GPIO_RTC_SDA        100
#define GPIO_RTC_SCL        99


MODULE_DESCRIPTION("i2c via gpio module");
MODULE_LICENSE("GPL");

static struct i2c_gpio_platform_data rtc_device_data = {
    .sda_pin = GPIO_RTC_SDA,
    .scl_pin = GPIO_RTC_SCL,
    .udelay  = 25
};

static struct platform_device i2c_gpio_bus_rtc = {
    .name   = "i2c-gpio",
    .id     = 0,
    .dev    = {
        .platform_data = &rtc_device_data,
    }
};

static int __init i2c_gpio_bus_init(void)
{
    return platform_device_register(&i2c_gpio_bus_rtc);
}

static void __exit i2c_gpio_bus_exit(void)
{
    platform_device_unregister(&i2c_gpio_bus_rtc);
}

module_init(i2c_gpio_bus_init);
module_exit(i2c_gpio_bus_exit);

but when I use the i2cdetect utility from the i2c tools package, I can't see my RTC device located at 0x68. Do I need to add some other stuff to get it working?

Thanks for answers!

jrm

1

There are 1 answers

0
jrm On BEST ANSWER

I finally solved my problem! I was not a software problem but rather a FPGA configuration issue. Follow this link, post #13 to know the answer.

Thanks to all ;-)