smp-bmips.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com)
  7. *
  8. * SMP support for BMIPS
  9. */
  10. #include <linux/init.h>
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/delay.h>
  14. #include <linux/smp.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/cpu.h>
  18. #include <linux/cpumask.h>
  19. #include <linux/reboot.h>
  20. #include <linux/io.h>
  21. #include <linux/compiler.h>
  22. #include <linux/linkage.h>
  23. #include <linux/bug.h>
  24. #include <linux/kernel.h>
  25. #include <asm/time.h>
  26. #include <asm/pgtable.h>
  27. #include <asm/processor.h>
  28. #include <asm/bootinfo.h>
  29. #include <asm/pmon.h>
  30. #include <asm/cacheflush.h>
  31. #include <asm/tlbflush.h>
  32. #include <asm/mipsregs.h>
  33. #include <asm/bmips.h>
  34. #include <asm/traps.h>
  35. #include <asm/barrier.h>
  36. #include <asm/cpu-features.h>
  37. static int __maybe_unused max_cpus = 1;
  38. /* these may be configured by the platform code */
  39. int bmips_smp_enabled = 1;
  40. int bmips_cpu_offset;
  41. cpumask_t bmips_booted_mask;
  42. unsigned long bmips_tp1_irqs = IE_IRQ1;
  43. #define RESET_FROM_KSEG0 0x80080800
  44. #define RESET_FROM_KSEG1 0xa0080800
  45. static void bmips_set_reset_vec(int cpu, u32 val);
  46. #ifdef CONFIG_SMP
  47. /* initial $sp, $gp - used by arch/mips/kernel/bmips_vec.S */
  48. unsigned long bmips_smp_boot_sp;
  49. unsigned long bmips_smp_boot_gp;
  50. static void bmips43xx_send_ipi_single(int cpu, unsigned int action);
  51. static void bmips5000_send_ipi_single(int cpu, unsigned int action);
  52. static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id);
  53. static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id);
  54. /* SW interrupts 0,1 are used for interprocessor signaling */
  55. #define IPI0_IRQ (MIPS_CPU_IRQ_BASE + 0)
  56. #define IPI1_IRQ (MIPS_CPU_IRQ_BASE + 1)
  57. #define CPUNUM(cpu, shift) (((cpu) + bmips_cpu_offset) << (shift))
  58. #define ACTION_CLR_IPI(cpu, ipi) (0x2000 | CPUNUM(cpu, 9) | ((ipi) << 8))
  59. #define ACTION_SET_IPI(cpu, ipi) (0x3000 | CPUNUM(cpu, 9) | ((ipi) << 8))
  60. #define ACTION_BOOT_THREAD(cpu) (0x08 | CPUNUM(cpu, 0))
  61. static void __init bmips_smp_setup(void)
  62. {
  63. int i, cpu = 1, boot_cpu = 0;
  64. int cpu_hw_intr;
  65. switch (current_cpu_type()) {
  66. case CPU_BMIPS4350:
  67. case CPU_BMIPS4380:
  68. /* arbitration priority */
  69. clear_c0_brcm_cmt_ctrl(0x30);
  70. /* NBK and weak order flags */
  71. set_c0_brcm_config_0(0x30000);
  72. /* Find out if we are running on TP0 or TP1 */
  73. boot_cpu = !!(read_c0_brcm_cmt_local() & (1 << 31));
  74. /*
  75. * MIPS interrupts 0,1 (SW INT 0,1) cross over to the other
  76. * thread
  77. * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output
  78. * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output
  79. */
  80. if (boot_cpu == 0)
  81. cpu_hw_intr = 0x02;
  82. else
  83. cpu_hw_intr = 0x1d;
  84. change_c0_brcm_cmt_intr(0xf8018000,
  85. (cpu_hw_intr << 27) | (0x03 << 15));
  86. /* single core, 2 threads (2 pipelines) */
  87. max_cpus = 2;
  88. break;
  89. case CPU_BMIPS5000:
  90. /* enable raceless SW interrupts */
  91. set_c0_brcm_config(0x03 << 22);
  92. /* route HW interrupt 0 to CPU0, HW interrupt 1 to CPU1 */
  93. change_c0_brcm_mode(0x1f << 27, 0x02 << 27);
  94. /* N cores, 2 threads per core */
  95. max_cpus = (((read_c0_brcm_config() >> 6) & 0x03) + 1) << 1;
  96. /* clear any pending SW interrupts */
  97. for (i = 0; i < max_cpus; i++) {
  98. write_c0_brcm_action(ACTION_CLR_IPI(i, 0));
  99. write_c0_brcm_action(ACTION_CLR_IPI(i, 1));
  100. }
  101. break;
  102. default:
  103. max_cpus = 1;
  104. }
  105. if (!bmips_smp_enabled)
  106. max_cpus = 1;
  107. /* this can be overridden by the BSP */
  108. if (!board_ebase_setup)
  109. board_ebase_setup = &bmips_ebase_setup;
  110. __cpu_number_map[boot_cpu] = 0;
  111. __cpu_logical_map[0] = boot_cpu;
  112. for (i = 0; i < max_cpus; i++) {
  113. if (i != boot_cpu) {
  114. __cpu_number_map[i] = cpu;
  115. __cpu_logical_map[cpu] = i;
  116. cpu++;
  117. }
  118. set_cpu_possible(i, 1);
  119. set_cpu_present(i, 1);
  120. }
  121. }
  122. /*
  123. * IPI IRQ setup - runs on CPU0
  124. */
  125. static void bmips_prepare_cpus(unsigned int max_cpus)
  126. {
  127. irqreturn_t (*bmips_ipi_interrupt)(int irq, void *dev_id);
  128. switch (current_cpu_type()) {
  129. case CPU_BMIPS4350:
  130. case CPU_BMIPS4380:
  131. bmips_ipi_interrupt = bmips43xx_ipi_interrupt;
  132. break;
  133. case CPU_BMIPS5000:
  134. bmips_ipi_interrupt = bmips5000_ipi_interrupt;
  135. break;
  136. default:
  137. return;
  138. }
  139. if (request_irq(IPI0_IRQ, bmips_ipi_interrupt,
  140. IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi0", NULL))
  141. panic("Can't request IPI0 interrupt");
  142. if (request_irq(IPI1_IRQ, bmips_ipi_interrupt,
  143. IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi1", NULL))
  144. panic("Can't request IPI1 interrupt");
  145. }
  146. /*
  147. * Tell the hardware to boot CPUx - runs on CPU0
  148. */
  149. static void bmips_boot_secondary(int cpu, struct task_struct *idle)
  150. {
  151. bmips_smp_boot_sp = __KSTK_TOS(idle);
  152. bmips_smp_boot_gp = (unsigned long)task_thread_info(idle);
  153. mb();
  154. /*
  155. * Initial boot sequence for secondary CPU:
  156. * bmips_reset_nmi_vec @ a000_0000 ->
  157. * bmips_smp_entry ->
  158. * plat_wired_tlb_setup (cached function call; optional) ->
  159. * start_secondary (cached jump)
  160. *
  161. * Warm restart sequence:
  162. * play_dead WAIT loop ->
  163. * bmips_smp_int_vec @ BMIPS_WARM_RESTART_VEC ->
  164. * eret to play_dead ->
  165. * bmips_secondary_reentry ->
  166. * start_secondary
  167. */
  168. pr_info("SMP: Booting CPU%d...\n", cpu);
  169. if (cpumask_test_cpu(cpu, &bmips_booted_mask)) {
  170. /* kseg1 might not exist if this CPU enabled XKS01 */
  171. bmips_set_reset_vec(cpu, RESET_FROM_KSEG0);
  172. switch (current_cpu_type()) {
  173. case CPU_BMIPS4350:
  174. case CPU_BMIPS4380:
  175. bmips43xx_send_ipi_single(cpu, 0);
  176. break;
  177. case CPU_BMIPS5000:
  178. bmips5000_send_ipi_single(cpu, 0);
  179. break;
  180. }
  181. } else {
  182. bmips_set_reset_vec(cpu, RESET_FROM_KSEG1);
  183. switch (current_cpu_type()) {
  184. case CPU_BMIPS4350:
  185. case CPU_BMIPS4380:
  186. /* Reset slave TP1 if booting from TP0 */
  187. if (cpu_logical_map(cpu) == 1)
  188. set_c0_brcm_cmt_ctrl(0x01);
  189. break;
  190. case CPU_BMIPS5000:
  191. write_c0_brcm_action(ACTION_BOOT_THREAD(cpu));
  192. break;
  193. }
  194. cpumask_set_cpu(cpu, &bmips_booted_mask);
  195. }
  196. }
  197. /*
  198. * Early setup - runs on secondary CPU after cache probe
  199. */
  200. static void bmips_init_secondary(void)
  201. {
  202. switch (current_cpu_type()) {
  203. case CPU_BMIPS4350:
  204. case CPU_BMIPS4380:
  205. clear_c0_cause(smp_processor_id() ? C_SW1 : C_SW0);
  206. break;
  207. case CPU_BMIPS5000:
  208. write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), 0));
  209. current_cpu_data.core = (read_c0_brcm_config() >> 25) & 3;
  210. break;
  211. }
  212. }
  213. /*
  214. * Late setup - runs on secondary CPU before entering the idle loop
  215. */
  216. static void bmips_smp_finish(void)
  217. {
  218. pr_info("SMP: CPU%d is running\n", smp_processor_id());
  219. /* make sure there won't be a timer interrupt for a little while */
  220. write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
  221. irq_enable_hazard();
  222. set_c0_status(IE_SW0 | IE_SW1 | bmips_tp1_irqs | IE_IRQ5 | ST0_IE);
  223. irq_enable_hazard();
  224. }
  225. /*
  226. * BMIPS5000 raceless IPIs
  227. *
  228. * Each CPU has two inbound SW IRQs which are independent of all other CPUs.
  229. * IPI0 is used for SMP_RESCHEDULE_YOURSELF
  230. * IPI1 is used for SMP_CALL_FUNCTION
  231. */
  232. static void bmips5000_send_ipi_single(int cpu, unsigned int action)
  233. {
  234. write_c0_brcm_action(ACTION_SET_IPI(cpu, action == SMP_CALL_FUNCTION));
  235. }
  236. static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id)
  237. {
  238. int action = irq - IPI0_IRQ;
  239. write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), action));
  240. if (action == 0)
  241. scheduler_ipi();
  242. else
  243. generic_smp_call_function_interrupt();
  244. return IRQ_HANDLED;
  245. }
  246. static void bmips5000_send_ipi_mask(const struct cpumask *mask,
  247. unsigned int action)
  248. {
  249. unsigned int i;
  250. for_each_cpu(i, mask)
  251. bmips5000_send_ipi_single(i, action);
  252. }
  253. /*
  254. * BMIPS43xx racey IPIs
  255. *
  256. * We use one inbound SW IRQ for each CPU.
  257. *
  258. * A spinlock must be held in order to keep CPUx from accidentally clearing
  259. * an incoming IPI when it writes CP0 CAUSE to raise an IPI on CPUy. The
  260. * same spinlock is used to protect the action masks.
  261. */
  262. static DEFINE_SPINLOCK(ipi_lock);
  263. static DEFINE_PER_CPU(int, ipi_action_mask);
  264. static void bmips43xx_send_ipi_single(int cpu, unsigned int action)
  265. {
  266. unsigned long flags;
  267. spin_lock_irqsave(&ipi_lock, flags);
  268. set_c0_cause(cpu ? C_SW1 : C_SW0);
  269. per_cpu(ipi_action_mask, cpu) |= action;
  270. irq_enable_hazard();
  271. spin_unlock_irqrestore(&ipi_lock, flags);
  272. }
  273. static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id)
  274. {
  275. unsigned long flags;
  276. int action, cpu = irq - IPI0_IRQ;
  277. spin_lock_irqsave(&ipi_lock, flags);
  278. action = __this_cpu_read(ipi_action_mask);
  279. per_cpu(ipi_action_mask, cpu) = 0;
  280. clear_c0_cause(cpu ? C_SW1 : C_SW0);
  281. spin_unlock_irqrestore(&ipi_lock, flags);
  282. if (action & SMP_RESCHEDULE_YOURSELF)
  283. scheduler_ipi();
  284. if (action & SMP_CALL_FUNCTION)
  285. generic_smp_call_function_interrupt();
  286. return IRQ_HANDLED;
  287. }
  288. static void bmips43xx_send_ipi_mask(const struct cpumask *mask,
  289. unsigned int action)
  290. {
  291. unsigned int i;
  292. for_each_cpu(i, mask)
  293. bmips43xx_send_ipi_single(i, action);
  294. }
  295. #ifdef CONFIG_HOTPLUG_CPU
  296. static int bmips_cpu_disable(void)
  297. {
  298. unsigned int cpu = smp_processor_id();
  299. if (cpu == 0)
  300. return -EBUSY;
  301. pr_info("SMP: CPU%d is offline\n", cpu);
  302. set_cpu_online(cpu, false);
  303. calculate_cpu_foreign_map();
  304. cpumask_clear_cpu(cpu, &cpu_callin_map);
  305. clear_c0_status(IE_IRQ5);
  306. local_flush_tlb_all();
  307. local_flush_icache_range(0, ~0);
  308. return 0;
  309. }
  310. static void bmips_cpu_die(unsigned int cpu)
  311. {
  312. }
  313. void __ref play_dead(void)
  314. {
  315. idle_task_exit();
  316. /* flush data cache */
  317. _dma_cache_wback_inv(0, ~0);
  318. /*
  319. * Wakeup is on SW0 or SW1; disable everything else
  320. * Use BEV !IV (BMIPS_WARM_RESTART_VEC) to avoid the regular Linux
  321. * IRQ handlers; this clears ST0_IE and returns immediately.
  322. */
  323. clear_c0_cause(CAUSEF_IV | C_SW0 | C_SW1);
  324. change_c0_status(
  325. IE_IRQ5 | bmips_tp1_irqs | IE_SW0 | IE_SW1 | ST0_IE | ST0_BEV,
  326. IE_SW0 | IE_SW1 | ST0_IE | ST0_BEV);
  327. irq_disable_hazard();
  328. /*
  329. * wait for SW interrupt from bmips_boot_secondary(), then jump
  330. * back to start_secondary()
  331. */
  332. __asm__ __volatile__(
  333. " wait\n"
  334. " j bmips_secondary_reentry\n"
  335. : : : "memory");
  336. }
  337. #endif /* CONFIG_HOTPLUG_CPU */
  338. struct plat_smp_ops bmips43xx_smp_ops = {
  339. .smp_setup = bmips_smp_setup,
  340. .prepare_cpus = bmips_prepare_cpus,
  341. .boot_secondary = bmips_boot_secondary,
  342. .smp_finish = bmips_smp_finish,
  343. .init_secondary = bmips_init_secondary,
  344. .send_ipi_single = bmips43xx_send_ipi_single,
  345. .send_ipi_mask = bmips43xx_send_ipi_mask,
  346. #ifdef CONFIG_HOTPLUG_CPU
  347. .cpu_disable = bmips_cpu_disable,
  348. .cpu_die = bmips_cpu_die,
  349. #endif
  350. };
  351. struct plat_smp_ops bmips5000_smp_ops = {
  352. .smp_setup = bmips_smp_setup,
  353. .prepare_cpus = bmips_prepare_cpus,
  354. .boot_secondary = bmips_boot_secondary,
  355. .smp_finish = bmips_smp_finish,
  356. .init_secondary = bmips_init_secondary,
  357. .send_ipi_single = bmips5000_send_ipi_single,
  358. .send_ipi_mask = bmips5000_send_ipi_mask,
  359. #ifdef CONFIG_HOTPLUG_CPU
  360. .cpu_disable = bmips_cpu_disable,
  361. .cpu_die = bmips_cpu_die,
  362. #endif
  363. };
  364. #endif /* CONFIG_SMP */
  365. /***********************************************************************
  366. * BMIPS vector relocation
  367. * This is primarily used for SMP boot, but it is applicable to some
  368. * UP BMIPS systems as well.
  369. ***********************************************************************/
  370. static void bmips_wr_vec(unsigned long dst, char *start, char *end)
  371. {
  372. memcpy((void *)dst, start, end - start);
  373. dma_cache_wback(dst, end - start);
  374. local_flush_icache_range(dst, dst + (end - start));
  375. instruction_hazard();
  376. }
  377. static inline void bmips_nmi_handler_setup(void)
  378. {
  379. bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec,
  380. &bmips_reset_nmi_vec_end);
  381. bmips_wr_vec(BMIPS_WARM_RESTART_VEC, &bmips_smp_int_vec,
  382. &bmips_smp_int_vec_end);
  383. }
  384. struct reset_vec_info {
  385. int cpu;
  386. u32 val;
  387. };
  388. static void bmips_set_reset_vec_remote(void *vinfo)
  389. {
  390. struct reset_vec_info *info = vinfo;
  391. int shift = info->cpu & 0x01 ? 16 : 0;
  392. u32 mask = ~(0xffff << shift), val = info->val >> 16;
  393. preempt_disable();
  394. if (smp_processor_id() > 0) {
  395. smp_call_function_single(0, &bmips_set_reset_vec_remote,
  396. info, 1);
  397. } else {
  398. if (info->cpu & 0x02) {
  399. /* BMIPS5200 "should" use mask/shift, but it's buggy */
  400. bmips_write_zscm_reg(0xa0, (val << 16) | val);
  401. bmips_read_zscm_reg(0xa0);
  402. } else {
  403. write_c0_brcm_bootvec((read_c0_brcm_bootvec() & mask) |
  404. (val << shift));
  405. }
  406. }
  407. preempt_enable();
  408. }
  409. static void bmips_set_reset_vec(int cpu, u32 val)
  410. {
  411. struct reset_vec_info info;
  412. if (current_cpu_type() == CPU_BMIPS5000) {
  413. /* this needs to run from CPU0 (which is always online) */
  414. info.cpu = cpu;
  415. info.val = val;
  416. bmips_set_reset_vec_remote(&info);
  417. } else {
  418. void __iomem *cbr = BMIPS_GET_CBR();
  419. if (cpu == 0)
  420. __raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0);
  421. else {
  422. if (current_cpu_type() != CPU_BMIPS4380)
  423. return;
  424. __raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
  425. }
  426. }
  427. __sync();
  428. back_to_back_c0_hazard();
  429. }
  430. void bmips_ebase_setup(void)
  431. {
  432. unsigned long new_ebase = ebase;
  433. BUG_ON(ebase != CKSEG0);
  434. switch (current_cpu_type()) {
  435. case CPU_BMIPS4350:
  436. /*
  437. * BMIPS4350 cannot relocate the normal vectors, but it
  438. * can relocate the BEV=1 vectors. So CPU1 starts up at
  439. * the relocated BEV=1, IV=0 general exception vector @
  440. * 0xa000_0380.
  441. *
  442. * set_uncached_handler() is used here because:
  443. * - CPU1 will run this from uncached space
  444. * - None of the cacheflush functions are set up yet
  445. */
  446. set_uncached_handler(BMIPS_WARM_RESTART_VEC - CKSEG0,
  447. &bmips_smp_int_vec, 0x80);
  448. __sync();
  449. return;
  450. case CPU_BMIPS3300:
  451. case CPU_BMIPS4380:
  452. /*
  453. * 0x8000_0000: reset/NMI (initially in kseg1)
  454. * 0x8000_0400: normal vectors
  455. */
  456. new_ebase = 0x80000400;
  457. bmips_set_reset_vec(0, RESET_FROM_KSEG0);
  458. break;
  459. case CPU_BMIPS5000:
  460. /*
  461. * 0x8000_0000: reset/NMI (initially in kseg1)
  462. * 0x8000_1000: normal vectors
  463. */
  464. new_ebase = 0x80001000;
  465. bmips_set_reset_vec(0, RESET_FROM_KSEG0);
  466. write_c0_ebase(new_ebase);
  467. break;
  468. default:
  469. return;
  470. }
  471. board_nmi_handler_setup = &bmips_nmi_handler_setup;
  472. ebase = new_ebase;
  473. }
  474. asmlinkage void __weak plat_wired_tlb_setup(void)
  475. {
  476. /*
  477. * Called when starting/restarting a secondary CPU.
  478. * Kernel stacks and other important data might only be accessible
  479. * once the wired entries are present.
  480. */
  481. }
  482. void __init bmips_cpu_setup(void)
  483. {
  484. void __iomem __maybe_unused *cbr = BMIPS_GET_CBR();
  485. u32 __maybe_unused cfg;
  486. switch (current_cpu_type()) {
  487. case CPU_BMIPS3300:
  488. /* Set BIU to async mode */
  489. set_c0_brcm_bus_pll(BIT(22));
  490. __sync();
  491. /* put the BIU back in sync mode */
  492. clear_c0_brcm_bus_pll(BIT(22));
  493. /* clear BHTD to enable branch history table */
  494. clear_c0_brcm_reset(BIT(16));
  495. /* Flush and enable RAC */
  496. cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
  497. __raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
  498. __raw_readl(cbr + BMIPS_RAC_CONFIG);
  499. cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
  500. __raw_writel(cfg | 0xf, cbr + BMIPS_RAC_CONFIG);
  501. __raw_readl(cbr + BMIPS_RAC_CONFIG);
  502. cfg = __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
  503. __raw_writel(cfg | 0x0fff0000, cbr + BMIPS_RAC_ADDRESS_RANGE);
  504. __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
  505. break;
  506. case CPU_BMIPS4380:
  507. /* CBG workaround for early BMIPS4380 CPUs */
  508. switch (read_c0_prid()) {
  509. case 0x2a040:
  510. case 0x2a042:
  511. case 0x2a044:
  512. case 0x2a060:
  513. cfg = __raw_readl(cbr + BMIPS_L2_CONFIG);
  514. __raw_writel(cfg & ~0x07000000, cbr + BMIPS_L2_CONFIG);
  515. __raw_readl(cbr + BMIPS_L2_CONFIG);
  516. }
  517. /* clear BHTD to enable branch history table */
  518. clear_c0_brcm_config_0(BIT(21));
  519. /* XI/ROTR enable */
  520. set_c0_brcm_config_0(BIT(23));
  521. set_c0_brcm_cmt_ctrl(BIT(15));
  522. break;
  523. case CPU_BMIPS5000:
  524. /* enable RDHWR, BRDHWR */
  525. set_c0_brcm_config(BIT(17) | BIT(21));
  526. /* Disable JTB */
  527. __asm__ __volatile__(
  528. " .set noreorder\n"
  529. " li $8, 0x5a455048\n"
  530. " .word 0x4088b00f\n" /* mtc0 t0, $22, 15 */
  531. " .word 0x4008b008\n" /* mfc0 t0, $22, 8 */
  532. " li $9, 0x00008000\n"
  533. " or $8, $8, $9\n"
  534. " .word 0x4088b008\n" /* mtc0 t0, $22, 8 */
  535. " sync\n"
  536. " li $8, 0x0\n"
  537. " .word 0x4088b00f\n" /* mtc0 t0, $22, 15 */
  538. " .set reorder\n"
  539. : : : "$8", "$9");
  540. /* XI enable */
  541. set_c0_brcm_config(BIT(27));
  542. /* enable MIPS32R2 ROR instruction for XI TLB handlers */
  543. __asm__ __volatile__(
  544. " li $8, 0x5a455048\n"
  545. " .word 0x4088b00f\n" /* mtc0 $8, $22, 15 */
  546. " nop; nop; nop\n"
  547. " .word 0x4008b008\n" /* mfc0 $8, $22, 8 */
  548. " lui $9, 0x0100\n"
  549. " or $8, $9\n"
  550. " .word 0x4088b008\n" /* mtc0 $8, $22, 8 */
  551. : : : "$8", "$9");
  552. break;
  553. }
  554. }