From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
linux-renesas-soc@vger.kernel.org,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 1/2] pinctrl: sh-pfc: Add drive strength support
Date: Wed, 23 Mar 2016 16:03:54 +0200 [thread overview]
Message-ID: <1677428.6HZQq3BeTR@avalon> (raw)
In-Reply-To: <CAMuHMdXZ6Eec37e7s3CO0Y782_Yy5hv--jX7gSGFTc5SCokZVA@mail.gmail.com>
Hi Geert,
On Wednesday 23 Mar 2016 10:54:02 Geert Uytterhoeven wrote:
> On Mon, Mar 21, 2016 at 12:33 AM, Laurent Pinchart wrote:
> > Add support for the drive-strengh pin configuration using the generic
> > pinconf DT bindings.
> >
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
>
> Thanks for your patch!
>
> > diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
> > index 181ea98a63b7..73f0b33ee0a1 100644
> > --- a/drivers/pinctrl/sh-pfc/core.c
> > +++ b/drivers/pinctrl/sh-pfc/core.c
> > @@ -173,6 +173,21 @@ void sh_pfc_write_raw_reg(void __iomem *mapped_reg,
> > unsigned int reg_width,
> > BUG();
> > }
> >
> > +u32 sh_pfc_read_reg(struct sh_pfc *pfc, u32 reg, unsigned int width)
> > +{
> > + return sh_pfc_read_raw_reg(sh_pfc_phys_to_virt(pfc, reg), width);
> > +}
> > +
> > +void sh_pfc_write_reg(struct sh_pfc *pfc, u32 reg, unsigned int width,
> > u32 data)
> > +{
> > + if (pfc->info->unlock_reg)
> > + sh_pfc_write_raw_reg(
> > + sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg),
> > 32,
> > + ~data);
> > +
> > + sh_pfc_write_raw_reg(sh_pfc_phys_to_virt(pfc, reg), width, data);
> > +}
>
> I like these helpers. They may also be used by r8a7778_pinmux_[gs]et_bias()
> and r8a7790_[gs]et_io_voltage().
>
> However, writing to the pull-up registers on r8a7778 doesn't seem to require
> writing to the unlock register first.
>
> Should we prepare for that and add a bool parameter to sh_pfc_write_reg()?
I've thought about it, but given that we don't have an immediate issue with
the r8a7778 implementation, I decided it would be better to wait until we have
a couple more users for that API to decide how to implement it best.
> > --- a/drivers/pinctrl/sh-pfc/pinctrl.c
> > +++ b/drivers/pinctrl/sh-pfc/pinctrl.c
> >
> > +static int sh_pfc_pinconf_get_drive_strength(struct sh_pfc *pfc,
> > + unsigned int pin)
> > +{
> > + unsigned long flags;
> > + unsigned int offset;
> > + unsigned int size;
> > + u32 reg;
> > + u32 val;
> > +
> > + reg = sh_pfc_pinconf_find_drive_strength_reg(pfc, pin, &offset,
> > &size); + if (!reg)
> > + return -EINVAL;
> > +
> > + spin_lock_irqsave(&pfc->lock, flags);
> > + val = sh_pfc_read_reg(pfc, reg, 32);
> > + spin_unlock_irqrestore(&pfc->lock, flags);
> > +
> > + val = (val >> offset) & GENMASK(size - 1, 0);
> > +
> > + /* Convert the value to mA based on a full drive strength value of
> > 24mA. + * We can make the full value configurable later if needed.
> > + */
> > + if (size == 2)
> > + val <<= 1;
>
> I would write "val *= 2" here, as you're doing arithmetic, and have a "* 3"
> below anyway.
It's actually not really arithmetics, but I realize the code doesn't work
correctly as a 2-bits drive strength set to 3 will be converted to 21 instead
of 34. I'll fix it and resubmit.
> > + return (val + 1) * 3;
> > +}
> > +
> > +static int sh_pfc_pinconf_set_drive_strength(struct sh_pfc *pfc,
> > + unsigned int pin, u16
> > strength)
> > +{
> > + unsigned long flags;
> > + unsigned int offset;
> > + unsigned int size;
> > + u32 reg;
> > + u32 val;
> > +
> > + if (strength < 3 || strength > 24)
> > + return -EINVAL;
> > +
> > + reg = sh_pfc_pinconf_find_drive_strength_reg(pfc, pin, &offset,
> > &size); + if (!reg)
> > + return -EINVAL;
> > +
> > + /* Convert the value from mA based on a full drive strength value
> > of
> > + * 24mA. We can make the full value configurable later if needed.
> > + */
> > + strength = strength / 3 - 1;
> > + if (size == 2)
> > + strength >>= 1;
>
> Same here: "strength / = 2".
>
> Apart from the above, everything else looks fine to me, thx!
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2016-03-23 14:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 23:33 [PATCH 0/2] r8a7795 pinctrl: Add drive strength support Laurent Pinchart
2016-03-20 23:33 ` [PATCH 1/2] pinctrl: sh-pfc: " Laurent Pinchart
2016-03-23 9:54 ` Geert Uytterhoeven
2016-03-23 14:03 ` Laurent Pinchart [this message]
2016-03-20 23:33 ` [PATCH 2/2] pinctrl: sh-pfc: r8a7795: " Laurent Pinchart
2016-03-23 10:14 ` Geert Uytterhoeven
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=1677428.6HZQq3BeTR@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=geert@linux-m68k.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.