2 * Board setup routines for Force PowerPMC-250 Processor PMC
4 * Author: Troy Benjegerdes <tbenjegerdes@mvista.com>
5 * Borrowed heavily from prpmc750_*.c by
6 * Matt Porter <mporter@mvista.com>
8 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
14 #include <linux/stddef.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <linux/reboot.h>
19 #include <linux/pci.h>
20 #include <linux/kdev_t.h>
21 #include <linux/types.h>
22 #include <linux/major.h>
23 #include <linux/initrd.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/slab.h>
27 #include <linux/seq_file.h>
28 #include <linux/root_dev.h>
30 #include <asm/byteorder.h>
31 #include <asm/system.h>
32 #include <asm/pgtable.h>
37 #include <asm/machdep.h>
39 #include <platforms/powerpmc250.h>
40 #include <asm/open_pic.h>
41 #include <asm/pci-bridge.h>
42 #include <asm/mpc10x.h>
43 #include <asm/uaccess.h>
44 #include <asm/bootinfo.h>
46 extern void powerpmc250_find_bridges(void);
47 extern unsigned long loops_per_jiffy;
49 static u_char powerpmc250_openpic_initsenses[] __initdata =
51 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 1, /* PMC INTA (also MPC107 output interrupt INTA) */
53 1, /* PMC INTB (also I82559 Ethernet controller) */
56 0, /* DUART interrupt (active high) */
60 powerpmc250_show_cpuinfo(struct seq_file *m)
62 seq_printf(m,"machine\t\t: Force PowerPMC250\n");
68 powerpmc250_setup_arch(void)
70 /* init to some ~sane value until calibrate_delay() runs */
71 loops_per_jiffy = 50000000/HZ;
73 /* Lookup PCI host bridges */
74 powerpmc250_find_bridges();
76 #ifdef CONFIG_BLK_DEV_INITRD
81 #ifdef CONFIG_ROOT_NFS
87 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
92 * Compute the PrPMC750's bus speed using the baud clock as a
95 unsigned long __init powerpmc250_get_bus_speed(void)
97 unsigned long tbl_start, tbl_end;
98 unsigned long current_state, old_state, bus_speed;
99 unsigned char lcr, dll, dlm;
100 int baud_divisor, count;
102 /* Read the UART's baud clock divisor */
103 lcr = readb(PRPMC750_SERIAL_0_LCR);
104 writeb(lcr | UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
105 dll = readb(PRPMC750_SERIAL_0_DLL);
106 dlm = readb(PRPMC750_SERIAL_0_DLM);
107 writeb(lcr & ~UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
108 baud_divisor = (dlm << 8) | dll;
111 * Use the baud clock divisor and base baud clock
112 * to determine the baud rate and use that as
113 * the number of baud clock edges we use for
114 * the time base sample. Make it half the baud
117 count = PRPMC750_BASE_BAUD / (baud_divisor * 16);
119 /* Find the first edge of the baud clock */
120 old_state = readb(PRPMC750_STATUS_REG) & PRPMC750_BAUDOUT_MASK;
122 current_state = readb(PRPMC750_STATUS_REG) &
123 PRPMC750_BAUDOUT_MASK;
124 } while(old_state == current_state);
126 old_state = current_state;
128 /* Get the starting time base value */
129 tbl_start = get_tbl();
132 * Loop until we have found a number of edges equal
133 * to half the count (half the baud rate)
137 current_state = readb(PRPMC750_STATUS_REG) &
138 PRPMC750_BAUDOUT_MASK;
139 } while(old_state == current_state);
140 old_state = current_state;
143 /* Get the ending time base value */
146 /* Compute bus speed */
147 bus_speed = (tbl_end-tbl_start)*128;
154 powerpmc250_calibrate_decr(void)
159 //freq = powerpmc250_get_bus_speed();
160 #warning hardcoded bus freq
163 tb_ticks_per_jiffy = freq / (HZ * divisor);
164 tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
168 powerpmc250_restart(char *cmd)
172 writeb(0x11, 0xfe000332);
177 powerpmc250_halt(void)
184 powerpmc250_power_off(void)
190 powerpmc250_init_IRQ(void)
193 OpenPIC_InitSenses = powerpmc250_openpic_initsenses;
194 OpenPIC_NumInitSenses = sizeof(powerpmc250_openpic_initsenses);
195 mpc10x_set_openpic();
199 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
201 static __inline__ void
202 powerpmc250_set_bat(void)
204 unsigned long bat3u, bat3l;
205 static int mapping_set = 0;
209 __asm__ __volatile__(
217 : "=r" (bat3u), "=r" (bat3l));
224 static unsigned long __init
225 powerpmc250_find_end_of_memory(void)
227 /* Cover I/O space with a BAT */
228 /* yuck, better hope your ram size is a power of 2 -- paulus */
229 powerpmc250_set_bat();
231 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
235 powerpmc250_map_io(void)
237 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
241 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
242 unsigned long r6, unsigned long r7)
244 parse_bootinfo(find_bootinfo());
246 #ifdef CONFIG_BLK_DEV_INITRD
249 initrd_start = r4 + KERNELBASE;
250 initrd_end = r5 + KERNELBASE;
254 /* Copy cmd_line parameters */
257 *(char *)(r7 + KERNELBASE) = 0;
258 strcpy(cmd_line, (char *)(r6 + KERNELBASE));
261 isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
262 isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
263 pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
265 ppc_md.setup_arch = powerpmc250_setup_arch;
266 ppc_md.show_cpuinfo = powerpmc250_show_cpuinfo;
267 ppc_md.init_IRQ = powerpmc250_init_IRQ;
268 ppc_md.get_irq = openpic_get_irq;
270 ppc_md.find_end_of_memory = powerpmc250_find_end_of_memory;
271 ppc_md.setup_io_mappings = powerpmc250_map_io;
273 ppc_md.restart = powerpmc250_restart;
274 ppc_md.power_off = powerpmc250_power_off;
275 ppc_md.halt = powerpmc250_halt;
277 /* PowerPMC250 has no timekeeper part */
278 ppc_md.time_init = NULL;
279 ppc_md.get_rtc_time = NULL;
280 ppc_md.set_rtc_time = NULL;
281 ppc_md.calibrate_decr = powerpmc250_calibrate_decr;
286 * (This used to be arch/ppc/platforms/powerpmc250_pci.c)
288 * PCI support for Force PowerPMC250
294 #define DBG(x...) printk(x)
299 static inline int __init
300 powerpmc250_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
302 static char pci_irq_table[][4] =
304 * PCI IDSEL/INTPIN->INTLINE
308 {17, 0, 0, 0}, /* Device 11 - 82559 */
309 {0, 0, 0, 0}, /* 12 */
310 {0, 0, 0, 0}, /* 13 */
311 {0, 0, 0, 0}, /* 14 */
312 {0, 0, 0, 0}, /* 15 */
313 {16, 17, 18, 19}, /* Device 16 - PMC A1?? */
315 const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
316 return PCI_IRQ_TABLE_LOOKUP;
320 powerpmc250_exclude_device(u_char bus, u_char devfn)
323 * While doing PCI Scan the MPC107 will 'detect' itself as
324 * device on the PCI Bus, will create an incorrect response and
325 * later will respond incorrectly to Configuration read coming
326 * from another device.
328 * The work around is that when doing a PCI Scan one
329 * should skip its own device number in the scan.
331 * The top IDsel is AD13 and the middle is AD14.
336 if ((bus == 0) && (PCI_SLOT(devfn) == 13 || PCI_SLOT(devfn) == 14)) {
337 return PCIBIOS_DEVICE_NOT_FOUND;
340 return PCIBIOS_SUCCESSFUL;
345 powerpmc250_find_bridges(void)
347 struct pci_controller* hose;
349 hose = pcibios_alloc_controller();
351 printk("Can't allocate PCI 'hose' structure!!!\n");
355 hose->first_busno = 0;
356 hose->last_busno = 0xff;
358 if (mpc10x_bridge_init(hose,
361 MPC10X_MAPB_EUMB_BASE) == 0) {
363 hose->mem_resources[0].end = 0xffffffff;
365 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
367 /* ppc_md.pcibios_fixup = pcore_pcibios_fixup; */
368 ppc_md.pci_swizzle = common_swizzle;
370 ppc_md.pci_exclude_device = powerpmc250_exclude_device;
371 ppc_md.pci_map_irq = powerpmc250_map_irq;
374 ppc_md.progress("Bridge init failed", 0x100);
375 printk("Host bridge init failed\n");