nds32.h 2.0 KB

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