]> err.no Git - linux-2.6/blob - arch/powerpc/platforms/pasemi/setup.c
cabf7017c05eca080ff3c7845f4139c92364916f
[linux-2.6] / arch / powerpc / platforms / pasemi / setup.c
1 /*
2  * Copyright (C) 2006 PA Semi, Inc
3  *
4  * Authors: Kip Walker, PA Semi
5  *          Olof Johansson, PA Semi
6  *
7  * Maintained by: Olof Johansson <olof@lixom.net>
8  *
9  * Based on arch/powerpc/platforms/maple/setup.c
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  */
24
25 #include <linux/errno.h>
26 #include <linux/kernel.h>
27 #include <linux/delay.h>
28 #include <linux/console.h>
29 #include <linux/pci.h>
30
31 #include <asm/prom.h>
32 #include <asm/system.h>
33 #include <asm/iommu.h>
34 #include <asm/machdep.h>
35 #include <asm/mpic.h>
36 #include <asm/smp.h>
37 #include <asm/time.h>
38
39 #include "pasemi.h"
40
41 static void __iomem *reset_reg;
42
43 static void pas_restart(char *cmd)
44 {
45         printk("Restarting...\n");
46         while (1)
47                 out_le32(reset_reg, 0x6000000);
48 }
49
50 #ifdef CONFIG_SMP
51 struct smp_ops_t pas_smp_ops = {
52         .probe          = smp_mpic_probe,
53         .message_pass   = smp_mpic_message_pass,
54         .kick_cpu       = smp_generic_kick_cpu,
55         .setup_cpu      = smp_mpic_setup_cpu,
56         .give_timebase  = smp_generic_give_timebase,
57         .take_timebase  = smp_generic_take_timebase,
58 };
59 #endif /* CONFIG_SMP */
60
61 void __init pas_setup_arch(void)
62 {
63 #ifdef CONFIG_SMP
64         /* Setup SMP callback */
65         smp_ops = &pas_smp_ops;
66 #endif
67         /* no iommu yet */
68         pci_dma_ops = &dma_direct_ops;
69
70         /* Lookup PCI hosts */
71         pas_pci_init();
72
73 #ifdef CONFIG_DUMMY_CONSOLE
74         conswitchp = &dummy_con;
75 #endif
76
77         /* Remap SDC register for doing reset */
78         /* XXXOJN This should maybe come out of the device tree */
79         reset_reg = ioremap(0xfc101100, 4);
80
81         pasemi_idle_init();
82 }
83
84 /* No legacy IO on our parts */
85 static int pas_check_legacy_ioport(unsigned int baseport)
86 {
87         return -ENODEV;
88 }
89
90 static __init void pas_init_IRQ(void)
91 {
92         struct device_node *np;
93         struct device_node *root, *mpic_node;
94         unsigned long openpic_addr;
95         const unsigned int *opprop;
96         int naddr, opplen;
97         struct mpic *mpic;
98
99         mpic_node = NULL;
100
101         for_each_node_by_type(np, "interrupt-controller")
102                 if (device_is_compatible(np, "open-pic")) {
103                         mpic_node = np;
104                         break;
105                 }
106         if (!mpic_node)
107                 for_each_node_by_type(np, "open-pic") {
108                         mpic_node = np;
109                         break;
110                 }
111         if (!mpic_node) {
112                 printk(KERN_ERR
113                         "Failed to locate the MPIC interrupt controller\n");
114                 return;
115         }
116
117         /* Find address list in /platform-open-pic */
118         root = of_find_node_by_path("/");
119         naddr = prom_n_addr_cells(root);
120         opprop = get_property(root, "platform-open-pic", &opplen);
121         if (!opprop) {
122                 printk(KERN_ERR "No platform-open-pic property.\n");
123                 of_node_put(root);
124                 return;
125         }
126         openpic_addr = of_read_number(opprop, naddr);
127         printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
128
129         mpic = mpic_alloc(mpic_node, openpic_addr,
130                           MPIC_PRIMARY|MPIC_LARGE_VECTORS,
131                           0, 0, " PAS-OPIC  ");
132         BUG_ON(!mpic);
133
134         mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
135         mpic_init(mpic);
136         of_node_put(mpic_node);
137         of_node_put(root);
138 }
139
140 static void __init pas_progress(char *s, unsigned short hex)
141 {
142         printk("[%04x] : %s\n", hex, s ? s : "");
143 }
144
145
146 static int pas_machine_check_handler(struct pt_regs *regs)
147 {
148         int cpu = smp_processor_id();
149         unsigned long srr0, srr1, dsisr;
150
151         srr0 = regs->nip;
152         srr1 = regs->msr;
153         dsisr = mfspr(SPRN_DSISR);
154         printk(KERN_ERR "Machine Check on CPU %d\n", cpu);
155         printk(KERN_ERR "SRR0 0x%016lx SRR1 0x%016lx\n", srr0, srr1);
156         printk(KERN_ERR "DSISR 0x%016lx DAR 0x%016lx\n", dsisr, regs->dar);
157         printk(KERN_ERR "Cause:\n");
158
159         if (srr1 & 0x200000)
160                 printk(KERN_ERR "Signalled by SDC\n");
161         if (srr1 & 0x100000) {
162                 printk(KERN_ERR "Load/Store detected error:\n");
163                 if (dsisr & 0x8000)
164                         printk(KERN_ERR "D-cache ECC double-bit error or bus error\n");
165                 if (dsisr & 0x4000)
166                         printk(KERN_ERR "LSU snoop response error\n");
167                 if (dsisr & 0x2000)
168                         printk(KERN_ERR "MMU SLB multi-hit or invalid B field\n");
169                 if (dsisr & 0x1000)
170                         printk(KERN_ERR "Recoverable Duptags\n");
171                 if (dsisr & 0x800)
172                         printk(KERN_ERR "Recoverable D-cache parity error count overflow\n");
173                 if (dsisr & 0x400)
174                         printk(KERN_ERR "TLB parity error count overflow\n");
175         }
176         if (srr1 & 0x80000)
177                 printk(KERN_ERR "Bus Error\n");
178         if (srr1 & 0x40000)
179                 printk(KERN_ERR "I-side SLB multiple hit\n");
180         if (srr1 & 0x20000)
181                 printk(KERN_ERR "I-cache parity error hit\n");
182
183         /* SRR1[62] is from MSR[62] if recoverable, so pass that back */
184         return !!(srr1 & 0x2);
185 }
186
187
188 /*
189  * Called very early, MMU is off, device-tree isn't unflattened
190  */
191 static int __init pas_probe(void)
192 {
193         unsigned long root = of_get_flat_dt_root();
194
195         if (!of_flat_dt_is_compatible(root, "PA6T-1682M"))
196                 return 0;
197
198         hpte_init_native();
199
200         return 1;
201 }
202
203 define_machine(pas) {
204         .name                   = "PA Semi PA6T-1682M",
205         .probe                  = pas_probe,
206         .setup_arch             = pas_setup_arch,
207         .init_IRQ               = pas_init_IRQ,
208         .get_irq                = mpic_get_irq,
209         .restart                = pas_restart,
210         .get_boot_time          = pas_get_boot_time,
211         .calibrate_decr         = generic_calibrate_decr,
212         .check_legacy_ioport    = pas_check_legacy_ioport,
213         .progress               = pas_progress,
214         .machine_check_exception = pas_machine_check_handler,
215 };