From 968079cb1800c87c97cc3a41be50c660e46778a2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 20 Feb 2022 13:55:32 +0000 Subject: [PATCH] fix dfi initialisation and calibration to use microwatt memory-io read/write (stwcix/lwzcix) --- libgram/src/calibration.c | 9 +++++---- libgram/src/dfii.c | 13 +++++++------ libgram/src/init.c | 4 ++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libgram/src/calibration.c b/libgram/src/calibration.c index a77c44a..bc1b223 100644 --- a/libgram/src/calibration.c +++ b/libgram/src/calibration.c @@ -5,6 +5,7 @@ #include #include "dfii.h" #include "helpers.h" +#include "io.h" static void set_rdly(const struct gramCtx *ctx, unsigned int phase, unsigned int rdly) { #ifdef GRAM_RW_FUNC @@ -15,9 +16,9 @@ static void set_rdly(const struct gramCtx *ctx, unsigned int phase, unsigned int } #else if (phase == 0) { - ctx->phy->rdly_p0 = rdly; + writel(rdly, (unsigned long)&ctx->phy->rdly_p0); } else if (phase == 1) { - ctx->phy->rdly_p1 = rdly; + writel(rdly, (unsigned long)&ctx->phy->rdly_p1); } #endif } @@ -26,7 +27,7 @@ void gram_reset_burstdet(const struct gramCtx *ctx) { #ifdef GRAM_RW_FUNC gram_write(ctx, (void*)&(ctx->phy->burstdet), 0); #else - ctx->phy->burstdet = 0; + writel(0, (unsigned long)&(ctx->phy->burstdet)); #endif } @@ -34,7 +35,7 @@ bool gram_read_burstdet(const struct gramCtx *ctx, int phase) { #ifdef GRAM_RW_FUNC return !!(gram_read(ctx, (void*)&(ctx->phy->burstdet)) & (1 << phase)); #else - return !!(ctx->phy->burstdet & (1 << phase)); + return !!(readl((unsigned long)&ctx->phy->burstdet) & (1 << phase)); #endif } diff --git a/libgram/src/dfii.c b/libgram/src/dfii.c index 58519bd..06aaf99 100644 --- a/libgram/src/dfii.c +++ b/libgram/src/dfii.c @@ -4,12 +4,13 @@ #include #include "dfii.h" #include "helpers.h" +#include "io.h" -static void dfii_setcontrol(const struct gramCtx *ctx, uint8_t val) { +static void dfii_setcontrol(const struct gramCtx *ctx, uint32_t val) { #ifdef GRAM_RW_FUNC gram_write(ctx, (void*)&(ctx->core->control), val); #else - ctx->core->control = val; + writel(val, (unsigned long)&(ctx->core->control)); #endif } @@ -25,7 +26,7 @@ void dfii_set_p0_address(const struct gramCtx *ctx, uint32_t val) { #ifdef GRAM_RW_FUNC gram_write(ctx, (void*)&(ctx->core->phases[0].address), val); #else - ctx->core->phases[0].address = val; + writel(val, (unsigned long)&ctx->core->phases[0].address); #endif } @@ -33,7 +34,7 @@ void dfii_set_p0_baddress(const struct gramCtx *ctx, uint32_t val) { #ifdef GRAM_RW_FUNC gram_write(ctx, (void*)&(ctx->core->phases[0].baddress), val); #else - ctx->core->phases[0].baddress = val; + writel(val, (unsigned long)&ctx->core->phases[0].baddress); #endif } @@ -42,8 +43,8 @@ void dfii_p0_command(const struct gramCtx *ctx, uint32_t cmd) { gram_write(ctx, (void*)&(ctx->core->phases[0].command), cmd); gram_write(ctx, (void*)&(ctx->core->phases[0].command_issue), 1); #else - ctx->core->phases[0].command = cmd; - ctx->core->phases[0].command_issue = 1; + writel(cmd, (unsigned long)&ctx->core->phases[0].command); + writel(1, (unsigned long)&ctx->core->phases[0].command_issue); #endif } diff --git a/libgram/src/init.c b/libgram/src/init.c index d869f0e..3d6c7a4 100644 --- a/libgram/src/init.c +++ b/libgram/src/init.c @@ -1,5 +1,6 @@ #include #include "dfii.h" +#include "console.h" int gram_init(struct gramCtx *ctx, const struct gramProfile *profile, void *ddr_base, void *core_base, void *phy_base) { ctx->ddr_base = ddr_base; @@ -7,8 +8,11 @@ int gram_init(struct gramCtx *ctx, const struct gramProfile *profile, void *ddr_ ctx->phy = phy_base; dfii_setsw(ctx, true); + puts("dfii_setsw\n"); dfii_initseq(ctx, profile); + puts("initseq\n"); gram_load_calibration(ctx, profile); + puts("cal"); dfii_setsw(ctx, false); return GRAM_ERR_NONE; -- 2.30.2