Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

MIPS: BMIPS: Add early CPU initialization code

Port the stblinux-3.3 code to perform a bunch of CPU-specific initialization,
make it compatible with run-time detection of the CPU, and unroll the
brcmstb-specific macros: BDEV_RB(), BDEV_UNSET.

The "pref 30" disabling is done as a quirk. This is a preliminary change to
allow the use of the "rotr" instruction gated by cpu_has_rixi.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Cc: john@phrozen.org
Cc: cernekee@gmail.com
Cc: jon.fraser@broadcom.com
Cc: pgynther@google.com
Cc: paul.burton@imgtec.com
Cc: ddaney.cavm@gmail.com
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/12504/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Florian Fainelli and committed by
Ralf Baechle
738a3f79 036aff91

+89
+1
arch/mips/bmips/setup.c
··· 111 111 112 112 void __init prom_init(void) 113 113 { 114 + bmips_cpu_setup(); 114 115 register_bmips_smp_ops(); 115 116 } 116 117
+1
arch/mips/include/asm/bmips.h
··· 88 88 89 89 extern void bmips_ebase_setup(void); 90 90 extern asmlinkage void plat_wired_tlb_setup(void); 91 + extern void bmips_cpu_setup(void); 91 92 92 93 static inline unsigned long bmips_read_zscm_reg(unsigned int offset) 93 94 {
+87
arch/mips/kernel/smp-bmips.c
··· 566 566 * once the wired entries are present. 567 567 */ 568 568 } 569 + 570 + void __init bmips_cpu_setup(void) 571 + { 572 + void __iomem __maybe_unused *cbr = BMIPS_GET_CBR(); 573 + u32 __maybe_unused cfg; 574 + 575 + switch (current_cpu_type()) { 576 + case CPU_BMIPS3300: 577 + /* Set BIU to async mode */ 578 + set_c0_brcm_bus_pll(BIT(22)); 579 + __sync(); 580 + 581 + /* put the BIU back in sync mode */ 582 + clear_c0_brcm_bus_pll(BIT(22)); 583 + 584 + /* clear BHTD to enable branch history table */ 585 + clear_c0_brcm_reset(BIT(16)); 586 + 587 + /* Flush and enable RAC */ 588 + cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); 589 + __raw_writel(cfg | 0x100, BMIPS_RAC_CONFIG); 590 + __raw_readl(cbr + BMIPS_RAC_CONFIG); 591 + 592 + cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG); 593 + __raw_writel(cfg | 0xf, BMIPS_RAC_CONFIG); 594 + __raw_readl(cbr + BMIPS_RAC_CONFIG); 595 + 596 + cfg = __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); 597 + __raw_writel(cfg | 0x0fff0000, cbr + BMIPS_RAC_ADDRESS_RANGE); 598 + __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE); 599 + break; 600 + 601 + case CPU_BMIPS4380: 602 + /* CBG workaround for early BMIPS4380 CPUs */ 603 + switch (read_c0_prid()) { 604 + case 0x2a040: 605 + case 0x2a042: 606 + case 0x2a044: 607 + case 0x2a060: 608 + cfg = __raw_readl(cbr + BMIPS_L2_CONFIG); 609 + __raw_writel(cfg & ~0x07000000, cbr + BMIPS_L2_CONFIG); 610 + __raw_readl(cbr + BMIPS_L2_CONFIG); 611 + } 612 + 613 + /* clear BHTD to enable branch history table */ 614 + clear_c0_brcm_config_0(BIT(21)); 615 + 616 + /* XI/ROTR enable */ 617 + set_c0_brcm_config_0(BIT(23)); 618 + set_c0_brcm_cmt_ctrl(BIT(15)); 619 + break; 620 + 621 + case CPU_BMIPS5000: 622 + /* enable RDHWR, BRDHWR */ 623 + set_c0_brcm_config(BIT(17) | BIT(21)); 624 + 625 + /* Disable JTB */ 626 + __asm__ __volatile__( 627 + " .set noreorder\n" 628 + " li $8, 0x5a455048\n" 629 + " .word 0x4088b00f\n" /* mtc0 t0, $22, 15 */ 630 + " .word 0x4008b008\n" /* mfc0 t0, $22, 8 */ 631 + " li $9, 0x00008000\n" 632 + " or $8, $8, $9\n" 633 + " .word 0x4088b008\n" /* mtc0 t0, $22, 8 */ 634 + " sync\n" 635 + " li $8, 0x0\n" 636 + " .word 0x4088b00f\n" /* mtc0 t0, $22, 15 */ 637 + " .set reorder\n" 638 + : : : "$8", "$9"); 639 + 640 + /* XI enable */ 641 + set_c0_brcm_config(BIT(27)); 642 + 643 + /* enable MIPS32R2 ROR instruction for XI TLB handlers */ 644 + __asm__ __volatile__( 645 + " li $8, 0x5a455048\n" 646 + " .word 0x4088b00f\n" /* mtc0 $8, $22, 15 */ 647 + " nop; nop; nop\n" 648 + " .word 0x4008b008\n" /* mfc0 $8, $22, 8 */ 649 + " lui $9, 0x0100\n" 650 + " or $8, $9\n" 651 + " .word 0x4088b008\n" /* mtc0 $8, $22, 8 */ 652 + : : : "$8", "$9"); 653 + break; 654 + } 655 + }