Pergunta

I am writing a driver for a chip that mainly communicates via i2c, but also uses a GPIO pin to signal. The relevant device tree node looks like this:

&i2c1 {
status = "okay";
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;

my_dev: my_dev@0c {
    compatible = "my_dev,my_dev";
    reg = <0x0c>;
    irq_gpio = <&gpio0 14 0>; 
};
};

I want to be able to read the irq_gpio value from my driver, so I can request an irq(via gpio_to(irq()) and set things up. I found that I need to reach the of_node member of struct i2c_board_info. However, the probe function of the driver gets only i2c_client and i2c_device_id structs. How do I reach the desired of_node by starting from i2c_client or the device id?

Foi útil?

Solução

Found the solution. Not only i2c_board_info has an of_node, but struct device as well. So the device node can be accessed via client->dev.of_node.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top