~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/asm-alpha/jensen.h

Version: ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __ALPHA_JENSEN_H
  2 #define __ALPHA_JENSEN_H
  3 
  4 #include <asm/compiler.h>
  5 
  6 /*
  7  * Defines for the AlphaPC EISA IO and memory address space.
  8  */
  9 
 10 /*
 11  * NOTE! The memory operations do not set any memory barriers, as it's
 12  * not needed for cases like a frame buffer that is essentially memory-like.
 13  * You need to do them by hand if the operations depend on ordering.
 14  *
 15  * Similarly, the port IO operations do a "mb" only after a write operation:
 16  * if an mb is needed before (as in the case of doing memory mapped IO
 17  * first, and then a port IO operation to the same device), it needs to be
 18  * done by hand.
 19  *
 20  * After the above has bitten me 100 times, I'll give up and just do the
 21  * mb all the time, but right now I'm hoping this will work out.  Avoiding
 22  * mb's may potentially be a noticeable speed improvement, but I can't
 23  * honestly say I've tested it.
 24  *
 25  * Handling interrupts that need to do mb's to synchronize to non-interrupts
 26  * is another fun race area.  Don't do it (because if you do, I'll have to
 27  * do *everything* with interrupts disabled, ugh).
 28  */
 29 
 30 /*
 31  * EISA Interrupt Acknowledge address
 32  */
 33 #define EISA_INTA               (IDENT_ADDR + 0x100000000UL)
 34 
 35 /*
 36  * FEPROM addresses
 37  */
 38 #define EISA_FEPROM0            (IDENT_ADDR + 0x180000000UL)
 39 #define EISA_FEPROM1            (IDENT_ADDR + 0x1A0000000UL)
 40 
 41 /*
 42  * VL82C106 base address
 43  */
 44 #define EISA_VL82C106           (IDENT_ADDR + 0x1C0000000UL)
 45 
 46 /*
 47  * EISA "Host Address Extension" address (bits 25-31 of the EISA address)
 48  */
 49 #define EISA_HAE                (IDENT_ADDR + 0x1D0000000UL)
 50 
 51 /*
 52  * "SYSCTL" register address
 53  */
 54 #define EISA_SYSCTL             (IDENT_ADDR + 0x1E0000000UL)
 55 
 56 /*
 57  * "spare" register address
 58  */
 59 #define EISA_SPARE              (IDENT_ADDR + 0x1F0000000UL)
 60 
 61 /*
 62  * EISA memory address offset
 63  */
 64 #define EISA_MEM                (IDENT_ADDR + 0x200000000UL)
 65 
 66 /*
 67  * EISA IO address offset
 68  */
 69 #define EISA_IO                 (IDENT_ADDR + 0x300000000UL)
 70 
 71 
 72 #ifdef __KERNEL__
 73 
 74 #ifndef __EXTERN_INLINE
 75 #define __EXTERN_INLINE extern inline
 76 #define __IO_EXTERN_INLINE
 77 #endif
 78 
 79 /*
 80  * Handle the "host address register". This needs to be set
 81  * to the high 7 bits of the EISA address.  This is also needed
 82  * for EISA IO addresses, which are only 16 bits wide (the
 83  * hae needs to be set to 0).
 84  *
 85  * HAE isn't needed for the local IO operations, though.
 86  */
 87 
 88 #define JENSEN_HAE_ADDRESS      EISA_HAE
 89 #define JENSEN_HAE_MASK         0x1ffffff
 90 
 91 __EXTERN_INLINE void jensen_set_hae(unsigned long addr)
 92 {
 93         /* hae on the Jensen is bits 31:25 shifted right */
 94         addr >>= 25;
 95         if (addr != alpha_mv.hae_cache)
 96                 set_hae(addr);
 97 }
 98 
 99 #define vuip    volatile unsigned int *
