Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631426 > unrolled thread

Re: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller

Started byGeert Uytterhoeven <geert@linux-m68k.org>
First post2017-04-26 14:30 +0200
Last post2017-04-28 10:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller Geert Uytterhoeven <geert@linux-m68k.org> - 2017-04-26 14:30 +0200
    Re: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller jmondi <jacopo@jmondi.org> - 2017-04-26 16:30 +0200
    Re: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller Linus Walleij <linus.walleij@linaro.org> - 2017-04-28 10:10 +0200

#1631426 — Re: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2017-04-26 14:30 +0200
SubjectRe: [PATCH v4 2/9] pinctrl: Renesas RZ/A1 pin and gpio controller
Message-ID<tAueZ-2dU-5@gated-at.bofh.it>
Hi Jacopo,

On Wed, Apr 5, 2017 at 4:07 PM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
> Add combined gpio and pin controller driver for Renesas RZ/A1
> r7s72100 SoC.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

> --- /dev/null
> +++ b/drivers/pinctrl/pinctrl-rza1.c

> +/*
> + * Keep this up-to-date with pinconf-generic.h: it performs packing of
> + * pin conf flags and argument during pinconf_generic_parse_dt_config();
> + * we simply discard pinconf argument here
> + */
> +#define PIN_CONF_UNPACK(pinconf)       ((pinconf) & 0xffUL)

Perhaps this should be moved to pinconf-generic.h, to make sure it stays
up-to-date?

> +static inline int rza1_get_bit(struct rza1_port *port, unsigned int reg,

I'd use "unsigned int" as the return type.
It doesn't matter much as register values are 16-bit, but people might copy
from this driver when writing their own.

> +                              unsigned int bit)
> +{
> +       void __iomem *mem = RZA1_ADDR(port->base, reg, port->id);
> +
> +       return ioread16(mem) & BIT(bit);
> +}

> +static inline int rza1_pin_get_direction(struct rza1_port *port,
> +                                        unsigned int pin)
> +{
> +       unsigned long irqflags;
> +       int input;
> +
> +       spin_lock_irqsave(&port->lock, irqflags);
> +       input = rza1_get_bit(port, RZA1_PM_REG, pin);
> +       spin_unlock_irqrestore(&port->lock, irqflags);
> +
> +       return input;

return !!input;

gpio_chip.get_direction() should return 0, 1, or a negative error value.

> +}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [next] | [standalone]


#1631482

Fromjmondi <jacopo@jmondi.org>
Date2017-04-26 16:30 +0200
Message-ID<tAw77-3rU-3@gated-at.bofh.it>
In reply to#1631426
Hi Geert,

On Wed, Apr 26, 2017 at 02:21:34PM +0200, Geert Uytterhoeven wrote:
> Hi Jacopo,
>
> On Wed, Apr 5, 2017 at 4:07 PM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
> > Add combined gpio and pin controller driver for Renesas RZ/A1
> > r7s72100 SoC.
> >
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>
> > --- /dev/null
> > +++ b/drivers/pinctrl/pinctrl-rza1.c
>
> > +/*
> > + * Keep this up-to-date with pinconf-generic.h: it performs packing of
> > + * pin conf flags and argument during pinconf_generic_parse_dt_config();
> > + * we simply discard pinconf argument here
> > + */
> > +#define PIN_CONF_UNPACK(pinconf)       ((pinconf) & 0xffUL)
>
> Perhaps this should be moved to pinconf-generic.h, to make sure it stays
> up-to-date?
>

Not sure, I'm discarding the argument of the configuration flag with
this macro...

I would keep this internal to this driver, or make two of them, one to
retrieve the flag, and one to retrieve argument..


> > +static inline int rza1_get_bit(struct rza1_port *port, unsigned int reg,
>
> I'd use "unsigned int" as the return type.
> It doesn't matter much as register values are 16-bit, but people might copy
> from this driver when writing their own.
>
> > +                              unsigned int bit)
> > +{
> > +       void __iomem *mem = RZA1_ADDR(port->base, reg, port->id);
> > +
> > +       return ioread16(mem) & BIT(bit);
> > +}
>
> > +static inline int rza1_pin_get_direction(struct rza1_port *port,
> > +                                        unsigned int pin)
> > +{
> > +       unsigned long irqflags;
> > +       int input;
> > +
> > +       spin_lock_irqsave(&port->lock, irqflags);
> > +       input = rza1_get_bit(port, RZA1_PM_REG, pin);
> > +       spin_unlock_irqrestore(&port->lock, irqflags);
> > +
> > +       return input;
>
> return !!input;
>
> gpio_chip.get_direction() should return 0, 1, or a negative error value.
>
> > +}
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

[toc] | [prev] | [next] | [standalone]


#1632606

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-04-28 10:10 +0200
Message-ID<tB98u-4Ii-9@gated-at.bofh.it>
In reply to#1631426
On Wed, Apr 26, 2017 at 2:21 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Wed, Apr 5, 2017 at 4:07 PM, Jacopo Mondi <jacopo+renesas@jmondi.org> wrote:
>> Add combined gpio and pin controller driver for Renesas RZ/A1
>> r7s72100 SoC.
>>
>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>
>> --- /dev/null
>> +++ b/drivers/pinctrl/pinctrl-rza1.c
>
>> +/*
>> + * Keep this up-to-date with pinconf-generic.h: it performs packing of
>> + * pin conf flags and argument during pinconf_generic_parse_dt_config();
>> + * we simply discard pinconf argument here
>> + */
>> +#define PIN_CONF_UNPACK(pinconf)       ((pinconf) & 0xffUL)
>
> Perhaps this should be moved to pinconf-generic.h, to make sure it stays
> up-to-date?

I agree. Use the generic macros.

If further processing is needed, make a static inline to discard config flags
etc.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web