Skip to content

Commit

Permalink
l2a: Add release and reinit implementations
Browse files Browse the repository at this point in the history
While we might be able to get away without it, if we're going to be
blocking for a while (such as while waiting for a wdt reset or
collecting a trace) it'd be nicer to restore the original values of
the HICR7 and HICR8 registers while doing so.

Signed-off-by: Zev Weiss <[email protected]>
  • Loading branch information
zevweiss committed Nov 16, 2023
1 parent 4527291 commit 4a53415
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions src/bridge/l2a.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,41 @@ static const struct ahb_ops l2ab_ahb_ops = {
.writel = l2ab_writel,
};

static int l2ab_save_hicr78(struct l2ab *ctx)
{
struct ilpcb *ilpcb = &ctx->ilpcb;
int rc;

rc = ilpcb_readl(ilpcb_as_ahb(ilpcb), LPC_HICR7, &ctx->restore7);
if (rc)
return rc;

return ilpcb_readl(ilpcb_as_ahb(ilpcb), LPC_HICR8, &ctx->restore8);
}

static int l2ab_restore_hicr78(struct l2ab *ctx)
{
struct ilpcb *ilpcb = &ctx->ilpcb;
int rc;

rc = ilpcb_writel(ilpcb_as_ahb(ilpcb), LPC_HICR8, ctx->restore8);
if (rc)
return rc;

return ilpcb_writel(ilpcb_as_ahb(ilpcb), LPC_HICR7, ctx->restore7);
}

static struct ahb *l2ab_driver_probe(int argc, char *argv[]);
static void l2ab_driver_destroy(struct ahb *ahb);
static int l2ab_driver_release(struct ahb *ahb);
static int l2ab_driver_reinit(struct ahb *ahb);

static struct bridge_driver l2ab_driver = {
.name = "l2a",
.probe = l2ab_driver_probe,
.destroy = l2ab_driver_destroy,
.reinit = l2ab_driver_reinit,
.release = l2ab_driver_release,
};
REGISTER_BRIDGE_DRIVER(l2ab_driver);

Expand All @@ -164,11 +192,7 @@ int l2ab_init(struct l2ab *ctx)
if (rc)
goto cleanup;

rc = ilpcb_readl(ilpcb_as_ahb(ilpcb), LPC_HICR7, &ctx->restore7);
if (rc)
goto cleanup;

rc = ilpcb_readl(ilpcb_as_ahb(ilpcb), LPC_HICR8, &ctx->restore8);
rc = l2ab_save_hicr78(ctx);
if (rc)
goto cleanup;

Expand All @@ -185,14 +209,9 @@ int l2ab_init(struct l2ab *ctx)

int l2ab_destroy(struct l2ab *ctx)
{
struct ilpcb *ilpcb = &ctx->ilpcb;
int rc;

rc = ilpcb_writel(ilpcb_as_ahb(ilpcb), LPC_HICR8, ctx->restore8);
if (rc)
return rc;

rc = ilpcb_writel(ilpcb_as_ahb(ilpcb), LPC_HICR7, ctx->restore7);
rc = l2ab_restore_hicr78(ctx);
if (rc)
return rc;

Expand Down Expand Up @@ -243,3 +262,13 @@ static void l2ab_driver_destroy(struct ahb *ahb)

free(ctx);
}

static int l2ab_driver_release(struct ahb *ahb)
{
return l2ab_restore_hicr78(to_l2ab(ahb));
}

static int l2ab_driver_reinit(struct ahb *ahb)
{
return l2ab_save_hicr78(to_l2ab(ahb));
}

0 comments on commit 4a53415

Please sign in to comment.