Commit | Line | Data |
---|---|---|
96f1050d RG |
1 | /* |
2 | * Copyright 2004-2009 Analog Devices Inc. | |
3 | * | |
4 | * Licensed under the GPL-2 or later. | |
5 | */ | |
6 | ||
1394f032 BW |
7 | #ifndef __ASM_BFIN_PROCESSOR_H |
8 | #define __ASM_BFIN_PROCESSOR_H | |
9 | ||
10 | /* | |
11 | * Default implementation of macro that returns current | |
12 | * instruction pointer ("program counter"). | |
13 | */ | |
14 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | |
15 | ||
d5ce528c | 16 | #include <asm/ptrace.h> |
2c1657c2 | 17 | #include <mach/blackfin.h> |
1394f032 BW |
18 | |
19 | static inline unsigned long rdusp(void) | |
20 | { | |
21 | unsigned long usp; | |
22 | ||
23 | __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp)); | |
24 | return usp; | |
25 | } | |
26 | ||
27 | static inline void wrusp(unsigned long usp) | |
28 | { | |
29 | __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); | |
30 | } | |
31 | ||
a45d575f RG |
32 | static inline unsigned long __get_SP(void) |
33 | { | |
34 | unsigned long sp; | |
35 | ||
36 | __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp)); | |
37 | return sp; | |
38 | } | |
39 | ||
1394f032 BW |
40 | /* |
41 | * User space process size: 1st byte beyond user address space. | |
d5adb029 BS |
42 | * Fairly meaningless on nommu. Parts of user programs can be scattered |
43 | * in a lot of places, so just disable this by setting it to 0xFFFFFFFF. | |
1394f032 | 44 | */ |
d5adb029 | 45 | #define TASK_SIZE 0xFFFFFFFF |
1394f032 | 46 | |
922a70d3 DH |
47 | #ifdef __KERNEL__ |
48 | #define STACK_TOP TASK_SIZE | |
49 | #endif | |
50 | ||
1394f032 BW |
51 | #define TASK_UNMAPPED_BASE 0 |
52 | ||
53 | struct thread_struct { | |
54 | unsigned long ksp; /* kernel stack pointer */ | |
55 | unsigned long usp; /* user stack pointer */ | |
56 | unsigned short seqstat; /* saved status register */ | |
57 | unsigned long esp0; /* points to SR of stack frame pt_regs */ | |
58 | unsigned long pc; /* instruction pointer */ | |
59 | void * debuggerinfo; | |
60 | }; | |
61 | ||
62 | #define INIT_THREAD { \ | |
63 | sizeof(init_stack) + (unsigned long) init_stack, 0, \ | |
64 | PS_S, 0, 0 \ | |
65 | } | |
66 | ||
d5ce528c MF |
67 | extern void start_thread(struct pt_regs *regs, unsigned long new_ip, |
68 | unsigned long new_sp); | |
1394f032 BW |
69 | |
70 | /* Forward declaration, a strange C thing */ | |
71 | struct task_struct; | |
72 | ||
73 | /* Free all resources held by a thread. */ | |
74 | static inline void release_thread(struct task_struct *dead_task) | |
75 | { | |
76 | } | |
77 | ||
1394f032 BW |
78 | /* |
79 | * Free current thread data structures etc.. | |
80 | */ | |
81 | static inline void exit_thread(void) | |
82 | { | |
83 | } | |
84 | ||
85 | /* | |
86 | * Return saved PC of a blocked thread. | |
87 | */ | |
88 | #define thread_saved_pc(tsk) (tsk->thread.pc) | |
89 | ||
90 | unsigned long get_wchan(struct task_struct *p); | |
91 | ||
92 | #define KSTK_EIP(tsk) \ | |
93 | ({ \ | |
94 | unsigned long eip = 0; \ | |
95 | if ((tsk)->thread.esp0 > PAGE_SIZE && \ | |
96 | MAP_NR((tsk)->thread.esp0) < max_mapnr) \ | |
97 | eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ | |
98 | eip; }) | |
99 | #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) | |
100 | ||
6b3087c6 | 101 | #define cpu_relax() smp_mb() |
3a6bfbc9 | 102 | #define cpu_relax_lowlatency() cpu_relax() |
1394f032 BW |
103 | |
104 | /* Get the Silicon Revision of the chip */ | |
e8c44319 | 105 | static inline uint32_t __pure bfin_revid(void) |
1394f032 | 106 | { |
bc4d6f36 RG |
107 | /* Always use CHIPID, to work around ANOMALY_05000234 */ |
108 | uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28; | |
0138da61 | 109 | |
10a5ecd0 GY |
110 | #ifdef _BOOTROM_GET_DXE_ADDRESS_TWI |
111 | /* | |
112 | * ANOMALY_05000364 | |
0138da61 MH |
113 | * Incorrect Revision Number in DSPID Register |
114 | */ | |
10a5ecd0 GY |
115 | if (ANOMALY_05000364 && |
116 | bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796) | |
117 | revid = 1; | |
0138da61 | 118 | #endif |
10a5ecd0 | 119 | |
0138da61 | 120 | return revid; |
1394f032 BW |
121 | } |
122 | ||
e482cad2 RG |
123 | static inline uint16_t __pure bfin_cpuid(void) |
124 | { | |
125 | return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12; | |
6b3087c6 | 126 | } |
e482cad2 | 127 | |
6b3087c6 GY |
128 | static inline uint32_t __pure bfin_dspid(void) |
129 | { | |
130 | return bfin_read_DSPID(); | |
e482cad2 RG |
131 | } |
132 | ||
2c1657c2 GY |
133 | #define blackfin_core_id() (bfin_dspid() & 0xff) |
134 | ||
e8c44319 | 135 | static inline uint32_t __pure bfin_compiled_revid(void) |
1394f032 BW |
136 | { |
137 | #if defined(CONFIG_BF_REV_0_0) | |
138 | return 0; | |
139 | #elif defined(CONFIG_BF_REV_0_1) | |
140 | return 1; | |
141 | #elif defined(CONFIG_BF_REV_0_2) | |
142 | return 2; | |
143 | #elif defined(CONFIG_BF_REV_0_3) | |
144 | return 3; | |
145 | #elif defined(CONFIG_BF_REV_0_4) | |
146 | return 4; | |
147 | #elif defined(CONFIG_BF_REV_0_5) | |
148 | return 5; | |
2e8ca591 BW |
149 | #elif defined(CONFIG_BF_REV_0_6) |
150 | return 6; | |
de3025f4 JZ |
151 | #elif defined(CONFIG_BF_REV_ANY) |
152 | return 0xffff; | |
153 | #else | |
154 | return -1; | |
1394f032 BW |
155 | #endif |
156 | } | |
157 | ||
158 | #endif |