rk29: add pmu.h
author黄涛 <huangtao@rock-chips.com>
Sat, 18 Dec 2010 06:43:38 +0000 (14:43 +0800)
committer黄涛 <huangtao@rock-chips.com>
Sat, 18 Dec 2010 06:43:58 +0000 (14:43 +0800)
arch/arm/mach-rk29/include/mach/pmu.h [new file with mode: 0644]
arch/arm/mach-rk29/include/mach/rk29_iomap.h
arch/arm/mach-rk29/io.c

diff --git a/arch/arm/mach-rk29/include/mach/pmu.h b/arch/arm/mach-rk29/include/mach/pmu.h
new file mode 100644 (file)
index 0000000..c3ad47e
--- /dev/null
@@ -0,0 +1,60 @@
+/* arch/arm/mach-rk29/include/mach/rk29_pmu.h
+ *
+ * Copyright (C) 2010 ROCKCHIP, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __ARCH_ARM_MACH_RK29_PMU_H
+
+#include <linux/irqflags.h>
+#include <asm/io.h>
+#include <mach/rk29_iomap.h>
+
+#define PMU_WAKEUP_EN0 0x00
+#define PMU_WAKEUP_EN1 0x04
+#define PMU_WAKEUP_EN2 0x08
+#define PMU_PD_CON     0x10
+#define PMU_MISC_CON   0x14
+#define PMU_PLL_CNT    0x18
+#define PMU_PD_ST      0x1c
+#define PMU_INT_ST     0x20
+
+enum pmu_power_domain {
+       PD_ARM_CORE = 0,
+       PD_NEON,
+       PD_ETM_DBG,
+       PD_L2_CACHE,
+       PD_VCODEC,
+       PD_DISPLAY,
+       PD_GPU,
+       PD_PERIPHERAL,
+       PD_MINI,
+};
+
+static inline void pmu_set_power_domain(enum pmu_power_domain pd, bool on)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       if (on)
+               writel(readl(RK29_PMU_BASE + PMU_PD_CON) & ~(1 << pd), RK29_PMU_BASE + PMU_PD_CON);
+       else
+               writel(readl(RK29_PMU_BASE + PMU_PD_CON) |  (1 << pd), RK29_PMU_BASE + PMU_PD_CON);
+       local_irq_restore(flags);
+}
+
+static inline bool pmu_power_domain_is_on(enum pmu_power_domain pd)
+{
+       return !(readl(RK29_PMU_BASE + PMU_PD_ST) & (1 << pd));
+}
+
+#endif
index 0f6193e6cb13ffb95a7bb8e2e6f7512d24ad4d44..5fffc05729c60d875f639754994b96ebd0e62a59 100644 (file)
 #define RK29_CRU_PHYS                          0x20000000
 #define RK29_CRU_BASE                          RK29_ADDR_BASE1
 #define RK29_CRU_SIZE                          SZ_4K
-#define RK29_PMU_PHYS                          0x20004000
-#define RK29_PMU_SIZE                          SZ_16K
+#define RK29_PMU_PHYS                  0x20004000
+#define RK29_PMU_BASE                  (RK29_ADDR_BASE1 + 0x4000)
+#define RK29_PMU_SIZE                  SZ_4K
 #define RK29_GRF_BASE                          (RK29_ADDR_BASE1+0x8000)
 #define RK29_GRF_PHYS                          0x20008000
 #define RK29_GRF_SIZE                          SZ_16K
index c669bef19fd6552d30be62bb34caa748db31b560..9815a273475634f0236ee46ce9e5a20b32f4f212 100644 (file)
@@ -41,6 +41,7 @@ static struct map_desc rk29_io_desc[] __initdata = {
        RK29_DEVICE(PWM),
        RK29_DEVICE(GRF),
        RK29_DEVICE(CRU),
+       RK29_DEVICE(PMU),
        RK29_DEVICE(GPIO0),
        RK29_DEVICE(GPIO1),
        RK29_DEVICE(GPIO2),