[ifxmips]:
[openwrt/svn-archive/archive.git] / target / linux / ifxmips / files / arch / mips / ifxmips / common / pmu.c
diff --git a/target/linux/ifxmips/files/arch/mips/ifxmips/common/pmu.c b/target/linux/ifxmips/files/arch/mips/ifxmips/common/pmu.c
new file mode 100644 (file)
index 0000000..afd890b
--- /dev/null
@@ -0,0 +1,25 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+
+#include <ifxmips.h>
+
+void
+ifxmips_pmu_enable(unsigned int module)
+{
+       int err = 1000000;
+
+       ifxmips_w32(ifxmips_r32(IFXMIPS_PMU_PWDCR) & ~module, IFXMIPS_PMU_PWDCR);
+       while (--err && (ifxmips_r32(IFXMIPS_PMU_PWDSR) & module));
+
+       if (!err)
+               panic("activating PMU module failed!");
+}
+EXPORT_SYMBOL(ifxmips_pmu_enable);
+
+void
+ifxmips_pmu_disable(unsigned int module)
+{
+       ifxmips_w32(ifxmips_r32(IFXMIPS_PMU_PWDCR) | module, IFXMIPS_PMU_PWDCR);
+}
+EXPORT_SYMBOL(ifxmips_pmu_disable);