0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/init.h>
0012 #include <linux/export.h>
0013 #include <linux/kernel.h>
0014 #include <linux/memblock.h>
0015 #include <linux/spinlock.h>
0016
0017 #include <asm/io.h>
0018 #include <asm/bootinfo.h>
0019 #include <asm/sgialib.h>
0020 #include <asm/sgi/mc.h>
0021 #include <asm/sgi/hpc3.h>
0022 #include <asm/sgi/ip22.h>
0023
0024 struct sgimc_regs *sgimc;
0025
0026 EXPORT_SYMBOL(sgimc);
0027
0028 static inline unsigned long get_bank_addr(unsigned int memconfig)
0029 {
0030 return (memconfig & SGIMC_MCONFIG_BASEADDR) << ((sgimc->systemid & SGIMC_SYSID_MASKREV) >= 5 ? 24 : 22);
0031 }
0032
0033 static inline unsigned long get_bank_size(unsigned int memconfig)
0034 {
0035 return ((memconfig & SGIMC_MCONFIG_RMASK) + 0x0100) << ((sgimc->systemid & SGIMC_SYSID_MASKREV) >= 5 ? 16 : 14);
0036 }
0037
0038 static inline unsigned int get_bank_config(int bank)
0039 {
0040 unsigned int res = bank > 1 ? sgimc->mconfig1 : sgimc->mconfig0;
0041 return bank % 2 ? res & 0xffff : res >> 16;
0042 }
0043
0044 #if defined(CONFIG_SGI_IP28) || defined(CONFIG_32BIT)
0045 static void __init probe_memory(void)
0046 {
0047
0048 }
0049 #else
0050
0051
0052
0053 static void __init probe_memory(void)
0054 {
0055 unsigned long addr, size;
0056 int i;
0057
0058 printk(KERN_INFO "MC: Probing memory configuration:\n");
0059 for (i = 0; i < 4; i++) {
0060 unsigned int tmp = get_bank_config(i);
0061 if (!(tmp & SGIMC_MCONFIG_BVALID))
0062 continue;
0063
0064 size = get_bank_size(tmp);
0065 addr = get_bank_addr(tmp);
0066 printk(KERN_INFO " bank%d: %3ldM @ %08lx\n",
0067 i, size / 1024 / 1024, addr);
0068
0069 if (addr >= SGIMC_SEG1_BADDR)
0070 memblock_add(addr, size);
0071 }
0072 }
0073 #endif
0074
0075 void __init sgimc_init(void)
0076 {
0077 u32 tmp;
0078
0079
0080 sgimc = (struct sgimc_regs *)
0081 ioremap(SGIMC_BASE, sizeof(struct sgimc_regs));
0082
0083 printk(KERN_INFO "MC: SGI memory controller Revision %d\n",
0084 (int) sgimc->systemid & SGIMC_SYSID_MASKREV);
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 tmp = sgimc->cpuctrl0;
0095 tmp &= ~SGIMC_CCTRL0_WDOG;
0096 sgimc->cpuctrl0 = tmp;
0097
0098
0099
0100
0101
0102
0103 sgimc->cstat = sgimc->gstat = 0;
0104
0105
0106
0107
0108
0109 tmp = sgimc->cpuctrl0;
0110 #ifndef CONFIG_SGI_IP28
0111 tmp |= SGIMC_CCTRL0_EPERRGIO | SGIMC_CCTRL0_EPERRMEM;
0112 #endif
0113 tmp |= SGIMC_CCTRL0_R4KNOCHKPARR;
0114 sgimc->cpuctrl0 = tmp;
0115
0116
0117
0118
0119 tmp = sgimc->cpuctrl1;
0120 tmp &= ~0xf;
0121 tmp |= 0xd;
0122 sgimc->cpuctrl1 = tmp;
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 sgimc->divider = 0x101;
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 tmp = sgimc->giopar & SGIMC_GIOPAR_GFX64;
0149 tmp |= SGIMC_GIOPAR_HPC64;
0150 tmp |= SGIMC_GIOPAR_ONEBUS;
0151
0152 if (ip22_is_fullhouse()) {
0153
0154 if (SGIOC_SYSID_BOARDREV(sgioc->sysid) < 2) {
0155 tmp |= SGIMC_GIOPAR_HPC264;
0156 tmp |= SGIMC_GIOPAR_PLINEEXP0;
0157 tmp |= SGIMC_GIOPAR_MASTEREXP1;
0158 tmp |= SGIMC_GIOPAR_RTIMEEXP0;
0159 } else {
0160 tmp |= SGIMC_GIOPAR_HPC264;
0161 tmp |= SGIMC_GIOPAR_PLINEEXP0;
0162 tmp |= SGIMC_GIOPAR_PLINEEXP1;
0163 tmp |= SGIMC_GIOPAR_MASTEREISA;
0164 }
0165 } else {
0166
0167 tmp |= SGIMC_GIOPAR_EISA64;
0168 tmp |= SGIMC_GIOPAR_MASTEREISA;
0169 }
0170 sgimc->giopar = tmp;
0171
0172 probe_memory();
0173 }
0174
0175 #ifdef CONFIG_SGI_IP28
0176 void __init prom_cleanup(void)
0177 {
0178 u32 mconfig1;
0179 unsigned long flags;
0180 spinlock_t lock;
0181
0182
0183
0184
0185
0186
0187 spin_lock_irqsave(&lock, flags);
0188 mconfig1 = sgimc->mconfig1;
0189
0190 sgimc->mconfig1 = (mconfig1 & 0xffff0000) | 0x2060;
0191 iob();
0192
0193 *(unsigned long *)PHYS_TO_XKSEG_UNCACHED(0x60000000) = 0;
0194 iob();
0195
0196 sgimc->cmacc = (sgimc->cmacc & ~0xf) | 4;
0197 iob();
0198
0199 sgimc->mconfig1 = mconfig1;
0200 iob();
0201 spin_unlock_irqrestore(&lock, flags);
0202 }
0203 #endif