Skip to content

Commit e82da21

Browse files
committed
sh: Track the CPU family in sh_cpuinfo.
This adds a family member to struct sh_cpuinfo, which allows us to fall back more on the probe routines to work out what sort of subtype we are running on. This will be used by the CPU cache initialization code in order to first do family-level initialization, followed by subtype-level optimizations. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent aae4d14 commit e82da21

8 files changed

Lines changed: 39 additions & 15 deletions

File tree

‎arch/sh/include/asm/bugs.h‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ static void __init check_bugs(void)
2121

2222
current_cpu_data.loops_per_jiffy = loops_per_jiffy;
2323

24-
switch (current_cpu_data.type) {
25-
case CPU_SH7619:
24+
switch (current_cpu_data.family) {
25+
case CPU_FAMILY_SH2:
2626
*p++ = '2';
2727
break;
28-
case CPU_SH7201 ... CPU_MXG:
28+
case CPU_FAMILY_SH2A:
2929
*p++ = '2';
3030
*p++ = 'a';
3131
break;
32-
case CPU_SH7705 ... CPU_SH7729:
32+
case CPU_FAMILY_SH3:
3333
*p++ = '3';
3434
break;
35-
case CPU_SH7750 ... CPU_SH4_501:
35+
case CPU_FAMILY_SH4:
3636
*p++ = '4';
3737
break;
38-
case CPU_SH7763 ... CPU_SHX3:
38+
case CPU_FAMILY_SH4A:
3939
*p++ = '4';
4040
*p++ = 'a';
4141
break;
42-
case CPU_SH7343 ... CPU_SH7366:
42+
case CPU_FAMILY_SH4AL_DSP:
4343
*p++ = '4';
4444
*p++ = 'a';
4545
*p++ = 'l';
@@ -48,15 +48,15 @@ static void __init check_bugs(void)
4848
*p++ = 's';
4949
*p++ = 'p';
5050
break;
51-
case CPU_SH5_101 ... CPU_SH5_103:
51+
case CPU_FAMILY_SH5:
5252
*p++ = '6';
5353
*p++ = '4';
5454
break;
55-
case CPU_SH_NONE:
55+
case CPU_FAMILY_UNKNOWN:
5656
/*
57-
* Specifically use CPU_SH_NONE rather than default:,
58-
* so we're able to have the compiler whine about
59-
* unhandled enumerations.
57+
* Specifically use CPU_FAMILY_UNKNOWN rather than
58+
* default:, so we're able to have the compiler whine
59+
* about unhandled enumerations.
6060
*/
6161
break;
6262
}

‎arch/sh/include/asm/processor.h‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ enum cpu_type {
4444
CPU_SH_NONE
4545
};
4646

47+
enum cpu_family {
48+
CPU_FAMILY_SH2,
49+
CPU_FAMILY_SH2A,
50+
CPU_FAMILY_SH3,
51+
CPU_FAMILY_SH4,
52+
CPU_FAMILY_SH4A,
53+
CPU_FAMILY_SH4AL_DSP,
54+
CPU_FAMILY_SH5,
55+
CPU_FAMILY_UNKNOWN,
56+
};
57+
4758
/*
4859
* TLB information structure
4960
*
@@ -61,7 +72,7 @@ struct tlb_info {
6172
};
6273

6374
struct sh_cpuinfo {
64-
unsigned int type;
75+
unsigned int type, family;
6576
int cut_major, cut_minor;
6677
unsigned long loops_per_jiffy;
6778
unsigned long asid_cache;

‎arch/sh/kernel/cpu/sh2/probe.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int __init detect_cpu_and_cache_system(void)
2929
*/
3030
boot_cpu_data.dcache.flags |= SH_CACHE_COMBINED;
3131
boot_cpu_data.icache = boot_cpu_data.dcache;
32+
boot_cpu_data.family = CPU_FAMILY_SH2;
3233

3334
return 0;
3435
}

‎arch/sh/kernel/cpu/sh2a/probe.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
int __init detect_cpu_and_cache_system(void)
1717
{
18+
boot_cpu_data.family = CPU_FAMILY_SH2A;
19+
1820
/* All SH-2A CPUs have support for 16 and 32-bit opcodes.. */
1921
boot_cpu_data.flags |= CPU_HAS_OP32;
2022

‎arch/sh/kernel/cpu/sh3/probe.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,7 @@ int __uses_jump_to_uncached detect_cpu_and_cache_system(void)
107107
boot_cpu_data.dcache.flags |= SH_CACHE_COMBINED;
108108
boot_cpu_data.icache = boot_cpu_data.dcache;
109109

110+
boot_cpu_data.family = CPU_FAMILY_SH3;
111+
110112
return 0;
111113
}

‎arch/sh/kernel/cpu/sh4/probe.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ int __init detect_cpu_and_cache_system(void)
5757
* Setup some generic flags we can probe on SH-4A parts
5858
*/
5959
if (((pvr >> 16) & 0xff) == 0x10) {
60-
if ((cvr & 0x10000000) == 0)
60+
boot_cpu_data.family = CPU_FAMILY_SH4A;
61+
62+
if ((cvr & 0x10000000) == 0) {
6163
boot_cpu_data.flags |= CPU_HAS_DSP;
64+
boot_cpu_data.family = CPU_FAMILY_SH4AL_DSP;
65+
}
6266

6367
boot_cpu_data.flags |= CPU_HAS_LLSC | CPU_HAS_PERF_COUNTER;
6468
boot_cpu_data.cut_major = pvr & 0x7f;
@@ -68,6 +72,7 @@ int __init detect_cpu_and_cache_system(void)
6872
} else {
6973
/* And some SH-4 defaults.. */
7074
boot_cpu_data.flags |= CPU_HAS_PTEA;
75+
boot_cpu_data.family = CPU_FAMILY_SH4;
7176
}
7277

7378
/* FPU detection works for everyone */
@@ -174,7 +179,7 @@ int __init detect_cpu_and_cache_system(void)
174179

175180
break;
176181
default:
177-
boot_cpu_data.type = CPU_SH_NONE;
182+
boot_cpu_data.type = boot_cpu_data.family = CPU_SH_NONE;
178183
break;
179184
}
180185

‎arch/sh/kernel/cpu/sh5/probe.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ int __init detect_cpu_and_cache_system(void)
3434
/* CPU.VCR aliased at CIR address on SH5-101 */
3535
boot_cpu_data.type = CPU_SH5_101;
3636

37+
boot_cpu_data.family = CPU_FAMILY_SH5;
38+
3739
/*
3840
* First, setup some sane values for the I-cache.
3941
*/

‎arch/sh/kernel/setup.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
struct sh_cpuinfo cpu_data[NR_CPUS] __read_mostly = {
5050
[0] = {
5151
.type = CPU_SH_NONE,
52+
.family = CPU_FAMILY_UNKNOWN,
5253
.loops_per_jiffy = 10000000,
5354
},
5455
};

0 commit comments

Comments
 (0)