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/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/types.h>
23 #include <linux/major.h>
24 #include <linux/initrd.h>
25 #include <linux/console.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28 #include <linux/seq_file.h>
29 #include <linux/ide.h>
30 #include <linux/root_dev.h>
32 #include <asm/byteorder.h>
33 #include <asm/system.h>
34 #include <asm/pgtable.h>
39 #include <asm/machdep.h>
41 #include <platforms/powerpmc250.h>
42 #include <asm/open_pic.h>
43 #include <asm/pci-bridge.h>
44 #include <asm/mpc10x.h>
45 #include <asm/uaccess.h>
46 #include <asm/bootinfo.h>
48 extern void powerpmc250_find_bridges(void);
49 extern unsigned long loops_per_jiffy;
51 static u_char powerpmc250_openpic_initsenses[] __initdata =
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54 1, /* PMC INTA (also MPC107 output interrupt INTA) */
55 1, /* PMC INTB (also I82559 Ethernet controller) */
58 0, /* DUART interrupt (active high) */
62 powerpmc250_show_cpuinfo(struct seq_file *m)
64 seq_printf(m,"machine\t\t: Force PowerPMC250\n");
70 powerpmc250_setup_arch(void)
72 /* init to some ~sane value until calibrate_delay() runs */
73 loops_per_jiffy = 50000000/HZ;
75 /* Lookup PCI host bridges */
76 powerpmc250_find_bridges();
78 #ifdef CONFIG_BLK_DEV_INITRD
83 #ifdef CONFIG_ROOT_NFS
89 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
94 * Compute the PrPMC750's bus speed using the baud clock as a
97 unsigned long __init powerpmc250_get_bus_speed(void)
99 unsigned long tbl_start, tbl_end;
100 unsigned long current_state, old_state, bus_speed;
101 unsigned char lcr, dll, dlm;
102 int baud_divisor, count;
104 /* Read the UART's baud clock divisor */
105 lcr = readb(PRPMC750_SERIAL_0_LCR);
106 writeb(lcr | UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
107 dll = readb(PRPMC750_SERIAL_0_DLL);
108 dlm = readb(PRPMC750_SERIAL_0_DLM);
109 writeb(lcr & ~UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
110 baud_divisor = (dlm << 8) | dll;
113 * Use the baud clock divisor and base baud clock
114 * to determine the baud rate and use that as
115 * the number of baud clock edges we use for
116 * the time base sample. Make it half the baud
119 count = PRPMC750_BASE_BAUD / (baud_divisor * 16);
121 /* Find the first edge of the baud clock */
122 old_state = readb(PRPMC750_STATUS_REG) & PRPMC750_BAUDOUT_MASK;
124 current_state = readb(PRPMC750_STATUS_REG) &
125 PRPMC750_BAUDOUT_MASK;
126 } while(old_state == current_state);
128 old_state = current_state;
130 /* Get the starting time base value */
131 tbl_start = get_tbl();
134 * Loop until we have found a number of edges equal
135 * to half the count (half the baud rate)
139 current_state = readb(PRPMC750_STATUS_REG) &
140 PRPMC750_BAUDOUT_MASK;
141 } while(old_state == current_state);
142 old_state = current_state;
145 /* Get the ending time base value */
148 /* Compute bus speed */
149 bus_speed = (tbl_end-tbl_start)*128;
156 powerpmc250_calibrate_decr(void)
161 //freq = powerpmc250_get_bus_speed();
162 #warning hardcoded bus freq
165 tb_ticks_per_jiffy = freq / (HZ * divisor);
166 tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
170 powerpmc250_restart(char *cmd)
174 writeb(0x11, 0xfe000332);
179 powerpmc250_halt(void)
186 powerpmc250_power_off(void)
192 powerpmc250_init_IRQ(void)
195 OpenPIC_InitSenses = powerpmc250_openpic_initsenses;
196 OpenPIC_NumInitSenses = sizeof(powerpmc250_openpic_initsenses);
197 mpc10x_set_openpic();
201 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
203 static __inline__ void
204 powerpmc250_set_bat(void)
206 unsigned long bat3u, bat3l;
207 static int mapping_set = 0;
211 __asm__ __volatile__(
219 : "=r" (bat3u), "=r" (bat3l));
226 static unsigned long __init
227 powerpmc250_find_end_of_memory(void)
229 /* Cover I/O space with a BAT */
230 /* yuck, better hope your ram size is a power of 2 -- paulus */
231 powerpmc250_set_bat();
233 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
237 powerpmc250_map_io(void)
239 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
243 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
244 unsigned long r6, unsigned long r7)
246 parse_bootinfo(find_bootinfo());
248 #ifdef CONFIG_BLK_DEV_INITRD
251 initrd_start = r4 + KERNELBASE;
252 initrd_end = r5 + KERNELBASE;
256 /* Copy cmd_line parameters */
259 *(char *)(r7 + KERNELBASE) = 0;
260 strcpy(cmd_line, (char *)(r6 + KERNELBASE));
263 isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
264 isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
265 pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
267 ppc_md.setup_arch = powerpmc250_setup_arch;
268 ppc_md.show_cpuinfo = powerpmc250_show_cpuinfo;
269 ppc_md.init_IRQ = powerpmc250_init_IRQ;
270 ppc_md.get_irq = openpic_get_irq;
272 ppc_md.find_end_of_memory = powerpmc250_find_end_of_memory;
273 ppc_md.setup_io_mappings = powerpmc250_map_io;
275 ppc_md.restart = powerpmc250_restart;
276 ppc_md.power_off = powerpmc250_power_off;
277 ppc_md.halt = powerpmc250_halt;
279 /* PowerPMC250 has no timekeeper part */
280 ppc_md.time_init = NULL;
281 ppc_md.get_rtc_time = NULL;
282 ppc_md.set_rtc_time = NULL;
283 ppc_md.calibrate_decr = powerpmc250_calibrate_decr;
288 * (This used to be arch/ppc/platforms/powerpmc250_pci.c)
290 * PCI support for Force PowerPMC250
296 #define DBG(x...) printk(x)
301 static inline int __init
302 powerpmc250_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
304 static char pci_irq_table[][4] =
306 * PCI IDSEL/INTPIN->INTLINE
310 {17, 0, 0, 0}, /* Device 11 - 82559 */
311 {0, 0, 0, 0}, /* 12 */
312 {0, 0, 0, 0}, /* 13 */
313 {0, 0, 0, 0}, /* 14 */
314 {0, 0, 0, 0}, /* 15 */
315 {16, 17, 18, 19}, /* Device 16 - PMC A1?? */
317 const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
318 return PCI_IRQ_TABLE_LOOKUP;
322 powerpmc250_exclude_device(u_char bus, u_char devfn)
325 * While doing PCI Scan the MPC107 will 'detect' itself as
326 * device on the PCI Bus, will create an incorrect response and
327 * later will respond incorrectly to Configuration read coming
328 * from another device.
330 * The work around is that when doing a PCI Scan one
331 * should skip its own device number in the scan.
333 * The top IDsel is AD13 and the middle is AD14.
338 if ((bus == 0) && (PCI_SLOT(devfn) == 13 || PCI_SLOT(devfn) == 14)) {
339 return PCIBIOS_DEVICE_NOT_FOUND;
342 return PCIBIOS_SUCCESSFUL;
347 powerpmc250_find_bridges(void)
349 struct pci_controller* hose;
351 hose = pcibios_alloc_controller();
353 printk("Can't allocate PCI 'hose' structure!!!\n");
357 hose->first_busno = 0;
358 hose->last_busno = 0xff;
360 if (mpc10x_bridge_init(hose,
363 MPC10X_MAPB_EUMB_BASE) == 0) {
365 hose->mem_resources[0].end = 0xffffffff;
367 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
369 /* ppc_md.pcibios_fixup = pcore_pcibios_fixup; */
370 ppc_md.pci_swizzle = common_swizzle;
372 ppc_md.pci_exclude_device = powerpmc250_exclude_device;
373 ppc_md.pci_map_irq = powerpmc250_map_irq;
376 ppc_md.progress("Bridge init failed", 0x100);
377 printk("Host bridge init failed\n");