xref: /rk3399_rockchip-uboot/arch/powerpc/cpu/mpc85xx/interrupts.c (revision deff9b1d2ab24955cc4f881d63a701f40d6b491f)
1a47a12beSStefan Roese /*
2a47a12beSStefan Roese  * (C) Copyright 2000-2002
3a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4a47a12beSStefan Roese  *
5a47a12beSStefan Roese  * (C) Copyright 2002 (440 port)
6a47a12beSStefan Roese  * Scott McNutt, Artesyn Communication Producs, smcnutt@artsyncp.com
7a47a12beSStefan Roese  *
8a47a12beSStefan Roese  * (C) Copyright 2003 Motorola Inc. (MPC85xx port)
9a47a12beSStefan Roese  * Xianghua Xiao (X.Xiao@motorola.com)
10a47a12beSStefan Roese  *
111a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
12a47a12beSStefan Roese  */
13a47a12beSStefan Roese 
14a47a12beSStefan Roese #include <common.h>
15a47a12beSStefan Roese #include <watchdog.h>
16a47a12beSStefan Roese #include <command.h>
17a47a12beSStefan Roese #include <asm/processor.h>
18a47a12beSStefan Roese #include <asm/io.h>
19cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
20cc1dd33fSJohn Schmoller #include <post.h>
21cc1dd33fSJohn Schmoller #endif
22a47a12beSStefan Roese 
interrupt_init_cpu(unsigned * decrementer_count)23*deff9b1dSTom Rini void interrupt_init_cpu(unsigned *decrementer_count)
24a47a12beSStefan Roese {
25680c613aSKim Phillips 	ccsr_pic_t __iomem *pic = (void *)CONFIG_SYS_MPC8xxx_PIC_ADDR;
26a47a12beSStefan Roese 
27cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
28cc1dd33fSJohn Schmoller 	/*
29cc1dd33fSJohn Schmoller 	 * The POST word is stored in the PIC's TFRR register which gets
30cc1dd33fSJohn Schmoller 	 * cleared when the PIC is reset.  Save it off so we can restore it
31cc1dd33fSJohn Schmoller 	 * later.
32cc1dd33fSJohn Schmoller 	 */
33cc1dd33fSJohn Schmoller 	ulong post_word = post_word_load();
34cc1dd33fSJohn Schmoller #endif
35cc1dd33fSJohn Schmoller 
36a47a12beSStefan Roese 	out_be32(&pic->gcr, MPC85xx_PICGCR_RST);
37a47a12beSStefan Roese 	while (in_be32(&pic->gcr) & MPC85xx_PICGCR_RST)
38a47a12beSStefan Roese 		;
39a47a12beSStefan Roese 	out_be32(&pic->gcr, MPC85xx_PICGCR_M);
40a47a12beSStefan Roese 	in_be32(&pic->gcr);
41a47a12beSStefan Roese 
42a47a12beSStefan Roese 	*decrementer_count = get_tbclk() / CONFIG_SYS_HZ;
43a47a12beSStefan Roese 
44a47a12beSStefan Roese 	/* PIE is same as DIE, dec interrupt enable */
453345d18dSBoschung, Rainer 	mtspr(SPRN_TCR, mfspr(SPRN_TCR) | TCR_PIE);
46a47a12beSStefan Roese 
47a47a12beSStefan Roese #ifdef CONFIG_INTERRUPTS
48a47a12beSStefan Roese 	pic->iivpr1 = 0x810001;	/* 50220 enable ecm interrupts */
49a47a12beSStefan Roese 	debug("iivpr1@%x = %x\n", (uint)&pic->iivpr1, pic->iivpr1);
50a47a12beSStefan Roese 
51a47a12beSStefan Roese 	pic->iivpr2 = 0x810002;	/* 50240 enable ddr interrupts */
52a47a12beSStefan Roese 	debug("iivpr2@%x = %x\n", (uint)&pic->iivpr2, pic->iivpr2);
53a47a12beSStefan Roese 
54a47a12beSStefan Roese 	pic->iivpr3 = 0x810003;	/* 50260 enable lbc interrupts */
55a47a12beSStefan Roese 	debug("iivpr3@%x = %x\n", (uint)&pic->iivpr3, pic->iivpr3);
56a47a12beSStefan Roese 
57a47a12beSStefan Roese #ifdef CONFIG_PCI1
58a47a12beSStefan Roese 	pic->iivpr8 = 0x810008;	/* enable pci1 interrupts */
59a47a12beSStefan Roese 	debug("iivpr8@%x = %x\n", (uint)&pic->iivpr8, pic->iivpr8);
60a47a12beSStefan Roese #endif
61a47a12beSStefan Roese #if defined(CONFIG_PCI2) || defined(CONFIG_PCIE2)
62a47a12beSStefan Roese 	pic->iivpr9 = 0x810009;	/* enable pci1 interrupts */
63a47a12beSStefan Roese 	debug("iivpr9@%x = %x\n", (uint)&pic->iivpr9, pic->iivpr9);
64a47a12beSStefan Roese #endif
65a47a12beSStefan Roese #ifdef CONFIG_PCIE1
66a47a12beSStefan Roese 	pic->iivpr10 = 0x81000a;	/* enable pcie1 interrupts */
67a47a12beSStefan Roese 	debug("iivpr10@%x = %x\n", (uint)&pic->iivpr10, pic->iivpr10);
68a47a12beSStefan Roese #endif
69a47a12beSStefan Roese #ifdef CONFIG_PCIE3
70a47a12beSStefan Roese 	pic->iivpr11 = 0x81000b;	/* enable pcie3 interrupts */
71a47a12beSStefan Roese 	debug("iivpr11@%x = %x\n", (uint)&pic->iivpr11, pic->iivpr11);
72a47a12beSStefan Roese #endif
73a47a12beSStefan Roese 
74a47a12beSStefan Roese 	pic->ctpr=0;		/* 40080 clear current task priority register */
75a47a12beSStefan Roese #endif
76a47a12beSStefan Roese 
77cc1dd33fSJohn Schmoller #ifdef CONFIG_POST
78cc1dd33fSJohn Schmoller 	post_word_store(post_word);
79cc1dd33fSJohn Schmoller #endif
80a47a12beSStefan Roese }
81a47a12beSStefan Roese 
82a47a12beSStefan Roese /* Install and free a interrupt handler. Not implemented yet. */
83a47a12beSStefan Roese 
84a47a12beSStefan Roese void
irq_install_handler(int vec,interrupt_handler_t * handler,void * arg)85a47a12beSStefan Roese irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
86a47a12beSStefan Roese {
87a47a12beSStefan Roese 	return;
88a47a12beSStefan Roese }
89a47a12beSStefan Roese 
90a47a12beSStefan Roese void
irq_free_handler(int vec)91a47a12beSStefan Roese irq_free_handler(int vec)
92a47a12beSStefan Roese {
93a47a12beSStefan Roese 	return;
94a47a12beSStefan Roese }
95a47a12beSStefan Roese 
timer_interrupt_cpu(struct pt_regs * regs)96a47a12beSStefan Roese void timer_interrupt_cpu(struct pt_regs *regs)
97a47a12beSStefan Roese {
98a47a12beSStefan Roese 	/* PIS is same as DIS, dec interrupt status */
99a47a12beSStefan Roese 	mtspr(SPRN_TSR, TSR_PIS);
100a47a12beSStefan Roese }
101a47a12beSStefan Roese 
102a47a12beSStefan Roese #if defined(CONFIG_CMD_IRQ)
103a47a12beSStefan Roese /* irqinfo - print information about PCI devices,not implemented. */
do_irqinfo(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])10454841ab5SWolfgang Denk int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
105a47a12beSStefan Roese {
106a47a12beSStefan Roese 	return 0;
107a47a12beSStefan Roese }
108a47a12beSStefan Roese #endif
109