From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: linux-gpio <linux-gpio@vger.kernel.org>,
linux-devicetree <devicetree@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Lee Jones <lee.jones@linaro.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v3 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs
Date: Thu, 3 Oct 2019 07:26:56 -0400 [thread overview]
Message-ID: <20191003112656.GB28856@aptenodytes> (raw)
In-Reply-To: <CAMpxmJWQ9iuNj8Nfhf0hVzP6piNPrb8_e7ucth0rmg8KwT4HdA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4298 bytes --]
Hi and thanks for the review!
On Thu 03 Oct 19, 10:26, Bartosz Golaszewski wrote:
> Hi Paul,
>
> just two nits:
>
> pt., 27 wrz 2019 o 12:04 Paul Kocialkowski
> <paul.kocialkowski@bootlin.com> napisał(a):
> >
> > The LogiCVC display hardware block comes with GPIO capabilities
> > that must be exposed separately from the main driver (as GPIOs) for
> > use with regulators and panels. A syscon is used to share the same
> > regmap across the two drivers.
> >
> > Since the GPIO capabilities are pretty simple, add them to the syscon
> > GPIO driver.
> >
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> > drivers/gpio/gpio-syscon.c | 68 ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 68 insertions(+)
> >
> > diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
> > index 05c537ed73f1..cdcb913b8f0c 100644
> > --- a/drivers/gpio/gpio-syscon.c
> > +++ b/drivers/gpio/gpio-syscon.c
> > @@ -190,6 +190,70 @@ static const struct syscon_gpio_data keystone_dsp_gpio = {
> > .set = keystone_gpio_set,
> > };
> >
> > +#define LOGICVC_CTRL_REG 0x40
> > +#define LOGICVC_CTRL_GPIO_SHIFT 11
> > +#define LOGICVC_CTRL_GPIO_BITS 5
> > +
> > +#define LOGICVC_POWER_CTRL_REG 0x78
> > +#define LOGICVC_POWER_CTRL_GPIO_SHIFT 0
> > +#define LOGICVC_POWER_CTRL_GPIO_BITS 4
> > +
> > +static void logicvc_gpio_offset(struct syscon_gpio_priv *priv,
> > + unsigned offset, unsigned int *reg,
> > + unsigned int *bit)
> > +{
> > + if (offset >= LOGICVC_CTRL_GPIO_BITS) {
> > + *reg = LOGICVC_POWER_CTRL_REG;
> > +
> > + /* To the (virtual) power ctrl offset. */
> > + offset -= LOGICVC_CTRL_GPIO_BITS;
> > + /* To the actual bit offset in reg. */
> > + offset += LOGICVC_POWER_CTRL_GPIO_SHIFT;
> > + } else {
> > + *reg = LOGICVC_CTRL_REG;
> > +
> > + /* To the actual bit offset in reg. */
> > + offset += LOGICVC_CTRL_GPIO_SHIFT;
> > + }
> > +
> > + *bit = BIT(offset);
> > +}
> > +
> > +static int logicvc_gpio_get(struct gpio_chip *chip, unsigned offset)
> > +{
> > + struct syscon_gpio_priv *priv = gpiochip_get_data(chip);
> > + unsigned int reg;
> > + unsigned int bit;
> > + unsigned int value;
>
> Can you put these on a single line?
Sure thing.
> > + int ret;
> > +
> > + logicvc_gpio_offset(priv, offset, ®, &bit);
> > +
> > + ret = regmap_read(priv->syscon, reg, &value);
> > + if (ret)
> > + return ret;
> > +
> > + return !!(value & bit);
> > +}
> > +
> > +static void logicvc_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
> > +{
> > + struct syscon_gpio_priv *priv = gpiochip_get_data(chip);
> > + unsigned int reg;
> > + unsigned int bit;
>
> Same here.
Will do!
Cheers,
Paul
> > +
> > + logicvc_gpio_offset(priv, offset, ®, &bit);
> > +
> > + regmap_update_bits(priv->syscon, reg, bit, val ? bit : 0);
> > +}
> > +
> > +static const struct syscon_gpio_data logicvc_gpio = {
> > + .flags = GPIO_SYSCON_FEAT_OUT,
> > + .bit_count = LOGICVC_CTRL_GPIO_BITS + LOGICVC_POWER_CTRL_GPIO_BITS,
> > + .get = logicvc_gpio_get,
> > + .set = logicvc_gpio_set,
> > +};
> > +
> > static const struct of_device_id syscon_gpio_ids[] = {
> > {
> > .compatible = "cirrus,ep7209-mctrl-gpio",
> > @@ -203,6 +267,10 @@ static const struct of_device_id syscon_gpio_ids[] = {
> > .compatible = "rockchip,rk3328-grf-gpio",
> > .data = &rockchip_rk3328_gpio_mute,
> > },
> > + {
> > + .compatible = "xylon,logicvc-3.02.a-gpio",
> > + .data = &logicvc_gpio,
> > + },
> > { }
> > };
> > MODULE_DEVICE_TABLE(of, syscon_gpio_ids);
> > --
> > 2.23.0
> >
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-10-03 11:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 10:04 [PATCH v3 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
2019-09-27 10:04 ` [PATCH v3 1/5] dt-bindings: Add Xylon vendor prefix Paul Kocialkowski
2019-09-27 20:49 ` Rob Herring
2019-09-27 10:04 ` [PATCH v3 2/5] dt-bindings: mfd: Document the Xylon LogiCVC multi-function device Paul Kocialkowski
2019-09-27 22:15 ` Rob Herring
2019-10-04 14:45 ` Lee Jones
2019-10-04 16:09 ` Rob Herring
2019-10-04 18:12 ` Paul Kocialkowski
2019-09-27 10:04 ` [PATCH v3 3/5] gpio: syscon: Add support for a custom get operation Paul Kocialkowski
2019-10-03 8:24 ` Bartosz Golaszewski
2019-10-03 11:26 ` Paul Kocialkowski
2019-10-03 14:05 ` Bartosz Golaszewski
2019-10-03 14:15 ` Paul Kocialkowski
2019-09-27 10:04 ` [PATCH v3 4/5] dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller Paul Kocialkowski
2019-09-27 22:16 ` Rob Herring
2019-09-27 10:04 ` [PATCH v3 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs Paul Kocialkowski
2019-10-03 8:26 ` Bartosz Golaszewski
2019-10-03 11:26 ` Paul Kocialkowski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191003112656.GB28856@aptenodytes \
--to=paul.kocialkowski@bootlin.com \
--cc=bgolaszewski@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox