18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com) 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Definitions for BMIPS processors 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#ifndef _ASM_BMIPS_H 118c2ecf20Sopenharmony_ci#define _ASM_BMIPS_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/compiler.h> 148c2ecf20Sopenharmony_ci#include <linux/linkage.h> 158c2ecf20Sopenharmony_ci#include <asm/addrspace.h> 168c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 178c2ecf20Sopenharmony_ci#include <asm/hazards.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* NOTE: the CBR register returns a PA, and it can be above 0xff00_0000 */ 208c2ecf20Sopenharmony_ci#define BMIPS_GET_CBR() ((void __iomem *)(CKSEG1 | \ 218c2ecf20Sopenharmony_ci (unsigned long) \ 228c2ecf20Sopenharmony_ci ((read_c0_brcm_cbr() >> 18) << 18))) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define BMIPS_RAC_CONFIG 0x00000000 258c2ecf20Sopenharmony_ci#define BMIPS_RAC_ADDRESS_RANGE 0x00000004 268c2ecf20Sopenharmony_ci#define BMIPS_RAC_CONFIG_1 0x00000008 278c2ecf20Sopenharmony_ci#define BMIPS_L2_CONFIG 0x0000000c 288c2ecf20Sopenharmony_ci#define BMIPS_LMB_CONTROL 0x0000001c 298c2ecf20Sopenharmony_ci#define BMIPS_SYSTEM_BASE 0x00000020 308c2ecf20Sopenharmony_ci#define BMIPS_PERF_GLOBAL_CONTROL 0x00020000 318c2ecf20Sopenharmony_ci#define BMIPS_PERF_CONTROL_0 0x00020004 328c2ecf20Sopenharmony_ci#define BMIPS_PERF_CONTROL_1 0x00020008 338c2ecf20Sopenharmony_ci#define BMIPS_PERF_COUNTER_0 0x00020010 348c2ecf20Sopenharmony_ci#define BMIPS_PERF_COUNTER_1 0x00020014 358c2ecf20Sopenharmony_ci#define BMIPS_PERF_COUNTER_2 0x00020018 368c2ecf20Sopenharmony_ci#define BMIPS_PERF_COUNTER_3 0x0002001c 378c2ecf20Sopenharmony_ci#define BMIPS_RELO_VECTOR_CONTROL_0 0x00030000 388c2ecf20Sopenharmony_ci#define BMIPS_RELO_VECTOR_CONTROL_1 0x00038000 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define BMIPS_NMI_RESET_VEC 0x80000000 418c2ecf20Sopenharmony_ci#define BMIPS_WARM_RESTART_VEC 0x80000380 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define ZSCM_REG_BASE 0x97000000 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#if !defined(__ASSEMBLY__) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#include <linux/cpumask.h> 488c2ecf20Sopenharmony_ci#include <asm/r4kcache.h> 498c2ecf20Sopenharmony_ci#include <asm/smp-ops.h> 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciextern const struct plat_smp_ops bmips43xx_smp_ops; 528c2ecf20Sopenharmony_ciextern const struct plat_smp_ops bmips5000_smp_ops; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic inline int register_bmips_smp_ops(void) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_CPU_BMIPS) && IS_ENABLED(CONFIG_SMP) 578c2ecf20Sopenharmony_ci switch (current_cpu_type()) { 588c2ecf20Sopenharmony_ci case CPU_BMIPS32: 598c2ecf20Sopenharmony_ci case CPU_BMIPS3300: 608c2ecf20Sopenharmony_ci return register_up_smp_ops(); 618c2ecf20Sopenharmony_ci case CPU_BMIPS4350: 628c2ecf20Sopenharmony_ci case CPU_BMIPS4380: 638c2ecf20Sopenharmony_ci register_smp_ops(&bmips43xx_smp_ops); 648c2ecf20Sopenharmony_ci break; 658c2ecf20Sopenharmony_ci case CPU_BMIPS5000: 668c2ecf20Sopenharmony_ci register_smp_ops(&bmips5000_smp_ops); 678c2ecf20Sopenharmony_ci break; 688c2ecf20Sopenharmony_ci default: 698c2ecf20Sopenharmony_ci return -ENODEV; 708c2ecf20Sopenharmony_ci } 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci return 0; 738c2ecf20Sopenharmony_ci#else 748c2ecf20Sopenharmony_ci return -ENODEV; 758c2ecf20Sopenharmony_ci#endif 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciextern char bmips_reset_nmi_vec[]; 798c2ecf20Sopenharmony_ciextern char bmips_reset_nmi_vec_end[]; 808c2ecf20Sopenharmony_ciextern char bmips_smp_movevec[]; 818c2ecf20Sopenharmony_ciextern char bmips_smp_int_vec[]; 828c2ecf20Sopenharmony_ciextern char bmips_smp_int_vec_end[]; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciextern int bmips_smp_enabled; 858c2ecf20Sopenharmony_ciextern int bmips_cpu_offset; 868c2ecf20Sopenharmony_ciextern cpumask_t bmips_booted_mask; 878c2ecf20Sopenharmony_ciextern unsigned long bmips_tp1_irqs; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciextern void bmips_ebase_setup(void); 908c2ecf20Sopenharmony_ciextern asmlinkage void plat_wired_tlb_setup(void); 918c2ecf20Sopenharmony_ciextern void bmips_cpu_setup(void); 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic inline unsigned long bmips_read_zscm_reg(unsigned int offset) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci unsigned long ret; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci barrier(); 988c2ecf20Sopenharmony_ci cache_op(Index_Load_Tag_S, ZSCM_REG_BASE + offset); 998c2ecf20Sopenharmony_ci __sync(); 1008c2ecf20Sopenharmony_ci _ssnop(); 1018c2ecf20Sopenharmony_ci _ssnop(); 1028c2ecf20Sopenharmony_ci _ssnop(); 1038c2ecf20Sopenharmony_ci _ssnop(); 1048c2ecf20Sopenharmony_ci _ssnop(); 1058c2ecf20Sopenharmony_ci _ssnop(); 1068c2ecf20Sopenharmony_ci _ssnop(); 1078c2ecf20Sopenharmony_ci ret = read_c0_ddatalo(); 1088c2ecf20Sopenharmony_ci _ssnop(); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci return ret; 1118c2ecf20Sopenharmony_ci} 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistatic inline void bmips_write_zscm_reg(unsigned int offset, unsigned long data) 1148c2ecf20Sopenharmony_ci{ 1158c2ecf20Sopenharmony_ci write_c0_ddatalo(data); 1168c2ecf20Sopenharmony_ci _ssnop(); 1178c2ecf20Sopenharmony_ci _ssnop(); 1188c2ecf20Sopenharmony_ci _ssnop(); 1198c2ecf20Sopenharmony_ci cache_op(Index_Store_Tag_S, ZSCM_REG_BASE + offset); 1208c2ecf20Sopenharmony_ci _ssnop(); 1218c2ecf20Sopenharmony_ci _ssnop(); 1228c2ecf20Sopenharmony_ci _ssnop(); 1238c2ecf20Sopenharmony_ci barrier(); 1248c2ecf20Sopenharmony_ci} 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#endif /* !defined(__ASSEMBLY__) */ 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#endif /* _ASM_BMIPS_H */ 129