Path: blob/master/arch/alpha/include/asm/core_lca.h
15126 views
#ifndef __ALPHA_LCA__H__1#define __ALPHA_LCA__H__23#include <asm/system.h>4#include <asm/compiler.h>56/*7* Low Cost Alpha (LCA) definitions (these apply to 21066 and 21068,8* for example).9*10* This file is based on:11*12* DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors13* Hardware Reference Manual; Digital Equipment Corp.; May 1994;14* Maynard, MA; Order Number: EC-N2681-71.15*/1617/*18* NOTE: The LCA uses a Host Address Extension (HAE) register to access19* PCI addresses that are beyond the first 27 bits of address20* space. Updating the HAE requires an external cycle (and21* a memory barrier), which tends to be slow. Instead of updating22* it on each sparse memory access, we keep the current HAE value23* cached in variable cache_hae. Only if the cached HAE differs24* from the desired HAE value do we actually updated HAE register.25* The HAE register is preserved by the interrupt handler entry/exit26* code, so this scheme works even in the presence of interrupts.27*28* Dense memory space doesn't require the HAE, but is restricted to29* aligned 32 and 64 bit accesses. Special Cycle and Interrupt30* Acknowledge cycles may also require the use of the HAE. The LCA31* limits I/O address space to the bottom 24 bits of address space,32* but this easily covers the 16 bit ISA I/O address space.33*/3435/*36* NOTE 2! The memory operations do not set any memory barriers, as37* it's not needed for cases like a frame buffer that is essentially38* memory-like. You need to do them by hand if the operations depend39* on ordering.40*41* Similarly, the port I/O operations do a "mb" only after a write42* operation: if an mb is needed before (as in the case of doing43* memory mapped I/O first, and then a port I/O operation to the same44* device), it needs to be done by hand.45*46* After the above has bitten me 100 times, I'll give up and just do47* the mb all the time, but right now I'm hoping this will work out.48* Avoiding mb's may potentially be a noticeable speed improvement,49* but I can't honestly say I've tested it.50*51* Handling interrupts that need to do mb's to synchronize to52* non-interrupts is another fun race area. Don't do it (because if53* you do, I'll have to do *everything* with interrupts disabled,54* ugh).55*/5657/*58* Memory Controller registers:59*/60#define LCA_MEM_BCR0 (IDENT_ADDR + 0x120000000UL)61#define LCA_MEM_BCR1 (IDENT_ADDR + 0x120000008UL)62#define LCA_MEM_BCR2 (IDENT_ADDR + 0x120000010UL)63#define LCA_MEM_BCR3 (IDENT_ADDR + 0x120000018UL)64#define LCA_MEM_BMR0 (IDENT_ADDR + 0x120000020UL)65#define LCA_MEM_BMR1 (IDENT_ADDR + 0x120000028UL)66#define LCA_MEM_BMR2 (IDENT_ADDR + 0x120000030UL)67#define LCA_MEM_BMR3 (IDENT_ADDR + 0x120000038UL)68#define LCA_MEM_BTR0 (IDENT_ADDR + 0x120000040UL)69#define LCA_MEM_BTR1 (IDENT_ADDR + 0x120000048UL)70#define LCA_MEM_BTR2 (IDENT_ADDR + 0x120000050UL)71#define LCA_MEM_BTR3 (IDENT_ADDR + 0x120000058UL)72#define LCA_MEM_GTR (IDENT_ADDR + 0x120000060UL)73#define LCA_MEM_ESR (IDENT_ADDR + 0x120000068UL)74#define LCA_MEM_EAR (IDENT_ADDR + 0x120000070UL)75#define LCA_MEM_CAR (IDENT_ADDR + 0x120000078UL)76#define LCA_MEM_VGR (IDENT_ADDR + 0x120000080UL)77#define LCA_MEM_PLM (IDENT_ADDR + 0x120000088UL)78#define LCA_MEM_FOR (IDENT_ADDR + 0x120000090UL)7980/*81* I/O Controller registers:82*/83#define LCA_IOC_HAE (IDENT_ADDR + 0x180000000UL)84#define LCA_IOC_CONF (IDENT_ADDR + 0x180000020UL)85#define LCA_IOC_STAT0 (IDENT_ADDR + 0x180000040UL)86#define LCA_IOC_STAT1 (IDENT_ADDR + 0x180000060UL)87#define LCA_IOC_TBIA (IDENT_ADDR + 0x180000080UL)88#define LCA_IOC_TB_ENA (IDENT_ADDR + 0x1800000a0UL)89#define LCA_IOC_SFT_RST (IDENT_ADDR + 0x1800000c0UL)90#define LCA_IOC_PAR_DIS (IDENT_ADDR + 0x1800000e0UL)91#define LCA_IOC_W_BASE0 (IDENT_ADDR + 0x180000100UL)92#define LCA_IOC_W_BASE1 (IDENT_ADDR + 0x180000120UL)93#define LCA_IOC_W_MASK0 (IDENT_ADDR + 0x180000140UL)94#define LCA_IOC_W_MASK1 (IDENT_ADDR + 0x180000160UL)95#define LCA_IOC_T_BASE0 (IDENT_ADDR + 0x180000180UL)96#define LCA_IOC_T_BASE1 (IDENT_ADDR + 0x1800001a0UL)97#define LCA_IOC_TB_TAG0 (IDENT_ADDR + 0x188000000UL)98#define LCA_IOC_TB_TAG1 (IDENT_ADDR + 0x188000020UL)99#define LCA_IOC_TB_TAG2 (IDENT_ADDR + 0x188000040UL)100#define LCA_IOC_TB_TAG3 (IDENT_ADDR + 0x188000060UL)101#define LCA_IOC_TB_TAG4 (IDENT_ADDR + 0x188000070UL)102#define LCA_IOC_TB_TAG5 (IDENT_ADDR + 0x1880000a0UL)103#define LCA_IOC_TB_TAG6 (IDENT_ADDR + 0x1880000c0UL)104#define LCA_IOC_TB_TAG7 (IDENT_ADDR + 0x1880000e0UL)105106/*107* Memory spaces:108*/109#define LCA_IACK_SC (IDENT_ADDR + 0x1a0000000UL)110#define LCA_CONF (IDENT_ADDR + 0x1e0000000UL)111#define LCA_IO (IDENT_ADDR + 0x1c0000000UL)112#define LCA_SPARSE_MEM (IDENT_ADDR + 0x200000000UL)113#define LCA_DENSE_MEM (IDENT_ADDR + 0x300000000UL)114115/*116* Bit definitions for I/O Controller status register 0:117*/118#define LCA_IOC_STAT0_CMD 0xf119#define LCA_IOC_STAT0_ERR (1<<4)120#define LCA_IOC_STAT0_LOST (1<<5)121#define LCA_IOC_STAT0_THIT (1<<6)122#define LCA_IOC_STAT0_TREF (1<<7)123#define LCA_IOC_STAT0_CODE_SHIFT 8124#define LCA_IOC_STAT0_CODE_MASK 0x7125#define LCA_IOC_STAT0_P_NBR_SHIFT 13126#define LCA_IOC_STAT0_P_NBR_MASK 0x7ffff127128#define LCA_HAE_ADDRESS LCA_IOC_HAE129130/* LCA PMR Power Management register defines */131#define LCA_PMR_ADDR (IDENT_ADDR + 0x120000098UL)132#define LCA_PMR_PDIV 0x7 /* Primary clock divisor */133#define LCA_PMR_ODIV 0x38 /* Override clock divisor */134#define LCA_PMR_INTO 0x40 /* Interrupt override */135#define LCA_PMR_DMAO 0x80 /* DMA override */136#define LCA_PMR_OCCEB 0xffff0000L /* Override cycle counter - even bits */137#define LCA_PMR_OCCOB 0xffff000000000000L /* Override cycle counter - even bits */138#define LCA_PMR_PRIMARY_MASK 0xfffffffffffffff8L139140/* LCA PMR Macros */141142#define LCA_READ_PMR (*(volatile unsigned long *)LCA_PMR_ADDR)143#define LCA_WRITE_PMR(d) (*((volatile unsigned long *)LCA_PMR_ADDR) = (d))144145#define LCA_GET_PRIMARY(r) ((r) & LCA_PMR_PDIV)146#define LCA_GET_OVERRIDE(r) (((r) >> 3) & LCA_PMR_PDIV)147#define LCA_SET_PRIMARY_CLOCK(r, c) ((r) = (((r) & LCA_PMR_PRIMARY_MASK)|(c)))148149/* LCA PMR Divisor values */150#define LCA_PMR_DIV_1 0x0151#define LCA_PMR_DIV_1_5 0x1152#define LCA_PMR_DIV_2 0x2153#define LCA_PMR_DIV_4 0x3154#define LCA_PMR_DIV_8 0x4155#define LCA_PMR_DIV_16 0x5156#define LCA_PMR_DIV_MIN DIV_1157#define LCA_PMR_DIV_MAX DIV_16158159160/*161* Data structure for handling LCA machine checks. Correctable errors162* result in a short logout frame, uncorrectable ones in a long one.163*/164struct el_lca_mcheck_short {165struct el_common h; /* common logout header */166unsigned long esr; /* error-status register */167unsigned long ear; /* error-address register */168unsigned long dc_stat; /* dcache status register */169unsigned long ioc_stat0; /* I/O controller status register 0 */170unsigned long ioc_stat1; /* I/O controller status register 1 */171};172173struct el_lca_mcheck_long {174struct el_common h; /* common logout header */175unsigned long pt[31]; /* PAL temps */176unsigned long exc_addr; /* exception address */177unsigned long pad1[3];178unsigned long pal_base; /* PALcode base address */179unsigned long hier; /* hw interrupt enable */180unsigned long hirr; /* hw interrupt request */181unsigned long mm_csr; /* MMU control & status */182unsigned long dc_stat; /* data cache status */183unsigned long dc_addr; /* data cache addr register */184unsigned long abox_ctl; /* address box control register */185unsigned long esr; /* error status register */186unsigned long ear; /* error address register */187unsigned long car; /* cache control register */188unsigned long ioc_stat0; /* I/O controller status register 0 */189unsigned long ioc_stat1; /* I/O controller status register 1 */190unsigned long va; /* virtual address register */191};192193union el_lca {194struct el_common * c;195struct el_lca_mcheck_long * l;196struct el_lca_mcheck_short * s;197};198199#ifdef __KERNEL__200201#ifndef __EXTERN_INLINE202#define __EXTERN_INLINE extern inline203#define __IO_EXTERN_INLINE204#endif205206/*207* I/O functions:208*209* Unlike Jensen, the Noname machines have no concept of local210* I/O---everything goes over the PCI bus.211*212* There is plenty room for optimization here. In particular,213* the Alpha's insb/insw/extb/extw should be useful in moving214* data to/from the right byte-lanes.215*/216217#define vip volatile int __force *218#define vuip volatile unsigned int __force *219#define vulp volatile unsigned long __force *220221#define LCA_SET_HAE \222do { \223if (addr >= (1UL << 24)) { \224unsigned long msb = addr & 0xf8000000; \225addr -= msb; \226set_hae(msb); \227} \228} while (0)229230231__EXTERN_INLINE unsigned int lca_ioread8(void __iomem *xaddr)232{233unsigned long addr = (unsigned long) xaddr;234unsigned long result, base_and_type;235236if (addr >= LCA_DENSE_MEM) {237addr -= LCA_DENSE_MEM;238LCA_SET_HAE;239base_and_type = LCA_SPARSE_MEM + 0x00;240} else {241addr -= LCA_IO;242base_and_type = LCA_IO + 0x00;243}244245result = *(vip) ((addr << 5) + base_and_type);246return __kernel_extbl(result, addr & 3);247}248249__EXTERN_INLINE void lca_iowrite8(u8 b, void __iomem *xaddr)250{251unsigned long addr = (unsigned long) xaddr;252unsigned long w, base_and_type;253254if (addr >= LCA_DENSE_MEM) {255addr -= LCA_DENSE_MEM;256LCA_SET_HAE;257base_and_type = LCA_SPARSE_MEM + 0x00;258} else {259addr -= LCA_IO;260base_and_type = LCA_IO + 0x00;261}262263w = __kernel_insbl(b, addr & 3);264*(vuip) ((addr << 5) + base_and_type) = w;265}266267__EXTERN_INLINE unsigned int lca_ioread16(void __iomem *xaddr)268{269unsigned long addr = (unsigned long) xaddr;270unsigned long result, base_and_type;271272if (addr >= LCA_DENSE_MEM) {273addr -= LCA_DENSE_MEM;274LCA_SET_HAE;275base_and_type = LCA_SPARSE_MEM + 0x08;276} else {277addr -= LCA_IO;278base_and_type = LCA_IO + 0x08;279}280281result = *(vip) ((addr << 5) + base_and_type);282return __kernel_extwl(result, addr & 3);283}284285__EXTERN_INLINE void lca_iowrite16(u16 b, void __iomem *xaddr)286{287unsigned long addr = (unsigned long) xaddr;288unsigned long w, base_and_type;289290if (addr >= LCA_DENSE_MEM) {291addr -= LCA_DENSE_MEM;292LCA_SET_HAE;293base_and_type = LCA_SPARSE_MEM + 0x08;294} else {295addr -= LCA_IO;296base_and_type = LCA_IO + 0x08;297}298299w = __kernel_inswl(b, addr & 3);300*(vuip) ((addr << 5) + base_and_type) = w;301}302303__EXTERN_INLINE unsigned int lca_ioread32(void __iomem *xaddr)304{305unsigned long addr = (unsigned long) xaddr;306if (addr < LCA_DENSE_MEM)307addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;308return *(vuip)addr;309}310311__EXTERN_INLINE void lca_iowrite32(u32 b, void __iomem *xaddr)312{313unsigned long addr = (unsigned long) xaddr;314if (addr < LCA_DENSE_MEM)315addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;316*(vuip)addr = b;317}318319__EXTERN_INLINE void __iomem *lca_ioportmap(unsigned long addr)320{321return (void __iomem *)(addr + LCA_IO);322}323324__EXTERN_INLINE void __iomem *lca_ioremap(unsigned long addr,325unsigned long size)326{327return (void __iomem *)(addr + LCA_DENSE_MEM);328}329330__EXTERN_INLINE int lca_is_ioaddr(unsigned long addr)331{332return addr >= IDENT_ADDR + 0x120000000UL;333}334335__EXTERN_INLINE int lca_is_mmio(const volatile void __iomem *addr)336{337return (unsigned long)addr >= LCA_DENSE_MEM;338}339340#undef vip341#undef vuip342#undef vulp343344#undef __IO_PREFIX345#define __IO_PREFIX lca346#define lca_trivial_rw_bw 2347#define lca_trivial_rw_lq 1348#define lca_trivial_io_bw 0349#define lca_trivial_io_lq 0350#define lca_trivial_iounmap 1351#include <asm/io_trivial.h>352353#ifdef __IO_EXTERN_INLINE354#undef __EXTERN_INLINE355#undef __IO_EXTERN_INLINE356#endif357358#endif /* __KERNEL__ */359360#endif /* __ALPHA_LCA__H__ */361362363