mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-22 20:18:54 +00:00
V1.0.5
This commit is contained in:
86
bsp/artinchip/sys/g73x/ram_param.c
Normal file
86
bsp/artinchip/sys/g73x/ram_param.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2024 ArtInChip Technology Co.,Ltd
|
||||
* Author: Xiong Hao <hao.xiong@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <aic_core.h>
|
||||
#include <aic_common.h>
|
||||
#include <ram_param.h>
|
||||
|
||||
#define PSRAM_SINGLE 0
|
||||
#define PSRAM_PARALLEL 1
|
||||
|
||||
enum PSRAM_FUSE_ID {
|
||||
APS3208K = 0x00,
|
||||
SCKW18_12816O = 0x01,
|
||||
APS12816O = 0x02,
|
||||
};
|
||||
|
||||
struct _psram_id {
|
||||
u8 psram_fuse_id;
|
||||
u32 psram_chip_id;
|
||||
};
|
||||
|
||||
struct _psram_info {
|
||||
u8 mark_id;
|
||||
u8 psram_num;
|
||||
u32 psram_size;
|
||||
struct _psram_id psram_id;
|
||||
};
|
||||
|
||||
#define PSRAM_TABLE_INFO \
|
||||
{ \
|
||||
/* force use the cfg0 */ \
|
||||
{0x0, 0, 0, {0, 0}}, \
|
||||
/* G730CES NON PSRAM*/ \
|
||||
{0x21, 0, 0, {0, 0}}, \
|
||||
/* G730EES NON PSRAM*/ \
|
||||
{0x22, 0, 0, {0, 0}}, \
|
||||
}
|
||||
|
||||
struct _psram_info psram_table_info[] = PSRAM_TABLE_INFO;
|
||||
|
||||
u8 psram_get_mark_id(void)
|
||||
{
|
||||
u32 fuse_218 = readl(0x19010218);
|
||||
u8 mark_id = fuse_218 & 0xff;
|
||||
|
||||
pr_info("fuse_218(0x19010218)=0x%x, mark_id=0x%x\n", fuse_218, mark_id);
|
||||
return mark_id;
|
||||
}
|
||||
|
||||
u8 psram_get_psram_id(void)
|
||||
{
|
||||
u32 fuse_224 = readl(0x19010224);
|
||||
u8 psram_id = (fuse_224 & 0xff0000) >> 20;
|
||||
|
||||
pr_info("fuse_224(0x19010224)=0x%x, psram_id=0x%x\n", fuse_224, psram_id);
|
||||
return psram_id;
|
||||
}
|
||||
|
||||
struct _psram_info *psram_get_info(u8 mark_id, u8 psram_fuse_id)
|
||||
{
|
||||
u32 len = ARRAY_SIZE(psram_table_info);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (((mark_id == psram_table_info[i].mark_id) &&
|
||||
(psram_fuse_id == psram_table_info[i].psram_id.psram_fuse_id))) {
|
||||
return &psram_table_info[i];
|
||||
}
|
||||
}
|
||||
pr_info("can't get the psram table, return the default info.\n");
|
||||
return &psram_table_info[0]; //if not find anyone, return the default info.
|
||||
}
|
||||
|
||||
u32 aic_get_ram_size(void)
|
||||
{
|
||||
struct _psram_info *psram_info;
|
||||
u8 mark_id, psram_id;
|
||||
|
||||
mark_id = psram_get_mark_id();
|
||||
psram_id = psram_get_psram_id();
|
||||
psram_info = psram_get_info(mark_id, psram_id);
|
||||
|
||||
return psram_info->psram_size;
|
||||
}
|
||||
Reference in New Issue
Block a user