From: Scott McNutt <smcnutt@psyent.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6 v3] nios2: add gpio support to nios2-generic board
Date: Tue, 25 May 2010 15:40:08 -0400 [thread overview]
Message-ID: <4BFC2798.90200@psyent.com> (raw)
In-Reply-To: <1272598458-17946-4-git-send-email-thomas@wytron.com.tw>
Applied to:
git://git.denx.de/u-boot-nios.git next
Thanks,
--Scott
Thomas Chou wrote:
> This patch adds gpio support of Altera PIO component to the
> nios2-generic board. Though it drives only gpio_led at the
> moment, it supports bidirectional port to control bit-banging
> I2C, NAND flash busy status or button switches, etc.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
> v3: split patches for gpio and spi, based gpio on altera pio core.
> v2: remove mmc_spi_init()
>
> board/altera/nios2-generic/Makefile | 1 +
> board/altera/nios2-generic/gpio.c | 55 +++++++++++++++++++++++++++++++++++
> include/configs/nios2-generic.h | 6 ++--
> 3 files changed, 59 insertions(+), 3 deletions(-)
> create mode 100644 board/altera/nios2-generic/gpio.c
>
> diff --git a/board/altera/nios2-generic/Makefile b/board/altera/nios2-generic/Makefile
> index 6780872..d1fca70 100644
> --- a/board/altera/nios2-generic/Makefile
> +++ b/board/altera/nios2-generic/Makefile
> @@ -32,6 +32,7 @@ LIB = $(obj)lib$(BOARD).a
> COBJS-y := $(BOARD).o
> COBJS-$(CONFIG_CMD_IDE) += ../common/cfide.o
> COBJS-$(CONFIG_EPLED) += ../common/epled.o
> +COBJS-$(CONFIG_GPIO) += gpio.o
> COBJS-$(CONFIG_SEVENSEG) += ../common/sevenseg.o
>
> SOBJS-y := text_base.o
> diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c
> new file mode 100644
> index 0000000..6c9c6c2
> --- /dev/null
> +++ b/board/altera/nios2-generic/gpio.c
> @@ -0,0 +1,55 @@
> +/*
> + * board gpio driver
> + *
> + * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
> + * Licensed under the GPL-2 or later.
> + */
> +#include <common.h>
> +#include <asm/io.h>
> +
> +#ifndef CONFIG_SYS_GPIO_BASE
> +
> +#define ALTERA_PIO_BASE LED_PIO_BASE
> +#define ALTERA_PIO_DATA (ALTERA_PIO_BASE + 0)
> +#define ALTERA_PIO_DIR (ALTERA_PIO_BASE + 4)
> +static u32 pio_data_reg;
> +static u32 pio_dir_reg;
> +
> +int gpio_direction_input(unsigned gpio)
> +{
> + u32 mask = 1 << gpio;
> + writel(pio_dir_reg &= ~mask, ALTERA_PIO_DIR);
> + return 0;
> +}
> +
> +int gpio_direction_output(unsigned gpio, int value)
> +{
> + u32 mask = 1 << gpio;
> + if (value)
> + pio_data_reg |= mask;
> + else
> + pio_data_reg &= ~mask;
> + writel(pio_data_reg, ALTERA_PIO_DATA);
> + writel(pio_dir_reg |= mask, ALTERA_PIO_DIR);
> + return 0;
> +}
> +
> +int gpio_get_value(unsigned gpio)
> +{
> + u32 mask = 1 << gpio;
> + if (pio_dir_reg & mask)
> + return (pio_data_reg & mask) ? 1 : 0;
> + else
> + return (readl(ALTERA_PIO_DATA) & mask) ? 1 : 0;
> +}
> +
> +void gpio_set_value(unsigned gpio, int value)
> +{
> + u32 mask = 1 << gpio;
> + if (value)
> + pio_data_reg |= mask;
> + else
> + pio_data_reg &= ~mask;
> + writel(pio_data_reg, ALTERA_PIO_DATA);
> +}
> +#endif
> diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
> index e83e1e3..e4bf57b 100644
> --- a/include/configs/nios2-generic.h
> +++ b/include/configs/nios2-generic.h
> @@ -63,10 +63,10 @@
> * STATUS LED
> */
> #define CONFIG_STATUS_LED /* Enable status driver */
> -#define CONFIG_EPLED /* Enable LED PIO driver */
> -#define CONFIG_SYS_LEDPIO_ADDR LED_PIO_BASE
> +#define CONFIG_GPIO_LED /* Enable GPIO LED driver */
> +#define CONFIG_GPIO /* Enable GPIO driver */
>
> -#define STATUS_LED_BIT 1 /* Bit-0 on PIO */
> +#define STATUS_LED_BIT 0 /* Bit-0 on GPIO */
> #define STATUS_LED_STATE 1 /* Blinking */
> #define STATUS_LED_PERIOD (500 / CONFIG_SYS_NIOS_TMRMS) /* 500 msec */
>
next prev parent reply other threads:[~2010-05-25 19:40 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-27 4:54 [U-Boot] [PATCH] nios2: add gpio based status led driver Thomas Chou
2010-04-20 13:19 ` Scott McNutt
2010-04-20 15:05 ` Thomas Chou
2010-04-20 16:19 ` Scott McNutt
2010-04-21 0:33 ` Thomas Chou
2010-04-21 0:45 ` [U-Boot] [PATCH v2] misc: " Thomas Chou
2010-04-24 19:23 ` Wolfgang Denk
2010-04-24 22:07 ` Thomas Chou
2010-04-24 22:32 ` Wolfgang Denk
2010-04-24 22:59 ` Thomas Chou
2010-04-25 0:48 ` Scott McNutt
2010-04-25 18:15 ` Wolfgang Denk
2010-04-25 18:14 ` Wolfgang Denk
2010-04-28 3:51 ` Thomas Chou
2010-05-04 22:30 ` Wolfgang Denk
2010-05-04 22:53 ` Scott McNutt
2010-05-05 0:09 ` Thomas Chou
2010-04-30 3:34 ` [U-Boot] [PATCH 0/6] add gpio_led and altera_spi drivers Thomas Chou
2010-04-30 3:34 ` [U-Boot] [PATCH 1/6 v4] nios2: add gpio support Thomas Chou
2010-05-21 14:39 ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:39 ` [U-Boot] " Scott McNutt
2010-04-30 3:34 ` [U-Boot] [PATCH 2/6 v2] misc: add gpio based status led driver Thomas Chou
2010-05-21 14:40 ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:39 ` [U-Boot] " Scott McNutt
2010-04-30 3:34 ` [U-Boot] [PATCH 3/6 v3] nios2: add gpio support to nios2-generic board Thomas Chou
2010-04-30 14:24 ` Scott McNutt
2010-04-30 15:21 ` Thomas Chou
2010-04-30 15:35 ` Scott McNutt
2010-05-21 14:41 ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:40 ` Scott McNutt [this message]
2010-04-30 3:34 ` [U-Boot] [PATCH 4/6 v10] spi: add altera spi controller support Thomas Chou
2010-05-21 14:43 ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:40 ` [U-Boot] " Scott McNutt
2010-04-30 3:34 ` [U-Boot] [PATCH 5/6 v2] spi_flash: support old STMicro parts with RES Thomas Chou
2010-04-30 12:48 ` Mike Frysinger
2010-04-30 13:15 ` Thomas Chou
2010-04-30 13:11 ` [U-Boot] [PATCH 5/6 v3] " Thomas Chou
2010-04-30 13:25 ` Mike Frysinger
2010-05-05 7:21 ` Mike Frysinger
2010-05-05 7:34 ` Thomas Chou
2010-05-05 19:57 ` Wolfgang Denk
2010-05-05 21:40 ` Mike Frysinger
2010-05-06 0:20 ` Thomas Chou
2010-04-30 3:34 ` [U-Boot] [PATCH 6/6 v3] nios2: add spi flash support to nios2-generic board Thomas Chou
2010-05-21 14:44 ` [U-Boot] [Nios2-dev] " Ian Abbott
2010-05-25 19:52 ` [U-Boot] " Scott McNutt
2010-04-27 3:29 ` [U-Boot] [PATCH] nios2: add epcs, gpio led and mmc_spi to nios2-generic Thomas Chou
2010-04-28 3:08 ` [U-Boot] [PATCH v2] " Thomas Chou
2010-06-09 4:27 ` [U-Boot] [PATCH v2] misc: add gpio based status led driver Mike Frysinger
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=4BFC2798.90200@psyent.com \
--to=smcnutt@psyent.com \
--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