/* * arch/arm/mach-sunxi/platsmp.h * * Copyright(c) 2013-2015 Allwinnertech Co., Ltd. * http://www.allwinnertech.com * * Author: liugang * * sunxi smp ops header file * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef __PLAT_SMP_H #define __PLAT_SMP_H #ifdef CONFIG_CPU_IDLE_SUNXI #include #endif #define get_nr_cores() \ ({ \ unsigned int __val; \ asm("mrc p15, 1, %0, c9, c0, 2" \ : "=r" (__val) \ : \ : "cc"); \ ((__val>>24) & 0x03) + 1; \ }) #if defined(CONFIG_ARCH_SUN8IW17) #define SUNXI_CCI400_PBASE (0x030D0000) #define SUNXI_CLUSTER0_CPUX_CFG_PBASE (0x09010000) #define SUNXI_CLUSTER1_CPUX_CFG_PBASE (0x09810000) #define SUNXI_CPUS_CFG_PBASE (0x07000400) #define CLUSTER_CPU_STATUS (0x80) #define CPU_RST_CTRL (0x00) #define CLUSTER_CTRL0 (0x10) #define CLUSTER_CTRL1 (0x14) #define CLUSTER_PWRON_RST(cluster) (0x40 + (cluster) * 0x40) #define CPU_PWR_CLAMP(cluster, cpu) (0x50 + (cluster*16 + cpu)*0x4) #define CLUSTER_PWROFF_GATING(cluster) (0x44 + (cluster) * 0x40) #else #ifdef CONFIG_ARCH_SUN8IW5 #define SUNXI_CPUCFG_PBASE (0x01F01C00) #define SUNXI_R_PRCM_PBASE (0x01F01400) #define SUNXI_CPU_PWROFF_REG (0x100) #define SUNXI_CPUX_PWR_CLAMP(x) (0x140 + (x)*0x04) #else #define SUNXI_CPUCFG_PBASE (0x01C25C00) #endif #define CPUCFG_CPUX_RST_CTRL(x) (0x40 + (x)*0x40) #define CPUCFG_CPUX_STATUS_REG(x) (0x48 + (x)*0x40) #define CPUCFG_GENER_CTRL_REG (0x184) #define CPUCFG_DEBUG_REG1 (0x1e4) #if !(defined CONFIG_ARCH_SUN8IW10) && !(defined CONFIG_ARCH_SUN8IW5) #define CPUCFG_PWROFF_GATING_REG (0x110) #define CPUCFG_PWR_SWITCH_REG(x) (0x120 + (x)*0x04) #endif #endif #if defined(CONFIG_ARCH_SUN8IW10) #define SUNXI_RTC_PBASE (0x01C20400) #define CPU_SOFT_ENTRY_REG0 (0x1e4) #elif defined(CONFIG_ARCH_SUN8IW11) #define SUNXI_SYSCTL_PBASE (0x01C00000) #define CPU_SOFT_ENTRY_REG0 (0xbc) #elif defined(CONFIG_ARCH_SUN8IW17) #define SUN8IW17_RTC_PBASE (0x07000000) #define CPU_SOFT_ENTRY_REG0 (0x1bc) #elif defined(CONFIG_ARCH_SUN8IW5) #define CPU_SOFT_ENTRY_REG0 (0x1a4) #endif extern void __iomem *sunxi_rtc_base; extern void __iomem *sunxi_sysctl_base; extern void __iomem *sunxi_cpucfg_base; static inline void sunxi_set_secondary_entry(void *entry) { #if (defined CONFIG_ARCH_SUN8IW10) || (defined CONFIG_ARCH_SUN8IW17) writel((u32)entry, sunxi_rtc_base + CPU_SOFT_ENTRY_REG0); #elif (defined CONFIG_ARCH_SUN8IW5) writel((u32)entry, sunxi_cpucfg_base + CPU_SOFT_ENTRY_REG0); #else writel((u32)entry, sunxi_sysctl_base + CPU_SOFT_ENTRY_REG0); #endif } #if defined(CONFIG_MCPM) && !defined(CONFIG_SUNXI_TRUSTZONE) extern void sun8i_power_up_setup(unsigned int affinity_level); #endif #ifndef CONFIG_MCPM extern void sunxi_cpu_die(unsigned int cpu); extern int sunxi_cpu_kill(unsigned int cpu); extern int sunxi_cpu_disable(unsigned int cpu); extern void __iomem *sunxi_r_prcm_base; static inline int sunxi_is_wfi_mode(int cpu) { #ifdef CONFIG_EVB_PLATFORM return readl(sunxi_cpucfg_base + CPUCFG_CPUX_STATUS_REG(cpu)) & (1<<2); #else return 1; #endif } static inline void sunxi_enable_cpu(int cpu) { unsigned int value; #if (defined CONFIG_ARCH_SUN8IW5) u32 pwr_reg; #endif /* Assert nCOREPORESET LOW and hold L1RSTDISABLE LOW. Ensure DBGPWRDUP is held LOW to prevent any external debug access to the processor. */ /* assert cpu core reset */ writel(0, sunxi_cpucfg_base + CPUCFG_CPUX_RST_CTRL(cpu)); /* L1RSTDISABLE hold low */ value = readl(sunxi_cpucfg_base + CPUCFG_GENER_CTRL_REG); value &= ~(1<