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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-m68knommu/] [mcfsmc.h] - Blame information for rev 1633

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

Line No. Rev Author Line
1 1633 jcastillo
/****************************************************************************/
2
 
3
/*
4
 *      mcfsmc.h -- SMC ethernet support for ColdFire environments.
5
 *
6
 *      (C) Copyright 1999, Greg Ungerer (gerg@moreton.com.au)
7
 */
8
 
9
/****************************************************************************/
10
#ifndef mcfsmc_h
11
#define mcfsmc_h
12
/****************************************************************************/
13
 
14
#include <linux/config.h>
15
 
16
#undef  outb
17
#undef  inb
18
 
19
/*
20
 *      Re-defines for ColdFire environment... The SMC part is
21
 *      mapped into memory space, so remap the PC-style in/out
22
 *      routines to handle that.
23
 */
24
#define outb    smc_outb
25
#define inb     smc_inb
26
#define outw    smc_outw
27
#define outwd   smc_outwd
28
#define inw     smc_inw
29
#define outl    smc_outl
30
#define inl     smc_inl
31
 
32
#define outsb   smc_outsb
33
#define outsw   smc_outsw
34
#define outsl   smc_outsl
35
#define insb    smc_insb
36
#define insw    smc_insw
37
#define insl    smc_insl
38
 
39
 
40
inline int smc_inb(unsigned int addr)
41
{
42
        register unsigned short w;
43
        w = *((volatile unsigned short *) (addr & ~0x1));
44
        return(((addr & 0x1) ? w : (w >> 8)) & 0xff);
45
}
46
 
47
inline void smc_outw(unsigned int val, unsigned int addr)
48
{
49
        *((volatile unsigned short *) addr) = ((val << 8) | (val >> 8));
50
}
51
 
52
inline int smc_inw(unsigned int addr)
53
{
54
        register unsigned short w;
55
        w = *((volatile unsigned short *) addr);
56
        return(((w << 8) | (w >> 8)) & 0xffff);
57
}
58
 
59
inline void smc_outl(unsigned long val, unsigned int addr)
60
{
61
        *((volatile unsigned long *) addr) =
62
                ((val << 8) & 0xff000000) | ((val >> 8) & 0x00ff0000) |
63
                ((val << 8) & 0x0000ff00) | ((val >> 8) & 0x000000ff);
64
}
65
 
66
inline void smc_outwd(unsigned int val, unsigned int addr)
67
{
68
        *((volatile unsigned short *) addr) = val;
69
}
70
 
71
 
72
/*
73
 *      The rep* functions are used to feed the data port with
74
 *      raw data. So we do not byte swap them when copying.
75
 */
76
 
77
inline void smc_insb(unsigned int addr, void *vbuf, int unsigned long len)
78
{
79
        volatile unsigned short *rp;
80
        unsigned short          *buf, *ebuf;
81
 
82
        buf = (unsigned short *) vbuf;
83
        rp = (volatile unsigned short *) addr;
84
 
85
        /* Copy as words for as long as possible */
86
        for (ebuf = buf + (len >> 1); (buf < ebuf); )
87
                *buf++ = *rp;
88
 
89
        /* Lastly, handle left over byte */
90
        if (len & 0x1)
91
                *((unsigned char *) buf) = (*rp >> 8) & 0xff;
92
}
93
 
94
inline void smc_insw(unsigned int addr, void *vbuf, unsigned long len)
95
{
96
        volatile unsigned short *rp;
97
        unsigned short          *buf, *ebuf;
98
 
99
        buf = (unsigned short *) vbuf;
100
        rp = (volatile unsigned short *) addr;
101
        for (ebuf = buf + len; (buf < ebuf); )
102
                *buf++ = *rp;
103
}
104
 
105
inline void smc_insl(unsigned int addr, void *vbuf, unsigned long len)
106
{
107
        volatile unsigned long  *rp;
108
        unsigned long           *buf, *ebuf;
109
 
110
        buf = (unsigned long *) vbuf;
111
        rp = (volatile unsigned long *) addr;
112
        for (ebuf = buf + len; (buf < ebuf); )
113
                *buf++ = *rp;
114
}
115
 
116
inline void smc_outsw(unsigned int addr, const void *vbuf, unsigned long len)
117
{
118
        volatile unsigned short *rp;
119
        unsigned short          *buf, *ebuf;
120
 
121
        buf = (unsigned short *) vbuf;
122
        rp = (volatile unsigned short *) addr;
123
        for (ebuf = buf + len; (buf < ebuf); )
124
                *rp = *buf++;
125
}
126
 
127
inline void smc_outsl(unsigned int addr, void *vbuf, unsigned long len)
128
{
129
        volatile unsigned long  *rp;
130
        unsigned long           *buf, *ebuf;
131
 
132
        buf = (unsigned long *) vbuf;
133
        rp = (volatile unsigned long *) addr;
134
        for (ebuf = buf + len; (buf < ebuf); )
135
                *rp = *buf++;
136
}
137
 
138
 
139
#ifdef CONFIG_NETtel
140
/*
141
 *      Re-map the address space of at least one of the SMC ethernet
142
 *      parts. Both parts power up decoding the same address, so we
143
 *      need to move one of them first, before doing enything else.
144
 */
145
 
146
void smc_remap(unsigned int ioaddr)
147
{
148
        static int              once = 0;
149
        extern unsigned short   ppdata;
150
        if (once++ == 0) {
151
                *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADDR)) = 0x00ec;
152
                ppdata |= 0x0080;
153
                *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADAT)) = ppdata;
154
                outw(0x0001, ioaddr + BANK_SELECT);
155
                outw(0x0001, ioaddr + BANK_SELECT);
156
                outw(0x0067, ioaddr + BASE);
157
 
158
                ppdata &= ~0x0080;
159
                *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADAT)) = ppdata;
160
        }
161
}
162
 
163
#endif
164
 
165
/****************************************************************************/
166
#endif  /* mcfsmc_h */

powered by: WebSVN 2.1.0

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