118a1eef9SKevin Cernekee /* 218a1eef9SKevin Cernekee * This file is subject to the terms and conditions of the GNU General Public 318a1eef9SKevin Cernekee * License. See the file "COPYING" in the main directory of this archive 418a1eef9SKevin Cernekee * for more details. 518a1eef9SKevin Cernekee * 618a1eef9SKevin Cernekee * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com) 718a1eef9SKevin Cernekee * 818a1eef9SKevin Cernekee * Definitions for BMIPS processors 918a1eef9SKevin Cernekee */ 1018a1eef9SKevin Cernekee #ifndef _ASM_BMIPS_H 1118a1eef9SKevin Cernekee #define _ASM_BMIPS_H 1218a1eef9SKevin Cernekee 1318a1eef9SKevin Cernekee #include <linux/compiler.h> 1418a1eef9SKevin Cernekee #include <linux/linkage.h> 1518a1eef9SKevin Cernekee #include <asm/addrspace.h> 1618a1eef9SKevin Cernekee #include <asm/mipsregs.h> 1718a1eef9SKevin Cernekee #include <asm/hazards.h> 1818a1eef9SKevin Cernekee 1918a1eef9SKevin Cernekee /* NOTE: the CBR register returns a PA, and it can be above 0xff00_0000 */ 2018a1eef9SKevin Cernekee #define BMIPS_GET_CBR() ((void __iomem *)(CKSEG1 | \ 2118a1eef9SKevin Cernekee (unsigned long) \ 2218a1eef9SKevin Cernekee ((read_c0_brcm_cbr() >> 18) << 18))) 2318a1eef9SKevin Cernekee 2418a1eef9SKevin Cernekee #define BMIPS_RAC_CONFIG 0x00000000 2518a1eef9SKevin Cernekee #define BMIPS_RAC_ADDRESS_RANGE 0x00000004 2618a1eef9SKevin Cernekee #define BMIPS_RAC_CONFIG_1 0x00000008 2718a1eef9SKevin Cernekee #define BMIPS_L2_CONFIG 0x0000000c 2818a1eef9SKevin Cernekee #define BMIPS_LMB_CONTROL 0x0000001c 2918a1eef9SKevin Cernekee #define BMIPS_SYSTEM_BASE 0x00000020 3018a1eef9SKevin Cernekee #define BMIPS_PERF_GLOBAL_CONTROL 0x00020000 3118a1eef9SKevin Cernekee #define BMIPS_PERF_CONTROL_0 0x00020004 3218a1eef9SKevin Cernekee #define BMIPS_PERF_CONTROL_1 0x00020008 3318a1eef9SKevin Cernekee #define BMIPS_PERF_COUNTER_0 0x00020010 3418a1eef9SKevin Cernekee #define BMIPS_PERF_COUNTER_1 0x00020014 3518a1eef9SKevin Cernekee #define BMIPS_PERF_COUNTER_2 0x00020018 3618a1eef9SKevin Cernekee #define BMIPS_PERF_COUNTER_3 0x0002001c 3718a1eef9SKevin Cernekee #define BMIPS_RELO_VECTOR_CONTROL_0 0x00030000 3818a1eef9SKevin Cernekee #define BMIPS_RELO_VECTOR_CONTROL_1 0x00038000 3918a1eef9SKevin Cernekee 4018a1eef9SKevin Cernekee #define BMIPS_NMI_RESET_VEC 0x80000000 4118a1eef9SKevin Cernekee #define BMIPS_WARM_RESTART_VEC 0x80000380 4218a1eef9SKevin Cernekee 4318a1eef9SKevin Cernekee #define ZSCM_REG_BASE 0x97000000 4418a1eef9SKevin Cernekee 4518a1eef9SKevin Cernekee #if !defined(__ASSEMBLY__) 4618a1eef9SKevin Cernekee 4718a1eef9SKevin Cernekee #include <linux/cpumask.h> 4818a1eef9SKevin Cernekee #include <asm/r4kcache.h> 4904fa8bf7SJonas Gorski #include <asm/smp-ops.h> 5018a1eef9SKevin Cernekee 51ff2c8252SMatt Redfearn extern const struct plat_smp_ops bmips43xx_smp_ops; 52ff2c8252SMatt Redfearn extern const struct plat_smp_ops bmips5000_smp_ops; 5304fa8bf7SJonas Gorski register_bmips_smp_ops(void)5404fa8bf7SJonas Gorskistatic inline int register_bmips_smp_ops(void) 5504fa8bf7SJonas Gorski { 5604fa8bf7SJonas Gorski #if IS_ENABLED(CONFIG_CPU_BMIPS) && IS_ENABLED(CONFIG_SMP) 5704fa8bf7SJonas Gorski switch (current_cpu_type()) { 5804fa8bf7SJonas Gorski case CPU_BMIPS32: 5904fa8bf7SJonas Gorski case CPU_BMIPS3300: 6004fa8bf7SJonas Gorski return register_up_smp_ops(); 6104fa8bf7SJonas Gorski case CPU_BMIPS4350: 6204fa8bf7SJonas Gorski case CPU_BMIPS4380: 6304fa8bf7SJonas Gorski register_smp_ops(&bmips43xx_smp_ops); 6404fa8bf7SJonas Gorski break; 6504fa8bf7SJonas Gorski case CPU_BMIPS5000: 6604fa8bf7SJonas Gorski register_smp_ops(&bmips5000_smp_ops); 6704fa8bf7SJonas Gorski break; 6804fa8bf7SJonas Gorski default: 6904fa8bf7SJonas Gorski return -ENODEV; 7004fa8bf7SJonas Gorski } 7104fa8bf7SJonas Gorski 7204fa8bf7SJonas Gorski return 0; 7304fa8bf7SJonas Gorski #else 7404fa8bf7SJonas Gorski return -ENODEV; 7504fa8bf7SJonas Gorski #endif 7604fa8bf7SJonas Gorski } 7704fa8bf7SJonas Gorski 78*e4f5cb1aSJonas Gorski extern char bmips_reset_nmi_vec[]; 79*e4f5cb1aSJonas Gorski extern char bmips_reset_nmi_vec_end[]; 80*e4f5cb1aSJonas Gorski extern char bmips_smp_movevec[]; 81*e4f5cb1aSJonas Gorski extern char bmips_smp_int_vec[]; 82*e4f5cb1aSJonas Gorski extern char bmips_smp_int_vec_end[]; 8318a1eef9SKevin Cernekee 8418a1eef9SKevin Cernekee extern int bmips_smp_enabled; 8518a1eef9SKevin Cernekee extern int bmips_cpu_offset; 8618a1eef9SKevin Cernekee extern cpumask_t bmips_booted_mask; 87d8010cebSKevin Cernekee extern unsigned long bmips_tp1_irqs; 8818a1eef9SKevin Cernekee 8918a1eef9SKevin Cernekee extern void bmips_ebase_setup(void); 9018a1eef9SKevin Cernekee extern asmlinkage void plat_wired_tlb_setup(void); 91738a3f79SFlorian Fainelli extern void bmips_cpu_setup(void); 9218a1eef9SKevin Cernekee bmips_read_zscm_reg(unsigned int offset)9318a1eef9SKevin Cernekeestatic inline unsigned long bmips_read_zscm_reg(unsigned int offset) 9418a1eef9SKevin Cernekee { 9518a1eef9SKevin Cernekee unsigned long ret; 9618a1eef9SKevin Cernekee 9743d30939SRalf Baechle barrier(); 9843d30939SRalf Baechle cache_op(Index_Load_Tag_S, ZSCM_REG_BASE + offset); 9943d30939SRalf Baechle __sync(); 10043d30939SRalf Baechle _ssnop(); 10143d30939SRalf Baechle _ssnop(); 10243d30939SRalf Baechle _ssnop(); 10343d30939SRalf Baechle _ssnop(); 10443d30939SRalf Baechle _ssnop(); 10543d30939SRalf Baechle _ssnop(); 10643d30939SRalf Baechle _ssnop(); 10743d30939SRalf Baechle ret = read_c0_ddatalo(); 10843d30939SRalf Baechle _ssnop(); 10943d30939SRalf Baechle 11018a1eef9SKevin Cernekee return ret; 11118a1eef9SKevin Cernekee } 11218a1eef9SKevin Cernekee bmips_write_zscm_reg(unsigned int offset,unsigned long data)11318a1eef9SKevin Cernekeestatic inline void bmips_write_zscm_reg(unsigned int offset, unsigned long data) 11418a1eef9SKevin Cernekee { 11543d30939SRalf Baechle write_c0_ddatalo(data); 11643d30939SRalf Baechle _ssnop(); 11743d30939SRalf Baechle _ssnop(); 11843d30939SRalf Baechle _ssnop(); 11943d30939SRalf Baechle cache_op(Index_Store_Tag_S, ZSCM_REG_BASE + offset); 12043d30939SRalf Baechle _ssnop(); 12143d30939SRalf Baechle _ssnop(); 12243d30939SRalf Baechle _ssnop(); 12343d30939SRalf Baechle barrier(); 12418a1eef9SKevin Cernekee } 12518a1eef9SKevin Cernekee 12618a1eef9SKevin Cernekee #endif /* !defined(__ASSEMBLY__) */ 12718a1eef9SKevin Cernekee 12818a1eef9SKevin Cernekee #endif /* _ASM_BMIPS_H */ 129