【问题标题】:Device Tree bindings for additional pin in i2c nodei2c 节点中附加引脚的设备树绑定
【发布时间】:2018-12-29 20:40:57
【问题描述】:

我正在尝试将重置引脚添加到我一直在使用的 i2c 设备。似乎从属性获取的结果返回 null。是否有可能以这种方式处理 GPIO?

设备树定义看起来像 THI

&PICO_DWARF_I2C1 {
    status = "okay";

    goodix: gt811@38 {
        compatible = "goodix,gt811";

        interrupts = <GPIO_NO(PICO_EXT_GPIO_P44) 2>;

        reset-gpios = <GPIO_NO(PICO_EXT_GPIO_P32) GPIO_ACTIVE_LOW>; 

        touchscreen-size-x = <1024>;
        touchscreen-size-y = <600>;
    };




};

源看起来像这样。其他可以工作但被省略的组件,例如 reg info 等等。这是我正在努力解决的问题。

static int goodix_get_gpio_config(struct goodix_ts_data *ts)
{
    int error;
    struct device *dev;
    struct gpio_desc *gpiod;

    if (!ts->client)
        return -EINVAL;
    dev = &ts->client->dev;
    struct device_node *np = &dev->of_node;


    /* Get the interrupt GPIO pin number */
    gpiod = of_get_property(dev->of_node, "interrupts", NULL);
    if (IS_ERR(gpiod)) {
        error = PTR_ERR(gpiod);
        if (error != -EPROBE_DEFER)
            dev_dbg(dev, "Failed to get %s GPIO: %d\n",
                GOODIX_GPIO_INT_NAME, error);
        return error;
    }

    ts->int_pin = gpiod;

    /* Get the reset line GPIO pin number */
    gpiod = of_get_property(dev->of_node, "reset-gpios", NULL);
    if (IS_ERR(gpiod)) {
        error = PTR_ERR(gpiod);
        if (error != -EPROBE_DEFER)
            dev_dbg(dev, "Failed to get %s GPIO: %d\n",
                GOODIX_GPIO_RST_NAME, error);
        return error;
    }

    ts->reset_pin = gpiod;
return 0;
}

这是正确的方法还是我应该调用不同的函数?

【问题讨论】:

  • 这是对定义的引用。没错。

标签: linux linux-kernel linux-device-driver embedded-linux device-tree


【解决方案1】:

问题是在 reset-gpios 属性中不需要 GPIO_NO() 函数。一旦它被删除,属性就会加载。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多