1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2a47a12beSStefan Roese /*
3a47a12beSStefan Roese  * (C) Copyright 2000-2002
4a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5a47a12beSStefan Roese  *
6a47a12beSStefan Roese  * (C) Copyright 2002 (440 port)
7a47a12beSStefan Roese  * Scott McNutt, Artesyn Communication Producs, smcnutt@artsyncp.com
8a47a12beSStefan Roese  *
9a47a12beSStefan Roese  * (C) Copyright 2003 Motorola Inc. (MPC85xx port)
10a47a12beSStefan Roese  * Xianghua Xiao (X.Xiao@motorola.com)
11a47a12beSStefan Roese  *
12a47a12beSStefan Roese  * (C) Copyright 2004, 2007 Freescale Semiconductor. (MPC86xx Port)
13a47a12beSStefan Roese  * Jeff Brown
14a47a12beSStefan Roese  * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
15a47a12beSStefan Roese  */
16a47a12beSStefan Roese 
17a47a12beSStefan Roese #include <common.h>
18a47a12beSStefan Roese #include <mpc86xx.h>
19a47a12beSStefan Roese #include <command.h>
20a47a12beSStefan Roese #include <asm/processor.h>
21cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
22cc1dd33fSJohn Schmoller #include <post.h>
23cc1dd33fSJohn Schmoller #endif
24a47a12beSStefan Roese 
interrupt_init_cpu(unsigned * decrementer_count)25deff9b1dSTom Rini void interrupt_init_cpu(unsigned *decrementer_count)
26a47a12beSStefan Roese {
27a47a12beSStefan Roese 	volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
28a47a12beSStefan Roese 	volatile ccsr_pic_t *pic = &immr->im_pic;
29a47a12beSStefan Roese 
30cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
31cc1dd33fSJohn Schmoller 	/*
32cc1dd33fSJohn Schmoller 	 * The POST word is stored in the PIC's TFRR register which gets
33cc1dd33fSJohn Schmoller 	 * cleared when the PIC is reset.  Save it off so we can restore it
34cc1dd33fSJohn Schmoller 	 * later.
35cc1dd33fSJohn Schmoller 	 */
36cc1dd33fSJohn Schmoller 	ulong post_word = post_word_load();
37cc1dd33fSJohn Schmoller #endif
38cc1dd33fSJohn Schmoller 
39a47a12beSStefan Roese 	pic->gcr = MPC86xx_PICGCR_RST;
40a47a12beSStefan Roese 	while (pic->gcr & MPC86xx_PICGCR_RST)
41a47a12beSStefan Roese 		;
42a47a12beSStefan Roese 	pic->gcr = MPC86xx_PICGCR_MODE;
43a47a12beSStefan Roese 
44a47a12beSStefan Roese 	*decrementer_count = get_tbclk() / CONFIG_SYS_HZ;
4508dd988bSChristophe Leroy 	debug("interrupt init: tbclk() = %ld MHz, decrementer_count = %d\n",
46a47a12beSStefan Roese 	      (get_tbclk() / 1000000),
47a47a12beSStefan Roese 	      *decrementer_count);
48a47a12beSStefan Roese 
49a47a12beSStefan Roese #ifdef CONFIG_INTERRUPTS
50a47a12beSStefan Roese 
51a47a12beSStefan Roese 	pic->iivpr1 = 0x810001;	/* 50220 enable mcm interrupts */
527f2229b5SMarek Vasut 	debug("iivpr1@%p = %x\n", &pic->iivpr1, pic->iivpr1);
53a47a12beSStefan Roese 
54a47a12beSStefan Roese 	pic->iivpr2 = 0x810002;	/* 50240 enable ddr interrupts */
557f2229b5SMarek Vasut 	debug("iivpr2@%p = %x\n", &pic->iivpr2, pic->iivpr2);
56a47a12beSStefan Roese 
57a47a12beSStefan Roese 	pic->iivpr3 = 0x810003;	/* 50260 enable lbc interrupts */
587f2229b5SMarek Vasut 	debug("iivpr3@%p = %x\n", &pic->iivpr3, pic->iivpr3);
59a47a12beSStefan Roese 
60a47a12beSStefan Roese #if defined(CONFIG_PCI1) || defined(CONFIG_PCIE1)
61a47a12beSStefan Roese 	pic->iivpr8 = 0x810008;	/* enable pcie1 interrupts */
627f2229b5SMarek Vasut 	debug("iivpr8@%p = %x\n", &pic->iivpr8, pic->iivpr8);
63a47a12beSStefan Roese #endif
64a47a12beSStefan Roese #if defined(CONFIG_PCI2) || defined(CONFIG_PCIE2)
65a47a12beSStefan Roese 	pic->iivpr9 = 0x810009;	/* enable pcie2 interrupts */
667f2229b5SMarek Vasut 	debug("iivpr9@%p = %x\n", &pic->iivpr9, pic->iivpr9);
67a47a12beSStefan Roese #endif
68a47a12beSStefan Roese 
69a47a12beSStefan Roese 	pic->ctpr = 0;	/* 40080 clear current task priority register */
70a47a12beSStefan Roese #endif
71a47a12beSStefan Roese 
72cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
73cc1dd33fSJohn Schmoller 	post_word_store(post_word);
74cc1dd33fSJohn Schmoller #endif
75a47a12beSStefan Roese }
76a47a12beSStefan Roese 
77a47a12beSStefan Roese /*
78a47a12beSStefan Roese  * timer_interrupt - gets called when the decrementer overflows,
79a47a12beSStefan Roese  * with interrupts disabled.
80a47a12beSStefan Roese  * Trivial implementation - no need to be really accurate.
81a47a12beSStefan Roese  */
timer_interrupt_cpu(struct pt_regs * regs)82a47a12beSStefan Roese void timer_interrupt_cpu(struct pt_regs *regs)
83a47a12beSStefan Roese {
84a47a12beSStefan Roese 	/* nothing to do here */
85a47a12beSStefan Roese }
86a47a12beSStefan Roese 
87a47a12beSStefan Roese /*
88a47a12beSStefan Roese  * Install and free a interrupt handler. Not implemented yet.
89a47a12beSStefan Roese  */
irq_install_handler(int vec,interrupt_handler_t * handler,void * arg)90a47a12beSStefan Roese void irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
91a47a12beSStefan Roese {
92a47a12beSStefan Roese }
93a47a12beSStefan Roese 
irq_free_handler(int vec)94a47a12beSStefan Roese void irq_free_handler(int vec)
95a47a12beSStefan Roese {
96a47a12beSStefan Roese }
97a47a12beSStefan Roese 
98a47a12beSStefan Roese /*
99a47a12beSStefan Roese  * irqinfo - print information about PCI devices,not implemented.
100a47a12beSStefan Roese  */
do_irqinfo(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])10154841ab5SWolfgang Denk int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
102a47a12beSStefan Roese {
103a47a12beSStefan Roese 	return 0;
104a47a12beSStefan Roese }
105a47a12beSStefan Roese 
106a47a12beSStefan Roese /*
107a47a12beSStefan Roese  * Handle external interrupts
108a47a12beSStefan Roese  */
external_interrupt(struct pt_regs * regs)109a47a12beSStefan Roese void external_interrupt(struct pt_regs *regs)
110a47a12beSStefan Roese {
111a47a12beSStefan Roese 	puts("external_interrupt (oops!)\n");
112a47a12beSStefan Roese }
113