bmips.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com)
  7. *
  8. * Definitions for BMIPS processors
  9. */
  10. #ifndef _ASM_BMIPS_H
  11. #define _ASM_BMIPS_H
  12. #include <linux/compiler.h>
  13. #include <linux/linkage.h>
  14. #include <asm/addrspace.h>
  15. #include <asm/mipsregs.h>
  16. #include <asm/hazards.h>
  17. /* NOTE: the CBR register returns a PA, and it can be above 0xff00_0000 */
  18. #define BMIPS_GET_CBR() ((void __iomem *)(CKSEG1 | \
  19. (unsigned long) \
  20. ((read_c0_brcm_cbr() >> 18) << 18)))
  21. #define BMIPS_RAC_CONFIG 0x00000000
  22. #define BMIPS_RAC_ADDRESS_RANGE 0x00000004
  23. #define BMIPS_RAC_CONFIG_1 0x00000008
  24. #define BMIPS_L2_CONFIG 0x0000000c
  25. #define BMIPS_LMB_CONTROL 0x0000001c
  26. #define BMIPS_SYSTEM_BASE 0x00000020
  27. #define BMIPS_PERF_GLOBAL_CONTROL 0x00020000
  28. #define BMIPS_PERF_CONTROL_0 0x00020004
  29. #define BMIPS_PERF_CONTROL_1 0x00020008
  30. #define BMIPS_PERF_COUNTER_0 0x00020010
  31. #define BMIPS_PERF_COUNTER_1 0x00020014
  32. #define BMIPS_PERF_COUNTER_2 0x00020018
  33. #define BMIPS_PERF_COUNTER_3 0x0002001c
  34. #define BMIPS_RELO_VECTOR_CONTROL_0 0x00030000
  35. #define BMIPS_RELO_VECTOR_CONTROL_1 0x00038000
  36. #define BMIPS_NMI_RESET_VEC 0x80000000
  37. #define BMIPS_WARM_RESTART_VEC 0x80000380
  38. #define ZSCM_REG_BASE 0x97000000
  39. #if !defined(__ASSEMBLY__)
  40. #include <linux/cpumask.h>
  41. #include <asm/r4kcache.h>
  42. #include <asm/smp-ops.h>
  43. extern struct plat_smp_ops bmips43xx_smp_ops;
  44. extern struct plat_smp_ops bmips5000_smp_ops;
  45. static inline int register_bmips_smp_ops(void)
  46. {
  47. #if IS_ENABLED(CONFIG_CPU_BMIPS) && IS_ENABLED(CONFIG_SMP)
  48. switch (current_cpu_type()) {
  49. case CPU_BMIPS32:
  50. case CPU_BMIPS3300:
  51. return register_up_smp_ops();
  52. case CPU_BMIPS4350:
  53. case CPU_BMIPS4380:
  54. register_smp_ops(&bmips43xx_smp_ops);
  55. break;
  56. case CPU_BMIPS5000:
  57. register_smp_ops(&bmips5000_smp_ops);
  58. break;
  59. default:
  60. return -ENODEV;
  61. }
  62. return 0;
  63. #else
  64. return -ENODEV;
  65. #endif
  66. }
  67. extern char bmips_reset_nmi_vec;
  68. extern char bmips_reset_nmi_vec_end;
  69. extern char bmips_smp_movevec;
  70. extern char bmips_smp_int_vec;
  71. extern char bmips_smp_int_vec_end;
  72. extern int bmips_smp_enabled;
  73. extern int bmips_cpu_offset;
  74. extern cpumask_t bmips_booted_mask;
  75. extern unsigned long bmips_tp1_irqs;
  76. extern void bmips_ebase_setup(void);
  77. extern asmlinkage void plat_wired_tlb_setup(void);
  78. extern void bmips_cpu_setup(void);
  79. static inline unsigned long bmips_read_zscm_reg(unsigned int offset)
  80. {
  81. unsigned long ret;
  82. barrier();
  83. cache_op(Index_Load_Tag_S, ZSCM_REG_BASE + offset);
  84. __sync();
  85. _ssnop();
  86. _ssnop();
  87. _ssnop();
  88. _ssnop();
  89. _ssnop();
  90. _ssnop();
  91. _ssnop();
  92. ret = read_c0_ddatalo();
  93. _ssnop();
  94. return ret;
  95. }
  96. static inline void bmips_write_zscm_reg(unsigned int offset, unsigned long data)
  97. {
  98. write_c0_ddatalo(data);
  99. _ssnop();
  100. _ssnop();
  101. _ssnop();
  102. cache_op(Index_Store_Tag_S, ZSCM_REG_BASE + offset);
  103. _ssnop();
  104. _ssnop();
  105. _ssnop();
  106. barrier();
  107. }
  108. static inline void bmips_post_dma_flush(struct device *dev)
  109. {
  110. void __iomem *cbr = BMIPS_GET_CBR();
  111. u32 cfg;
  112. if (boot_cpu_type() != CPU_BMIPS3300 &&
  113. boot_cpu_type() != CPU_BMIPS4350 &&
  114. boot_cpu_type() != CPU_BMIPS4380)
  115. return;
  116. /* Flush stale data out of the readahead cache */
  117. cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
  118. __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
  119. __raw_readl(cbr + BMIPS_RAC_CONFIG);
  120. }
  121. #endif /* !defined(__ASSEMBLY__) */
  122. #endif /* _ASM_BMIPS_H */