mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-02 17:41:08 +00:00
60f38d82c4
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEPVPGJshWBf4d9CyLd9zb2sjISdEFAl1RU+gACgkQd9zb2sjI SdE/OBAAgytrPuru4s5bBwIqBpMk2IbmNsuAOG6FY6plXpUyaYRsn+wUZikPkkif Wv9f/iB2Zv7wHtKnMbM8dafCViaMmU7m5mF71GS2Xt7dEfZZQWN/RWwKe5UfTVxF 7hI5RU6OQMN8kwEB/AJIoFzhxzND9I2E5gocAafGn+dakmxoNR54rr//7DGlULNM kOYucXV5oYwDxc14nUXkYP13UrKds0bN0iWk+s367uPUcUuzEprD+/LV0NYTqLMp udCE0RLEvA8b3TxZeR9skjPWwBFc7crzWRsVDBdKujmTEvsZdEoBo0FbqEn6nr1u m5Q2dMYn2TvRHL4t7fppeqAryjE6JPmyuHUE4F+umvIs3QOjijgTPmG3pC0Trb1Z +iXrcoBbv+/zCbt5TQpPqYwW9wp3VSHGZlY9NZKS+Lwo/+Kj+JEXjzmzpASO8ruU 5NCQE1mNZtb/i2UDN649NptoNSxV+jP5qjh9rJZuQMF5oL6e3UMrfz/d7EeWOvSY MKRZIGm+HEPXwR7dOleHAuHDHBZ5ztWGlYyNMjtgTvgHk499tvvZYQ00LrHU1Uze wKeK3uN5UQujcJf14wM2AhHZhB22ZUy4onshY8rI4lUq1oRpc8nZ+31R+xXmuC/o wt+KmyTdD4Eva1batGmM1zpl3bSgDndyBo5FNlWH1xY5jZU/6Ro= =M0sg -----END PGP SIGNATURE----- Merge tag 'u-boot-amlogic-20190812' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic - amlogic: add support for the SEI Robotic SEI510
181 lines
3.2 KiB
C
181 lines
3.2 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <asm/arch/boot.h>
|
|
#include <env.h>
|
|
#include <linux/libfdt.h>
|
|
#include <linux/err.h>
|
|
#include <asm/arch/mem.h>
|
|
#include <asm/arch/sm.h>
|
|
#include <asm/armv8/mmu.h>
|
|
#include <asm/unaligned.h>
|
|
#include <efi_loader.h>
|
|
|
|
#if CONFIG_IS_ENABLED(FASTBOOT)
|
|
#include <asm/psci.h>
|
|
#include <fastboot.h>
|
|
#endif
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
__weak int board_init(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int dram_init(void)
|
|
{
|
|
const fdt64_t *val;
|
|
int offset;
|
|
int len;
|
|
|
|
offset = fdt_path_offset(gd->fdt_blob, "/memory");
|
|
if (offset < 0)
|
|
return -EINVAL;
|
|
|
|
val = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
|
|
if (len < sizeof(*val) * 2)
|
|
return -EINVAL;
|
|
|
|
/* Use unaligned access since cache is still disabled */
|
|
gd->ram_size = get_unaligned_be64(&val[1]);
|
|
|
|
return 0;
|
|
}
|
|
|
|
__weak int meson_ft_board_setup(void *blob, bd_t *bd)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int ft_board_setup(void *blob, bd_t *bd)
|
|
{
|
|
meson_init_reserved_memory(blob);
|
|
|
|
return meson_ft_board_setup(blob, bd);
|
|
}
|
|
|
|
void meson_board_add_reserved_memory(void *fdt, u64 start, u64 size)
|
|
{
|
|
int ret;
|
|
|
|
ret = fdt_add_mem_rsv(fdt, start, size);
|
|
if (ret)
|
|
printf("Could not reserve zone @ 0x%llx\n", start);
|
|
|
|
if (IS_ENABLED(CONFIG_EFI_LOADER)) {
|
|
efi_add_memory_map(start,
|
|
ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
|
|
EFI_RESERVED_MEMORY_TYPE, false);
|
|
}
|
|
}
|
|
|
|
int meson_generate_serial_ethaddr(void)
|
|
{
|
|
u8 mac_addr[ARP_HLEN];
|
|
char serial[SM_SERIAL_SIZE];
|
|
u32 sid;
|
|
u16 sid16;
|
|
|
|
if (!meson_sm_get_serial(serial, SM_SERIAL_SIZE)) {
|
|
sid = crc32(0, (unsigned char *)serial, SM_SERIAL_SIZE);
|
|
sid16 = crc16_ccitt(0, (unsigned char *)serial, SM_SERIAL_SIZE);
|
|
|
|
/* Ensure the NIC specific bytes of the mac are not all 0 */
|
|
if ((sid & 0xffffff) == 0)
|
|
sid |= 0x800000;
|
|
|
|
/* Non OUI / registered MAC address */
|
|
mac_addr[0] = ((sid16 >> 8) & 0xfc) | 0x02;
|
|
mac_addr[1] = (sid16 >> 0) & 0xff;
|
|
mac_addr[2] = (sid >> 24) & 0xff;
|
|
mac_addr[3] = (sid >> 16) & 0xff;
|
|
mac_addr[4] = (sid >> 8) & 0xff;
|
|
mac_addr[5] = (sid >> 0) & 0xff;
|
|
|
|
eth_env_set_enetaddr("ethaddr", mac_addr);
|
|
} else
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void meson_set_boot_source(void)
|
|
{
|
|
const char *source;
|
|
|
|
switch (meson_get_boot_device()) {
|
|
case BOOT_DEVICE_EMMC:
|
|
source = "emmc";
|
|
break;
|
|
|
|
case BOOT_DEVICE_NAND:
|
|
source = "nand";
|
|
break;
|
|
|
|
case BOOT_DEVICE_SPI:
|
|
source = "spi";
|
|
break;
|
|
|
|
case BOOT_DEVICE_SD:
|
|
source = "sd";
|
|
break;
|
|
|
|
case BOOT_DEVICE_USB:
|
|
source = "usb";
|
|
break;
|
|
|
|
default:
|
|
source = "unknown";
|
|
}
|
|
|
|
env_set("boot_source", source);
|
|
}
|
|
|
|
__weak int meson_board_late_init(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int board_late_init(void)
|
|
{
|
|
meson_set_boot_source();
|
|
|
|
return meson_board_late_init();
|
|
}
|
|
|
|
#if CONFIG_IS_ENABLED(FASTBOOT)
|
|
static unsigned int reboot_reason = REBOOT_REASON_NORMAL;
|
|
|
|
int fastboot_set_reboot_flag()
|
|
{
|
|
reboot_reason = REBOOT_REASON_BOOTLOADER;
|
|
|
|
printf("Using reboot reason: 0x%x\n", reboot_reason);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void reset_cpu(ulong addr)
|
|
{
|
|
struct pt_regs regs;
|
|
|
|
regs.regs[0] = ARM_PSCI_0_2_FN_SYSTEM_RESET;
|
|
regs.regs[1] = reboot_reason;
|
|
|
|
printf("Rebooting with reason: 0x%lx\n", regs.regs[1]);
|
|
|
|
smc_call(®s);
|
|
|
|
while (1)
|
|
;
|
|
}
|
|
#else
|
|
void reset_cpu(ulong addr)
|
|
{
|
|
psci_system_reset();
|
|
}
|
|
#endif
|