gpio子系统
gpio子系统主要用于配置引脚申请释放,输入输出,默认状态,io中断等。
设备树分别定义了GPIO0_B3和GPIO4_D4两个GPIO引脚:
es8316: es8316@10 {
#sound-dai-cells = <0>;
compatible = "everest,es8316";
reg = <0x10>;
clocks = <&cru SCLK_I2S_8CH_OUT>;
clock-names = "mclk";
spk-con-gpio = <&gpio0 11 GPIO_ACTIVE_HIGH>;
hp-det-gpio = <&gpio4 28 GPIO_ACTIVE_LOW>;
};
驱动程序获取gpio:
es8316->spk_ctl_gpio = of_get_named_gpio_flags(np, "spk-con-gpio", 0, &flags);
//通过of_get_named_gpio_flags()函数获取GPIO0_B3引脚
ret = devm_gpio_request_one(&i2c->dev, es8316->spk_ctl_gpio, GPIOF_DIR_OUT, NULL);
//通过devm_gpio_request_one()函数申请该引脚并配置为输出
es8316->hp_det_gpio = of_get_named_gpio_flags(np, "hp-det-gpio", 0, &flags);
//通过o