From 03d67e127685f65513e7b78dacbd4ccaf01053f6 Mon Sep 17 00:00:00 2001 From: Joachim Foerster Date: Fri, 21 Oct 2011 15:48:50 +0200 Subject: gpio: Add driver for Altera's PIO core 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 Tested-by: Thomas Chou Signed-off-by: Thomas Chou --- board/altera/nios2-generic/custom_fpga.h | 1 + board/altera/nios2-generic/nios2-generic.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'board') 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 #include #include +#include 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 -- cgit v1.1