blob: 4142873a87ef504080046aeaf28495163e2dda89 [file] [log] [blame]
Olof Johansson1e768752006-09-06 14:42:08 -05001/*
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
Olof Johansson1e768752006-09-06 14:42:08 -050025#include <linux/errno.h>
26#include <linux/kernel.h>
27#include <linux/delay.h>
28#include <linux/console.h>
Benjamin Herrenschmidt12d04ee2006-11-11 17:25:02 +110029#include <linux/pci.h>
Olof Johansson1e768752006-09-06 14:42:08 -050030
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
41static void pas_restart(char *cmd)
42{
43 printk("restart unimplemented, looping...\n");
44 for (;;) ;
45}
46
47static void pas_power_off(void)
48{
49 printk("power off unimplemented, looping...\n");
50 for (;;) ;
51}
52
53static void pas_halt(void)
54{
55 pas_power_off();
56}
57
58#ifdef CONFIG_SMP
59struct smp_ops_t pas_smp_ops = {
60 .probe = smp_mpic_probe,
61 .message_pass = smp_mpic_message_pass,
62 .kick_cpu = smp_generic_kick_cpu,
63 .setup_cpu = smp_mpic_setup_cpu,
64 .give_timebase = smp_generic_give_timebase,
65 .take_timebase = smp_generic_take_timebase,
66};
67#endif /* CONFIG_SMP */
68
69void __init pas_setup_arch(void)
70{
71#ifdef CONFIG_SMP
72 /* Setup SMP callback */
73 smp_ops = &pas_smp_ops;
74#endif
Benjamin Herrenschmidt12d04ee2006-11-11 17:25:02 +110075 /* no iommu yet */
76 pci_dma_ops = &dma_direct_ops;
77
Olof Johansson1e768752006-09-06 14:42:08 -050078 /* Lookup PCI hosts */
79 pas_pci_init();
80
81#ifdef CONFIG_DUMMY_CONSOLE
82 conswitchp = &dummy_con;
83#endif
84
85 printk(KERN_DEBUG "Using default idle loop\n");
86}
87
Olof Johansson1e768752006-09-06 14:42:08 -050088/* No legacy IO on our parts */
89static int pas_check_legacy_ioport(unsigned int baseport)
90{
91 return -ENODEV;
92}
93
94static __init void pas_init_IRQ(void)
95{
96 struct device_node *np;
97 struct device_node *root, *mpic_node;
98 unsigned long openpic_addr;
99 const unsigned int *opprop;
100 int naddr, opplen;
101 struct mpic *mpic;
102
103 mpic_node = NULL;
104
105 for_each_node_by_type(np, "interrupt-controller")
106 if (device_is_compatible(np, "open-pic")) {
107 mpic_node = np;
108 break;
109 }
110 if (!mpic_node)
111 for_each_node_by_type(np, "open-pic") {
112 mpic_node = np;
113 break;
114 }
115 if (!mpic_node) {
116 printk(KERN_ERR
117 "Failed to locate the MPIC interrupt controller\n");
118 return;
119 }
120
121 /* Find address list in /platform-open-pic */
122 root = of_find_node_by_path("/");
123 naddr = prom_n_addr_cells(root);
124 opprop = get_property(root, "platform-open-pic", &opplen);
125 if (!opprop) {
126 printk(KERN_ERR "No platform-open-pic property.\n");
127 of_node_put(root);
128 return;
129 }
130 openpic_addr = of_read_number(opprop, naddr);
131 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
Olof Johansson1e768752006-09-06 14:42:08 -0500132
Olof Johansson7df24572007-01-28 23:33:18 -0600133 mpic = mpic_alloc(mpic_node, openpic_addr,
134 MPIC_PRIMARY|MPIC_LARGE_VECTORS,
135 0, 0, " PAS-OPIC ");
Olof Johansson1e768752006-09-06 14:42:08 -0500136 BUG_ON(!mpic);
137
138 mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
139 mpic_init(mpic);
140 of_node_put(mpic_node);
141 of_node_put(root);
142}
143
144static void __init pas_progress(char *s, unsigned short hex)
145{
146 printk("[%04x] : %s\n", hex, s ? s : "");
147}
148
149
Olof Johanssonbfed9d32007-02-04 16:36:50 -0600150static int pas_machine_check_handler(struct pt_regs *regs)
151{
152 int cpu = smp_processor_id();
153 unsigned long srr0, srr1, dsisr;
154
155 srr0 = regs->nip;
156 srr1 = regs->msr;
157 dsisr = mfspr(SPRN_DSISR);
158 printk(KERN_ERR "Machine Check on CPU %d\n", cpu);
159 printk(KERN_ERR "SRR0 0x%016lx SRR1 0x%016lx\n", srr0, srr1);
160 printk(KERN_ERR "DSISR 0x%016lx DAR 0x%016lx\n", dsisr, regs->dar);
161 printk(KERN_ERR "Cause:\n");
162
163 if (srr1 & 0x200000)
164 printk(KERN_ERR "Signalled by SDC\n");
165 if (srr1 & 0x100000) {
166 printk(KERN_ERR "Load/Store detected error:\n");
167 if (dsisr & 0x8000)
168 printk(KERN_ERR "D-cache ECC double-bit error or bus error\n");
169 if (dsisr & 0x4000)
170 printk(KERN_ERR "LSU snoop response error\n");
171 if (dsisr & 0x2000)
172 printk(KERN_ERR "MMU SLB multi-hit or invalid B field\n");
173 if (dsisr & 0x1000)
174 printk(KERN_ERR "Recoverable Duptags\n");
175 if (dsisr & 0x800)
176 printk(KERN_ERR "Recoverable D-cache parity error count overflow\n");
177 if (dsisr & 0x400)
178 printk(KERN_ERR "TLB parity error count overflow\n");
179 }
180 if (srr1 & 0x80000)
181 printk(KERN_ERR "Bus Error\n");
182 if (srr1 & 0x40000)
183 printk(KERN_ERR "I-side SLB multiple hit\n");
184 if (srr1 & 0x20000)
185 printk(KERN_ERR "I-cache parity error hit\n");
186
187 /* SRR1[62] is from MSR[62] if recoverable, so pass that back */
188 return !!(srr1 & 0x2);
189}
190
191
Olof Johansson1e768752006-09-06 14:42:08 -0500192/*
193 * Called very early, MMU is off, device-tree isn't unflattened
194 */
195static int __init pas_probe(void)
196{
197 unsigned long root = of_get_flat_dt_root();
198
199 if (!of_flat_dt_is_compatible(root, "PA6T-1682M"))
200 return 0;
201
202 hpte_init_native();
203
204 return 1;
205}
206
207define_machine(pas) {
208 .name = "PA Semi PA6T-1682M",
209 .probe = pas_probe,
210 .setup_arch = pas_setup_arch,
Olof Johansson1e768752006-09-06 14:42:08 -0500211 .init_IRQ = pas_init_IRQ,
212 .get_irq = mpic_get_irq,
Olof Johansson1e768752006-09-06 14:42:08 -0500213 .restart = pas_restart,
214 .power_off = pas_power_off,
215 .halt = pas_halt,
216 .get_boot_time = pas_get_boot_time,
217 .calibrate_decr = generic_calibrate_decr,
218 .check_legacy_ioport = pas_check_legacy_ioport,
219 .progress = pas_progress,
Olof Johanssonbfed9d32007-02-04 16:36:50 -0600220 .machine_check_exception = pas_machine_check_handler,
Olof Johansson1e768752006-09-06 14:42:08 -0500221};