From: Michal Simek <monstr@monstr.eu>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Michal Simek <monstr@monstr.eu>,
Michal Simek <michal.simek@xilinx.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <rob.herring@calxeda.com>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Subject: Re: [PATCH 1/2] GPIO: Add support for dual channel in gpio-xilinx.c
Date: Thu, 20 Jun 2013 14:12:23 +0200 [thread overview]
Message-ID: <51C2F1A7.3030805@monstr.eu> (raw)
In-Reply-To: <CACRpkdbcq+e099mT+TVwv9vDjXwkf8QdB_4b4UXuysPF+40oUQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3293 bytes --]
On 06/20/2013 01:33 PM, Linus Walleij wrote:
> On Thu, Jun 20, 2013 at 12:59 PM, Michal Simek <monstr@monstr.eu> wrote:
>> On 06/20/2013 11:23 AM, Linus Walleij wrote:
>
>>> What about something like this:
>>>
>>> static bool is_dual (struct device_node *np)
>>> {
>>> struct property *prop = of_find_property(np, "xlnx,is-dual", NULL);
>>> int ret;
>>> u32 val;
>>>
>>> if (!prop)
>>> return false;
>>>
>>> ret = of_property_read_u32(np, "xlnx,is-dual", &val);
>>> if (ret < 0)
>>> return true; /* node exists but has no cells */
>>>
>>> return !!val;
>>> }
>>
>> we can do it in this way but what I don't like on this is that IP
>> is design to support 2 channels right now.
>> It can happen that Xilinx decides to extend this for new channels.
>> Register map is prepared for it and there is enough space to do it.
>>
>> And when this is done then is-dual (which is current name which
>> is used in hardware configuration from design tools) will contain
>> larger value >1.
>> I agree that is-dual is not the best name.
>
> You don't say. It's about as smart as this:
>
> #define NUMBER_TWO 4
>
> Oh well, that's not your fault.
>
> But seriously:
>
> xlnx,is-dual;
>
> without an argument can still be taken to mean "2", and
> you still need to inperpret the absence if this parameter
> as "1" do you not?
>
>> What about to do it differently?
>> Generate number of channel in the description.
>> And also do for() loop in the probe function to read values based
>> on this channel number.
>
> Sorry I can't translate this, can you send a patch?
Sure.
xlnx,is-dual is always present in the HW and in all DTSes and it
is generated for several years
Based on my experience with hardware guys what happen when they add
new channel is that they will use xlnx,is-dual = 2 for 3 channels,
xlnx,is-dual = 3 for 4 channels, etc. They won't care about names
but they are working like that.
It means for me is really problematic it try to work with this
value as boolean even that name is confusing.
That's why it is much easier for me to start to use new property
which will describe number of channels but this value is not
used in design tools. Let's say number-of-channels = 1 or 2
in DT binding which will describe number channels in this IP.
Is this acceptable for you?
If you look how that dual channel is supported you will see that it is
probe_first_channel
if there is second channel probe it too.
And code there is very similar.
That's why I am thinking about using the loop to remove that code
duplication.
Something like this in "psedo code"
for(i = 0; i < number-of-channel; i++) {
char *str_def = "xlnx,dout-default"
if(i)
add -(i+1) suffix to str_def (-2 for example just to reflect how design tools generates it)
of_property_read_u32(np, str_def, &chip->gpio_state);
...
gpiochip_add()
}
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2013-06-20 12:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-29 11:27 [PATCH 1/2] GPIO: Add support for dual channel in gpio-xilinx.c Michal Simek
2013-05-29 11:27 ` [PATCH 2/2] DT: Add documentation for gpio-xilinx Michal Simek
[not found] ` <4b90b06fce0475b579cfba4d968b4778359154f6.1369826814.git.michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2013-05-30 19:46 ` [PATCH 1/2] GPIO: Add support for dual channel in gpio-xilinx.c Linus Walleij
[not found] ` <CACRpkdY4xaCOe28nu-NrYQ7pafjhj8-xqFcJRF9iJUy3SrCVrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-31 5:43 ` Michal Simek
2013-05-31 7:14 ` Linus Walleij
[not found] ` <CACRpkdbHiaK6YPgXyxNgEeZxAsddK4x0vS-q3YfyXnj_BgHvuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-31 7:34 ` Michal Simek
2013-06-17 5:29 ` Linus Walleij
2013-06-20 7:51 ` Michal Simek
2013-06-20 9:23 ` Linus Walleij
[not found] ` <CACRpkdbWXFLgcUJ-gcUArRotJMoX4JBU9mmheooJBWsLR=QHOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-20 10:59 ` Michal Simek
2013-06-20 11:33 ` Linus Walleij
2013-06-20 12:12 ` Michal Simek [this message]
2013-06-24 10:01 ` Linus Walleij
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=51C2F1A7.3030805@monstr.eu \
--to=monstr@monstr.eu \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=plagnioj@jcrosoft.com \
--cc=rob.herring@calxeda.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).