blob: c83268181b90d28ee113184351b5dcfc7c18e8f4 [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>
Simon Glassafb02152019-12-28 10:45:01 -07007#include <cpu_func.h>
Stefan Roese05b17652016-05-17 15:00:30 +02008#include <dm.h>
9#include <fdtdec.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090010#include <linux/libfdt.h>
Stefan Roese05b17652016-05-17 15:00:30 +020011#include <asm/io.h>
12#include <asm/system.h>
13#include <asm/arch/cpu.h>
14#include <asm/arch/soc.h>
15#include <asm/armv8/mmu.h>
16
Stefan Roese05b17652016-05-17 15:00:30 +020017/* Armada 3700 */
18#define MVEBU_GPIO_NB_REG_BASE (MVEBU_REGISTER(0x13800))
19
20#define MVEBU_TEST_PIN_LATCH_N (MVEBU_GPIO_NB_REG_BASE + 0x8)
21#define MVEBU_XTAL_MODE_MASK BIT(9)
22#define MVEBU_XTAL_MODE_OFFS 9
23#define MVEBU_XTAL_CLOCK_25MHZ 0x0
24#define MVEBU_XTAL_CLOCK_40MHZ 0x1
25
26#define MVEBU_NB_WARM_RST_REG (MVEBU_GPIO_NB_REG_BASE + 0x40)
27#define MVEBU_NB_WARM_RST_MAGIC_NUM 0x1d1e
28
29static struct mm_region mvebu_mem_map[] = {
30 {
31 /* RAM */
32 .phys = 0x0UL,
33 .virt = 0x0UL,
34 .size = 0x80000000UL,
35 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
36 PTE_BLOCK_INNER_SHARE
37 },
38 {
39 /* SRAM, MMIO regions */
40 .phys = 0xd0000000UL,
41 .virt = 0xd0000000UL,
42 .size = 0x02000000UL, /* 32MiB internal registers */
43 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
44 PTE_BLOCK_NON_SHARE
45 },
46 {
Wilson Ding80af2f92018-03-26 15:57:28 +080047 /* PCI regions */
48 .phys = 0xe8000000UL,
49 .virt = 0xe8000000UL,
50 .size = 0x02000000UL, /* 32MiB master PCI space */
51 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
52 PTE_BLOCK_NON_SHARE
53 },
54 {
Stefan Roese05b17652016-05-17 15:00:30 +020055 /* List terminator */
56 0,
57 }
58};
59
60struct mm_region *mem_map = mvebu_mem_map;
61
Stefan Roese05b17652016-05-17 15:00:30 +020062void reset_cpu(ulong ignored)
63{
64 /*
65 * Write magic number of 0x1d1e to North Bridge Warm Reset register
66 * to trigger warm reset
67 */
68 writel(MVEBU_NB_WARM_RST_MAGIC_NUM, MVEBU_NB_WARM_RST_REG);
69}
70
71/*
72 * get_ref_clk
73 *
74 * return: reference clock in MHz (25 or 40)
75 */
76u32 get_ref_clk(void)
77{
78 u32 regval;
79
80 regval = (readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) >>
81 MVEBU_XTAL_MODE_OFFS;
82
83 if (regval == MVEBU_XTAL_CLOCK_25MHZ)
84 return 25;
85 else
86 return 40;
87}