1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ALPHA_JENSEN_H
3 #define __ALPHA_JENSEN_H
5 #include <asm/compiler.h>
8 * Defines for the AlphaPC EISA IO and memory address space.
12 * NOTE! The memory operations do not set any memory barriers, as it's
13 * not needed for cases like a frame buffer that is essentially memory-like.
14 * You need to do them by hand if the operations depend on ordering.
16 * Similarly, the port IO operations do a "mb" only after a write operation:
17 * if an mb is needed before (as in the case of doing memory mapped IO
18 * first, and then a port IO operation to the same device), it needs to be
21 * After the above has bitten me 100 times, I'll give up and just do the
22 * mb all the time, but right now I'm hoping this will work out. Avoiding
23 * mb's may potentially be a noticeable speed improvement, but I can't
24 * honestly say I've tested it.
26 * Handling interrupts that need to do mb's to synchronize to non-interrupts
27 * is another fun race area. Don't do it (because if you do, I'll have to
28 * do *everything* with interrupts disabled, ugh).
32 * EISA Interrupt Acknowledge address
34 #define EISA_INTA (IDENT_ADDR + 0x100000000UL)
39 #define EISA_FEPROM0 (IDENT_ADDR + 0x180000000UL)
40 #define EISA_FEPROM1 (IDENT_ADDR + 0x1A0000000UL)
43 * VL82C106 base address
45 #define EISA_VL82C106 (IDENT_ADDR + 0x1C0000000UL)
48 * EISA "Host Address Extension" address (bits 25-31 of the EISA address)
50 #define EISA_HAE (IDENT_ADDR + 0x1D0000000UL)
53 * "SYSCTL" register address
55 #define EISA_SYSCTL (IDENT_ADDR + 0x1E0000000UL)
58 * "spare" register address
60 #define EISA_SPARE (IDENT_ADDR + 0x1F0000000UL)
63 * EISA memory address offset
65 #define EISA_MEM (IDENT_ADDR + 0x200000000UL)
68 * EISA IO address offset
70 #define EISA_IO (IDENT_ADDR + 0x300000000UL)
75 #ifndef __EXTERN_INLINE
76 #define __EXTERN_INLINE extern inline
77 #define __IO_EXTERN_INLINE
81 * Handle the "host address register". This needs to be set
82 * to the high 7 bits of the EISA address. This is also needed
83 * for EISA IO addresses, which are only 16 bits wide (the
84 * hae needs to be set to 0).
86 * HAE isn't needed for the local IO operations, though.
89 #define JENSEN_HAE_ADDRESS EISA_HAE
90 #define JENSEN_HAE_MASK 0x1ffffff
92 __EXTERN_INLINE
void jensen_set_hae(unsigned long addr
)
94 /* hae on the Jensen is bits 31:25 shifted right */
96 if (addr
!= alpha_mv
.hae_cache
)
100 #define vuip volatile unsigned int *
105 * The "local" functions are those that don't go out to the EISA bus,
106 * but instead act on the VL82C106 chip directly.. This is mainly the
107 * keyboard, RTC, printer and first two serial lines..
109 * The local stuff makes for some complications, but it seems to be
110 * gone in the PCI version. I hope I can get DEC suckered^H^H^H^H^H^H^H^H
111 * convinced that I need one of the newer machines.
114 static inline unsigned int jensen_local_inb(unsigned long addr
)
116 return 0xff & *(vuip
)((addr
<< 9) + EISA_VL82C106
);
119 static inline void jensen_local_outb(u8 b
, unsigned long addr
)
121 *(vuip
)((addr
<< 9) + EISA_VL82C106
) = b
;
125 static inline unsigned int jensen_bus_inb(unsigned long addr
)
130 result
= *(volatile int *)((addr
<< 7) + EISA_IO
+ 0x00);
131 return __kernel_extbl(result
, addr
& 3);
134 static inline void jensen_bus_outb(u8 b
, unsigned long addr
)
137 *(vuip
)((addr
<< 7) + EISA_IO
+ 0x00) = b
* 0x01010101;
142 * It seems gcc is not very good at optimizing away logical
143 * operations that result in operations across inline functions.
144 * Which is why this is a macro.
147 #define jensen_is_local(addr) ( \
148 /* keyboard */ (addr == 0x60 || addr == 0x64) || \
149 /* RTC */ (addr == 0x170 || addr == 0x171) || \
150 /* mb COM2 */ (addr >= 0x2f8 && addr <= 0x2ff) || \
151 /* mb LPT1 */ (addr >= 0x3bc && addr <= 0x3be) || \
152 /* mb COM2 */ (addr >= 0x3f8 && addr <= 0x3ff))
154 __EXTERN_INLINE u8
jensen_inb(unsigned long addr
)
156 if (jensen_is_local(addr
))
157 return jensen_local_inb(addr
);
159 return jensen_bus_inb(addr
);
162 __EXTERN_INLINE
void jensen_outb(u8 b
, unsigned long addr
)
164 if (jensen_is_local(addr
))
165 jensen_local_outb(b
, addr
);
167 jensen_bus_outb(b
, addr
);
170 __EXTERN_INLINE u16
jensen_inw(unsigned long addr
)
175 result
= *(volatile int *) ((addr
<< 7) + EISA_IO
+ 0x20);
176 result
>>= (addr
& 3) * 8;
177 return 0xffffUL
& result
;
180 __EXTERN_INLINE u32
jensen_inl(unsigned long addr
)
183 return *(vuip
) ((addr
<< 7) + EISA_IO
+ 0x60);
186 __EXTERN_INLINE
void jensen_outw(u16 b
, unsigned long addr
)
189 *(vuip
) ((addr
<< 7) + EISA_IO
+ 0x20) = b
* 0x00010001;
193 __EXTERN_INLINE
void jensen_outl(u32 b
, unsigned long addr
)
196 *(vuip
) ((addr
<< 7) + EISA_IO
+ 0x60) = b
;
204 __EXTERN_INLINE u8
jensen_readb(const volatile void __iomem
*xaddr
)
206 unsigned long addr
= (unsigned long) xaddr
;
209 jensen_set_hae(addr
);
210 addr
&= JENSEN_HAE_MASK
;
211 result
= *(volatile int *) ((addr
<< 7) + EISA_MEM
+ 0x00);
212 result
>>= (addr
& 3) * 8;
213 return 0xffUL
& result
;
216 __EXTERN_INLINE u16
jensen_readw(const volatile void __iomem
*xaddr
)
218 unsigned long addr
= (unsigned long) xaddr
;
221 jensen_set_hae(addr
);
222 addr
&= JENSEN_HAE_MASK
;
223 result
= *(volatile int *) ((addr
<< 7) + EISA_MEM
+ 0x20);
224 result
>>= (addr
& 3) * 8;
225 return 0xffffUL
& result
;
228 __EXTERN_INLINE u32
jensen_readl(const volatile void __iomem
*xaddr
)
230 unsigned long addr
= (unsigned long) xaddr
;
231 jensen_set_hae(addr
);
232 addr
&= JENSEN_HAE_MASK
;
233 return *(vuip
) ((addr
<< 7) + EISA_MEM
+ 0x60);
236 __EXTERN_INLINE u64
jensen_readq(const volatile void __iomem
*xaddr
)
238 unsigned long addr
= (unsigned long) xaddr
;
239 unsigned long r0
, r1
;
241 jensen_set_hae(addr
);
242 addr
&= JENSEN_HAE_MASK
;
243 addr
= (addr
<< 7) + EISA_MEM
+ 0x60;
245 r1
= *(vuip
) (addr
+ (4 << 7));
246 return r1
<< 32 | r0
;
249 __EXTERN_INLINE
void jensen_writeb(u8 b
, volatile void __iomem
*xaddr
)
251 unsigned long addr
= (unsigned long) xaddr
;
252 jensen_set_hae(addr
);
253 addr
&= JENSEN_HAE_MASK
;
254 *(vuip
) ((addr
<< 7) + EISA_MEM
+ 0x00) = b
* 0x01010101;
257 __EXTERN_INLINE
void jensen_writew(u16 b
, volatile void __iomem
*xaddr
)
259 unsigned long addr
= (unsigned long) xaddr
;
260 jensen_set_hae(addr
);
261 addr
&= JENSEN_HAE_MASK
;
262 *(vuip
) ((addr
<< 7) + EISA_MEM
+ 0x20) = b
* 0x00010001;
265 __EXTERN_INLINE
void jensen_writel(u32 b
, volatile void __iomem
*xaddr
)
267 unsigned long addr
= (unsigned long) xaddr
;
268 jensen_set_hae(addr
);
269 addr
&= JENSEN_HAE_MASK
;
270 *(vuip
) ((addr
<< 7) + EISA_MEM
+ 0x60) = b
;
273 __EXTERN_INLINE
void jensen_writeq(u64 b
, volatile void __iomem
*xaddr
)
275 unsigned long addr
= (unsigned long) xaddr
;
276 jensen_set_hae(addr
);
277 addr
&= JENSEN_HAE_MASK
;
278 addr
= (addr
<< 7) + EISA_MEM
+ 0x60;
280 *(vuip
) (addr
+ (4 << 7)) = b
>> 32;
283 __EXTERN_INLINE
void __iomem
*jensen_ioportmap(unsigned long addr
)
285 return (void __iomem
*)addr
;
288 __EXTERN_INLINE
void __iomem
*jensen_ioremap(unsigned long addr
,
291 return (void __iomem
*)(addr
+ 0x100000000ul
);
294 __EXTERN_INLINE
int jensen_is_ioaddr(unsigned long addr
)
296 return (long)addr
>= 0;
299 __EXTERN_INLINE
int jensen_is_mmio(const volatile void __iomem
*addr
)
301 return (unsigned long)addr
>= 0x100000000ul
;
304 /* New-style ioread interface. All the routines are so ugly for Jensen
305 that it doesn't make sense to merge them. */
307 #define IOPORT(OS, NS) \
308 __EXTERN_INLINE unsigned int jensen_ioread##NS(const void __iomem *xaddr) \
310 if (jensen_is_mmio(xaddr)) \
311 return jensen_read##OS(xaddr - 0x100000000ul); \
313 return jensen_in##OS((unsigned long)xaddr); \
315 __EXTERN_INLINE void jensen_iowrite##NS(u##NS b, void __iomem *xaddr) \
317 if (jensen_is_mmio(xaddr)) \
318 jensen_write##OS(b, xaddr - 0x100000000ul); \
320 jensen_out##OS(b, (unsigned long)xaddr); \
332 #define __IO_PREFIX jensen
333 #define jensen_trivial_rw_bw 0
334 #define jensen_trivial_rw_lq 0
335 #define jensen_trivial_io_bw 0
336 #define jensen_trivial_io_lq 0
337 #define jensen_trivial_iounmap 1
338 #include <asm/io_trivial.h>
340 #ifdef __IO_EXTERN_INLINE
341 #undef __EXTERN_INLINE
342 #undef __IO_EXTERN_INLINE
345 #endif /* __KERNEL__ */
347 #endif /* __ALPHA_JENSEN_H */