blob: 76a2aa4ce65e17ecfb16ca566c0d90c1ac8e59df [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/ppc/syslib/m8260_setup.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Adapted from 'alpha' version by Gary Thomas
6 * Modified by Cort Dougan (cort@cs.nmt.edu)
7 * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
8 * Further modified for generic 8xx and 8260 by Dan.
9 */
10
11#include <linux/config.h>
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/mm.h>
15#include <linux/stddef.h>
16#include <linux/slab.h>
17#include <linux/init.h>
18#include <linux/initrd.h>
19#include <linux/root_dev.h>
20#include <linux/seq_file.h>
21#include <linux/irq.h>
22
23#include <asm/mmu.h>
24#include <asm/io.h>
25#include <asm/pgtable.h>
26#include <asm/mpc8260.h>
Kumar Galad054b5a2005-07-27 11:44:06 -070027#include <asm/cpm2.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/machdep.h>
29#include <asm/bootinfo.h>
30#include <asm/time.h>
31
32#include "cpm2_pic.h"
33
34unsigned char __res[sizeof(bd_t)];
35
Vitaly Borduga6dbba72005-05-28 15:52:09 -070036extern void pq2_find_bridges(void);
37extern void pq2pci_init_irq(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038extern void idma_pci9_init(void);
39
40/* Place-holder for board-specific init */
41void __attribute__ ((weak)) __init
42m82xx_board_setup(void)
43{
44}
45
46static void __init
47m8260_setup_arch(void)
48{
49 /* Print out Vendor and Machine info. */
50 printk(KERN_INFO "%s %s port\n", CPUINFO_VENDOR, CPUINFO_MACHINE);
51
52 /* Reset the Communication Processor Module. */
53 cpm2_reset();
54#ifdef CONFIG_8260_PCI9
55 /* Initialise IDMA for PCI erratum workaround */
56 idma_pci9_init();
57#endif
58#ifdef CONFIG_PCI_8260
Vitaly Borduga6dbba72005-05-28 15:52:09 -070059 pq2_find_bridges();
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#endif
61#ifdef CONFIG_BLK_DEV_INITRD
62 if (initrd_start)
63 ROOT_DEV = Root_RAM0;
64#endif
Vitaly Bordug1461b4e2005-10-28 17:46:28 -070065
66 identify_ppc_sys_by_name_and_id(BOARD_CHIP_NAME,
67 in_be32(CPM_MAP_ADDR + CPM_IMMR_OFFSET));
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 m82xx_board_setup();
70}
71
72/* The decrementer counts at the system (internal) clock frequency
73 * divided by four.
74 */
75static void __init
76m8260_calibrate_decr(void)
77{
78 bd_t *binfo = (bd_t *)__res;
79 int freq, divisor;
80
81 freq = binfo->bi_busfreq;
82 divisor = 4;
83 tb_ticks_per_jiffy = freq / HZ / divisor;
84 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
85}
86
87/* The 8260 has an internal 1-second timer update register that
88 * we should use for this purpose.
89 */
90static uint rtc_time;
91
92static int
93m8260_set_rtc_time(unsigned long time)
94{
95 rtc_time = time;
96
97 return(0);
98}
99
100static unsigned long
101m8260_get_rtc_time(void)
102{
103 /* Get time from the RTC.
104 */
105 return((unsigned long)rtc_time);
106}
107
108#ifndef BOOTROM_RESTART_ADDR
109#warning "Using default BOOTROM_RESTART_ADDR!"
110#define BOOTROM_RESTART_ADDR 0xff000104
111#endif
112
113static void
114m8260_restart(char *cmd)
115{
116 extern void m8260_gorom(bd_t *bi, uint addr);
117 uint startaddr;
118
119 /* Most boot roms have a warmstart as the second instruction
120 * of the reset vector. If that doesn't work for you, change this
121 * or the reboot program to send a proper address.
122 */
123 startaddr = BOOTROM_RESTART_ADDR;
124 if (cmd != NULL) {
125 if (!strncmp(cmd, "startaddr=", 10))
126 startaddr = simple_strtoul(&cmd[10], NULL, 0);
127 }
128
129 m8260_gorom((void*)__pa(__res), startaddr);
130}
131
132static void
133m8260_halt(void)
134{
135 local_irq_disable();
136 while (1);
137}
138
139static void
140m8260_power_off(void)
141{
142 m8260_halt();
143}
144
145static int
146m8260_show_cpuinfo(struct seq_file *m)
147{
148 bd_t *bp = (bd_t *)__res;
149
150 seq_printf(m, "vendor\t\t: %s\n"
151 "machine\t\t: %s\n"
152 "\n"
153 "mem size\t\t: 0x%08x\n"
154 "console baud\t\t: %d\n"
155 "\n"
156 "core clock\t: %u MHz\n"
157 "CPM clock\t: %u MHz\n"
158 "bus clock\t: %u MHz\n",
159 CPUINFO_VENDOR, CPUINFO_MACHINE, bp->bi_memsize,
160 bp->bi_baudrate, bp->bi_intfreq / 1000000,
161 bp->bi_cpmfreq / 1000000, bp->bi_busfreq / 1000000);
162 return 0;
163}
164
165/* Initialize the internal interrupt controller. The number of
166 * interrupts supported can vary with the processor type, and the
167 * 8260 family can have up to 64.
168 * External interrupts can be either edge or level triggered, and
169 * need to be initialized by the appropriate driver.
170 */
171static void __init
172m8260_init_IRQ(void)
173{
174 cpm2_init_IRQ();
175
176 /* Initialize the default interrupt mapping priorities,
177 * in case the boot rom changed something on us.
178 */
179 cpm2_immr->im_intctl.ic_siprr = 0x05309770;
Vitaly Borduga6dbba72005-05-28 15:52:09 -0700180
181#if defined(CONFIG_PCI) && (defined(CONFIG_ADS8272) || defined(CONFIG_PQ2FADS))
182 /* Initialize stuff for the 82xx CPLD IC and install demux */
183 pq2pci_init_irq();
184#endif
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186}
187
188/*
189 * Same hack as 8xx
190 */
191static unsigned long __init
192m8260_find_end_of_memory(void)
193{
194 bd_t *binfo = (bd_t *)__res;
195
196 return binfo->bi_memsize;
197}
198
199/* Map the IMMR, plus anything else we can cover
200 * in that upper space according to the memory controller
201 * chip select mapping. Grab another bunch of space
202 * below that for stuff we can't cover in the upper.
203 */
204static void __init
205m8260_map_io(void)
206{
207 uint addr;
208
209 /* Map IMMR region to a 256MB BAT */
210 addr = (cpm2_immr != NULL) ? (uint)cpm2_immr : CPM_MAP_ADDR;
211 io_block_mapping(addr, addr, 0x10000000, _PAGE_IO);
212
213 /* Map I/O region to a 256MB BAT */
214 io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO);
215}
216
217/* Place-holder for board-specific ppc_md hooking */
218void __attribute__ ((weak)) __init
219m82xx_board_init(void)
220{
221}
222
223/* Inputs:
224 * r3 - Optional pointer to a board information structure.
225 * r4 - Optional pointer to the physical starting address of the init RAM
226 * disk.
227 * r5 - Optional pointer to the physical ending address of the init RAM
228 * disk.
229 * r6 - Optional pointer to the physical starting address of any kernel
230 * command-line parameters.
231 * r7 - Optional pointer to the physical ending address of any kernel
232 * command-line parameters.
233 */
234void __init
235platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
236 unsigned long r6, unsigned long r7)
237{
238 parse_bootinfo(find_bootinfo());
239
240 if ( r3 )
241 memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
242
243#ifdef CONFIG_BLK_DEV_INITRD
244 /* take care of initrd if we have one */
245 if ( r4 ) {
246 initrd_start = r4 + KERNELBASE;
247 initrd_end = r5 + KERNELBASE;
248 }
249#endif /* CONFIG_BLK_DEV_INITRD */
250 /* take care of cmd line */
251 if ( r6 ) {
252 *(char *)(r7+KERNELBASE) = 0;
253 strcpy(cmd_line, (char *)(r6+KERNELBASE));
254 }
255
256 ppc_md.setup_arch = m8260_setup_arch;
257 ppc_md.show_cpuinfo = m8260_show_cpuinfo;
258 ppc_md.init_IRQ = m8260_init_IRQ;
259 ppc_md.get_irq = cpm2_get_irq;
260
261 ppc_md.restart = m8260_restart;
262 ppc_md.power_off = m8260_power_off;
263 ppc_md.halt = m8260_halt;
264
265 ppc_md.set_rtc_time = m8260_set_rtc_time;
266 ppc_md.get_rtc_time = m8260_get_rtc_time;
267 ppc_md.calibrate_decr = m8260_calibrate_decr;
268
269 ppc_md.find_end_of_memory = m8260_find_end_of_memory;
270 ppc_md.setup_io_mappings = m8260_map_io;
271
272 /* Call back for board-specific settings and overrides. */
273 m82xx_board_init();
274}