blob: 71ff20fd494a6d3c38dc3aac631c3d9f06a07561 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Relocate bridge's register base and call board specific routine.
3 *
4 * Author: Mark A. Greer <source@mvista.com>
5 *
6 * 2005 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/config.h>
13#include <linux/types.h>
14#include <asm/io.h>
15#include <asm/mv64x60_defs.h>
16
17extern struct bi_record *decompress_kernel(unsigned long load_addr,
18 int num_words, unsigned long cksum);
19
Mark A. Greerd01c08c2005-09-03 15:55:56 -070020
21u32 size_reg[MV64x60_CPU2MEM_WINDOWS] = {
22 MV64x60_CPU2MEM_0_SIZE, MV64x60_CPU2MEM_1_SIZE,
23 MV64x60_CPU2MEM_2_SIZE, MV64x60_CPU2MEM_3_SIZE
24};
25
26/* Read mem ctlr to get the amount of mem in system */
27unsigned long
28mv64360_get_mem_size(void)
29{
30 u32 enables, i, v;
31 u32 mem = 0;
32
33 enables = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE +
34 MV64360_CPU_BAR_ENABLE) & 0xf;
35
36 for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++)
37 if (!(enables & (1<<i))) {
38 v = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE
39 + size_reg[i]) & 0xffff;
40 v = (v + 1) << 16;
41 mem += v;
42 }
43
44 return mem;
45}
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047void
48mv64x60_move_base(void __iomem *old_base, void __iomem *new_base)
49{
50 u32 bits, mask, b;
51
52 if (old_base != new_base) {
53#ifdef CONFIG_GT64260
54 bits = 12;
55 mask = 0x07000000;
56#else /* Must be mv64[34]60 */
57 bits = 16;
58 mask = 0x03000000;
59#endif
60 b = in_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE);
61 b &= mask;
62 b |= ((u32)new_base >> (32 - bits));
63 out_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE, b);
64
65 __asm__ __volatile__("sync");
66
67 /* Wait for change to happen (in accordance with the manual) */
68 while (in_le32(new_base + MV64x60_INTERNAL_SPACE_DECODE) != b);
69 }
70}
71
72void __attribute__ ((weak))
73mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
74{
75}
76
77void *
78load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
79 void *ign1, void *ign2)
80{
81 mv64x60_move_base((void __iomem *)CONFIG_MV64X60_BASE,
82 (void __iomem *)CONFIG_MV64X60_NEW_BASE);
83 mv64x60_board_init((void __iomem *)CONFIG_MV64X60_BASE,
84 (void __iomem *)CONFIG_MV64X60_NEW_BASE);
85 return decompress_kernel(load_addr, num_words, cksum);
86}