gpio_subsystem

linux kernel gpio驱动的编写,可以分为四步:

the integer-based GPIO interface – legacy

  1. 配置设备树dts gpio属性

  2. 从设备树dts获得gpio

  3. 设置/获得gpio电平

the descriptor-based GPIO interface - recommended way

  1. 配置设备树dts gpio属性

  2. 从设备树dts获得gpio

  3. 设置/获得gpio电平

  4. 释放gpio

the integer-based GPIO interface – legacy

1. 配置设备树dts gpio属性

xxx {
    compatible = "xxx,xxx";

    xxx-gpios = <&gpio1 3 GPIO_ACTIVE_LOW>; // 低电平有效
    state = "okay";
};

2. 从设备树dts获得gpio

3. 设置/获得gpio电平

1. 配置设备树dts gpio属性

2. 从设备树dts获得gpio

3. 设置/获得gpio电平

4. 释放gpio

Last updated

Was this helpful?