blob: 264bdc7d6c7ef5e42b16678fd9b6c42b745bbe8a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenke65527f2004-02-12 00:47:09 +00002/*
wdenke65527f2004-02-12 00:47:09 +00003 * (C) Copyright 2000-2004
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wang95bed1f2012-03-26 21:49:04 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiew34674692007-08-16 13:20:50 -05007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
wdenke65527f2004-02-12 00:47:09 +00008 */
9
Simon Glass9b61c7c2019-11-14 12:57:41 -070010#include <irq_func.h>
wdenke65527f2004-02-12 00:47:09 +000011#include <watchdog.h>
12#include <asm/processor.h>
TsiChungLiew8cd73be2007-08-15 19:21:21 -050013#include <asm/immap.h>
Alison Wang95bed1f2012-03-26 21:49:04 +000014#include <asm/io.h>
Zachary P. Landau0bba8622006-01-26 17:35:56 -050015
wdenke65527f2004-02-12 00:47:09 +000016#ifdef CONFIG_M5272
TsiChungLiew8cd73be2007-08-15 19:21:21 -050017int interrupt_init(void)
wdenke65527f2004-02-12 00:47:09 +000018{
Alison Wang95bed1f2012-03-26 21:49:04 +000019 intctrl_t *intp = (intctrl_t *) (MMAP_INTC);
wdenke65527f2004-02-12 00:47:09 +000020
TsiChungLiew8cd73be2007-08-15 19:21:21 -050021 /* disable all external interrupts */
Alison Wang95bed1f2012-03-26 21:49:04 +000022 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
TsiChungLiew8cd73be2007-08-15 19:21:21 -050028 /* initialize vector register */
Alison Wang95bed1f2012-03-26 21:49:04 +000029 out_8(&intp->int_pivr, 0x40);
wdenke65527f2004-02-12 00:47:09 +000030
TsiChungLiew8cd73be2007-08-15 19:21:21 -050031 enable_interrupts();
wdenke65527f2004-02-12 00:47:09 +000032
TsiChungLiew8cd73be2007-08-15 19:21:21 -050033 return 0;
wdenke65527f2004-02-12 00:47:09 +000034}
35
Marek Vasut38908f52023-03-23 01:20:39 +010036#if CONFIG_IS_ENABLED(MCFTMR)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050037void dtimer_intr_setup(void)
wdenke65527f2004-02-12 00:47:09 +000038{
Tom Rini364d0022023-01-10 11:19:45 -050039 intctrl_t *intp = (intctrl_t *) (CFG_SYS_INTR_BASE);
wdenke65527f2004-02-12 00:47:09 +000040
Alison Wang95bed1f2012-03-26 21:49:04 +000041 clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK);
Tom Rini364d0022023-01-10 11:19:45 -050042 setbits_be32(&intp->int_icr1, CFG_SYS_TMRINTR_PRI);
wdenke65527f2004-02-12 00:47:09 +000043}
Marek Vasut38908f52023-03-23 01:20:39 +010044#endif /* CONFIG_MCFTMR */
TsiChungLiew8cd73be2007-08-15 19:21:21 -050045#endif /* CONFIG_M5272 */
wdenke65527f2004-02-12 00:47:09 +000046
TsiChung Liewb354aef2009-06-12 11:29:00 +000047#if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \
48 defined(CONFIG_M5271) || defined(CONFIG_M5275)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050049int interrupt_init(void)
wdenke65527f2004-02-12 00:47:09 +000050{
Tom Rini364d0022023-01-10 11:19:45 -050051 int0_t *intp = (int0_t *) (CFG_SYS_INTR_BASE);
wdenke65527f2004-02-12 00:47:09 +000052
TsiChungLiew8cd73be2007-08-15 19:21:21 -050053 /* Make sure all interrupts are disabled */
TsiChung Liewb354aef2009-06-12 11:29:00 +000054#if defined(CONFIG_M5208)
Alison Wang95bed1f2012-03-26 21:49:04 +000055 out_be32(&intp->imrl0, 0xffffffff);
56 out_be32(&intp->imrh0, 0xffffffff);
TsiChung Liewb354aef2009-06-12 11:29:00 +000057#else
Alison Wang95bed1f2012-03-26 21:49:04 +000058 setbits_be32(&intp->imrl0, 0x1);
TsiChung Liewb354aef2009-06-12 11:29:00 +000059#endif
wdenke65527f2004-02-12 00:47:09 +000060
TsiChungLiew8cd73be2007-08-15 19:21:21 -050061 enable_interrupts();
62 return 0;
wdenke65527f2004-02-12 00:47:09 +000063}
64
Marek Vasut38908f52023-03-23 01:20:39 +010065#if CONFIG_IS_ENABLED(MCFTMR)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050066void dtimer_intr_setup(void)
wdenke65527f2004-02-12 00:47:09 +000067{
Tom Rini364d0022023-01-10 11:19:45 -050068 int0_t *intp = (int0_t *) (CFG_SYS_INTR_BASE);
wdenke65527f2004-02-12 00:47:09 +000069
Tom Rini364d0022023-01-10 11:19:45 -050070 out_8(&intp->icr0[CFG_SYS_TMRINTR_NO], CFG_SYS_TMRINTR_PRI);
Alison Wang95bed1f2012-03-26 21:49:04 +000071 clrbits_be32(&intp->imrl0, 0x00000001);
Tom Rini364d0022023-01-10 11:19:45 -050072 clrbits_be32(&intp->imrl0, CFG_SYS_TMRINTR_MASK);
wdenke65527f2004-02-12 00:47:09 +000073}
Marek Vasut38908f52023-03-23 01:20:39 +010074#endif /* CONFIG_MCFTMR */
Matthew Fettke761e2e92008-02-04 15:38:20 -060075#endif /* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */
wdenke65527f2004-02-12 00:47:09 +000076
TsiChungLiew34674692007-08-16 13:20:50 -050077#if defined(CONFIG_M5249) || defined(CONFIG_M5253)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050078int interrupt_init(void)
wdenke65527f2004-02-12 00:47:09 +000079{
TsiChungLiew8cd73be2007-08-15 19:21:21 -050080 enable_interrupts();
wdenke65527f2004-02-12 00:47:09 +000081
82 return 0;
83}
wdenke65527f2004-02-12 00:47:09 +000084
Marek Vasut38908f52023-03-23 01:20:39 +010085#if CONFIG_IS_ENABLED(MCFTMR)
TsiChungLiew8cd73be2007-08-15 19:21:21 -050086void dtimer_intr_setup(void)
wdenke65527f2004-02-12 00:47:09 +000087{
TsiChungLiew8cd73be2007-08-15 19:21:21 -050088 mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400);
Tom Rini364d0022023-01-10 11:19:45 -050089 mbar_writeByte(MCFSIM_TIMER2ICR, CFG_SYS_TMRINTR_PRI);
stroese53395a22004-12-16 18:09:49 +000090}
Marek Vasut38908f52023-03-23 01:20:39 +010091#endif /* CONFIG_MCFTMR */
TsiChungLiew34674692007-08-16 13:20:50 -050092#endif /* CONFIG_M5249 || CONFIG_M5253 */