OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [include/] [asm-alpha/] [lca.h] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#include <linux/config.h> /* CONFIG_ALPHA_SRM_SETUP */
2
#ifndef __ALPHA_LCA__H__
3
#define __ALPHA_LCA__H__
4
 
5
/*
6
 * Low Cost Alpha (LCA) definitions (these apply to 21066 and 21068,
7
 * for example).
8
 *
9
 * This file is based on:
10
 *
11
 *      DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors
12
 *      Hardware Reference Manual; Digital Equipment Corp.; May 1994;
13
 *      Maynard, MA; Order Number: EC-N2681-71.
14
 */
15
 
16
/*
17
 * NOTE: The LCA uses a Host Address Extension (HAE) register to access
18
 *       PCI addresses that are beyond the first 27 bits of address
19
 *       space.  Updating the HAE requires an external cycle (and
20
 *       a memory barrier), which tends to be slow.  Instead of updating
21
 *       it on each sparse memory access, we keep the current HAE value
22
 *       cached in variable cache_hae.  Only if the cached HAE differs
23
 *       from the desired HAE value do we actually updated HAE register.
24
 *       The HAE register is preserved by the interrupt handler entry/exit
25
 *       code, so this scheme works even in the presence of interrupts.
26
 *
27
 * Dense memory space doesn't require the HAE, but is restricted to
28
 * aligned 32 and 64 bit accesses.  Special Cycle and Interrupt
29
 * Acknowledge cycles may also require the use of the HAE.  The LCA
30
 * limits I/O address space to the bottom 24 bits of address space,
31
 * but this easily covers the 16 bit ISA I/O address space.
32
 */
33
 
34
/*
35
 * NOTE 2! The memory operations do not set any memory barriers, as
36
 * it's not needed for cases like a frame buffer that is essentially
37
 * memory-like.  You need to do them by hand if the operations depend
38
 * on ordering.
39
 *
40
 * Similarly, the port I/O operations do a "mb" only after a write
41
 * operation: if an mb is needed before (as in the case of doing
42
 * memory mapped I/O first, and then a port I/O operation to the same
43
 * device), it needs to be done by hand.
44
 *
45
 * After the above has bitten me 100 times, I'll give up and just do
46
 * the mb all the time, but right now I'm hoping this will work out.
47
 * Avoiding mb's may potentially be a noticeable speed improvement,
48
 * but I can't honestly say I've tested it.
49
 *
50
 * Handling interrupts that need to do mb's to synchronize to
51
 * non-interrupts is another fun race area.  Don't do it (because if
52
 * you do, I'll have to do *everything* with interrupts disabled,
53
 * ugh).
54
 */
55
 
56
#include <asm/system.h>
57
 
58
#ifdef CONFIG_ALPHA_SRM_SETUP
59
/* if we are using the SRM PCI setup, we'll need to use variables instead */
60
#define LCA_DMA_WIN_BASE_DEFAULT    (1024*1024*1024)
61
#define LCA_DMA_WIN_SIZE_DEFAULT    (1024*1024*1024)
62
 
63
extern unsigned int LCA_DMA_WIN_BASE;
64
extern unsigned int LCA_DMA_WIN_SIZE;
65
 
66
#else /* SRM_SETUP */
67
#define LCA_DMA_WIN_BASE        (1024*1024*1024)
68
#define LCA_DMA_WIN_SIZE        (1024*1024*1024)
69
#endif /* SRM_SETUP */
70
 
71
/*
72
 * Memory Controller registers:
73
 */
74
#define LCA_MEM_BCR0            (IDENT_ADDR + 0x120000000UL)
75
#define LCA_MEM_BCR1            (IDENT_ADDR + 0x120000008UL)
76
#define LCA_MEM_BCR2            (IDENT_ADDR + 0x120000010UL)
77
#define LCA_MEM_BCR3            (IDENT_ADDR + 0x120000018UL)
78
#define LCA_MEM_BMR0            (IDENT_ADDR + 0x120000020UL)
79
#define LCA_MEM_BMR1            (IDENT_ADDR + 0x120000028UL)
80
#define LCA_MEM_BMR2            (IDENT_ADDR + 0x120000030UL)
81
#define LCA_MEM_BMR3            (IDENT_ADDR + 0x120000038UL)
82
#define LCA_MEM_BTR0            (IDENT_ADDR + 0x120000040UL)
83
#define LCA_MEM_BTR1            (IDENT_ADDR + 0x120000048UL)
84
#define LCA_MEM_BTR2            (IDENT_ADDR + 0x120000050UL)
85
#define LCA_MEM_BTR3            (IDENT_ADDR + 0x120000058UL)
86
#define LCA_MEM_GTR             (IDENT_ADDR + 0x120000060UL)
87
#define LCA_MEM_ESR             (IDENT_ADDR + 0x120000068UL)
88
#define LCA_MEM_EAR             (IDENT_ADDR + 0x120000070UL)
89
#define LCA_MEM_CAR             (IDENT_ADDR + 0x120000078UL)
90
#define LCA_MEM_VGR             (IDENT_ADDR + 0x120000080UL)
91
#define LCA_MEM_PLM             (IDENT_ADDR + 0x120000088UL)
92
#define LCA_MEM_FOR             (IDENT_ADDR + 0x120000090UL)
93
 
