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);
92 #if defined(CONFIG_VGA_CONSOLE)
93 vga_init((unsigned char *)0xC0000000);
94 #endif /* CONFIG_VGA_CONSOLE */
97 /* Is this Motorola PPCBug? */
98 if ((1 & residual->VitalProductData.FirmwareSupports) &&
99 (1 == residual->VitalProductData.FirmwareSupplier)) {
100 unsigned char base_mod;
101 unsigned char board_type = inb(0x801) & 0xF0;
104 * Reset the onboard 21x4x Ethernet
105 * Motorola Ethernet is at IDSEL 14 (devfn 0x70)
107 pci_read_config_32(0x70, 0x00, &pci_viddid);
108 pci_did = (pci_viddid & 0xffff0000) >> 16;
109 /* Be sure we've really found a 21x4x chip */
110 if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_DEC) &&
111 ((pci_did == PCI_DEVICE_ID_DEC_TULIP_FAST) ||
112 (pci_did == PCI_DEVICE_ID_DEC_TULIP) ||
113 (pci_did == PCI_DEVICE_ID_DEC_TULIP_PLUS) ||
114 (pci_did == PCI_DEVICE_ID_DEC_21142))) {
115 pci_read_config_32(0x70,
118 /* Get the physical base address */
120 (tulip_pci_base & ~0x03UL) + 0x80000000;
121 /* Strobe the 21x4x reset bit in CSR0 */
122 writel(0x1, tulip_base);
125 /* If this is genesis 2 board then check for no
126 * keyboard controller and more than one processor.
128 if (board_type == 0xe0) {
129 base_mod = inb(0x803);
130 /* if a MVME2300/2400 or a Sitka then no keyboard */
131 if((base_mod == 0xFA) || (base_mod == 0xF9) ||
132 (base_mod == 0xE1)) {
133 keyb_present = 0; /* no keyboard */
136 /* If this is a multiprocessor system then
137 * park the other processor so that the
138 * kernel knows where to find them.
140 if (residual->MaxNumCpus > 1)
143 memcpy(hold_residual,residual,sizeof(RESIDUAL));
146 /* Call decompress_kernel */
147 decompress_kernel(load_addr, num_words, cksum);
150 residual->VitalProductData.SmpIar = (unsigned long)0xc0;
151 residual->Cpus[1].CpuState = CPU_GOOD;
152 hold_residual->VitalProductData.Reserved5 = 0xdeadbeef;
155 /* Now go and clear out the BATs and ensure that our MSR is
159 /* Make r3 be a pointer to the residual data. */
160 return (unsigned long)hold_residual;
166 unsigned int pci_viddid, pci_did;
168 /* First, figure out what kind of host bridge we are on. If it's
169 * an MPC10x, we can ask it directly how much memory it has.
170 * Otherwise, see if the residual data has anything. This isn't
171 * the best way, but it can be the only way. If there's nothing,
172 * assume 32MB. -- Tom.
174 /* See what our host bridge is. */
175 pci_read_config_32(0x00, 0x00, &pci_viddid);
176 pci_did = (pci_viddid & 0xffff0000) >> 16;
177 /* See if we are on an MPC10x. */
178 if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_MOTOROLA)
179 && ((pci_did == PCI_DEVICE_ID_MOTOROLA_MPC105)
180 || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC106)
181 || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC107)))
182 return mpc10x_get_mem_size();
183 /* If it's not, see if we have anything in the residual data. */
184 else if (hold_residual && hold_residual->TotalMemory)
185 return hold_residual->TotalMemory;
186 else if (OFW_interface) {
188 * This is a 'best guess' check. We want to make sure
189 * we don't try this on a PReP box without OF
192 while (OFW_interface)
197 /* get handle to memory description */
198 if (!(dev_handle = finddevice("/memory@0")))
202 if (getprop(dev_handle, "reg", mem_info,
203 sizeof(mem_info)) != 8)
210 /* Fall back to hard-coding 32MB. */