Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/ppc/syslib/m8260_setup.c |
| 3 | * |
| 4 | * Copyright (C) 1995 Linus Torvalds |
| 5 | * Adapted from 'alpha' version by Gary Thomas |
| 6 | * Modified by Cort Dougan (cort@cs.nmt.edu) |
| 7 | * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net) |
| 8 | * Further modified for generic 8xx and 8260 by Dan. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/config.h> |
| 12 | #include <linux/sched.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/mm.h> |
| 15 | #include <linux/stddef.h> |
| 16 | #include <linux/slab.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/initrd.h> |
| 19 | #include <linux/root_dev.h> |
| 20 | #include <linux/seq_file.h> |
| 21 | #include <linux/irq.h> |
| 22 | |
| 23 | #include <asm/mmu.h> |
| 24 | #include <asm/io.h> |
| 25 | #include <asm/pgtable.h> |
| 26 | #include <asm/mpc8260.h> |
| 27 | #include <asm/immap_cpm2.h> |
| 28 | #include <asm/machdep.h> |
| 29 | #include <asm/bootinfo.h> |
| 30 | #include <asm/time.h> |
| 31 | |
| 32 | #include "cpm2_pic.h" |
| 33 | |
| 34 | unsigned char __res[sizeof(bd_t)]; |
| 35 | |
| 36 | extern void cpm2_reset(void); |
Vitaly Bordug | a6dbba7 | 2005-05-28 15:52:09 -0700 | [diff] [blame^] | 37 | extern void pq2_find_bridges(void); |
| 38 | extern void pq2pci_init_irq(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | extern void idma_pci9_init(void); |
| 40 | |
| 41 | /* Place-holder for board-specific init */ |
| 42 | void __attribute__ ((weak)) __init |
| 43 | m82xx_board_setup(void) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | static void __init |
| 48 | m8260_setup_arch(void) |
| 49 | { |
| 50 | /* Print out Vendor and Machine info. */ |
| 51 | printk(KERN_INFO "%s %s port\n", CPUINFO_VENDOR, CPUINFO_MACHINE); |
| 52 | |
| 53 | /* Reset the Communication Processor Module. */ |
| 54 | cpm2_reset(); |
| 55 | #ifdef CONFIG_8260_PCI9 |
| 56 | /* Initialise IDMA for PCI erratum workaround */ |
| 57 | idma_pci9_init(); |
| 58 | #endif |
| 59 | #ifdef CONFIG_PCI_8260 |
Vitaly Bordug | a6dbba7 | 2005-05-28 15:52:09 -0700 | [diff] [blame^] | 60 | pq2_find_bridges(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #endif |
| 62 | #ifdef CONFIG_BLK_DEV_INITRD |
| 63 | if (initrd_start) |
| 64 | ROOT_DEV = Root_RAM0; |
| 65 | #endif |
| 66 | m82xx_board_setup(); |
| 67 | } |
| 68 | |
| 69 | /* The decrementer counts at the system (internal) clock frequency |
| 70 | * divided by four. |
| 71 | */ |
| 72 | static void __init |
| 73 | m8260_calibrate_decr(void) |
| 74 | { |
| 75 | bd_t *binfo = (bd_t *)__res; |
| 76 | int freq, divisor; |
| 77 | |
| 78 | freq = binfo->bi_busfreq; |
| 79 | divisor = 4; |
| 80 | tb_ticks_per_jiffy = freq / HZ / divisor; |
| 81 | tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000); |
| 82 | } |
| 83 | |
| 84 | /* The 8260 has an internal 1-second timer update register that |
| 85 | * we should use for this purpose. |
| 86 | */ |
| 87 | static uint rtc_time; |
| 88 | |
| 89 | static int |
| 90 | m8260_set_rtc_time(unsigned long time) |
| 91 | { |
| 92 | rtc_time = time; |
| 93 | |
| 94 | return(0); |
| 95 | } |
| 96 | |
| 97 | static unsigned long |
| 98 | m8260_get_rtc_time(void) |
| 99 | { |
| 100 | /* Get time from the RTC. |
| 101 | */ |
| 102 | return((unsigned long)rtc_time); |
| 103 | } |
| 104 | |
| 105 | #ifndef BOOTROM_RESTART_ADDR |
| 106 | #warning "Using default BOOTROM_RESTART_ADDR!" |
| 107 | #define BOOTROM_RESTART_ADDR 0xff000104 |
| 108 | #endif |
| 109 | |
| 110 | static void |
| 111 | m8260_restart(char *cmd) |
| 112 | { |
| 113 | extern void m8260_gorom(bd_t *bi, uint addr); |
| 114 | uint startaddr; |
| 115 | |
| 116 | /* Most boot roms have a warmstart as the second instruction |
| 117 | * of the reset vector. If that doesn't work for you, change this |
| 118 | * or the reboot program to send a proper address. |
| 119 | */ |
| 120 | startaddr = BOOTROM_RESTART_ADDR; |
| 121 | if (cmd != NULL) { |
| 122 | if (!strncmp(cmd, "startaddr=", 10)) |
| 123 | startaddr = simple_strtoul(&cmd[10], NULL, 0); |
| 124 | } |
| 125 | |
| 126 | m8260_gorom((void*)__pa(__res), startaddr); |
| 127 | } |
| 128 | |
| 129 | static void |
| 130 | m8260_halt(void) |
| 131 | { |
| 132 | local_irq_disable(); |
| 133 | while (1); |
| 134 | } |
| 135 | |
| 136 | static void |
| 137 | m8260_power_off(void) |
| 138 | { |
| 139 | m8260_halt(); |
| 140 | } |
| 141 | |
| 142 | static int |
| 143 | m8260_show_cpuinfo(struct seq_file *m) |
| 144 | { |
| 145 | bd_t *bp = (bd_t *)__res; |
| 146 | |
| 147 | seq_printf(m, "vendor\t\t: %s\n" |
| 148 | "machine\t\t: %s\n" |
| 149 | "\n" |
| 150 | "mem size\t\t: 0x%08x\n" |
| 151 | "console baud\t\t: %d\n" |
| 152 | "\n" |
| 153 | "core clock\t: %u MHz\n" |
| 154 | "CPM clock\t: %u MHz\n" |
| 155 | "bus clock\t: %u MHz\n", |
| 156 | CPUINFO_VENDOR, CPUINFO_MACHINE, bp->bi_memsize, |
| 157 | bp->bi_baudrate, bp->bi_intfreq / 1000000, |
| 158 | bp->bi_cpmfreq / 1000000, bp->bi_busfreq / 1000000); |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | /* Initialize the internal interrupt controller. The number of |
| 163 | * interrupts supported can vary with the processor type, and the |
| 164 | * 8260 family can have up to 64. |
| 165 | * External interrupts can be either edge or level triggered, and |
| 166 | * need to be initialized by the appropriate driver. |
| 167 | */ |
| 168 | static void __init |
| 169 | m8260_init_IRQ(void) |
| 170 | { |
| 171 | cpm2_init_IRQ(); |
| 172 | |
| 173 | /* Initialize the default interrupt mapping priorities, |
| 174 | * in case the boot rom changed something on us. |
| 175 | */ |
| 176 | cpm2_immr->im_intctl.ic_siprr = 0x05309770; |
Vitaly Bordug | a6dbba7 | 2005-05-28 15:52:09 -0700 | [diff] [blame^] | 177 | |
| 178 | #if defined(CONFIG_PCI) && (defined(CONFIG_ADS8272) || defined(CONFIG_PQ2FADS)) |
| 179 | /* Initialize stuff for the 82xx CPLD IC and install demux */ |
| 180 | pq2pci_init_irq(); |
| 181 | #endif |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Same hack as 8xx |
| 187 | */ |
| 188 | static unsigned long __init |
| 189 | m8260_find_end_of_memory(void) |
| 190 | { |
| 191 | bd_t *binfo = (bd_t *)__res; |
| 192 | |
| 193 | return binfo->bi_memsize; |
| 194 | } |
| 195 | |
| 196 | /* Map the IMMR, plus anything else we can cover |
| 197 | * in that upper space according to the memory controller |
| 198 | * chip select mapping. Grab another bunch of space |
| 199 | * below that for stuff we can't cover in the upper. |
| 200 | */ |
| 201 | static void __init |
| 202 | m8260_map_io(void) |
| 203 | { |
| 204 | uint addr; |
| 205 | |
| 206 | /* Map IMMR region to a 256MB BAT */ |
| 207 | addr = (cpm2_immr != NULL) ? (uint)cpm2_immr : CPM_MAP_ADDR; |
| 208 | io_block_mapping(addr, addr, 0x10000000, _PAGE_IO); |
| 209 | |
| 210 | /* Map I/O region to a 256MB BAT */ |
| 211 | io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO); |
| 212 | } |
| 213 | |
| 214 | /* Place-holder for board-specific ppc_md hooking */ |
| 215 | void __attribute__ ((weak)) __init |
| 216 | m82xx_board_init(void) |
| 217 | { |
| 218 | } |
| 219 | |
| 220 | /* Inputs: |
| 221 | * r3 - Optional pointer to a board information structure. |
| 222 | * r4 - Optional pointer to the physical starting address of the init RAM |
| 223 | * disk. |
| 224 | * r5 - Optional pointer to the physical ending address of the init RAM |
| 225 | * disk. |
| 226 | * r6 - Optional pointer to the physical starting address of any kernel |
| 227 | * command-line parameters. |
| 228 | * r7 - Optional pointer to the physical ending address of any kernel |
| 229 | * command-line parameters. |
| 230 | */ |
| 231 | void __init |
| 232 | platform_init(unsigned long r3, unsigned long r4, unsigned long r5, |
| 233 | unsigned long r6, unsigned long r7) |
| 234 | { |
| 235 | parse_bootinfo(find_bootinfo()); |
| 236 | |
| 237 | if ( r3 ) |
| 238 | memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) ); |
| 239 | |
| 240 | #ifdef CONFIG_BLK_DEV_INITRD |
| 241 | /* take care of initrd if we have one */ |
| 242 | if ( r4 ) { |
| 243 | initrd_start = r4 + KERNELBASE; |
| 244 | initrd_end = r5 + KERNELBASE; |
| 245 | } |
| 246 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 247 | /* take care of cmd line */ |
| 248 | if ( r6 ) { |
| 249 | *(char *)(r7+KERNELBASE) = 0; |
| 250 | strcpy(cmd_line, (char *)(r6+KERNELBASE)); |
| 251 | } |
| 252 | |
| 253 | ppc_md.setup_arch = m8260_setup_arch; |
| 254 | ppc_md.show_cpuinfo = m8260_show_cpuinfo; |
| 255 | ppc_md.init_IRQ = m8260_init_IRQ; |
| 256 | ppc_md.get_irq = cpm2_get_irq; |
| 257 | |
| 258 | ppc_md.restart = m8260_restart; |
| 259 | ppc_md.power_off = m8260_power_off; |
| 260 | ppc_md.halt = m8260_halt; |
| 261 | |
| 262 | ppc_md.set_rtc_time = m8260_set_rtc_time; |
| 263 | ppc_md.get_rtc_time = m8260_get_rtc_time; |
| 264 | ppc_md.calibrate_decr = m8260_calibrate_decr; |
| 265 | |
| 266 | ppc_md.find_end_of_memory = m8260_find_end_of_memory; |
| 267 | ppc_md.setup_io_mappings = m8260_map_io; |
| 268 | |
| 269 | /* Call back for board-specific settings and overrides. */ |
| 270 | m82xx_board_init(); |
| 271 | } |