Commit f6e545a73f8842400f76de4b185b31bea782ff85
1 parent
2489bb54a5
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
pfc: rmobile: Add hook to configure pin as GPIO
Add hook into the PFC driver to allow the GPIO driver to toggle GPSR registers into GPIO mode when GPIO is requested. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Showing 2 changed files with 30 additions and 0 deletions Side-by-side Diff
drivers/pinctrl/renesas/pfc.c
... | ... | @@ -448,6 +448,35 @@ |
448 | 448 | return priv->pfc.info->functions[selector].name; |
449 | 449 | } |
450 | 450 | |
451 | +int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector) | |
452 | +{ | |
453 | + struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev); | |
454 | + struct sh_pfc_pinctrl *pmx = &priv->pmx; | |
455 | + struct sh_pfc *pfc = &priv->pfc; | |
456 | + struct sh_pfc_pin_config *cfg; | |
457 | + const struct sh_pfc_pin *pin = NULL; | |
458 | + int i, idx; | |
459 | + | |
460 | + for (i = 1; i < pfc->info->nr_pins; i++) { | |
461 | + if (priv->pfc.info->pins[i].pin != pin_selector) | |
462 | + continue; | |
463 | + | |
464 | + pin = &priv->pfc.info->pins[i]; | |
465 | + break; | |
466 | + } | |
467 | + | |
468 | + if (!pin) | |
469 | + return -EINVAL; | |
470 | + | |
471 | + idx = sh_pfc_get_pin_index(pfc, pin->pin); | |
472 | + cfg = &pmx->configs[idx]; | |
473 | + | |
474 | + if (cfg->type != PINMUX_TYPE_NONE) | |
475 | + return -EBUSY; | |
476 | + | |
477 | + return sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_GPIO); | |
478 | +} | |
479 | + | |
451 | 480 | static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector, |
452 | 481 | unsigned func_selector) |
453 | 482 | { |
drivers/pinctrl/renesas/sh_pfc.h
... | ... | @@ -243,6 +243,7 @@ |
243 | 243 | const struct sh_pfc_bias_info * |
244 | 244 | sh_pfc_pin_to_bias_info(const struct sh_pfc_bias_info *info, |
245 | 245 | unsigned int num, unsigned int pin); |
246 | +int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector); | |
246 | 247 | |
247 | 248 | extern const struct sh_pfc_soc_info r8a7795_pinmux_info; |
248 | 249 | extern const struct sh_pfc_soc_info r8a7796_pinmux_info; |