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.
20 #include <linux/config.h>
38 * Re-defines for ColdFire environment... The SMC part is
39 * mapped into memory space, so remap the PC-style in/out
40 * routines to handle that.
45 #define outwd smc_outwd
50 #define outsb smc_outsb
51 #define outsw smc_outsw
52 #define outsl smc_outsl
58 static inline int smc_inb(unsigned int addr)
60 register unsigned short w;
61 w = *((volatile unsigned short *) (addr & ~0x1));
62 return(((addr & 0x1) ? w : (w >> 8)) & 0xff);
65 static inline void smc_outw(unsigned int val, unsigned int addr)
67 *((volatile unsigned short *) addr) = (val << 8) | (val >> 8);
70 static inline int smc_inw(unsigned int addr)
72 register unsigned short w;
73 w = *((volatile unsigned short *) addr);
74 return(((w << 8) | (w >> 8)) & 0xffff);
77 static inline void smc_outl(unsigned long val, unsigned int addr)
79 *((volatile unsigned long *) addr) =
80 ((val << 8) & 0xff000000) | ((val >> 8) & 0x00ff0000) |
81 ((val << 8) & 0x0000ff00) | ((val >> 8) & 0x000000ff);
84 static inline void smc_outwd(unsigned int val, unsigned int addr)
86 *((volatile unsigned short *) addr) = val;
91 * The rep* functions are used to feed the data port with
92 * raw data. So we do not byte swap them when copying.
95 static inline void smc_insb(unsigned int addr, void *vbuf, int unsigned long len)
97 volatile unsigned short *rp;
98 unsigned short *buf, *ebuf;
100 buf = (unsigned short *) vbuf;
101 rp = (volatile unsigned short *) addr;
103 /* Copy as words for as long as possible */
104 for (ebuf = buf + (len >> 1); (buf < ebuf); )
107 /* Lastly, handle left over byte */
109 *((unsigned char *) buf) = (*rp >> 8) & 0xff;
112 static inline void smc_insw(unsigned int addr, void *vbuf, unsigned long len)
114 volatile unsigned short *rp;
115 unsigned short *buf, *ebuf;
117 buf = (unsigned short *) vbuf;
118 rp = (volatile unsigned short *) addr;
119 for (ebuf = buf + len; (buf < ebuf); )
123 static inline void smc_insl(unsigned int addr, void *vbuf, unsigned long len)
125 volatile unsigned long *rp;
126 unsigned long *buf, *ebuf;
128 buf = (unsigned long *) vbuf;
129 rp = (volatile unsigned long *) addr;
130 for (ebuf = buf + len; (buf < ebuf); )
134 static inline void smc_outsw(unsigned int addr, const void *vbuf, unsigned long len)
136 volatile unsigned short *rp;
137 unsigned short *buf, *ebuf;
139 buf = (unsigned short *) vbuf;
140 rp = (volatile unsigned short *) addr;
141 for (ebuf = buf + len; (buf < ebuf); )
145 static inline void smc_outsl(unsigned int addr, void *vbuf, unsigned long len)
147 volatile unsigned long *rp;
148 unsigned long *buf, *ebuf;
150 buf = (unsigned long *) vbuf;
151 rp = (volatile unsigned long *) addr;
152 for (ebuf = buf + len; (buf < ebuf); )
159 * Re-map the address space of at least one of the SMC ethernet
160 * parts. Both parts power up decoding the same address, so we
161 * need to move one of them first, before doing enything else.
163 * We also increase the number of wait states for this part by one.
166 void smc_remap(unsigned int ioaddr)
169 extern unsigned short ppdata;
171 *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADDR)) = 0x00ec;
173 *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADAT)) = ppdata;
174 outw(0x0001, ioaddr + BANK_SELECT);
175 outw(0x0001, ioaddr + BANK_SELECT);
176 outw(0x0067, ioaddr + BASE);
179 *((volatile unsigned short *)(MCF_MBAR+MCFSIM_PADAT)) = ppdata;
182 *((volatile unsigned short *)(MCF_MBAR+MCFSIM_CSCR3)) = 0x1180;
187 /****************************************************************************/
188 #endif /* mcfsmc_h */