Forum Discussion
Altera_Forum
Honored Contributor
12 years agoHello hippo,
Thank for replying to my post. I tried your solution but when my board is booting, the i2c-gpio driver reports an error about the i2crtc node as we can see below:
altera_gpio: /sopc@0/gpio@0x6002630: registered, irq -6
altera_gpio: /sopc@0/gpio@0x6002640: registered, irq -6
altera_gpio: /sopc@0/gpio@0x6002650: registered, irq -6
altera_gpio: /sopc@0/gpio@0x6002660: registered, irq -6
altera_gpio: /sopc@0/gpio@0x6002670: registered, irq -6
/sopc@0/i2crtc: invalid GPIO pins, sda=-22/scl=-22
JFFS2 version 2.2. © 2001-2006 Red Hat, Inc.
msgmni has been set to 25
io scheduler noop registered (default)
ttyAL0 at MMIO 0x6002540 (irq = 2) is a Altera UART
console enabled
I looked on the source code and I found that error -22 match the EINVAL errno value (invalid argument) in the i2c-gpio driver's probe function. Extract below:
/* Check if devicetree nodes exist and build platform data */
static int i2c_gpio_of_probe(struct platform_device *pdev,
struct i2c_gpio_platform_data *pdata)
{
struct device_node *np = pdev->dev.of_node;
const __be32 *prop;
int sda_pin, scl_pin;
int len;
if (!np || of_gpio_count(np) < 2)
return -ENXIO;
sda_pin = of_get_gpio_flags(np, 0, NULL);
scl_pin = of_get_gpio_flags(np, 1, NULL);
if (sda_pin < 0 || scl_pin < 0) {
pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n",
np->full_name, sda_pin, scl_pin);
return -ENXIO;
}
}
So I think, something goes wrong in my device tree. Here is what I did: -> in my device tree, I replaced the I2C_RTC node (described as a sub node of the sopc)
sopc@0 {
ranges;
# address-cells = < 1 >;
# size-cells = < 1 >;
device_type = "soc";
compatible = "ALTR,avalon", "simple-bus";
bus-frequency = < 50000000 >;
I2C_RTC: gpio@0x6002660 {
compatible = "i2c-gpio";
reg = < 0x06002660 0x00000010 >;
width = < 2 >; /* width type NUMBER */
resetvalue = < 0 >; /* resetValue type NUMBER */
}; //end gpio@0x6002660 (I2C_RTC)
}; //end sopc@0
by: (see bold text)
sopc@0 {
ranges;
# address-cells = < 1 >;
# size-cells = < 1 >;
device_type = "soc";
compatible = "ALTR,avalon", "simple-bus";
bus-frequency = < 50000000 >;
gpio_0: gpio@0x6002660 {
compatible = "ALTR,pio-10.0","ALTR,pio-1.0";
reg = < 0x6002660 0x00000010 >;
//bidir-width = <8>;
//input-width = <4>;
width = < 2 >;
resetvalue = < 0 >;
# gpio-cells = <2>;
gpio-controller;
}; //end gpio (gpio_0)
i2crtc {
# address-cells = <1>;
# size-cells = <0>;
compatible = "i2c-gpio";
gpios = < &gpio_0 100 0 /* SDA signal */
&gpio_0 99 0 >; /* SCL signal */
scl-is-output-only;
rtc@68 {
compatible = "m41t83"; /* as my rtc chip is an ST m41t83 */
reg = <0x68>;
};
}; //end i2crtc
}; //end sopc@0
Where am I going wrong?