}
 }
 
+static void b5k_instruction_hazard(void)
+{
+       __sync();
+       __sync();
+       __asm__ __volatile__(
+       "       nop; nop; nop; nop; nop; nop; nop; nop\n"
+       "       nop; nop; nop; nop; nop; nop; nop; nop\n"
+       "       nop; nop; nop; nop; nop; nop; nop; nop\n"
+       "       nop; nop; nop; nop; nop; nop; nop; nop\n"
+       : : : "memory");
+}
+
 static char *way_string[] = { NULL, "direct mapped", "2-way",
        "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
 };
 
        coherency_setup();
        board_cache_error_setup = r4k_cache_error_setup;
+
+       /*
+        * Per-CPU overrides
+        */
+       switch (current_cpu_type()) {
+       case CPU_BMIPS4350:
+       case CPU_BMIPS4380:
+               /* No IPI is needed because all CPUs share the same D$ */
+               flush_data_cache_page = r4k_blast_dcache_page;
+               break;
+       case CPU_BMIPS5000:
+               /* We lose our superpowers if L2 is disabled */
+               if (c->scache.flags & MIPS_CACHE_NOT_PRESENT)
+                       break;
+
+               /* I$ fills from D$ just by emptying the write buffers */
+               flush_cache_page = (void *)b5k_instruction_hazard;
+               flush_cache_range = (void *)b5k_instruction_hazard;
+               flush_cache_sigtramp = (void *)b5k_instruction_hazard;
+               local_flush_data_cache_page = (void *)b5k_instruction_hazard;
+               flush_data_cache_page = (void *)b5k_instruction_hazard;
+               flush_icache_range = (void *)b5k_instruction_hazard;
+               local_flush_icache_range = (void *)b5k_instruction_hazard;
+
+               /* Cache aliases are handled in hardware; allow HIGHMEM */
+               current_cpu_data.dcache.flags &= ~MIPS_CACHE_ALIASES;
+
+               /* Optimization: an L2 flush implicitly flushes the L1 */
+               current_cpu_data.options |= MIPS_CPU_INCLUSIVE_CACHES;
+               break;
+       }
 }
 
 static int r4k_cache_pm_notifier(struct notifier_block *self, unsigned long cmd,