x86: use generic per-device dma coherent allocator
[pandora-kernel.git] / arch / ppc / boot / simple / misc-mv64x60.c
1 /*
2  * 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/types.h>
13 #include <asm/io.h>
14 #include <asm/mv64x60_defs.h>
15
16 extern struct bi_record *decompress_kernel(unsigned long load_addr,
17         int num_words, unsigned long cksum);
18
19
20 u32 size_reg[MV64x60_CPU2MEM_WINDOWS] = {
21         MV64x60_CPU2MEM_0_SIZE, MV64x60_CPU2MEM_1_SIZE,
22         MV64x60_CPU2MEM_2_SIZE, MV64x60_CPU2MEM_3_SIZE
23 };
24
25 /* Read mem ctlr to get the amount of mem in system */
26 unsigned long
27 mv64360_get_mem_size(void)
28 {
29         u32     enables, i, v;
30         u32     mem = 0;
31
32         enables = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE +
33                 MV64360_CPU_BAR_ENABLE) & 0xf;
34
35         for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++)
36                 if (!(enables & (1<<i))) {
37                         v = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE
38                                 + size_reg[i]) & 0xffff;
39                         v = (v + 1) << 16;
40                         mem += v;
41                 }
42
43         return mem;
44 }
45
46 void
47 mv64x60_move_base(void __iomem *old_base, void __iomem *new_base)
48 {
49         u32     bits, mask, b;
50
51         if (old_base != new_base) {
52 #ifdef CONFIG_GT64260
53                 bits = 12;
54                 mask = 0x07000000;
55 #else /* Must be mv64[34]60 */
56                 bits = 16;
57                 mask = 0x03000000;
58 #endif
59                 b = in_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE);
60                 b &= mask;
61                 b |= ((u32)new_base >> (32 - bits));
62                 out_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE, b);
63
64                 __asm__ __volatile__("sync");
65
66                 /* Wait for change to happen (in accordance with the manual) */
67                 while (in_le32(new_base + MV64x60_INTERNAL_SPACE_DECODE) != b);
68         }
69 }
70
71 void __attribute__ ((weak))
72 mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
73 {
74 }
75
76 void *
77 load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
78                 void *ign1, void *ign2)
79 {
80         mv64x60_move_base((void __iomem *)CONFIG_MV64X60_BASE,
81                 (void __iomem *)CONFIG_MV64X60_NEW_BASE);
82         mv64x60_board_init((void __iomem *)CONFIG_MV64X60_BASE,
83                 (void __iomem *)CONFIG_MV64X60_NEW_BASE);
84         return decompress_kernel(load_addr, num_words, cksum);
85 }