summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/netgear-rn2120/lowlevel.c
blob: c78d3644b5f9a45e3562803e4607e7ae3ffb9dd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: 2015 Uwe Kleine-König <kernel@pengutronix.de>, Pengutronix

#include <common.h>
#include <asm/barebox-arm.h>
#include <asm/barebox-arm-head.h>
#include <asm/io.h>
#include <mach/lowlevel.h>
#include <mach/common.h>

extern char __dtb_armada_xp_rn2120_bb_start[];

ENTRY_FUNCTION(start_netgear_rn2120, r0, r1, r2)
{
	void *fdt;
	void __iomem *base = mvebu_get_initial_int_reg_base();

	arm_cpu_lowlevel_init();

	/*
	 * This is necessary to allow the machine to draw more power. Probably
	 * connected to a TI TPS65251. Without this resetting a phy makes the
	 * SoC reset.
	 * This is effectively gpio_direction_output(42, 1);
	 */
	writel((1 << 10) | readl(base + 0x18140), base + 0x18140);
	writel(~(1 << 10) & readl(base + 0x18144), base + 0x18144);

	/*
	 * The vendor binary that initializes RAM doesn't program the SDRAM
	 * Address Decoding registers to match the actual available RAM. But as
	 * barebox later determines the RAM size from these, fix them up here.
	 */

	/* Win 1 Base Address Register: base=0x40000000 */
	writel(0x40000000, base + 0x20188);
	/* Win 1 Control Register: size=0x4000000, wincs=1, en=1*/
	writel(0x3fffffe5, base + 0x2018c);

	/* Win 0 Base Address Register is already 0, base=0x00000000 */
	/* Win 0 Control Register: size=0x4000000, wincs=0, en=1 */
	writel(0x3fffffe1, base + 0x20184);

	fdt = __dtb_armada_xp_rn2120_bb_start +
		get_runtime_offset();

	armada_370_xp_barebox_entry(fdt);
}