简介
pinctrl子系统简介
demo
rg_otg_active: rg_otg_active{
mux {
pins = "gpio4";
function = "gpio";
};
config {
pins = "gpio4";
drive-strength = <2>;
bias-disable;
output-high;
};
};
rg_otg_sleep: rg_otg_sleep{
mux {
pins = "gpio4";
function = "gpio";
};
config {
pins = "gpio4";
drive-strength = <2>;
bias-disable;
output-low;
};
};
pinctrl-names = "rg_otg_active",
"rg_otg_sleep";
pinctrl-0 = <&rg_otg_active>;
pinctrl-1 = <&rg_otg_sleep>;
struct bq25890_device {
struct pinctrl *rg500_otg_pinctrl;
struct pinctrl_state *rg500_otg_state_high;
struct pinctrl_state *rg500_otg_state_low;
};
static int pin_parse_dt(struct bq25890_device *bq)
{
int rc;
/* rg otg pin */
bq->rg500_otg_pinctrl = devm_pinctrl_get(bq->dev);
if (IS_ERR(bq->rg500_otg_pinctrl)) {
pr_err("Couldn't get rg500_otg_pinctrl rc=%d\n", PTR_ERR(bq->rg500_otg_pinctrl));
bq->rg500_otg_pinctrl = NULL;
}
if (bq->rg500_otg_pinctrl) {
bq->rg500_otg_state_high = pinctrl_lookup_state(bq->rg500_otg_pinctrl,
"rg_otg_active");
if (IS_ERR(bq->rg500_otg_state_high)) {
rc = PTR_ERR(bq->rg500_otg_state_high);
pr_err("Couldn't get bq_otg state high rc=%d\n", rc);
return rc;
}
bq->rg500_otg_state_low = pinctrl_lookup_state(bq->rg500_otg_pinctrl,
"rg_otg_sleep");
if (IS_ERR(bq->rg500_otg_state_low)) {
rc = PTR_ERR(bq->rg500_otg_state_low);
pr_err("Couldn't get bq_otg state low rc=%d\n", rc);
return rc;
}
return 0;
}
pinctrl_select_state(bq->rg500_otg_pinctrl,bq->rg500_otg_state_high);
pinctrl_select_state(bq->rg500_otg_pinctrl,bq->rg500_otg_state_low);