2 * Copyright (C) 2010 Albert ARIBAUD <albert.aribaud@free.fr>
4 * Based on original Kirkwood support which is
6 * Marvell Semiconductor <www.marvell.com>
7 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
30 #include <asm/cache.h>
31 #include <u-boot/md5.h>
32 #include <asm/arch/orion5x.h>
37 void reset_cpu(unsigned long ignored
)
39 struct orion5x_cpu_registers
*cpureg
=
40 (struct orion5x_cpu_registers
*)ORION5X_CPU_REG_BASE
;
42 writel(readl(&cpureg
->rstoutn_mask
) | (1 << 2),
43 &cpureg
->rstoutn_mask
);
44 writel(readl(&cpureg
->sys_soft_rst
) | 1,
45 &cpureg
->sys_soft_rst
);
52 * Used with the Base register to set the address window size and location.
53 * Must be programmed from LSB to MSB as sequence of ones followed by
54 * sequence of zeros. The number of ones specifies the size of the window in
55 * 64 KByte granularity (e.g., a value of 0x00FF specifies 256 = 16 MByte).
56 * NOTE: A value of 0x0 specifies 64-KByte size.
58 unsigned int orion5x_winctrl_calcsize(unsigned int sizeval
)
62 u32 val
= sizeval
>> 1;
64 for (i
= 0; val
>= 0x10000; i
++) {
68 return 0x0000ffff & j
;
72 * orion5x_config_adr_windows - Configure address Windows
74 * There are 8 address windows supported by Orion5x Soc to addess different
75 * devices. Each window can be configured for size, BAR and remap addr
76 * Below configuration is standard for most of the cases
78 * If remap function not used, remap_lo must be set as base
82 * 1) in order to avoid windows with inconsistent control and base values
83 * (which could prevent access to BOOTCS and hence execution from FLASH)
84 * always disable window before writing the base value then reenable it
85 * by writing the control value.
87 * 2) in order to avoid losing access to BOOTCS when disabling window 7,
88 * first configure window 6 for BOOTCS, then configure window 7 for BOOTCS,
89 * then configure windows 6 for its own target.
91 * Reference Documentation:
92 * Mbus-L to Mbus Bridge Registers Configuration.
93 * (Sec 25.1 and 25.3 of Datasheet)
95 int orion5x_config_adr_windows(void)
97 struct orion5x_win_registers
*winregs
=
98 (struct orion5x_win_registers
*)ORION5X_CPU_WIN_BASE
;
100 /* Disable window 0, configure it for its intended target, enable it. */
101 writel(0, &winregs
[0].ctrl
);
102 writel(ORION5X_ADR_PCIE_MEM
, &winregs
[0].base
);
103 writel(ORION5X_ADR_PCIE_MEM_REMAP_LO
, &winregs
[0].remap_lo
);
104 writel(ORION5X_ADR_PCIE_MEM_REMAP_HI
, &winregs
[0].remap_hi
);
105 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_PCIE_MEM
,
106 ORION5X_TARGET_PCIE
, ORION5X_ATTR_PCIE_MEM
,
107 ORION5X_WIN_ENABLE
), &winregs
[0].ctrl
);
108 /* Disable window 1, configure it for its intended target, enable it. */
109 writel(0, &winregs
[1].ctrl
);
110 writel(ORION5X_ADR_PCIE_IO
, &winregs
[1].base
);
111 writel(ORION5X_ADR_PCIE_IO_REMAP_LO
, &winregs
[1].remap_lo
);
112 writel(ORION5X_ADR_PCIE_IO_REMAP_HI
, &winregs
[1].remap_hi
);
113 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_PCIE_IO
,
114 ORION5X_TARGET_PCIE
, ORION5X_ATTR_PCIE_IO
,
115 ORION5X_WIN_ENABLE
), &winregs
[1].ctrl
);
116 /* Disable window 2, configure it for its intended target, enable it. */
117 writel(0, &winregs
[2].ctrl
);
118 writel(ORION5X_ADR_PCI_MEM
, &winregs
[2].base
);
119 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_PCI_MEM
,
120 ORION5X_TARGET_PCI
, ORION5X_ATTR_PCI_MEM
,
121 ORION5X_WIN_ENABLE
), &winregs
[2].ctrl
);
122 /* Disable window 3, configure it for its intended target, enable it. */
123 writel(0, &winregs
[3].ctrl
);
124 writel(ORION5X_ADR_PCI_IO
, &winregs
[3].base
);
125 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_PCI_IO
,
126 ORION5X_TARGET_PCI
, ORION5X_ATTR_PCI_IO
,
127 ORION5X_WIN_ENABLE
), &winregs
[3].ctrl
);
128 /* Disable window 4, configure it for its intended target, enable it. */
129 writel(0, &winregs
[4].ctrl
);
130 writel(ORION5X_ADR_DEV_CS0
, &winregs
[4].base
);
131 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_DEV_CS0
,
132 ORION5X_TARGET_DEVICE
, ORION5X_ATTR_DEV_CS0
,
133 ORION5X_WIN_ENABLE
), &winregs
[4].ctrl
);
134 /* Disable window 5, configure it for its intended target, enable it. */
135 writel(0, &winregs
[5].ctrl
);
136 writel(ORION5X_ADR_DEV_CS1
, &winregs
[5].base
);
137 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_DEV_CS1
,
138 ORION5X_TARGET_DEVICE
, ORION5X_ATTR_DEV_CS1
,
139 ORION5X_WIN_ENABLE
), &winregs
[5].ctrl
);
140 /* Disable window 6, configure it for FLASH, enable it. */
141 writel(0, &winregs
[6].ctrl
);
142 writel(ORION5X_ADR_BOOTROM
, &winregs
[6].base
);
143 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_BOOTROM
,
144 ORION5X_TARGET_DEVICE
, ORION5X_ATTR_BOOTROM
,
145 ORION5X_WIN_ENABLE
), &winregs
[6].ctrl
);
146 /* Disable window 7, configure it for FLASH, enable it. */
147 writel(0, &winregs
[7].ctrl
);
148 writel(ORION5X_ADR_BOOTROM
, &winregs
[7].base
);
149 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_BOOTROM
,
150 ORION5X_TARGET_DEVICE
, ORION5X_ATTR_BOOTROM
,
151 ORION5X_WIN_ENABLE
), &winregs
[7].ctrl
);
152 /* Disable window 6, configure it for its intended target, enable it. */
153 writel(0, &winregs
[6].ctrl
);
154 writel(ORION5X_ADR_DEV_CS2
, &winregs
[6].base
);
155 writel(ORION5X_CPU_WIN_CTRL_DATA(ORION5X_SZ_DEV_CS2
,
156 ORION5X_TARGET_DEVICE
, ORION5X_ATTR_DEV_CS2
,
157 ORION5X_WIN_ENABLE
), &winregs
[6].ctrl
);
163 * Orion5x identification is done through PCIE space.
166 u32
orion5x_device_id(void)
168 return readl(PCIE_DEV_ID_OFF
) >> 16;
171 u32
orion5x_device_rev(void)
173 return readl(PCIE_DEV_REV_OFF
) & 0xff;
176 #if defined(CONFIG_DISPLAY_CPUINFO)
178 /* Display device and revision IDs.
179 * This function must cover all known device/revision
180 * combinations, not only the one for which u-boot is
181 * compiled; this way, one can identify actual HW in
182 * case of a mismatch.
184 int print_cpuinfo(void)
186 char dev_str
[] = "0x0000";
187 char rev_str
[] = "0x00";
188 char *dev_name
= NULL
;
189 char *rev_name
= NULL
;
191 u32 dev
= orion5x_device_id();
192 u32 rev
= orion5x_device_rev();
194 if (dev
== MV88F5181_DEV_ID
) {
195 dev_name
= "MV88F5181";
196 if (rev
== MV88F5181_REV_B1
)
198 else if (rev
== MV88F5181L_REV_A1
) {
199 dev_name
= "MV88F5181L";
201 } else if (rev
== MV88F5181L_REV_A0
) {
202 dev_name
= "MV88F5181L";
205 } else if (dev
== MV88F5182_DEV_ID
) {
206 dev_name
= "MV88F5182";
207 if (rev
== MV88F5182_REV_A2
)
209 } else if (dev
== MV88F5281_DEV_ID
) {
210 dev_name
= "MV88F5281";
211 if (rev
== MV88F5281_REV_D2
)
213 else if (rev
== MV88F5281_REV_D1
)
215 else if (rev
== MV88F5281_REV_D0
)
217 } else if (dev
== MV88F6183_DEV_ID
) {
218 dev_name
= "MV88F6183";
219 if (rev
== MV88F6183_REV_B0
)
222 if (dev_name
== NULL
) {
223 sprintf(dev_str
, "0x%04x", dev
);
226 if (rev_name
== NULL
) {
227 sprintf(rev_str
, "0x%02x", rev
);
231 printf("SoC: Orion5x %s-%s\n", dev_name
, rev_name
);
235 #endif /* CONFIG_DISPLAY_CPUINFO */
237 #ifdef CONFIG_ARCH_CPU_INIT
238 int arch_cpu_init(void)
240 /* Enable and invalidate L2 cache in write through mode */
241 invalidate_l2_cache();
243 orion5x_config_adr_windows();
247 #endif /* CONFIG_ARCH_CPU_INIT */
250 * SOC specific misc init
252 #if defined(CONFIG_ARCH_MISC_INIT)
253 int arch_misc_init(void)
257 /*CPU streaming & write allocate */
258 temp
= readfr_extra_feature_reg();
259 temp
&= ~(1 << 28); /* disable wr alloc */
260 writefr_extra_feature_reg(temp
);
262 temp
= readfr_extra_feature_reg();
263 temp
&= ~(1 << 29); /* streaming disabled */
264 writefr_extra_feature_reg(temp
);
266 /* L2Cache settings */
267 temp
= readfr_extra_feature_reg();
268 /* Disable L2C pre fetch - Set bit 24 */
270 /* enable L2C - Set bit 22 */
272 writefr_extra_feature_reg(temp
);
275 /* Change reset vector to address 0x0 */
277 set_cr(temp
& ~CR_V
);
279 /* Set CPIOs and MPPs - values provided by board
281 writel(ORION5X_MPP0_7
, ORION5X_MPP_BASE
+0x00);
282 writel(ORION5X_MPP8_15
, ORION5X_MPP_BASE
+0x04);
283 writel(ORION5X_MPP16_23
, ORION5X_MPP_BASE
+0x50);
284 writel(ORION5X_GPIO_OUT_ENABLE
, ORION5X_GPIO_BASE
+0x04);
286 /* initialize timer */
290 #endif /* CONFIG_ARCH_MISC_INIT */
293 int cpu_eth_init(bd_t
*bis
)
295 mvgbe_initialize(bis
);