2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-05-12 22:40:54 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010
|
|
|
|
* Reinhard Meyer, reinhard.meyer@emk-elektronik.de
|
|
|
|
* (C) Copyright 2009
|
|
|
|
* Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
|
|
|
|
* (C) Copyright 2013
|
|
|
|
* Bo Shen <voice.shen@atmel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2019-11-14 19:57:20 +00:00
|
|
|
#include <vsprintf.h>
|
2013-05-12 22:40:54 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/at91_pit.h>
|
|
|
|
#include <asm/arch/at91_gpbr.h>
|
|
|
|
#include <asm/arch/clk.h>
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
#ifndef CFG_SYS_AT91_MAIN_CLOCK
|
|
|
|
#define CFG_SYS_AT91_MAIN_CLOCK 0
|
2013-05-12 22:40:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
2023-05-30 09:05:16 +00:00
|
|
|
#if defined(CONFIG_CLK_CCF) || defined(CONFIG_CLK_SCMI)
|
2020-11-11 11:15:08 +00:00
|
|
|
return 0;
|
|
|
|
#else
|
2022-11-16 18:10:41 +00:00
|
|
|
return at91_clock_init(CFG_SYS_AT91_MAIN_CLOCK);
|
2020-11-11 11:15:08 +00:00
|
|
|
#endif
|
2013-05-12 22:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void arch_preboot_os(void)
|
|
|
|
{
|
2020-08-20 13:11:52 +00:00
|
|
|
#if (IS_ENABLED(CONFIG_ATMEL_PIT_TIMER))
|
2013-05-12 22:40:54 +00:00
|
|
|
ulong cpiv;
|
|
|
|
at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
|
|
|
|
|
|
|
|
cpiv = AT91_PIT_MR_PIV_MASK(readl(&pit->piir));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable PITC
|
|
|
|
* Add 0x1000 to current counter to stop it faster
|
|
|
|
* without waiting for wrapping back to 0
|
|
|
|
*/
|
|
|
|
writel(cpiv + 0x1000, &pit->mr);
|
2020-08-20 13:11:52 +00:00
|
|
|
#endif
|
2013-05-12 22:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
|
|
|
int print_cpuinfo(void)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
printf("CPU: %s\n", get_cpu_name());
|
|
|
|
printf("Crystal frequency: %8s MHz\n",
|
|
|
|
strmhz(buf, get_main_clk_rate()));
|
|
|
|
printf("CPU clock : %8s MHz\n",
|
|
|
|
strmhz(buf, get_cpu_clk_rate()));
|
|
|
|
printf("Master clock : %8s MHz\n",
|
|
|
|
strmhz(buf, get_mck_clk_rate()));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
2014-05-19 11:51:28 +00:00
|
|
|
icache_enable();
|
|
|
|
dcache_enable();
|
2013-05-12 22:40:54 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 06:38:26 +00:00
|
|
|
#define ATMEL_CHIPID_CIDR_VERSION 0x1f
|
|
|
|
|
2013-05-12 22:40:54 +00:00
|
|
|
unsigned int get_chip_id(void)
|
|
|
|
{
|
2015-09-08 06:38:26 +00:00
|
|
|
return readl(ATMEL_CHIPID_CIDR) & ~ATMEL_CHIPID_CIDR_VERSION;
|
2013-05-12 22:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int get_extension_chip_id(void)
|
|
|
|
{
|
2015-09-08 06:38:26 +00:00
|
|
|
return readl(ATMEL_CHIPID_EXID);
|
2013-05-12 22:40:54 +00:00
|
|
|
}
|