Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | /* * * Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu> * * Module name: walnut_setup.c * * Description: * Architecture- / platform-specific boot-time initialization code for * the IBM PowerPC 403GP "Walnut" evaluation board. Adapted from original * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek * <dan@net4x.com>. * */ #include <linux/config.h> #include <linux/init.h> #include <linux/smp.h> #include <linux/threads.h> #include <linux/interrupt.h> #include <linux/param.h> #include <linux/string.h> #include <linux/blk.h> #include <asm/processor.h> #include <asm/board.h> #include <asm/machdep.h> #include <asm/page.h> #include "local_irq.h" #include "ppc4xx_pic.h" #include "time.h" #include "walnut_setup.h" /* Function Prototypes */ extern void abort(void); /* Global Variables */ unsigned char __res[sizeof(bd_t)]; /* * void __init walnut_init() * * Description: * This routine... * * Input(s): * r3 - Optional pointer to a board information structure. * r4 - Optional pointer to the physical starting address of the init RAM * disk. * r5 - Optional pointer to the physical ending address of the init RAM * disk. * r6 - Optional pointer to the physical starting address of any kernel * command-line parameters. * r7 - Optional pointer to the physical ending address of any kernel * command-line parameters. * * Output(s): * N/A * * Returns: * N/A * */ void __init walnut_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { /* * If we were passed in a board information, copy it into the * residual data area. */ if (r3) { memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t)); } #if defined(CONFIG_BLK_DEV_INITRD) /* * If the init RAM disk has been configured in, and there's a valid * starting address for it, set it up. */ if (r4) { initrd_start = r4 + KERNELBASE; initrd_end = r5 + KERNELBASE; } #endif /* CONFIG_BLK_DEV_INITRD */ /* Copy the kernel command line arguments to a safe place. */ if (r6) { *(char *)(r7 + KERNELBASE) = 0; strcpy(cmd_line, (char *)(r6 + KERNELBASE)); } /* Initialize machine-dependency vectors */ ppc_md.setup_arch = walnut_setup_arch; ppc_md.setup_residual = walnut_setup_residual; ppc_md.get_cpuinfo = NULL; ppc_md.irq_cannonicalize = NULL; ppc_md.init_IRQ = walnut_init_IRQ; ppc_md.get_irq = walnut_get_irq; ppc_md.init = NULL; ppc_md.restart = walnut_restart; ppc_md.power_off = walnut_power_off; ppc_md.halt = walnut_halt; ppc_md.time_init = walnut_time_init; ppc_md.set_rtc_time = walnut_set_rtc_time; ppc_md.get_rtc_time = walnut_get_rtc_time; ppc_md.calibrate_decr = walnut_calibrate_decr; ppc_md.kbd_setkeycode = NULL; ppc_md.kbd_getkeycode = NULL; ppc_md.kbd_translate = NULL; ppc_md.kbd_unexpected_up = NULL; ppc_md.kbd_leds = NULL; ppc_md.kbd_init_hw = NULL; #if defined(CONFIG_MAGIC_SYSRQ) ppc_md.ppc_kbd_sysrq_xlate = NULL; #endif return; } /* * Document me. */ void __init walnut_setup_arch(void) { /* XXX - Implement me */ } /* * int walnut_setup_residual() * * Description: * This routine pretty-prints the platform's internal CPU and bus clock * frequencies into the buffer for usage in /proc/cpuinfo. * * Input(s): * *buffer - Buffer into which CPU and bus clock frequencies are to be * printed. * * Output(s): * *buffer - Buffer with the CPU and bus clock frequencies. * * Returns: * The number of bytes copied into 'buffer' if OK, otherwise zero or less * on error. */ int walnut_setup_residual(char *buffer) { int len = 0; bd_t *bp = (bd_t *)__res; len += sprintf(len + buffer, "clock\t\t: %dMHz\n" "bus clock\t\t: %dMHz\n", bp->bi_intfreq / 1000000, bp->bi_busfreq / 1000000); return (len); } /* * Document me. */ void __init walnut_init_IRQ(void) { int i; ppc4xx_pic_init(); for (i = 0; i < NR_IRQS; i++) { irq_desc[i].handler = ppc4xx_pic; } return; } /* * Document me. */ int walnut_get_irq(struct pt_regs *regs) { return (ppc4xx_pic_get_irq(regs)); } /* * Document me. */ void walnut_restart(char *cmd) { abort(); } /* * Document me. */ void walnut_power_off(void) { walnut_restart(NULL); } /* * Document me. */ void walnut_halt(void) { walnut_restart(NULL); } /* * Document me. */ void __init walnut_time_init(void) { /* XXX - Implement me */ } /* * Document me. */ int __init walnut_set_rtc_time(unsigned long time) { /* XXX - Implement me */ return (0); } /* * Document me. */ unsigned long __init walnut_get_rtc_time(void) { /* XXX - Implement me */ return (0); } /* * void __init walnut_calibrate_decr() * * Description: * This routine retrieves the internal processor frequency from the board * information structure, sets up the kernel timer decrementer based on * that value, enables the 403 programmable interval timer (PIT) and sets * it up for auto-reload. * * Input(s): * N/A * * Output(s): * N/A * * Returns: * N/A * */ void __init walnut_calibrate_decr(void) { unsigned int freq; bd_t *bip = (bd_t *)__res; freq = bip->bi_intfreq; decrementer_count = freq / HZ; count_period_num = 1; count_period_den = freq; /* Enable the PIT and set auto-reload of its value */ mtspr(SPRN_TCR, TCR_PIE | TCR_ARE); /* Clear any pending timer interrupts */ mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS); } |