mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-23 11:33:32 +00:00
aba3fa1d3f
- sei610 & meson64_android cleanups to prepare android 11 boot support - use Android BCB mechanism for reboot reason instead of HW reboot flag - Switch meson64_android boot flow to use abootimg for A/B, AVB and DTBO support -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEPVPGJshWBf4d9CyLd9zb2sjISdEFAmESPjcACgkQd9zb2sjI SdFabg/+K/5kH01N6etPpPgNH3DTns3Z7Uv16rawGaFJVj4V2O/Ak2vmhvjJA4df KvLJL3AVolMOfD4xTABRDyLKt3maCgIYkamdBWBV/xKCTKL7fvvqj8V1U5iUsGKm Wl2KbbDj+dGNF+IYO9V4T1D/JaRjAUk4YeztFEDaNdP3P1N+01v2FyfkadBL5un3 dqwHb3DMNS2SyjnE3glTAs3g/+3nmrHhAHiVVZQlJHsijuup6f93e8huKQ4v1oFX xsNzeI9j6jGBvVI6hRsHNLOZzhj8/ZcSntdlL+b4FbY++KzrKidMgVECc486cc8t IEq/iJHggYhwRtw3EAYblmMVFiQeo07hgSbbSP8mIJWARtqh439tLUyKxW3y/5UT UlGLHcsSSwv/5NhY8ugGAYeaGGXNpMMc5ISbssnn5FB6VHSox4nRZai5U9jKoyc2 iBNNdyLiLi/Fz9YMWj8SAibajT8bchWu1qW2n85nFb3xWQpXcbjzlglnLY6bX3TQ 1d5ehInNK8deptHNh2eGBsPKOUJ/gDTvEey+6J517hbJ59My96v+dvmbtG7kH9Z8 157KQzjvHH4X9MDW8wYb381TV8kcNi3b16QPP2RKxuK1Zrve0RLPhOAz/YeSkTDN mavHlaY7JvUXjAct0K5VXHvA9U6DBrvc3eb7KoXL4b4+SHr/4UQ= =RZ8+ -----END PGP SIGNATURE----- Merge tag 'u-boot-amlogic-20210810' of https://source.denx.de/u-boot/custodians/u-boot-amlogic - odroid-n2: fix fdtfile suffix for n2-plus - sei610 & meson64_android cleanups to prepare android 11 boot support - use Android BCB mechanism for reboot reason instead of HW reboot flag - Switch meson64_android boot flow to use abootimg for A/B, AVB and DTBO support
140 lines
3.3 KiB
C
140 lines
3.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2020 BayLibre, SAS
|
|
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <adc.h>
|
|
#include <env.h>
|
|
#include <init.h>
|
|
#include <net.h>
|
|
#include <asm/io.h>
|
|
#include <asm/arch/boot.h>
|
|
#include <asm/arch/sm.h>
|
|
#include <asm/arch/eth.h>
|
|
#include <asm/arch/boot.h>
|
|
|
|
#define EFUSE_MAC_OFFSET 20
|
|
#define EFUSE_MAC_SIZE 12
|
|
#define MAC_ADDR_LEN 6
|
|
|
|
#define ODROID_HW_VS_ADC_CHANNEL 1
|
|
|
|
#define MESON_SOC_ID_G12B 0x29
|
|
#define MESON_SOC_ID_SM1 0x2b
|
|
|
|
int mmc_get_env_dev(void)
|
|
{
|
|
if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
/* Variant detection is based on the ADC RAW values for the channel #1 */
|
|
static struct meson_odroid_boards {
|
|
unsigned int soc_id;
|
|
unsigned int adc_min;
|
|
unsigned int adc_max;
|
|
char *variant;
|
|
} boards[] = {
|
|
/* OdroidN2 rev 2018,7,23 */
|
|
{ MESON_SOC_ID_G12B, 80 * 4, 90 * 4, "n2" },
|
|
/* OdroidN2 rev 2018,12,6 */
|
|
{ MESON_SOC_ID_G12B, 160 * 4, 170 * 4, "n2" },
|
|
/* OdroidN2 rev 2019,1,17 */
|
|
{ MESON_SOC_ID_G12B, 245 * 4, 255 * 4, "n2" },
|
|
/* OdroidN2 rev 2019,2,7 */
|
|
{ MESON_SOC_ID_G12B, 330 * 4, 350 * 4, "n2" },
|
|
/* OdroidN2plus rev 2019,11,20 */
|
|
{ MESON_SOC_ID_G12B, 410 * 4, 430 * 4, "n2-plus" },
|
|
/* OdroidC4 rev 2020,01,29 */
|
|
{ MESON_SOC_ID_SM1, 80 * 4, 100 * 4, "c4" },
|
|
/* OdroidHC4 rev 2019,12,10 */
|
|
{ MESON_SOC_ID_SM1, 300 * 4, 320 * 4, "hc4" },
|
|
/* OdroidC4 rev 2019,11,29 */
|
|
{ MESON_SOC_ID_SM1, 335 * 4, 345 * 4, "c4" },
|
|
/* OdroidHC4 rev 2020,8,7 */
|
|
{ MESON_SOC_ID_SM1, 590 * 4, 610 * 4, "hc4" },
|
|
};
|
|
|
|
static void odroid_set_fdtfile(char *soc, char *variant)
|
|
{
|
|
char s[128];
|
|
|
|
snprintf(s, sizeof(s), "amlogic/meson-%s-odroid-%s.dtb", soc, variant);
|
|
env_set("fdtfile", s);
|
|
}
|
|
|
|
static int odroid_detect_variant(void)
|
|
{
|
|
char *variant = "", *soc = "";
|
|
unsigned int adcval = 0;
|
|
int ret, i, soc_id = 0;
|
|
|
|
if (of_machine_is_compatible("amlogic,sm1")) {
|
|
soc_id = MESON_SOC_ID_SM1;
|
|
soc = "sm1";
|
|
} else if (of_machine_is_compatible("amlogic,g12b")) {
|
|
soc_id = MESON_SOC_ID_G12B;
|
|
soc = "g12b";
|
|
} else {
|
|
return -1;
|
|
}
|
|
|
|
ret = adc_channel_single_shot("adc@9000", ODROID_HW_VS_ADC_CHANNEL,
|
|
&adcval);
|
|
if (ret)
|
|
return ret;
|
|
|
|
for (i = 0 ; i < ARRAY_SIZE(boards) ; ++i) {
|
|
if (soc_id == boards[i].soc_id &&
|
|
adcval >= boards[i].adc_min &&
|
|
adcval < boards[i].adc_max) {
|
|
variant = boards[i].variant;
|
|
break;
|
|
}
|
|
}
|
|
|
|
printf("Board variant: %s\n", variant);
|
|
env_set("variant", variant);
|
|
|
|
odroid_set_fdtfile(soc, variant);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int misc_init_r(void)
|
|
{
|
|
u8 mac_addr[MAC_ADDR_LEN];
|
|
char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
|
|
ssize_t len;
|
|
|
|
if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG) &&
|
|
meson_get_soc_rev(tmp, sizeof(tmp)) > 0)
|
|
env_set("soc_rev", tmp);
|
|
|
|
if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
|
|
len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
|
|
efuse_mac_addr, EFUSE_MAC_SIZE);
|
|
if (len != EFUSE_MAC_SIZE)
|
|
return 0;
|
|
|
|
/* MAC is stored in ASCII format, 1bytes = 2characters */
|
|
for (int i = 0; i < 6; i++) {
|
|
tmp[0] = efuse_mac_addr[i * 2];
|
|
tmp[1] = efuse_mac_addr[i * 2 + 1];
|
|
tmp[2] = '\0';
|
|
mac_addr[i] = hextoul(tmp, NULL);
|
|
}
|
|
|
|
if (is_valid_ethaddr(mac_addr))
|
|
eth_env_set_enetaddr("ethaddr", mac_addr);
|
|
else
|
|
meson_generate_serial_ethaddr();
|
|
}
|
|
|
|
odroid_detect_variant();
|
|
return 0;
|
|
}
|