aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/netlogic/xlr/pic.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/include/asm/netlogic/xlr/pic.h')
-rw-r--r--arch/mips/include/asm/netlogic/xlr/pic.h48
1 files changed, 45 insertions, 3 deletions
diff --git a/arch/mips/include/asm/netlogic/xlr/pic.h b/arch/mips/include/asm/netlogic/xlr/pic.h
index 2f549453585e..63c99176dffe 100644
--- a/arch/mips/include/asm/netlogic/xlr/pic.h
+++ b/arch/mips/include/asm/netlogic/xlr/pic.h
@@ -35,10 +35,11 @@
35#ifndef _ASM_NLM_XLR_PIC_H 35#ifndef _ASM_NLM_XLR_PIC_H
36#define _ASM_NLM_XLR_PIC_H 36#define _ASM_NLM_XLR_PIC_H
37 37
38#define PIC_CLKS_PER_SEC 66666666ULL 38#define PIC_CLK_HZ 66666666
39/* PIC hardware interrupt numbers */ 39/* PIC hardware interrupt numbers */
40#define PIC_IRT_WD_INDEX 0 40#define PIC_IRT_WD_INDEX 0
41#define PIC_IRT_TIMER_0_INDEX 1 41#define PIC_IRT_TIMER_0_INDEX 1
42#define PIC_IRT_TIMER_INDEX(i) ((i) + PIC_IRT_TIMER_0_INDEX)
42#define PIC_IRT_TIMER_1_INDEX 2 43#define PIC_IRT_TIMER_1_INDEX 2
43#define PIC_IRT_TIMER_2_INDEX 3 44#define PIC_IRT_TIMER_2_INDEX 3
44#define PIC_IRT_TIMER_3_INDEX 4 45#define PIC_IRT_TIMER_3_INDEX 4
@@ -99,6 +100,7 @@
99 100
100/* PIC Registers */ 101/* PIC Registers */
101#define PIC_CTRL 0x00 102#define PIC_CTRL 0x00
103#define PIC_CTRL_STE 8 /* timer enable start bit */
102#define PIC_IPI 0x04 104#define PIC_IPI 0x04
103#define PIC_INT_ACK 0x06 105#define PIC_INT_ACK 0x06
104 106
@@ -251,12 +253,52 @@ nlm_pic_ack(uint64_t base, int irt)
251} 253}
252 254
253static inline void 255static inline void
254nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt) 256nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt, int en)
255{ 257{
256 nlm_write_reg(base, PIC_IRT_0(irt), (1u << hwt)); 258 nlm_write_reg(base, PIC_IRT_0(irt), (1u << hwt));
257 /* local scheduling, invalid, level by default */ 259 /* local scheduling, invalid, level by default */
258 nlm_write_reg(base, PIC_IRT_1(irt), 260 nlm_write_reg(base, PIC_IRT_1(irt),
259 (1 << 30) | (1 << 6) | irq); 261 (en << 30) | (1 << 6) | irq);
262}
263
264static inline uint64_t
265nlm_pic_read_timer(uint64_t base, int timer)
266{
267 uint32_t up1, up2, low;
268
269 up1 = nlm_read_reg(base, PIC_TIMER_COUNT_1(timer));
270 low = nlm_read_reg(base, PIC_TIMER_COUNT_0(timer));
271 up2 = nlm_read_reg(base, PIC_TIMER_COUNT_1(timer));
272
273 if (up1 != up2) /* wrapped, get the new low */
274 low = nlm_read_reg(base, PIC_TIMER_COUNT_0(timer));
275 return ((uint64_t)up2 << 32) | low;
276
277}
278
279static inline uint32_t
280nlm_pic_read_timer32(uint64_t base, int timer)
281{
282 return nlm_read_reg(base, PIC_TIMER_COUNT_0(timer));
283}
284
285static inline void
286nlm_pic_set_timer(uint64_t base, int timer, uint64_t value, int irq, int cpu)
287{
288 uint32_t up, low;
289 uint64_t pic_ctrl = nlm_read_reg(base, PIC_CTRL);
290 int en;
291
292 en = (irq > 0);
293 up = value >> 32;
294 low = value & 0xFFFFFFFF;
295 nlm_write_reg(base, PIC_TIMER_MAXVAL_0(timer), low);
296 nlm_write_reg(base, PIC_TIMER_MAXVAL_1(timer), up);
297 nlm_pic_init_irt(base, PIC_IRT_TIMER_INDEX(timer), irq, cpu, 0);
298
299 /* enable the timer */
300 pic_ctrl |= (1 << (PIC_CTRL_STE + timer));
301 nlm_write_reg(base, PIC_CTRL, pic_ctrl);
260} 302}
261#endif 303#endif
262#endif /* _ASM_NLM_XLR_PIC_H */ 304#endif /* _ASM_NLM_XLR_PIC_H */