drivers: pinctrl: rcar: Rework pin configuration
Rework pin configuration to meet documented procedures. 3 procedures are covered here: - GPIO -> Peripheral (+select peripheral function) - Peripheral -> GPIO - Change from Peripheral function 1 -> Peripheral function 2 Signed-off-by: Aymeric Aillet <aymeric.aillet@iot.bzh>
This commit is contained in:
parent
8c193743ac
commit
732f829f69
1 changed files with 15 additions and 7 deletions
|
@ -166,19 +166,27 @@ int pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
/* Some pins cannot be used as GPIO */
|
||||
/* Set pin as GPIO if capable */
|
||||
if (RCAR_IS_GP_PIN(pin->pin)) {
|
||||
pfc_rcar_set_gpsr(pin->pin, true);
|
||||
pfc_rcar_set_gpsr(pin->pin, false);
|
||||
} else if ((pin->flags & RCAR_PIN_FLAGS_FUNC_SET) == 0U) {
|
||||
/* A function must be set for non GPIO capable pin */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Select function for pin */
|
||||
if ((pin->flags & RCAR_PIN_FLAGS_FUNC_SET) != 0U) {
|
||||
pfc_rcar_set_ipsr(&pin->func);
|
||||
}
|
||||
|
||||
if ((pin->flags & RCAR_PIN_FLAGS_PULL_SET) != 0U) {
|
||||
ret = pfc_rcar_set_bias(pin->pin, pin->flags);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
if (RCAR_IS_GP_PIN(pin->pin)) {
|
||||
pfc_rcar_set_gpsr(pin->pin, true);
|
||||
}
|
||||
|
||||
if ((pin->flags & RCAR_PIN_FLAGS_PULL_SET) != 0U) {
|
||||
ret = pfc_rcar_set_bias(pin->pin, pin->flags);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue