1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2000-2004
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
7  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
8  */
9 
10 #include <common.h>
11 #include <watchdog.h>
12 #include <asm/processor.h>
13 #include <asm/immap.h>
14 #include <asm/io.h>
15 
16 #ifdef	CONFIG_M5272
17 int interrupt_init(void)
18 {
19 	intctrl_t *intp = (intctrl_t *) (MMAP_INTC);
20 
21 	/* disable all external interrupts */
22 	out_be32(&intp->int_icr1, 0x88888888);
23 	out_be32(&intp->int_icr2, 0x88888888);
24 	out_be32(&intp->int_icr3, 0x88888888);
25 	out_be32(&intp->int_icr4, 0x88888888);
26 	out_be32(&intp->int_pitr, 0x00000000);
27 
28 	/* initialize vector register */
29 	out_8(&intp->int_pivr, 0x40);
30 
31 	enable_interrupts();
32 
33 	return 0;
34 }
35 
36 #if defined(CONFIG_MCFTMR)
37 void dtimer_intr_setup(void)
38 {
39 	intctrl_t *intp = (intctrl_t *) (CONFIG_SYS_INTR_BASE);
40 
41 	clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK);
42 	setbits_be32(&intp->int_icr1, CONFIG_SYS_TMRINTR_PRI);
43 }
44 #endif				/* CONFIG_MCFTMR */
45 #endif				/* CONFIG_M5272 */
46 
47 #if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \
48     defined(CONFIG_M5271) || defined(CONFIG_M5275)
49 int interrupt_init(void)
50 {
51 	int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
52 
53 	/* Make sure all interrupts are disabled */
54 #if defined(CONFIG_M5208)
55 	out_be32(&intp->imrl0, 0xffffffff);
56 	out_be32(&intp->imrh0, 0xffffffff);
57 #else
58 	setbits_be32(&intp->imrl0, 0x1);
59 #endif
60 
61 	enable_interrupts();
62 	return 0;
63 }
64 
65 #if defined(CONFIG_MCFTMR)
66 void dtimer_intr_setup(void)
67 {
68 	int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
69 
70 	out_8(&intp->icr0[CONFIG_SYS_TMRINTR_NO], CONFIG_SYS_TMRINTR_PRI);
71 	clrbits_be32(&intp->imrl0, 0x00000001);
72 	clrbits_be32(&intp->imrl0, CONFIG_SYS_TMRINTR_MASK);
73 }
74 #endif				/* CONFIG_MCFTMR */
75 #endif				/* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */
76 
77 #if defined(CONFIG_M5249) || defined(CONFIG_M5253)
78 int interrupt_init(void)
79 {
80 	enable_interrupts();
81 
82 	return 0;
83 }
84 
85 #if defined(CONFIG_MCFTMR)
86 void dtimer_intr_setup(void)
87 {
88 	mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400);
89 	mbar_writeByte(MCFSIM_TIMER2ICR, CONFIG_SYS_TMRINTR_PRI);
90 }
91 #endif				/* CONFIG_MCFTMR */
92 #endif				/* CONFIG_M5249 || CONFIG_M5253 */
93