From: Stephen Warren <swarren@wwwdotorg.org>
To: Dong Aisheng <aisheng.dong@freescale.com>
Cc: "linus.walleij@linaro.org" <linus.walleij@linaro.org>,
"grant.likely@secretlab.ca" <grant.likely@secretlab.ca>,
"rob.herring@calxeda.com" <rob.herring@calxeda.com>,
"linus.walleij@stericsson.com" <linus.walleij@stericsson.com>,
Dong Aisheng-B29396 <B29396@freescale.com>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"dongas86@gmail.com" <dongas86@gmail.com>,
"shawn.guo@linaro.org" <shawn.guo@linaro.org>,
"thomas.abraham@linaro.org" <thomas.abraham@linaro.org>,
"tony@atomide.com" <tony@atomide.com>,
"sjg@chromium.org" <sjg@chromium.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH V2 6/6] pinctrl: tegra: Add complete device tree support
Date: Wed, 21 Mar 2012 10:07:27 -0600 [thread overview]
Message-ID: <4F69FCBF.3050708@wwwdotorg.org> (raw)
In-Reply-To: <20120321093504.GA12118@shlinux2.ap.freescale.net>
On 03/21/2012 03:35 AM, Dong Aisheng wrote:
> On Wed, Mar 21, 2012 at 01:44:39AM +0800, Stephen Warren wrote:
>> Implement pinctrl_ops dt_node_to_map() and dt_free_map(). These allow
>> complete specification of the desired pinmux configuration using device
>> tree.
>>
>> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
>> ---
>> v2: Rebase on of_property_for_each_string() API changes.
>> ---
> Nice code and a good example to people.
>
> A small suggestion below:
>> +static int add_map_configs(struct pinctrl_map **map, unsigned *num_maps,
>> + const char *group, unsigned long *configs,
>> + unsigned num_configs)
>> +{
>> + unsigned i = *num_maps;
>> + unsigned long *dup_configs;
>> + int ret;
>> +
>> + dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
>> + GFP_KERNEL);
>> + if (!dup_configs)
>> + return -ENOMEM;
>> +
>> + ret = add_map(map, num_maps);
>> + if (ret < 0)
>> + return ret;
>> +
>> + (*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
>
> It still does not support PIN_MAP_TYPE_CONFIGS_PIN, right?
Yes.
This is mainly due to a pinctrl core limitation. The core only supports
muxing on groups, so even though the Tegra30 HW supports muxing per pin,
the driver must define a group for each pin. Given that, it's simplest
just to do all the pin config on those same groups.
If/when the pinctrl core supports muxing per pin, we can take advantage
of this within the Tegra pinctrl driver without affecting the binding at
all.
>> + for_each_child_of_node(np_config, np) {
>> + ret = of_property_read_string(np, "nvidia,function", &function);
>> + if (ret < 0)
>> + function = NULL;
>> +
>> + for (i = 0; i < ARRAY_SIZE(cfg_params); i++) {
>> + ret = of_property_read_u32(np, cfg_params[i].property,
>> + &val);
>> + if (!ret) {
>> + config = TEGRA_PINCONF_PACK(
>> + cfg_params[i].param, val);
>> + ret = add_config(&configs, &num_configs,
>> + config);
>> + if (ret < 0)
>> + goto error;
>> + }
>> + }
>> +
>> + of_property_for_each_string(np, "nvidia,pins", prop, group) {
>
> If we calculate out the strings count and allocate corresponding size array, we may not
> need to keep krealloc the maps and configs array size for each entry.
> And this may be a little higher efficient.
That's true. However, it'd require the code to loop once to determine
how many properties are present and how many entries there are in the
pin list. Then, loop again to actually construct the mapping table
array. This is all added complexity that doesn't affect correctness. I'd
rather get the simple code going first, and then refine it later if
there turns out to be a performance issue.
next prev parent reply other threads:[~2012-03-21 16:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 17:44 [PATCH V2 1/6] dt: add property iteration helpers Stephen Warren
2012-03-20 17:44 ` [PATCH V2 2/6] dt: pinctrl: Document device tree binding Stephen Warren
2012-03-20 19:50 ` Simon Glass
[not found] ` <1332265479-1260-2-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-21 5:37 ` Dong Aisheng
2012-03-20 17:44 ` [PATCH V2 3/6] pinctrl: core device tree mapping table parsing support Stephen Warren
[not found] ` <1332265479-1260-3-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-21 7:31 ` Dong Aisheng
[not found] ` <20120321073116.GE3191-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-21 15:48 ` Stephen Warren
[not found] ` <4F69F844.3060102-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-21 17:25 ` Stephen Warren
[not found] ` <4F6A0F05.90104-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-22 5:49 ` Dong Aisheng
2012-03-22 3:39 ` Dong Aisheng
2012-03-20 17:44 ` [PATCH V2 4/6] dt: Move Tegra20 pin mux binding into new pinctrl directory Stephen Warren
2012-03-20 17:44 ` [PATCH V2 5/6] dt: Document Tegra20/30 pinctrl binding Stephen Warren
[not found] ` <1332265479-1260-5-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-21 9:19 ` Dong Aisheng
[not found] ` <20120321091919.GA18592-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-21 15:57 ` Stephen Warren
[not found] ` <4F69FA5A.9020504-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-22 4:00 ` Dong Aisheng
[not found] ` <20120322040024.GB840-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-22 15:45 ` Stephen Warren
[not found] ` <4F6B491B.8040506-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-23 4:51 ` Dong Aisheng
2012-03-20 17:44 ` [PATCH V2 6/6] pinctrl: tegra: Add complete device tree support Stephen Warren
[not found] ` <1332265479-1260-6-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-21 9:35 ` Dong Aisheng
2012-03-21 16:07 ` Stephen Warren [this message]
[not found] ` <4F69FCBF.3050708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-22 4:07 ` Dong Aisheng
[not found] ` <20120322040730.GC840-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2012-03-22 17:22 ` Stephen Warren
2012-04-01 17:29 ` Linus Walleij
[not found] ` <CACRpkdav8x-Td-fH1Ree83GhNR8r7aA1dBsTQo2eU3nwwam21Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-02 15:34 ` Stephen Warren
[not found] ` <4F79C6F7.4070701-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-03 21:06 ` Linus Walleij
[not found] ` <1332265479-1260-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-03-20 20:03 ` [PATCH V2 1/6] dt: add property iteration helpers Rob Herring
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=4F69FCBF.3050708@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=B29396@freescale.com \
--cc=aisheng.dong@freescale.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dongas86@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rob.herring@calxeda.com \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@linaro.org \
--cc=sjg@chromium.org \
--cc=thomas.abraham@linaro.org \
--cc=tony@atomide.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).