xref: /linux/arch/arm/mach-highbank/sysregs.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*9952f691SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2220e6cf7SRob Herring /*
3220e6cf7SRob Herring  * Copyright 2011 Calxeda, Inc.
4220e6cf7SRob Herring  */
5220e6cf7SRob Herring #ifndef _MACH_HIGHBANK__SYSREGS_H_
6220e6cf7SRob Herring #define _MACH_HIGHBANK__SYSREGS_H_
7220e6cf7SRob Herring 
8220e6cf7SRob Herring #include <linux/io.h>
97a2848d3SRob Herring #include <linux/smp.h>
107a2848d3SRob Herring #include <asm/smp_plat.h>
117a2848d3SRob Herring #include <asm/smp_scu.h>
127a2848d3SRob Herring #include "core.h"
13220e6cf7SRob Herring 
14220e6cf7SRob Herring extern void __iomem *sregs_base;
15220e6cf7SRob Herring 
16220e6cf7SRob Herring #define HB_SREG_A9_PWR_REQ		0xf00
17220e6cf7SRob Herring #define HB_SREG_A9_BOOT_STAT		0xf04
18220e6cf7SRob Herring #define HB_SREG_A9_BOOT_DATA		0xf08
19220e6cf7SRob Herring 
20220e6cf7SRob Herring #define HB_PWR_SUSPEND			0
21220e6cf7SRob Herring #define HB_PWR_SOFT_RESET		1
22220e6cf7SRob Herring #define HB_PWR_HARD_RESET		2
23220e6cf7SRob Herring #define HB_PWR_SHUTDOWN			3
24220e6cf7SRob Herring 
257a2848d3SRob Herring #define SREG_CPU_PWR_CTRL(c)		(0x200 + ((c) * 4))
267a2848d3SRob Herring 
highbank_set_core_pwr(void)277a2848d3SRob Herring static inline void highbank_set_core_pwr(void)
287a2848d3SRob Herring {
2963fc1370SRob Herring 	int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
307a2848d3SRob Herring 	if (scu_base_addr)
317a2848d3SRob Herring 		scu_power_mode(scu_base_addr, SCU_PM_POWEROFF);
327a2848d3SRob Herring 	else
337a2848d3SRob Herring 		writel_relaxed(1, sregs_base + SREG_CPU_PWR_CTRL(cpu));
347a2848d3SRob Herring }
357a2848d3SRob Herring 
highbank_clear_core_pwr(void)369852910aSRob Herring static inline void highbank_clear_core_pwr(void)
379852910aSRob Herring {
3863fc1370SRob Herring 	int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
399852910aSRob Herring 	if (scu_base_addr)
409852910aSRob Herring 		scu_power_mode(scu_base_addr, SCU_PM_NORMAL);
419852910aSRob Herring 	else
429852910aSRob Herring 		writel_relaxed(0, sregs_base + SREG_CPU_PWR_CTRL(cpu));
439852910aSRob Herring }
449852910aSRob Herring 
highbank_set_pwr_suspend(void)45c05ee88fSRob Herring static inline void highbank_set_pwr_suspend(void)
46220e6cf7SRob Herring {
47220e6cf7SRob Herring 	writel(HB_PWR_SUSPEND, sregs_base + HB_SREG_A9_PWR_REQ);
487a2848d3SRob Herring 	highbank_set_core_pwr();
49220e6cf7SRob Herring }
50220e6cf7SRob Herring 
highbank_set_pwr_shutdown(void)51c05ee88fSRob Herring static inline void highbank_set_pwr_shutdown(void)
52220e6cf7SRob Herring {
53220e6cf7SRob Herring 	writel(HB_PWR_SHUTDOWN, sregs_base + HB_SREG_A9_PWR_REQ);
547a2848d3SRob Herring 	highbank_set_core_pwr();
55220e6cf7SRob Herring }
56220e6cf7SRob Herring 
highbank_set_pwr_soft_reset(void)57c05ee88fSRob Herring static inline void highbank_set_pwr_soft_reset(void)
58220e6cf7SRob Herring {
59220e6cf7SRob Herring 	writel(HB_PWR_SOFT_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
607a2848d3SRob Herring 	highbank_set_core_pwr();
61220e6cf7SRob Herring }
62220e6cf7SRob Herring 
highbank_set_pwr_hard_reset(void)63c05ee88fSRob Herring static inline void highbank_set_pwr_hard_reset(void)
64220e6cf7SRob Herring {
65220e6cf7SRob Herring 	writel(HB_PWR_HARD_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
667a2848d3SRob Herring 	highbank_set_core_pwr();
67220e6cf7SRob Herring }
68220e6cf7SRob Herring 
highbank_clear_pwr_request(void)699852910aSRob Herring static inline void highbank_clear_pwr_request(void)
709852910aSRob Herring {
719852910aSRob Herring 	writel(~0UL, sregs_base + HB_SREG_A9_PWR_REQ);
729852910aSRob Herring 	highbank_clear_core_pwr();
739852910aSRob Herring }
749852910aSRob Herring 
75220e6cf7SRob Herring #endif
76