GPIO配置,電平的上拉,下拉。輸入輸出配置:this
下面是某個平臺上的gpio的配置:spa
xx.c.net
*power management*/ int gf_power_on(struct gf_dev* gf_dev) { int rc = 0; if (gpio_is_valid(gf_dev->pwr_gpio)) { gpio_set_value(gf_dev->pwr_gpio, 1); } msleep(10); pr_info("---- power on ok ----\n"); return rc; } int gf_power_off(struct gf_dev* gf_dev) { int rc = 0; if (gpio_is_valid(gf_dev->pwr_gpio)) { gpio_set_value(gf_dev->pwr_gpio, 0); gpio_set_value(gf_dev->reset_gpio, 0); } pr_info("---- power off ----\n"); return rc; } /******************************************************************** *CPU output low level in RST pin to reset GF. This is the MUST action for GF. *Take care of this function. IO Pin driver strength / glitch and so on. ********************************************************************/ int gf_hw_reset(struct gf_dev *gf_dev, unsigned int delay_ms) { if(gf_dev == NULL) { pr_info("Input buff is NULL.\n"); return -1; } gpio_direction_output(gf_dev->reset_gpio, 0); //這裏注意一下gpio的方向(輸入或者輸出)
gpio_set_value(gf_dev->reset_gpio, 0); mdelay(3); gpio_set_value(gf_dev->reset_gpio, 1);//是拉高爲高電平(1),或者拉低爲低電平(0) mdelay(delay_ms); return 0; } int gf_irq_num(struct gf_dev *gf_dev) { if(gf_dev == NULL) { pr_info("Input buff is NULL.\n"); return -1; } else { return gpio_to_irq(gf_dev->irq_gpio); } }
DTSI的配置 xx.dtsicode
kernel/arch/arm64/boot/dts/qcom/sdm660-bbry-athena.dtsi &tlmm { goodix_pwr_active: goodix_pwr_active{ mux { pins = "gpio12"; function = "gpio"; }; config { pins = "gpio12"; drive-strength = <2>; bias-disable = <0>; output-high; }; }; goodix_reset_reset: goodix_reset_reset{ mux { pins = "gpio20"; function = "gpio"; }; config { pins = "gpio20"; drive-strength = <2>; bias-disable = <0>; output-low; }; }; goodix_reset_active: goodix_reset_active{ mux { pins = "gpio20"; function = "gpio"; }; config { pins = "gpio20"; drive-strength = <2>; bias-disable = <0>; output-high; }; }; goodix_irq_active: goodix_irq_active { mux { pins = "gpio72"; function = "gpio"; }; config { pins = "gpio72"; drive-strength = <2>; bias-disable = <0>; input-enable; }; }; }; &soc { goodix_gf5216{ status = "ok"; compatible = "goodix,fingerprint"; spi-max-frequency = <4800000>; reg = <0>; input-device-name = "gf5216"; interrupt-parent = <&tlmm>; interrupts = <72 0>; goodix,gpio_reset = <&tlmm 20 0x00>; goodix,gpio_irq = <&tlmm 72 0x00>; goodix,gpio_pwr = <&tlmm 12 0x00>; pinctrl-names = "goodixfp_pwr_active", "goodixfp_reset_reset", "goodixfp_reset_active", "goodixfp_irq_active"; pinctrl-0 = <&goodix_pwr_active>; pinctrl-1 = <&goodix_reset_reset>; pinctrl-2 = <&goodix_reset_active>; pinctrl-3 = <&goodix_irq_active>; }; };
擴展閱讀:blog
http://www.javashuo.com/article/p-mvlaonan-ez.htmlget
嵌入式中的BSP---BSP究竟是什麼?input
https://blog.csdn.net/qq_38500662/article/details/80965774it
BSP與HAL的關係io