4 * This gpio core is described in http://nioswiki.com/GPIO
8 * when CONFIG_SYS_GPIO_BASE is not defined, board may provide
11 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
18 #ifndef _ASM_NIOS2_GPIO_H_
19 #define _ASM_NIOS2_GPIO_H_
21 #ifdef CONFIG_SYS_GPIO_BASE
24 static inline int gpio_direction_input(unsigned gpio)
26 writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2));
30 static inline int gpio_direction_output(unsigned gpio, int value)
32 writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
36 static inline int gpio_get_value(unsigned gpio)
38 return readl(CONFIG_SYS_GPIO_BASE + (gpio << 2));
41 static inline void gpio_set_value(unsigned gpio, int value)
43 writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
46 extern int gpio_direction_input(unsigned gpio);
47 extern int gpio_direction_output(unsigned gpio, int value);
48 extern int gpio_get_value(unsigned gpio);
49 extern void gpio_set_value(unsigned gpio, int value);
50 #endif /* CONFIG_SYS_GPIO_BASE */
52 #endif /* _ASM_NIOS2_GPIO_H_ */