mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
drivers: net: fsl-mc: add a command which dumps the MC log
Extended fsl_mc command adding an extra option dump_log Signed-off-by: Cosmin-Florin Aluchenesei <aluchenesei.cosmin-florin@nxp.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
This commit is contained in:
parent
a48492679c
commit
ed06772a60
2 changed files with 97 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <image.h>
|
||||
#include <log.h>
|
||||
#include <malloc.h>
|
||||
#include <mapmem.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <linux/bug.h>
|
||||
#include <asm/io.h>
|
||||
|
@ -38,6 +39,16 @@
|
|||
#define MC_BOOT_ENV_VAR "mcinitcmd"
|
||||
#define MC_DRAM_BLOCK_DEFAULT_SIZE (512UL * 1024 * 1024)
|
||||
|
||||
#define MC_BUFFER_SIZE (1024 * 1024 * 16)
|
||||
#define MAGIC_MC 0x4d430100
|
||||
#define MC_FW_ADDR_MASK_LOW 0xE0000000
|
||||
#define MC_FW_ADDR_MASK_HIGH 0X1FFFF
|
||||
#define MC_STRUCT_BUFFER_OFFSET 0x01000000
|
||||
#define MC_OFFSET_DELTA MC_STRUCT_BUFFER_OFFSET
|
||||
|
||||
#define LOG_HEADER_FLAG_BUFFER_WRAPAROUND 0x80000000
|
||||
#define LAST_BYTE(a) ((a) & ~(LOG_HEADER_FLAG_BUFFER_WRAPAROUND))
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
static int mc_memset_resv_ram;
|
||||
static struct mc_version mc_ver_info;
|
||||
|
@ -1773,11 +1784,78 @@ err:
|
|||
return err;
|
||||
}
|
||||
|
||||
static void print_k_bytes(const void *buf, ssize_t *size)
|
||||
{
|
||||
while (*size > 0) {
|
||||
int count = printf("%s", (char *)buf);
|
||||
|
||||
buf += count;
|
||||
*size -= count;
|
||||
}
|
||||
}
|
||||
|
||||
static void mc_dump_log(void)
|
||||
{
|
||||
struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
|
||||
u64 high = in_le64(&mc_ccsr_regs->reg_mcfbahr) & MC_FW_ADDR_MASK_HIGH;
|
||||
u64 low = in_le64(&mc_ccsr_regs->reg_mcfbalr) & MC_FW_ADDR_MASK_LOW;
|
||||
u32 buf_len, wrapped, last_byte, magic, buf_start;
|
||||
u64 mc_addr = (high << 32) | low;
|
||||
struct log_header *header;
|
||||
ssize_t size, bytes_end;
|
||||
const void *end_of_data;
|
||||
const void *map_addr;
|
||||
const void *end_addr;
|
||||
const void *cur_ptr;
|
||||
const void *buf;
|
||||
|
||||
map_addr = map_sysmem(mc_addr + MC_STRUCT_BUFFER_OFFSET,
|
||||
MC_BUFFER_SIZE);
|
||||
header = (struct log_header *)map_addr;
|
||||
last_byte = in_le32(&header->last_byte);
|
||||
buf_len = in_le32(&header->buf_length);
|
||||
magic = in_le32(&header->magic_word);
|
||||
buf_start = in_le32(&header->buf_start);
|
||||
buf = map_addr + buf_start - MC_OFFSET_DELTA;
|
||||
end_addr = buf + buf_len;
|
||||
wrapped = last_byte & LOG_HEADER_FLAG_BUFFER_WRAPAROUND;
|
||||
end_of_data = buf + LAST_BYTE(last_byte);
|
||||
|
||||
if (magic != MAGIC_MC) {
|
||||
puts("Magic number is not valid\n");
|
||||
printf("expected = %08x, received = %08x\n", MAGIC_MC, magic);
|
||||
goto err_magic;
|
||||
}
|
||||
|
||||
if (wrapped && end_of_data != end_addr)
|
||||
cur_ptr = end_of_data + 1;
|
||||
else
|
||||
cur_ptr = buf;
|
||||
|
||||
if (cur_ptr <= end_of_data)
|
||||
size = end_of_data - cur_ptr;
|
||||
else
|
||||
size = (end_addr - cur_ptr) + (end_of_data - buf);
|
||||
|
||||
bytes_end = end_addr - cur_ptr;
|
||||
if (size > bytes_end) {
|
||||
print_k_bytes(cur_ptr, &bytes_end);
|
||||
|
||||
cur_ptr = buf;
|
||||
size -= bytes_end;
|
||||
}
|
||||
|
||||
print_k_bytes(buf, &size);
|
||||
|
||||
err_magic:
|
||||
unmap_sysmem(map_addr);
|
||||
}
|
||||
|
||||
static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
int err = 0;
|
||||
if (argc < 3)
|
||||
if (argc < 2)
|
||||
goto usage;
|
||||
|
||||
switch (argv[1][0]) {
|
||||
|
@ -1787,6 +1865,8 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
|
||||
u64 aiop_fw_addr;
|
||||
#endif
|
||||
if (argc < 3)
|
||||
goto usage;
|
||||
|
||||
sub_cmd = argv[2][0];
|
||||
|
||||
|
@ -1918,6 +1998,12 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
if (argc > 2)
|
||||
goto usage;
|
||||
|
||||
mc_dump_log();
|
||||
break;
|
||||
default:
|
||||
printf("Invalid option: %s\n", argv[1]);
|
||||
goto usage;
|
||||
|
@ -1936,6 +2022,7 @@ U_BOOT_CMD(
|
|||
"fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
|
||||
"fsl_mc apply spb [spb_addr] - Apply SPB Soft Parser Blob\n"
|
||||
"fsl_mc start aiop [FW_addr] - Start AIOP\n"
|
||||
"fsl_mc dump_log - Dump MC Log\n"
|
||||
);
|
||||
|
||||
void mc_env_boot(void)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2014 Freescale Semiconductor
|
||||
* Copyright 2021 NXP
|
||||
*/
|
||||
|
||||
#ifndef __FSL_MC_H__
|
||||
|
@ -52,6 +53,14 @@ struct mc_ccsr_registers {
|
|||
u32 reg_error[];
|
||||
};
|
||||
|
||||
struct log_header {
|
||||
u32 magic_word;
|
||||
char reserved[4];
|
||||
u32 buf_start;
|
||||
u32 buf_length;
|
||||
u32 last_byte;
|
||||
};
|
||||
|
||||
void fdt_fsl_mc_fixup_iommu_map_entry(void *blob);
|
||||
int get_mc_boot_status(void);
|
||||
int get_dpl_apply_status(void);
|
||||
|
|
Loading…
Reference in a new issue