Re: [PATCH v3 13/16] pinctrl: Add AXP192 pin control driver

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

 



Michael Walle <michael@xxxxxxxx> writes:

> Hi,
>
> As Linus suggested you could have a look at devm_gpio_regmap_register()
> with a custom xlate() callback and some improvements. But I've never
> worked with pinctrl so I might be wrong. See below.
>
>> +static int axp192_gpio_get(struct gpio_chip *chip, unsigned int offset)
>> +{
>> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
>> +	const struct axp192_pctl_reg_info *reginfo = &pctl->desc->in_regs[offset];
>> +	unsigned int val;
>> +	int ret;
>> +
>> +	ret = regmap_read(pctl->regmap, reginfo->reg, &val);
>> +	if (ret)
>> +		return ret;
>> +
>> +	return !!(val & reginfo->mask);
>> +}
>
> This should work.
>
>> +
>> +static int axp192_gpio_get_direction(struct gpio_chip *chip, unsigned
>> int offset)
>> +{
>> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
>> +	const struct axp192_pctl_reg_info *reginfo =
>> &pctl->desc->ctrl_regs[offset];
>> +	const u8 *input_muxvals = pctl->desc->functions[AXP192_FUNC_INPUT].muxvals;
>> +	unsigned int val;
>> +	int ret;
>> +
>> +	ret = regmap_read(pctl->regmap, reginfo->reg, &val);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if ((val & reginfo->mask) == (input_muxvals[offset] <<
>> (ffs(reginfo->mask) - 1)))
>> +		return GPIO_LINE_DIRECTION_IN;
>
> This isn't supported (yet) in gpio-regmap...
>
>> +
>> +	return GPIO_LINE_DIRECTION_OUT;
>> +}
>> +
>> +static void axp192_gpio_set(struct gpio_chip *chip, unsigned int
>> offset, int value)
>> +{
>> +	struct axp192_pctl *pctl = gpiochip_get_data(chip);
>> +	const struct axp192_pctl_reg_info *reginfo = &pctl->desc->out_regs[offset];
>> +
>> +	regmap_update_bits(pctl->regmap, reginfo->reg, reginfo->mask, value
>> ? reginfo->mask : 0);
>> +}
>> +
>> +static int axp192_gpio_direction_input(struct gpio_chip *chip,
>> unsigned int offset)
>> +{
>> +	return pinctrl_gpio_direction_input(chip->base + offset);
>> +}
>
> ..as well as this.
>
>> +
>> +static int axp192_gpio_direction_output(struct gpio_chip *chip,
>> unsigned int offset, int value)
>> +{
>> +	chip->set(chip, offset, value);
>
> Why don't you call pinctrl_gpio_direction_output() here?

Probably because I copied this from pinctrl-axp209. I'll fix it in
the next version.

>
>
> I *think* what is needed for gpio-regmap to support this is:
>  - support values and masks for the direction, for now, we
>    only support single bits.
>  - support the pinctrl_gpio_direction_{input,output} calls
>
> -michael

That sounds about right, thanks for taking a look.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux