From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 24 Sep 2015 20:04:52 +0200 Subject: [U-Boot] [PATCH] nios2 : convert altera_pio to driver model In-Reply-To: <1443086105-11783-1-git-send-email-thomas@wytron.com.tw> References: <1443086105-11783-1-git-send-email-thomas@wytron.com.tw> Message-ID: <201509242004.52343.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday, September 24, 2015 at 11:15:05 AM, Thomas Chou wrote: > Convert altera_pio to driver model. > > Signed-off-by: Thomas Chou 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!