2 * GEFanuc C2K platform code.
4 * Author: Remi Machet <rmachet@slac.stanford.edu>
6 * Originated from prpmc2800.c
8 * 2008 (c) Stanford University
9 * 2007 (c) MontaVista, Software, Inc.
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
21 #include "gunzip_util.h"
26 static u8
*bridge_base
;
28 static void c2k_bridge_setup(u32 mem_size
)
30 u32 i
, v
[30], enables
, acc_bits
;
31 u32 pci_base_hi
, pci_base_lo
, size
, buf
[2];
32 unsigned long cpu_base
;
34 void *devp
, *mv64x60_devp
;
35 u8
*bridge_pbase
, is_coherent
;
36 struct mv64x60_cpu2pci_win
*tbl
;
39 bridge_pbase
= mv64x60_get_bridge_pbase();
40 is_coherent
= mv64x60_is_coherent();
43 acc_bits
= MV64x60_PCI_ACC_CNTL_SNOOP_WB
44 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
45 | MV64x60_PCI_ACC_CNTL_MBURST_32_BYTES
46 | MV64x60_PCI_ACC_CNTL_RDSIZE_32_BYTES
;
48 acc_bits
= MV64x60_PCI_ACC_CNTL_SNOOP_NONE
49 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
50 | MV64x60_PCI_ACC_CNTL_MBURST_128_BYTES
51 | MV64x60_PCI_ACC_CNTL_RDSIZE_256_BYTES
;
53 mv64x60_config_ctlr_windows(bridge_base
, bridge_pbase
, is_coherent
);
54 mv64x60_devp
= find_node_by_compatible(NULL
, "marvell,mv64360");
55 if (mv64x60_devp
== NULL
)
56 fatal("Error: Missing marvell,mv64360 device tree node\n\r");
58 enables
= in_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
));
59 enables
|= 0x007ffe00; /* Disable all cpu->pci windows */
60 out_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
), enables
);
62 /* Get the cpu -> pci i/o & mem mappings from the device tree */
64 for (bus
= 0; ; bus
++) {
67 name
[strlen(name
)-1] = bus
+'0';
69 devp
= find_node_by_alias(name
);
74 fatal("Error: Only 2 PCI controllers are supported at" \
77 mv64x60_config_pci_windows(bridge_base
, bridge_pbase
, bus
, 0,
80 rc
= getprop(devp
, "ranges", v
, sizeof(v
));
82 fatal("Error: Can't find marvell,mv64360-pci ranges"
85 /* Get the cpu -> pci i/o & mem mappings from the device tree */
87 for (i
= 0; i
< rc
; i
+= 6) {
88 switch (v
[i
] & 0xff000000) {
89 case 0x01000000: /* PCI I/O Space */
90 tbl
= mv64x60_cpu2pci_io
;
92 case 0x02000000: /* PCI MEM Space */
93 tbl
= mv64x60_cpu2pci_mem
;
100 pci_base_lo
= v
[i
+2];
107 if (!dt_xlate_addr(devp
, buf
, sizeof(buf
), &cpu_base
))
108 fatal("Error: Can't translate PCI address " \
109 "0x%x\n\r", (u32
)cpu_base
);
111 mv64x60_config_cpu2pci_window(bridge_base
, bus
,
112 pci_base_hi
, pci_base_lo
, cpu_base
, size
, tbl
);
115 enables
&= ~(3<<(9+bus
*5)); /* Enable cpu->pci<bus> i/o,
116 cpu->pci<bus> mem0 */
117 out_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
),
122 static void c2k_fixups(void)
126 mem_size
= mv64x60_get_mem_size(bridge_base
);
127 c2k_bridge_setup(mem_size
); /* Do necessary bridge setup */
130 #define MV64x60_MPP_CNTL_0 0xf000
131 #define MV64x60_MPP_CNTL_2 0xf008
132 #define MV64x60_GPP_IO_CNTL 0xf100
133 #define MV64x60_GPP_LEVEL_CNTL 0xf110
134 #define MV64x60_GPP_VALUE_SET 0xf118
136 static void c2k_reset(void)
142 if (bridge_base
!= 0) {
143 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_0
));
145 out_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_0
), temp
);
147 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
));
149 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
), temp
);
151 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
));
153 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
), temp
);
155 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_2
));
157 out_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_2
), temp
);
159 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
));
161 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
), temp
);
163 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
));
165 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
), temp
);
167 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_VALUE_SET
),
176 void platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
177 unsigned long r6
, unsigned long r7
)
181 fdt_init(_dtb_start
);
183 bridge_base
= mv64x60_get_bridge_base();
185 platform_ops
.fixups
= c2k_fixups
;
186 platform_ops
.exit
= c2k_reset
;
188 if (serial_console_init() < 0)