Move the write-back-and-invalidate sequence out of andes_l2_disable() into andes_l2_flush_all() and expose it as the flush_all operation.
andes_l2_disable() calls andes_l2_flush_all() before clearing the enable bit, so disabling the cache works as before. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Randolph Lin <[email protected]> --- drivers/cache/cache-andes-l2.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/cache/cache-andes-l2.c b/drivers/cache/cache-andes-l2.c index 45a4f216b07..007b23af2b9 100644 --- a/drivers/cache/cache-andes-l2.c +++ b/drivers/cache/cache-andes-l2.c @@ -91,7 +91,7 @@ static int andes_l2_enable(struct udevice *dev) return 0; } -static int andes_l2_disable(struct udevice *dev) +static int andes_l2_flush_all(struct udevice *dev) { struct andes_l2_plat *plat = dev_get_plat(dev); volatile struct l2cache *regs = plat->regs; @@ -109,12 +109,23 @@ static int andes_l2_disable(struct udevice *dev) hang(); } } - clrbits_le32(®s->control, L2_ENABLE); } return 0; } +static int andes_l2_disable(struct udevice *dev) +{ + struct andes_l2_plat *plat = dev_get_plat(dev); + struct l2cache *regs = plat->regs; + + andes_l2_flush_all(dev); + if (regs) + clrbits_le32(®s->control, L2_ENABLE); + + return 0; +} + static int andes_l2_of_to_plat(struct udevice *dev) { struct andes_l2_plat *plat = dev_get_plat(dev); @@ -192,6 +203,7 @@ static const struct udevice_id andes_l2_cache_ids[] = { static const struct cache_ops andes_l2_cache_ops = { .enable = andes_l2_enable, .disable = andes_l2_disable, + .flush_all = andes_l2_flush_all, }; U_BOOT_DRIVER(andes_l2_cache) = { -- 2.34.1
