mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-17 17:48:55 +00:00
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Mingfeng.Li <mingfeng.li@artinchip.com>
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <console.h>
|
|
#include <aic_core.h>
|
|
#include <aic_common.h>
|
|
#include <aic_errno.h>
|
|
#include <xspi_psram.h>
|
|
#include <hexdump.h>
|
|
|
|
#define BASE_DRAM (0x40000000)
|
|
#define PARALLEL_MODE 1
|
|
#define SINGLE_MODE 0
|
|
static u8 xspi_get_parallel_mode(void)
|
|
{
|
|
u32 val = readl(0x10300000);
|
|
return (u8)((val >> 6) & 0x01);
|
|
}
|
|
|
|
static int do_psram_test(int argc, char *argv[])
|
|
{
|
|
int len = 0x400000;
|
|
|
|
printf(" %s:%d BASE_DRAM=0x%x...\n", __FUNCTION__, __LINE__, BASE_DRAM);
|
|
aic_xspi_psram_probe();
|
|
printf(" %s:%d ...\n", __FUNCTION__, __LINE__);
|
|
if (xspi_get_parallel_mode() == PARALLEL_MODE) {
|
|
len = 0x800000;
|
|
printf(" %s:%d PARALLEL_MODE len=0x%x...\n", __FUNCTION__, __LINE__, len);
|
|
}else {
|
|
printf(" %s:%d SINGLE_MODE len=0x%x...\n", __FUNCTION__, __LINE__, len);
|
|
}
|
|
|
|
memset((void *)BASE_DRAM, 0x55, len/2);
|
|
hexdump((void *)BASE_DRAM, 0x40000, 4); //256k
|
|
printf(" %s:%d ...\n\n\n", __FUNCTION__, __LINE__);
|
|
hexdump((void *)BASE_DRAM+ (len/2) -0x40000, 0x40000, 4);
|
|
printf(" %s:%d ...\n\n\n", __FUNCTION__, __LINE__);
|
|
memset((void *)BASE_DRAM+(len/2), 0xaa, len/2);
|
|
hexdump((void *)BASE_DRAM+(len/2), 0x40000, 4);
|
|
printf(" %s:%d ...\n\n\n", __FUNCTION__, __LINE__);
|
|
hexdump((void *)BASE_DRAM + len - 0x40000, 0x40000, 4);
|
|
printf(" %s:%d ...\n\n\n", __FUNCTION__, __LINE__);
|
|
hexdump((void *)BASE_DRAM, 0x40000, 4);
|
|
|
|
return 0;
|
|
}
|
|
|
|
CONSOLE_CMD(test_psram, do_psram_test, "psram memory test ...");
|