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

MIPS: Cleanup CP0 PRId and CP1 FPIR register access masks

Replace hardcoded CP0 PRId and CP1 FPIR register access masks throughout.
The change does not touch places that use shifted or partial masks.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5838/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Maciej W. Rozycki and committed by
Ralf Baechle
8ff374b9 b42b4f3a

+77 -45
+2 -1
arch/mips/alchemy/common/usb.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/spinlock.h> 16 16 #include <linux/syscore_ops.h> 17 + #include <asm/cpu.h> 17 18 #include <asm/mach-au1x00/au1000.h> 18 19 19 20 /* control register offsets */ ··· 359 358 { 360 359 #if defined(CONFIG_DMA_COHERENT) 361 360 /* Au1200 AB USB does not support coherent memory */ 362 - if (!(read_c0_prid() & 0xff)) { 361 + if (!(read_c0_prid() & PRID_REV_MASK)) { 363 362 printk(KERN_INFO "Au1200 USB: this is chip revision AB !!\n"); 364 363 printk(KERN_INFO "Au1200 USB: update your board or re-configure" 365 364 " the kernel\n");
+2 -2
arch/mips/bcm63xx/cpu.c
··· 306 306 307 307 switch (c->cputype) { 308 308 case CPU_BMIPS3300: 309 - if ((read_c0_prid() & 0xff00) != PRID_IMP_BMIPS3300_ALT) 309 + if ((read_c0_prid() & PRID_IMP_MASK) != PRID_IMP_BMIPS3300_ALT) 310 310 __cpu_name[cpu] = "Broadcom BCM6338"; 311 311 /* fall-through */ 312 312 case CPU_BMIPS32: 313 313 chipid_reg = BCM_6345_PERF_BASE; 314 314 break; 315 315 case CPU_BMIPS4350: 316 - switch ((read_c0_prid() & 0xff)) { 316 + switch ((read_c0_prid() & PRID_REV_MASK)) { 317 317 case 0x04: 318 318 chipid_reg = BCM_3368_PERF_BASE; 319 319 break;
+29 -9
arch/mips/include/asm/cpu.h
··· 3 3 * various MIPS cpu types. 4 4 * 5 5 * Copyright (C) 1996 David S. Miller (davem@davemloft.net) 6 - * Copyright (C) 2004 Maciej W. Rozycki 6 + * Copyright (C) 2004, 2013 Maciej W. Rozycki 7 7 */ 8 8 #ifndef _ASM_CPU_H 9 9 #define _ASM_CPU_H 10 10 11 - /* Assigned Company values for bits 23:16 of the PRId Register 12 - (CP0 register 15, select 0). As of the MIPS32 and MIPS64 specs from 13 - MTI, the PRId register is defined in this (backwards compatible) 14 - way: 11 + /* 12 + As of the MIPS32 and MIPS64 specs from MTI, the PRId register (CP0 13 + register 15, select 0) is defined in this (backwards compatible) way: 15 14 16 15 +----------------+----------------+----------------+----------------+ 17 16 | Company Options| Company ID | Processor ID | Revision | ··· 21 22 that bits 16-23 have been 0 for all MIPS processors before the MIPS32/64 22 23 spec. 23 24 */ 25 + 26 + #define PRID_OPT_MASK 0xff000000 27 + 28 + /* 29 + * Assigned Company values for bits 23:16 of the PRId register. 30 + */ 31 + 32 + #define PRID_COMP_MASK 0xff0000 24 33 25 34 #define PRID_COMP_LEGACY 0x000000 26 35 #define PRID_COMP_MIPS 0x010000 ··· 45 38 #define PRID_COMP_INGENIC 0xd00000 46 39 47 40 /* 48 - * Assigned values for the product ID register. In order to detect a 49 - * certain CPU type exactly eventually additional registers may need to 50 - * be examined. These are valid when 23:16 == PRID_COMP_LEGACY 41 + * Assigned Processor ID (implementation) values for bits 15:8 of the PRId 42 + * register. In order to detect a certain CPU type exactly eventually 43 + * additional registers may need to be examined. 51 44 */ 45 + 46 + #define PRID_IMP_MASK 0xff00 47 + 48 + /* 49 + * These are valid when 23:16 == PRID_COMP_LEGACY 50 + */ 51 + 52 52 #define PRID_IMP_R2000 0x0100 53 53 #define PRID_IMP_AU1_REV1 0x0100 54 54 #define PRID_IMP_AU1_REV2 0x0200 ··· 196 182 #define PRID_IMP_NETLOGIC_XLP2XX 0x1200 197 183 198 184 /* 199 - * Definitions for 7:0 on legacy processors 185 + * Particular Revision values for bits 7:0 of the PRId register. 200 186 */ 201 187 202 188 #define PRID_REV_MASK 0x00ff 189 + 190 + /* 191 + * Definitions for 7:0 on legacy processors 192 + */ 203 193 204 194 #define PRID_REV_TX4927 0x0022 205 195 #define PRID_REV_TX4937 0x0030 ··· 244 226 * +---------------------------------+----------------+----------------+ 245 227 * 31 16 15 8 7 0 246 228 */ 229 + 230 + #define FPIR_IMP_MASK 0xff00 247 231 248 232 #define FPIR_IMP_NONE 0x0000 249 233
+3 -1
arch/mips/include/asm/mach-au1x00/au1000.h
··· 43 43 #include <linux/io.h> 44 44 #include <linux/irq.h> 45 45 46 + #include <asm/cpu.h> 47 + 46 48 /* cpu pipeline flush */ 47 49 void static inline au_sync(void) 48 50 { ··· 142 140 143 141 static inline int alchemy_get_cputype(void) 144 142 { 145 - switch (read_c0_prid() & 0xffff0000) { 143 + switch (read_c0_prid() & (PRID_OPT_MASK | PRID_COMP_MASK)) { 146 144 case 0x00030000: 147 145 return ALCHEMY_CPU_AU1000; 148 146 break;
+22 -20
arch/mips/kernel/cpu-probe.c
··· 123 123 */ 124 124 static inline int __cpu_has_fpu(void) 125 125 { 126 - return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE); 126 + return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE); 127 127 } 128 128 129 129 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) ··· 323 323 324 324 static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) 325 325 { 326 - switch (c->processor_id & 0xff00) { 326 + switch (c->processor_id & PRID_IMP_MASK) { 327 327 case PRID_IMP_R2000: 328 328 c->cputype = CPU_R2000; 329 329 __cpu_name[cpu] = "R2000"; ··· 334 334 c->tlbsize = 64; 335 335 break; 336 336 case PRID_IMP_R3000: 337 - if ((c->processor_id & 0xff) == PRID_REV_R3000A) { 337 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) { 338 338 if (cpu_has_confreg()) { 339 339 c->cputype = CPU_R3081E; 340 340 __cpu_name[cpu] = "R3081"; ··· 354 354 break; 355 355 case PRID_IMP_R4000: 356 356 if (read_c0_config() & CONF_SC) { 357 - if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 357 + if ((c->processor_id & PRID_REV_MASK) >= 358 + PRID_REV_R4400) { 358 359 c->cputype = CPU_R4400PC; 359 360 __cpu_name[cpu] = "R4400PC"; 360 361 } else { ··· 363 362 __cpu_name[cpu] = "R4000PC"; 364 363 } 365 364 } else { 366 - if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 365 + if ((c->processor_id & PRID_REV_MASK) >= 366 + PRID_REV_R4400) { 367 367 c->cputype = CPU_R4400SC; 368 368 __cpu_name[cpu] = "R4400SC"; 369 369 } else { ··· 457 455 __cpu_name[cpu] = "TX3927"; 458 456 c->tlbsize = 64; 459 457 } else { 460 - switch (c->processor_id & 0xff) { 458 + switch (c->processor_id & PRID_REV_MASK) { 461 459 case PRID_REV_TX3912: 462 460 c->cputype = CPU_TX3912; 463 461 __cpu_name[cpu] = "TX3912"; ··· 643 641 static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) 644 642 { 645 643 decode_configs(c); 646 - switch (c->processor_id & 0xff00) { 644 + switch (c->processor_id & PRID_IMP_MASK) { 647 645 case PRID_IMP_4KC: 648 646 c->cputype = CPU_4KC; 649 647 __cpu_name[cpu] = "MIPS 4Kc"; ··· 714 712 static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu) 715 713 { 716 714 decode_configs(c); 717 - switch (c->processor_id & 0xff00) { 715 + switch (c->processor_id & PRID_IMP_MASK) { 718 716 case PRID_IMP_AU1_REV1: 719 717 case PRID_IMP_AU1_REV2: 720 718 c->cputype = CPU_ALCHEMY; ··· 733 731 break; 734 732 case 4: 735 733 __cpu_name[cpu] = "Au1200"; 736 - if ((c->processor_id & 0xff) == 2) 734 + if ((c->processor_id & PRID_REV_MASK) == 2) 737 735 __cpu_name[cpu] = "Au1250"; 738 736 break; 739 737 case 5: ··· 751 749 { 752 750 decode_configs(c); 753 751 754 - switch (c->processor_id & 0xff00) { 752 + switch (c->processor_id & PRID_IMP_MASK) { 755 753 case PRID_IMP_SB1: 756 754 c->cputype = CPU_SB1; 757 755 __cpu_name[cpu] = "SiByte SB1"; 758 756 /* FPU in pass1 is known to have issues. */ 759 - if ((c->processor_id & 0xff) < 0x02) 757 + if ((c->processor_id & PRID_REV_MASK) < 0x02) 760 758 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); 761 759 break; 762 760 case PRID_IMP_SB1A: ··· 769 767 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu) 770 768 { 771 769 decode_configs(c); 772 - switch (c->processor_id & 0xff00) { 770 + switch (c->processor_id & PRID_IMP_MASK) { 773 771 case PRID_IMP_SR71000: 774 772 c->cputype = CPU_SR71000; 775 773 __cpu_name[cpu] = "Sandcraft SR71000"; ··· 782 780 static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu) 783 781 { 784 782 decode_configs(c); 785 - switch (c->processor_id & 0xff00) { 783 + switch (c->processor_id & PRID_IMP_MASK) { 786 784 case PRID_IMP_PR4450: 787 785 c->cputype = CPU_PR4450; 788 786 __cpu_name[cpu] = "Philips PR4450"; ··· 794 792 static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) 795 793 { 796 794 decode_configs(c); 797 - switch (c->processor_id & 0xff00) { 795 + switch (c->processor_id & PRID_IMP_MASK) { 798 796 case PRID_IMP_BMIPS32_REV4: 799 797 case PRID_IMP_BMIPS32_REV8: 800 798 c->cputype = CPU_BMIPS32; ··· 809 807 set_elf_platform(cpu, "bmips3300"); 810 808 break; 811 809 case PRID_IMP_BMIPS43XX: { 812 - int rev = c->processor_id & 0xff; 810 + int rev = c->processor_id & PRID_REV_MASK; 813 811 814 812 if (rev >= PRID_REV_BMIPS4380_LO && 815 813 rev <= PRID_REV_BMIPS4380_HI) { ··· 835 833 static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu) 836 834 { 837 835 decode_configs(c); 838 - switch (c->processor_id & 0xff00) { 836 + switch (c->processor_id & PRID_IMP_MASK) { 839 837 case PRID_IMP_CAVIUM_CN38XX: 840 838 case PRID_IMP_CAVIUM_CN31XX: 841 839 case PRID_IMP_CAVIUM_CN30XX: ··· 878 876 decode_configs(c); 879 877 /* JZRISC does not implement the CP0 counter. */ 880 878 c->options &= ~MIPS_CPU_COUNTER; 881 - switch (c->processor_id & 0xff00) { 879 + switch (c->processor_id & PRID_IMP_MASK) { 882 880 case PRID_IMP_JZRISC: 883 881 c->cputype = CPU_JZRISC; 884 882 __cpu_name[cpu] = "Ingenic JZRISC"; ··· 893 891 { 894 892 decode_configs(c); 895 893 896 - if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) { 894 + if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) { 897 895 c->cputype = CPU_ALCHEMY; 898 896 __cpu_name[cpu] = "Au1300"; 899 897 /* following stuff is not for Alchemy */ ··· 908 906 MIPS_CPU_EJTAG | 909 907 MIPS_CPU_LLSC); 910 908 911 - switch (c->processor_id & 0xff00) { 909 + switch (c->processor_id & PRID_IMP_MASK) { 912 910 case PRID_IMP_NETLOGIC_XLP2XX: 913 911 c->cputype = CPU_XLP; 914 912 __cpu_name[cpu] = "Broadcom XLPII"; ··· 987 985 c->cputype = CPU_UNKNOWN; 988 986 989 987 c->processor_id = read_c0_prid(); 990 - switch (c->processor_id & 0xff0000) { 988 + switch (c->processor_id & PRID_COMP_MASK) { 991 989 case PRID_COMP_LEGACY: 992 990 cpu_probe_legacy(c, cpu); 993 991 break;
+6 -5
arch/mips/mm/c-r4k.c
··· 792 792 * aliases. In this case it is better to treat the cache as always 793 793 * having aliases. 794 794 */ 795 - if ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(2, 4, 0)) 795 + if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_ENCODE_332(2, 4, 0)) 796 796 c->dcache.flags |= MIPS_CACHE_VTAG; 797 - if ((c->processor_id & 0xff) == PRID_REV_ENCODE_332(2, 4, 0)) 797 + if ((c->processor_id & PRID_REV_MASK) == PRID_REV_ENCODE_332(2, 4, 0)) 798 798 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); 799 - if (((c->processor_id & 0xff00) == PRID_IMP_1074K) && 800 - ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(1, 1, 0))) { 799 + if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_1074K && 800 + (c->processor_id & PRID_REV_MASK) <= PRID_REV_ENCODE_332(1, 1, 0)) { 801 801 c->dcache.flags |= MIPS_CACHE_VTAG; 802 802 write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND); 803 803 } ··· 1031 1031 * presumably no vendor is shipping his hardware in the "bad" 1032 1032 * configuration. 1033 1033 */ 1034 - if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 && 1034 + if ((prid & PRID_IMP_MASK) == PRID_IMP_R4000 && 1035 + (prid & PRID_REV_MASK) < PRID_REV_R4400 && 1035 1036 !(config & CONF_SC) && c->icache.linesz != 16 && 1036 1037 PAGE_SIZE <= 0x8000) 1037 1038 panic("Improper R4000SC processor configuration detected");
+3 -2
arch/mips/mti-malta/malta-time.c
··· 27 27 #include <linux/timex.h> 28 28 #include <linux/mc146818rtc.h> 29 29 30 + #include <asm/cpu.h> 30 31 #include <asm/mipsregs.h> 31 32 #include <asm/mipsmtregs.h> 32 33 #include <asm/hardirq.h> ··· 77 76 #endif 78 77 79 78 #if defined (CONFIG_KVM_GUEST) && defined (CONFIG_KVM_HOST_FREQ) 80 - unsigned int prid = read_c0_prid() & 0xffff00; 79 + unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK); 81 80 82 81 /* 83 82 * XXXKYMA: hardwire the CPU frequency to Host Freq/4 ··· 170 169 171 170 void __init plat_time_init(void) 172 171 { 173 - unsigned int prid = read_c0_prid() & 0xffff00; 172 + unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK); 174 173 unsigned int freq; 175 174 176 175 estimate_frequencies();
+2 -1
arch/mips/mti-sead3/sead3-time.c
··· 7 7 */ 8 8 #include <linux/init.h> 9 9 10 + #include <asm/cpu.h> 10 11 #include <asm/setup.h> 11 12 #include <asm/time.h> 12 13 #include <asm/irq.h> ··· 35 34 */ 36 35 static unsigned int __init estimate_cpu_frequency(void) 37 36 { 38 - unsigned int prid = read_c0_prid() & 0xffff00; 37 + unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK); 39 38 unsigned int tick = 0; 40 39 unsigned int freq; 41 40 unsigned int orig;
+2 -1
arch/mips/netlogic/xlr/fmn-config.c
··· 36 36 #include <linux/irq.h> 37 37 #include <linux/interrupt.h> 38 38 39 + #include <asm/cpu.h> 39 40 #include <asm/mipsregs.h> 40 41 #include <asm/netlogic/xlr/fmn.h> 41 42 #include <asm/netlogic/xlr/xlr.h> ··· 188 187 int processor_id, num_core; 189 188 190 189 num_core = hweight32(nlm_current_node()->coremask); 191 - processor_id = read_c0_prid() & 0xff00; 190 + processor_id = read_c0_prid() & PRID_IMP_MASK; 192 191 193 192 setup_cpu_fmninfo(cpu, num_core); 194 193 switch (processor_id) {
+2 -1
arch/mips/sibyte/bcm1480/setup.c
··· 22 22 #include <linux/string.h> 23 23 24 24 #include <asm/bootinfo.h> 25 + #include <asm/cpu.h> 25 26 #include <asm/mipsregs.h> 26 27 #include <asm/io.h> 27 28 #include <asm/sibyte/sb1250.h> ··· 120 119 uint64_t sys_rev; 121 120 int plldiv; 122 121 123 - sb1_pass = read_c0_prid() & 0xff; 122 + sb1_pass = read_c0_prid() & PRID_REV_MASK; 124 123 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); 125 124 soc_type = SYS_SOC_TYPE(sys_rev); 126 125 part_type = G_SYS_PART(sys_rev);
+2 -1
arch/mips/sibyte/sb1250/setup.c
··· 22 22 #include <linux/string.h> 23 23 24 24 #include <asm/bootinfo.h> 25 + #include <asm/cpu.h> 25 26 #include <asm/mipsregs.h> 26 27 #include <asm/io.h> 27 28 #include <asm/sibyte/sb1250.h> ··· 183 182 int plldiv; 184 183 int bad_config = 0; 185 184 186 - sb1_pass = read_c0_prid() & 0xff; 185 + sb1_pass = read_c0_prid() & PRID_REV_MASK; 187 186 sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); 188 187 soc_type = SYS_SOC_TYPE(sys_rev); 189 188 soc_pass = G_SYS_REVISION(sys_rev);
+2 -1
arch/mips/sni/setup.c
··· 25 25 #endif 26 26 27 27 #include <asm/bootinfo.h> 28 + #include <asm/cpu.h> 28 29 #include <asm/io.h> 29 30 #include <asm/reboot.h> 30 31 #include <asm/sni.h> ··· 174 173 system_type = "RM300-Cxx"; 175 174 break; 176 175 case SNI_BRD_PCI_DESKTOP: 177 - switch (read_c0_prid() & 0xff00) { 176 + switch (read_c0_prid() & PRID_IMP_MASK) { 178 177 case PRID_IMP_R4600: 179 178 case PRID_IMP_R4700: 180 179 system_type = "RM200-C20";