mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-22 19:23:07 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
144 lines
2.7 KiB
C
144 lines
2.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* PXA CPU information display
|
|
*
|
|
* Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <asm/io.h>
|
|
#include <errno.h>
|
|
#include <linux/compiler.h>
|
|
|
|
#ifdef CONFIG_CPU_PXA25X
|
|
#if ((CONFIG_SYS_INIT_SP_ADDR) != 0xfffff800)
|
|
#error "Init SP address must be set to 0xfffff800 for PXA250"
|
|
#endif
|
|
#endif
|
|
|
|
#define CPU_MASK_PXA_PRODID 0x000003f0
|
|
#define CPU_MASK_PXA_REVID 0x0000000f
|
|
|
|
#define CPU_MASK_PRODREV (CPU_MASK_PXA_PRODID | CPU_MASK_PXA_REVID)
|
|
|
|
#define CPU_VALUE_PXA25X 0x100
|
|
#define CPU_VALUE_PXA27X 0x110
|
|
|
|
static uint32_t pxa_get_cpuid(void)
|
|
{
|
|
uint32_t cpuid;
|
|
asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r"(cpuid));
|
|
return cpuid;
|
|
}
|
|
|
|
int cpu_is_pxa25x(void)
|
|
{
|
|
uint32_t id = pxa_get_cpuid();
|
|
id &= CPU_MASK_PXA_PRODID;
|
|
return id == CPU_VALUE_PXA25X;
|
|
}
|
|
|
|
int cpu_is_pxa27x(void)
|
|
{
|
|
uint32_t id = pxa_get_cpuid();
|
|
id &= CPU_MASK_PXA_PRODID;
|
|
return id == CPU_VALUE_PXA27X;
|
|
}
|
|
|
|
int cpu_is_pxa27xm(void)
|
|
{
|
|
uint32_t id = pxa_get_cpuid();
|
|
return ((id & CPU_MASK_PXA_PRODID) == CPU_VALUE_PXA27X) &&
|
|
((id & CPU_MASK_PXA_REVID) == 8);
|
|
}
|
|
|
|
uint32_t pxa_get_cpu_revision(void)
|
|
{
|
|
return pxa_get_cpuid() & CPU_MASK_PRODREV;
|
|
}
|
|
|
|
#ifdef CONFIG_DISPLAY_CPUINFO
|
|
static const char *pxa25x_get_revision(void)
|
|
{
|
|
static __maybe_unused const char * const revs_25x[] = { "A0" };
|
|
static __maybe_unused const char * const revs_26x[] = {
|
|
"A0", "B0", "B1"
|
|
};
|
|
static const char *unknown = "Unknown";
|
|
uint32_t id;
|
|
|
|
if (!cpu_is_pxa25x())
|
|
return unknown;
|
|
|
|
id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
|
|
|
|
/* PXA26x is a sick special case as it can't be told apart from PXA25x :-( */
|
|
#ifdef CONFIG_CPU_PXA26X
|
|
switch (id) {
|
|
case 3: return revs_26x[0];
|
|
case 5: return revs_26x[1];
|
|
case 6: return revs_26x[2];
|
|
}
|
|
#else
|
|
if (id == 6)
|
|
return revs_25x[0];
|
|
#endif
|
|
return unknown;
|
|
}
|
|
|
|
static const char *pxa27x_get_revision(void)
|
|
{
|
|
static const char *const rev[] = { "A0", "A1", "B0", "B1", "C0", "C5" };
|
|
static const char *unknown = "Unknown";
|
|
uint32_t id;
|
|
|
|
if (!cpu_is_pxa27x())
|
|
return unknown;
|
|
|
|
id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
|
|
|
|
if ((id == 5) || (id == 6) || (id > 8))
|
|
return unknown;
|
|
|
|
/* Cap the special PXA270 C5 case. */
|
|
if (id == 7)
|
|
id = 5;
|
|
|
|
/* Cap the special PXA270M A1 case. */
|
|
if (id == 8)
|
|
id = 1;
|
|
|
|
return rev[id];
|
|
}
|
|
|
|
static int print_cpuinfo_pxa2xx(void)
|
|
{
|
|
if (cpu_is_pxa25x()) {
|
|
puts("Marvell PXA25x rev. ");
|
|
puts(pxa25x_get_revision());
|
|
} else if (cpu_is_pxa27x()) {
|
|
puts("Marvell PXA27x");
|
|
if (cpu_is_pxa27xm()) puts("M");
|
|
puts(" rev. ");
|
|
puts(pxa27x_get_revision());
|
|
} else
|
|
return -EINVAL;
|
|
|
|
puts("\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int print_cpuinfo(void)
|
|
{
|
|
int ret;
|
|
|
|
puts("CPU: ");
|
|
|
|
ret = print_cpuinfo_pxa2xx();
|
|
if (!ret)
|
|
return ret;
|
|
|
|
return ret;
|
|
}
|
|
#endif
|