iomux: add interface: iomux_is_set(unsigned int mode)
authorkfx <kfx@rock-chips.com>
Mon, 5 Aug 2013 08:04:24 +0000 (16:04 +0800)
committerkfx <kfx@rock-chips.com>
Mon, 5 Aug 2013 08:04:24 +0000 (16:04 +0800)
return value:
-1: mode is invalide
0 : mode is not set
1 : mode is set

arch/arm/plat-rk/include/plat/iomux.h
arch/arm/plat-rk/iomux.c

index c2c5fc5f3e4db50fb9672002fa6959795cbe770f..fe4a14132a7126db42c4f1b9acb13c65c3ccc7e7 100644 (file)
@@ -11,4 +11,11 @@ void iomux_set_gpio_mode(int gpio);
 void iomux_set(unsigned int mode);
 void __init iomux_init(void);
 
+/* return value:
+ * -1: mode is invalide 
+ * 0:  mode is not set
+ * 1:  mode is set
+ */
+int iomux_is_set(unsigned int);
+
 #endif
index 89b354754c56591ab6b24ba1f7d963bdb52b2aef..93e40ea0f8623ece4e9ddc13c4a5b141d5516feb 100644 (file)
@@ -96,12 +96,38 @@ void iomux_set(unsigned int mode)
 
         writel_relaxed(v, (void *)addr);
 }
+int iomux_is_set(unsigned int mode)
+{
+        unsigned int v, addr, mask;
+        struct union_mode m;
+        
+        m.mode = mode;
+       if(!mode_is_valid(mode)){
+               INFO("<%s> mode(0x%x) is invalid\n", __func__, mode);
+               return -1;
+       }
+        mask = 3;
+        v = (m.mux.mode << (m.mux.off * 2)) + (mask << (m.mux.off * 2 + 16));
+        addr = (unsigned int)GRF_IOMUX_BASE + 16 * m.mux.bank + 4 * (m.mux.goff - 0x0A);
+
+        if((readl_relaxed((void *)addr) & v) != 0)
+               return 1;
+       else if((mode & 0x03) == 0) //gpio mode
+               return 1;
+       else
+               return 0;
+}
 #else
 void iomux_set(unsigned int mode)
 {
        INFO("%s is not support\n", __func__);
        return;
 }
+int iomux_is_set(unsigned int mode)
+{
+       INFO("%s is not support\n", __func__);
+       return;
+}
 #endif
 EXPORT_SYMBOL(iomux_set);