| 1 |
199 |
simons |
#ifndef __ALPHA_APECS__H__
|
| 2 |
|
|
#define __ALPHA_APECS__H__
|
| 3 |
|
|
|
| 4 |
|
|
#include <linux/types.h>
|
| 5 |
|
|
|
| 6 |
|
|
/*
|
| 7 |
|
|
* APECS is the internal name for the 2107x chipset which provides
|
| 8 |
|
|
* memory controller and PCI access for the 21064 chip based systems.
|
| 9 |
|
|
*
|
| 10 |
|
|
* This file is based on:
|
| 11 |
|
|
*
|
| 12 |
|
|
* DECchip 21071-AA and DECchip 21072-AA Core Logic Chipsets
|
| 13 |
|
|
* Data Sheet
|
| 14 |
|
|
*
|
| 15 |
|
|
* EC-N0648-72
|
| 16 |
|
|
*
|
| 17 |
|
|
*
|
| 18 |
|
|
* david.rusling@reo.mts.dec.com Initial Version.
|
| 19 |
|
|
*
|
| 20 |
|
|
*/
|
| 21 |
|
|
#include <linux/config.h>
|
| 22 |
|
|
|
| 23 |
|
|
#ifdef CONFIG_ALPHA_XL
|
| 24 |
|
|
/*
|
| 25 |
|
|
An AVANTI *might* be an XL, and an XL has only 27 bits of ISA address
|
| 26 |
|
|
that get passed through the PCI<->ISA bridge chip. So we've gotta use
|
| 27 |
|
|
both windows to max out the physical memory we can DMA to. Sigh...
|
| 28 |
|
|
|
| 29 |
|
|
If we try a window at 0 for 1GB as a work-around, we run into conflicts
|
| 30 |
|
|
with ISA/PCI bus memory which can't be relocated, like VGA aperture and
|
| 31 |
|
|
BIOS ROMs. So we must put the windows high enough to avoid these areas.
|
| 32 |
|
|
|
| 33 |
|
|
We put window 1 at BUS 64Mb for 64Mb, mapping physical 0 to 64Mb-1,
|
| 34 |
|
|
and window 2 at BUS 1Gb for 1Gb, mapping physical 0 to 1Gb-1.
|
| 35 |
|
|
Yes, this does map 0 to 64Mb-1 twice, but only window 1 will actually
|
| 36 |
|
|
be used for that range (via virt_to_bus()).
|
| 37 |
|
|
|
| 38 |
|
|
Note that we actually fudge the window 1 maximum as 48Mb instead of 64Mb,
|
| 39 |
|
|
to keep virt_to_bus() from returning an address in the first window, for
|
| 40 |
|
|
a data area that goes beyond the 64Mb first DMA window. Sigh...
|
| 41 |
|
|
The fudge factor MUST match with <asm/dma.h> MAX_DMA_ADDRESS, but
|
| 42 |
|
|
we can't just use that here, because of header file looping... :-(
|
| 43 |
|
|
|
| 44 |
|
|
Window 1 will be used for all DMA from the ISA bus; yes, that does
|
| 45 |
|
|
limit what memory an ISA floppy or soundcard or Ethernet can touch, but
|
| 46 |
|
|
it's also a known limitation on other platforms as well. We use the
|
| 47 |
|
|
same technique that is used on INTEL platforms with similar limitation:
|
| 48 |
|
|
set MAX_DMA_ADDRESS and clear some pages' DMAable flags during mem_init().
|
| 49 |
|
|
We trust that any ISA bus device drivers will *always* ask for DMAable
|
| 50 |
|
|
memory explicitly via kmalloc()/get_free_pages() flags arguments.
|
| 51 |
|
|
|
| 52 |
|
|
Note that most PCI bus devices' drivers do *not* explicitly ask for
|
| 53 |
|
|
DMAable memory; they count on being able to DMA to any memory they
|
| 54 |
|
|
get from kmalloc()/get_free_pages(). They will also use window 1 for
|
| 55 |
|
|
any physical memory accesses below 64Mb; the rest will be handled by
|
| 56 |
|
|
window 2, maxing out at 1Gb of memory. I trust this is enough... :-)
|
| 57 |
|
|
|
| 58 |
|
|
We hope that the area before the first window is large enough so that
|
| 59 |
|
|
there will be no overlap at the top end (64Mb). We *must* locate the
|
| 60 |
|
|
PCI cards' memory just below window 1, so that there's still the
|
| 61 |
|
|
possibility of being able to access it via SPARSE space. This is
|
| 62 |
|
|
important for cards such as the Matrox Millennium, whose Xserver
|
| 63 |
|
|
wants to access memory-mapped registers in byte and short lengths.
|
| 64 |
|
|
|
| 65 |
|
|
Note that the XL is treated differently from the AVANTI, even though
|
| 66 |
|
|
for most other things they are identical. It didn't seem reasonable to
|
| 67 |
|
|
make the AVANTI support pay for the limitations of the XL. It is true,
|
| 68 |
|
|
however, that an XL kernel will run on an AVANTI without problems.
|
| 69 |
|
|
|
| 70 |
|
|
*/
|
| 71 |
|
|
#define APECS_XL_DMA_WIN1_BASE (64*1024*1024)
|
| 72 |
|
|
#define APECS_XL_DMA_WIN1_SIZE (64*1024*1024)
|
| 73 |
|
|
#define APECS_XL_DMA_WIN1_SIZE_PARANOID (48*1024*1024)
|
| 74 |
|
|
#define APECS_XL_DMA_WIN2_BASE (1024*1024*1024)
|
| 75 |
|
|
#define APECS_XL_DMA_WIN2_SIZE (1024*1024*1024)
|
| 76 |
|
|
|
| 77 |
|
|
#else /* CONFIG_ALPHA_XL */
|
| 78 |
|
|
|
| 79 |
|
|
/* these are for normal APECS family machines, AVANTI/MUSTANG/EB64/PC64 */
|
| 80 |
|
|
#ifdef CONFIG_ALPHA_SRM_SETUP
|
| 81 |
|
|
/* if we are using the SRM PCI setup, we'll need to use variables instead */
|
| 82 |
|
|
#define APECS_DMA_WIN_BASE_DEFAULT (1024*1024*1024)
|
| 83 |
|
|
#define APECS_DMA_WIN_SIZE_DEFAULT (1024*1024*1024)
|
| 84 |
|
|
|
| 85 |
|
|
extern unsigned int APECS_DMA_WIN_BASE;
|
| 86 |
|
|
extern unsigned int APECS_DMA_WIN_SIZE;
|
| 87 |
|
|
|
| 88 |
|
|
#else /* SRM_SETUP */
|
| 89 |
|
|
#define APECS_DMA_WIN_BASE (1024*1024*1024)
|
| 90 |
|
|
#define APECS_DMA_WIN_SIZE (1024*1024*1024)
|
| 91 |
|
|
#endif /* SRM_SETUP */
|
| 92 |
|
|
|
| 93 |
|
|
#endif /* CONFIG_ALPHA_XL */
|
| 94 |
|
|
|
| 95 |
|
|
/*
|
| 96 |
|
|
* 21071-DA Control and Status registers.
|
| 97 |
|
|
* These are used for PCI memory access.
|
| 98 |
|
|
*/
|
| 99 |
|
|
#define APECS_IOC_DCSR (IDENT_ADDR + 0x1A0000000UL)
|
| 100 |
|
|
#define APECS_IOC_PEAR (IDENT_ADDR + 0x1A0000020UL)
|
| 101 |
|
|
#define APECS_IOC_SEAR (IDENT_ADDR + 0x1A0000040UL)
|
| 102 |
|
|
#define APECS_IOC_DR1 (IDENT_ADDR + 0x1A0000060UL)
|
| 103 |
|
|
#define APECS_IOC_DR2 (IDENT_ADDR + 0x1A0000080UL)
|
| 104 |
|
|
#define APECS_IOC_DR3 (IDENT_ADDR + 0x1A00000A0UL)
|
| 105 |
|
|
|
| 106 |
|
|
#define APECS_IOC_TB1R (IDENT_ADDR + 0x1A00000C0UL)
|
| 107 |
|
|
#define APECS_IOC_TB2R (IDENT_ADDR + 0x1A00000E0UL)
|
| 108 |
|
|
|
| 109 |
|
|
#define APECS_IOC_PB1R (IDENT_ADDR + 0x1A0000100UL)
|
| 110 |
|
|
#define APECS_IOC_PB2R (IDENT_ADDR + 0x1A0000120UL)
|
| 111 |
|
|
|
| 112 |
|
|
#define APECS_IOC_PM1R (IDENT_ADDR + 0x1A0000140UL)
|
| 113 |
|
|
#define APECS_IOC_PM2R (IDENT_ADDR + 0x1A0000160UL)
|
| 114 |
|
|
|
| 115 |
|
|
#define APECS_IOC_HAXR0 (IDENT_ADDR + 0x1A0000180UL)
|
| 116 |
|
|
#define APECS_IOC_HAXR1 (IDENT_ADDR + 0x1A00001A0UL)
|
| 117 |
|
|
#define APECS_IOC_HAXR2 (IDENT_ADDR + 0x1A00001C0UL)
|
| 118 |
|
|
|
| 119 |
|
|
#define APECS_IOC_PMLT (IDENT_ADDR + 0x1A00001E0UL)
|
| 120 |
|
|
|
| 121 |
|
|
#define APECS_IOC_TLBTAG0 (IDENT_ADDR + 0x1A0000200UL)
|
| 122 |
|
|
#define APECS_IOC_TLBTAG1 (IDENT_ADDR + 0x1A0000220UL)
|
| 123 |
|
|
#define APECS_IOC_TLBTAG2 (IDENT_ADDR + 0x1A0000240UL)
|
| 124 |
|
|
#define APECS_IOC_TLBTAG3 (IDENT_ADDR + 0x1A0000260UL)
|
| 125 |
|
|
#define APECS_IOC_TLBTAG4 (IDENT_ADDR + 0x1A0000280UL)
|
| 126 |
|
|
#define APECS_IOC_TLBTAG5 (IDENT_ADDR + 0x1A00002A0UL)
|
| 127 |
|
|
#define APECS_IOC_TLBTAG6 (IDENT_ADDR + 0x1A00002C0UL)
|
| 128 |
|
|
#define APECS_IOC_TLBTAG7 (IDENT_ADDR + 0x1A00002E0UL)
|
| 129 |
|
|
|
| 130 |
|
|
#define APECS_IOC_TLBDATA0 (IDENT_ADDR + 0x1A0000300UL)
|
| 131 |
|
|
#define APECS_IOC_TLBDATA1 (IDENT_ADDR + 0x1A0000320UL)
|
| 132 |
|
|
#define APECS_IOC_TLBDATA2 (IDENT_ADDR + 0x1A0000340UL)
|
| 133 |
|
|
#define APECS_IOC_TLBDATA3 (IDENT_ADDR + 0x1A0000360UL)
|
| 134 |
|
|
#define APECS_IOC_TLBDATA4 (IDENT_ADDR + 0x1A0000380UL)
|
| 135 |
|
|
#define APECS_IOC_TLBDATA5 (IDENT_ADDR + 0x1A00003A0UL)
|
| 136 |
|
|
#define APECS_IOC_TLBDATA6 (IDENT_ADDR + 0x1A00003C0UL)
|
| 137 |
|
|
#define APECS_IOC_TLBDATA7 (IDENT_ADDR + 0x1A00003E0UL)
|
| 138 |
|
|
|
| 139 |
|
|
#define APECS_IOC_TBIA (IDENT_ADDR + 0x1A0000400UL)
|
| 140 |
|
|
|
| 141 |
|
|
|
| 142 |
|
|
/*
|
| 143 |
|
|
* 21071-CA Control and Status registers.
|
| 144 |
|
|
* These are used to program memory timing,
|
| 145 |
|
|
* configure memory and initialise the B-Cache.
|
| 146 |
|
|
*/
|
| 147 |
|
|
#define APECS_MEM_GCR (IDENT_ADDR + 0x180000000UL)
|
| 148 |
|
|
#define APECS_MEM_EDSR (IDENT_ADDR + 0x180000040UL)
|
| 149 |
|
|
#define APECS_MEM_TAR (IDENT_ADDR + 0x180000060UL)
|
| 150 |
|
|
#define APECS_MEM_ELAR (IDENT_ADDR + 0x180000080UL)
|
| 151 |
|
|
#define APECS_MEM_EHAR (IDENT_ADDR + 0x1800000a0UL)
|
| 152 |
|
|
#define APECS_MEM_SFT_RST (IDENT_ADDR + 0x1800000c0UL)
|
| 153 |
|
|
#define APECS_MEM_LDxLAR (IDENT_ADDR + 0x1800000e0UL)
|
| 154 |
|
|
#define APECS_MEM_LDxHAR (IDENT_ADDR + 0x180000100UL)
|
| 155 |
|
|
#define APECS_MEM_GTR (IDENT_ADDR + 0x180000200UL)
|
| 156 |
|
|
#define APECS_MEM_RTR (IDENT_ADDR + 0x180000220UL)
|
| 157 |
|
|
#define APECS_MEM_VFPR (IDENT_ADDR + 0x180000240UL)
|
| 158 |
|
|
#define APECS_MEM_PDLDR (IDENT_ADDR + 0x180000260UL)
|
| 159 |
|
|
#define APECS_MEM_PDhDR (IDENT_ADDR + 0x180000280UL)
|
| 160 |
|
|
|
| 161 |
|
|
/* Bank x Base Address Register */
|
| 162 |
|
|
#define APECS_MEM_B0BAR (IDENT_ADDR + 0x180000800UL)
|
| 163 |
|
|
#define APECS_MEM_B1BAR (IDENT_ADDR + 0x180000820UL)
|
| 164 |
|
|
#define APECS_MEM_B2BAR (IDENT_ADDR + 0x180000840UL)
|
| 165 |
|
|
#define APECS_MEM_B3BAR (IDENT_ADDR + 0x180000860UL)
|
| 166 |
|
|
#define APECS_MEM_B4BAR (IDENT_ADDR + 0x180000880UL)
|
| 167 |
|
|
#define APECS_MEM_B5BAR (IDENT_ADDR + 0x1800008A0UL)
|
| 168 |
|
|
#define APECS_MEM_B6BAR (IDENT_ADDR + 0x1800008C0UL)
|
| 169 |
|
|
#define APECS_MEM_B7BAR (IDENT_ADDR + 0x1800008E0UL)
|
| 170 |
|
|
#define APECS_MEM_B8BAR (IDENT_ADDR + 0x180000900UL)
|
| 171 |
|
|
|
| 172 |
|
|
/* Bank x Configuration Register */
|
| 173 |
|
|
#define APECS_MEM_B0BCR (IDENT_ADDR + 0x180000A00UL)
|
| 174 |
|
|
#define APECS_MEM_B1BCR (IDENT_ADDR + 0x180000A20UL)
|
| 175 |
|
|
#define APECS_MEM_B2BCR (IDENT_ADDR + 0x180000A40UL)
|
| 176 |
|
|
#define APECS_MEM_B3BCR (IDENT_ADDR + 0x180000A60UL)
|
| 177 |
|
|
#define APECS_MEM_B4BCR (IDENT_ADDR + 0x180000A80UL)
|
| 178 |
|
|
#define APECS_MEM_B5BCR (IDENT_ADDR + 0x180000AA0UL)
|
| 179 |
|
|
#define APECS_MEM_B6BCR (IDENT_ADDR + 0x180000AC0UL)
|
| 180 |
|
|
#define APECS_MEM_B7BCR (IDENT_ADDR + 0x180000AE0UL)
|
| 181 |
|
|
#define APECS_MEM_B8BCR (IDENT_ADDR + 0x180000B00UL)
|
| 182 |
|
|
|
| 183 |
|
|
/* Bank x Timing Register A */
|
| 184 |
|
|
#define APECS_MEM_B0TRA (IDENT_ADDR + 0x180000C00UL)
|
| 185 |
|
|
#define APECS_MEM_B1TRA (IDENT_ADDR + 0x180000C20UL)
|
| 186 |
|
|
#define APECS_MEM_B2TRA (IDENT_ADDR + 0x180000C40UL)
|
| 187 |
|
|
#define APECS_MEM_B3TRA (IDENT_ADDR + 0x180000C60UL)
|
| 188 |
|
|
#define APECS_MEM_B4TRA (IDENT_ADDR + 0x180000C80UL)
|
| 189 |
|
|
#define APECS_MEM_B5TRA (IDENT_ADDR + 0x180000CA0UL)
|
| 190 |
|
|
#define APECS_MEM_B6TRA (IDENT_ADDR + 0x180000CC0UL)
|
| 191 |
|
|
#define APECS_MEM_B7TRA (IDENT_ADDR + 0x180000CE0UL)
|
| 192 |
|
|
#define APECS_MEM_B8TRA (IDENT_ADDR + 0x180000D00UL)
|
| 193 |
|
|
|
| 194 |
|
|
/* Bank x Timing Register B */
|
| 195 |
|
|
#define APECS_MEM_B0TRB (IDENT_ADDR + 0x180000E00UL)
|
| 196 |
|
|
#define APECS_MEM_B1TRB (IDENT_ADDR + 0x180000E20UL)
|
| 197 |
|
|
#define APECS_MEM_B2TRB (IDENT_ADDR + 0x180000E40UL)
|
| 198 |
|
|
#define APECS_MEM_B3TRB (IDENT_ADDR + 0x180000E60UL)
|
| 199 |
|
|
#define APECS_MEM_B4TRB (IDENT_ADDR + 0x180000E80UL)
|
| 200 |
|
|
#define APECS_MEM_B5TRB (IDENT_ADDR + 0x180000EA0UL)
|
| 201 |
|
|
#define APECS_MEM_B6TRB (IDENT_ADDR + 0x180000EC0UL)
|
| 202 |
|
|
#define APECS_MEM_B7TRB (IDENT_ADDR + 0x180000EE0UL)
|
| 203 |
|
|
#define APECS_MEM_B8TRB (IDENT_ADDR + 0x180000F00UL)
|
| 204 |
|
|
|
| 205 |
|
|
|
| 206 |
|
|
/*
|
| 207 |
|
|
* Memory spaces:
|
| 208 |
|
|
*/
|
| 209 |
|
|
#define APECS_IACK_SC (IDENT_ADDR + 0x1b0000000UL)
|
| 210 |
|
|
#define APECS_CONF (IDENT_ADDR + 0x1e0000000UL)
|
| 211 |
|
|
#define APECS_IO (IDENT_ADDR + 0x1c0000000UL)
|
| 212 |
|
|
#define APECS_SPARSE_MEM (IDENT_ADDR + 0x200000000UL)
|
| 213 |
|
|
#define APECS_DENSE_MEM (IDENT_ADDR + 0x300000000UL)
|
| 214 |
|
|
|
| 215 |
|
|
/*
|
| 216 |
|
|
* Bit definitions for I/O Controller status register 0:
|
| 217 |
|
|
*/
|
| 218 |
|
|
#define APECS_IOC_STAT0_CMD 0xf
|
| 219 |
|
|
#define APECS_IOC_STAT0_ERR (1<<4)
|
| 220 |
|
|
#define APECS_IOC_STAT0_LOST (1<<5)
|
| 221 |
|
|
#define APECS_IOC_STAT0_THIT (1<<6)
|
| 222 |
|
|
#define APECS_IOC_STAT0_TREF (1<<7)
|
| 223 |
|
|
#define APECS_IOC_STAT0_CODE_SHIFT 8
|
| 224 |
|
|
#define APECS_IOC_STAT0_CODE_MASK 0x7
|
| 225 |
|
|
#define APECS_IOC_STAT0_P_NBR_SHIFT 13
|
| 226 |
|
|
#define APECS_IOC_STAT0_P_NBR_MASK 0x7ffff
|
| 227 |
|
|
|
| 228 |
|
|
#define HAE_ADDRESS APECS_IOC_HAXR1
|
| 229 |
|
|
|
| 230 |
|
|
#ifdef __KERNEL__
|
| 231 |
|
|
|
| 232 |
|
|
/*
|
| 233 |
|
|
* Translate physical memory address as seen on (PCI) bus into
|
| 234 |
|
|
* a kernel virtual address and vv.
|
| 235 |
|
|
*/
|
| 236 |
|
|
/* NOTE: we fudge the window 1 maximum as 48Mb instead of 64Mb, to prevent
|
| 237 |
|
|
virt_to_bus() from returning an address in the first window, for a
|
| 238 |
|
|
data area that goes beyond the 64Mb first DMA window. Sigh...
|
| 239 |
|
|
This MUST match with <asm/dma.h> MAX_DMA_ADDRESS for consistency, but
|
| 240 |
|
|
we can't just use that here, because of header file looping... :-(
|
| 241 |
|
|
*/
|
| 242 |
|
|
extern inline unsigned long virt_to_bus(void * address)
|
| 243 |
|
|
{
|
| 244 |
|
|
unsigned long paddr = virt_to_phys(address);
|
| 245 |
|
|
#ifdef CONFIG_ALPHA_XL
|
| 246 |
|
|
if (paddr < APECS_XL_DMA_WIN1_SIZE_PARANOID)
|
| 247 |
|
|
return paddr + APECS_XL_DMA_WIN1_BASE;
|
| 248 |
|
|
else
|
| 249 |
|
|
return paddr + APECS_XL_DMA_WIN2_BASE; /* win 2 xlates to 0 also */
|
| 250 |
|
|
#else /* CONFIG_ALPHA_XL */
|
| 251 |
|
|
return paddr + APECS_DMA_WIN_BASE;
|
| 252 |
|
|
#endif /* CONFIG_ALPHA_XL */
|
| 253 |
|
|
}
|
| 254 |
|
|
|
| 255 |
|
|
extern inline void * bus_to_virt(unsigned long address)
|
| 256 |
|
|
{
|
| 257 |
|
|
/*
|
| 258 |
|
|
* This check is a sanity check but also ensures that bus
|
| 259 |
|
|
* address 0 maps to virtual address 0 which is useful to
|
| 260 |
|
|
* detect null "pointers" (the NCR driver is much simpler if
|
| 261 |
|
|
* NULL pointers are preserved).
|
| 262 |
|
|
*/
|
| 263 |
|
|
#ifdef CONFIG_ALPHA_XL
|
| 264 |
|
|
if (address < APECS_XL_DMA_WIN1_BASE)
|
| 265 |
|
|
return 0;
|
| 266 |
|
|
else if (address < (APECS_XL_DMA_WIN1_BASE + APECS_XL_DMA_WIN1_SIZE))
|
| 267 |
|
|
return phys_to_virt(address - APECS_XL_DMA_WIN1_BASE);
|
| 268 |
|
|
else /* should be more checking here, maybe? */
|
| 269 |
|
|
return phys_to_virt(address - APECS_XL_DMA_WIN2_BASE);
|
| 270 |
|
|
#else /* CONFIG_ALPHA_XL */
|
| 271 |
|
|
if (address < APECS_DMA_WIN_BASE)
|
| 272 |
|
|
return 0;
|
| 273 |
|
|
return phys_to_virt(address - APECS_DMA_WIN_BASE);
|
| 274 |
|
|
#endif /* CONFIG_ALPHA_XL */
|
| 275 |
|
|
}
|
| 276 |
|
|
|
| 277 |
|
|
/*
|
| 278 |
|
|
* I/O functions:
|
| 279 |
|
|
*
|
| 280 |
|
|
* Unlike Jensen, the APECS machines have no concept of local
|
| 281 |
|
|
* I/O---everything goes over the PCI bus.
|
| 282 |
|
|
*
|
| 283 |
|
|
* There is plenty room for optimization here. In particular,
|
| 284 |
|
|
* the Alpha's insb/insw/extb/extw should be useful in moving
|
| 285 |
|
|
* data to/from the right byte-lanes.
|
| 286 |
|
|
*/
|
| 287 |
|
|
|
| 288 |
|
|
#define vuip volatile unsigned int *
|
| 289 |
|
|
|
| 290 |
|
|
extern inline unsigned int __inb(unsigned long addr)
|
| 291 |
|
|
{
|
| 292 |
|
|
long result = *(vuip) ((addr << 5) + APECS_IO + 0x00);
|
| 293 |
|
|
result >>= (addr & 3) * 8;
|
| 294 |
|
|
return 0xffUL & result;
|
| 295 |
|
|
}
|
| 296 |
|
|
|
| 297 |
|
|
extern inline void __outb(unsigned char b, unsigned long addr)
|
| 298 |
|
|
{
|
| 299 |
|
|
unsigned int w;
|
| 300 |
|
|
|
| 301 |
|
|
asm ("insbl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
|
| 302 |
|
|
*(vuip) ((addr << 5) + APECS_IO + 0x00) = w;
|
| 303 |
|
|
mb();
|
| 304 |
|
|
}
|
| 305 |
|
|
|
| 306 |
|
|
extern inline unsigned int __inw(unsigned long addr)
|
| 307 |
|
|
{
|
| 308 |
|
|
long result = *(vuip) ((addr << 5) + APECS_IO + 0x08);
|
| 309 |
|
|
result >>= (addr & 3) * 8;
|
| 310 |
|
|
return 0xffffUL & result;
|
| 311 |
|
|
}
|
| 312 |
|
|
|
| 313 |
|
|
extern inline void __outw(unsigned short b, unsigned long addr)
|
| 314 |
|
|
{
|
| 315 |
|
|
unsigned int w;
|
| 316 |
|
|
|
| 317 |
|
|
asm ("inswl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
|
| 318 |
|
|
*(vuip) ((addr << 5) + APECS_IO + 0x08) = w;
|
| 319 |
|
|
mb();
|
| 320 |
|
|
}
|
| 321 |
|
|
|
| 322 |
|
|
extern inline unsigned int __inl(unsigned long addr)
|
| 323 |
|
|
{
|
| 324 |
|
|
return *(vuip) ((addr << 5) + APECS_IO + 0x18);
|
| 325 |
|
|
}
|
| 326 |
|
|
|
| 327 |
|
|
extern inline void __outl(unsigned int b, unsigned long addr)
|
| 328 |
|
|
{
|
| 329 |
|
|
*(vuip) ((addr << 5) + APECS_IO + 0x18) = b;
|
| 330 |
|
|
mb();
|
| 331 |
|
|
}
|
| 332 |
|
|
|
| 333 |
|
|
|
| 334 |
|
|
/*
|
| 335 |
|
|
* Memory functions. 64-bit and 32-bit accesses are done through
|
| 336 |
|
|
* dense memory space, everything else through sparse space.
|
| 337 |
|
|
*/
|
| 338 |
|
|
extern inline unsigned long __readb(unsigned long addr)
|
| 339 |
|
|
{
|
| 340 |
|
|
unsigned long result, shift, msb;
|
| 341 |
|
|
|
| 342 |
|
|
shift = (addr & 0x3) * 8;
|
| 343 |
|
|
if (addr >= (1UL << 24)) {
|
| 344 |
|
|
msb = addr & 0xf8000000;
|
| 345 |
|
|
addr -= msb;
|
| 346 |
|
|
if (msb != hae.cache) {
|
| 347 |
|
|
set_hae(msb);
|
| 348 |
|
|
}
|
| 349 |
|
|
}
|
| 350 |
|
|
result = *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x00);
|
| 351 |
|
|
result >>= shift;
|
| 352 |
|
|
return 0xffUL & result;
|
| 353 |
|
|
}
|
| 354 |
|
|
|
| 355 |
|
|
extern inline unsigned long __readw(unsigned long addr)
|
| 356 |
|
|
{
|
| 357 |
|
|
unsigned long result, shift, msb;
|
| 358 |
|
|
|
| 359 |
|
|
shift = (addr & 0x3) * 8;
|
| 360 |
|
|
if (addr >= (1UL << 24)) {
|
| 361 |
|
|
msb = addr & 0xf8000000;
|
| 362 |
|
|
addr -= msb;
|
| 363 |
|
|
if (msb != hae.cache) {
|
| 364 |
|
|
set_hae(msb);
|
| 365 |
|
|
}
|
| 366 |
|
|
}
|
| 367 |
|
|
result = *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x08);
|
| 368 |
|
|
result >>= shift;
|
| 369 |
|
|
return 0xffffUL & result;
|
| 370 |
|
|
}
|
| 371 |
|
|
|
| 372 |
|
|
extern inline unsigned long __readl(unsigned long addr)
|
| 373 |
|
|
{
|
| 374 |
|
|
return *(vuip) (addr + APECS_DENSE_MEM);
|
| 375 |
|
|
}
|
| 376 |
|
|
|
| 377 |
|
|
extern inline void __writeb(unsigned char b, unsigned long addr)
|
| 378 |
|
|
{
|
| 379 |
|
|
unsigned long msb;
|
| 380 |
|
|
|
| 381 |
|
|
if (addr >= (1UL << 24)) {
|
| 382 |
|
|
msb = addr & 0xf8000000;
|
| 383 |
|
|
addr -= msb;
|
| 384 |
|
|
if (msb != hae.cache) {
|
| 385 |
|
|
set_hae(msb);
|
| 386 |
|
|
}
|
| 387 |
|
|
}
|
| 388 |
|
|
*(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x00) = b * 0x01010101;
|
| 389 |
|
|
}
|
| 390 |
|
|
|
| 391 |
|
|
extern inline void __writew(unsigned short b, unsigned long addr)
|
| 392 |
|
|
{
|
| 393 |
|
|
unsigned long msb;
|
| 394 |
|
|
|
| 395 |
|
|
if (addr >= (1UL << 24)) {
|
| 396 |
|
|
msb = addr & 0xf8000000;
|
| 397 |
|
|
addr -= msb;
|
| 398 |
|
|
if (msb != hae.cache) {
|
| 399 |
|
|
set_hae(msb);
|
| 400 |
|
|
}
|
| 401 |
|
|
}
|
| 402 |
|
|
*(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x08) = b * 0x00010001;
|
| 403 |
|
|
}
|
| 404 |
|
|
|
| 405 |
|
|
extern inline void __writel(unsigned int b, unsigned long addr)
|
| 406 |
|
|
{
|
| 407 |
|
|
*(vuip) (addr + APECS_DENSE_MEM) = b;
|
| 408 |
|
|
}
|
| 409 |
|
|
|
| 410 |
|
|
#define inb(port) \
|
| 411 |
|
|
(__builtin_constant_p((port))?__inb(port):_inb(port))
|
| 412 |
|
|
|
| 413 |
|
|
#define outb(x, port) \
|
| 414 |
|
|
(__builtin_constant_p((port))?__outb((x),(port)):_outb((x),(port)))
|
| 415 |
|
|
|
| 416 |
|
|
#define readl(a) __readl((unsigned long)(a))
|
| 417 |
|
|
#define writel(v,a) __writel((v),(unsigned long)(a))
|
| 418 |
|
|
|
| 419 |
|
|
#undef vuip
|
| 420 |
|
|
|
| 421 |
|
|
extern unsigned long apecs_init (unsigned long mem_start,
|
| 422 |
|
|
unsigned long mem_end);
|
| 423 |
|
|
|
| 424 |
|
|
#endif /* __KERNEL__ */
|
| 425 |
|
|
|
| 426 |
|
|
/*
|
| 427 |
|
|
* Data structure for handling APECS machine checks:
|
| 428 |
|
|
*/
|
| 429 |
|
|
#ifdef CONFIG_ALPHA_MIKASA
|
| 430 |
|
|
struct el_apecs_sysdata_mcheck {
|
| 431 |
|
|
unsigned long coma_gcr;
|
| 432 |
|
|
unsigned long coma_edsr;
|
| 433 |
|
|
unsigned long coma_ter;
|
| 434 |
|
|
unsigned long coma_elar;
|
| 435 |
|
|
unsigned long coma_ehar;
|
| 436 |
|
|
unsigned long coma_ldlr;
|
| 437 |
|
|
unsigned long coma_ldhr;
|
| 438 |
|
|
unsigned long coma_base0;
|
| 439 |
|
|
unsigned long coma_base1;
|
| 440 |
|
|
unsigned long coma_base2;
|
| 441 |
|
|
unsigned long coma_base3;
|
| 442 |
|
|
unsigned long coma_cnfg0;
|
| 443 |
|
|
unsigned long coma_cnfg1;
|
| 444 |
|
|
unsigned long coma_cnfg2;
|
| 445 |
|
|
unsigned long coma_cnfg3;
|
| 446 |
|
|
unsigned long epic_dcsr;
|
| 447 |
|
|
unsigned long epic_pear;
|
| 448 |
|
|
unsigned long epic_sear;
|
| 449 |
|
|
unsigned long epic_tbr1;
|
| 450 |
|
|
unsigned long epic_tbr2;
|
| 451 |
|
|
unsigned long epic_pbr1;
|
| 452 |
|
|
unsigned long epic_pbr2;
|
| 453 |
|
|
unsigned long epic_pmr1;
|
| 454 |
|
|
unsigned long epic_pmr2;
|
| 455 |
|
|
unsigned long epic_harx1;
|
| 456 |
|
|
unsigned long epic_harx2;
|
| 457 |
|
|
unsigned long epic_pmlt;
|
| 458 |
|
|
unsigned long epic_tag0;
|
| 459 |
|
|
unsigned long epic_tag1;
|
| 460 |
|
|
unsigned long epic_tag2;
|
| 461 |
|
|
unsigned long epic_tag3;
|
| 462 |
|
|
unsigned long epic_tag4;
|
| 463 |
|
|
unsigned long epic_tag5;
|
| 464 |
|
|
unsigned long epic_tag6;
|
| 465 |
|
|
unsigned long epic_tag7;
|
| 466 |
|
|
unsigned long epic_data0;
|
| 467 |
|
|
unsigned long epic_data1;
|
| 468 |
|
|
unsigned long epic_data2;
|
| 469 |
|
|
unsigned long epic_data3;
|
| 470 |
|
|
unsigned long epic_data4;
|
| 471 |
|
|
unsigned long epic_data5;
|
| 472 |
|
|
unsigned long epic_data6;
|
| 473 |
|
|
unsigned long epic_data7;
|
| 474 |
|
|
|
| 475 |
|
|
unsigned long pceb_vid;
|
| 476 |
|
|
unsigned long pceb_did;
|
| 477 |
|
|
unsigned long pceb_revision;
|
| 478 |
|
|
unsigned long pceb_command;
|
| 479 |
|
|
unsigned long pceb_status;
|
| 480 |
|
|
unsigned long pceb_latency;
|
| 481 |
|
|
unsigned long pceb_control;
|
| 482 |
|
|
unsigned long pceb_arbcon;
|
| 483 |
|
|
unsigned long pceb_arbpri;
|
| 484 |
|
|
|
| 485 |
|
|
unsigned long esc_id;
|
| 486 |
|
|
unsigned long esc_revision;
|
| 487 |
|
|
unsigned long esc_int0;
|
| 488 |
|
|
unsigned long esc_int1;
|
| 489 |
|
|
unsigned long esc_elcr0;
|
| 490 |
|
|
unsigned long esc_elcr1;
|
| 491 |
|
|
unsigned long esc_last_eisa;
|
| 492 |
|
|
unsigned long esc_nmi_stat;
|
| 493 |
|
|
|
| 494 |
|
|
unsigned long pci_ir;
|
| 495 |
|
|
unsigned long pci_imr;
|
| 496 |
|
|
unsigned long svr_mgr;
|
| 497 |
|
|
};
|
| 498 |
|
|
#else /* CONFIG_ALPHA_MIKASA */
|
| 499 |
|
|
/* this for the normal APECS machines */
|
| 500 |
|
|
struct el_apecs_sysdata_mcheck {
|
| 501 |
|
|
unsigned long coma_gcr;
|
| 502 |
|
|
unsigned long coma_edsr;
|
| 503 |
|
|
unsigned long coma_ter;
|
| 504 |
|
|
unsigned long coma_elar;
|
| 505 |
|
|
unsigned long coma_ehar;
|
| 506 |
|
|
unsigned long coma_ldlr;
|
| 507 |
|
|
unsigned long coma_ldhr;
|
| 508 |
|
|
unsigned long coma_base0;
|
| 509 |
|
|
unsigned long coma_base1;
|
| 510 |
|
|
unsigned long coma_base2;
|
| 511 |
|
|
unsigned long coma_cnfg0;
|
| 512 |
|
|
unsigned long coma_cnfg1;
|
| 513 |
|
|
unsigned long coma_cnfg2;
|
| 514 |
|
|
unsigned long epic_dcsr;
|
| 515 |
|
|
unsigned long epic_pear;
|
| 516 |
|
|
unsigned long epic_sear;
|
| 517 |
|
|
unsigned long epic_tbr1;
|
| 518 |
|
|
unsigned long epic_tbr2;
|
| 519 |
|
|
unsigned long epic_pbr1;
|
| 520 |
|
|
unsigned long epic_pbr2;
|
| 521 |
|
|
unsigned long epic_pmr1;
|
| 522 |
|
|
unsigned long epic_pmr2;
|
| 523 |
|
|
unsigned long epic_harx1;
|
| 524 |
|
|
unsigned long epic_harx2;
|
| 525 |
|
|
unsigned long epic_pmlt;
|
| 526 |
|
|
unsigned long epic_tag0;
|
| 527 |
|
|
unsigned long epic_tag1;
|
| 528 |
|
|
unsigned long epic_tag2;
|
| 529 |
|
|
unsigned long epic_tag3;
|
| 530 |
|
|
unsigned long epic_tag4;
|
| 531 |
|
|
unsigned long epic_tag5;
|
| 532 |
|
|
unsigned long epic_tag6;
|
| 533 |
|
|
unsigned long epic_tag7;
|
| 534 |
|
|
unsigned long epic_data0;
|
| 535 |
|
|
unsigned long epic_data1;
|
| 536 |
|
|
unsigned long epic_data2;
|
| 537 |
|
|
unsigned long epic_data3;
|
| 538 |
|
|
unsigned long epic_data4;
|
| 539 |
|
|
unsigned long epic_data5;
|
| 540 |
|
|
unsigned long epic_data6;
|
| 541 |
|
|
unsigned long epic_data7;
|
| 542 |
|
|
};
|
| 543 |
|
|
#endif /* CONFIG_ALPHA_MIKASA */
|
| 544 |
|
|
|
| 545 |
|
|
struct el_procdata {
|
| 546 |
|
|
unsigned long paltemp[32]; /* PAL TEMP REGS. */
|
| 547 |
|
|
/* EV4-specific fields */
|
| 548 |
|
|
unsigned long exc_addr; /* Address of excepting instruction. */
|
| 549 |
|
|
unsigned long exc_sum; /* Summary of arithmetic traps. */
|
| 550 |
|
|
unsigned long exc_mask; /* Exception mask (from exc_sum). */
|
| 551 |
|
|
unsigned long iccsr; /* IBox hardware enables. */
|
| 552 |
|
|
unsigned long pal_base; /* Base address for PALcode. */
|
| 553 |
|
|
unsigned long hier; /* Hardware Interrupt Enable. */
|
| 554 |
|
|
unsigned long hirr; /* Hardware Interrupt Request. */
|
| 555 |
|
|
unsigned long csr; /* D-stream fault info. */
|
| 556 |
|
|
unsigned long dc_stat; /* D-cache status (ECC/Parity Err). */
|
| 557 |
|
|
unsigned long dc_addr; /* EV3 Phys Addr for ECC/DPERR. */
|
| 558 |
|
|
unsigned long abox_ctl; /* ABox Control Register. */
|
| 559 |
|
|
unsigned long biu_stat; /* BIU Status. */
|
| 560 |
|
|
unsigned long biu_addr; /* BUI Address. */
|
| 561 |
|
|
unsigned long biu_ctl; /* BIU Control. */
|
| 562 |
|
|
unsigned long fill_syndrome;/* For correcting ECC errors. */
|
| 563 |
|
|
unsigned long fill_addr; /* Cache block which was being read */
|
| 564 |
|
|
unsigned long va; /* Effective VA of fault or miss. */
|
| 565 |
|
|
unsigned long bc_tag; /* Backup Cache Tag Probe Results.*/
|
| 566 |
|
|
};
|
| 567 |
|
|
|
| 568 |
|
|
|
| 569 |
|
|
#define RTC_PORT(x) (0x70 + (x))
|
| 570 |
|
|
#define RTC_ADDR(x) (0x80 | (x))
|
| 571 |
|
|
#define RTC_ALWAYS_BCD 0
|
| 572 |
|
|
|
| 573 |
|
|
#endif /* __ALPHA_APECS__H__ */
|