From e91d54535f8535c6de05044fa6f715a78f4320f8 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Fri, 24 Dec 2010 15:19:44 +0800 Subject: [PATCH 1/4] nios2: add gpio_free Signed-off-by: Thomas Chou Signed-off-by: Scott McNutt --- arch/nios2/include/asm/gpio.h | 6 ++++++ board/altera/nios2-generic/gpio.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h index cff1dd9a1..36a71324d 100644 --- a/arch/nios2/include/asm/gpio.h +++ b/arch/nios2/include/asm/gpio.h @@ -26,6 +26,11 @@ static inline int gpio_request(unsigned gpio, const char *label) return 0; } +static inline int gpio_free(unsigned gpio) +{ + return 0; +} + static inline int gpio_direction_input(unsigned gpio) { writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2)); @@ -49,6 +54,7 @@ static inline void gpio_set_value(unsigned gpio, int value) } #else extern int gpio_request(unsigned gpio, const char *label); +extern int gpio_free(unsigned gpio); extern int gpio_direction_input(unsigned gpio); extern int gpio_direction_output(unsigned gpio, int value); extern int gpio_get_value(unsigned gpio); diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c index d4496843f..8c639ce36 100644 --- a/board/altera/nios2-generic/gpio.c +++ b/board/altera/nios2-generic/gpio.c @@ -20,6 +20,11 @@ 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; From df8f1252612b641bc2697163576902f9927d4af3 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Mon, 27 Dec 2010 09:30:17 +0800 Subject: [PATCH 2/4] altera_spi: add spi_set_speed Added this for mmc_spi driver. Though altera spi core does not support programmable speed. It is fixed when configured in sopc-builder. Signed-off-by: Thomas Chou Signed-off-by: Scott McNutt --- drivers/spi/altera_spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 918b22356..138d6f4b4 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -70,6 +70,11 @@ void spi_init(void) { } +void spi_set_speed(struct spi_slave *slave, uint hz) +{ + /* altera spi core does not support programmable speed */ +} + struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int mode) { From 85debefaf2d3d0dea800fa84bfe0e9823bc03d89 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Mon, 27 Dec 2010 10:45:34 +0800 Subject: [PATCH 3/4] nios2: use long for ssize_t This is consistent with nios2-linux. And resolved the warning, cmd_nvedit.c: In function `do_env_export': cmd_nvedit.c:660: warning: size_t format, ssize_t arg (arg 3) Signed-off-by: Thomas Chou Signed-off-by: Scott McNutt --- arch/nios2/include/asm/posix_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/nios2/include/asm/posix_types.h b/arch/nios2/include/asm/posix_types.h index c2deea6bf..673364099 100644 --- a/arch/nios2/include/asm/posix_types.h +++ b/arch/nios2/include/asm/posix_types.h @@ -17,7 +17,7 @@ typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef unsigned long __kernel_size_t; -typedef int __kernel_ssize_t; +typedef long __kernel_ssize_t; typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; From d8a593c68bac7b9d9b26af6fa8c392671213ce93 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Mon, 27 Dec 2010 10:46:01 +0800 Subject: [PATCH 4/4] nios2: add gpio_is_valid Signed-off-by: Thomas Chou Signed-off-by: Scott McNutt --- arch/nios2/include/asm/gpio.h | 6 ++++++ board/altera/nios2-generic/custom_fpga.h | 1 + board/altera/nios2-generic/gpio.c | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h index 36a71324d..4b21c8f7f 100644 --- a/arch/nios2/include/asm/gpio.h +++ b/arch/nios2/include/asm/gpio.h @@ -52,6 +52,11 @@ static inline void gpio_set_value(unsigned gpio, int value) { writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2)); } + +static inline int gpio_is_valid(int number) +{ + return ((unsigned)number) < CONFIG_SYS_GPIO_WIDTH; +} #else extern int gpio_request(unsigned gpio, const char *label); extern int gpio_free(unsigned gpio); @@ -59,6 +64,7 @@ extern int gpio_direction_input(unsigned gpio); extern int gpio_direction_output(unsigned gpio, int value); extern int gpio_get_value(unsigned gpio); extern void gpio_set_value(unsigned gpio, int value); +extern int gpio_is_valid(int number); #endif /* CONFIG_SYS_GPIO_BASE */ #endif /* _ASM_NIOS2_GPIO_H_ */ diff --git a/board/altera/nios2-generic/custom_fpga.h b/board/altera/nios2-generic/custom_fpga.h index a11add559..f7f38535f 100644 --- a/board/altera/nios2-generic/custom_fpga.h +++ b/board/altera/nios2-generic/custom_fpga.h @@ -50,6 +50,7 @@ /* led_pio.s1 is a altera_avalon_pio */ #define LED_PIO_BASE 0x82120870 +#define LED_PIO_WIDTH 8 /* high_res_timer.s1 is a altera_avalon_timer */ #define CONFIG_SYS_TIMER_BASE 0x82120820 diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c index 8c639ce36..4a3056435 100644 --- a/board/altera/nios2-generic/gpio.c +++ b/board/altera/nios2-generic/gpio.c @@ -10,6 +10,7 @@ #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; @@ -62,4 +63,9 @@ void gpio_set_value(unsigned gpio, int value) pio_data_reg &= ~mask; writel(pio_data_reg, ALTERA_PIO_DATA); } + +int gpio_is_valid(int number) +{ + return ((unsigned)number) < ALTERA_PIO_WIDTH; +} #endif