1 /****************************************************************************/
4 * mcfsmc.h -- SMC ethernet support for ColdFire environments.
6 * (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2000, Lineo Inc. (www.lineo.com)
10 /****************************************************************************/
13 /****************************************************************************/
16 * None of the current ColdFire targets that use the SMC91x111
17 * allow 8 bit accesses. So this code is 16bit access only.
37 * Re-defines for ColdFire environment... The SMC part is
38 * mapped into memory space, so remap the PC-style in/out
39 * routines to handle that.
44 #define outwd smc_outwd
49 #define outsb smc_outsb
50 #define outsw smc_outsw
51 #define outsl smc_outsl
57 static inline int smc_inb(unsigned int addr
)
59 register unsigned short w
;
60 w
= *((volatile unsigned short *) (addr
& ~0x1));
61 return(((addr
& 0x1) ? w
: (w
>> 8)) & 0xff);
64 static inline void smc_outw(unsigned int val
, unsigned int addr
)
66 *((volatile unsigned short *) addr
) = (val
<< 8) | (val
>> 8);
69 static inline int smc_inw(unsigned int addr
)
71 register unsigned short w
;
72 w
= *((volatile unsigned short *) addr
);
73 return(((w
<< 8) | (w
>> 8)) & 0xffff);
76 static inline void smc_outl(unsigned long val
, unsigned int addr
)
78 *((volatile unsigned long *) addr
) =
79 ((val
<< 8) & 0xff000000) | ((val
>> 8) & 0x00ff0000) |
80 ((val
<< 8) & 0x0000ff00) | ((val
>> 8) & 0x000000ff);
83 static inline void smc_outwd(unsigned int val
, unsigned int addr
)
85 *((volatile unsigned short *) addr
) = val
;
90 * The rep* functions are used to feed the data port with
91 * raw data. So we do not byte swap them when copying.
94 static inline void smc_insb(unsigned int addr
, void *vbuf
, int unsigned long len
)
96 volatile unsigned short *rp
;
97 unsigned short *buf
, *ebuf
;
99 buf
= (unsigned short *) vbuf
;
100 rp
= (volatile unsigned short *) addr
;
102 /* Copy as words for as long as possible */
103 for (ebuf
= buf
+ (len
>> 1); (buf
< ebuf
); )
106 /* Lastly, handle left over byte */
108 *((unsigned char *) buf
) = (*rp
>> 8) & 0xff;
111 static inline void smc_insw(unsigned int addr
, void *vbuf
, unsigned long len
)
113 volatile unsigned short *rp
;
114 unsigned short *buf
, *ebuf
;
116 buf
= (unsigned short *) vbuf
;
117 rp
= (volatile unsigned short *) addr
;
118 for (ebuf
= buf
+ len
; (buf
< ebuf
); )
122 static inline void smc_insl(unsigned int addr
, void *vbuf
, unsigned long len
)
124 volatile unsigned long *rp
;
125 unsigned long *buf
, *ebuf
;
127 buf
= (unsigned long *) vbuf
;
128 rp
= (volatile unsigned long *) addr
;
129 for (ebuf
= buf
+ len
; (buf
< ebuf
); )
133 static inline void smc_outsw(unsigned int addr
, const void *vbuf
, unsigned long len
)
135 volatile unsigned short *rp
;
136 unsigned short *buf
, *ebuf
;
138 buf
= (unsigned short *) vbuf
;
139 rp
= (volatile unsigned short *) addr
;
140 for (ebuf
= buf
+ len
; (buf
< ebuf
); )
144 static inline void smc_outsl(unsigned int addr
, void *vbuf
, unsigned long len
)
146 volatile unsigned long *rp
;
147 unsigned long *buf
, *ebuf
;
149 buf
= (unsigned long *) vbuf
;
150 rp
= (volatile unsigned long *) addr
;
151 for (ebuf
= buf
+ len
; (buf
< ebuf
); )
158 * Re-map the address space of at least one of the SMC ethernet
159 * parts. Both parts power up decoding the same address, so we
160 * need to move one of them first, before doing enything else.
162 * We also increase the number of wait states for this part by one.
165 void smc_remap(unsigned int ioaddr
)
168 extern unsigned short ppdata
;
170 *((volatile unsigned short *)MCFSIM_PADDR
) = 0x00ec;
172 *((volatile unsigned short *)MCFSIM_PADAT
) = ppdata
;
173 outw(0x0001, ioaddr
+ BANK_SELECT
);
174 outw(0x0001, ioaddr
+ BANK_SELECT
);
175 outw(0x0067, ioaddr
+ BASE
);
178 *((volatile unsigned short *)MCFSIM_PADAT
) = ppdata
;
181 *((volatile unsigned short *)(MCF_MBAR
+MCFSIM_CSCR3
)) = 0x1180;
186 /****************************************************************************/
187 #endif /* mcfsmc_h */