Path: blob/master/arch/alpha/include/asm/core_apecs.h
15126 views
#ifndef __ALPHA_APECS__H__1#define __ALPHA_APECS__H__23#include <linux/types.h>4#include <asm/compiler.h>56/*7* APECS is the internal name for the 2107x chipset which provides8* 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 Chipsets13* Data Sheet14*15* EC-N0648-7216*17*18* [email protected] Initial Version.19*20*/2122/*23An AVANTI *might* be an XL, and an XL has only 27 bits of ISA address24that get passed through the PCI<->ISA bridge chip. So we've gotta use25both windows to max out the physical memory we can DMA to. Sigh...2627If we try a window at 0 for 1GB as a work-around, we run into conflicts28with ISA/PCI bus memory which can't be relocated, like VGA aperture and29BIOS ROMs. So we must put the windows high enough to avoid these areas.3031We put window 1 at BUS 64Mb for 64Mb, mapping physical 0 to 64Mb-1,32and window 2 at BUS 1Gb for 1Gb, mapping physical 0 to 1Gb-1.33Yes, this does map 0 to 64Mb-1 twice, but only window 1 will actually34be used for that range (via virt_to_bus()).3536Note that we actually fudge the window 1 maximum as 48Mb instead of 64Mb,37to keep virt_to_bus() from returning an address in the first window, for38a data area that goes beyond the 64Mb first DMA window. Sigh...39The fudge factor MUST match with <asm/dma.h> MAX_DMA_ADDRESS, but40we can't just use that here, because of header file looping... :-(4142Window 1 will be used for all DMA from the ISA bus; yes, that does43limit what memory an ISA floppy or sound card or Ethernet can touch, but44it's also a known limitation on other platforms as well. We use the45same technique that is used on INTEL platforms with similar limitation:46set MAX_DMA_ADDRESS and clear some pages' DMAable flags during mem_init().47We trust that any ISA bus device drivers will *always* ask for DMAable48memory explicitly via kmalloc()/get_free_pages() flags arguments.4950Note that most PCI bus devices' drivers do *not* explicitly ask for51DMAable memory; they count on being able to DMA to any memory they52get from kmalloc()/get_free_pages(). They will also use window 1 for53any physical memory accesses below 64Mb; the rest will be handled by54window 2, maxing out at 1Gb of memory. I trust this is enough... :-)5556We hope that the area before the first window is large enough so that57there will be no overlap at the top end (64Mb). We *must* locate the58PCI cards' memory just below window 1, so that there's still the59possibility of being able to access it via SPARSE space. This is60important for cards such as the Matrox Millennium, whose Xserver61wants to access memory-mapped registers in byte and short lengths.6263Note that the XL is treated differently from the AVANTI, even though64for most other things they are identical. It didn't seem reasonable to65make the AVANTI support pay for the limitations of the XL. It is true,66however, that an XL kernel will run on an AVANTI without problems.6768%%% All of this should be obviated by the ability to route69everything through the iommu.70*/7172/*73* 21071-DA Control and Status registers.74* These are used for PCI memory access.75*/76#define APECS_IOC_DCSR (IDENT_ADDR + 0x1A0000000UL)77#define APECS_IOC_PEAR (IDENT_ADDR + 0x1A0000020UL)78#define APECS_IOC_SEAR (IDENT_ADDR + 0x1A0000040UL)79#define APECS_IOC_DR1 (IDENT_ADDR + 0x1A0000060UL)80#define APECS_IOC_DR2 (IDENT_ADDR + 0x1A0000080UL)81#define APECS_IOC_DR3 (IDENT_ADDR + 0x1A00000A0UL)8283#define APECS_IOC_TB1R (IDENT_ADDR + 0x1A00000C0UL)84#define APECS_IOC_TB2R (IDENT_ADDR + 0x1A00000E0UL)8586#define APECS_IOC_PB1R (IDENT_ADDR + 0x1A0000100UL)87#define APECS_IOC_PB2R (IDENT_ADDR + 0x1A0000120UL)8889#define APECS_IOC_PM1R (IDENT_ADDR + 0x1A0000140UL)90#define APECS_IOC_PM2R (IDENT_ADDR + 0x1A0000160UL)9192#define APECS_IOC_HAXR0 (IDENT_ADDR + 0x1A0000180UL)93#define APECS_IOC_HAXR1 (IDENT_ADDR + 0x1A00001A0UL)94#define APECS_IOC_HAXR2 (IDENT_ADDR + 0x1A00001C0UL)9596#define APECS_IOC_PMLT (IDENT_ADDR + 0x1A00001E0UL)9798#define APECS_IOC_TLBTAG0 (IDENT_ADDR + 0x1A0000200UL)99#define APECS_IOC_TLBTAG1 (IDENT_ADDR + 0x1A0000220UL)100#define APECS_IOC_TLBTAG2 (IDENT_ADDR + 0x1A0000240UL)101#define APECS_IOC_TLBTAG3 (IDENT_ADDR + 0x1A0000260UL)102#define APECS_IOC_TLBTAG4 (IDENT_ADDR + 0x1A0000280UL)103#define APECS_IOC_TLBTAG5 (IDENT_ADDR + 0x1A00002A0UL)104#define APECS_IOC_TLBTAG6 (IDENT_ADDR + 0x1A00002C0UL)105#define APECS_IOC_TLBTAG7 (IDENT_ADDR + 0x1A00002E0UL)106107#define APECS_IOC_TLBDATA0 (IDENT_ADDR + 0x1A0000300UL)108#define APECS_IOC_TLBDATA1 (IDENT_ADDR + 0x1A0000320UL)109#define APECS_IOC_TLBDATA2 (IDENT_ADDR + 0x1A0000340UL)110#define APECS_IOC_TLBDATA3 (IDENT_ADDR + 0x1A0000360UL)111#define APECS_IOC_TLBDATA4 (IDENT_ADDR + 0x1A0000380UL)112#define APECS_IOC_TLBDATA5 (IDENT_ADDR + 0x1A00003A0UL)113#define APECS_IOC_TLBDATA6 (IDENT_ADDR + 0x1A00003C0UL)114#define APECS_IOC_TLBDATA7 (IDENT_ADDR + 0x1A00003E0UL)115116#define APECS_IOC_TBIA (IDENT_ADDR + 0x1A0000400UL)117118119/*120* 21071-CA Control and Status registers.121* These are used to program memory timing,122* configure memory and initialise the B-Cache.123*/124#define APECS_MEM_GCR (IDENT_ADDR + 0x180000000UL)125#define APECS_MEM_EDSR (IDENT_ADDR + 0x180000040UL)126#define APECS_MEM_TAR (IDENT_ADDR + 0x180000060UL)127#define APECS_MEM_ELAR (IDENT_ADDR + 0x180000080UL)128#define APECS_MEM_EHAR (IDENT_ADDR + 0x1800000a0UL)129#define APECS_MEM_SFT_RST (IDENT_ADDR + 0x1800000c0UL)130#define APECS_MEM_LDxLAR (IDENT_ADDR + 0x1800000e0UL)131#define APECS_MEM_LDxHAR (IDENT_ADDR + 0x180000100UL)132#define APECS_MEM_GTR (IDENT_ADDR + 0x180000200UL)133#define APECS_MEM_RTR (IDENT_ADDR + 0x180000220UL)134#define APECS_MEM_VFPR (IDENT_ADDR + 0x180000240UL)135#define APECS_MEM_PDLDR (IDENT_ADDR + 0x180000260UL)136#define APECS_MEM_PDhDR (IDENT_ADDR + 0x180000280UL)137138/* Bank x Base Address Register */139#define APECS_MEM_B0BAR (IDENT_ADDR + 0x180000800UL)140#define APECS_MEM_B1BAR (IDENT_ADDR + 0x180000820UL)141#define APECS_MEM_B2BAR (IDENT_ADDR + 0x180000840UL)142#define APECS_MEM_B3BAR (IDENT_ADDR + 0x180000860UL)143#define APECS_MEM_B4BAR (IDENT_ADDR + 0x180000880UL)144#define APECS_MEM_B5BAR (IDENT_ADDR + 0x1800008A0UL)145#define APECS_MEM_B6BAR (IDENT_ADDR + 0x1800008C0UL)146#define APECS_MEM_B7BAR (IDENT_ADDR + 0x1800008E0UL)147#define APECS_MEM_B8BAR (IDENT_ADDR + 0x180000900UL)148149/* Bank x Configuration Register */150#define APECS_MEM_B0BCR (IDENT_ADDR + 0x180000A00UL)151#define APECS_MEM_B1BCR (IDENT_ADDR + 0x180000A20UL)152#define APECS_MEM_B2BCR (IDENT_ADDR + 0x180000A40UL)153#define APECS_MEM_B3BCR (IDENT_ADDR + 0x180000A60UL)154#define APECS_MEM_B4BCR (IDENT_ADDR + 0x180000A80UL)155#define APECS_MEM_B5BCR (IDENT_ADDR + 0x180000AA0UL)156#define APECS_MEM_B6BCR (IDENT_ADDR + 0x180000AC0UL)157#define APECS_MEM_B7BCR (IDENT_ADDR + 0x180000AE0UL)158#define APECS_MEM_B8BCR (IDENT_ADDR + 0x180000B00UL)159160/* Bank x Timing Register A */161#define APECS_MEM_B0TRA (IDENT_ADDR + 0x180000C00UL)162#define APECS_MEM_B1TRA (IDENT_ADDR + 0x180000C20UL)163#define APECS_MEM_B2TRA (IDENT_ADDR + 0x180000C40UL)164#define APECS_MEM_B3TRA (IDENT_ADDR + 0x180000C60UL)165#define APECS_MEM_B4TRA (IDENT_ADDR + 0x180000C80UL)166#define APECS_MEM_B5TRA (IDENT_ADDR + 0x180000CA0UL)167#define APECS_MEM_B6TRA (IDENT_ADDR + 0x180000CC0UL)168#define APECS_MEM_B7TRA (IDENT_ADDR + 0x180000CE0UL)169#define APECS_MEM_B8TRA (IDENT_ADDR + 0x180000D00UL)170171/* Bank x Timing Register B */172#define APECS_MEM_B0TRB (IDENT_ADDR + 0x180000E00UL)173#define APECS_MEM_B1TRB (IDENT_ADDR + 0x180000E20UL)174#define APECS_MEM_B2TRB (IDENT_ADDR + 0x180000E40UL)175#define APECS_MEM_B3TRB (IDENT_ADDR + 0x180000E60UL)176#define APECS_MEM_B4TRB (IDENT_ADDR + 0x180000E80UL)177#define APECS_MEM_B5TRB (IDENT_ADDR + 0x180000EA0UL)178#define APECS_MEM_B6TRB (IDENT_ADDR + 0x180000EC0UL)179#define APECS_MEM_B7TRB (IDENT_ADDR + 0x180000EE0UL)180#define APECS_MEM_B8TRB (IDENT_ADDR + 0x180000F00UL)181182183/*184* Memory spaces:185*/186#define APECS_IACK_SC (IDENT_ADDR + 0x1b0000000UL)187#define APECS_CONF (IDENT_ADDR + 0x1e0000000UL)188#define APECS_IO (IDENT_ADDR + 0x1c0000000UL)189#define APECS_SPARSE_MEM (IDENT_ADDR + 0x200000000UL)190#define APECS_DENSE_MEM (IDENT_ADDR + 0x300000000UL)191192193/*194* Bit definitions for I/O Controller status register 0:195*/196#define APECS_IOC_STAT0_CMD 0xf197#define APECS_IOC_STAT0_ERR (1<<4)198#define APECS_IOC_STAT0_LOST (1<<5)199#define APECS_IOC_STAT0_THIT (1<<6)200#define APECS_IOC_STAT0_TREF (1<<7)201#define APECS_IOC_STAT0_CODE_SHIFT 8202#define APECS_IOC_STAT0_CODE_MASK 0x7203#define APECS_IOC_STAT0_P_NBR_SHIFT 13204#define APECS_IOC_STAT0_P_NBR_MASK 0x7ffff205206#define APECS_HAE_ADDRESS APECS_IOC_HAXR1207208209/*210* Data structure for handling APECS machine checks:211*/212213struct el_apecs_mikasa_sysdata_mcheck214{215unsigned long coma_gcr;216unsigned long coma_edsr;217unsigned long coma_ter;218unsigned long coma_elar;219unsigned long coma_ehar;220unsigned long coma_ldlr;221unsigned long coma_ldhr;222unsigned long coma_base0;223unsigned long coma_base1;224unsigned long coma_base2;225unsigned long coma_base3;226unsigned long coma_cnfg0;227unsigned long coma_cnfg1;228unsigned long coma_cnfg2;229unsigned long coma_cnfg3;230unsigned long epic_dcsr;231unsigned long epic_pear;232unsigned long epic_sear;233unsigned long epic_tbr1;234unsigned long epic_tbr2;235unsigned long epic_pbr1;236unsigned long epic_pbr2;237unsigned long epic_pmr1;238unsigned long epic_pmr2;239unsigned long epic_harx1;240unsigned long epic_harx2;241unsigned long epic_pmlt;242unsigned long epic_tag0;243unsigned long epic_tag1;244unsigned long epic_tag2;245unsigned long epic_tag3;246unsigned long epic_tag4;247unsigned long epic_tag5;248unsigned long epic_tag6;249unsigned long epic_tag7;250unsigned long epic_data0;251unsigned long epic_data1;252unsigned long epic_data2;253unsigned long epic_data3;254unsigned long epic_data4;255unsigned long epic_data5;256unsigned long epic_data6;257unsigned long epic_data7;258259unsigned long pceb_vid;260unsigned long pceb_did;261unsigned long pceb_revision;262unsigned long pceb_command;263unsigned long pceb_status;264unsigned long pceb_latency;265unsigned long pceb_control;266unsigned long pceb_arbcon;267unsigned long pceb_arbpri;268269unsigned long esc_id;270unsigned long esc_revision;271unsigned long esc_int0;272unsigned long esc_int1;273unsigned long esc_elcr0;274unsigned long esc_elcr1;275unsigned long esc_last_eisa;276unsigned long esc_nmi_stat;277278unsigned long pci_ir;279unsigned long pci_imr;280unsigned long svr_mgr;281};282283/* This for the normal APECS machines. */284struct el_apecs_sysdata_mcheck285{286unsigned long coma_gcr;287unsigned long coma_edsr;288unsigned long coma_ter;289unsigned long coma_elar;290unsigned long coma_ehar;291unsigned long coma_ldlr;292unsigned long coma_ldhr;293unsigned long coma_base0;294unsigned long coma_base1;295unsigned long coma_base2;296unsigned long coma_cnfg0;297unsigned long coma_cnfg1;298unsigned long coma_cnfg2;299unsigned long epic_dcsr;300unsigned long epic_pear;301unsigned long epic_sear;302unsigned long epic_tbr1;303unsigned long epic_tbr2;304unsigned long epic_pbr1;305unsigned long epic_pbr2;306unsigned long epic_pmr1;307unsigned long epic_pmr2;308unsigned long epic_harx1;309unsigned long epic_harx2;310unsigned long epic_pmlt;311unsigned long epic_tag0;312unsigned long epic_tag1;313unsigned long epic_tag2;314unsigned long epic_tag3;315unsigned long epic_tag4;316unsigned long epic_tag5;317unsigned long epic_tag6;318unsigned long epic_tag7;319unsigned long epic_data0;320unsigned long epic_data1;321unsigned long epic_data2;322unsigned long epic_data3;323unsigned long epic_data4;324unsigned long epic_data5;325unsigned long epic_data6;326unsigned long epic_data7;327};328329struct el_apecs_procdata330{331unsigned long paltemp[32]; /* PAL TEMP REGS. */332/* EV4-specific fields */333unsigned long exc_addr; /* Address of excepting instruction. */334unsigned long exc_sum; /* Summary of arithmetic traps. */335unsigned long exc_mask; /* Exception mask (from exc_sum). */336unsigned long iccsr; /* IBox hardware enables. */337unsigned long pal_base; /* Base address for PALcode. */338unsigned long hier; /* Hardware Interrupt Enable. */339unsigned long hirr; /* Hardware Interrupt Request. */340unsigned long csr; /* D-stream fault info. */341unsigned long dc_stat; /* D-cache status (ECC/Parity Err). */342unsigned long dc_addr; /* EV3 Phys Addr for ECC/DPERR. */343unsigned long abox_ctl; /* ABox Control Register. */344unsigned long biu_stat; /* BIU Status. */345unsigned long biu_addr; /* BUI Address. */346unsigned long biu_ctl; /* BIU Control. */347unsigned long fill_syndrome;/* For correcting ECC errors. */348unsigned long fill_addr; /* Cache block which was being read */349unsigned long va; /* Effective VA of fault or miss. */350unsigned long bc_tag; /* Backup Cache Tag Probe Results.*/351};352353354#ifdef __KERNEL__355356#ifndef __EXTERN_INLINE357#define __EXTERN_INLINE extern inline358#define __IO_EXTERN_INLINE359#endif360361/*362* I/O functions:363*364* Unlike Jensen, the APECS machines have no concept of local365* I/O---everything goes over the PCI bus.366*367* There is plenty room for optimization here. In particular,368* the Alpha's insb/insw/extb/extw should be useful in moving369* data to/from the right byte-lanes.370*/371372#define vip volatile int __force *373#define vuip volatile unsigned int __force *374#define vulp volatile unsigned long __force *375376#define APECS_SET_HAE \377do { \378if (addr >= (1UL << 24)) { \379unsigned long msb = addr & 0xf8000000; \380addr -= msb; \381set_hae(msb); \382} \383} while (0)384385__EXTERN_INLINE unsigned int apecs_ioread8(void __iomem *xaddr)386{387unsigned long addr = (unsigned long) xaddr;388unsigned long result, base_and_type;389390if (addr >= APECS_DENSE_MEM) {391addr -= APECS_DENSE_MEM;392APECS_SET_HAE;393base_and_type = APECS_SPARSE_MEM + 0x00;394} else {395addr -= APECS_IO;396base_and_type = APECS_IO + 0x00;397}398399result = *(vip) ((addr << 5) + base_and_type);400return __kernel_extbl(result, addr & 3);401}402403__EXTERN_INLINE void apecs_iowrite8(u8 b, void __iomem *xaddr)404{405unsigned long addr = (unsigned long) xaddr;406unsigned long w, base_and_type;407408if (addr >= APECS_DENSE_MEM) {409addr -= APECS_DENSE_MEM;410APECS_SET_HAE;411base_and_type = APECS_SPARSE_MEM + 0x00;412} else {413addr -= APECS_IO;414base_and_type = APECS_IO + 0x00;415}416417w = __kernel_insbl(b, addr & 3);418*(vuip) ((addr << 5) + base_and_type) = w;419}420421__EXTERN_INLINE unsigned int apecs_ioread16(void __iomem *xaddr)422{423unsigned long addr = (unsigned long) xaddr;424unsigned long result, base_and_type;425426if (addr >= APECS_DENSE_MEM) {427addr -= APECS_DENSE_MEM;428APECS_SET_HAE;429base_and_type = APECS_SPARSE_MEM + 0x08;430} else {431addr -= APECS_IO;432base_and_type = APECS_IO + 0x08;433}434435result = *(vip) ((addr << 5) + base_and_type);436return __kernel_extwl(result, addr & 3);437}438439__EXTERN_INLINE void apecs_iowrite16(u16 b, void __iomem *xaddr)440{441unsigned long addr = (unsigned long) xaddr;442unsigned long w, base_and_type;443444if (addr >= APECS_DENSE_MEM) {445addr -= APECS_DENSE_MEM;446APECS_SET_HAE;447base_and_type = APECS_SPARSE_MEM + 0x08;448} else {449addr -= APECS_IO;450base_and_type = APECS_IO + 0x08;451}452453w = __kernel_inswl(b, addr & 3);454*(vuip) ((addr << 5) + base_and_type) = w;455}456457__EXTERN_INLINE unsigned int apecs_ioread32(void __iomem *xaddr)458{459unsigned long addr = (unsigned long) xaddr;460if (addr < APECS_DENSE_MEM)461addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;462return *(vuip)addr;463}464465__EXTERN_INLINE void apecs_iowrite32(u32 b, void __iomem *xaddr)466{467unsigned long addr = (unsigned long) xaddr;468if (addr < APECS_DENSE_MEM)469addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;470*(vuip)addr = b;471}472473__EXTERN_INLINE void __iomem *apecs_ioportmap(unsigned long addr)474{475return (void __iomem *)(addr + APECS_IO);476}477478__EXTERN_INLINE void __iomem *apecs_ioremap(unsigned long addr,479unsigned long size)480{481return (void __iomem *)(addr + APECS_DENSE_MEM);482}483484__EXTERN_INLINE int apecs_is_ioaddr(unsigned long addr)485{486return addr >= IDENT_ADDR + 0x180000000UL;487}488489__EXTERN_INLINE int apecs_is_mmio(const volatile void __iomem *addr)490{491return (unsigned long)addr >= APECS_DENSE_MEM;492}493494#undef APECS_SET_HAE495496#undef vip497#undef vuip498#undef vulp499500#undef __IO_PREFIX501#define __IO_PREFIX apecs502#define apecs_trivial_io_bw 0503#define apecs_trivial_io_lq 0504#define apecs_trivial_rw_bw 2505#define apecs_trivial_rw_lq 1506#define apecs_trivial_iounmap 1507#include <asm/io_trivial.h>508509#ifdef __IO_EXTERN_INLINE510#undef __EXTERN_INLINE511#undef __IO_EXTERN_INLINE512#endif513514#endif /* __KERNEL__ */515516#endif /* __ALPHA_APECS__H__ */517518519