2 * arch/ppc/platforms/prpmc750_setup.c
4 * Board setup routines for Motorola PrPMC750
6 * Author: 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.1. 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/blk.h>
25 #include <linux/console.h>
26 #include <linux/delay.h>
27 #include <linux/irq.h>
28 #include <linux/seq_file.h>
29 #include <linux/ide.h>
30 #include <linux/root_dev.h>
32 #include <asm/system.h>
33 #include <asm/pgtable.h>
37 #include <asm/machdep.h>
39 #include <platforms/prpmc750.h>
40 #include <asm/open_pic.h>
41 #include <asm/bootinfo.h>
42 #include <asm/pplus.h>
44 extern void prpmc750_find_bridges(void);
45 extern int mpic_init(void);
46 extern unsigned long loops_per_jiffy
;
48 static u_char prpmc750_openpic_initsenses
[] __initdata
=
50 1, /* PRPMC750_INT_HOSTINT0 */
51 1, /* PRPMC750_INT_UART */
52 1, /* PRPMC750_INT_DEBUGINT */
53 1, /* PRPMC750_INT_HAWK_WDT */
54 1, /* PRPMC750_INT_UNUSED */
55 1, /* PRPMC750_INT_ABORT */
56 1, /* PRPMC750_INT_HOSTINT1 */
57 1, /* PRPMC750_INT_HOSTINT2 */
58 1, /* PRPMC750_INT_HOSTINT3 */
59 1, /* PRPMC750_INT_PMC_INTA */
60 1, /* PRPMC750_INT_PMC_INTB */
61 1, /* PRPMC750_INT_PMC_INTC */
62 1, /* PRPMC750_INT_PMC_INTD */
63 1, /* PRPMC750_INT_UNUSED */
64 1, /* PRPMC750_INT_UNUSED */
65 1, /* PRPMC750_INT_UNUSED */
69 prpmc750_show_cpuinfo(struct seq_file
*m
)
71 seq_printf(m
, "machine\t\t: PrPMC750\n");
77 prpmc750_setup_arch(void)
79 /* init to some ~sane value until calibrate_delay() runs */
80 loops_per_jiffy
= 50000000/HZ
;
82 /* Lookup PCI host bridges */
83 prpmc750_find_bridges();
85 #ifdef CONFIG_BLK_DEV_INITRD
90 #ifdef CONFIG_ROOT_NFS
96 #ifdef CONFIG_DUMMY_CONSOLE
97 conswitchp
= &dummy_con
;
100 /* Find and map our OpenPIC */
101 pplus_mpic_init(PRPMC750_PCI_MEM_OFFSET
);
102 OpenPIC_InitSenses
= prpmc750_openpic_initsenses
;
103 OpenPIC_NumInitSenses
= sizeof(prpmc750_openpic_initsenses
);
105 printk("PrPMC750 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
109 * Compute the PrPMC750's bus speed using the baud clock as a
112 static unsigned long __init
113 prpmc750_get_bus_speed(void)
115 unsigned long tbl_start
, tbl_end
;
116 unsigned long current_state
, old_state
, bus_speed
;
117 unsigned char lcr
, dll
, dlm
;
118 int baud_divisor
, count
;
120 /* Read the UART's baud clock divisor */
121 lcr
= readb(PRPMC750_SERIAL_0_LCR
);
122 writeb(lcr
| UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
123 dll
= readb(PRPMC750_SERIAL_0_DLL
);
124 dlm
= readb(PRPMC750_SERIAL_0_DLM
);
125 writeb(lcr
& ~UART_LCR_DLAB
, PRPMC750_SERIAL_0_LCR
);
126 baud_divisor
= (dlm
<< 8) | dll
;
129 * Use the baud clock divisor and base baud clock
130 * to determine the baud rate and use that as
131 * the number of baud clock edges we use for
132 * the time base sample. Make it half the baud
135 count
= PRPMC750_BASE_BAUD
/ (baud_divisor
* 16);
137 /* Find the first edge of the baud clock */
138 old_state
= readb(PRPMC750_STATUS_REG
) & PRPMC750_BAUDOUT_MASK
;
140 current_state
= readb(PRPMC750_STATUS_REG
) &
141 PRPMC750_BAUDOUT_MASK
;
142 } while(old_state
== current_state
);
144 old_state
= current_state
;
146 /* Get the starting time base value */
147 tbl_start
= get_tbl();
150 * Loop until we have found a number of edges equal
151 * to half the count (half the baud rate)
155 current_state
= readb(PRPMC750_STATUS_REG
) &
156 PRPMC750_BAUDOUT_MASK
;
157 } while(old_state
== current_state
);
158 old_state
= current_state
;
161 /* Get the ending time base value */
164 /* Compute bus speed */
165 bus_speed
= (tbl_end
-tbl_start
)*128;
171 prpmc750_calibrate_decr(void)
176 freq
= prpmc750_get_bus_speed();
178 tb_ticks_per_jiffy
= freq
/ (HZ
* divisor
);
179 tb_to_us
= mulhwu_scale_factor(freq
/divisor
, 1000000);
183 prpmc750_restart(char *cmd
)
186 writeb(PRPMC750_MODRST_MASK
, PRPMC750_MODRST_REG
);
198 prpmc750_power_off(void)
204 prpmc750_init_IRQ(void)
206 openpic_init(1, 0, 0, -1);
210 * Set BAT 3 to map 0xf0000000 to end of physical memory space.
212 static __inline__
void
213 prpmc750_set_bat(void)
215 unsigned long bat3u
, bat3l
;
216 static int mapping_set
= 0;
220 __asm__
__volatile__(
228 : "=r" (bat3u
), "=r" (bat3l
));
236 * We need to read the Falcon/Hawk memory controller
237 * to properly determine this value
239 static unsigned long __init
240 prpmc750_find_end_of_memory(void)
242 /* Cover the Hawk registers with a BAT */
245 /* Read the memory size from the Hawk SMC */
246 return pplus_get_mem_size(PRPMC750_HAWK_SMC_BASE
);
250 prpmc750_map_io(void)
252 io_block_mapping(0x80000000, 0x80000000, 0x10000000, _PAGE_IO
);
253 io_block_mapping(0xf0000000, 0xc0000000, 0x08000000, _PAGE_IO
);
254 io_block_mapping(0xf8000000, 0xf8000000, 0x08000000, _PAGE_IO
);
258 platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
259 unsigned long r6
, unsigned long r7
)
261 parse_bootinfo(find_bootinfo());
263 isa_io_base
= PRPMC750_ISA_IO_BASE
;
264 isa_mem_base
= PRPMC750_ISA_MEM_BASE
;
265 pci_dram_offset
= PRPMC750_SYS_MEM_BASE
;
267 ppc_md
.setup_arch
= prpmc750_setup_arch
;
268 ppc_md
.show_cpuinfo
= prpmc750_show_cpuinfo
;
269 ppc_md
.init_IRQ
= prpmc750_init_IRQ
;
270 ppc_md
.get_irq
= openpic_get_irq
;
272 ppc_md
.find_end_of_memory
= prpmc750_find_end_of_memory
;
273 ppc_md
.setup_io_mappings
= prpmc750_map_io
;
275 ppc_md
.restart
= prpmc750_restart
;
276 ppc_md
.power_off
= prpmc750_power_off
;
277 ppc_md
.halt
= prpmc750_halt
;
279 /* PrPMC750 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
= prpmc750_calibrate_decr
;