All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver.
@ 2011-10-17 15:36 Joachim Foerster
  2011-10-17 15:36 ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
  2011-10-17 15:36 ` [U-Boot] [PATCH 2/2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
  0 siblings, 2 replies; 10+ messages in thread
From: Joachim Foerster @ 2011-10-17 15:36 UTC (permalink / raw)
  To: u-boot

Let's have a dedicated driver for Altera's PIO ip core, which does not
have to be duplicated for each board using PIO.

Joachim Foerster (2):
  gpio: Add driver for Altera's PIO core
  board/nios2-generic: Use altera_pio driver and remove board specific
    driver

 arch/nios2/include/asm/gpio.h              |   13 +-
 board/altera/nios2-generic/Makefile        |    1 -
 board/altera/nios2-generic/custom_fpga.h   |    1 +
 board/altera/nios2-generic/gpio.c          |   71 -------
 board/altera/nios2-generic/nios2-generic.c |    8 +
 drivers/gpio/Makefile                      |    1 +
 drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
 include/configs/nios2-generic.h            |    4 +
 8 files changed, 324 insertions(+), 74 deletions(-)
 delete mode 100644 board/altera/nios2-generic/gpio.c
 create mode 100644 drivers/gpio/altera_pio.c

-- 
1.7.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core
  2011-10-17 15:36 [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
@ 2011-10-17 15:36 ` Joachim Foerster
  2011-10-21  7:21   ` Thomas Chou
  2011-10-17 15:36 ` [U-Boot] [PATCH 2/2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
  1 sibling, 1 reply; 10+ messages in thread
From: Joachim Foerster @ 2011-10-17 15:36 UTC (permalink / raw)
  To: u-boot

This driver may handle multiple PIO cores and thus needs to be
setup by calling the altera_pio_init() function within the early
board setup routine.

The driver comes with some extras, see below the copyleft header.

Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
---
 arch/nios2/include/asm/gpio.h              |   13 +-
 board/altera/nios2-generic/custom_fpga.h   |    1 +
 board/altera/nios2-generic/nios2-generic.c |    8 +
 drivers/gpio/Makefile                      |    1 +
 drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
 5 files changed, 320 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpio/altera_pio.c

diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h
index 4b21c8f..908381f 100644
--- a/arch/nios2/include/asm/gpio.h
+++ b/arch/nios2/include/asm/gpio.h
@@ -5,8 +5,8 @@
  * bit[0] data
  * bit[1] output enable
  *
- * when CONFIG_SYS_GPIO_BASE is not defined, board may provide
- * its own driver.
+ * When CONFIG_SYS_GPIO_BASE is not defined, the board may either
+ * provide its own driver or the altera_pio driver may be used.
  *
  * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
  *
@@ -58,6 +58,15 @@ static inline int gpio_is_valid(int number)
 	return ((unsigned)number) < CONFIG_SYS_GPIO_WIDTH;
 }
 #else
+#ifdef CONFIG_ALTERA_PIO
+extern int altera_pio_init(u32 base, u8 width, char iot,
+			   u32 rstval, u32 negmask,
+			   const char *label);
+
+extern void altera_pio_info(void);
+#define gpio_status() altera_pio_info()
+#endif
+
 extern int gpio_request(unsigned gpio, const char *label);
 extern int gpio_free(unsigned gpio);
 extern int gpio_direction_input(unsigned gpio);
diff --git a/board/altera/nios2-generic/custom_fpga.h b/board/altera/nios2-generic/custom_fpga.h
index f7f3853..fd3ec9a 100644
--- a/board/altera/nios2-generic/custom_fpga.h
+++ b/board/altera/nios2-generic/custom_fpga.h
@@ -51,6 +51,7 @@
 /* led_pio.s1 is a altera_avalon_pio */
 #define LED_PIO_BASE 0x82120870
 #define LED_PIO_WIDTH 8
+#define LED_PIO_RSTVAL 0x0
 
 /* high_res_timer.s1 is a altera_avalon_timer */
 #define CONFIG_SYS_TIMER_BASE 0x82120820
diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c
index 49ef80d..0f88275 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -26,6 +26,7 @@
 #include <netdev.h>
 #include <mtd/cfi_flash.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 
 void text_base_hook(void); /* nop hook for text_base.S */
 
@@ -43,6 +44,13 @@ void early_flash_cmd_reset(void)
 int board_early_init_f(void)
 {
 	text_base_hook();
+#ifdef CONFIG_ALTERA_PIO
+#ifdef LED_PIO_BASE
+	altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
+			LED_PIO_RSTVAL, (1 << LED_PIO_WIDTH) - 1,
+			"led");
+#endif
+#endif
 #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
 	early_flash_cmd_reset();
 #endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index beca1da..c874b1a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -34,6 +34,7 @@ COBJS-$(CONFIG_PCA953X)		+= pca953x.o
 COBJS-$(CONFIG_S5P)		+= s5p_gpio.o
 COBJS-$(CONFIG_TEGRA2_GPIO)	+= tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO)	+= da8xx_gpio.o
