SPI DTSI

GPIO配置,电平的上拉,下拉。输入输出配置:

下面是某个平台上的gpio的配置:

xx.c

*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.dtsi

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>;
  };
};

 扩展阅读:

https://blog.csdn.net/ibelieve1974/article/details/72235579

嵌入式中的BSP---BSP到底是什么?

https://blog.csdn.net/qq_38500662/article/details/80965774

BSP与HAL的关系

posted @ 2019-04-18 17:39  代码海洋中的一条鱼  阅读(765)  评论(0编辑  收藏  举报