0

I am trying to use a driver with a gpio interrupt on BeagleboneBlack. My device tree has the following entry for my custom device:

&i2c1{...

mydevice: mydevice@0c {
    compatible = "mydevice,mydeice";
    reg = <0x0c>;
    mag_irq_gpio = <&gpio1 13 0>; /* INT line */ 
};
...}

Its driver counterpart has this:

static int parse_dt(struct i2c_client *client)
{
    struct device_node *node = client->dev.of_node;
    struct mydev_data *data = i2c_get_clientdata(client);

    return of_property_read_u32(node, "mag_irq_gpio", &data->gpio);
} 

The driver loads and works fine, except the gpio number is completely wrong. The property read function returns success, and reads 8 as the gpio number, even if I put a different number to the device tree.

How am I supposed to pass a gpio number as generic data? The interrupt works if I manually override the gpio number inside my driver.

Atilla Filiz
  • 2,383
  • 8
  • 29
  • 47
  • 1
    You have defined the entry `mag_irq_gpio` as a vector of three numbers. The numbers appear to represent (1) the (address of the second?) PIO controller, `gpio1`, (2) the _relative_ pin number, `13`, and (3) pin options (`0` for presumably none specified). When the driver retrieves this entry, it should fetch all three values, not just one. Your driver may have to convert the controller number and relative pin number into an "absolute" pin number. – sawdust Apr 29 '14 at 20:26

1 Answers1

1

As per comment by @sawdust

<&gpio1 13 0>

denotes an array of three values. I solved the issue by manually calculating the GPIO number and passing it as a single number:

<14>
Atilla Filiz
  • 2,383
  • 8
  • 29
  • 47
  • whats the default state you put for this? Low? – Raulp Aug 18 '16 at 10:46
  • I did the actual initialization in my driver, and it is an input. – Atilla Filiz Aug 18 '16 at 14:04
  • can you please paste the code for the same?How did you retrieve the GPIO.Also suppose if that gpio is used by some other driver will you get a failure = -ENOENT or something ! – Raulp Aug 19 '16 at 03:52
  • This was a while ago and I don't work there anymore, so I can't find the code. Basically when I tried to get the GPIO number, I was getting it wrong (because I was just reading the GPIO base address, not the correct register at all.) The code to retrieve is in my question already, the parse_dt function. – Atilla Filiz Aug 19 '16 at 16:34