1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pmu.c, Power Management Unit routines for NEC VR4100 series.
5 * Copyright (C) 2003-2007 Yoichi Yuasa <yuasa@linux-mips.org>
8 #include <linux/errno.h>
9 #include <linux/init.h>
10 #include <linux/ioport.h>
11 #include <linux/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/types.h>
16 #include <asm/cacheflush.h>
20 #include <asm/processor.h>
21 #include <asm/reboot.h>
23 #define PMU_TYPE1_BASE 0x0b0000a0UL
24 #define PMU_TYPE1_SIZE 0x0eUL
26 #define PMU_TYPE2_BASE 0x0f0000c0UL
27 #define PMU_TYPE2_SIZE 0x10UL
29 #define PMUCNT2REG 0x06
30 #define SOFTRST 0x0010
32 static void __iomem
*pmu_base
;
34 #define pmu_read(offset) readw(pmu_base + (offset))
35 #define pmu_write(offset, value) writew((value), pmu_base + (offset))
37 static void __cpuidle
vr41xx_cpu_wait(void)
42 * "standby" sets IE bit of the CP0_STATUS to 1.
44 __asm__("standby;\n");
49 static inline void software_reset(void)
53 switch (current_cpu_type()) {
57 pmucnt2
= pmu_read(PMUCNT2REG
);
59 pmu_write(PMUCNT2REG
, pmucnt2
);
62 set_c0_status(ST0_BEV
| ST0_ERL
);
63 change_c0_config(CONF_CM_CMASK
, CONF_CM_UNCACHED
);
66 __asm__("jr %0"::"r"(0xbfc00000));
71 static void vr41xx_restart(char *command
)
78 static void vr41xx_halt(void)
81 printk(KERN_NOTICE
"\nYou can turn off the power supply\n");
82 __asm__("hibernate;\n");
85 static int __init
vr41xx_pmu_init(void)
87 unsigned long start
, size
;
89 switch (current_cpu_type()) {
92 start
= PMU_TYPE1_BASE
;
93 size
= PMU_TYPE1_SIZE
;
98 start
= PMU_TYPE2_BASE
;
99 size
= PMU_TYPE2_SIZE
;
102 printk("Unexpected CPU of NEC VR4100 series\n");
106 if (request_mem_region(start
, size
, "PMU") == NULL
)
109 pmu_base
= ioremap(start
, size
);
110 if (pmu_base
== NULL
) {
111 release_mem_region(start
, size
);
115 cpu_wait
= vr41xx_cpu_wait
;
116 _machine_restart
= vr41xx_restart
;
117 _machine_halt
= vr41xx_halt
;
118 pm_power_off
= vr41xx_halt
;
123 core_initcall(vr41xx_pmu_init
);