rk2928: port config: add port operation interface
authorkfx <kfx@rock-chips.com>
Tue, 9 Oct 2012 03:30:00 +0000 (11:30 +0800)
committerkfx <kfx@rock-chips.com>
Tue, 9 Oct 2012 03:30:00 +0000 (11:30 +0800)
arch/arm/mach-rk2928/include/mach/gpio.h
arch/arm/mach-rk2928/iomux.c

index 24f2b08b9f1f885020bda1f8a614a37756d66c8e..d6e8c368a2bfe6cd5ba76412ddbe3f6b3666b626 100755 (executable)
@@ -373,6 +373,63 @@ 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__ */
 
 #endif
index 81da2cb6ffdb7b0b1a85987e457f6d3e2b0ce0f9..bcc6c625a78ec0e9a498ac5b23d95743d1fde7de 100755 (executable)
@@ -306,7 +306,7 @@ void gpio_set_iomux(int gpio)
         struct mux_config *cfg;
         
         cfg = &rk30_muxs[(gpio - PIN_BASE)];
-        
+        cfg->mode = 0;
         rk30_mux_set(cfg);
 }
 EXPORT_SYMBOL(gpio_set_iomux);