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/ide.h>
29 #include <linux/root_dev.h>
31 #include <asm/byteorder.h>
32 #include <asm/system.h>
33 #include <asm/pgtable.h>
38 #include <asm/machdep.h>
40 #include <platforms/powerpmc250.h>
41 #include <asm/open_pic.h>
42 #include <asm/pci-bridge.h>
43 #include <asm/mpc10x.h>
44 #include <asm/uaccess.h>
45 #include <asm/bootinfo.h>
47 extern void powerpmc250_find_bridges(void);
48 extern unsigned long loops_per_jiffy
;
50 static u_char powerpmc250_openpic_initsenses
[] __initdata
=
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 1, /* PMC INTA (also MPC107 output interrupt INTA) */
54 1, /* PMC INTB (also I82559 Ethernet controller) */
57 0, /* DUART interrupt (active high) */
61 powerpmc250_show_cpuinfo(struct seq_file
*m
)
63 seq_printf(m
,"machine\t\t: Force PowerPMC250\n");
69 powerpmc250_setup_arch(void)
71 /* init to some ~sane value until calibrate_delay() runs */
72 loops_per_jiffy
= 50000000/HZ
;
74 /* Lookup PCI host bridges */
75 powerpmc250_find_bridges();
77 #ifdef CONFIG_BLK_DEV_INITRD
82 #ifdef CONFIG_ROOT_NFS
88 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
93 * Compute the PrPMC750's bus speed using the baud clock as a
96 unsigned long __init
powerpmc250_get_bus_speed(void)
98 unsigned long tbl_start
, tbl_end
;
99 unsigned long current_state
, old_state
, bus_speed
;
100 unsigned char lcr
, dll
, dlm
;
101 int baud_divisor
, count
;
103 /* Read the UART's baud clock divisor */
104 lcr
= readb(PRPMC750_SERIAL_0_LCR
);
105 writeb(lcr
| UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
106 dll
= readb(PRPMC750_SERIAL_0_DLL
);
107 dlm
= readb(PRPMC750_SERIAL_0_DLM
);
108 writeb(lcr
& ~UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
109 baud_divisor
= (dlm
<< 8) | dll
;
112 * Use the baud clock divisor and base baud clock
113 * to determine the baud rate and use that as
114 * the number of baud clock edges we use for
115 * the time base sample. Make it half the baud
118 count
= PRPMC750_BASE_BAUD
/ (baud_divisor
* 16);
120 /* Find the first edge of the baud clock */
121 old_state
= readb(PRPMC750_STATUS_REG
) & PRPMC750_BAUDOUT_MASK
;
123 current_state
= readb(PRPMC750_STATUS_REG
) &
124 PRPMC750_BAUDOUT_MASK
;
125 } while(old_state
== current_state
);
127 old_state
= current_state
;
129 /* Get the starting time base value */
130 tbl_start
= get_tbl();
133 * Loop until we have found a number of edges equal
134 * to half the count (half the baud rate)
138 current_state
= readb(PRPMC750_STATUS_REG
) &
139 PRPMC750_BAUDOUT_MASK
;
140 } while(old_state
== current_state
);
141 old_state
= current_state
;
144 /* Get the ending time base value */
147 /* Compute bus speed */
148 bus_speed
= (tbl_end
-tbl_start
)*128;
155 powerpmc250_calibrate_decr(void)
160 //freq = powerpmc250_get_bus_speed();
161 #warning hardcoded bus freq
164 tb_ticks_per_jiffy
= freq
/ (HZ
* divisor
);
165 tb_to_us
= mulhwu_scale_factor(freq
/divisor
, 1000000);
169 powerpmc250_restart(char *cmd
)
173 writeb(0x11, 0xfe000332);
178 powerpmc250_halt(void)
185 powerpmc250_power_off(void)
191 powerpmc250_init_IRQ(void)
194 OpenPIC_InitSenses
= powerpmc250_openpic_initsenses
;
195 OpenPIC_NumInitSenses
= sizeof(powerpmc250_openpic_initsenses
);
196 mpc10x_set_openpic();
200 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
202 static __inline__
void
203 powerpmc250_set_bat(void)
205 unsigned long bat3u
, bat3l
;
206 static int mapping_set
= 0;
210 __asm__
__volatile__(
218 : "=r" (bat3u
), "=r" (bat3l
));
225 static unsigned long __init
226 powerpmc250_find_end_of_memory(void)
228 /* Cover I/O space with a BAT */
229 /* yuck, better hope your ram size is a power of 2 -- paulus */
230 powerpmc250_set_bat();
232 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B
);
236 powerpmc250_map_io(void)
238 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO
);
242 platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
243 unsigned long r6
, unsigned long r7
)
245 parse_bootinfo(find_bootinfo());
247 #ifdef CONFIG_BLK_DEV_INITRD
250 initrd_start
= r4
+ KERNELBASE
;
251 initrd_end
= r5
+ KERNELBASE
;
255 /* Copy cmd_line parameters */
258 *(char *)(r7
+ KERNELBASE
) = 0;
259 strcpy(cmd_line
, (char *)(r6
+ KERNELBASE
));
262 isa_io_base
= MPC10X_MAPB_ISA_IO_BASE
;
263 isa_mem_base
= MPC10X_MAPB_ISA_MEM_BASE
;
264 pci_dram_offset
= MPC10X_MAPB_DRAM_OFFSET
;
266 ppc_md
.setup_arch
= powerpmc250_setup_arch
;
267 ppc_md
.show_cpuinfo
= powerpmc250_show_cpuinfo
;
268 ppc_md
.init_IRQ
= powerpmc250_init_IRQ
;
269 ppc_md
.get_irq
= openpic_get_irq
;
271 ppc_md
.find_end_of_memory
= powerpmc250_find_end_of_memory
;
272 ppc_md
.setup_io_mappings
= powerpmc250_map_io
;
274 ppc_md
.restart
= powerpmc250_restart
;
275 ppc_md
.power_off
= powerpmc250_power_off
;
276 ppc_md
.halt
= powerpmc250_halt
;
278 /* PowerPMC250 has no timekeeper part */
279 ppc_md
.time_init
= NULL
;
280 ppc_md
.get_rtc_time
= NULL
;
281 ppc_md
.set_rtc_time
= NULL
;
282 ppc_md
.calibrate_decr
= powerpmc250_calibrate_decr
;
287 * (This used to be arch/ppc/platforms/powerpmc250_pci.c)
289 * PCI support for Force PowerPMC250
295 #define DBG(x...) printk(x)
300 static inline int __init
301 powerpmc250_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
303 static char pci_irq_table
[][4] =
305 * PCI IDSEL/INTPIN->INTLINE
309 {17, 0, 0, 0}, /* Device 11 - 82559 */
310 {0, 0, 0, 0}, /* 12 */
311 {0, 0, 0, 0}, /* 13 */
312 {0, 0, 0, 0}, /* 14 */
313 {0, 0, 0, 0}, /* 15 */
314 {16, 17, 18, 19}, /* Device 16 - PMC A1?? */
316 const long min_idsel
= 11, max_idsel
= 16, irqs_per_slot
= 4;
317 return PCI_IRQ_TABLE_LOOKUP
;
321 powerpmc250_exclude_device(u_char bus
, u_char devfn
)
324 * While doing PCI Scan the MPC107 will 'detect' itself as
325 * device on the PCI Bus, will create an incorrect response and
326 * later will respond incorrectly to Configuration read coming
327 * from another device.
329 * The work around is that when doing a PCI Scan one
330 * should skip its own device number in the scan.
332 * The top IDsel is AD13 and the middle is AD14.
337 if ((bus
== 0) && (PCI_SLOT(devfn
) == 13 || PCI_SLOT(devfn
) == 14)) {
338 return PCIBIOS_DEVICE_NOT_FOUND
;
341 return PCIBIOS_SUCCESSFUL
;
346 powerpmc250_find_bridges(void)
348 struct pci_controller
* hose
;
350 hose
= pcibios_alloc_controller();
352 printk("Can't allocate PCI 'hose' structure!!!\n");
356 hose
->first_busno
= 0;
357 hose
->last_busno
= 0xff;
359 if (mpc10x_bridge_init(hose
,
362 MPC10X_MAPB_EUMB_BASE
) == 0) {
364 hose
->mem_resources
[0].end
= 0xffffffff;
366 hose
->last_busno
= pciauto_bus_scan(hose
, hose
->first_busno
);
368 /* ppc_md.pcibios_fixup = pcore_pcibios_fixup; */
369 ppc_md
.pci_swizzle
= common_swizzle
;
371 ppc_md
.pci_exclude_device
= powerpmc250_exclude_device
;
372 ppc_md
.pci_map_irq
= powerpmc250_map_irq
;
375 ppc_md
.progress("Bridge init failed", 0x100);
376 printk("Host bridge init failed\n");