1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
249613d4dSRussell King #ifndef __ASMARM_ARCH_SCU_H
349613d4dSRussell King #define __ASMARM_ARCH_SCU_H
449613d4dSRussell King
5292ec42aSRussell King #define SCU_PM_NORMAL 0
6292ec42aSRussell King #define SCU_PM_DORMANT 2
7292ec42aSRussell King #define SCU_PM_POWEROFF 3
8292ec42aSRussell King
9292ec42aSRussell King #ifndef __ASSEMBLER__
10e9d6b335SHiroshi Doyu
11fed3c155SJohan Hovold #include <linux/errno.h>
12e9d6b335SHiroshi Doyu #include <asm/cputype.h>
13e9d6b335SHiroshi Doyu
scu_a9_has_base(void)14e9d6b335SHiroshi Doyu static inline bool scu_a9_has_base(void)
15e9d6b335SHiroshi Doyu {
16af040ffcSRussell King return read_cpuid_part() == ARM_CPU_PART_CORTEX_A9;
17e9d6b335SHiroshi Doyu }
18e9d6b335SHiroshi Doyu
scu_a9_get_base(void)19e9d6b335SHiroshi Doyu static inline unsigned long scu_a9_get_base(void)
20e9d6b335SHiroshi Doyu {
21e9d6b335SHiroshi Doyu unsigned long pa;
22e9d6b335SHiroshi Doyu
23e9d6b335SHiroshi Doyu asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (pa));
24e9d6b335SHiroshi Doyu
25e9d6b335SHiroshi Doyu return pa;
26e9d6b335SHiroshi Doyu }
27e9d6b335SHiroshi Doyu
282abc75a8SNishanth Menon #ifdef CONFIG_HAVE_ARM_SCU
29a8cbcd92SRussell King unsigned int scu_get_core_count(void __iomem *);
30292ec42aSRussell King int scu_power_mode(void __iomem *, unsigned int);
310606326eSMartin Blumenstingl int scu_cpu_power_enable(void __iomem *, unsigned int);
32936a4174SMartin Blumenstingl int scu_get_cpu_power_mode(void __iomem *scu_base, unsigned int logical_cpu);
332abc75a8SNishanth Menon #else
scu_get_core_count(void __iomem * scu_base)342abc75a8SNishanth Menon static inline unsigned int scu_get_core_count(void __iomem *scu_base)
352abc75a8SNishanth Menon {
362abc75a8SNishanth Menon return 0;
372abc75a8SNishanth Menon }
scu_power_mode(void __iomem * scu_base,unsigned int mode)382abc75a8SNishanth Menon static inline int scu_power_mode(void __iomem *scu_base, unsigned int mode)
392abc75a8SNishanth Menon {
402abc75a8SNishanth Menon return -EINVAL;
412abc75a8SNishanth Menon }
scu_cpu_power_enable(void __iomem * scu_base,unsigned int mode)420606326eSMartin Blumenstingl static inline int scu_cpu_power_enable(void __iomem *scu_base,
430606326eSMartin Blumenstingl unsigned int mode)
440606326eSMartin Blumenstingl {
450606326eSMartin Blumenstingl return -EINVAL;
460606326eSMartin Blumenstingl }
scu_get_cpu_power_mode(void __iomem * scu_base,unsigned int logical_cpu)47936a4174SMartin Blumenstingl static inline int scu_get_cpu_power_mode(void __iomem *scu_base,
48936a4174SMartin Blumenstingl unsigned int logical_cpu)
49936a4174SMartin Blumenstingl {
50936a4174SMartin Blumenstingl return -EINVAL;
51936a4174SMartin Blumenstingl }
522abc75a8SNishanth Menon #endif
53eed88123SRob Herring
542abc75a8SNishanth Menon #if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU)
55eed88123SRob Herring void scu_enable(void __iomem *scu_base);
56eed88123SRob Herring #else
scu_enable(void __iomem * scu_base)57eed88123SRob Herring static inline void scu_enable(void __iomem *scu_base) {}
58eed88123SRob Herring #endif
59eed88123SRob Herring
60292ec42aSRussell King #endif
6149613d4dSRussell King
6249613d4dSRussell King #endif
63