+COBJS-$(CONFIG_ALTERA_PIO)	+= altera_pio.o
 
 COBJS	:= $(COBJS-y)
 SRCS 	:= $(COBJS:.o=.c)
diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
new file mode 100644
index 0000000..1b8c19c
--- /dev/null
+++ b/drivers/gpio/altera_pio.c
@@ -0,0 +1,299 @@
+/*
+ * Driver for Altera's PIO ip core
+ *
+ * Copyright (C) 2011  Missing Link Electronics
+ *                     Joachim Foerster <joachim@missinglinkelectronics.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * To use this driver, in your board's config. header:
+ * #define CONFIG_ALTERA_PIO
+ * #define CONFIG_SYS_ALTERA_PIO_NUM <number-of-pio-cores>
+ * #define CONFIG_SYS_ALTERA_PIO_GPIO_NUM <total-number-of-gpios>
+ * And in your board's early setup routine:
+ * altera_pio_init(<baseaddr>, <width>, 'i'|'o'|'t',
+ *                 <reset-value>, <neg-mask>, "label");
+ *  - 'i'|'o'|'t': PIO is input-only/output-only/tri-state
+ *  - <reset-value>: for correct initial status display, output-only
+ *  - <neg-mask> is meant to be used to in cases of active-low
+ *    GPIOs, such as LEDs and buttons (on/pressed == 0). Each bit
+ *    which is 1 in <neg-mask> inverts the corresponding GPIO's value
+ *    before set/after get. So: gpio_set_value(gpio, 1) => LED on .
+ *
+ * Do NOT define CONFIG_SYS_GPIO_BASE !
+ *
+ * Optionally, in your board's config. header:
+ * - To force a GPIO numbering scheme like in Linux ...
+ * #define CONFIG_GPIO_DOWNTO_NUMBERING
+ * ... starting with 255 (default)
+ * #define CONFIG_GPIO_DOWNTO_MAX 255
+ */
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+#ifdef CONFIG_GPIO_DOWNTO_NUMBERING
+#ifndef CONFIG_GPIO_DOWNTO_MAX
+#define CONFIG_GPIO_DOWNTO_MAX 255
+#endif
+#endif
+
+#define ALTERA_PIO_DATA		0x0
+#define ALTERA_PIO_DIR		0x4
+
+#define GPIO_LABEL_SIZE		9
+
+
+static struct altera_pio {
+	u32 base;
+	u8 width;
+	char iot;
+	u32 negmask;
+	u32 sh_data;
+	u32 sh_dir;
+	int gidx;
+	char label[GPIO_LABEL_SIZE];
+} pios[CONFIG_SYS_ALTERA_PIO_NUM];
+
+static int pio_num = 0;
+
+static struct altera_pio_gpio {
+	unsigned num;
+	struct altera_pio *pio;
+	char reqlabel[GPIO_LABEL_SIZE];
+} gpios[CONFIG_SYS_ALTERA_PIO_GPIO_NUM];
+
+static int pio_gpio_num = 0;
+
+
+static int altera_pio_gidx(unsigned gpio)
+{
+	int i;
+
+	for (i = 0; i < pio_gpio_num; ++i) {
+		if (gpio == gpios[i].num)
+			break;
+	}
+	if (i >= pio_gpio_num)
+		return -1;
+	return i;
+}
+
+static struct altera_pio *altera_pio_get_and_mask(unsigned gpio, u32 *mask)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return NULL;
+	if (mask)
+		*mask = 1 << (gidx - gpios[gidx].pio->gidx);
+	return gpios[gidx].pio;
+}
+
+#define altera_pio_use_gidx(_gidx, _reqlabel) \
+	{ strncpy(gpios[_gidx].reqlabel, _reqlabel, GPIO_LABEL_SIZE); }
+#define altera_pio_unuse_gidx(_gidx) { gpios[_gidx].reqlabel[0] = '\0'; }
+#define altera_pio_is_gidx_used(_gidx) (gpios[_gidx].reqlabel[0] != '\0')
+
+static int altera_pio_gpio_init(struct altera_pio *pio, u8 width)
+{
+	u8 gidx = pio_gpio_num;
+	int i;
+
+	if (!width)
+		return -1;
+	if ((pio_gpio_num + width) > CONFIG_SYS_ALTERA_PIO_GPIO_NUM)
+		return -1;
+
+	for (i = 0; i < width; ++i) {
+#ifdef CONFIG_GPIO_DOWNTO_NUMBERING
+		gpios[pio_gpio_num + i].num = \
+			CONFIG_GPIO_DOWNTO_MAX + 1 - gidx - width + i;
+#else
+		gpios[pio_gpio_num + i].num = pio_gpio_num + i;
+#endif
+		gpios[pio_gpio_num + i].pio = pio;
+		altera_pio_unuse_gidx(pio_gpio_num + i);
+	}
+	pio_gpio_num += width;
+	return gidx;
+}
+
+int altera_pio_init(u32 base, u8 width, char iot, u32 rstval, u32 negmask,
+		 const char *label)
+{
+	if (pio_num >= CONFIG_SYS_ALTERA_PIO_NUM)
+		return -1;
+
+	pios[pio_num].base = base;
+	pios[pio_num].width = width;
+	pios[pio_num].iot = iot;
+	switch (iot) {
+	case 'i':
+		/* input only */
+		pios[pio_num].sh_dir = 0;
+		pios[pio_num].sh_data = readl(base + ALTERA_PIO_DATA);
+		break;
+	case 'o':
+		/* output only */
+		pios[pio_num].sh_dir = 0xffffffff & ((1 << width) - 1);
+		pios[pio_num].sh_data = rstval;
+		break;
+	case 't':
+		/* bidir, tri-state */
+		pios[pio_num].sh_dir = readl(base + ALTERA_PIO_DIR);
+		pios[pio_num].sh_data = readl(base + ALTERA_PIO_DATA);
+		break;
+	default:
+		return -1;
+	}
+	pios[pio_num].negmask = negmask & ((1 << width) - 1);
+	pios[pio_num].gidx = altera_pio_gpio_init(&pios[pio_num], width);
+	if (pios[pio_num].gidx < 0)
+		return -1;
+	strncpy(pios[pio_num].label, label, GPIO_LABEL_SIZE);
+	return pio_num++;
+}
+
+void altera_pio_info(void)
+{
+	int i;
+	int j;
+	int gidx;
+	u32 mask;
+
+	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 % 4u: %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);
+		}
+	}
+}
+
+
+int gpio_request(unsigned gpio, const char *label)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return gidx;
+	if (altera_pio_is_gidx_used(gidx))
+		return -1;
+
+	altera_pio_use_gidx(gidx, label);
+	return 0;
+}
+
+int gpio_free(unsigned gpio)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return gidx;
+	if (!altera_pio_is_gidx_used(gidx))
+		return -1;
+
+	altera_pio_unuse_gidx(gidx);
+	return 0;
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+	if (pio->iot == 'o')
+		return -1;
+
+	writel(pio->sh_dir &= ~mask, pio->base + ALTERA_PIO_DIR);
+	return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+	if (pio->iot == 'i')
+		return -1;
+
+	value = (pio->negmask & mask) ? !value : value;
+	if (value)
+		pio->sh_data |= mask;
+	else
+		pio->sh_data &= ~mask;
+	writel(pio->sh_data, pio->base + ALTERA_PIO_DATA);
+	writel(pio->sh_dir |= mask, pio->base + ALTERA_PIO_DIR);
+	return 0;
+}
+
+int gpio_get_value(unsigned gpio)
+{
+	u32 mask;
+	struct altera_pio *pio;
+	u32 val;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+
+	if ((pio->sh_dir & mask) || (pio->iot == 'o'))
+		val = pio->sh_data & mask;
+	else
+		val = readl(pio->base + ALTERA_PIO_DATA) & mask;
+	return (pio->negmask & mask) ? !val : val;
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return;
+	if (pio->iot == 'i')
+		return;
+
+	value = (pio->negmask & mask) ? !value : value;
+	if (value)
+		pio->sh_data |= mask;
+	else
+		pio->sh_data &= ~mask;
+	writel(pio->sh_data, pio->base + ALTERA_PIO_DATA);
+	return;
+}
+
+int gpio_is_valid(int number)
+{
+	int gidx = altera_pio_gidx(number);
+
+	if (gidx < 0)
+		return 1;
+	return 0;
+}
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/2] board/nios2-generic: Use altera_pio driver and remove board specific driver
  2011-10-17 15:36 [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
  2011-10-17 15:36 ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
@ 2011-10-17 15:36 ` Joachim Foerster
  1 sibling, 0 replies; 10+ messages in thread
From: Joachim Foerster @ 2011-10-17 15:36 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
---
 board/altera/nios2-generic/Makefile |    1 -
 board/altera/nios2-generic/gpio.c   |   71 -----------------------------------
 include/configs/nios2-generic.h     |    4 ++
 3 files changed, 4 insertions(+), 72 deletions(-)
 delete mode 100644 board/altera/nios2-generic/gpio.c

diff --git a/board/altera/nios2-generic/Makefile b/board/altera/nios2-generic/Makefile
index 359f590..59fd465 100644
--- a/board/altera/nios2-generic/Makefile
+++ b/board/altera/nios2-generic/Makefile
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).o
 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
deleted file mode 100644
index 4a30564..0000000
--- a/board/altera/nios2-generic/gpio.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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_WIDTH LED_PIO_WIDTH
-#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_request(unsigned gpio, const char *label)
-{
-	return 0;
-}
-
-int gpio_free(unsigned gpio)
-{
-	return 0;
-}
-
-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);
-}
-
-int gpio_is_valid(int number)
-{
-	return ((unsigned)number) < ALTERA_PIO_WIDTH;
-}
-#endif
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 1395939..9ba35e8 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -63,6 +63,10 @@
 /*
  * STATUS LED
  */
+#define CONFIG_ALTERA_PIO
+#define CONFIG_SYS_ALTERA_PIO_NUM	1
+#define CONFIG_SYS_ALTERA_PIO_GPIO_NUM	LED_PIO_WIDTH
+
 #define CONFIG_STATUS_LED		/* Enable status driver */
 #define CONFIG_GPIO_LED		/* Enable GPIO LED driver */
 #define CONFIG_GPIO			/* Enable GPIO driver */
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core
  2011-10-17 15:36 ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
@ 2011-10-21  7:21   ` Thomas Chou
  2011-10-21 13:48     ` [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
  2011-10-21 13:49     ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Chou @ 2011-10-21  7:21 UTC (permalink / raw)
  To: u-boot

On 10/17/2011 11:36 PM, Joachim Foerster wrote:
> This driver may handle multiple PIO cores and thus needs to be
> setup by calling the altera_pio_init() function within the early
> board setup routine.
>
> The driver comes with some extras, see below the copyleft header.
>
> Signed-off-by: Joachim Foerster<joachim.foerster@missinglinkelectronics.com>
> ---
>   arch/nios2/include/asm/gpio.h              |   13 +-
>   board/altera/nios2-generic/custom_fpga.h   |    1 +
>   board/altera/nios2-generic/nios2-generic.c |    8 +
>   drivers/gpio/Makefile                      |    1 +
>   drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
>   5 files changed, 320 insertions(+), 2 deletions(-)
>   create mode 100644 drivers/gpio/altera_pio.c

Hi Joachim,

Please fix these warning. Thanks.

$ ./MAKEALL nios2-generic
Configuring for nios2-generic board...
altera_pio.c: In function `altera_pio_info':
altera_pio.c:189: warning: ` ' flag used with `%u' printf format

checkpatch.pl

ERROR: do not initialise statics to 0 or NULL
#209: FILE: drivers/gpio/altera_pio.c:71:
+static int pio_num = 0;

ERROR: do not initialise statics to 0 or NULL
#217: FILE: drivers/gpio/altera_pio.c:79:
+static int pio_gpio_num = 0;


Otherwise,
Tested-by: Thomas Chou <thomas@wytron.com.tw>

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver.
  2011-10-21  7:21   ` Thomas Chou
@ 2011-10-21 13:48     ` Joachim Foerster
  2011-10-21 13:48       ` [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core Joachim Foerster
  2011-10-21 13:48       ` [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
  2011-10-21 13:49     ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
  1 sibling, 2 replies; 10+ messages in thread
From: Joachim Foerster @ 2011-10-21 13:48 UTC (permalink / raw)
  To: u-boot

Let's have a dedicated driver for Altera's PIO ip core, which does not
have to be duplicated for each board using PIO.

Joachim Foerster (2):
  gpio: Add driver for Altera's PIO core
  board/nios2-generic: Use altera_pio driver and remove board specific
    driver

Changes for v2:
	PATCH 1/2:
	- get rid of checkpatch warnings about init.ing static
	- use %d instead of %u together the usage of the space-flag
	PATCH 2/2:
	nothing

 arch/nios2/include/asm/gpio.h              |   13 +-
 board/altera/nios2-generic/Makefile        |    1 -
 board/altera/nios2-generic/custom_fpga.h   |    1 +
 board/altera/nios2-generic/gpio.c          |   71 -------
 board/altera/nios2-generic/nios2-generic.c |    8 +
 drivers/gpio/Makefile                      |    1 +
 drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
 include/configs/nios2-generic.h            |    4 +
 8 files changed, 324 insertions(+), 74 deletions(-)
 delete mode 100644 board/altera/nios2-generic/gpio.c
 create mode 100644 drivers/gpio/altera_pio.c

-- 
1.7.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core
  2011-10-21 13:48     ` [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
@ 2011-10-21 13:48       ` Joachim Foerster
  2011-10-28  7:29         ` Thomas Chou
  2011-10-21 13:48       ` [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
  1 sibling, 1 reply; 10+ messages in thread
From: Joachim Foerster @ 2011-10-21 13:48 UTC (permalink / raw)
  To: u-boot

This driver may handle multiple PIO cores and thus needs to be
setup by calling the altera_pio_init() function within the early
board setup routine.

The driver comes with some extras, see below the copyleft header.

Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
Tested-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/include/asm/gpio.h              |   13 +-
 board/altera/nios2-generic/custom_fpga.h   |    1 +
 board/altera/nios2-generic/nios2-generic.c |    8 +
 drivers/gpio/Makefile                      |    1 +
 drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
 5 files changed, 320 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpio/altera_pio.c

diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h
index 4b21c8f..908381f 100644
--- a/arch/nios2/include/asm/gpio.h
+++ b/arch/nios2/include/asm/gpio.h
@@ -5,8 +5,8 @@
  * bit[0] data
  * bit[1] output enable
  *
- * when CONFIG_SYS_GPIO_BASE is not defined, board may provide
- * its own driver.
+ * When CONFIG_SYS_GPIO_BASE is not defined, the board may either
+ * provide its own driver or the altera_pio driver may be used.
  *
  * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
  *
@@ -58,6 +58,15 @@ static inline int gpio_is_valid(int number)
 	return ((unsigned)number) < CONFIG_SYS_GPIO_WIDTH;
 }
 #else
+#ifdef CONFIG_ALTERA_PIO
+extern int altera_pio_init(u32 base, u8 width, char iot,
+			   u32 rstval, u32 negmask,
+			   const char *label);
+
+extern void altera_pio_info(void);
+#define gpio_status() altera_pio_info()
+#endif
+
 extern int gpio_request(unsigned gpio, const char *label);
 extern int gpio_free(unsigned gpio);
 extern int gpio_direction_input(unsigned gpio);
diff --git a/board/altera/nios2-generic/custom_fpga.h b/board/altera/nios2-generic/custom_fpga.h
index f7f3853..fd3ec9a 100644
--- a/board/altera/nios2-generic/custom_fpga.h
+++ b/board/altera/nios2-generic/custom_fpga.h
@@ -51,6 +51,7 @@
 /* led_pio.s1 is a altera_avalon_pio */
 #define LED_PIO_BASE 0x82120870
 #define LED_PIO_WIDTH 8
+#define LED_PIO_RSTVAL 0x0
 
 /* high_res_timer.s1 is a altera_avalon_timer */
 #define CONFIG_SYS_TIMER_BASE 0x82120820
diff --git a/board/altera/nios2-generic/nios2-generic.c b/board/altera/nios2-generic/nios2-generic.c
index 49ef80d..0f88275 100644
--- a/board/altera/nios2-generic/nios2-generic.c
+++ b/board/altera/nios2-generic/nios2-generic.c
@@ -26,6 +26,7 @@
 #include <netdev.h>
 #include <mtd/cfi_flash.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 
 void text_base_hook(void); /* nop hook for text_base.S */
 
@@ -43,6 +44,13 @@ void early_flash_cmd_reset(void)
 int board_early_init_f(void)
 {
 	text_base_hook();
+#ifdef CONFIG_ALTERA_PIO
+#ifdef LED_PIO_BASE
+	altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
+			LED_PIO_RSTVAL, (1 << LED_PIO_WIDTH) - 1,
+			"led");
+#endif
+#endif
 #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
 	early_flash_cmd_reset();
 #endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index beca1da..c874b1a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -34,6 +34,7 @@ COBJS-$(CONFIG_PCA953X)		+= pca953x.o
 COBJS-$(CONFIG_S5P)		+= s5p_gpio.o
 COBJS-$(CONFIG_TEGRA2_GPIO)	+= tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO)	+= da8xx_gpio.o
+COBJS-$(CONFIG_ALTERA_PIO)	+= altera_pio.o
 
 COBJS	:= $(COBJS-y)
 SRCS 	:= $(COBJS:.o=.c)
diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
new file mode 100644
index 0000000..fb03760
--- /dev/null
+++ b/drivers/gpio/altera_pio.c
@@ -0,0 +1,299 @@
+/*
+ * Driver for Altera's PIO ip core
+ *
+ * Copyright (C) 2011  Missing Link Electronics
+ *                     Joachim Foerster <joachim@missinglinkelectronics.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * To use this driver, in your board's config. header:
+ * #define CONFIG_ALTERA_PIO
+ * #define CONFIG_SYS_ALTERA_PIO_NUM <number-of-pio-cores>
+ * #define CONFIG_SYS_ALTERA_PIO_GPIO_NUM <total-number-of-gpios>
+ * And in your board's early setup routine:
+ * altera_pio_init(<baseaddr>, <width>, 'i'|'o'|'t',
+ *                 <reset-value>, <neg-mask>, "label");
+ *  - 'i'|'o'|'t': PIO is input-only/output-only/tri-state
+ *  - <reset-value>: for correct initial status display, output-only
+ *  - <neg-mask> is meant to be used to in cases of active-low
+ *    GPIOs, such as LEDs and buttons (on/pressed == 0). Each bit
+ *    which is 1 in <neg-mask> inverts the corresponding GPIO's value
+ *    before set/after get. So: gpio_set_value(gpio, 1) => LED on .
+ *
+ * Do NOT define CONFIG_SYS_GPIO_BASE !
+ *
+ * Optionally, in your board's config. header:
+ * - To force a GPIO numbering scheme like in Linux ...
+ * #define CONFIG_GPIO_DOWNTO_NUMBERING
+ * ... starting with 255 (default)
+ * #define CONFIG_GPIO_DOWNTO_MAX 255
+ */
+#include <common.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+#ifdef CONFIG_GPIO_DOWNTO_NUMBERING
+#ifndef CONFIG_GPIO_DOWNTO_MAX
+#define CONFIG_GPIO_DOWNTO_MAX 255
+#endif
+#endif
+
+#define ALTERA_PIO_DATA		0x0
+#define ALTERA_PIO_DIR		0x4
+
+#define GPIO_LABEL_SIZE		9
+
+
+static struct altera_pio {
+	u32 base;
+	u8 width;
+	char iot;
+	u32 negmask;
+	u32 sh_data;
+	u32 sh_dir;
+	int gidx;
+	char label[GPIO_LABEL_SIZE];
+} pios[CONFIG_SYS_ALTERA_PIO_NUM];
+
+static int pio_num;
+
+static struct altera_pio_gpio {
+	unsigned num;
+	struct altera_pio *pio;
+	char reqlabel[GPIO_LABEL_SIZE];
+} gpios[CONFIG_SYS_ALTERA_PIO_GPIO_NUM];
+
+static int pio_gpio_num;
+
+
+static int altera_pio_gidx(unsigned gpio)
+{
+	int i;
+
+	for (i = 0; i < pio_gpio_num; ++i) {
+		if (gpio == gpios[i].num)
+			break;
+	}
+	if (i >= pio_gpio_num)
+		return -1;
+	return i;
+}
+
+static struct altera_pio *altera_pio_get_and_mask(unsigned gpio, u32 *mask)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return NULL;
+	if (mask)
+		*mask = 1 << (gidx - gpios[gidx].pio->gidx);
+	return gpios[gidx].pio;
+}
+
+#define altera_pio_use_gidx(_gidx, _reqlabel) \
+	{ strncpy(gpios[_gidx].reqlabel, _reqlabel, GPIO_LABEL_SIZE); }
+#define altera_pio_unuse_gidx(_gidx) { gpios[_gidx].reqlabel[0] = '\0'; }
+#define altera_pio_is_gidx_used(_gidx) (gpios[_gidx].reqlabel[0] != '\0')
+
+static int altera_pio_gpio_init(struct altera_pio *pio, u8 width)
+{
+	u8 gidx = pio_gpio_num;
+	int i;
+
+	if (!width)
+		return -1;
+	if ((pio_gpio_num + width) > CONFIG_SYS_ALTERA_PIO_GPIO_NUM)
+		return -1;
+
+	for (i = 0; i < width; ++i) {
+#ifdef CONFIG_GPIO_DOWNTO_NUMBERING
+		gpios[pio_gpio_num + i].num = \
+			CONFIG_GPIO_DOWNTO_MAX + 1 - gidx - width + i;
+#else
+		gpios[pio_gpio_num + i].num = pio_gpio_num + i;
+#endif
+		gpios[pio_gpio_num + i].pio = pio;
+		altera_pio_unuse_gidx(pio_gpio_num + i);
+	}
+	pio_gpio_num += width;
+	return gidx;
+}
+
+int altera_pio_init(u32 base, u8 width, char iot, u32 rstval, u32 negmask,
+		 const char *label)
+{
+	if (pio_num >= CONFIG_SYS_ALTERA_PIO_NUM)
+		return -1;
+
+	pios[pio_num].base = base;
+	pios[pio_num].width = width;
+	pios[pio_num].iot = iot;
+	switch (iot) {
+	case 'i':
+		/* input only */
+		pios[pio_num].sh_dir = 0;
+		pios[pio_num].sh_data = readl(base + ALTERA_PIO_DATA);
+		break;
+	case 'o':
+		/* output only */
+		pios[pio_num].sh_dir = 0xffffffff & ((1 << width) - 1);
+		pios[pio_num].sh_data = rstval;
+		break;
+	case 't':
+		/* bidir, tri-state */
+		pios[pio_num].sh_dir = readl(base + ALTERA_PIO_DIR);
+		pios[pio_num].sh_data = readl(base + ALTERA_PIO_DATA);
+		break;
+	default:
+		return -1;
+	}
+	pios[pio_num].negmask = negmask & ((1 << width) - 1);
+	pios[pio_num].gidx = altera_pio_gpio_init(&pios[pio_num], width);
+	if (pios[pio_num].gidx < 0)
+		return -1;
+	strncpy(pios[pio_num].label, label, GPIO_LABEL_SIZE);
+	return pio_num++;
+}
+
+void altera_pio_info(void)
+{
+	int i;
+	int j;
+	int gidx;
+	u32 mask;
+
+	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);
+		}
+	}
+}
+
+
+int gpio_request(unsigned gpio, const char *label)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return gidx;
+	if (altera_pio_is_gidx_used(gidx))
+		return -1;
+
+	altera_pio_use_gidx(gidx, label);
+	return 0;
+}
+
+int gpio_free(unsigned gpio)
+{
+	int gidx = altera_pio_gidx(gpio);
+	if (gidx < 0)
+		return gidx;
+	if (!altera_pio_is_gidx_used(gidx))
+		return -1;
+
+	altera_pio_unuse_gidx(gidx);
+	return 0;
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+	if (pio->iot == 'o')
+		return -1;
+
+	writel(pio->sh_dir &= ~mask, pio->base + ALTERA_PIO_DIR);
+	return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+	if (pio->iot == 'i')
+		return -1;
+
+	value = (pio->negmask & mask) ? !value : value;
+	if (value)
+		pio->sh_data |= mask;
+	else
+		pio->sh_data &= ~mask;
+	writel(pio->sh_data, pio->base + ALTERA_PIO_DATA);
+	writel(pio->sh_dir |= mask, pio->base + ALTERA_PIO_DIR);
+	return 0;
+}
+
+int gpio_get_value(unsigned gpio)
+{
+	u32 mask;
+	struct altera_pio *pio;
+	u32 val;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return -1;
+
+	if ((pio->sh_dir & mask) || (pio->iot == 'o'))
+		val = pio->sh_data & mask;
+	else
+		val = readl(pio->base + ALTERA_PIO_DATA) & mask;
+	return (pio->negmask & mask) ? !val : val;
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+	u32 mask;
+	struct altera_pio *pio;
+
+	pio = altera_pio_get_and_mask(gpio, &mask);
+	if (!pio)
+		return;
+	if (pio->iot == 'i')
+		return;
+
+	value = (pio->negmask & mask) ? !value : value;
+	if (value)
+		pio->sh_data |= mask;
+	else
+		pio->sh_data &= ~mask;
+	writel(pio->sh_data, pio->base + ALTERA_PIO_DATA);
+	return;
+}
+
+int gpio_is_valid(int number)
+{
+	int gidx = altera_pio_gidx(number);
+
+	if (gidx < 0)
+		return 1;
+	return 0;
+}
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver
  2011-10-21 13:48     ` [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
  2011-10-21 13:48       ` [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core Joachim Foerster
@ 2011-10-21 13:48       ` Joachim Foerster
  2011-10-28  7:29         ` Thomas Chou
  1 sibling, 1 reply; 10+ messages in thread
From: Joachim Foerster @ 2011-10-21 13:48 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Joachim Foerster <joachim.foerster@missinglinkelectronics.com>
---
 board/altera/nios2-generic/Makefile |    1 -
 board/altera/nios2-generic/gpio.c   |   71 -----------------------------------
 include/configs/nios2-generic.h     |    4 ++
 3 files changed, 4 insertions(+), 72 deletions(-)
 delete mode 100644 board/altera/nios2-generic/gpio.c

diff --git a/board/altera/nios2-generic/Makefile b/board/altera/nios2-generic/Makefile
index 359f590..59fd465 100644
--- a/board/altera/nios2-generic/Makefile
+++ b/board/altera/nios2-generic/Makefile
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).o
 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
