Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 2 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 3 | * (C) Copyright 2000-2004 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 6 | * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 7 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Simon Glass | 9b61c7c | 2019-11-14 12:57:41 -0700 | [diff] [blame] | 10 | #include <irq_func.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 11 | #include <watchdog.h> |
| 12 | #include <asm/processor.h> |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 13 | #include <asm/immap.h> |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 15 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 16 | #ifdef CONFIG_M5272 |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 17 | int interrupt_init(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 18 | { |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 19 | intctrl_t *intp = (intctrl_t *) (MMAP_INTC); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 20 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 21 | /* disable all external interrupts */ |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 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 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 28 | /* initialize vector register */ |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 29 | out_8(&intp->int_pivr, 0x40); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 30 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 31 | enable_interrupts(); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 32 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 33 | return 0; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 36 | #if CONFIG_IS_ENABLED(MCFTMR) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 37 | void dtimer_intr_setup(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 38 | { |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 39 | intctrl_t *intp = (intctrl_t *) (CFG_SYS_INTR_BASE); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 40 | |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 41 | clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK); |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 42 | setbits_be32(&intp->int_icr1, CFG_SYS_TMRINTR_PRI); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 43 | } |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 44 | #endif /* CONFIG_MCFTMR */ |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 45 | #endif /* CONFIG_M5272 */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 46 | |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 47 | #if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \ |
| 48 | defined(CONFIG_M5271) || defined(CONFIG_M5275) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 49 | int interrupt_init(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 50 | { |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 51 | int0_t *intp = (int0_t *) (CFG_SYS_INTR_BASE); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 52 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 53 | /* Make sure all interrupts are disabled */ |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 54 | #if defined(CONFIG_M5208) |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 55 | out_be32(&intp->imrl0, 0xffffffff); |
| 56 | out_be32(&intp->imrh0, 0xffffffff); |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 57 | #else |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 58 | setbits_be32(&intp->imrl0, 0x1); |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 59 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 60 | |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 61 | enable_interrupts(); |
| 62 | return 0; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 65 | #if CONFIG_IS_ENABLED(MCFTMR) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 66 | void dtimer_intr_setup(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 67 | { |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 68 | int0_t *intp = (int0_t *) (CFG_SYS_INTR_BASE); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 69 | |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 70 | out_8(&intp->icr0[CFG_SYS_TMRINTR_NO], CFG_SYS_TMRINTR_PRI); |
Alison Wang | 95bed1f | 2012-03-26 21:49:04 +0000 | [diff] [blame] | 71 | clrbits_be32(&intp->imrl0, 0x00000001); |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 72 | clrbits_be32(&intp->imrl0, CFG_SYS_TMRINTR_MASK); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 73 | } |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 74 | #endif /* CONFIG_MCFTMR */ |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 75 | #endif /* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 76 | |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 77 | #if defined(CONFIG_M5249) || defined(CONFIG_M5253) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 78 | int interrupt_init(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 79 | { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 80 | enable_interrupts(); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 81 | |
| 82 | return 0; |
| 83 | } |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 84 | |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 85 | #if CONFIG_IS_ENABLED(MCFTMR) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 86 | void dtimer_intr_setup(void) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 87 | { |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 88 | mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400); |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 89 | mbar_writeByte(MCFSIM_TIMER2ICR, CFG_SYS_TMRINTR_PRI); |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 90 | } |
Marek Vasut | 38908f5 | 2023-03-23 01:20:39 +0100 | [diff] [blame] | 91 | #endif /* CONFIG_MCFTMR */ |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 92 | #endif /* CONFIG_M5249 || CONFIG_M5253 */ |