2 * arch/ppc/boot/simple/misc-prep.c
4 * Maintainer: Tom Rini <trini@kernel.crashing.org>
6 * In the past: Gary Thomas, Cort Dougan <cort@cs.nmt.edu>
9 #include <linux/config.h>
10 #include <linux/pci_ids.h>
11 #include <linux/types.h>
12 #include <asm/residual.h>
13 #include <asm/string.h>
14 #include <asm/byteorder.h>
19 extern int keyb_present; /* keyboard controller is present by default */
20 RESIDUAL hold_resid_buf;
21 RESIDUAL *hold_residual = &hold_resid_buf;
22 static void *OFW_interface; /* Pointer to OF, if available. */
24 #ifdef CONFIG_VGA_CONSOLE
25 char *vidmem = (char *)0xC00B8000;
26 int lines = 25, cols = 80;
27 int orig_x, orig_y = 24;
28 #endif /* CONFIG_VGA_CONSOLE */
30 extern int CRT_tstc(void);
31 extern int vga_init(unsigned char *ISA_mem);
32 extern void gunzip(void *, int, unsigned char *, int *);
33 extern unsigned long serial_init(int chan, void *ignored);
34 extern void serial_fixups(void);
35 extern struct bi_record *decompress_kernel(unsigned long load_addr,
36 int num_words, unsigned long cksum);
37 extern void disable_6xx_mmu(void);
38 extern unsigned long mpc10x_get_mem_size(void);
41 writel(unsigned int val, unsigned int address)
43 /* Ensure I/O operations complete */
44 __asm__ volatile("eieio");
45 *(unsigned int *)address = cpu_to_le32(val);
48 #define PCI_CFG_ADDR(dev,off) ((0x80<<24) | (dev<<8) | (off&0xfc))
49 #define PCI_CFG_DATA(off) (MPC10X_MAPA_CNFG_DATA+(off&3))
52 pci_read_config_32(unsigned char devfn,
56 /* Ensure I/O operations complete */
57 __asm__ volatile("eieio");
58 *(unsigned int *)PCI_CFG_ADDR(devfn,offset) =
59 cpu_to_le32(MPC10X_MAPA_CNFG_ADDR);
60 /* Ensure I/O operations complete */
61 __asm__ volatile("eieio");
62 *val = le32_to_cpu(*(unsigned int *)PCI_CFG_DATA(offset));
66 #ifdef CONFIG_VGA_CONSOLE
72 memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
73 for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
76 #endif /* CONFIG_VGA_CONSOLE */
79 load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
80 RESIDUAL *residual, void *OFW)
83 unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base;
85 /* If we have Open Firmware, initialise it immediately */
88 ofinit(OFW_interface);
91 #if defined(CONFIG_VGA_CONSOLE)
92 vga_init((unsigned char *)0xC0000000);
93 #endif /* CONFIG_VGA_CONSOLE */
96 /* Is this Motorola PPCBug? */
97 if ((1 & residual->VitalProductData.FirmwareSupports) &&
98 (1 == residual->VitalProductData.FirmwareSupplier)) {
99 unsigned char base_mod;
100 unsigned char board_type = inb(0x801) & 0xF0;
103 * Reset the onboard 21x4x Ethernet
104 * Motorola Ethernet is at IDSEL 14 (devfn 0x70)
106 pci_read_config_32(0x70, 0x00, &pci_viddid);
107 pci_did = (pci_viddid & 0xffff0000) >> 16;
108 /* Be sure we've really found a 21x4x chip */
109 if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_DEC) &&
110 ((pci_did == PCI_DEVICE_ID_DEC_TULIP_FAST) ||
111 (pci_did == PCI_DEVICE_ID_DEC_TULIP) ||
112 (pci_did == PCI_DEVICE_ID_DEC_TULIP_PLUS) ||
113 (pci_did == PCI_DEVICE_ID_DEC_21142))) {
114 pci_read_config_32(0x70,
117 /* Get the physical base address */
119 (tulip_pci_base & ~0x03UL) + 0x80000000;
120 /* Strobe the 21x4x reset bit in CSR0 */
121 writel(0x1, tulip_base);
124 /* If this is genesis 2 board then check for no
125 * keyboard controller and more than one processor.
127 if (board_type == 0xe0) {
128 base_mod = inb(0x803);
129 /* if a MVME2300/2400 or a Sitka then no keyboard */
130 if((base_mod == 0xFA) || (base_mod == 0xF9) ||
131 (base_mod == 0xE1)) {
132 keyb_present = 0; /* no keyboard */
135 /* If this is a multiprocessor system then
136 * park the other processor so that the
137 * kernel knows where to find them.
139 if (residual->MaxNumCpus > 1)
142 memcpy(hold_residual,residual,sizeof(RESIDUAL));
145 /* Call decompress_kernel */
146 decompress_kernel(load_addr, num_words, cksum);
149 residual->VitalProductData.SmpIar = (unsigned long)0xc0;
150 residual->Cpus[1].CpuState = CPU_GOOD;
151 hold_residual->VitalProductData.Reserved5 = 0xdeadbeef;
154 /* Now go and clear out the BATs and ensure that our MSR is
158 /* Make r3 be a pointer to the residual data. */
159 return (unsigned long)hold_residual;
165 unsigned int pci_viddid, pci_did;
167 /* First, figure out what kind of host bridge we are on. If it's
168 * an MPC10x, we can ask it directly how much memory it has.
169 * Otherwise, see if the residual data has anything. This isn't
170 * the best way, but it can be the only way. If there's nothing,
171 * assume 32MB. -- Tom.
173 /* See what our host bridge is. */
174 pci_read_config_32(0x00, 0x00, &pci_viddid);
175 pci_did = (pci_viddid & 0xffff0000) >> 16;
176 /* See if we are on an MPC10x. */
177 if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_MOTOROLA)
178 && ((pci_did == PCI_DEVICE_ID_MOTOROLA_MPC105)
179 || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC106)
180 || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC107)))
181 return mpc10x_get_mem_size();
182 /* If it's not, see if we have anything in the residual data. */
183 else if (hold_residual && hold_residual->TotalMemory)
184 return hold_residual->TotalMemory;
185 else if (OFW_interface) {
187 * This is a 'best guess' check. We want to make sure
188 * we don't try this on a PReP box without OF
191 while (OFW_interface)
196 /* get handle to memory description */
197 if (!(dev_handle = finddevice("/memory@0")))
201 if (getprop(dev_handle, "reg", mem_info,
202 sizeof(mem_info)) != 8)
209 /* Fall back to hard-coding 32MB. */