高通GPIO配置方式

From 8916 , GPIO configurations start using pinctrl framework  .The pin control-based software model differs in the following ways. 

1.  All pin configuration information  is defined in a SoC-specific file,<soc>-pinctrl.dtsi. This file will contain the pin groupings as well as the configurations and functions to be applied to them. 
2.  Individual client device tree nodes will reference the configuration nodes defined in  <soc>-pinctrl.dtsi. This will comprise the state of the pins. A client can have any number of configuration nodes in a state, and a client can have any number of states.
3.  This state information will be parsed with a call to devm_pinctrl_get();
4.  A client can subsequently choose to install a given state by using pinctrl_lookup_state() and pinctrl_select_state(). 
Here are example for configurations gpio107

In msm8916-pinctrl.dtsi
        tlmm_gpio_key {
            qcom,pins = <&gp 107>;
....
            gpio_key_active: gpio_key_active {
                drive-strength = <2>;
                bias-pull-up;
                output-high;
            };
            gpio_key_suspend: gpio_key_suspend {
                drive-strength = <2>;
                bias-pull-up;
                output-low
            };
        };
In msm8916-mtp.dtsi
    gpio_keys {
......
        pinctrl-names = "tlmm_gpio_key_active","tlmm_gpio_key_suspend";
        pinctrl-0 = <&gpio_key_active>;
        pinctrl-1 = <&gpio_key_suspend>;
    
in your client driver, which using the gpio107 ,
1.       key_pinctrl = devm_pinctrl_get(dev);
2.       set_state =pinctrl_lookup_state(key_pinctrl,"tlmm_gpio_key_active");
or
set_state =pinctrl_lookup_state(key_pinctrl,"tlmm_gpio_key_suspend");                           
3.    retval = pinctrl_select_state(key_pinctrl, set_state);
if you want to add more state for gpio , then you can add as following :
1.       add new configurations in msm8916-pinctrl.dtsi
        tlmm_gpio_key {
….
           gpio_key_default: gpio_key_default {
                drive-strength = <8>;
                bias-disable;
            };
        };
2.       add setting in msm8916-mtp.dtsi
    gpio_keys {
    pinctrl-names =  "tlmm_gpio_key_active","tlmm_gpio_key_suspend,”tlmm_gpio_key_default”;
......
    pinctrl-2 = <&gpio_key_default>;
3.    using new configurations:
      set_state =pinctrl_lookup_state(key_pinctrl,"tlmm_gpio_key_default");
      retval = pinctrl_select_state(key_pinctrl, set_state)In msm8916-pinctrl.dtsi
        tlmm_gpio_key {
            qcom,pins = <&gp 107>;
....
            gpio_key_active: gpio_key_active {
                drive-strength = <2>;
                bias-pull-up;
                output-high;
            };
            gpio_key_suspend: gpio_key_suspend {
                drive-strength = <2>;
                bias-pull-up;
                output-low
            };
        }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值