arcregs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _ASM_ARC_ARCREGS_H
  9. #define _ASM_ARC_ARCREGS_H
  10. #ifdef __KERNEL__
  11. /* Build Configuration Registers */
  12. #define ARC_REG_DCCMBASE_BCR 0x61 /* DCCM Base Addr */
  13. #define ARC_REG_CRC_BCR 0x62
  14. #define ARC_REG_DVFB_BCR 0x64
  15. #define ARC_REG_EXTARITH_BCR 0x65
  16. #define ARC_REG_VECBASE_BCR 0x68
  17. #define ARC_REG_PERIBASE_BCR 0x69
  18. #define ARC_REG_FP_BCR 0x6B /* Single-Precision FPU */
  19. #define ARC_REG_DPFP_BCR 0x6C /* Dbl Precision FPU */
  20. #define ARC_REG_MMU_BCR 0x6f
  21. #define ARC_REG_DCCM_BCR 0x74 /* DCCM Present + SZ */
  22. #define ARC_REG_TIMERS_BCR 0x75
  23. #define ARC_REG_ICCM_BCR 0x78
  24. #define ARC_REG_XY_MEM_BCR 0x79
  25. #define ARC_REG_MAC_BCR 0x7a
  26. #define ARC_REG_MUL_BCR 0x7b
  27. #define ARC_REG_SWAP_BCR 0x7c
  28. #define ARC_REG_NORM_BCR 0x7d
  29. #define ARC_REG_MIXMAX_BCR 0x7e
  30. #define ARC_REG_BARREL_BCR 0x7f
  31. #define ARC_REG_D_UNCACH_BCR 0x6A
  32. /* status32 Bits Positions */
  33. #define STATUS_H_BIT 0 /* CPU Halted */
  34. #define STATUS_E1_BIT 1 /* Int 1 enable */
  35. #define STATUS_E2_BIT 2 /* Int 2 enable */
  36. #define STATUS_A1_BIT 3 /* Int 1 active */
  37. #define STATUS_A2_BIT 4 /* Int 2 active */
  38. #define STATUS_AE_BIT 5 /* Exception active */
  39. #define STATUS_DE_BIT 6 /* PC is in delay slot */
  40. #define STATUS_U_BIT 7 /* User/Kernel mode */
  41. #define STATUS_L_BIT 12 /* Loop inhibit */
  42. /* These masks correspond to the status word(STATUS_32) bits */
  43. #define STATUS_H_MASK (1<<STATUS_H_BIT)
  44. #define STATUS_E1_MASK (1<<STATUS_E1_BIT)
  45. #define STATUS_E2_MASK (1<<STATUS_E2_BIT)
  46. #define STATUS_A1_MASK (1<<STATUS_A1_BIT)
  47. #define STATUS_A2_MASK (1<<STATUS_A2_BIT)
  48. #define STATUS_AE_MASK (1<<STATUS_AE_BIT)
  49. #define STATUS_DE_MASK (1<<STATUS_DE_BIT)
  50. #define STATUS_U_MASK (1<<STATUS_U_BIT)
  51. #define STATUS_L_MASK (1<<STATUS_L_BIT)
  52. /*
  53. * ECR: Exception Cause Reg bits-n-pieces
  54. * [23:16] = Exception Vector
  55. * [15: 8] = Exception Cause Code
  56. * [ 7: 0] = Exception Parameters (for certain types only)
  57. */
  58. #define ECR_VEC_MASK 0xff0000
  59. #define ECR_CODE_MASK 0x00ff00
  60. #define ECR_PARAM_MASK 0x0000ff
  61. /* Exception Cause Vector Values */
  62. #define ECR_V_INSN_ERR 0x02
  63. #define ECR_V_MACH_CHK 0x20
  64. #define ECR_V_ITLB_MISS 0x21
  65. #define ECR_V_DTLB_MISS 0x22
  66. #define ECR_V_PROTV 0x23
  67. /* Protection Violation Exception Cause Code Values */
  68. #define ECR_C_PROTV_INST_FETCH 0x00
  69. #define ECR_C_PROTV_LOAD 0x01
  70. #define ECR_C_PROTV_STORE 0x02
  71. #define ECR_C_PROTV_XCHG 0x03
  72. #define ECR_C_PROTV_MISALIG_DATA 0x04
  73. /* DTLB Miss Exception Cause Code Values */
  74. #define ECR_C_BIT_DTLB_LD_MISS 8
  75. #define ECR_C_BIT_DTLB_ST_MISS 9
  76. /* Auxiliary registers */
  77. #define AUX_IDENTITY 4
  78. #define AUX_INTR_VEC_BASE 0x25
  79. #define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */
  80. #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
  81. #define AUX_IRQ_LV12 0x43 /* interrupt level register */
  82. #define AUX_IENABLE 0x40c
  83. #define AUX_ITRIGGER 0x40d
  84. #define AUX_IPULSE 0x415
  85. /* Timer related Aux registers */
  86. #define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */
  87. #define ARC_REG_TIMER0_CTRL 0x22 /* timer 0 control */
  88. #define ARC_REG_TIMER0_CNT 0x21 /* timer 0 count */
  89. #define ARC_REG_TIMER1_LIMIT 0x102 /* timer 1 limit */
  90. #define ARC_REG_TIMER1_CTRL 0x101 /* timer 1 control */
  91. #define ARC_REG_TIMER1_CNT 0x100 /* timer 1 count */
  92. #define TIMER_CTRL_IE (1 << 0) /* Interupt when Count reachs limit */
  93. #define TIMER_CTRL_NH (1 << 1) /* Count only when CPU NOT halted */
  94. /* MMU Management regs */
  95. #define ARC_REG_TLBPD0 0x405
  96. #define ARC_REG_TLBPD1 0x406
  97. #define ARC_REG_TLBINDEX 0x407
  98. #define ARC_REG_TLBCOMMAND 0x408
  99. #define ARC_REG_PID 0x409
  100. #define ARC_REG_SCRATCH_DATA0 0x418
  101. /* Bits in MMU PID register */
  102. #define MMU_ENABLE (1 << 31) /* Enable MMU for process */
  103. /* Error code if probe fails */
  104. #define TLB_LKUP_ERR 0x80000000
  105. /* TLB Commands */
  106. #define TLBWrite 0x1
  107. #define TLBRead 0x2
  108. #define TLBGetIndex 0x3
  109. #define TLBProbe 0x4
  110. #if (CONFIG_ARC_MMU_VER >= 2)
  111. #define TLBWriteNI 0x5 /* write JTLB without inv uTLBs */
  112. #define TLBIVUTLB 0x6 /* explicitly inv uTLBs */
  113. #else
  114. #undef TLBWriteNI /* These cmds don't exist on older MMU */
  115. #undef TLBIVUTLB
  116. #endif
  117. /* Instruction cache related Auxiliary registers */
  118. #define ARC_REG_IC_BCR 0x77 /* Build Config reg */
  119. #define ARC_REG_IC_IVIC 0x10
  120. #define ARC_REG_IC_CTRL 0x11
  121. #define ARC_REG_IC_IVIL 0x19
  122. #if (CONFIG_ARC_MMU_VER > 2)
  123. #define ARC_REG_IC_PTAG 0x1E
  124. #endif
  125. /* Bit val in IC_CTRL */
  126. #define IC_CTRL_CACHE_DISABLE 0x1
  127. /* Data cache related Auxiliary registers */
  128. #define ARC_REG_DC_BCR 0x72
  129. #define ARC_REG_DC_IVDC 0x47
  130. #define ARC_REG_DC_CTRL 0x48
  131. #define ARC_REG_DC_IVDL 0x4A
  132. #define ARC_REG_DC_FLSH 0x4B
  133. #define ARC_REG_DC_FLDL 0x4C
  134. #if (CONFIG_ARC_MMU_VER > 2)
  135. #define ARC_REG_DC_PTAG 0x5C
  136. #endif
  137. /* Bit val in DC_CTRL */
  138. #define DC_CTRL_INV_MODE_FLUSH 0x40
  139. #define DC_CTRL_FLUSH_STATUS 0x100
  140. /* MMU Management regs */
  141. #define ARC_REG_PID 0x409
  142. #define ARC_REG_SCRATCH_DATA0 0x418
  143. /* Bits in MMU PID register */
  144. #define MMU_ENABLE (1 << 31) /* Enable MMU for process */
  145. /*
  146. * Floating Pt Registers
  147. * Status regs are read-only (build-time) so need not be saved/restored
  148. */
  149. #define ARC_AUX_FP_STAT 0x300
  150. #define ARC_AUX_DPFP_1L 0x301
  151. #define ARC_AUX_DPFP_1H 0x302
  152. #define ARC_AUX_DPFP_2L 0x303
  153. #define ARC_AUX_DPFP_2H 0x304
  154. #define ARC_AUX_DPFP_STAT 0x305
  155. #ifndef __ASSEMBLY__
  156. /*
  157. ******************************************************************
  158. * Inline ASM macros to read/write AUX Regs
  159. * Essentially invocation of lr/sr insns from "C"
  160. */
  161. #if 1
  162. #define read_aux_reg(reg) __builtin_arc_lr(reg)
  163. /* gcc builtin sr needs reg param to be long immediate */
  164. #define write_aux_reg(reg_immed, val) \
  165. __builtin_arc_sr((unsigned int)val, reg_immed)
  166. #else
  167. #define read_aux_reg(reg) \
  168. ({ \
  169. unsigned int __ret; \
  170. __asm__ __volatile__( \
  171. " lr %0, [%1]" \
  172. : "=r"(__ret) \
  173. : "i"(reg)); \
  174. __ret; \
  175. })
  176. /*
  177. * Aux Reg address is specified as long immediate by caller
  178. * e.g.
  179. * write_aux_reg(0x69, some_val);
  180. * This generates tightest code.
  181. */
  182. #define write_aux_reg(reg_imm, val) \
  183. ({ \
  184. __asm__ __volatile__( \
  185. " sr %0, [%1] \n" \
  186. : \
  187. : "ir"(val), "i"(reg_imm)); \
  188. })
  189. /*
  190. * Aux Reg address is specified in a variable
  191. * * e.g.
  192. * reg_num = 0x69
  193. * write_aux_reg2(reg_num, some_val);
  194. * This has to generate glue code to load the reg num from
  195. * memory to a reg hence not recommended.
  196. */
  197. #define write_aux_reg2(reg_in_var, val) \
  198. ({ \
  199. unsigned int tmp; \
  200. \
  201. __asm__ __volatile__( \
  202. " ld %0, [%2] \n\t" \
  203. " sr %1, [%0] \n\t" \
  204. : "=&r"(tmp) \
  205. : "r"(val), "memory"(&reg_in_var)); \
  206. })
  207. #endif
  208. #define READ_BCR(reg, into) \
  209. { \
  210. unsigned int tmp; \
  211. tmp = read_aux_reg(reg); \
  212. if (sizeof(tmp) == sizeof(into)) { \
  213. into = *((typeof(into) *)&tmp); \
  214. } else { \
  215. extern void bogus_undefined(void); \
  216. bogus_undefined(); \
  217. } \
  218. }
  219. #define WRITE_BCR(reg, into) \
  220. { \
  221. unsigned int tmp; \
  222. if (sizeof(tmp) == sizeof(into)) { \
  223. tmp = (*(unsigned int *)(into)); \
  224. write_aux_reg(reg, tmp); \
  225. } else { \
  226. extern void bogus_undefined(void); \
  227. bogus_undefined(); \
  228. } \
  229. }
  230. /* Helpers */
  231. #define TO_KB(bytes) ((bytes) >> 10)
  232. #define TO_MB(bytes) (TO_KB(bytes) >> 10)
  233. #define PAGES_TO_KB(n_pages) ((n_pages) << (PAGE_SHIFT - 10))
  234. #define PAGES_TO_MB(n_pages) (PAGES_TO_KB(n_pages) >> 10)
  235. #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
  236. /* These DPFP regs need to be saved/restored across ctx-sw */
  237. struct arc_fpu {
  238. struct {
  239. unsigned int l, h;
  240. } aux_dpfp[2];
  241. };
  242. #endif
  243. /*
  244. ***************************************************************
  245. * Build Configuration Registers, with encoded hardware config
  246. */
  247. struct bcr_identity {
  248. #ifdef CONFIG_CPU_BIG_ENDIAN
  249. unsigned int chip_id:16, cpu_id:8, family:8;
  250. #else
  251. unsigned int family:8, cpu_id:8, chip_id:16;
  252. #endif
  253. };
  254. struct bcr_mmu_1_2 {
  255. #ifdef CONFIG_CPU_BIG_ENDIAN
  256. unsigned int ver:8, ways:4, sets:4, u_itlb:8, u_dtlb:8;
  257. #else
  258. unsigned int u_dtlb:8, u_itlb:8, sets:4, ways:4, ver:8;
  259. #endif
  260. };
  261. struct bcr_mmu_3 {
  262. #ifdef CONFIG_CPU_BIG_ENDIAN
  263. unsigned int ver:8, ways:4, sets:4, osm:1, reserv:3, pg_sz:4,
  264. u_itlb:4, u_dtlb:4;
  265. #else
  266. unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, reserv:3, osm:1, sets:4,
  267. ways:4, ver:8;
  268. #endif
  269. };
  270. #define EXTN_SWAP_VALID 0x1
  271. #define EXTN_NORM_VALID 0x2
  272. #define EXTN_MINMAX_VALID 0x2
  273. #define EXTN_BARREL_VALID 0x2
  274. struct bcr_extn {
  275. #ifdef CONFIG_CPU_BIG_ENDIAN
  276. unsigned int pad:20, crc:1, ext_arith:2, mul:2, barrel:2, minmax:2,
  277. norm:2, swap:1;
  278. #else
  279. unsigned int swap:1, norm:2, minmax:2, barrel:2, mul:2, ext_arith:2,
  280. crc:1, pad:20;
  281. #endif
  282. };
  283. /* DSP Options Ref Manual */
  284. struct bcr_extn_mac_mul {
  285. #ifdef CONFIG_CPU_BIG_ENDIAN
  286. unsigned int pad:16, type:8, ver:8;
  287. #else
  288. unsigned int ver:8, type:8, pad:16;
  289. #endif
  290. };
  291. struct bcr_extn_xymem {
  292. #ifdef CONFIG_CPU_BIG_ENDIAN
  293. unsigned int ram_org:2, num_banks:4, bank_sz:4, ver:8;
  294. #else
  295. unsigned int ver:8, bank_sz:4, num_banks:4, ram_org:2;
  296. #endif
  297. };
  298. struct bcr_cache {
  299. #ifdef CONFIG_CPU_BIG_ENDIAN
  300. unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
  301. #else
  302. unsigned int ver:8, config:4, sz:4, line_len:4, pad:12;
  303. #endif
  304. };
  305. struct bcr_perip {
  306. #ifdef CONFIG_CPU_BIG_ENDIAN
  307. unsigned int start:8, pad2:8, sz:8, pad:8;
  308. #else
  309. unsigned int pad:8, sz:8, pad2:8, start:8;
  310. #endif
  311. };
  312. struct bcr_iccm {
  313. #ifdef CONFIG_CPU_BIG_ENDIAN
  314. unsigned int base:16, pad:5, sz:3, ver:8;
  315. #else
  316. unsigned int ver:8, sz:3, pad:5, base:16;
  317. #endif
  318. };
  319. /* DCCM Base Address Register: ARC_REG_DCCMBASE_BCR */
  320. struct bcr_dccm_base {
  321. #ifdef CONFIG_CPU_BIG_ENDIAN
  322. unsigned int addr:24, ver:8;
  323. #else
  324. unsigned int ver:8, addr:24;
  325. #endif
  326. };
  327. /* DCCM RAM Configuration Register: ARC_REG_DCCM_BCR */
  328. struct bcr_dccm {
  329. #ifdef CONFIG_CPU_BIG_ENDIAN
  330. unsigned int res:21, sz:3, ver:8;
  331. #else
  332. unsigned int ver:8, sz:3, res:21;
  333. #endif
  334. };
  335. /* Both SP and DP FPU BCRs have same format */
  336. struct bcr_fp {
  337. #ifdef CONFIG_CPU_BIG_ENDIAN
  338. unsigned int fast:1, ver:8;
  339. #else
  340. unsigned int ver:8, fast:1;
  341. #endif
  342. };
  343. /*
  344. *******************************************************************
  345. * Generic structures to hold build configuration used at runtime
  346. */
  347. struct cpuinfo_arc_mmu {
  348. unsigned int ver, pg_sz, sets, ways, u_dtlb, u_itlb, num_tlb;
  349. };
  350. struct cpuinfo_arc_cache {
  351. unsigned int has_aliasing, sz, line_len, assoc, ver;
  352. };
  353. struct cpuinfo_arc_ccm {
  354. unsigned int base_addr, sz;
  355. };
  356. struct cpuinfo_arc {
  357. struct cpuinfo_arc_cache icache, dcache;
  358. struct cpuinfo_arc_mmu mmu;
  359. struct bcr_identity core;
  360. unsigned int timers;
  361. unsigned int vec_base;
  362. unsigned int uncached_base;
  363. struct cpuinfo_arc_ccm iccm, dccm;
  364. struct bcr_extn extn;
  365. struct bcr_extn_xymem extn_xymem;
  366. struct bcr_extn_mac_mul extn_mac_mul;
  367. struct bcr_fp fp, dpfp;
  368. };
  369. extern struct cpuinfo_arc cpuinfo_arc700[];
  370. #endif /* __ASEMBLY__ */
  371. #endif /* __KERNEL__ */
  372. #endif /* _ASM_ARC_ARCREGS_H */