blob: 7c8e4cade1ecfa917f159b575589fee3f1885163 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese05b17652016-05-17 15:00:30 +02002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese05b17652016-05-17 15:00:30 +02004 */
5
6#include <common.h>
7#include <dm.h>
8#include <fdtdec.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +09009#include <linux/libfdt.h>
Stefan Roese05b17652016-05-17 15:00:30 +020010#include <asm/io.h>
11#include <asm/system.h>
12#include <asm/arch/cpu.h>
13#include <asm/arch/soc.h>
14#include <asm/armv8/mmu.h>
15
Stefan Roese05b17652016-05-17 15:00:30 +020016/* Armada 3700 */
17#define MVEBU_GPIO_NB_REG_BASE (MVEBU_REGISTER(0x13800))
18
19#define MVEBU_TEST_PIN_LATCH_N (MVEBU_GPIO_NB_REG_BASE + 0x8)
20#define MVEBU_XTAL_MODE_MASK BIT(9)
21#define MVEBU_XTAL_MODE_OFFS 9
22#define MVEBU_XTAL_CLOCK_25MHZ 0x0
23#define MVEBU_XTAL_CLOCK_40MHZ 0x1
24
25#define MVEBU_NB_WARM_RST_REG (MVEBU_GPIO_NB_REG_BASE + 0x40)
26#define MVEBU_NB_WARM_RST_MAGIC_NUM 0x1d1e
27
28static struct mm_region mvebu_mem_map[] = {
29 {
30 /* RAM */
31 .phys = 0x0UL,
32 .virt = 0x0UL,
33 .size = 0x80000000UL,
34 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
35 PTE_BLOCK_INNER_SHARE
36 },
37 {
38 /* SRAM, MMIO regions */
39 .phys = 0xd0000000UL,
40 .virt = 0xd0000000UL,
41 .size = 0x02000000UL, /* 32MiB internal registers */
42 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
43 PTE_BLOCK_NON_SHARE
44 },
45 {
Wilson Ding80af2f92018-03-26 15:57:28 +080046 /* PCI regions */
47 .phys = 0xe8000000UL,
48 .virt = 0xe8000000UL,
49 .size = 0x02000000UL, /* 32MiB master PCI space */
50 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
51 PTE_BLOCK_NON_SHARE
52 },
53 {
Stefan Roese05b17652016-05-17 15:00:30 +020054 /* List terminator */
55 0,
56 }
57};
58
59struct mm_region *mem_map = mvebu_mem_map;
60
Stefan Roese05b17652016-05-17 15:00:30 +020061void reset_cpu(ulong ignored)
62{
63 /*
64 * Write magic number of 0x1d1e to North Bridge Warm Reset register
65 * to trigger warm reset
66 */
67 writel(MVEBU_NB_WARM_RST_MAGIC_NUM, MVEBU_NB_WARM_RST_REG);
68}
69
70/*
71 * get_ref_clk
72 *
73 * return: reference clock in MHz (25 or 40)
74 */
75u32 get_ref_clk(void)
76{
77 u32 regval;
78
79 regval = (readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) >>
80 MVEBU_XTAL_MODE_OFFS;
81
82 if (regval == MVEBU_XTAL_CLOCK_25MHZ)
83 return 25;
84 else
85 return 40;
86}