高通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,-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  -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
            };
        }

 

 

你可能感兴趣的:(自我总结经验)