94
/*
95
 * I/O Controller registers:
96
 */
97
#define LCA_IOC_HAE             (IDENT_ADDR + 0x180000000UL)
98
#define LCA_IOC_CONF            (IDENT_ADDR + 0x180000020UL)
99
#define LCA_IOC_STAT0           (IDENT_ADDR + 0x180000040UL)
100
#define LCA_IOC_STAT1           (IDENT_ADDR + 0x180000060UL)
101
#define LCA_IOC_TBIA            (IDENT_ADDR + 0x180000080UL)
102
#define LCA_IOC_TB_ENA          (IDENT_ADDR + 0x1800000a0UL)
103
#define LCA_IOC_SFT_RST         (IDENT_ADDR + 0x1800000c0UL)
104
#define LCA_IOC_PAR_DIS         (IDENT_ADDR + 0x1800000e0UL)
105
#define LCA_IOC_W_BASE0         (IDENT_ADDR + 0x180000100UL)
106
#define LCA_IOC_W_BASE1         (IDENT_ADDR + 0x180000120UL)
107
#define LCA_IOC_W_MASK0         (IDENT_ADDR + 0x180000140UL)
108
#define LCA_IOC_W_MASK1         (IDENT_ADDR + 0x180000160UL)
109
#define LCA_IOC_T_BASE0         (IDENT_ADDR + 0x180000180UL)
110
#define LCA_IOC_T_BASE1         (IDENT_ADDR + 0x1800001a0UL)
111
#define LCA_IOC_TB_TAG0         (IDENT_ADDR + 0x188000000UL)
112
#define LCA_IOC_TB_TAG1         (IDENT_ADDR + 0x188000020UL)
113
#define LCA_IOC_TB_TAG2         (IDENT_ADDR + 0x188000040UL)
114
#define LCA_IOC_TB_TAG3         (IDENT_ADDR + 0x188000060UL)
115
#define LCA_IOC_TB_TAG4         (IDENT_ADDR + 0x188000070UL)
116
#define LCA_IOC_TB_TAG5         (IDENT_ADDR + 0x1880000a0UL)
117
#define LCA_IOC_TB_TAG6         (IDENT_ADDR + 0x1880000c0UL)
118
#define LCA_IOC_TB_TAG7         (IDENT_ADDR + 0x1880000e0UL)
119
 
120
/*
121
 * Memory spaces:
122
 */
123
#define LCA_IACK_SC             (IDENT_ADDR + 0x1a0000000UL)
124
#define LCA_CONF                (IDENT_ADDR + 0x1e0000000UL)
125
#define LCA_IO                  (IDENT_ADDR + 0x1c0000000UL)
126
#define LCA_SPARSE_MEM          (IDENT_ADDR + 0x200000000UL)
127
#define LCA_DENSE_MEM           (IDENT_ADDR + 0x300000000UL)
128
 
129
/*
130
 * Bit definitions for I/O Controller status register 0:
131
 */
132
#define LCA_IOC_STAT0_CMD               0xf
133
#define LCA_IOC_STAT0_ERR               (1<<4)
134
#define LCA_IOC_STAT0_LOST              (1<<5)
135
#define LCA_IOC_STAT0_THIT              (1<<6)
136
#define LCA_IOC_STAT0_TREF              (1<<7)
137
#define LCA_IOC_STAT0_CODE_SHIFT        8
138
#define LCA_IOC_STAT0_CODE_MASK         0x7
139
#define LCA_IOC_STAT0_P_NBR_SHIFT       13
140
#define LCA_IOC_STAT0_P_NBR_MASK        0x7ffff
141
 
142
#define HAE_ADDRESS     LCA_IOC_HAE
143
 
144
/* LCA PMR Power Management register defines */
145
#define LCA_PMR_ADDR    (IDENT_ADDR + 0x120000098UL)
146
#define LCA_PMR_PDIV    0x7                     /* Primary clock divisor */
147
#define LCA_PMR_ODIV    0x38                    /* Override clock divisor */
148
#define LCA_PMR_INTO    0x40                    /* Interrupt override */
149
#define LCA_PMR_DMAO    0x80                    /* DMA override */
150
#define LCA_PMR_OCCEB   0xffff0000L             /* Override cycle counter - even
151
 bits */
