diff --git a/src/bridge/l2a.c b/src/bridge/l2a.c index ae717fc..ce6560f 100644 --- a/src/bridge/l2a.c +++ b/src/bridge/l2a.c @@ -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); @@ -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; @@ -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; @@ -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)); +}