nds32.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (C) 2005-2017 Andes Technology Corporation
  3. #ifndef _ASM_NDS32_NDS32_H_
  4. #define _ASM_NDS32_NDS32_H_
  5. #include <asm/bitfield.h>
  6. #include <asm/cachectl.h>
  7. #ifndef __ASSEMBLY__
  8. #include <linux/init.h>
  9. #include <asm/barrier.h>
  10. #include <nds32_intrinsic.h>
  11. #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
  12. #define FP_OFFSET (-3)
  13. #else
  14. #define FP_OFFSET (-2)
  15. #endif
  16. extern void __init early_trap_init(void);
  17. static inline void GIE_ENABLE(void)
  18. {
  19. mb();
  20. __nds32__gie_en();
  21. }
  22. static inline void GIE_DISABLE(void)
  23. {
  24. mb();
  25. __nds32__gie_dis();
  26. }
  27. static inline unsigned long CACHE_SET(unsigned char cache)
  28. {
  29. if (cache == ICACHE)
  30. return 64 << ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISET) >>
  31. ICM_CFG_offISET);
  32. else
  33. return 64 << ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSET) >>
  34. DCM_CFG_offDSET);
  35. }
  36. static inline unsigned long CACHE_WAY(unsigned char cache)
  37. {
  38. if (cache == ICACHE)
  39. return 1 +
  40. ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskIWAY) >> ICM_CFG_offIWAY);
  41. else
  42. return 1 +
  43. ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDWAY) >> DCM_CFG_offDWAY);
  44. }
  45. static inline unsigned long CACHE_LINE_SIZE(unsigned char cache)
  46. {
  47. if (cache == ICACHE)
  48. return 8 <<
  49. (((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISZ) >> ICM_CFG_offISZ) - 1);
  50. else
  51. return 8 <<
  52. (((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSZ) >> DCM_CFG_offDSZ) - 1);
  53. }
  54. #endif /* __ASSEMBLY__ */
  55. #define IVB_BASE PHYS_OFFSET /* in user space for intr/exc/trap/break table base, 64KB aligned
  56. * We defined at the start of the physical memory */
  57. /* dispatched sub-entry exception handler numbering */
  58. #define RD_PROT 0 /* read protrection */
  59. #define WRT_PROT 1 /* write protection */
  60. #define NOEXEC 2 /* non executable */
  61. #define PAGE_MODIFY 3 /* page modified */
  62. #define ACC_BIT 4 /* access bit */
  63. #define RESVED_PTE 5 /* reserved PTE attribute */
  64. /* reserved 6 ~ 16 */
  65. #endif /* _ASM_NDS32_NDS32_H_ */