152
#define LCA_PMR_OCCOB   0xffff000000000000L     /* Override cycle counter - even
153
 bits */
154
#define LCA_PMR_PRIMARY_MASK    0xfffffffffffffff8
155
/* LCA PMR Macros */
156
 
157
#define READ_PMR        (*(volatile unsigned long *)LCA_PMR_ADDR)
158
#define WRITE_PMR(d)    (*((volatile unsigned long *)LCA_PMR_ADDR) = (d))
159
 
160
#define GET_PRIMARY(r)  ((r) & LCA_PMR_PDIV)
161
#define GET_OVERRIDE(r) (((r) >> 3) & LCA_PMR_PDIV)
162
#define SET_PRIMARY_CLOCK(r, c) ((r) = (((r) & LCA_PMR_PRIMARY_MASK) | (c)))
163
 
164
/* LCA PMR Divisor values */
165
#define DIV_1   0x0
166
#define DIV_1_5 0x1
167
#define DIV_2   0x2
168
#define DIV_4   0x3
169
#define DIV_8   0x4
170
#define DIV_16  0x5
171
#define DIV_MIN DIV_1
172
#define DIV_MAX DIV_16
173
 
174
 
175
#ifdef __KERNEL__
176
 
177
/*
178
 * Translate physical memory address as seen on (PCI) bus into
179
 * a kernel virtual address and vv.
180
 */
181
extern inline unsigned long virt_to_bus(void * address)
182
{
183
        return virt_to_phys(address) + LCA_DMA_WIN_BASE;
184
}
185
 
186
extern inline void * bus_to_virt(unsigned long address)
187
{
188
        /*
189
         * This check is a sanity check but also ensures that bus
190
         * address 0 maps to virtual address 0 which is useful to
191
         * detect null "pointers" (the NCR driver is much simpler if
192
         * NULL pointers are preserved).
193
         */
194
        if (address < LCA_DMA_WIN_BASE)
195
                return 0;
196
        return phys_to_virt(address - LCA_DMA_WIN_BASE);
197
}
198
 
199
/*
200
 * I/O functions:
201
 *
202
 * Unlike Jensen, the Noname machines have no concept of local
203
 * I/O---everything goes over the PCI bus.
204
 *
205
 * There is plenty room for optimization here.  In particular,
206
 * the Alpha's insb/insw/extb/extw should be useful in moving
207
 * data to/from the right byte-lanes.
208
 */
209
 
210
#define vuip    volatile unsigned int *
211
 
212
extern inline unsigned int __inb(unsigned long addr)
213
{
214
        long result = *(vuip) ((addr << 5) + LCA_IO + 0x00);
215
        result >>= (addr & 3) * 8;
216
        return 0xffUL & result;
217
}
218
 
219
extern inline void __outb(unsigned char b, unsigned long addr)
220
{
221
        unsigned int w;
222
 
223
        asm ("insbl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
224
        *(vuip) ((addr << 5) + LCA_IO + 0x00) = w;
225
        mb();
226
}
227
 
228
extern inline unsigned int __inw(unsigned long addr)
229
{
230
        long result = *(vuip) ((addr << 5) + LCA_IO + 0x08);
231
        result >>= (addr & 3) * 8;
232
        return 0xffffUL & result;
233
}
234
 
235
extern inline void __outw(unsigned short b, unsigned long addr)
236
{
237
        unsigned int w;
238
 
239
        asm ("inswl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
240
        *(vuip) ((addr << 5) + LCA_IO + 0x08) = w;
241
        mb();
242
}
243
 
244
extern inline unsigned int __inl(unsigned long addr)
245
{
246
        return *(vuip) ((addr << 5) + LCA_IO + 0x18);
247
}
248
 
249
extern inline void __outl(unsigned int b, unsigned long addr)
250
{
251
        *(vuip) ((addr << 5) + LCA_IO + 0x18) = b;
252
        mb();
253
}
254
 
255
 
256
/*
257
 * Memory functions.  64-bit and 32-bit accesses are done through
258
 * dense memory space, everything else through sparse space.
259
 */
260
extern inline unsigned long __readb(unsigned long addr)
261
{
262
        unsigned long result, shift, msb;
263
 
264
        shift = (addr & 0x3) * 8;
265
        if (addr >= (1UL << 24)) {
266
                msb = addr & 0xf8000000;
267
                addr -= msb;
268
                if (msb != hae.cache) {
269
                        set_hae(msb);
270
                }
271
        }
272
        result = *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x00);
273
        result >>= shift;
274
        return 0xffUL & result;
275
}
276
 
277
extern inline unsigned long __readw(unsigned long addr)
278
{
279
        unsigned long result, shift, msb;
280
 
281
        shift = (addr & 0x3) * 8;
282
        if (addr >= (1UL << 24)) {
283
                msb = addr & 0xf8000000;
284
                addr -= msb;
285
                if (msb != hae.cache) {
286
                        set_hae(msb);
287
                }
288
        }
289
        result = *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x08);
290
        result >>= shift;
291
        return 0xffffUL & result;
292
}
293
 
