1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
9 #include <linux/libfdt.h>
11 #include <asm/system.h>
12 #include <asm/arch/cpu.h>
13 #include <asm/arch/soc.h>
14 #include <asm/armv8/mmu.h>
17 #define MVEBU_RFU_BASE (MVEBU_REGISTER(0x6f0000))
18 #define RFU_GLOBAL_SW_RST (MVEBU_RFU_BASE + 0x84)
19 #define RFU_SW_RESET_OFFSET 0
22 * The following table includes all memory regions for Armada 7k and
23 * 8k SoCs. The Armada 7k is missing the CP110 slave regions here. Lets
24 * define these regions at the beginning of the struct so that they
25 * can be easier removed later dynamically if an Armada 7k device is detected.
26 * For a detailed memory map, please see doc/mvebu/armada-8k-memory.txt
28 #define ARMADA_7K8K_COMMON_REGIONS_START 2
29 static struct mm_region mvebu_mem_map[] = {
30 /* Armada 80x0 memory regions include the CP1 (slave) units */
32 /* SRAM, MMIO regions - CP110 slave region */
35 .size = 0x02000000UL, /* 32MiB internal registers */
36 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
43 .size = 0x04000000UL, /* 64MiB CP110 slave PCI space */
44 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
47 /* Armada 80x0 and 70x0 common memory regions start here */
53 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
57 /* SRAM, MMIO regions - AP806 region */
60 .size = 0x01000000UL, /* 16MiB internal registers */
61 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
65 /* SRAM, MMIO regions - CP110 master region */
68 .size = 0x02000000UL, /* 32MiB internal registers */
69 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
76 .size = 0x04000000UL, /* 64MiB CP110 master PCI space */
77 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
85 struct mm_region *mem_map = mvebu_mem_map;
87 void enable_caches(void)
90 * Armada 7k is not equipped with the CP110 slave CP. In case this
91 * code runs on an Armada 7k device, lets remove the CP110 slave
92 * entries from the memory mapping by moving the start to the
95 if (of_machine_is_compatible("marvell,armada7040"))
96 mem_map = &mvebu_mem_map[ARMADA_7K8K_COMMON_REGIONS_START];
102 void reset_cpu(ulong ignored)
106 reg = readl(RFU_GLOBAL_SW_RST);
107 reg &= ~(1 << RFU_SW_RESET_OFFSET);
108 writel(reg, RFU_GLOBAL_SW_RST);
112 * TODO - implement this functionality using platform
113 * clock driver once it gets available
114 * Return NAND clock in Hz
116 u32 mvebu_get_nand_clock(void)
118 unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;
119 unsigned long NF_CLOCK_SEL_MASK = 0x1;
122 reg = readl(NAND_FLASH_CLK_CTRL);
123 if (reg & NF_CLOCK_SEL_MASK)
124 return 400 * 1000000;
126 return 250 * 1000000;