xref: /openbmc/linux/arch/sh/include/asm/processor.h (revision b24413180f5600bcb3bb70fbed5cf186b60864bd)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_PROCESSOR_H
3f15cbe6fSPaul Mundt #define __ASM_SH_PROCESSOR_H
4f15cbe6fSPaul Mundt 
5f15cbe6fSPaul Mundt #include <asm/cpu-features.h>
6f15cbe6fSPaul Mundt #include <asm/segment.h>
781b66995SPaul Mundt #include <asm/cache.h>
8f15cbe6fSPaul Mundt 
9f15cbe6fSPaul Mundt #ifndef __ASSEMBLY__
10f15cbe6fSPaul Mundt /*
11f15cbe6fSPaul Mundt  *  CPU type and hardware bug flags. Kept separately for each CPU.
12f15cbe6fSPaul Mundt  *
13f15cbe6fSPaul Mundt  *  Each one of these also needs a CONFIG_CPU_SUBTYPE_xxx entry
14f15cbe6fSPaul Mundt  *  in arch/sh/mm/Kconfig, as well as an entry in arch/sh/kernel/setup.c
15f15cbe6fSPaul Mundt  *  for parsing the subtype in get_cpu_subtype().
16f15cbe6fSPaul Mundt  */
17f15cbe6fSPaul Mundt enum cpu_type {
18f15cbe6fSPaul Mundt 	/* SH-2 types */
195a846abaSRich Felker 	CPU_SH7619, CPU_J2,
20f15cbe6fSPaul Mundt 
21f15cbe6fSPaul Mundt 	/* SH-2A types */
220b25b7c8SPhil Edworthy 	CPU_SH7201, CPU_SH7203, CPU_SH7206, CPU_SH7263, CPU_SH7264, CPU_SH7269,
230b25b7c8SPhil Edworthy 	CPU_MXG,
24f15cbe6fSPaul Mundt 
25f15cbe6fSPaul Mundt 	/* SH-3 types */
26f15cbe6fSPaul Mundt 	CPU_SH7705, CPU_SH7706, CPU_SH7707,
27f15cbe6fSPaul Mundt 	CPU_SH7708, CPU_SH7708S, CPU_SH7708R,
28f15cbe6fSPaul Mundt 	CPU_SH7709, CPU_SH7709A, CPU_SH7710, CPU_SH7712,
29f15cbe6fSPaul Mundt 	CPU_SH7720, CPU_SH7721, CPU_SH7729,
30f15cbe6fSPaul Mundt 
31f15cbe6fSPaul Mundt 	/* SH-4 types */
32f15cbe6fSPaul Mundt 	CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
33f15cbe6fSPaul Mundt 	CPU_SH7760, CPU_SH4_202, CPU_SH4_501,
34f15cbe6fSPaul Mundt 
35f15cbe6fSPaul Mundt 	/* SH-4A types */
3655ba99ebSKuninori Morimoto 	CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SH7786,
37fea88a0cSNobuhiro Iwamatsu 	CPU_SH7723, CPU_SH7724, CPU_SH7757, CPU_SH7734, CPU_SHX3,
38f15cbe6fSPaul Mundt 
39f15cbe6fSPaul Mundt 	/* SH4AL-DSP types */
40fac6c2a8SMagnus Damm 	CPU_SH7343, CPU_SH7722, CPU_SH7366, CPU_SH7372,
41f15cbe6fSPaul Mundt 
42f15cbe6fSPaul Mundt 	/* SH-5 types */
43f15cbe6fSPaul Mundt         CPU_SH5_101, CPU_SH5_103,
44f15cbe6fSPaul Mundt 
45f15cbe6fSPaul Mundt 	/* Unknown subtype */
46f15cbe6fSPaul Mundt 	CPU_SH_NONE
47f15cbe6fSPaul Mundt };
48f15cbe6fSPaul Mundt 
49e82da214SPaul Mundt enum cpu_family {
50e82da214SPaul Mundt 	CPU_FAMILY_SH2,
51e82da214SPaul Mundt 	CPU_FAMILY_SH2A,
52e82da214SPaul Mundt 	CPU_FAMILY_SH3,
53e82da214SPaul Mundt 	CPU_FAMILY_SH4,
54e82da214SPaul Mundt 	CPU_FAMILY_SH4A,
55e82da214SPaul Mundt 	CPU_FAMILY_SH4AL_DSP,
56e82da214SPaul Mundt 	CPU_FAMILY_SH5,
57e82da214SPaul Mundt 	CPU_FAMILY_UNKNOWN,
58e82da214SPaul Mundt };
59e82da214SPaul Mundt 
6081b66995SPaul Mundt /*
6181b66995SPaul Mundt  * TLB information structure
6281b66995SPaul Mundt  *
6381b66995SPaul Mundt  * Defined for both I and D tlb, per-processor.
6481b66995SPaul Mundt  */
6581b66995SPaul Mundt struct tlb_info {
6681b66995SPaul Mundt 	unsigned long long next;
6781b66995SPaul Mundt 	unsigned long long first;
6881b66995SPaul Mundt 	unsigned long long last;
6981b66995SPaul Mundt 
7081b66995SPaul Mundt 	unsigned int entries;
7181b66995SPaul Mundt 	unsigned int step;
7281b66995SPaul Mundt 
7381b66995SPaul Mundt 	unsigned long flags;
7481b66995SPaul Mundt };
7581b66995SPaul Mundt 
7681b66995SPaul Mundt struct sh_cpuinfo {
77e82da214SPaul Mundt 	unsigned int type, family;
7881b66995SPaul Mundt 	int cut_major, cut_minor;
7981b66995SPaul Mundt 	unsigned long loops_per_jiffy;
8081b66995SPaul Mundt 	unsigned long asid_cache;
8181b66995SPaul Mundt 
8281b66995SPaul Mundt 	struct cache_info icache;	/* Primary I-cache */
8381b66995SPaul Mundt 	struct cache_info dcache;	/* Primary D-cache */
8481b66995SPaul Mundt 	struct cache_info scache;	/* Secondary cache */
8581b66995SPaul Mundt 
8681b66995SPaul Mundt 	/* TLB info */
8781b66995SPaul Mundt 	struct tlb_info itlb;
8881b66995SPaul Mundt 	struct tlb_info dtlb;
8981b66995SPaul Mundt 
902f98492cSPaul Mundt 	unsigned int phys_bits;
9181b66995SPaul Mundt 	unsigned long flags;
9281b66995SPaul Mundt } __attribute__ ((aligned(L1_CACHE_BYTES)));
9381b66995SPaul Mundt 
9481b66995SPaul Mundt extern struct sh_cpuinfo cpu_data[];
9581b66995SPaul Mundt #define boot_cpu_data cpu_data[0]
9681b66995SPaul Mundt #define current_cpu_data cpu_data[smp_processor_id()]
9781b66995SPaul Mundt #define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
9881b66995SPaul Mundt 
99eb67cf14SPaul Mundt #define cpu_sleep()	__asm__ __volatile__ ("sleep" : : : "memory")
100eb67cf14SPaul Mundt #define cpu_relax()	barrier()
101eb67cf14SPaul Mundt 
102e839ca52SDavid Howells void default_idle(void);
103e839ca52SDavid Howells void stop_this_cpu(void *);
104e839ca52SDavid Howells 
105f15cbe6fSPaul Mundt /* Forward decl */
106fa43972fSPaul Mundt struct seq_operations;
1073ef2932bSPaul Mundt struct task_struct;
108fa43972fSPaul Mundt 
109fa43972fSPaul Mundt extern struct pt_regs fake_swapper_regs;
110f15cbe6fSPaul Mundt 
1114a6feab0SPaul Mundt extern void cpu_init(void);
112a9079ca0SPaul Mundt extern void cpu_probe(void);
113a9079ca0SPaul Mundt 
1143ef2932bSPaul Mundt /* arch/sh/kernel/process.c */
1153ef2932bSPaul Mundt extern unsigned int xstate_size;
1163ef2932bSPaul Mundt extern void free_thread_xstate(struct task_struct *);
1173ef2932bSPaul Mundt extern struct kmem_cache *task_xstate_cachep;
1183ef2932bSPaul Mundt 
11994ea5e44SPaul Mundt /* arch/sh/mm/alignment.c */
12094ea5e44SPaul Mundt extern int get_unalign_ctl(struct task_struct *, unsigned long addr);
12194ea5e44SPaul Mundt extern int set_unalign_ctl(struct task_struct *, unsigned int val);
12294ea5e44SPaul Mundt 
12394ea5e44SPaul Mundt #define GET_UNALIGN_CTL(tsk, addr)	get_unalign_ctl((tsk), (addr))
12494ea5e44SPaul Mundt #define SET_UNALIGN_CTL(tsk, val)	set_unalign_ctl((tsk), (val))
12594ea5e44SPaul Mundt 
126d9b9487aSPaul Mundt /* arch/sh/mm/init.c */
127d9b9487aSPaul Mundt extern unsigned int mem_init_done;
128d9b9487aSPaul Mundt 
129f15cbe6fSPaul Mundt /* arch/sh/kernel/setup.c */
130f15cbe6fSPaul Mundt const char *get_cpu_subtype(struct sh_cpuinfo *c);
131fa43972fSPaul Mundt extern const struct seq_operations cpuinfo_op;
132f15cbe6fSPaul Mundt 
13394ea5e44SPaul Mundt /* thread_struct flags */
13494ea5e44SPaul Mundt #define SH_THREAD_UAC_NOPRINT	(1 << 0)
13594ea5e44SPaul Mundt #define SH_THREAD_UAC_SIGBUS	(1 << 1)
13694ea5e44SPaul Mundt #define SH_THREAD_UAC_MASK	(SH_THREAD_UAC_NOPRINT | SH_THREAD_UAC_SIGBUS)
13794ea5e44SPaul Mundt 
138eb9b9b56SMagnus Damm /* processor boot mode configuration */
1390d4fdbb6SMagnus Damm #define MODE_PIN0 (1 << 0)
1400d4fdbb6SMagnus Damm #define MODE_PIN1 (1 << 1)
1410d4fdbb6SMagnus Damm #define MODE_PIN2 (1 << 2)
1420d4fdbb6SMagnus Damm #define MODE_PIN3 (1 << 3)
1430d4fdbb6SMagnus Damm #define MODE_PIN4 (1 << 4)
1440d4fdbb6SMagnus Damm #define MODE_PIN5 (1 << 5)
1450d4fdbb6SMagnus Damm #define MODE_PIN6 (1 << 6)
1460d4fdbb6SMagnus Damm #define MODE_PIN7 (1 << 7)
1470d4fdbb6SMagnus Damm #define MODE_PIN8 (1 << 8)
1480d4fdbb6SMagnus Damm #define MODE_PIN9 (1 << 9)
1490d4fdbb6SMagnus Damm #define MODE_PIN10 (1 << 10)
1500d4fdbb6SMagnus Damm #define MODE_PIN11 (1 << 11)
1510d4fdbb6SMagnus Damm #define MODE_PIN12 (1 << 12)
1520d4fdbb6SMagnus Damm #define MODE_PIN13 (1 << 13)
1530d4fdbb6SMagnus Damm #define MODE_PIN14 (1 << 14)
1540d4fdbb6SMagnus Damm #define MODE_PIN15 (1 << 15)
1550d4fdbb6SMagnus Damm 
156eb9b9b56SMagnus Damm int generic_mode_pins(void);
157eb9b9b56SMagnus Damm int test_mode_pin(int pin);
158eb9b9b56SMagnus Damm 
159f15cbe6fSPaul Mundt #ifdef CONFIG_VSYSCALL
160f15cbe6fSPaul Mundt int vsyscall_init(void);
161f15cbe6fSPaul Mundt #else
162f15cbe6fSPaul Mundt #define vsyscall_init() do { } while (0)
163f15cbe6fSPaul Mundt #endif
164f15cbe6fSPaul Mundt 
165e839ca52SDavid Howells /*
166e839ca52SDavid Howells  * SH-2A has both 16 and 32-bit opcodes, do lame encoding checks.
167e839ca52SDavid Howells  */
168e839ca52SDavid Howells #ifdef CONFIG_CPU_SH2A
169e839ca52SDavid Howells extern unsigned int instruction_size(unsigned int insn);
170e839ca52SDavid Howells #elif defined(CONFIG_SUPERH32)
171e839ca52SDavid Howells #define instruction_size(insn)	(2)
172e839ca52SDavid Howells #else
173e839ca52SDavid Howells #define instruction_size(insn)	(4)
174e839ca52SDavid Howells #endif
175e839ca52SDavid Howells 
176f15cbe6fSPaul Mundt #endif /* __ASSEMBLY__ */
177f15cbe6fSPaul Mundt 
178f15cbe6fSPaul Mundt #ifdef CONFIG_SUPERH32
179a1ce3928SDavid Howells # include <asm/processor_32.h>
180f15cbe6fSPaul Mundt #else
181a1ce3928SDavid Howells # include <asm/processor_64.h>
182f15cbe6fSPaul Mundt #endif
183f15cbe6fSPaul Mundt 
184f15cbe6fSPaul Mundt #endif /* __ASM_SH_PROCESSOR_H */
185