[PATCH] powerpc: lindent 85xx platform code
[powerpc.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/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/pci.h>
18 #include <linux/kdev_t.h>
19 #include <linux/delay.h>
20 #include <linux/seq_file.h>
21 #include <linux/root_dev.h>
22
23 #include <asm/system.h>
24 #include <asm/time.h>
25 #include <asm/machdep.h>
26 #include <asm/pci-bridge.h>
27 #include <asm/mpc85xx.h>
28 #include <asm/prom.h>
29 #include <asm/mpic.h>
30 #include <mm/mmu_decl.h>
31 #include <asm/udbg.h>
32
33 #include <sysdev/fsl_soc.h>
34 #include "mpc85xx.h"
35
36 #ifndef CONFIG_PCI
37 unsigned long isa_io_base = 0;
38 unsigned long isa_mem_base = 0;
39 #endif
40
41 /*
42  * Internal interrupts are all Level Sensitive, and Positive Polarity
43  *
44  * Note:  Likely, this table and the following function should be
45  *        obtained and derived from the OF Device Tree.
46  */
47 static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
48         MPC85XX_INTERNAL_IRQ_SENSES,
49         0x0,                    /* External  0: */
50 #if defined(CONFIG_PCI)
51         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext 1: PCI slot 0 */
52         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext 2: PCI slot 1 */
53         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext 3: PCI slot 2 */
54         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* Ext 4: PCI slot 3 */
55 #else
56         0x0,                    /* External  1: */
57         0x0,                    /* External  2: */
58         0x0,                    /* External  3: */
59         0x0,                    /* External  4: */
60 #endif
61         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 5: PHY */
62         0x0,                    /* External  6: */
63         (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),      /* External 7: PHY */
64         0x0,                    /* External  8: */
65         0x0,                    /* External  9: */
66         0x0,                    /* External 10: */
67         0x0,                    /* External 11: */
68 };
69
70 void __init mpc85xx_ads_pic_init(void)
71 {
72         struct mpic *mpic1;
73         phys_addr_t OpenPIC_PAddr;
74
75         /* Determine the Physical Address of the OpenPIC regs */
76         OpenPIC_PAddr = get_immrbase() + MPC85xx_OPENPIC_OFFSET;
77
78         mpic1 = mpic_alloc(OpenPIC_PAddr,
79                            MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
80                            4, MPC85xx_OPENPIC_IRQ_OFFSET, 0, 250,
81                            mpc85xx_ads_openpic_initsenses,
82                            sizeof(mpc85xx_ads_openpic_initsenses),
83                            " OpenPIC  ");
84         BUG_ON(mpic1 == NULL);
85         mpic_assign_isu(mpic1, 0, OpenPIC_PAddr + 0x10200);
86         mpic_assign_isu(mpic1, 1, OpenPIC_PAddr + 0x10280);
87         mpic_assign_isu(mpic1, 2, OpenPIC_PAddr + 0x10300);
88         mpic_assign_isu(mpic1, 3, OpenPIC_PAddr + 0x10380);
89         mpic_assign_isu(mpic1, 4, OpenPIC_PAddr + 0x10400);
90         mpic_assign_isu(mpic1, 5, OpenPIC_PAddr + 0x10480);
91         mpic_assign_isu(mpic1, 6, OpenPIC_PAddr + 0x10500);
92         mpic_assign_isu(mpic1, 7, OpenPIC_PAddr + 0x10580);
93
94         /* dummy mappings to get to 48 */
95         mpic_assign_isu(mpic1, 8, OpenPIC_PAddr + 0x10600);
96         mpic_assign_isu(mpic1, 9, OpenPIC_PAddr + 0x10680);
97         mpic_assign_isu(mpic1, 10, OpenPIC_PAddr + 0x10700);
98         mpic_assign_isu(mpic1, 11, OpenPIC_PAddr + 0x10780);
99
100         /* External ints */
101         mpic_assign_isu(mpic1, 12, OpenPIC_PAddr + 0x10000);
102         mpic_assign_isu(mpic1, 13, OpenPIC_PAddr + 0x10080);
103         mpic_assign_isu(mpic1, 14, OpenPIC_PAddr + 0x10100);
104         mpic_init(mpic1);
105 }
106
107 /*
108  * Setup the architecture
109  */
110 static void __init mpc85xx_ads_setup_arch(void)
111 {
112         struct device_node *cpu;
113
114         if (ppc_md.progress)
115                 ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
116
117         cpu = of_find_node_by_type(NULL, "cpu");
118         if (cpu != 0) {
119                 unsigned int *fp;
120
121                 fp = (int *)get_property(cpu, "clock-frequency", NULL);
122                 if (fp != 0)
123                         loops_per_jiffy = *fp / HZ;
124                 else
125                         loops_per_jiffy = 50000000 / HZ;
126                 of_node_put(cpu);
127         }
128 #ifdef  CONFIG_ROOT_NFS
129         ROOT_DEV = Root_NFS;
130 #else
131         ROOT_DEV = Root_HDA1;
132 #endif
133 }
134
135 void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
136 {
137         uint pvid, svid, phid1;
138         uint memsize = total_memory;
139
140         pvid = mfspr(SPRN_PVR);
141         svid = mfspr(SPRN_SVR);
142
143         seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
144         seq_printf(m, "Machine\t\t: mpc85xx\n");
145         seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
146         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
147
148         /* Display cpu Pll setting */
149         phid1 = mfspr(SPRN_HID1);
150         seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
151
152         /* Display the amount of memory */
153         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
154 }
155
156 void __init platform_init(void)
157 {
158         ppc_md.setup_arch = mpc85xx_ads_setup_arch;
159         ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
160
161         ppc_md.init_IRQ = mpc85xx_ads_pic_init;
162         ppc_md.get_irq = mpic_get_irq;
163
164         ppc_md.restart = mpc85xx_restart;
165         ppc_md.power_off = NULL;
166         ppc_md.halt = NULL;
167
168         ppc_md.time_init = NULL;
169         ppc_md.set_rtc_time = NULL;
170         ppc_md.get_rtc_time = NULL;
171         ppc_md.calibrate_decr = generic_calibrate_decr;
172
173         ppc_md.progress = udbg_progress;
174
175         if (ppc_md.progress)
176                 ppc_md.progress("mpc85xx_ads platform_init(): exit", 0);
177 }