From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] nios2 : convert altera_pio to driver model
Date: Thu, 24 Sep 2015 20:04:52 +0200 [thread overview]
Message-ID: <201509242004.52343.marex@denx.de> (raw)
In-Reply-To: <1443086105-11783-1-git-send-email-thomas@wytron.com.tw>
On Thursday, September 24, 2015 at 11:15:05 AM, Thomas Chou wrote:
> Convert altera_pio to driver model.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Hi,
now this is quite a nice patch :-)
> ---
> arch/nios2/dts/3c120_devboard.dts | 38 ++++
> arch/nios2/include/asm/gpio.h | 80 +-------
> board/altera/nios2-generic/nios2-generic.c | 7 -
> configs/nios2-generic_defconfig | 2 +
> drivers/gpio/Kconfig | 7 +
> drivers/gpio/altera_pio.c | 316
> +++++++---------------------- include/configs/nios2-generic.h |
> 20 --
> 7 files changed, 124 insertions(+), 346 deletions(-)
>
[...]
> +static int altera_pio_get_value(struct udevice *dev, unsigned pin)
> {
> - int i;
> - int j;
> - int gidx;
> - u32 mask;
> + struct altera_pio_platdata *plat = dev_get_platdata(dev);
> + struct altera_pio_regs *const regs = plat->regs;
>
> - for (i = 0; i < pio_num; ++i) {
> - printf("Altera PIO % 2d, @0x%08x, "
> - "width: %u, label: %s\n",
> - i, pios[i].base, pios[i].width, pios[i].label);
> - gidx = pios[i].gidx;
> - for (j = gidx; j < (gidx + pios[i].width); ++j) {
> - mask = 1 << (j - gidx);
> - printf("\tGPIO % 4d: %s %s [%c] %s\n",
> - gpios[j].num,
> - gpios[j].pio->sh_dir & mask ? "out" : " in",
> - gpio_get_value(gpios[j].num) ? "set" : "clr",
> - altera_pio_is_gidx_used(j) ? 'x' : ' ',
> - gpios[j].reqlabel);
> - }
> - }
> + return !!(readl(®s->data) & (1 << pin));
You can drop the double negation here, the API design is done such that
0 is log. low and non-zero is log. high .
[...]
Thanks!
next prev parent reply other threads:[~2015-09-24 18:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 9:15 [U-Boot] [PATCH] nios2 : convert altera_pio to driver model Thomas Chou
2015-09-24 18:04 ` Marek Vasut [this message]
2015-09-25 8:05 ` [U-Boot] [PATCH v2] " Thomas Chou
2015-09-26 9:07 ` [U-Boot] [PATCH v3] " Thomas Chou
2015-09-30 1:18 ` Chin Liang See
2015-09-30 18:29 ` Simon Glass
2015-10-01 0:38 ` Thomas Chou
2015-09-30 13:37 ` [U-Boot] [PATCH v4] " Thomas Chou
2015-10-03 13:10 ` Thomas Chou
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=201509242004.52343.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/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