Skip to content

add 3519DV500 #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static bool detect_and_set(const char *manufacturer,
static bool hw_detect_system() {
long uart_base = get_uart0_address();
switch (uart_base) {
#ifdef __arm__
#if defined(__aarch64__) || defined(__arm__)
// xm510
case 0x10030000:
return detect_and_set("Xiongmai", xm_detect_cpu, setup_hal_xm, 0);
Expand All @@ -132,6 +132,11 @@ static bool hw_detect_system() {
case 0x20080000:
return detect_and_set(VENDOR_HISI, hisi_detect_cpu, setup_hal_hisi,
0x20050000);
// hi3519DV500
case 0x11040000:
return detect_and_set(VENDOR_HISI, hisi_detect_cpu, setup_hal_hisi,
0x11020000);

#endif
default:
return generic_detect_cpu();
Expand Down Expand Up @@ -173,6 +178,8 @@ const char *getchipfamily() {
return "hi3516cv300";
case HISI_V4A:
return "hi3516cv500";
case HISI_V4B:
return "hi3519dv500";
case HISI_V4:
if (*chip_name == 'g')
return "gk7205v200";
Expand Down
15 changes: 15 additions & 0 deletions src/hal/hisi/hal_hisi.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ static uint32_t hisi_reg_temp(uint32_t read_addr, int temp_bitness,
// Temperature sensor (T-Sensor) control register
#define EV300_MISC_CTRL45 0x120280B4

// T-Sensor temperature record register 0
#define DV500_MISC_CTRL47 0x1102A008
// Temperature sensor (T-Sensor) control register
#define DV500_MISC_CTRL45 0x1102A000

static float hisi_get_temp() {
float tempo;
switch (chip_generation) {
Expand Down Expand Up @@ -553,6 +558,12 @@ static float hisi_get_temp() {
hisi_reg_temp(EV300_MISC_CTRL47, 10, EV300_MISC_CTRL45, 0xC3200000);
tempo = ((tempo - 117) / 798) * 165 - 40;
break;
case HISI_V4B:
// MISC_CTRL47 bit[9:0]
tempo =
hisi_reg_temp(DV500_MISC_CTRL47, 10, DV500_MISC_CTRL45, 0x60FA0000);
tempo = ((tempo - 136) / 793 * 165) - 40;
break;
default:
return NAN;
}
Expand Down Expand Up @@ -746,6 +757,10 @@ static const char *get_hisi_chip_id(uint32_t family_id, uint8_t scsysid0) {
// A new chip that was received in the OpenIPC lab 2023.07.28
chip_generation = HISI_V4;
return "7205V500";
//3519DV500
case 0x3519D500:
chip_generation = HISI_V4B;
return "3519DV500";
default:
fprintf(stderr, "Got unexpected ID 0x%x for HiSilicon\n", family_id);
return "unknown";
Expand Down
1 change: 1 addition & 0 deletions src/hal/hisi/hal_hisi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define HISI_V3 0x3516C300
#define HISI_V4 0x3516E300
#define HISI_V4A 0x3516C500
#define HISI_V4B 0x3519D500
#define HISI_3536C 0x3536C100
#define HISI_3536D 0x3536D100

Expand Down
4 changes: 3 additions & 1 deletion src/reginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,11 +2192,13 @@ static const muxctrl_reg_t **regs_by_chip() {
else if (IS_16DV200)
return DV200regs;
break;
case HISI_V4B:
return CV500regs;
case HISI_3536C:
return RCV100regs;
case HISI_3536D:
return DV100regs;
case INFINITY6:
case INFINITY6:
case INFINITY6B:
return I6B_regs;
case INFINITY6C:
Expand Down
17 changes: 13 additions & 4 deletions src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,24 @@ void restore_printk() {

bool get_pid_cmdline(pid_t godpid, char *cmdname) {
char sname[1024];

snprintf(sname, sizeof(sname), "/proc/%d/cmdline", godpid);
FILE *fp = fopen(sname, "r");


//////// /proc/10320000.usb30drd/ at 3519dv500 readed as /proc/10320000/ and call Segmentation fault
if (fp == NULL) {

fprintf(stderr, "Failed to open file %s \n" , sname);
return; // Handle error appropriately
}

if (fp && fgets(sname, sizeof(sname), fp)) {
if (cmdname)
strcpy(cmdname, sname);

fclose(fp);
fp = NULL; // Set to NULL to avoid double close
return true;
}

fclose(fp);
return false;
}
Expand Down Expand Up @@ -323,18 +330,20 @@ static unsigned long time_by_proc(const char *filename, char *shortname,
}

pid_t get_god_pid(char *shortname, size_t shortsz) {


DIR *dir = opendir("/proc");
if (!dir)
return -1;

unsigned long max = 0;
char sname[1024], prname[255], maxname[255] = {0};
pid_t godpid = -1, tmp;

struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
if (*entry->d_name && isdigit(entry->d_name[0])) {
snprintf(sname, sizeof(sname), "/proc/%s/stat", entry->d_name);

tmp = strtol(entry->d_name, NULL, 10);
if (get_pid_cmdline(tmp, NULL)) {
unsigned long curres = time_by_proc(sname, prname, sizeof(prname));
Expand Down