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/slab.h>
30 #include <linux/seq_file.h>
31 #include <linux/ide.h>
32 #include <linux/root_dev.h>
34 #include <asm/byteorder.h>
35 #include <asm/system.h>
36 #include <asm/pgtable.h>
41 #include <asm/machdep.h>
43 #include <platforms/powerpmc250.h>
44 #include <asm/open_pic.h>
45 #include <asm/pci-bridge.h>
46 #include <asm/mpc10x.h>
47 #include <asm/uaccess.h>
48 #include <asm/bootinfo.h>
50 extern void powerpmc250_find_bridges(void);
51 extern unsigned long loops_per_jiffy
;
53 static u_char powerpmc250_openpic_initsenses
[] __initdata
=
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 1, /* PMC INTA (also MPC107 output interrupt INTA) */
57 1, /* PMC INTB (also I82559 Ethernet controller) */
60 0, /* DUART interrupt (active high) */
64 powerpmc250_show_cpuinfo(struct seq_file
*m
)
66 seq_printf(m
,"machine\t\t: Force PowerPMC250\n");
72 powerpmc250_setup_arch(void)
74 /* init to some ~sane value until calibrate_delay() runs */
75 loops_per_jiffy
= 50000000/HZ
;
77 /* Lookup PCI host bridges */
78 powerpmc250_find_bridges();
80 #ifdef CONFIG_BLK_DEV_INITRD
85 #ifdef CONFIG_ROOT_NFS
91 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
96 * Compute the PrPMC750's bus speed using the baud clock as a
99 unsigned long __init
powerpmc250_get_bus_speed(void)
101 unsigned long tbl_start
, tbl_end
;
102 unsigned long current_state
, old_state
, bus_speed
;
103 unsigned char lcr
, dll
, dlm
;
104 int baud_divisor
, count
;
106 /* Read the UART's baud clock divisor */
107 lcr
= readb(PRPMC750_SERIAL_0_LCR
);
108 writeb(lcr
| UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
109 dll
= readb(PRPMC750_SERIAL_0_DLL
);
110 dlm
= readb(PRPMC750_SERIAL_0_DLM
);
111 writeb(lcr
& ~UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
112 baud_divisor
= (dlm
<< 8) | dll
;
115 * Use the baud clock divisor and base baud clock
116 * to determine the baud rate and use that as
117 * the number of baud clock edges we use for
118 * the time base sample. Make it half the baud
121 count
= PRPMC750_BASE_BAUD
/ (baud_divisor
* 16);
123 /* Find the first edge of the baud clock */
124 old_state
= readb(PRPMC750_STATUS_REG
) & PRPMC750_BAUDOUT_MASK
;
126 current_state
= readb(PRPMC750_STATUS_REG
) &
127 PRPMC750_BAUDOUT_MASK
;
128 } while(old_state
== current_state
);
130 old_state
= current_state
;
132 /* Get the starting time base value */
133 tbl_start
= get_tbl();
136 * Loop until we have found a number of edges equal
137 * to half the count (half the baud rate)
141 current_state
= readb(PRPMC750_STATUS_REG
) &
142 PRPMC750_BAUDOUT_MASK
;
143 } while(old_state
== current_state
);
144 old_state
= current_state
;
147 /* Get the ending time base value */
150 /* Compute bus speed */
151 bus_speed
= (tbl_end
-tbl_start
)*128;
158 powerpmc250_calibrate_decr(void)
163 //freq = powerpmc250_get_bus_speed();
164 #warning hardcoded bus freq
167 tb_ticks_per_jiffy
= freq
/ (HZ
* divisor
);
168 tb_to_us
= mulhwu_scale_factor(freq
/divisor
, 1000000);
172 powerpmc250_restart(char *cmd
)
176 writeb(0x11, 0xfe000332);
181 powerpmc250_halt(void)
188 powerpmc250_power_off(void)
194 powerpmc250_init_IRQ(void)
197 OpenPIC_InitSenses
= powerpmc250_openpic_initsenses
;
198 OpenPIC_NumInitSenses
= sizeof(powerpmc250_openpic_initsenses
);
199 mpc10x_set_openpic();
203 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
205 static __inline__
void
206 powerpmc250_set_bat(void)
208 unsigned long bat3u
, bat3l
;
209 static int mapping_set
= 0;
213 __asm__
__volatile__(
221 : "=r" (bat3u
), "=r" (bat3l
));
228 static unsigned long __init
229 powerpmc250_find_end_of_memory(void)
231 /* Cover I/O space with a BAT */
232 /* yuck, better hope your ram size is a power of 2 -- paulus */
233 powerpmc250_set_bat();
235 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B
);
239 powerpmc250_map_io(void)
241 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO
);
245 platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
246 unsigned long r6
, unsigned long r7
)
248 parse_bootinfo(find_bootinfo());
250 #ifdef CONFIG_BLK_DEV_INITRD
253 initrd_start
= r4
+ KERNELBASE
;
254 initrd_end
= r5
+ KERNELBASE
;
258 /* Copy cmd_line parameters */
261 *(char *)(r7
+ KERNELBASE
) = 0;
262 strcpy(cmd_line
, (char *)(r6
+ KERNELBASE
));
265 isa_io_base
= MPC10X_MAPB_ISA_IO_BASE
;
266 isa_mem_base
= MPC10X_MAPB_ISA_MEM_BASE
;
267 pci_dram_offset
= MPC10X_MAPB_DRAM_OFFSET
;
269 ppc_md
.setup_arch
= powerpmc250_setup_arch
;
270 ppc_md
.show_cpuinfo
= powerpmc250_show_cpuinfo
;
271 ppc_md
.init_IRQ
= powerpmc250_init_IRQ
;
272 ppc_md
.get_irq
= openpic_get_irq
;
274 ppc_md
.find_end_of_memory
= powerpmc250_find_end_of_memory
;
275 ppc_md
.setup_io_mappings
= powerpmc250_map_io
;
277 ppc_md
.restart
= powerpmc250_restart
;
278 ppc_md
.power_off
= powerpmc250_power_off
;
279 ppc_md
.halt
= powerpmc250_halt
;
281 /* PowerPMC250 has no timekeeper part */
282 ppc_md
.time_init
= NULL
;
283 ppc_md
.get_rtc_time
= NULL
;
284 ppc_md
.set_rtc_time
= NULL
;
285 ppc_md
.calibrate_decr
= powerpmc250_calibrate_decr
;
290 * (This used to be arch/ppc/platforms/powerpmc250_pci.c)
292 * PCI support for Force PowerPMC250
298 #define DBG(x...) printk(x)
303 static inline int __init
304 powerpmc250_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
306 static char pci_irq_table
[][4] =
308 * PCI IDSEL/INTPIN->INTLINE
312 {17, 0, 0, 0}, /* Device 11 - 82559 */
313 {0, 0, 0, 0}, /* 12 */
314 {0, 0, 0, 0}, /* 13 */
315 {0, 0, 0, 0}, /* 14 */
316 {0, 0, 0, 0}, /* 15 */
317 {16, 17, 18, 19}, /* Device 16 - PMC A1?? */
319 const long min_idsel
= 11, max_idsel
= 16, irqs_per_slot
= 4;
320 return PCI_IRQ_TABLE_LOOKUP
;
324 powerpmc250_exclude_device(u_char bus
, u_char devfn
)
327 * While doing PCI Scan the MPC107 will 'detect' itself as
328 * device on the PCI Bus, will create an incorrect response and
329 * later will respond incorrectly to Configuration read coming
330 * from another device.
332 * The work around is that when doing a PCI Scan one
333 * should skip its own device number in the scan.
335 * The top IDsel is AD13 and the middle is AD14.
340 if ((bus
== 0) && (PCI_SLOT(devfn
) == 13 || PCI_SLOT(devfn
) == 14)) {
341 return PCIBIOS_DEVICE_NOT_FOUND
;
344 return PCIBIOS_SUCCESSFUL
;
349 powerpmc250_find_bridges(void)
351 struct pci_controller
* hose
;
353 hose
= pcibios_alloc_controller();
355 printk("Can't allocate PCI 'hose' structure!!!\n");
359 hose
->first_busno
= 0;
360 hose
->last_busno
= 0xff;
362 if (mpc10x_bridge_init(hose
,
365 MPC10X_MAPB_EUMB_BASE
) == 0) {
367 hose
->mem_resources
[0].end
= 0xffffffff;
369 hose
->last_busno
= pciauto_bus_scan(hose
, hose
->first_busno
);
371 /* ppc_md.pcibios_fixup = pcore_pcibios_fixup; */
372 ppc_md
.pci_swizzle
= common_swizzle
;
374 ppc_md
.pci_exclude_device
= powerpmc250_exclude_device
;
375 ppc_md
.pci_map_irq
= powerpmc250_map_irq
;
378 ppc_md
.progress("Bridge init failed", 0x100);
379 printk("Host bridge init failed\n");