blob: f874675b12f495a2156c8d0dfc39fec1a8e963c9 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkbf9e3b32004-02-12 00:47:09 +00002/*
wdenkbf9e3b32004-02-12 00:47:09 +00003 * (C) Copyright 2000-2004
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 *
Alison Wang32dbaaf2012-03-26 21:49:04 +00006 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiewa1436a82007-08-16 13:20:50 -05007 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
wdenkbf9e3b32004-02-12 00:47:09 +00008 */
9
10#include <common.h>
11#include <watchdog.h>
12#include <asm/processor.h>
TsiChungLiew83ec20b2007-08-15 19:21:21 -050013#include <asm/immap.h>
Alison Wang32dbaaf2012-03-26 21:49:04 +000014#include <asm/io.h>
Zachary P. Landaueacbd312006-01-26 17:35:56 -050015
wdenkbf9e3b32004-02-12 00:47:09 +000016#ifdef CONFIG_M5272
TsiChungLiew83ec20b2007-08-15 19:21:21 -050017int interrupt_init(void)
wdenkbf9e3b32004-02-12 00:47:09 +000018{
Alison Wang32dbaaf2012-03-26 21:49:04 +000019 intctrl_t *intp = (intctrl_t *) (MMAP_INTC);
wdenkbf9e3b32004-02-12 00:47:09 +000020
21 /* disable all external interrupts */
Alison Wang32dbaaf2012-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
wdenkbf9e3b32004-02-12 00:47:09 +000028 /* initialize vector register */
Alison Wang32dbaaf2012-03-26 21:49:04 +000029 out_8(&intp->int_pivr, 0x40);
wdenkbf9e3b32004-02-12 00:47:09 +000030
TsiChungLiew83ec20b2007-08-15 19:21:21 -050031 enable_interrupts();
wdenkbf9e3b32004-02-12 00:47:09 +000032
33 return 0;
34}
TsiChungLiew83ec20b2007-08-15 19:21:21 -050035
36#if defined(CONFIG_MCFTMR)
37void dtimer_intr_setup(void)
38{
Alison Wang32dbaaf2012-03-26 21:49:04 +000039 intctrl_t *intp = (intctrl_t *) (CONFIG_SYS_INTR_BASE);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050040
Alison Wang32dbaaf2012-03-26 21:49:04 +000041 clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK);
42 setbits_be32(&intp->int_icr1, CONFIG_SYS_TMRINTR_PRI);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050043}
44#endif /* CONFIG_MCFTMR */
45#endif /* CONFIG_M5272 */
wdenkbf9e3b32004-02-12 00:47:09 +000046
TsiChung Liewbf9a5212009-06-12 11:29:00 +000047#if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \
48 defined(CONFIG_M5271) || defined(CONFIG_M5275)
TsiChungLiew83ec20b2007-08-15 19:21:21 -050049int interrupt_init(void)
wdenkbf9e3b32004-02-12 00:47:09 +000050{
Alison Wang32dbaaf2012-03-26 21:49:04 +000051 int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050052
53 /* Make sure all interrupts are disabled */
TsiChung Liewbf9a5212009-06-12 11:29:00 +000054#if defined(CONFIG_M5208)
Alison Wang32dbaaf2012-03-26 21:49:04 +000055 out_be32(&intp->imrl0, 0xffffffff);
56 out_be32(&intp->imrh0, 0xffffffff);
TsiChung Liewbf9a5212009-06-12 11:29:00 +000057#else
Alison Wang32dbaaf2012-03-26 21:49:04 +000058 setbits_be32(&intp->imrl0, 0x1);
TsiChung Liewbf9a5212009-06-12 11:29:00 +000059#endif
TsiChungLiew83ec20b2007-08-15 19:21:21 -050060
61 enable_interrupts();
wdenkbf9e3b32004-02-12 00:47:09 +000062 return 0;
63}
TsiChungLiew83ec20b2007-08-15 19:21:21 -050064
65#if defined(CONFIG_MCFTMR)
66void dtimer_intr_setup(void)
67{
Alison Wang32dbaaf2012-03-26 21:49:04 +000068 int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050069
Alison Wang32dbaaf2012-03-26 21:49:04 +000070 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);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050073}
74#endif /* CONFIG_MCFTMR */
Matthew Fettkef71d9d92008-02-04 15:38:20 -060075#endif /* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */
stroese8c725b92004-12-16 18:09:49 +000076
TsiChungLiewa1436a82007-08-16 13:20:50 -050077#if defined(CONFIG_M5249) || defined(CONFIG_M5253)
TsiChungLiew83ec20b2007-08-15 19:21:21 -050078int interrupt_init(void)
stroese8c725b92004-12-16 18:09:49 +000079{
TsiChungLiew83ec20b2007-08-15 19:21:21 -050080 enable_interrupts();
stroese8c725b92004-12-16 18:09:49 +000081
82 return 0;
83}
TsiChungLiew83ec20b2007-08-15 19:21:21 -050084
85#if defined(CONFIG_MCFTMR)
86void dtimer_intr_setup(void)
87{
88 mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020089 mbar_writeByte(MCFSIM_TIMER2ICR, CONFIG_SYS_TMRINTR_PRI);
TsiChungLiew83ec20b2007-08-15 19:21:21 -050090}
91#endif /* CONFIG_MCFTMR */
TsiChungLiewa1436a82007-08-16 13:20:50 -050092#endif /* CONFIG_M5249 || CONFIG_M5253 */