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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
> +	}
> +}




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux