Merge mulgrave-w:git/scsi-misc-2.6
[pandora-kernel.git] / arch / powerpc / platforms / 85xx / mpc85xx_ads.c
1 /*
2  * MPC85xx setup and early boot code plus other random bits.
3  *
4  * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5  *
6  * Copyright 2005 Freescale Semiconductor Inc.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #include <linux/stddef.h>
15 #include <linux/kernel.h>
16 #include <linux/pci.h>
17 #include <linux/kdev_t.h>
18 #include <linux/delay.h>
19 #include <linux/seq_file.h>
20 #include <linux/root_dev.h>
21
22 #include <asm/system.h>
23 #include <asm/time.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
26 #include <asm/mpc85xx.h>
27 #include <asm/prom.h>
28 #include <asm/mpic.h>
29 #include <mm/mmu_decl.h>
30 #include <asm/udbg.h>
31
32 #include <sysdev/fsl_soc.h>
33 #include "mpc85xx.h"
34
35 #ifndef CONFIG_PCI
36 unsigned long isa_io_base = 0;
37 unsigned long isa_mem_base = 0;
38 #endif
39
40 #ifdef CONFIG_PCI
41 int
42 mpc85xx_exclude_device(u_char bus, u_char devfn)
43 {
44         if (bus == 0 && PCI_SLOT(devfn) == 0)
45                 return PCIBIOS_DEVICE_NOT_FOUND;
46         else
47                 return PCIBIOS_SUCCESSFUL;
48 }
49
50 void __init
51 mpc85xx_pcibios_fixup(void)
52 {
53         struct pci_dev *dev = NULL;
54
55         for_each_pci_dev(dev)
56                 pci_read_irq_line(dev);
57 }
58 #endif /* CONFIG_PCI */
59
60
61 void __init mpc85xx_ads_pic_init(void)
62 {
63         struct mpic *mpic;
64         struct resource r;
65         struct device_node *np = NULL;
66
67         np = of_find_node_by_type(np, "open-pic");
68
69         if (np == NULL) {
70                 printk(KERN_ERR "Could not find open-pic node\n");
71                 return;
72         }
73
74         if(of_address_to_resource(np, 0, &r)) {
75                 printk(KERN_ERR "Could not map mpic register space\n");
76                 of_node_put(np);
77                 return;
78         }
79
80         mpic = mpic_alloc(np, r.start,
81                         MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
82                         4, 0, " OpenPIC  ");
83         BUG_ON(mpic == NULL);
84         of_node_put(np);
85
86         mpic_assign_isu(mpic, 0, r.start + 0x10200);
87         mpic_assign_isu(mpic, 1, r.start + 0x10280);
88         mpic_assign_isu(mpic, 2, r.start + 0x10300);
89         mpic_assign_isu(mpic, 3, r.start + 0x10380);
90         mpic_assign_isu(mpic, 4, r.start + 0x10400);
91         mpic_assign_isu(mpic, 5, r.start + 0x10480);
92         mpic_assign_isu(mpic, 6, r.start + 0x10500);
93         mpic_assign_isu(mpic, 7, r.start + 0x10580);
94
95         /* Unused on this platform (leave room for 8548) */
96         mpic_assign_isu(mpic, 8, r.start + 0x10600);
97         mpic_assign_isu(mpic, 9, r.start + 0x10680);
98         mpic_assign_isu(mpic, 10, r.start + 0x10700);
99         mpic_assign_isu(mpic, 11, r.start + 0x10780);
100
101         /* External Interrupts */
102         mpic_assign_isu(mpic, 12, r.start + 0x10000);
103         mpic_assign_isu(mpic, 13, r.start + 0x10080);
104         mpic_assign_isu(mpic, 14, r.start + 0x10100);
105
106         mpic_init(mpic);
107 }
108
109 /*
110  * Setup the architecture
111  */
112 static void __init mpc85xx_ads_setup_arch(void)
113 {
114         struct device_node *cpu;
115 #ifdef CONFIG_PCI
116         struct device_node *np;
117 #endif
118
119         if (ppc_md.progress)
120                 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
121
122         cpu = of_find_node_by_type(NULL, "cpu");
123         if (cpu != 0) {
124                 const unsigned int *fp;
125
126                 fp = get_property(cpu, "clock-frequency", NULL);
127                 if (fp != 0)
128                         loops_per_jiffy = *fp / HZ;
129                 else
130                         loops_per_jiffy = 50000000 / HZ;
131                 of_node_put(cpu);
132         }
133
134 #ifdef CONFIG_PCI
135         for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
136                 add_bridge(np);
137
138         ppc_md.pcibios_fixup = mpc85xx_pcibios_fixup;
139         ppc_md.pci_exclude_device = mpc85xx_exclude_device;
140 #endif
141
142 #ifdef  CONFIG_ROOT_NFS
143         ROOT_DEV = Root_NFS;
144 #else
145         ROOT_DEV = Root_HDA1;
146 #endif
147 }
148
149 void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
150 {
151         uint pvid, svid, phid1;
152         uint memsize = total_memory;
153
154         pvid = mfspr(SPRN_PVR);
155         svid = mfspr(SPRN_SVR);
156
157         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
158         seq_printf(m, "Machine\t\t: mpc85xx\n");
159         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
160         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
161
162         /* Display cpu Pll setting */
163         phid1 = mfspr(SPRN_HID1);
164         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
165
166         /* Display the amount of memory */
167         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
168 }
169
170 /*
171  * Called very early, device-tree isn't unflattened
172  */
173 static int __init mpc85xx_ads_probe(void)
174 {
175         /* We always match for now, eventually we should look at the flat
176            dev tree to ensure this is the board we are suppose to run on
177         */
178         return 1;
179 }
180
181 define_machine(mpc85xx_ads) {
182         .name                   = "MPC85xx ADS",
183         .probe                  = mpc85xx_ads_probe,
184         .setup_arch             = mpc85xx_ads_setup_arch,
185         .init_IRQ               = mpc85xx_ads_pic_init,
186         .show_cpuinfo           = mpc85xx_ads_show_cpuinfo,
187         .get_irq                = mpic_get_irq,
188         .restart                = mpc85xx_restart,
189         .calibrate_decr         = generic_calibrate_decr,
190         .progress               = udbg_progress,
191 };