diff options
Diffstat (limited to 'arch/powerpc/platforms/83xx/mpc834x_sys.c')
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc834x_sys.c | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c new file mode 100644 index 0000000000..2098dd05a7 --- /dev/null +++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * arch/powerpc/platforms/83xx/mpc834x_sys.c | ||
3 | * | ||
4 | * MPC834x SYS board specific routines | ||
5 | * | ||
6 | * Maintainer: Kumar Gala <galak@kernel.crashing.org> | ||
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/init.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/reboot.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/kdev_t.h> | ||
22 | #include <linux/major.h> | ||
23 | #include <linux/console.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/seq_file.h> | ||
26 | #include <linux/root_dev.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/fsl_devices.h> | ||
29 | |||
30 | #include <asm/system.h> | ||
31 | #include <asm/pgtable.h> | ||
32 | #include <asm/page.h> | ||
33 | #include <asm/atomic.h> | ||
34 | #include <asm/time.h> | ||
35 | #include <asm/io.h> | ||
36 | #include <asm/machdep.h> | ||
37 | #include <asm/ipic.h> | ||
38 | #include <asm/bootinfo.h> | ||
39 | #include <asm/pci-bridge.h> | ||
40 | #include <asm/mpc83xx.h> | ||
41 | #include <asm/irq.h> | ||
42 | #include <mm/mmu_decl.h> | ||
43 | #include <asm/prom.h> | ||
44 | #include <asm/udbg.h> | ||
45 | #include <sysdev/fsl_soc.h> | ||
46 | |||
47 | #include "mpc83xx.h" | ||
48 | |||
49 | #ifndef CONFIG_PCI | ||
50 | unsigned long isa_io_base = 0; | ||
51 | unsigned long isa_mem_base = 0; | ||
52 | #endif | ||
53 | |||
54 | #ifdef CONFIG_PCI | ||
55 | extern int mpc83xx_pci2_busno; | ||
56 | |||
57 | static int | ||
58 | mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin) | ||
59 | { | ||
60 | static char pci_irq_table[][4] = | ||
61 | /* | ||
62 | * PCI IDSEL/INTPIN->INTLINE | ||
63 | * A B C D | ||
64 | */ | ||
65 | { | ||
66 | {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x11 */ | ||
67 | {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x12 */ | ||
68 | {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x13 */ | ||
69 | {0, 0, 0, 0}, | ||
70 | {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x15 */ | ||
71 | {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x16 */ | ||
72 | {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x17 */ | ||
73 | {PIRQB, PIRQC, PIRQD, PIRQA}, /* idsel 0x18 */ | ||
74 | {0, 0, 0, 0}, /* idsel 0x19 */ | ||
75 | {0, 0, 0, 0}, /* idsel 0x20 */ | ||
76 | }; | ||
77 | |||
78 | const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4; | ||
79 | return PCI_IRQ_TABLE_LOOKUP; | ||
80 | } | ||
81 | |||
82 | static int | ||
83 | mpc83xx_exclude_device(u_char bus, u_char devfn) | ||
84 | { | ||
85 | if (bus == 0 && PCI_SLOT(devfn) == 0) | ||
86 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
87 | if (mpc83xx_pci2_busno) | ||
88 | if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0) | ||
89 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
90 | return PCIBIOS_SUCCESSFUL; | ||
91 | } | ||
92 | #endif /* CONFIG_PCI */ | ||
93 | |||
94 | /* ************************************************************************ | ||
95 | * | ||
96 | * Setup the architecture | ||
97 | * | ||
98 | */ | ||
99 | static void __init | ||
100 | mpc834x_sys_setup_arch(void) | ||
101 | { | ||
102 | struct device_node *np; | ||
103 | |||
104 | if (ppc_md.progress) | ||
105 | ppc_md.progress("mpc834x_sys_setup_arch()", 0); | ||
106 | |||
107 | np = of_find_node_by_type(NULL, "cpu"); | ||
108 | if (np != 0) { | ||
109 | unsigned int *fp = (int *) get_property(np, "clock-frequency", NULL); | ||
110 | if (fp != 0) | ||
111 | loops_per_jiffy = *fp / HZ; | ||
112 | else | ||
113 | loops_per_jiffy = 50000000 / HZ; | ||
114 | of_node_put(np); | ||
115 | } | ||
116 | |||
117 | #ifdef CONFIG_PCI | ||
118 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | ||
119 | add_bridge(np); | ||
120 | |||
121 | ppc_md.pci_swizzle = common_swizzle; | ||
122 | ppc_md.pci_map_irq = mpc83xx_map_irq; | ||
123 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | ||
124 | #endif | ||
125 | |||
126 | #ifdef CONFIG_ROOT_NFS | ||
127 | ROOT_DEV = Root_NFS; | ||
128 | #else | ||
129 | ROOT_DEV = Root_HDA1; | ||
130 | #endif | ||
131 | } | ||
132 | |||
133 | void __init | ||
134 | mpc834x_sys_init_IRQ(void) | ||
135 | { | ||
136 | u8 senses[8] = { | ||
137 | 0, /* EXT 0 */ | ||
138 | IRQ_SENSE_LEVEL, /* EXT 1 */ | ||
139 | IRQ_SENSE_LEVEL, /* EXT 2 */ | ||
140 | 0, /* EXT 3 */ | ||
141 | #ifdef CONFIG_PCI | ||
142 | IRQ_SENSE_LEVEL, /* EXT 4 */ | ||
143 | IRQ_SENSE_LEVEL, /* EXT 5 */ | ||
144 | IRQ_SENSE_LEVEL, /* EXT 6 */ | ||
145 | IRQ_SENSE_LEVEL, /* EXT 7 */ | ||
146 | #else | ||
147 | 0, /* EXT 4 */ | ||
148 | 0, /* EXT 5 */ | ||
149 | 0, /* EXT 6 */ | ||
150 | 0, /* EXT 7 */ | ||
151 | #endif | ||
152 | }; | ||
153 | |||
154 | ipic_init(get_immrbase() + 0x00700, 0, 0, senses, 8); | ||
155 | |||
156 | /* Initialize the default interrupt mapping priorities, | ||
157 | * in case the boot rom changed something on us. | ||
158 | */ | ||
159 | ipic_set_default_priority(); | ||
160 | } | ||
161 | |||
162 | #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374) | ||
163 | extern ulong ds1374_get_rtc_time(void); | ||
164 | extern int ds1374_set_rtc_time(ulong); | ||
165 | |||
166 | static int __init | ||
167 | mpc834x_rtc_hookup(void) | ||
168 | { | ||
169 | struct timespec tv; | ||
170 | |||
171 | ppc_md.get_rtc_time = ds1374_get_rtc_time; | ||
172 | ppc_md.set_rtc_time = ds1374_set_rtc_time; | ||
173 | |||
174 | tv.tv_nsec = 0; | ||
175 | tv.tv_sec = (ppc_md.get_rtc_time)(); | ||
176 | do_settimeofday(&tv); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | late_initcall(mpc834x_rtc_hookup); | ||
181 | #endif | ||
182 | |||
183 | static void | ||
184 | mpc83xx_restart(char *cmd) | ||
185 | { | ||
186 | #define RST_OFFSET 0x00000900 | ||
187 | #define RST_PROT_REG 0x00000018 | ||
188 | #define RST_CTRL_REG 0x0000001c | ||
189 | __be32 __iomem *reg; | ||
190 | |||
191 | // map reset register space | ||
192 | reg = ioremap(get_immrbase() + 0x900, 0xff); | ||
193 | |||
194 | local_irq_disable(); | ||
195 | |||
196 | /* enable software reset "RSTE" */ | ||
197 | out_be32(reg + (RST_PROT_REG >> 2), 0x52535445); | ||
198 | |||
199 | /* set software hard reset */ | ||
200 | out_be32(reg + (RST_CTRL_REG >> 2), 0x52535445); | ||
201 | for(;;); | ||
202 | } | ||
203 | |||
204 | static long __init | ||
205 | mpc83xx_time_init(void) | ||
206 | { | ||
207 | #define SPCR_OFFSET 0x00000110 | ||
208 | #define SPCR_TBEN 0x00400000 | ||
209 | __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4); | ||
210 | __be32 tmp; | ||
211 | |||
212 | tmp = in_be32(spcr); | ||
213 | out_be32(spcr, tmp|SPCR_TBEN); | ||
214 | |||
215 | iounmap(spcr); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | void __init | ||
220 | platform_init(void) | ||
221 | { | ||
222 | /* setup the PowerPC module struct */ | ||
223 | ppc_md.setup_arch = mpc834x_sys_setup_arch; | ||
224 | |||
225 | ppc_md.init_IRQ = mpc834x_sys_init_IRQ; | ||
226 | ppc_md.get_irq = ipic_get_irq; | ||
227 | |||
228 | ppc_md.restart = mpc83xx_restart; | ||
229 | |||
230 | ppc_md.time_init = mpc83xx_time_init; | ||
231 | ppc_md.set_rtc_time = NULL; | ||
232 | ppc_md.get_rtc_time = NULL; | ||
233 | ppc_md.calibrate_decr = generic_calibrate_decr; | ||
234 | |||
235 | ppc_md.progress = udbg_progress; | ||
236 | |||
237 | if (ppc_md.progress) | ||
238 | ppc_md.progress("mpc834x_sys_init(): exit", 0); | ||
239 | |||
240 | return; | ||
241 | } | ||
242 | |||
243 | |||