[POWERPC] Reworked interrupt numbers for OpenPIC based Freescale chips
[pandora-kernel.git] / arch / powerpc / platforms / 85xx / mpc8544_ds.c
1 /*
2  * MPC8544 DS Board Setup
3  *
4  * Author Xianghua Xiao (x.xiao@freescale.com)
5  * Copyright 2007 Freescale Semiconductor Inc.
6  *
7  * This program is free software; you can redistribute  it and/or modify it
8  * under  the terms of  the GNU General  Public License as published by the
9  * Free Software Foundation;  either version 2 of the  License, or (at your
10  * option) any later version.
11  */
12
13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
15 #include <linux/kdev_t.h>
16 #include <linux/delay.h>
17 #include <linux/seq_file.h>
18
19 #include <asm/system.h>
20 #include <asm/time.h>
21 #include <asm/machdep.h>
22 #include <asm/mpc85xx.h>
23 #include <mm/mmu_decl.h>
24 #include <asm/prom.h>
25 #include <asm/udbg.h>
26 #include <asm/mpic.h>
27 #include <asm/i8259.h>
28
29 #include <sysdev/fsl_soc.h>
30 #include "mpc85xx.h"
31
32 #undef DEBUG
33
34 #ifdef DEBUG
35 #define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
36 #else
37 #define DBG(fmt, args...)
38 #endif
39
40
41 void __init mpc8544_ds_pic_init(void)
42 {
43         struct mpic *mpic;
44         struct resource r;
45         struct device_node *np = NULL;
46 #ifdef CONFIG_PPC_I8259
47         struct device_node *cascade_node = NULL;
48         int cascade_irq;
49 #endif
50
51         np = of_find_node_by_type(np, "open-pic");
52
53         if (np == NULL) {
54                 printk(KERN_ERR "Could not find open-pic node\n");
55                 return;
56         }
57
58         if (of_address_to_resource(np, 0, &r)) {
59                 printk(KERN_ERR "Failed to map mpic register space\n");
60                 of_node_put(np);
61                 return;
62         }
63
64         mpic = mpic_alloc(np, r.start,
65                           MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
66                         0, 256, " OpenPIC  ");
67         BUG_ON(mpic == NULL);
68
69         mpic_init(mpic);
70
71 #ifdef CONFIG_PPC_I8259
72         /* Initialize the i8259 controller */
73         for_each_node_by_type(np, "interrupt-controller")
74             if (of_device_is_compatible(np, "chrp,iic")) {
75                 cascade_node = np;
76                 break;
77         }
78
79         if (cascade_node == NULL) {
80                 printk(KERN_DEBUG "Could not find i8259 PIC\n");
81                 return;
82         }
83
84         cascade_irq = irq_of_parse_and_map(cascade_node, 0);
85         if (cascade_irq == NO_IRQ) {
86                 printk(KERN_ERR "Failed to map cascade interrupt\n");
87                 return;
88         }
89
90         DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq);
91
92         i8259_init(cascade_node, 0);
93         of_node_put(cascade_node);
94
95         set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade);
96 #endif  /* CONFIG_PPC_I8259 */
97 }
98
99
100 /*
101  * Setup the architecture
102  */
103 static void __init mpc8544_ds_setup_arch(void)
104 {
105         if (ppc_md.progress)
106                 ppc_md.progress("mpc8544_ds_setup_arch()", 0);
107
108         printk("MPC8544 DS board from Freescale Semiconductor\n");
109 }
110
111
112 /*
113  * Called very early, device-tree isn't unflattened
114  */
115 static int __init mpc8544_ds_probe(void)
116 {
117         unsigned long root = of_get_flat_dt_root();
118
119         return of_flat_dt_is_compatible(root, "MPC8544DS");
120 }
121
122 define_machine(mpc8544_ds) {
123         .name                   = "MPC8544 DS",
124         .probe                  = mpc8544_ds_probe,
125         .setup_arch             = mpc8544_ds_setup_arch,
126         .init_IRQ               = mpc8544_ds_pic_init,
127         .get_irq                = mpic_get_irq,
128         .restart                = mpc85xx_restart,
129         .calibrate_decr         = generic_calibrate_decr,
130         .progress               = udbg_progress,
131 };