deleted file mode 100644
index 4a30564..0000000
--- a/board/altera/nios2-generic/gpio.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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_WIDTH LED_PIO_WIDTH
-#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_request(unsigned gpio, const char *label)
-{
-	return 0;
-}
-
-int gpio_free(unsigned gpio)
-{
-	return 0;
-}
-
-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);
-}
-
-int gpio_is_valid(int number)
-{
-	return ((unsigned)number) < ALTERA_PIO_WIDTH;
-}
-#endif
diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h
index 1395939..9ba35e8 100644
--- a/include/configs/nios2-generic.h
+++ b/include/configs/nios2-generic.h
@@ -63,6 +63,10 @@
 /*
  * STATUS LED
  */
+#define CONFIG_ALTERA_PIO
+#define CONFIG_SYS_ALTERA_PIO_NUM	1
+#define CONFIG_SYS_ALTERA_PIO_GPIO_NUM	LED_PIO_WIDTH
+
 #define CONFIG_STATUS_LED		/* Enable status driver */
 #define CONFIG_GPIO_LED		/* Enable GPIO LED driver */
 #define CONFIG_GPIO			/* Enable GPIO driver */
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core
  2011-10-21  7:21   ` Thomas Chou
  2011-10-21 13:48     ` [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
@ 2011-10-21 13:49     ` Joachim Foerster
  1 sibling, 0 replies; 10+ messages in thread
From: Joachim Foerster @ 2011-10-21 13:49 UTC (permalink / raw)
  To: u-boot

On 10/21/2011 09:21 AM, Thomas Chou wrote:
> On 10/17/2011 11:36 PM, Joachim Foerster wrote:
>> This driver may handle multiple PIO cores and thus needs to be
>> setup by calling the altera_pio_init() function within the early
>> board setup routine.
>>
>> The driver comes with some extras, see below the copyleft header.
>>
>> Signed-off-by: Joachim
>> Foerster<joachim.foerster@missinglinkelectronics.com>
>> ---
>> arch/nios2/include/asm/gpio.h | 13 +-
>> board/altera/nios2-generic/custom_fpga.h | 1 +
>> board/altera/nios2-generic/nios2-generic.c | 8 +
>> drivers/gpio/Makefile | 1 +
>> drivers/gpio/altera_pio.c | 299 ++++++++++++++++++++++++++++
>> 5 files changed, 320 insertions(+), 2 deletions(-)
>> create mode 100644 drivers/gpio/altera_pio.c
>
> Hi Joachim,
>
> Please fix these warning. Thanks.
>
> $ ./MAKEALL nios2-generic
> Configuring for nios2-generic board...
> altera_pio.c: In function `altera_pio_info':
> altera_pio.c:189: warning: ` ' flag used with `%u' printf format

Ok, I'll use %d - in this case it is the same. Does anybody know why %u 
warns about space-flag usage? Is space-flag + %u indeed evil ?

> Otherwise,
> Tested-by: Thomas Chou <thomas@wytron.com.tw>
>
> Best regards,
> Thomas

Thanks for reviewing.

-- 
Joachim Foerster

Missing Link Electronics
http://www.missinglinkelectronics.com
Office EU: +49 (731) 141-149-0
Office US: +1  (408) 457-0700
email: joachim.foerster at missinglinkelectronics.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core
  2011-10-21 13:48       ` [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core Joachim Foerster
@ 2011-10-28  7:29         ` Thomas Chou
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Chou @ 2011-10-28  7:29 UTC (permalink / raw)
  To: u-boot

On 10/21/2011 09:48 PM, Joachim Foerster wrote:
> This driver may handle multiple PIO cores and thus needs to be
> setup by calling the altera_pio_init() function within the early
> board setup routine.
>
> The driver comes with some extras, see below the copyleft header.
>
> Signed-off-by: Joachim Foerster<joachim.foerster@missinglinkelectronics.com>
> Tested-by: Thomas Chou<thomas@wytron.com.tw>
> ---
>   arch/nios2/include/asm/gpio.h              |   13 +-
>   board/altera/nios2-generic/custom_fpga.h   |    1 +
>   board/altera/nios2-generic/nios2-generic.c |    8 +
>   drivers/gpio/Makefile                      |    1 +
>   drivers/gpio/altera_pio.c                  |  299 ++++++++++++++++++++++++++++
>   5 files changed, 320 insertions(+), 2 deletions(-)
>   create mode 100644 drivers/gpio/altera_pio.c

Hi Joachim,

Applied. Thanks.

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver
  2011-10-21 13:48       ` [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
@ 2011-10-28  7:29         ` Thomas Chou
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Chou @ 2011-10-28  7:29 UTC (permalink / raw)
  To: u-boot

On 10/21/2011 09:48 PM, Joachim Foerster wrote:
> Signed-off-by: Joachim Foerster<joachim.foerster@missinglinkelectronics.com>
> ---
>   board/altera/nios2-generic/Makefile |    1 -
>   board/altera/nios2-generic/gpio.c   |   71 -----------------------------------
>   include/configs/nios2-generic.h     |    4 ++
>   3 files changed, 4 insertions(+), 72 deletions(-)
>   delete mode 100644 board/altera/nios2-generic/gpio.c

Hi Joachim,

Applied. Thanks.

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-10-28  7:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17 15:36 [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
2011-10-17 15:36 ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
2011-10-21  7:21   ` Thomas Chou
2011-10-21 13:48     ` [U-Boot] [PATCH 0/2] Replace nios2-generic's gpio.c with dedicated driver Joachim Foerster
2011-10-21 13:48       ` [U-Boot] [PATCH 1/2 v2] gpio: Add driver for Altera's PIO core Joachim Foerster
2011-10-28  7:29         ` Thomas Chou
2011-10-21 13:48       ` [U-Boot] [PATCH 2/2 v2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster
2011-10-28  7:29         ` Thomas Chou
2011-10-21 13:49     ` [U-Boot] [PATCH 1/2] gpio: Add driver for Altera's PIO core Joachim Foerster
2011-10-17 15:36 ` [U-Boot] [PATCH 2/2] board/nios2-generic: Use altera_pio driver and remove board specific driver Joachim Foerster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.