[main]add type for ddr command interface

This commit is contained in:
JianjunJiang 2021-05-26 11:26:25 +08:00
parent 298a80bc1d
commit a9acea8d71
6 changed files with 11 additions and 9 deletions

View File

@ -15,7 +15,7 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
return 0;
}
static int chip_ddr(struct xfel_ctx_t * ctx)
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
{
return 0;
}

View File

@ -22,7 +22,7 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
return 0;
}
static int chip_ddr(struct xfel_ctx_t * ctx)
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
{
return 0;
}

View File

@ -51,7 +51,7 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
return 1;
}
static int chip_ddr(struct xfel_ctx_t * ctx)
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
{
static const uint8_t dram_bin[] = {
0x02, 0x00, 0x00, 0xea, 0x00, 0x72, 0x02, 0x00, 0x00, 0x20, 0x02, 0x00,

4
fel.c
View File

@ -329,10 +329,10 @@ int fel_chip_jtag(struct xfel_ctx_t * ctx)
return 0;
}
int fel_chip_ddr(struct xfel_ctx_t * ctx)
int fel_chip_ddr(struct xfel_ctx_t * ctx, const char * type)
{
if(ctx && ctx->chip && ctx->chip->ddr)
return ctx->chip->ddr(ctx);
return ctx->chip->ddr(ctx, type);
return 0;
}

4
fel.h
View File

@ -34,7 +34,7 @@ struct chip_t {
int (*reset)(struct xfel_ctx_t * ctx);
int (*sid)(struct xfel_ctx_t * ctx, uint32_t * sid);
int (*jtag)(struct xfel_ctx_t * ctx);
int (*ddr)(struct xfel_ctx_t * ctx);
int (*ddr)(struct xfel_ctx_t * ctx, const char * type);
};
#define R32(reg) fel_read32(ctx, reg)
@ -50,7 +50,7 @@ void fel_write(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len, i
int fel_chip_reset(struct xfel_ctx_t * ctx);
int fel_chip_sid(struct xfel_ctx_t * ctx, uint32_t * sid);
int fel_chip_jtag(struct xfel_ctx_t * ctx);
int fel_chip_ddr(struct xfel_ctx_t * ctx);
int fel_chip_ddr(struct xfel_ctx_t * ctx, const char * type);
#ifdef __cplusplus
}

6
main.c
View File

@ -92,7 +92,7 @@ static void usage(void)
printf(" xfel reset - Reset device using watchdog\r\n");
printf(" xfel sid - Output 128-bits SID information\r\n");
printf(" xfel jtag - Enable JTAG debug\r\n");
printf(" xfel ddr - Initial DDR controller\r\n");
printf(" xfel ddr [type] - Initial DDR controller with optional type\r\n");
}
int main(int argc, char * argv[])
@ -269,7 +269,9 @@ int main(int argc, char * argv[])
}
else if(!strcmp(argv[1], "ddr"))
{
if(!fel_chip_ddr(&ctx))
argc -= 2;
argv += 2;
if(!fel_chip_ddr(&ctx, (argc == 1) ? argv[0] : NULL))
printf("The chip don't support '%s' command\r\n", argv[1]);
}
else