Discussion:
[ORLinux] [PATCH 0/2] openrisc: Basic idle state implementation
Sebastian Macke
2014-07-20 15:13:29 UTC
Permalink
These patches add support for the idle state of the cpu.

I tested the patches successfully in the jor1k emulator.


Sebastian Macke (2):
openrisc: Fix the bitmask for the unit present register
openrisc: Initial support for the idle state

arch/openrisc/include/asm/spr_defs.h | 4 ++--
arch/openrisc/kernel/process.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
--
2.0.1
Sebastian Macke
2014-07-20 15:13:30 UTC
Permalink
Signed-off-by: Sebastian Macke <sebastian at macke.de>
---
arch/openrisc/include/asm/spr_defs.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/openrisc/include/asm/spr_defs.h b/arch/openrisc/include/asm/spr_defs.h
index 5dbc668..367dac7 100644
--- a/arch/openrisc/include/asm/spr_defs.h
+++ b/arch/openrisc/include/asm/spr_defs.h
@@ -152,8 +152,8 @@
#define SPR_UPR_MP 0x00000020 /* MAC present */
#define SPR_UPR_DUP 0x00000040 /* Debug unit present */
#define SPR_UPR_PCUP 0x00000080 /* Performance counters unit present */
-#define SPR_UPR_PMP 0x00000100 /* Power management present */
-#define SPR_UPR_PICP 0x00000200 /* PIC present */
+#define SPR_UPR_PICP 0x00000100 /* PIC present */
+#define SPR_UPR_PMP 0x00000200 /* Power management present */
#define SPR_UPR_TTP 0x00000400 /* Tick timer present */
#define SPR_UPR_RES 0x00fe0000 /* Reserved */
#define SPR_UPR_CUP 0xff000000 /* Context units present */
--
2.0.1
Sebastian Macke
2014-07-20 15:13:31 UTC
Permalink
This patch adds basic support for the idle state of the cpu.
The patch overrides the regular idle function, enables the interupts,
checks for the power management unit and enables the cpu doze mode
if available.

Signed-off-by: Sebastian Macke <sebastian at macke.de>
---
arch/openrisc/kernel/process.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 86b9978..677175f 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -75,6 +75,19 @@ void machine_power_off(void)
__asm__("l.nop 1");
}

+/*
+ * Send the doze signal to the cpu if available.
+ * Make sure, that all interrupts are enabled
+ */
+void arch_cpu_idle(void)
+{
+ unsigned long upr;
+ local_irq_enable();
+ upr = mfspr(SPR_UPR);
+ if (upr & SPR_UPR_PMP)
+ mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME);
+}
+
void (*pm_power_off) (void) = machine_power_off;

/*
--
2.0.1
Loading...