Skip to content

Commit eb4b5fd

Browse files
committed
arch/tricore: drop illd dependence for irq
Access the SRC (Service Request Control) and INT registers directly instead of going through IfxSrc/IfxCpu/IfxInt: - tc3xx/tc4xx irq.h: add the SRC register bit layout (it differs between TC3xx and TC4xx) and the INT LASR base addresses. - irq.h: drop IfxCpu_Intrinsics.h and IfxCpu_reg.h, add the ICR.CCPN field definitions, and use the "disable"/"restore" instructions directly in up_irq_save()/up_irq_restore(). - tricore_irq.c: add tricore_src_init() replacing IfxSrc_init(), and replace the remaining IfxSrc/IfxCpu calls with register accesses and the "enable" instruction. - tc4xx CMakeLists.txt/Make.defs: drop the SRC_GPSR00 and SRC_CPU_CPU0_SB aliases that are no longer used. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
1 parent f7fc0f7 commit eb4b5fd

8 files changed

Lines changed: 167 additions & 97 deletions

File tree

‎arch/tricore/include/irq.h‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545

4646
#include <arch/chip/irq.h>
4747
#include <arch/arch.h>
48-
#include <IfxCpu_Intrinsics.h>
49-
#include <IfxCpu_reg.h>
5048

5149
/****************************************************************************
5250
* Pre-processor Prototypes
@@ -158,6 +156,18 @@
158156
#define TRICORE_IRQ_MIN_PRIORITY 1
159157
#define TRICORE_IRQ_MAX_PRIORITY CONFIG_ARCH_IRQ_MAX_PRIORITY
160158

159+
/* ICR (Interrupt Control Register) bit definitions.
160+
* [7:0] CCPN - Current CPU Priority Number
161+
* [15] IE - Interrupt Enable (global)
162+
* [23:16] PIPN - Previous Interrupt Priority Number
163+
*/
164+
165+
#define ICR_CCPN_SHIFT 0
166+
#define ICR_CCPN_MASK (0xffu << ICR_CCPN_SHIFT)
167+
#define ICR_IE (1u << 15)
168+
#define ICR_PIPN_SHIFT 16
169+
#define ICR_PIPN_MASK (0xffu << ICR_PIPN_SHIFT)
170+
161171
/* For use with EABI and floating point, the stack must be aligned to 8-byte
162172
* addresses.
163173
*/
@@ -264,22 +274,23 @@ noinstrument_function static inline_function uintptr_t up_getsp(void)
264274
noinstrument_function static inline_function irqstate_t up_irq_save(void)
265275
{
266276
#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
267-
Ifx_CPU_ICR icr;
268-
irqstate_t ccpn;
269-
270-
icr.U = tricore_mfcr(CPU_ICR);
271-
ccpn = icr.B.CCPN;
277+
uint32_t icr = tricore_mfcr(CPU_ICR);
278+
irqstate_t ccpn = (icr & ICR_CCPN_MASK) >> ICR_CCPN_SHIFT;
272279

273280
if (TRICORE_IRQ_DISABLE_PRIORITY > ccpn)
274281
{
275-
icr.B.CCPN = TRICORE_IRQ_DISABLE_PRIORITY;
276-
tricore_mtcr(CPU_ICR, icr.U);
282+
icr &= ~ICR_CCPN_MASK;
283+
icr |= TRICORE_IRQ_DISABLE_PRIORITY << ICR_CCPN_SHIFT;
284+
tricore_mtcr(CPU_ICR, icr);
277285
UP_ISB();
278286
}
279287

280288
return ccpn;
281289
#else
282-
return __disable_and_save();
290+
irqstate_t flags;
291+
292+
__asm__ volatile ("disable %0" : "=d"(flags) :: "memory");
293+
return flags;
283294
#endif
284295
}
285296

@@ -298,17 +309,17 @@ noinstrument_function static inline_function
298309
void up_irq_restore(irqstate_t flags)
299310
{
300311
#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
301-
Ifx_CPU_ICR icr;
312+
uint32_t icr = tricore_mfcr(CPU_ICR);
302313

303-
icr.U = tricore_mfcr(CPU_ICR);
304-
if (flags < icr.B.CCPN)
314+
if (flags < ((icr & ICR_CCPN_MASK) >> ICR_CCPN_SHIFT))
305315
{
306-
icr.B.CCPN = flags;
307-
tricore_mtcr(CPU_ICR, icr.U);
316+
icr &= ~ICR_CCPN_MASK;
317+
icr |= flags << ICR_CCPN_SHIFT;
318+
tricore_mtcr(CPU_ICR, icr);
308319
UP_ISB();
309320
}
310321
#else
311-
__restore(flags);
322+
__asm__ volatile ("restore %0" :: "d"(flags) : "memory");
312323
#endif
313324
}
314325

‎arch/tricore/include/tc3xx/irq.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,39 @@
3535
* Pre-processor Prototypes
3636
****************************************************************************/
3737

