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.
25 static u8
*bridge_base
;
27 static void c2k_bridge_setup(u32 mem_size
)
29 u32 i
, v
[30], enables
, acc_bits
;
30 u32 pci_base_hi
, pci_base_lo
, size
, buf
[2];
31 unsigned long cpu_base
;
33 void *devp
, *mv64x60_devp
;
34 u8
*bridge_pbase
, is_coherent
;
35 struct mv64x60_cpu2pci_win
*tbl
;
38 bridge_pbase
= mv64x60_get_bridge_pbase();
39 is_coherent
= mv64x60_is_coherent();
42 acc_bits
= MV64x60_PCI_ACC_CNTL_SNOOP_WB
43 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
44 | MV64x60_PCI_ACC_CNTL_MBURST_32_BYTES
45 | MV64x60_PCI_ACC_CNTL_RDSIZE_32_BYTES
;
47 acc_bits
= MV64x60_PCI_ACC_CNTL_SNOOP_NONE
48 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
49 | MV64x60_PCI_ACC_CNTL_MBURST_128_BYTES
50 | MV64x60_PCI_ACC_CNTL_RDSIZE_256_BYTES
;
52 mv64x60_config_ctlr_windows(bridge_base
, bridge_pbase
, is_coherent
);
53 mv64x60_devp
= find_node_by_compatible(NULL
, "marvell,mv64360");
54 if (mv64x60_devp
== NULL
)
55 fatal("Error: Missing marvell,mv64360 device tree node\n\r");
57 enables
= in_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
));
58 enables
|= 0x007ffe00; /* Disable all cpu->pci windows */
59 out_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
), enables
);
61 /* Get the cpu -> pci i/o & mem mappings from the device tree */
63 for (bus
= 0; ; bus
++) {
66 name
[strlen(name
)-1] = bus
+'0';
68 devp
= find_node_by_alias(name
);
73 fatal("Error: Only 2 PCI controllers are supported at" \
76 mv64x60_config_pci_windows(bridge_base
, bridge_pbase
, bus
, 0,
79 rc
= getprop(devp
, "ranges", v
, sizeof(v
));
81 fatal("Error: Can't find marvell,mv64360-pci ranges"
84 /* Get the cpu -> pci i/o & mem mappings from the device tree */
86 for (i
= 0; i
< rc
; i
+= 6) {
87 switch (v
[i
] & 0xff000000) {
88 case 0x01000000: /* PCI I/O Space */
89 tbl
= mv64x60_cpu2pci_io
;
91 case 0x02000000: /* PCI MEM Space */
92 tbl
= mv64x60_cpu2pci_mem
;
106 if (!dt_xlate_addr(devp
, buf
, sizeof(buf
), &cpu_base
))
107 fatal("Error: Can't translate PCI address " \
108 "0x%x\n\r", (u32
)cpu_base
);
110 mv64x60_config_cpu2pci_window(bridge_base
, bus
,
111 pci_base_hi
, pci_base_lo
, cpu_base
, size
, tbl
);
114 enables
&= ~(3<<(9+bus
*5)); /* Enable cpu->pci<bus> i/o,
115 cpu->pci<bus> mem0 */
116 out_le32((u32
*)(bridge_base
+ MV64x60_CPU_BAR_ENABLE
),
121 static void c2k_fixups(void)
125 mem_size
= mv64x60_get_mem_size(bridge_base
);
126 c2k_bridge_setup(mem_size
); /* Do necessary bridge setup */
129 #define MV64x60_MPP_CNTL_0 0xf000
130 #define MV64x60_MPP_CNTL_2 0xf008
131 #define MV64x60_GPP_IO_CNTL 0xf100
132 #define MV64x60_GPP_LEVEL_CNTL 0xf110
133 #define MV64x60_GPP_VALUE_SET 0xf118
135 static void c2k_reset(void)
141 if (bridge_base
!= 0) {
142 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_0
));
144 out_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_0
), temp
);
146 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
));
148 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
), temp
);
150 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
));
152 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
), temp
);
154 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_2
));
156 out_le32((u32
*)(bridge_base
+ MV64x60_MPP_CNTL_2
), temp
);
158 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
));
160 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_LEVEL_CNTL
), temp
);
162 temp
= in_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
));
164 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_IO_CNTL
), temp
);
166 out_le32((u32
*)(bridge_base
+ MV64x60_GPP_VALUE_SET
),
175 void platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
176 unsigned long r6
, unsigned long r7
)
180 fdt_init(_dtb_start
);
182 bridge_base
= mv64x60_get_bridge_base();
184 platform_ops
.fixups
= c2k_fixups
;
185 platform_ops
.exit
= c2k_reset
;
187 if (serial_console_init() < 0)