2 * arch/ppc/syslib/ibm44x_common.c
4 * PPC44x system library
6 * Matt Porter <mporter@kernel.crashing.org>
7 * Copyright 2002-2004 MontaVista Software Inc.
9 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
10 * Copyright (c) 2003, 2004 Zultys Technologies
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/config.h>
19 #include <linux/time.h>
20 #include <linux/types.h>
21 #include <linux/serial.h>
23 #include <asm/ibm44x.h>
25 #include <asm/machdep.h>
27 #include <asm/ppc4xx_pic.h>
28 #include <asm/param.h>
30 #include <syslib/gen550.h>
32 phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
34 phys_addr_t page_4gb = 0;
37 * Trap the least significant 32-bit portions of an
38 * address in the 440's 36-bit address space. Fix
39 * them up with the appropriate ERPN
41 if ((addr >= PPC44x_IO_LO) && (addr < PPC44x_IO_HI))
42 page_4gb = PPC44x_IO_PAGE;
43 else if ((addr >= PPC44x_PCICFG_LO) && (addr < PPC44x_PCICFG_HI))
44 page_4gb = PPC44x_PCICFG_PAGE;
45 else if ((addr >= PPC44x_PCIMEM_LO) && (addr < PPC44x_PCIMEM_HI))
46 page_4gb = PPC44x_PCIMEM_PAGE;
48 return (page_4gb | addr);
51 void __init ibm44x_calibrate_decr(unsigned int freq)
53 tb_ticks_per_jiffy = freq / HZ;
54 tb_to_us = mulhwu_scale_factor(freq, 1000000);
56 /* Set the time base to zero */
60 /* Clear any pending timer interrupts */
61 mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
63 /* Enable decrementer interrupt */
64 mtspr(SPRN_TCR, TCR_DIE);
67 extern void abort(void);
69 static void ibm44x_restart(char *cmd)
75 static void ibm44x_power_off(void)
81 static void ibm44x_halt(void)
88 * Read the 44x memory controller to get size of system memory.
90 static unsigned long __init ibm44x_find_end_of_memory(void)
100 mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B0CR);
103 mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B1CR);
106 mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B2CR);
109 mtdcr(DCRN_SDRAM0_CFGADDR, SDRAM0_B3CR);
113 bank_config = mfdcr(DCRN_SDRAM0_CFGDATA);
115 if (!(bank_config & SDRAM_CONFIG_BANK_ENABLE))
117 switch (SDRAM_CONFIG_BANK_SIZE(bank_config))
119 case SDRAM_CONFIG_SIZE_8M:
120 mem_size += PPC44x_MEM_SIZE_8M;
122 case SDRAM_CONFIG_SIZE_16M:
123 mem_size += PPC44x_MEM_SIZE_16M;
125 case SDRAM_CONFIG_SIZE_32M:
126 mem_size += PPC44x_MEM_SIZE_32M;
128 case SDRAM_CONFIG_SIZE_64M:
129 mem_size += PPC44x_MEM_SIZE_64M;
131 case SDRAM_CONFIG_SIZE_128M:
132 mem_size += PPC44x_MEM_SIZE_128M;
134 case SDRAM_CONFIG_SIZE_256M:
135 mem_size += PPC44x_MEM_SIZE_256M;
137 case SDRAM_CONFIG_SIZE_512M:
138 mem_size += PPC44x_MEM_SIZE_512M;
145 static void __init ibm44x_init_irq(void)
151 for (i = 0; i < NR_IRQS; i++)
152 irq_desc[i].handler = ppc4xx_pic;
155 void __init ibm44x_platform_init(void)
157 ppc_md.init_IRQ = ibm44x_init_irq;
158 ppc_md.find_end_of_memory = ibm44x_find_end_of_memory;
159 ppc_md.restart = ibm44x_restart;
160 ppc_md.power_off = ibm44x_power_off;
161 ppc_md.halt = ibm44x_halt;
163 #ifdef CONFIG_SERIAL_TEXT_DEBUG
164 ppc_md.progress = gen550_progress;
165 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
167 ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
171 * The Abatron BDI JTAG debugger does not tolerate others
172 * mucking with the debug registers.
174 #if !defined(CONFIG_BDI_SWITCH)
175 /* Enable internal debug mode */
176 mtspr(SPRN_DBCR0, (DBCR0_IDM));
178 /* Clear any residual debug events */
179 mtspr(SPRN_DBSR, 0xffffffff);