100 
101 /*
102  * IO functions
103  *
104  * The "local" functions are those that don't go out to the EISA bus,
105  * but instead act on the VL82C106 chip directly.. This is mainly the
106  * keyboard, RTC,  printer and first two serial lines..
107  *
108  * The local stuff makes for some complications, but it seems to be
109  * gone in the PCI version. I hope I can get DEC suckered^H^H^H^H^H^H^H^H
110  * convinced that I need one of the newer machines.
111  */
112 
113 static inline unsigned int jensen_local_inb(unsigned long addr)
114 {
115         return 0xff & *(vuip)((addr << 9) + EISA_VL82C106);
116 }
117 
118 static inline void jensen_local_outb(u8 b, unsigned long addr)
119 {
120         *(vuip)((addr << 9) + EISA_VL82C106) = b;
121         mb();
122 }
123 
124 static inline unsigned int jensen_bus_inb(unsigned long addr)
125 {
126         long result;
127 
128         jensen_set_hae(0);
129         result = *(volatile int *)((addr << 7) + EISA_IO + 0x00);
130         return __kernel_extbl(result, addr & 3);
131 }
132 
133 static inline void jensen_bus_outb(u8 b, unsigned long addr)
134 {
135         jensen_set_hae(0);
136         *(vuip)((addr << 7) + EISA_IO + 0x00) = b * 0x01010101;
137         mb();
138 }
139 
140 /*
141  * It seems gcc is not very good at optimizing away logical
142  * operations that result in operations across inline functions.
143  * Which is why this is a macro.
144  */
145 
146 #define jensen_is_local(addr) ( \
147 /* keyboard */  (addr == 0x60 || addr == 0x64) || \
148 /* RTC */       (addr == 0x170 || addr == 0x171) || \
149 /* mb COM2 */   (addr >= 0x2f8 && addr <= 0x2ff) || \
150 /* mb LPT1 */   (addr >= 0x3bc && addr <= 0x3be) || \
151 /* mb COM2 */   (addr >= 0x3f8 && addr <= 0x3ff))
152 
153 __EXTERN_INLINE u8 jensen_inb(unsigned long addr)
154 {
155         if (jensen_is_local(addr))
156                 return jensen_local_inb(addr);
157         else
158                 return jensen_bus_inb(addr);
159 }
160 
161 __EXTERN_INLINE void jensen_outb(u8 b, unsigned long addr)
162 {
163         if (jensen_is_local(addr))
164                 jensen_local_outb(b, addr);
165         else
166                 jensen_bus_outb(b, addr);
167 }
168 
169 __EXTERN_INLINE u16 jensen_inw(unsigned long addr)
170 {
171         long result;
172 
173         jensen_set_hae(0);
174         result = *(volatile int *) ((addr << 7) + EISA_IO + 0x20);
175         result >>= (addr & 3) * 8;
176         return 0xffffUL & result;
177 }
178 
179 __EXTERN_INLINE u32 jensen_inl(unsigned long addr)
180 {
181         jensen_set_hae(0);
182         return *(vuip) ((addr << 7) + EISA_IO + 0x60);
183 }
184 
185 __EXTERN_INLINE void jensen_outw(u16 b, unsigned long addr)
186 {
187         jensen_set_hae(0);
188         *(vuip) ((addr << 7) + EISA_IO + 0x20) = b * 0x00010001;
189         mb();
190 }
191 
192 __EXTERN_INLINE void jensen_outl(u32 b, unsigned long addr)
193 {
194         jensen_set_hae(0);
195         *(vuip) ((addr << 7) + EISA_IO + 0x60) = b;
196         mb();
197 }
198 
199 /*
200  * Memory functions.
201  */
202 
203 __EXTERN_INLINE u8 jensen_readb(unsigned long addr)
204 {
205         long result;
206 
207         jensen_set_hae(addr);
208         addr &= JENSEN_HAE_MASK;
209         result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x00);
210         result >>= (addr & 3) * 8;
211         return 0xffUL & result;
212 }
213 
214 __EXTERN_INLINE u16 jensen_readw(unsigned long addr)
215 {
216         long result;
217 
218         jensen_set_hae(addr);
219         addr &= JENSEN_HAE_MASK;
220         result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x20);
221         result >>= (addr & 3) * 8;
222         return 0xffffUL & result;
223 }
224 
225 __EXTERN_INLINE u32 jensen_readl(unsigned long addr)
226 {
227         jensen_set_hae(addr);
228         addr &= JENSEN_HAE_MASK;
229         return *(vuip) ((addr << 7) + EISA_MEM + 0x60);
230 }
231 
232 __EXTERN_INLINE u64 jensen_readq(unsigned long addr)
233 {
234         unsigned long r0, r1;
235 
236         jensen_set_hae(addr);
237         addr &= JENSEN_HAE_MASK;
238         addr = (addr << 7) + EISA_MEM + 0x60;
239         r0 = *(vuip) (addr);
240         r1 = *(vuip) (addr + (4 << 7));
241         return r1 << 32 | r0;
242 }
243 
244 __EXTERN_INLINE void jensen_writeb(u8 b, unsigned long addr)
245 {
246         jensen_set_hae(addr);
247         addr &= JENSEN_HAE_MASK;
248         *(vuip) ((addr << 7) + EISA_MEM + 0x00) = b * 0x01010101;
249 }
250 
251 __EXTERN_INLINE void jensen_writew(u16 b, unsigned long addr)
252 {
253         jensen_set_hae(addr);
254         addr &= JENSEN_HAE_MASK;
255         *(vuip) ((addr << 7) + EISA_MEM + 0x20) = b * 0x00010001;
256 }
257 
258 __EXTERN_INLINE void jensen_writel(u32 b, unsigned long addr)
259 {
260         jensen_set_hae(addr);
261         addr &= JENSEN_HAE_MASK;
262         *(vuip) ((addr << 7) + EISA_MEM + 0x60) = b;
263 }
264 
265 __EXTERN_INLINE void jensen_writeq(u64 b, unsigned long addr)
266 {
267         jensen_set_hae(addr);
268         addr &= JENSEN_HAE_MASK;
269         addr = (addr << 7) + EISA_MEM + 0x60;
270         *(vuip) (addr) = b;
271         *(vuip) (addr + (4 << 7)) = b >> 32;
272 }
273 
274 __EXTERN_INLINE unsigned long jensen_ioremap(unsigned long addr, 
275                                              unsigned long size)
276 {
277         return addr;
278 }
279 
280 __EXTERN_INLINE void jensen_iounmap(unsigned long addr)
281 {
282         return;
283 }
284 
285 __EXTERN_INLINE int jensen_is_ioaddr(unsigned long addr)
286 {
287         return (long)addr >= 0;
288 }
289 
290 #undef vuip
291 
292 #ifdef __WANT_IO_DEF
293 
294 #define __inb           jensen_inb
295 #define __inw           jensen_inw
296 #define __inl           jensen_inl
297 #define __outb          jensen_outb
298 #define __outw          jensen_outw
299 #define __outl          jensen_outl
300 #define __readb         jensen_readb
301 #define __readw         jensen_readw
302 #define __writeb        jensen_writeb
303 #define __writew        jensen_writew
304 #define __readl         jensen_readl
305 #define __readq         jensen_readq
306 #define __writel        jensen_writel
307 #define __writeq        jensen_writeq
308 #define __ioremap       jensen_ioremap
309 #define __iounmap(a)    jensen_iounmap((unsigned long)a)
310 #define __is_ioaddr     jensen_is_ioaddr
311 
312 /*
313  * The above have so much overhead that it probably doesn't make
314  * sense to have them inlined (better icache behaviour).
315  */
316 #define inb(port) \
317 (__builtin_constant_p((port))?__inb(port):_inb(port))
318 
319 #define outb(x, port) \
320 (__builtin_constant_p((port))?__outb((x),(port)):_outb((x),(port)))
321 
322 #endif /* __WANT_IO_DEF */
323 
324 #ifdef __IO_EXTERN_INLINE
325 #undef __EXTERN_INLINE
326 #undef __IO_EXTERN_INLINE
327 #endif
328 
329 #endif /* __KERNEL__ */
330 
331 #endif /* __ALPHA_JENSEN_H */
332 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp