]> git.sur5r.net Git - u-boot/commitdiff
pinctrl: rmobile: Add support for setting single pins
authorMarek Vasut <marek.vasut+renesas@gmail.com>
Sun, 26 Nov 2017 16:42:16 +0000 (17:42 +0100)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Thu, 30 Nov 2017 01:34:21 +0000 (02:34 +0100)
Add code to handle single pins nodes from DT in addition to already
support groups handling.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
drivers/pinctrl/renesas/pfc.c

index 1675485d6692e80b98b8df268df680bf38dc9f7d..b7b74985a34bd3b02dc63d7ab9b95db3f80298f7 100644 (file)
@@ -448,6 +448,22 @@ static const char *sh_pfc_pinctrl_get_function_name(struct udevice *dev,
        return priv->pfc.info->functions[selector].name;
 }
 
+static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector,
+                                 unsigned func_selector)
+{
+       struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
+       struct sh_pfc_pinctrl *pmx = &priv->pmx;
+       struct sh_pfc *pfc = &priv->pfc;
+       const struct sh_pfc_pin *pin = &priv->pfc.info->pins[pin_selector];
+       int idx = sh_pfc_get_pin_index(pfc, pin->pin);
+       struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
+
+       if (cfg->type != PINMUX_TYPE_NONE)
+               return -EBUSY;
+
+       return sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_FUNCTION);
+}
+
 static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector,
                                     unsigned func_selector)
 {
@@ -642,6 +658,19 @@ static int sh_pfc_pinconf_set(struct sh_pfc_pinctrl *pmx, unsigned _pin,
        return 0;
 }
 
+static int sh_pfc_pinconf_pin_set(struct udevice *dev,
+                                 unsigned int pin_selector,
+                                 unsigned int param, unsigned int arg)
+{
+       struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
+       struct sh_pfc_pinctrl *pmx = &priv->pmx;
+       struct sh_pfc *pfc = &priv->pfc;
+       const struct sh_pfc_pin *pin = &pfc->info->pins[pin_selector];
+
+       sh_pfc_pinconf_set(pmx, pin->pin, param, arg);
+
+       return 0;
+}
 
 static int sh_pfc_pinconf_group_set(struct udevice *dev,
                                      unsigned int group_selector,
@@ -671,8 +700,10 @@ static struct pinctrl_ops sh_pfc_pinctrl_ops = {
 #if CONFIG_IS_ENABLED(PINCONF)
        .pinconf_num_params     = ARRAY_SIZE(sh_pfc_pinconf_params),
        .pinconf_params         = sh_pfc_pinconf_params,
+       .pinconf_set            = sh_pfc_pinconf_pin_set,
        .pinconf_group_set      = sh_pfc_pinconf_group_set,
 #endif
+       .pinmux_set             = sh_pfc_pinctrl_pin_set,
        .pinmux_group_set       = sh_pfc_pinctrl_group_set,
        .set_state              = pinctrl_generic_set_state,
 };