Commit 93a26d58 authored by Bernhard Nortmann's avatar Bernhard Nortmann Committed by NiteHawk
Browse files

uart0-helloworld: Refactor SoC detection



Besides having fewer lines of code, the #define macros should
also prevent users from accidentally using these names without
braces (i.e. as function pointers). Instead, this will cause
compiler errors now.

soc_info.c: add "A10s" label in comment for SoC ID 0x1625.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent b8e3a003
......@@ -103,7 +103,7 @@ soc_info_t soc_info_table[] = {
.needs_l2en = true,
.sid_addr = 0x01C23800,
},{
.soc_id = 0x1625, /* Allwinner A13, R8 */
.soc_id = 0x1625, /* Allwinner A10s, A13, R8 */
.scratch_addr = 0x1000,
.thunk_addr = 0xA200, .thunk_size = 0x200,
.swap_buffers = a10_a13_a20_sram_swap_buffers,
......
......@@ -247,51 +247,28 @@ void soc_detection_init(void)
}
}
int soc_is_a10(void)
{
return soc_id == 0x1623;
}
int soc_is_a10s(void)
{
return (soc_id == 0x1625) &&
(((readl(SUN4I_SID_BASE + 0x08) >> 12) & 0xf) == 7);
}
int soc_is_a13(void)
{
return (soc_id == 0x1625) &&
!(((readl(SUN4I_SID_BASE + 0x08) >> 12) & 0xf) == 7);
}
int soc_is_a20(void)
{
return soc_id == 0x1651;
}
/* Most SoCs can reliably be distinguished by simply checking their ID value */
int soc_is_a31(void)
{
return soc_id == 0x1633;
}
#define soc_is_a10() (soc_id == 0x1623)
#define soc_is_a20() (soc_id == 0x1651)
#define soc_is_a31() (soc_id == 0x1633)
#define soc_is_a80() (soc_id == 0x1639)
#define soc_is_a64() (soc_id == 0x1689)
#define soc_is_h3() (soc_id == 0x1680)
#define soc_is_h5() (soc_id == 0x1718)
int soc_is_a80(void)
{
return soc_id == 0x1639;
}
/* A10s and A13 share the same ID, so we need a little more effort on those */
int soc_is_a64(void)
{
return soc_id == 0x1689;
}
int soc_is_h3(void)
int soc_is_a10s(void)
{
return soc_id == 0x1680;
return soc_id == 0x1625 &&
(readl(SUN4I_SID_BASE + 8) & 0xf000) == 0x7000;
}
int soc_is_h5(void)
int soc_is_a13(void)
{
return soc_id == 0x1718;
return soc_id == 0x1625 &&
(readl(SUN4I_SID_BASE + 8) & 0xf000) != 0x7000;
}
/*****************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment