From 0cf0742344f231758e277b0d2a81a98683e30b80 Mon Sep 17 00:00:00 2001 From: kfx Date: Tue, 9 Oct 2012 12:21:19 +0800 Subject: [PATCH] move port config interface to arch/arm/plat-rk --- arch/arm/mach-rk2928/include/mach/gpio.h | 56 -------------------- arch/arm/plat-rk/Makefile | 1 + arch/arm/plat-rk/config.c | 67 ++++++++++++++++++++++++ arch/arm/plat-rk/include/plat/gpio.h | 6 +++ 4 files changed, 74 insertions(+), 56 deletions(-) create mode 100644 arch/arm/plat-rk/config.c diff --git a/arch/arm/mach-rk2928/include/mach/gpio.h b/arch/arm/mach-rk2928/include/mach/gpio.h index d6e8c368a2bf..caf0c55929bd 100755 --- a/arch/arm/mach-rk2928/include/mach/gpio.h +++ b/arch/arm/mach-rk2928/include/mach/gpio.h @@ -373,62 +373,6 @@ static inline int irq_to_gpio(unsigned irq) { return irq - NR_GIC_IRQS + PIN_BASE; } -static inline int port_output_init(unsigned int value, int on, char *name) -{ - int ret = 0; - struct port_config port; - - port = get_port_config(value); - ret = gpio_request(port.gpio, name); - if(ret < 0) - return ret; - gpio_pull_updown(port.gpio, port.io.pull_mode); - gpio_direction_output(port.gpio, (on)? !port.io.active_low: !!port.io.active_low); - - return 0; -} -static inline void port_output_on(unsigned int value) -{ - struct port_config port; - - port = get_port_config(value); - gpio_set_value(port.gpio, !port.io.active_low); -} -static inline void port_output_off(unsigned int value) -{ - struct port_config port; - - port = get_port_config(value); - gpio_set_value(port.gpio, !!port.io.active_low); -} -static inline void port_deinit(unsigned int value) -{ - struct port_config port; - - port = get_port_config(value); - gpio_free(port.gpio); -} -static inline int port_input_init(unsigned int value, char *name) -{ - int ret = 0; - struct port_config port; - - port = get_port_config(value); - ret = gpio_request(port.gpio, name); - if(ret < 0) - return ret; - gpio_pull_updown(port.gpio, port.io.pull_mode); - gpio_direction_input(port.gpio); - - return 0; -} -static inline int port_get_value(unsigned int value) -{ - struct port_config port; - - port = get_port_config(value); - return gpio_get_value(port.gpio); -} #endif /* __ASSEMBLY__ */ diff --git a/arch/arm/plat-rk/Makefile b/arch/arm/plat-rk/Makefile index e8972c45c7ab..1c295798bdcd 100644 --- a/arch/arm/plat-rk/Makefile +++ b/arch/arm/plat-rk/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_FIQ) += fiq.o obj-$(CONFIG_FIQ_DEBUGGER) += rk_fiq_debugger.o obj-$(CONFIG_RK_EARLY_PRINTK) += early_printk.o ../kernel/debug.o obj-y += mem_reserve.o +obj-y += config.o obj-y += sram.o CFLAGS_sram.o += -mthumb obj-$(CONFIG_DDR_TEST) += memtester.o diff --git a/arch/arm/plat-rk/config.c b/arch/arm/plat-rk/config.c new file mode 100644 index 000000000000..50cc300c6c5f --- /dev/null +++ b/arch/arm/plat-rk/config.c @@ -0,0 +1,67 @@ +#include +#include + +int port_output_init(unsigned int value, int on, char *name) +{ + int ret = 0; + struct port_config port; + + port = get_port_config(value); + ret = gpio_request(port.gpio, name); + if(ret < 0) + return ret; + gpio_pull_updown(port.gpio, port.io.pull_mode); + gpio_direction_output(port.gpio, (on)? !port.io.active_low: !!port.io.active_low); + + return 0; +} +EXPORT_SYMBOL(port_output_init); +void port_output_on(unsigned int value) +{ + struct port_config port; + + port = get_port_config(value); + gpio_set_value(port.gpio, !port.io.active_low); +} +EXPORT_SYMBOL(port_output_on); +void port_output_off(unsigned int value) +{ + struct port_config port; + + port = get_port_config(value); + gpio_set_value(port.gpio, !!port.io.active_low); +} +EXPORT_SYMBOL(port_output_off); +void port_deinit(unsigned int value) +{ + struct port_config port; + + port = get_port_config(value); + gpio_free(port.gpio); +} +EXPORT_SYMBOL(port_deinit); +int port_input_init(unsigned int value, char *name) +{ + int ret = 0; + struct port_config port; + + port = get_port_config(value); + ret = gpio_request(port.gpio, name); + if(ret < 0) + return ret; + gpio_pull_updown(port.gpio, port.io.pull_mode); + gpio_direction_input(port.gpio); + + return 0; +} +EXPORT_SYMBOL(port_input_init); +int port_get_value(unsigned int value) +{ + struct port_config port; + + port = get_port_config(value); + return gpio_get_value(port.gpio); +} +EXPORT_SYMBOL(port_get_value); + + diff --git a/arch/arm/plat-rk/include/plat/gpio.h b/arch/arm/plat-rk/include/plat/gpio.h index 7e5beca04230..d9846f46d696 100644 --- a/arch/arm/plat-rk/include/plat/gpio.h +++ b/arch/arm/plat-rk/include/plat/gpio.h @@ -43,6 +43,12 @@ static inline struct port_config get_port_config(unsigned int value) return port; } void gpio_set_iomux(int gpio); +int port_output_init(unsigned int value, int on, char *name); +void port_output_on(unsigned int value); +void port_output_off(unsigned int value); +int port_input_init(unsigned int value, char *name); +int port_get_value(unsigned int value); +void port_deinit(unsigned int value); typedef enum eGPIOPinLevel { -- 2.34.1