u-boot/arch/arm/mach-mvebu/armada8k/cpu.c
Harald Seiler 35b65dd8ef reset: Remove addr parameter from reset_cpu()
Historically, the reset_cpu() function had an `addr` parameter which was
meant to pass in an address of the reset vector location, where the CPU
should reset to.  This feature is no longer used anywhere in U-Boot as
all reset_cpu() implementations now ignore the passed value.  Generic
code has been added which always calls reset_cpu() with `0` which means
this feature can no longer be used easily anyway.

Over time, many implementations seem to have "misunderstood" the
existence of this parameter as a way to customize/parameterize the reset
(e.g.  COLD vs WARM resets).  As this is not properly supported, the
code will almost always not do what it is intended to (because all
call-sites just call reset_cpu() with 0).

To avoid confusion and to clean up the codebase from unused left-overs
of the past, remove the `addr` parameter entirely.  Code which intends
to support different kinds of resets should be rewritten as a sysreset
driver instead.

This transformation was done with the following coccinelle patch:

    @@
    expression argvalue;
    @@
    - reset_cpu(argvalue)
    + reset_cpu()

    @@
    identifier argname;
    type argtype;
    @@
    - reset_cpu(argtype argname)
    + reset_cpu(void)
    { ... }

Signed-off-by: Harald Seiler <hws@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-03-02 14:03:02 -05:00

152 lines
3.6 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2016 Stefan Roese <sr@denx.de>
*/
#include <common.h>
#include <cpu_func.h>
#include <dm.h>
#include <fdtdec.h>
#include <linux/libfdt.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/arch/cpu.h>
#include <asm/arch/soc.h>
#include <asm/armv8/mmu.h>
/* Armada 7k/8k */
#define MVEBU_RFU_BASE (MVEBU_REGISTER(0x6f0000))
#define RFU_GLOBAL_SW_RST (MVEBU_RFU_BASE + 0x84)
#define RFU_SW_RESET_OFFSET 0
#define SAR0_REG (MVEBU_REGISTER(0x2400200))
#define BOOT_MODE_MASK 0x3f
#define BOOT_MODE_OFFSET 4
/*
* The following table includes all memory regions for Armada 7k and
* 8k SoCs. The Armada 7k is missing the CP110 slave regions here. Lets
* define these regions at the beginning of the struct so that they
* can be easier removed later dynamically if an Armada 7k device is detected.
* For a detailed memory map, please see doc/mvebu/armada-8k-memory.txt
*/
#define ARMADA_7K8K_COMMON_REGIONS_START 2
static struct mm_region mvebu_mem_map[] = {
/* Armada 80x0 memory regions include the CP1 (slave) units */
{
/* SRAM, MMIO regions - CP110 slave region */
.phys = 0xf4000000UL,
.virt = 0xf4000000UL,
.size = 0x02000000UL, /* 32MiB internal registers */
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
},
{
/* PCI CP1 regions */
.phys = 0xfa000000UL,
.virt = 0xfa000000UL,
.size = 0x04000000UL, /* 64MiB CP110 slave PCI space */
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
},
/* Armada 80x0 and 70x0 common memory regions start here */
{
/* RAM */
.phys = 0x0UL,
.virt = 0x0UL,
.size = 0x80000000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
PTE_BLOCK_INNER_SHARE
},
{
/* SRAM, MMIO regions - AP806 region */
.phys = 0xf0000000UL,
.virt = 0xf0000000UL,
.size = 0x01000000UL, /* 16MiB internal registers */
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
},
{
/* SRAM, MMIO regions - CP110 master region */
.phys = 0xf2000000UL,
.virt = 0xf2000000UL,
.size = 0x02000000UL, /* 32MiB internal registers */
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
},
{
/* PCI CP0 regions */
.phys = 0xf6000000UL,
.virt = 0xf6000000UL,
.size = 0x04000000UL, /* 64MiB CP110 master PCI space */
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE
},
{
0,
}
};
struct mm_region *mem_map = mvebu_mem_map;
void enable_caches(void)
{
/*
* Armada 7k is not equipped with the CP110 slave CP. In case this
* code runs on an Armada 7k device, lets remove the CP110 slave
* entries from the memory mapping by moving the start to the
* common regions.
*/
if (of_machine_is_compatible("marvell,armada7040"))
mem_map = &mvebu_mem_map[ARMADA_7K8K_COMMON_REGIONS_START];
icache_enable();
dcache_enable();
}
void reset_cpu(void)
{
u32 reg;
reg = readl(RFU_GLOBAL_SW_RST);
reg &= ~(1 << RFU_SW_RESET_OFFSET);
writel(reg, RFU_GLOBAL_SW_RST);
}
/*
* TODO - implement this functionality using platform
* clock driver once it gets available
* Return NAND clock in Hz
*/
u32 mvebu_get_nand_clock(void)
{
unsigned long NAND_FLASH_CLK_CTRL = 0xF2440700UL;
unsigned long NF_CLOCK_SEL_MASK = 0x1;
u32 reg;
reg = readl(NAND_FLASH_CLK_CTRL);
if (reg & NF_CLOCK_SEL_MASK)
return 400 * 1000000;
else
return 250 * 1000000;
}
int mmc_get_env_dev(void)
{
u32 reg;
unsigned int boot_mode;
reg = readl(SAR0_REG);
boot_mode = (reg >> BOOT_MODE_OFFSET) & BOOT_MODE_MASK;
switch (boot_mode) {
case 0x28:
case 0x2a:
return 0;
case 0x29:
case 0x2b:
return 1;
}
return CONFIG_SYS_MMC_ENV_DEV;
}