linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Jason Cooper <jason@lakedaemon.net>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Rob Landley <rob@landley.net>,
	Russell King <linux@arm.linux.org.uk>,
	Lior Amsalem <alior@marvell.com>, Andrew Lunn <andrew@lunn.ch>,
	Gregory CLEMENT <gregory.clement@free-electrons.com>,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Stephen Warren <swarren@wwwdotorg.org>
Subject: Re: [PATCH 01/11] pinctrl: mvebu: pinctrl driver core
Date: Mon, 20 Aug 2012 11:46:14 +0200	[thread overview]
Message-ID: <CABJ1b_TCF=Jfb0uuoh-M87n6faezj4OqZ4S_nJLA0yKga2-ioQ@mail.gmail.com> (raw)
In-Reply-To: <CACRpkda0wUW4E3y=ucGRFu5fwwyFWo2dc=4qBaH6CFSOW2ZL_A@mail.gmail.com>

On 8/20/12, Linus Walleij <linus.walleij@linaro.org> wrote:
> Are you taking this patch series through some Marvell tree or do you want
> me to carry it in the pinctrl tree?

Hi Linus,

I think it would be better to take it through the Marvell tree of Jason
Cooper. It is only for Marvell SoCs anyway.

>> +uart1: serial@12100 {
>> +       compatible = "ns16550a";
>> +       reg = <0x12100 0x100>;
>> +       reg-shift = <2>;
>> +       interrupts = <7>;
>> +       clock-frequency = <166666667>;
>
> It's got nothing to do with this patch, but getting a clock frequency
> out of the DT instead of getting it from the clk_get_rate(clk) and
> the clock tree seems absurd... (But maybe this platform does not
> even have a clk implementation?)

It's of_serial's implementation. I patched that once for getting
frequency out of "clocks" property but then I got busy with
porting mach-dove and pinctrl.. Marvell SoCs do have a clk
implementation and as soon as of_serial can handle "clocks"
property it will be used for sure. I can remove "clock-frequency"
from the example anyway as it is not really part of pinctrl
binding documentation.

> (...)
>> +#include <linux/pinctrl/consumer.h>
>
> Why are you including this header?
> (There are valid reasons, state them in a comment,
> e.g. /* to access pinctrl_gpio* in GPIO portions */)

I guess it was a left-over from my experiments with
default pinmux configuration until you pointed me to
the correct way of having the pinctrl itself hog muxes.

I'll remove that include.

>> +struct mvebu_pinctrl {
>> +       struct device *dev;
>> +       struct pinctrl_dev *pctldev;
>> +       struct pinctrl_desc desc;
>> +       void __iomem *base;
>> +       struct mvebu_pinctrl_group *groups;
>> +       unsigned num_groups;
>> +       struct mvebu_pinctrl_function *functions;
>> +       unsigned num_functions;
>> +       unsigned variant;
>> +};
>
> There is some other "variant" field elsewhere that is
> a u8, is this correct? In this and the other case, should
> this "variant" rather be an enum?

I'll review the variant types but inside pinctrl-mvebu variant
is used as a bit mask to distinguish different variants. Anyway,
they should always be the same size.

>> +static int mvebu_common_mpp_get(struct mvebu_pinctrl *pctl,
>> +                               struct mvebu_pinctrl_group *grp,
>> +                               unsigned long *config)
>> +{
>> +       unsigned pin = grp->gid;
>> +       unsigned off = (pin / 8) * 4;
>> +       unsigned shift = (pin % 8) * 4;
>
> Some magic numbers here. Either use relevant #define:s or
> put an inline comment that explains what is going on.

Ok.

>> +static void mvebu_pinctrl_dt_free_map(struct pinctrl_dev *pctldev,
>> +                               struct pinctrl_map *map, unsigned
>> num_maps)
>> +{
>> +       kfree(map);
>> +}
>
> Is it possible to use devm_* managed devm_kzalloc() for this map
> so you don't need to free it explicitly?
>
> (Maybe not, just checking.)

Hmm, I guess not as I thought I've read not to use devm_kfree when
you allocate _and_ free stuff on runtime without removing the device
itself, right?

>> diff --git a/drivers/pinctrl/pinctrl-mvebu.h
>> b/drivers/pinctrl/pinctrl-mvebu.h
> (...)
>> +/*
>
> Kerneldoc begins with /** have you really tested to generate
> kerneldoc?

Nope, I wasn't even aware of that, sorry. I just copied it over
from some other pinctrl include. I'll check for compatibility with
kerneldoc.

>> +struct mvebu_mpp_ctrl {
>> +       const char *name;
>> +       u8 pid;
>> +       u8 npins;
>
> So, there will never be > 256 pins on a Marvell platform?

Well, with all current platforms we are well below 100. I guess
256 max (muxable) pins will be enough.

>> + * struct mvebu_mpp_ctrl_setting - describe a mpp ctrl setting
>> + * @val: ctrl setting value
>
> It is not obvious to me what this means, it it possible to elaborate
> on how this member is defined and used?

Well, I see if I can clarify the description but wrt the datasheet it
_should_ be quite obvious.

>> + * @variant: (optional) variant identifier mask
>
> This thing again, there are lots of "variants" around here.
> Is it a candidate for an enum?

As it is a mask, I don't think enum fits here.

>> + * @flags: (private) flags to store gpi/gpo/gpio capabilities
>
> Write something about the two available flags and what they
> mean maybe?

Ok.

>> +#define  MVEBU_SETTING_GPO     (1 << 0)
>> +#define  MVEBU_SETTING_GPI     (1 << 1)
>
> So these are the possible flags I suspect. (Looking good.)

Yes, some mpp pins on Marvell SoCs are out-only, while
normally they are in-out. I haven't seen in-only yet but better
to have the flags ready if someone stumbles upon one.

>> +#if defined(CONFIG_DEBUG_FS)
>> +#define MPP_VAR_FUNCTION(_val, _name, _subname, _mask)         \
>> +       _MPP_VAR_FUNCTION(_val, _name, _subname, _mask)
>> +#else
>> +#define MPP_VAR_FUNCTION(_val, _name, _subname, _mask)         \
>> +       _MPP_VAR_FUNCTION(_val, _name, NULL, _mask)
>> +#endif
>
> This looks a bit kludgy. Is the purpose to save memory
> if debugfs is not used?

Yes, that was the intention. Subnames are not used by pinctrl at all,
other for debugfs files. Although, there are some pins that have two different
settings for the same device name, e.g. sata(prsnt) and sata(act), I don't
think it is a good idea to use the subname but have sata(prsnt) and sata-1(act)
instead. Otherwise, you'll always have to look up the specific function for
each pin. OTOH, I could check for "sata" and take the subname into account
when it is given in marvell,function. But it will not help reducing the required
pinmux descriptions in DT because you still have to distinguish both and
there are only 2 out of ~50 groups that have them for Dove.

> This looks good overall.

Thanks!
In some internal review with Andrew I also added a spinlock to
mvebu_pinconf_get/_set that will protect all calls to generic and specific
_get/_set register accesses. Moreover, I replaced clk_get_sys in pinctrl-dove
with the devm_ counterpart and removed the explicit clk_put.

Sebastian

  reply	other threads:[~2012-08-20  9:46 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-11 12:56 [PATCH 00/11] pinctrl: mvebu: pinctrl driver Sebastian Hesselbarth
2012-08-11 12:56 ` [PATCH 01/11] pinctrl: mvebu: pinctrl driver core Sebastian Hesselbarth
2012-08-20  9:09   ` Linus Walleij
2012-08-20  9:46     ` Sebastian Hesselbarth [this message]
2012-08-20 12:51       ` Thomas Petazzoni
2012-08-20 14:18       ` Linus Walleij
2012-08-20 14:51         ` Sebastian Hesselbarth
2012-08-25  8:22     ` Andrew Lunn
2012-08-20 14:11   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 02/11] pinctrl: mvebu: dove pinctrl driver Sebastian Hesselbarth
2012-08-20 13:43   ` Linus Walleij
2012-08-20 14:43     ` Sebastian Hesselbarh
2012-08-20 17:16     ` Thomas Petazzoni
2012-08-11 12:56 ` [PATCH 03/11] pinctrl: mvebu: kirkwood " Sebastian Hesselbarth
2012-08-20 13:49   ` Linus Walleij
2012-08-27 13:43     ` Ben Dooks
2012-08-27 19:19       ` Sebastian Hesselbarth
2012-08-27 20:02         ` Stephen Warren
2012-08-11 12:56 ` [PATCH 04/11] pinctrl: mvebu: add pinctrl driver for Armada 370 Sebastian Hesselbarth
2012-08-20 14:25   ` Linus Walleij
2012-08-20 16:48     ` Sebastian Hesselbarth
2012-08-20 17:36       ` Thomas Petazzoni
2012-08-20 18:01         ` Sebastian Hesselbarth
2012-08-20 18:51           ` Thomas Petazzoni
2012-08-21  7:12         ` Gregory CLEMENT
2012-08-11 12:56 ` [PATCH 05/11] pinctrl: mvebu: add pinctrl driver for Armada XP Sebastian Hesselbarth
2012-08-20 14:26   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 06/11] ARM: mvebu: add pinctrl device in DT for Armada 370/XP SoCs Sebastian Hesselbarth
2012-08-20 14:27   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 07/11] ARM: mvebu: Add pinctrl support to Armada XP SoCs Sebastian Hesselbarth
2012-08-20 14:27   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 08/11] ARM: mvebu: Add pinctrl support to Armada 370 SoC Sebastian Hesselbarth
2012-08-20 14:28   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 09/11] ARM: mvebu: adjust Armada XP evaluation board DTS Sebastian Hesselbarth
2012-08-20 14:28   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 10/11] arm: mvebu: enable PINCTRL usage Sebastian Hesselbarth
2012-08-20 14:29   ` Linus Walleij
2012-08-11 12:56 ` [PATCH 11/11] arm: mvebu: add pinctrl support in defconfig Sebastian Hesselbarth
2012-08-20 14:31   ` Linus Walleij
2012-08-20 14:54     ` Sebastian Hesselbarth
2012-08-20 17:37       ` Thomas Petazzoni
2012-08-20  8:12 ` [PATCH 00/11] pinctrl: mvebu: pinctrl driver Linus Walleij
2012-08-22  8:22 ` [PATCH v2 0/9] " Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 1/9] pinctrl: mvebu: pinctrl driver core Sebastian Hesselbarth
2012-08-22 20:43     ` Stephen Warren
2012-08-23  9:45       ` Sebastian Hesselbarth
2012-08-23 17:54         ` Stephen Warren
2012-08-23 20:31           ` Sebastian Hesselbarth
2012-08-23 21:26             ` Stephen Warren
2012-08-23 23:01               ` Sebastian Hesselbarth
2012-08-24  3:34                 ` Stephen Warren
2012-08-25 15:53                   ` Sebastian Hesselbarth
2012-08-27  4:33                     ` Stephen Warren
2012-09-02  7:30                       ` Linus Walleij
2012-09-02  8:27                         ` Sebastian Hesselbarth
2012-09-03  9:32                           ` Linus Walleij
2012-09-03 19:47                           ` Jason Cooper
2012-09-09 19:56                           ` Jason Cooper
2012-08-22  8:22   ` [PATCH v2 2/9] pinctrl: mvebu: dove pinctrl driver Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 3/9] pinctrl: mvebu: kirkwood " Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 4/9] pinctrl: mvebu: add pinctrl driver for Armada 370 Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 5/9] pinctrl: mvebu: add pinctrl driver for Armada XP Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 6/9] ARM: mvebu: add pinctrl device in DT for Armada 370/XP SoCs Sebastian Hesselbarth
2012-08-22  8:22   ` [PATCH v2 7/9] ARM: mvebu: Add pinctrl support to Armada XP SoCs Sebastian Hesselbarth
2012-08-22 20:45     ` Stephen Warren
2012-08-22  8:22   ` [PATCH v2 8/9] ARM: mvebu: Add pinctrl support to Armada 370 SoC Sebastian Hesselbarth
2012-08-22 20:46     ` Stephen Warren
2012-08-22  8:22   ` [PATCH v2 9/9] ARM: mvebu: adjust Armada XP evaluation board DTS Sebastian Hesselbarth
2012-09-10  8:39   ` [PATCH v3 0/9] pinctrl: mvebu: pinctrl driver Sebastian Hesselbarth
2012-09-10  8:39     ` [PATCH v3 1/9] pinctrl: mvebu: pinctrl driver core Sebastian Hesselbarth
2012-09-10 15:39       ` Linus Walleij
2012-09-11 14:44       ` Thomas Petazzoni
2012-09-11 22:17         ` Stephen Warren
2012-09-12  6:04           ` Linus Walleij
2012-09-12  6:54           ` Thomas Petazzoni
2012-09-12 15:50             ` Linus Walleij
2012-09-12 16:01               ` Thomas Petazzoni
2012-09-12 16:17                 ` Linus Walleij
2012-09-12 21:10             ` Stephen Warren
2012-09-10  8:39     ` [PATCH v3 2/9] pinctrl: mvebu: dove pinctrl driver Sebastian Hesselbarth
2012-09-10 15:40       ` Linus Walleij
2012-09-11 22:18       ` Stephen Warren
2012-09-10  8:39     ` [PATCH v3 3/9] pinctrl: mvebu: kirkwood " Sebastian Hesselbarth
2012-09-10 15:42       ` Linus Walleij
2012-09-10  8:39     ` [PATCH v3 4/9] pinctrl: mvebu: add pinctrl driver for Armada 370 Sebastian Hesselbarth
2012-09-10 15:43       ` Linus Walleij
2012-09-10  8:39     ` [PATCH v3 5/9] pinctrl: mvebu: add pinctrl driver for Armada XP Sebastian Hesselbarth
2012-09-10 15:43       ` Linus Walleij
2012-09-10  8:39     ` [PATCH v3 6/9] ARM: mvebu: add pinctrl device in DT for Armada 370/XP SoCs Sebastian Hesselbarth
2012-09-11 22:23       ` Stephen Warren
2012-09-12  6:56         ` Thomas Petazzoni
2012-09-12 20:57           ` Stephen Warren
2012-09-10  8:39     ` [PATCH v3 7/9] ARM: mvebu: Add pinctrl support to Armada XP SoCs Sebastian Hesselbarth
2012-09-10  8:39     ` [PATCH v3 8/9] ARM: mvebu: Add pinctrl support to Armada 370 SoC Sebastian Hesselbarth
2012-09-10  8:39     ` [PATCH v3 9/9] ARM: mvebu: adjust Armada XP evaluation board DTS Sebastian Hesselbarth
2012-09-10 15:45     ` [PATCH v3 0/9] pinctrl: mvebu: pinctrl driver Linus Walleij
2012-09-10 15:57       ` Sebastian Hesselbarth
2012-09-13 15:41 ` [PATCH v4 00/10] " Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 01/10] pinctrl: mvebu: pinctrl driver core Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 02/10] pinctrl: mvebu: dove pinctrl driver Sebastian Hesselbarth
2013-06-18 11:36     ` Russell King - ARM Linux
2013-06-18 12:01       ` Sebastian Hesselbarth
2013-06-18 15:02       ` Linus Walleij
2013-06-18 15:11         ` Russell King - ARM Linux
2013-06-18 15:23           ` Linus Walleij
2013-06-18 18:33           ` Mark Brown
2012-09-13 15:41   ` [PATCH v4 03/10] pinctrl: mvebu: kirkwood " Sebastian Hesselbarth
2012-09-16  7:46     ` Andrew Lunn
2012-09-16  9:09       ` Sebastian Hesselbarth
2012-09-17  8:45         ` Linus Walleij
2012-09-20 15:30           ` Arnd Bergmann
2012-09-20 18:34             ` Andrew Lunn
2012-09-20 19:28             ` Linus Walleij
2012-09-20 19:36               ` Thomas Petazzoni
2012-09-20 19:51                 ` Andrew Lunn
2012-09-21 10:56                 ` Ben Dooks
2012-09-21 18:14                 ` Linus Walleij
2012-09-16 12:40       ` Jason Cooper
2012-09-17  1:55         ` Nicolas Pitre
2012-09-17  6:36           ` Sebastian Hesselbarth
2012-09-17  8:32             ` Andrew Lunn
2012-09-18 18:59     ` Andrew Lunn
2012-09-13 15:41   ` [PATCH v4 04/10] pinctrl: mvebu: add pinctrl driver for Armada 370 Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 05/10] pinctrl: mvebu: add pinctrl driver for Armada XP Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 06/10] ARM: mvebu: Add pinctrl support to Armada XP SoCs Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 07/10] ARM: mvebu: Add pinctrl support to Armada 370 SoC Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 08/10] ARM: mvebu: adjust Armada XP evaluation board DTS Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 09/10] arm: mvebu: split Kconfig options for Armada 370 and XP Sebastian Hesselbarth
2012-09-13 15:41   ` [PATCH v4 10/10] arm: mvebu: select the pinctrl drivers for Armada 370 and Armada XP platforms Sebastian Hesselbarth
2012-09-13 15:48   ` [PATCH v4 00/10] pinctrl: mvebu: pinctrl driver Thomas Petazzoni
2012-09-14 16:41   ` Stephen Warren
2012-09-20  8:13 ` [PATCH 00/11] " Linus Walleij
2012-09-20  8:17   ` Sebastian Hesselbarth
2012-09-20  9:04     ` Thomas Petazzoni
2012-09-20 10:02       ` Andrew Lunn
2012-09-20 10:32         ` Thomas Petazzoni

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='CABJ1b_TCF=Jfb0uuoh-M87n6faezj4OqZ4S_nJLA0yKga2-ioQ@mail.gmail.com' \
    --to=sebastian.hesselbarth@gmail.com \
    --cc=alior@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=ben.dooks@codethink.co.uk \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=swarren@wwwdotorg.org \
    --cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).