294
extern inline unsigned long __readl(unsigned long addr)
295
{
296
        return *(vuip) (addr + LCA_DENSE_MEM);
297
}
298
 
299
extern inline void __writeb(unsigned char b, unsigned long addr)
300
{
301
        unsigned long msb;
302
        unsigned int w;
303
 
304
        if (addr >= (1UL << 24)) {
305
                msb = addr & 0xf8000000;
306
                addr -= msb;
307
                if (msb != hae.cache) {
308
                        set_hae(msb);
309
                }
310
        }
311
        asm ("insbl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
312
        *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x00) = w;
313
}
314
 
315
extern inline void __writew(unsigned short b, unsigned long addr)
316
{
317
        unsigned long msb;
318
        unsigned int w;
319
 
320
        if (addr >= (1UL << 24)) {
321
                msb = addr & 0xf8000000;
322
                addr -= msb;
323
                if (msb != hae.cache) {
324
                        set_hae(msb);
325
                }
326
        }
327
        asm ("inswl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
328
        *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x08) = w;
329
}
330
 
331
extern inline void __writel(unsigned int b, unsigned long addr)
332
{
333
        *(vuip) (addr + LCA_DENSE_MEM) = b;
334
}
335
 
336
/*
337
 * Most of the above have so much overhead that it probably doesn't
338
 * make sense to have them inlined (better icache behavior).
339
 */
340
 
341
#define inb(port) \
342
(__builtin_constant_p((port))?__inb(port):_inb(port))
343
 
344
#define outb(x, port) \
345
(__builtin_constant_p((port))?__outb((x),(port)):_outb((x),(port)))
346
 
347
#define readl(a)        __readl((unsigned long)(a))
348
#define writel(v,a)     __writel((v),(unsigned long)(a))
349
 
350
#undef vuip
351
 
352
extern unsigned long lca_init (unsigned long mem_start, unsigned long mem_end);
353
 
354
#endif /* __KERNEL__ */
355
 
356
/*
357
 * Data structure for handling LCA machine checks.  Correctable errors
358
 * result in a short logout frame, uncorrectable ones in a long one.
359
 */
360
struct el_lca_mcheck_short {
361
        struct el_common        h;              /* common logout header */
362
        unsigned long           esr;            /* error-status register */
363
        unsigned long           ear;            /* error-address register */
364
        unsigned long           dc_stat;        /* dcache status register */
365
        unsigned long           ioc_stat0;      /* I/O controller status register 0 */
366
        unsigned long           ioc_stat1;      /* I/O controller status register 1 */
367
};
368
 
369
struct el_lca_mcheck_long {
370
        struct el_common        h;              /* common logout header */
371
        unsigned long           pt[31];         /* PAL temps */
372
        unsigned long           exc_addr;       /* exception address */
373
        unsigned long           pad1[3];
374
        unsigned long           pal_base;       /* PALcode base address */
375
        unsigned long           hier;           /* hw interrupt enable */
376
        unsigned long           hirr;           /* hw interrupt request */
377
        unsigned long           mm_csr;         /* MMU control & status */
378
        unsigned long           dc_stat;        /* data cache status */
379
        unsigned long           dc_addr;        /* data cache addr register */
380
        unsigned long           abox_ctl;       /* address box control register */
381
        unsigned long           esr;            /* error status register */
382
        unsigned long           ear;            /* error address register */
383
        unsigned long           car;            /* cache control register */
384
        unsigned long           ioc_stat0;      /* I/O controller status register 0 */
385
        unsigned long           ioc_stat1;      /* I/O controller status register 1 */
386
        unsigned long           va;             /* virtual address register */
387
};
388
 
389
union el_lca {
390
        struct el_common *              c;
391
        struct el_lca_mcheck_long *     l;
392
        struct el_lca_mcheck_short *    s;
393
};
394
 
395
#define RTC_PORT(x)     (0x70 + (x))
396
#define RTC_ADDR(x)     (0x80 | (x))
397
#define RTC_ALWAYS_BCD  0
398
 
399
#endif /* __ALPHA_LCA__H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.