38+
/* Service Request Control (SRC) register bit definitions.
39+
*
40+
* TC3xx layout:
41+
* [7:0] SRPN - Service Request Priority Number
42+
* [10] SRE - Service Request Enable
43+
* [13:11] TOS - Type of Service (3-bit, CPU0-5/DMA)
44+
* No VM / CS fields.
45+
*
46+
* Common bits (identical on both TC3xx/TC4xx):
47+
* [24] SRR, [25] CLRR, [26] SETR, [27] IOV, [28] IOVCLR
48+
*/
49+
50+
#define SRCR_SRPN_SHIFT 0
51+
#define SRCR_SRPN_MASK (0xffu << SRCR_SRPN_SHIFT)
52+
#define SRCR_VM_SHIFT 0
53+
#define SRCR_VM_MASK 0
54+
#define SRCR_CS 0
55+
#define SRCR_TOS_SHIFT 11
56+
#define SRCR_TOS_MASK (0x7u << SRCR_TOS_SHIFT)
57+
#define SRCR_SRE (1u << 10)
58+
#define SRCR_SRR (1u << 24)
59+
#define SRCR_CLRR (1u << 25)
60+
#define SRCR_SETR (1u << 26)
61+
#define SRCR_IOV (1u << 27)
62+
#define SRCR_IOVCLR (1u << 28)
63+
3864
/* Service Request Control (SRC) */
3965

4066
#define TRICORE_SRC_BASEADDR 0xf0038000
4167
#define TRICORE_SRC_GPSR0_SR0 0xf0038990
4268
#define TRICORE_INT_SRB0_ADDR 0xf0037010
69+
#define TRICORE_INT_LASR0_ADDR 0xf0037204
70+
#define TRICORE_INT_LASR_SPACING 0x10
4371

4472
/* Type of Service (TOS) */
4573

‎arch/tricore/include/tc4xx/irq.h‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,40 @@
3535
* Pre-processor Prototypes
3636
****************************************************************************/
3737

38+
/* Service Request Control (SRC) register bit definitions.
39+
*
40+
* TC4xx layout:
41+
* [7:0] SRPN - Service Request Priority Number
42+
* [10:8] VM - Virtual Machine ID
43+
* [11] CS - Context Save
44+
* [15:12] TOS - Type of Service (4-bit, CPU0-5/CSRM/DMA0-1/GTM/PPU)
45+
* [23] SRE - Service Request Enable
46+
*
47+
* Common bits (identical on both TC3xx/TC4xx):
48+
* [24] SRR, [25] CLRR, [26] SETR, [27] IOV, [28] IOVCLR
49+
*/
50+
51+
#define SRCR_SRPN_SHIFT 0
52+
#define SRCR_SRPN_MASK (0xffu << SRCR_SRPN_SHIFT)
53+
#define SRCR_VM_SHIFT 8
54+
#define SRCR_VM_MASK (0x7u << SRCR_VM_SHIFT)
55+
#define SRCR_CS (1u << 11)
56+
#define SRCR_TOS_SHIFT 12
57+
#define SRCR_TOS_MASK (0xfu << SRCR_TOS_SHIFT)
58+
#define SRCR_SRE (1u << 23)
59+
#define SRCR_SRR (1u << 24)
60+
#define SRCR_CLRR (1u << 25)
61+
#define SRCR_SETR (1u << 26)
62+
#define SRCR_IOV (1u << 27)
63+
#define SRCR_IOVCLR (1u << 28)
64+
3865
/* Service Request Control (SRC) */
3966

4067
#define TRICORE_SRC_BASEADDR 0xf4432000 /* TC4DX */
4168
#define TRICORE_SRC_GPSR0_SR0 0xf4433460 /* TC4DX */
4269
#define TRICORE_INT_SRB0_ADDR 0xf4430b00 /* TC4DX */
70+
#define TRICORE_INT_LASR0_ADDR 0xf4430c20
71+
#define TRICORE_INT_LASR_SPACING 0x34
4372

4473
/* Type of Service (TOS) */
4574

‎arch/tricore/src/common/tricore_doirq.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@
4141

4242
#include "tricore_internal.h"
4343

44-
#include "IfxCpu.h"
45-
#include "IfxInt_reg.h"
46-
47-
/****************************************************************************
48-
* Pre-processor Definitions
49-
****************************************************************************/
50-
51-
#define TRICORE_INT_LASR0_ADDR ((uintptr_t)&INT_LASR0)
52-
#define TRICORE_INT_LASR_SPACING ((uintptr_t)&INT_LASR1 - \
53-
(uintptr_t)&INT_LASR0)
54-
5544
/****************************************************************************
5645
* Private Functions
5746
****************************************************************************/

‎arch/tricore/src/common/tricore_internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ extern uintptr_t _eheap[]; /* End+1 of .heap */
171171
/* Interrupt ****************************************************************/
172172

173173
void tricore_ack_irq(int irq);
174+
void tricore_src_init(int irq, uint8_t tos, uint8_t srpn);
174175
int tricore_srpn_to_irq(int srpn);
175176
int tricore_irq_to_srpn(int irq);
176177
void tricore_register_irq_srpn(int irq);

0 commit comments

Comments
 (0)