RE: [RESEND PATCH v3 3/3] pinctrl: da9062: add driver support

From: Adam Thomson
Date: Thu Dec 12 2019 - 11:48:35 EST


On 12 December 2019 16:04, Marco Felsch wrote:

> +static int da9062_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
> + unsigned long config)
> +{
> + struct da9062_pctl *pctl = gpiochip_get_data(gc);
> + struct regmap *regmap = pctl->da9062->regmap;
> + int gpio_mode;
> +
> + /*
> + * We need to meet the following restrictions [1, Figure 18]:
> + * - PIN_CONFIG_BIAS_PULL_DOWN -> only allowed if the pin is used as
> + * gpio input
> + * - PIN_CONFIG_BIAS_PULL_UP -> only allowed if the pin is used as
> + * gpio output open-drain.
> + */
> +
> + switch (pinconf_to_config_param(config)) {
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + gpio_mode = da9062_pctl_get_pin_mode(pctl, offset);
> + if (gpio_mode < 0)
> + return -EINVAL;
> + else if (gpio_mode != DA9062_PIN_GPI)
> + return -ENOTSUPP;
> + return regmap_update_bits(regmap, DA9062AA_CONFIG_K,
> + BIT(offset), BIT(offset));
> + case PIN_CONFIG_BIAS_PULL_UP:
> + gpio_mode = da9062_pctl_get_pin_mode(pctl, offset);
> + if (gpio_mode < 0)
> + return -EINVAL;
> + else if (gpio_mode != DA9062_PIN_GPO_OD)
> + return -ENOTSUPP;
> + return regmap_update_bits(regmap, DA9062AA_CONFIG_K,
> + BIT(offset), BIT(offset));

Apologies for the delay on reviewing. Just looking at the datasheet, how do we
disable PULL_DOWN (for input) and PULL_UP (for output)? Should we not have a
'PIN_CONFIG_BIAS_DISABLE' case here to handle this?

> + case PIN_CONFIG_DRIVE_OPEN_DRAIN:
> + return da9062_pctl_set_pin_mode(pctl, offset,
> + DA9062_PIN_GPO_OD);
> + case PIN_CONFIG_DRIVE_PUSH_PULL:
> + return da9062_pctl_set_pin_mode(pctl, offset,
> + DA9062_PIN_GPO_PP);
> + default:
> + return -ENOTSUPP;
> + }
> +}