0
votes

I'm trying to interface a GPIO controller in a kernel driver and I'm not sure if I'm doing everything right.

This is my device tree code:

gpio_screen1:gpio1@20 {
            compatible = "nxp,pca9535";
            gpio-controller;
            #gpio-cells = <2>;
            reg = <0x20>;
//          pinctrl-names = "default";
//          pinctrl-0 = <&pinctrl_pca9505>;
            };

    screen: screen@0x02000 {
        compatible = "myscreen,myscreen";
        #address-cells = <1>;
        #size-cells = <0>;
        reg = < 0x04000 0xF00 >;                    
        interrupts = <1 2>;
        reset-gpios     = <&gpio_screen1 15 0>;
        sleep-gpios     = <&gpio_screen1 14 0>;
        clk_sel1-gpios  = <&gpio_screen1 10 0>;
        lane_sel-gpios  = <&gpio_screen1 9 0>;
    };

And this is my driver code that registers the GPIO

gpio = of_get_named_gpio(pdev->dev.of_node, "reset-gpios", 0);
if (!gpio_is_valid(gpio)) {
        dev_err(&pdev->dev, "failed to parse reset gpio\n");
        return gpio;
}
dev->reset = gpio;

Is this initialization correct?

I've been looking at the Documentation for this GPIO controller but it's not very helpful.

1

1 Answers

0
votes

I don't see anything wrong with gpio initialization from driver side. It's quite simple. Next step is request initialized gpio:

ret = devm_gpio_request_one(&pdev->dev, dev->reset, GPIOF_OUT_INIT_HIGH, "gpio-reset");
if (ret) {
    dev_err(&pdev->dev, "failed to request gpio %d: %d\n", dev->reset, ret);
    return -EINVAL;
}

With regard devicetree part here, as I understand, you did based on gpio-pcf857x.txt or something like that. Don't you use interrupt on these gpios?

And main question, does it work? ;)