2 * arch/ppc/platforms/powerpmc250.c
4 * Board setup routines for Force PowerPMC-250 Processor PMC
6 * Author: Troy Benjegerdes <tbenjegerdes@mvista.com>
7 * Borrowed heavily from prpmc750_*.c by
8 * Matt Porter <mporter@mvista.com>
10 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2. This program
12 * is licensed "as is" without any warranty of any kind, whether express
16 #include <linux/config.h>
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/errno.h>
21 #include <linux/reboot.h>
22 #include <linux/pci.h>
23 #include <linux/kdev_t.h>
24 #include <linux/types.h>
25 #include <linux/major.h>
26 #include <linux/initrd.h>
27 #include <linux/console.h>
28 #include <linux/delay.h>
29 #include <linux/irq.h>
30 #include <linux/slab.h>
31 #include <linux/seq_file.h>
32 #include <linux/ide.h>
33 #include <linux/root_dev.h>
35 #include <asm/byteorder.h>
36 #include <asm/system.h>
37 #include <asm/pgtable.h>
42 #include <asm/machdep.h>
44 #include <platforms/powerpmc250.h>
45 #include <asm/open_pic.h>
46 #include <asm/pci-bridge.h>
47 #include <asm/mpc10x.h>
48 #include <asm/uaccess.h>
49 #include <asm/bootinfo.h>
51 extern void powerpmc250_find_bridges(void);
52 extern unsigned long loops_per_jiffy
;
54 static u_char powerpmc250_openpic_initsenses
[] __initdata
=
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 1, /* PMC INTA (also MPC107 output interrupt INTA) */
58 1, /* PMC INTB (also I82559 Ethernet controller) */
61 0, /* DUART interrupt (active high) */
65 powerpmc250_show_cpuinfo(struct seq_file
*m
)
67 seq_printf(m
,"machine\t\t: Force PowerPMC250\n");
73 powerpmc250_setup_arch(void)
75 /* init to some ~sane value until calibrate_delay() runs */
76 loops_per_jiffy
= 50000000/HZ
;
78 /* Lookup PCI host bridges */
79 powerpmc250_find_bridges();
81 #ifdef CONFIG_BLK_DEV_INITRD
86 #ifdef CONFIG_ROOT_NFS
92 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
97 * Compute the PrPMC750's bus speed using the baud clock as a
100 unsigned long __init
powerpmc250_get_bus_speed(void)
102 unsigned long tbl_start
, tbl_end
;
103 unsigned long current_state
, old_state
, bus_speed
;
104 unsigned char lcr
, dll
, dlm
;
105 int baud_divisor
, count
;
107 /* Read the UART's baud clock divisor */
108 lcr
= readb(PRPMC750_SERIAL_0_LCR
);
109 writeb(lcr
| UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
110 dll
= readb(PRPMC750_SERIAL_0_DLL
);
111 dlm
= readb(PRPMC750_SERIAL_0_DLM
);
112 writeb(lcr
& ~UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
113 baud_divisor
= (dlm
<< 8) | dll
;
116 * Use the baud clock divisor and base baud clock
117 * to determine the baud rate and use that as
118 * the number of baud clock edges we use for
119 * the time base sample. Make it half the baud
122 count
= PRPMC750_BASE_BAUD
/ (baud_divisor
* 16);
124 /* Find the first edge of the baud clock */
125 old_state
= readb(PRPMC750_STATUS_REG
) & PRPMC750_BAUDOUT_MASK
;
127 current_state
= readb(PRPMC750_STATUS_REG
) &
128 PRPMC750_BAUDOUT_MASK
;
129 } while(old_state
== current_state
);
131 old_state
= current_state
;
133 /* Get the starting time base value */
134 tbl_start
= get_tbl();
137 * Loop until we have found a number of edges equal
138 * to half the count (half the baud rate)
142 current_state
= readb(PRPMC750_STATUS_REG
) &
143 PRPMC750_BAUDOUT_MASK
;
144 } while(old_state
== current_state
);
145 old_state
= current_state
;
148 /* Get the ending time base value */
151 /* Compute bus speed */
152 bus_speed
= (tbl_end
-tbl_start
)*128;
159 powerpmc250_calibrate_decr(void)
164 //freq = powerpmc250_get_bus_speed();
165 #warning hardcoded bus freq
168 tb_ticks_per_jiffy
= freq
/ (HZ
* divisor
);
169 tb_to_us
= mulhwu_scale_factor(freq
/divisor
, 1000000);
173 powerpmc250_restart(char *cmd
)
177 writeb(0x11, 0xfe000332);
182 powerpmc250_halt(void)
189 powerpmc250_power_off(void)
195 powerpmc250_init_IRQ(void)
198 OpenPIC_InitSenses
= powerpmc250_openpic_initsenses
;
199 OpenPIC_NumInitSenses
= sizeof(powerpmc250_openpic_initsenses
);
200 mpc10x_set_openpic();
204 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
206 static __inline__
void
207 powerpmc250_set_bat(void)
209 unsigned long bat3u
, bat3l
;
210 static int mapping_set
= 0;
214 __asm__
__volatile__(
222 : "=r" (bat3u
), "=r" (bat3l
));
229 static unsigned long __init
230 powerpmc250_find_end_of_memory(void)
232 /* Cover I/O space with a BAT */
233 /* yuck, better hope your ram size is a power of 2 -- paulus */
234 powerpmc250_set_bat();
236 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B
);
240 powerpmc250_map_io(void)
242 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO
);
246 platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
247 unsigned long r6
, unsigned long r7
)
249 parse_bootinfo(find_bootinfo());
251 #ifdef CONFIG_BLK_DEV_INITRD
254 initrd_start
= r4
+ KERNELBASE
;
255 initrd_end
= r5
+ KERNELBASE
;
259 /* Copy cmd_line parameters */
262 *(char *)(r7
+ KERNELBASE
) = 0;
263 strcpy(cmd_line
, (char *)(r6
+ KERNELBASE
));
266 isa_io_base
= MPC10X_MAPB_ISA_IO_BASE
;
267 isa_mem_base
= MPC10X_MAPB_ISA_MEM_BASE
;
268 pci_dram_offset
= MPC10X_MAPB_DRAM_OFFSET
;
270 ppc_md
.setup_arch
= powerpmc250_setup_arch
;
271 ppc_md
.show_cpuinfo
= powerpmc250_show_cpuinfo
;
272 ppc_md
.init_IRQ
= powerpmc250_init_IRQ
;
273 ppc_md
.get_irq
= openpic_get_irq
;
275 ppc_md
.find_end_of_memory
= powerpmc250_find_end_of_memory
;
276 ppc_md
.setup_io_mappings
= powerpmc250_map_io
;
278 ppc_md
.restart
= powerpmc250_restart
;
279 ppc_md
.power_off
= powerpmc250_power_off
;
280 ppc_md
.halt
= powerpmc250_halt
;
282 /* PowerPMC250 has no timekeeper part */
283 ppc_md
.time_init
= NULL
;
284 ppc_md
.get_rtc_time
= NULL
;
285 ppc_md
.set_rtc_time
= NULL
;
286 ppc_md
.calibrate_decr
= powerpmc250_calibrate_decr
;
291 * (This used to be arch/ppc/platforms/powerpmc250_pci.c)
293 * PCI support for Force PowerPMC250
299 #define DBG(x...) printk(x)
304 static inline int __init
305 powerpmc250_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
307 static char pci_irq_table
[][4] =
309 * PCI IDSEL/INTPIN->INTLINE
313 {17, 0, 0, 0}, /* Device 11 - 82559 */
314 {0, 0, 0, 0}, /* 12 */
315 {0, 0, 0, 0}, /* 13 */
316 {0, 0, 0, 0}, /* 14 */
317 {0, 0, 0, 0}, /* 15 */
318 {16, 17, 18, 19}, /* Device 16 - PMC A1?? */
320 const long min_idsel
= 11, max_idsel
= 16, irqs_per_slot
= 4;
321 return PCI_IRQ_TABLE_LOOKUP
;
325 powerpmc250_exclude_device(u_char bus
, u_char devfn
)
328 * While doing PCI Scan the MPC107 will 'detect' itself as
329 * device on the PCI Bus, will create an incorrect response and
330 * later will respond incorrectly to Configuration read coming
331 * from another device.
333 * The work around is that when doing a PCI Scan one
334 * should skip its own device number in the scan.
336 * The top IDsel is AD13 and the middle is AD14.
341 if ((bus
== 0) && (PCI_SLOT(devfn
) == 13 || PCI_SLOT(devfn
) == 14)) {
342 return PCIBIOS_DEVICE_NOT_FOUND
;
345 return PCIBIOS_SUCCESSFUL
;
350 powerpmc250_find_bridges(void)
352 struct pci_controller
* hose
;
354 hose
= pcibios_alloc_controller();
356 printk("Can't allocate PCI 'hose' structure!!!\n");
360 hose
->first_busno
= 0;
361 hose
->last_busno
= 0xff;
363 if (mpc10x_bridge_init(hose
,
366 MPC10X_MAPB_EUMB_BASE
) == 0) {
368 hose
->mem_resources
[0].end
= 0xffffffff;
370 hose
->last_busno
= pciauto_bus_scan(hose
, hose
->first_busno
);
372 /* ppc_md.pcibios_fixup = pcore_pcibios_fixup; */
373 ppc_md
.pci_swizzle
= common_swizzle
;
375 ppc_md
.pci_exclude_device
= powerpmc250_exclude_device
;
376 ppc_md
.pci_map_irq
= powerpmc250_map_irq
;
379 ppc_md
.progress("Bridge init failed", 0x100);
380 printk("Host bridge init failed\n");