[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <me4ummrWKIPseIG4ay7yCfrumN8sIdvc@localhost>
Date: Mon, 27 Jun 2022 14:12:58 +0100
From: Aidan MacDonald <aidanmacdonald.0x0@...il.com>
To: Michael Walle <michael@...le.cc>
Cc: linus.walleij@...aro.org, brgl@...ev.pl, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, wens@...e.org, jic23@...nel.org,
lee.jones@...aro.org, sre@...nel.org, broonie@...nel.org,
gregkh@...uxfoundation.org, lgirdwood@...il.com, lars@...afoo.de,
rafael@...nel.org, quic_gurus@...cinc.com,
sebastian.reichel@...labora.com, andy.shevchenko@...il.com,
linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: Re: [PATCH v3 13/16] pinctrl: Add AXP192 pin control driver
Michael Walle <michael@...le.cc> 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.
Powered by blists - more mailing lists