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