12 #include <linux/kernel.h>
13 #include <linux/module.h>
15 #include <linux/types.h>
19 #include <linux/netdevice.h>
22 #include <linux/stddef.h>
23 #include <linux/mii.h>
29 #define DRV_NAME "s6gmac"
30 #define DRV_PRMT DRV_NAME ": "
35 #define S6_GMAC_MACCONF1 0x000
36 #define S6_GMAC_MACCONF1_TXENA 0
37 #define S6_GMAC_MACCONF1_SYNCTX 1
38 #define S6_GMAC_MACCONF1_RXENA 2
39 #define S6_GMAC_MACCONF1_SYNCRX 3
40 #define S6_GMAC_MACCONF1_TXFLOWCTRL 4
41 #define S6_GMAC_MACCONF1_RXFLOWCTRL 5
42 #define S6_GMAC_MACCONF1_LOOPBACK 8
43 #define S6_GMAC_MACCONF1_RESTXFUNC 16
44 #define S6_GMAC_MACCONF1_RESRXFUNC 17
45 #define S6_GMAC_MACCONF1_RESTXMACCTRL 18
46 #define S6_GMAC_MACCONF1_RESRXMACCTRL 19
47 #define S6_GMAC_MACCONF1_SIMULRES 30
48 #define S6_GMAC_MACCONF1_SOFTRES 31
49 #define S6_GMAC_MACCONF2 0x004
50 #define S6_GMAC_MACCONF2_FULL 0
51 #define S6_GMAC_MACCONF2_CRCENA 1
52 #define S6_GMAC_MACCONF2_PADCRCENA 2
53 #define S6_GMAC_MACCONF2_LENGTHFCHK 4
54 #define S6_GMAC_MACCONF2_HUGEFRAMENA 5
55 #define S6_GMAC_MACCONF2_IFMODE 8
56 #define S6_GMAC_MACCONF2_IFMODE_NIBBLE 1
57 #define S6_GMAC_MACCONF2_IFMODE_BYTE 2
58 #define S6_GMAC_MACCONF2_IFMODE_MASK 3
59 #define S6_GMAC_MACCONF2_PREAMBLELEN 12
60 #define S6_GMAC_MACCONF2_PREAMBLELEN_MASK 0x0F
61 #define S6_GMAC_MACIPGIFG 0x008
62 #define S6_GMAC_MACIPGIFG_B2BINTERPGAP 0
63 #define S6_GMAC_MACIPGIFG_B2BINTERPGAP_MASK 0x7F
64 #define S6_GMAC_MACIPGIFG_MINIFGENFORCE 8
65 #define S6_GMAC_MACIPGIFG_B2BINTERPGAP2 16
66 #define S6_GMAC_MACIPGIFG_B2BINTERPGAP1 24
67 #define S6_GMAC_MACHALFDUPLEX 0x00C
68 #define S6_GMAC_MACHALFDUPLEX_COLLISWIN 0
69 #define S6_GMAC_MACHALFDUPLEX_COLLISWIN_MASK 0x3F
70 #define S6_GMAC_MACHALFDUPLEX_RETXMAX 12
71 #define S6_GMAC_MACHALFDUPLEX_RETXMAX_MASK 0x0F
72 #define S6_GMAC_MACHALFDUPLEX_EXCESSDEF 16
73 #define S6_GMAC_MACHALFDUPLEX_NOBACKOFF 17
74 #define S6_GMAC_MACHALFDUPLEX_BPNOBCKOF 18
75 #define S6_GMAC_MACHALFDUPLEX_ALTBEBENA 19
76 #define S6_GMAC_MACHALFDUPLEX_ALTBEBTRN 20
77 #define S6_GMAC_MACHALFDUPLEX_ALTBEBTR_MASK 0x0F
78 #define S6_GMAC_MACMAXFRAMELEN 0x010
79 #define S6_GMAC_MACMIICONF 0x020
80 #define S6_GMAC_MACMIICONF_CSEL 0
81 #define S6_GMAC_MACMIICONF_CSEL_DIV10 0
82 #define S6_GMAC_MACMIICONF_CSEL_DIV12 1
83 #define S6_GMAC_MACMIICONF_CSEL_DIV14 2
84 #define S6_GMAC_MACMIICONF_CSEL_DIV18 3
85 #define S6_GMAC_MACMIICONF_CSEL_DIV24 4
86 #define S6_GMAC_MACMIICONF_CSEL_DIV34 5
87 #define S6_GMAC_MACMIICONF_CSEL_DIV68 6
88 #define S6_GMAC_MACMIICONF_CSEL_DIV168 7
89 #define S6_GMAC_MACMIICONF_CSEL_MASK 7
90 #define S6_GMAC_MACMIICONF_PREAMBLESUPR 4
91 #define S6_GMAC_MACMIICONF_SCANAUTOINCR 5
92 #define S6_GMAC_MACMIICMD 0x024
93 #define S6_GMAC_MACMIICMD_READ 0
94 #define S6_GMAC_MACMIICMD_SCAN 1
95 #define S6_GMAC_MACMIIADDR 0x028
96 #define S6_GMAC_MACMIIADDR_REG 0
97 #define S6_GMAC_MACMIIADDR_REG_MASK 0x1F
98 #define S6_GMAC_MACMIIADDR_PHY 8
99 #define S6_GMAC_MACMIIADDR_PHY_MASK 0x1F
100 #define S6_GMAC_MACMIICTRL 0x02C
101 #define S6_GMAC_MACMIISTAT 0x030
102 #define S6_GMAC_MACMIIINDI 0x034
103 #define S6_GMAC_MACMIIINDI_BUSY 0
104 #define S6_GMAC_MACMIIINDI_SCAN 1
105 #define S6_GMAC_MACMIIINDI_INVAL 2
106 #define S6_GMAC_MACINTERFSTAT 0x03C
107 #define S6_GMAC_MACINTERFSTAT_LINKFAIL 3
108 #define S6_GMAC_MACINTERFSTAT_EXCESSDEF 9
109 #define S6_GMAC_MACSTATADDR1 0x040
110 #define S6_GMAC_MACSTATADDR2 0x044
112 #define S6_GMAC_FIFOCONF0 0x048
113 #define S6_GMAC_FIFOCONF0_HSTRSTWT 0
114 #define S6_GMAC_FIFOCONF0_HSTRSTSR 1
115 #define S6_GMAC_FIFOCONF0_HSTRSTFR 2
116 #define S6_GMAC_FIFOCONF0_HSTRSTST 3
117 #define S6_GMAC_FIFOCONF0_HSTRSTFT 4
118 #define S6_GMAC_FIFOCONF0_WTMENREQ 8
119 #define S6_GMAC_FIFOCONF0_SRFENREQ 9
120 #define S6_GMAC_FIFOCONF0_FRFENREQ 10
121 #define S6_GMAC_FIFOCONF0_STFENREQ 11
122 #define S6_GMAC_FIFOCONF0_FTFENREQ 12
123 #define S6_GMAC_FIFOCONF0_WTMENRPLY 16
124 #define S6_GMAC_FIFOCONF0_SRFENRPLY 17
125 #define S6_GMAC_FIFOCONF0_FRFENRPLY 18
126 #define S6_GMAC_FIFOCONF0_STFENRPLY 19
127 #define S6_GMAC_FIFOCONF0_FTFENRPLY 20
128 #define S6_GMAC_FIFOCONF1 0x04C
129 #define S6_GMAC_FIFOCONF2 0x050
130 #define S6_GMAC_FIFOCONF2_CFGLWM 0
131 #define S6_GMAC_FIFOCONF2_CFGHWM 16
132 #define S6_GMAC_FIFOCONF3 0x054
133 #define S6_GMAC_FIFOCONF3_CFGFTTH 0
134 #define S6_GMAC_FIFOCONF3_CFGHWMFT 16
135 #define S6_GMAC_FIFOCONF4 0x058
136 #define S6_GMAC_FIFOCONF_RSV_PREVDROP 0
137 #define S6_GMAC_FIFOCONF_RSV_RUNT 1
138 #define S6_GMAC_FIFOCONF_RSV_FALSECAR 2
139 #define S6_GMAC_FIFOCONF_RSV_CODEERR 3
140 #define S6_GMAC_FIFOCONF_RSV_CRCERR 4
141 #define S6_GMAC_FIFOCONF_RSV_LENGTHERR 5
142 #define S6_GMAC_FIFOCONF_RSV_LENRANGE 6
143 #define S6_GMAC_FIFOCONF_RSV_OK 7
144 #define S6_GMAC_FIFOCONF_RSV_MULTICAST 8
145 #define S6_GMAC_FIFOCONF_RSV_BROADCAST 9
146 #define S6_GMAC_FIFOCONF_RSV_DRIBBLE 10
147 #define S6_GMAC_FIFOCONF_RSV_CTRLFRAME 11
148 #define S6_GMAC_FIFOCONF_RSV_PAUSECTRL 12
149 #define S6_GMAC_FIFOCONF_RSV_UNOPCODE 13
150 #define S6_GMAC_FIFOCONF_RSV_VLANTAG 14
151 #define S6_GMAC_FIFOCONF_RSV_LONGEVENT 15
152 #define S6_GMAC_FIFOCONF_RSV_TRUNCATED 16
153 #define S6_GMAC_FIFOCONF_RSV_MASK 0x3FFFF
154 #define S6_GMAC_FIFOCONF5 0x05C
155 #define S6_GMAC_FIFOCONF5_DROPLT64 18
156 #define S6_GMAC_FIFOCONF5_CFGBYTM 19
157 #define S6_GMAC_FIFOCONF5_RXDROPSIZE 20
158 #define S6_GMAC_FIFOCONF5_RXDROPSIZE_MASK 0xF
160 #define S6_GMAC_STAT_REGS 0x080
161 #define S6_GMAC_STAT_SIZE_MIN 12
162 #define S6_GMAC_STATTR64 0x080
163 #define S6_GMAC_STATTR64_SIZE 18
164 #define S6_GMAC_STATTR127 0x084
165 #define S6_GMAC_STATTR127_SIZE 18
166 #define S6_GMAC_STATTR255 0x088
167 #define S6_GMAC_STATTR255_SIZE 18
168 #define S6_GMAC_STATTR511 0x08C
169 #define S6_GMAC_STATTR511_SIZE 18
170 #define S6_GMAC_STATTR1K 0x090
171 #define S6_GMAC_STATTR1K_SIZE 18
172 #define S6_GMAC_STATTRMAX 0x094
173 #define S6_GMAC_STATTRMAX_SIZE 18
174 #define S6_GMAC_STATTRMGV 0x098
175 #define S6_GMAC_STATTRMGV_SIZE 18
176 #define S6_GMAC_STATRBYT 0x09C
177 #define S6_GMAC_STATRBYT_SIZE 24
178 #define S6_GMAC_STATRPKT 0x0A0
179 #define S6_GMAC_STATRPKT_SIZE 18
180 #define S6_GMAC_STATRFCS 0x0A4
181 #define S6_GMAC_STATRFCS_SIZE 12
182 #define S6_GMAC_STATRMCA 0x0A8
183 #define S6_GMAC_STATRMCA_SIZE 18
184 #define S6_GMAC_STATRBCA 0x0AC
185 #define S6_GMAC_STATRBCA_SIZE 22
186 #define S6_GMAC_STATRXCF 0x0B0
187 #define S6_GMAC_STATRXCF_SIZE 18
188 #define S6_GMAC_STATRXPF 0x0B4
189 #define S6_GMAC_STATRXPF_SIZE 12
190 #define S6_GMAC_STATRXUO 0x0B8
191 #define S6_GMAC_STATRXUO_SIZE 12
192 #define S6_GMAC_STATRALN 0x0BC
193 #define S6_GMAC_STATRALN_SIZE 12
194 #define S6_GMAC_STATRFLR 0x0C0
195 #define S6_GMAC_STATRFLR_SIZE 16
196 #define S6_GMAC_STATRCDE 0x0C4
197 #define S6_GMAC_STATRCDE_SIZE 12
198 #define S6_GMAC_STATRCSE 0x0C8
199 #define S6_GMAC_STATRCSE_SIZE 12
200 #define S6_GMAC_STATRUND 0x0CC
201 #define S6_GMAC_STATRUND_SIZE 12
202 #define S6_GMAC_STATROVR 0x0D0
203 #define S6_GMAC_STATROVR_SIZE 12
204 #define S6_GMAC_STATRFRG 0x0D4
205 #define S6_GMAC_STATRFRG_SIZE 12
206 #define S6_GMAC_STATRJBR 0x0D8
207 #define S6_GMAC_STATRJBR_SIZE 12
208 #define S6_GMAC_STATRDRP 0x0DC
209 #define S6_GMAC_STATRDRP_SIZE 12
210 #define S6_GMAC_STATTBYT 0x0E0
211 #define S6_GMAC_STATTBYT_SIZE 24
212 #define S6_GMAC_STATTPKT 0x0E4
213 #define S6_GMAC_STATTPKT_SIZE 18
214 #define S6_GMAC_STATTMCA 0x0E8
215 #define S6_GMAC_STATTMCA_SIZE 18
216 #define S6_GMAC_STATTBCA 0x0EC
217 #define S6_GMAC_STATTBCA_SIZE 18
218 #define S6_GMAC_STATTXPF 0x0F0
219 #define S6_GMAC_STATTXPF_SIZE 12
220 #define S6_GMAC_STATTDFR 0x0F4
221 #define S6_GMAC_STATTDFR_SIZE 12
222 #define S6_GMAC_STATTEDF 0x0F8
223 #define S6_GMAC_STATTEDF_SIZE 12
224 #define S6_GMAC_STATTSCL 0x0FC
225 #define S6_GMAC_STATTSCL_SIZE 12
226 #define S6_GMAC_STATTMCL 0x100
227 #define S6_GMAC_STATTMCL_SIZE 12
228 #define S6_GMAC_STATTLCL 0x104
229 #define S6_GMAC_STATTLCL_SIZE 12
230 #define S6_GMAC_STATTXCL 0x108
231 #define S6_GMAC_STATTXCL_SIZE 12
232 #define S6_GMAC_STATTNCL 0x10C
233 #define S6_GMAC_STATTNCL_SIZE 13
234 #define S6_GMAC_STATTPFH 0x110
235 #define S6_GMAC_STATTPFH_SIZE 12
236 #define S6_GMAC_STATTDRP 0x114
237 #define S6_GMAC_STATTDRP_SIZE 12
238 #define S6_GMAC_STATTJBR 0x118
239 #define S6_GMAC_STATTJBR_SIZE 12
240 #define S6_GMAC_STATTFCS 0x11C
241 #define S6_GMAC_STATTFCS_SIZE 12
242 #define S6_GMAC_STATTXCF 0x120
243 #define S6_GMAC_STATTXCF_SIZE 12
244 #define S6_GMAC_STATTOVR 0x124
245 #define S6_GMAC_STATTOVR_SIZE 12
246 #define S6_GMAC_STATTUND 0x128
247 #define S6_GMAC_STATTUND_SIZE 12
248 #define S6_GMAC_STATTFRG 0x12C
249 #define S6_GMAC_STATTFRG_SIZE 12
250 #define S6_GMAC_STATCARRY(n) (0x130 + 4*(n))
251 #define S6_GMAC_STATCARRYMSK(n) (0x138 + 4*(n))
252 #define S6_GMAC_STATCARRY1_RDRP 0
253 #define S6_GMAC_STATCARRY1_RJBR 1
254 #define S6_GMAC_STATCARRY1_RFRG 2
255 #define S6_GMAC_STATCARRY1_ROVR 3
256 #define S6_GMAC_STATCARRY1_RUND 4
257 #define S6_GMAC_STATCARRY1_RCSE 5
258 #define S6_GMAC_STATCARRY1_RCDE 6
259 #define S6_GMAC_STATCARRY1_RFLR 7
260 #define S6_GMAC_STATCARRY1_RALN 8
261 #define S6_GMAC_STATCARRY1_RXUO 9
262 #define S6_GMAC_STATCARRY1_RXPF 10
263 #define S6_GMAC_STATCARRY1_RXCF 11
264 #define S6_GMAC_STATCARRY1_RBCA 12
265 #define S6_GMAC_STATCARRY1_RMCA 13
266 #define S6_GMAC_STATCARRY1_RFCS 14
267 #define S6_GMAC_STATCARRY1_RPKT 15
268 #define S6_GMAC_STATCARRY1_RBYT 16
269 #define S6_GMAC_STATCARRY1_TRMGV 25
270 #define S6_GMAC_STATCARRY1_TRMAX 26
271 #define S6_GMAC_STATCARRY1_TR1K 27
272 #define S6_GMAC_STATCARRY1_TR511 28
273 #define S6_GMAC_STATCARRY1_TR255 29
274 #define S6_GMAC_STATCARRY1_TR127 30
275 #define S6_GMAC_STATCARRY1_TR64 31
276 #define S6_GMAC_STATCARRY2_TDRP 0
277 #define S6_GMAC_STATCARRY2_TPFH 1
278 #define S6_GMAC_STATCARRY2_TNCL 2
279 #define S6_GMAC_STATCARRY2_TXCL 3
280 #define S6_GMAC_STATCARRY2_TLCL 4
281 #define S6_GMAC_STATCARRY2_TMCL 5
282 #define S6_GMAC_STATCARRY2_TSCL 6
283 #define S6_GMAC_STATCARRY2_TEDF 7
284 #define S6_GMAC_STATCARRY2_TDFR 8
285 #define S6_GMAC_STATCARRY2_TXPF 9
286 #define S6_GMAC_STATCARRY2_TBCA 10
287 #define S6_GMAC_STATCARRY2_TMCA 11
288 #define S6_GMAC_STATCARRY2_TPKT 12
289 #define S6_GMAC_STATCARRY2_TBYT 13
290 #define S6_GMAC_STATCARRY2_TFRG 14
291 #define S6_GMAC_STATCARRY2_TUND 15
292 #define S6_GMAC_STATCARRY2_TOVR 16
293 #define S6_GMAC_STATCARRY2_TXCF 17
294 #define S6_GMAC_STATCARRY2_TFCS 18
295 #define S6_GMAC_STATCARRY2_TJBR 19
297 #define S6_GMAC_HOST_PBLKCTRL 0x140
298 #define S6_GMAC_HOST_PBLKCTRL_TXENA 0
299 #define S6_GMAC_HOST_PBLKCTRL_RXENA 1
300 #define S6_GMAC_HOST_PBLKCTRL_TXSRES 2
301 #define S6_GMAC_HOST_PBLKCTRL_RXSRES 3
302 #define S6_GMAC_HOST_PBLKCTRL_TXBSIZ 8
303 #define S6_GMAC_HOST_PBLKCTRL_RXBSIZ 12
304 #define S6_GMAC_HOST_PBLKCTRL_SIZ_16 4
305 #define S6_GMAC_HOST_PBLKCTRL_SIZ_32 5
306 #define S6_GMAC_HOST_PBLKCTRL_SIZ_64 6
307 #define S6_GMAC_HOST_PBLKCTRL_SIZ_128 7
308 #define S6_GMAC_HOST_PBLKCTRL_SIZ_MASK 0xF
309 #define S6_GMAC_HOST_PBLKCTRL_STATENA 16
310 #define S6_GMAC_HOST_PBLKCTRL_STATAUTOZ 17
311 #define S6_GMAC_HOST_PBLKCTRL_STATCLEAR 18
312 #define S6_GMAC_HOST_PBLKCTRL_RGMII 19
313 #define S6_GMAC_HOST_INTMASK 0x144
314 #define S6_GMAC_HOST_INTSTAT 0x148
315 #define S6_GMAC_HOST_INT_TXBURSTOVER 3
316 #define S6_GMAC_HOST_INT_TXPREWOVER 4
317 #define S6_GMAC_HOST_INT_RXBURSTUNDER 5
318 #define S6_GMAC_HOST_INT_RXPOSTRFULL 6
319 #define S6_GMAC_HOST_INT_RXPOSTRUNDER 7
320 #define S6_GMAC_HOST_RXFIFOHWM 0x14C
321 #define S6_GMAC_HOST_CTRLFRAMXP 0x150
322 #define S6_GMAC_HOST_DSTADDRLO(n) (0x160 + 8*(n))
323 #define S6_GMAC_HOST_DSTADDRHI(n) (0x164 + 8*(n))
324 #define S6_GMAC_HOST_DSTMASKLO(n) (0x180 + 8*(n))
325 #define S6_GMAC_HOST_DSTMASKHI(n) (0x184 + 8*(n))
327 #define S6_GMAC_BURST_PREWR 0x1B0
328 #define S6_GMAC_BURST_PREWR_LEN 0
329 #define S6_GMAC_BURST_PREWR_LEN_MASK ((1 << 20) - 1)
330 #define S6_GMAC_BURST_PREWR_CFE 20
331 #define S6_GMAC_BURST_PREWR_PPE 21
332 #define S6_GMAC_BURST_PREWR_FCS 22
333 #define S6_GMAC_BURST_PREWR_PAD 23
334 #define S6_GMAC_BURST_POSTRD 0x1D0
335 #define S6_GMAC_BURST_POSTRD_LEN 0
336 #define S6_GMAC_BURST_POSTRD_LEN_MASK ((1 << 20) - 1)
337 #define S6_GMAC_BURST_POSTRD_DROP 20
342 #define S6_NUM_TX_SKB 8
343 #define S6_NUM_RX_SKB 16
344 #define S6_MAX_FRLEN 1536
375 struct s6gmac *
pd = netdev_priv(dev);
388 struct s6gmac *
pd = netdev_priv(dev);
407 static void s6gmac_tx_interrupt(
struct net_device *dev)
409 struct s6gmac *pd = netdev_priv(dev);
415 netif_wake_queue(dev);
424 #define S6_STATS_B (8 * sizeof(u32))
425 #define S6_STATS_C(b, r, f) [b] = { \
426 BUILD_BUG_ON_ZERO(r##_SIZE < S6_GMAC_STAT_SIZE_MIN) + \
427 BUILD_BUG_ON_ZERO((r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1)) \
429 r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1), \
430 BUILD_BUG_ON_ZERO(((unsigned)((r - S6_GMAC_STAT_REGS) / sizeof(u32))) \
432 (r - S6_GMAC_STAT_REGS) / sizeof(u32), \
433 BUILD_BUG_ON_ZERO((offsetof(struct net_device_stats, f)) \
434 % sizeof(unsigned long)) + \
435 BUILD_BUG_ON_ZERO((((unsigned)(offsetof(struct net_device_stats, f)) \
436 / sizeof(unsigned long)) >= (1<<6))) + \
437 BUILD_BUG_ON_ZERO((sizeof(((struct net_device_stats *)0)->f) \
438 != sizeof(unsigned long))) + \
439 (offsetof(struct net_device_stats, f)) / sizeof(unsigned long)},
468 static void s6gmac_stats_collect(
struct s6gmac *pd,
481 static void s6gmac_stats_carry(
struct s6gmac *pd,
492 static inline u32 s6gmac_stats_pending(
struct s6gmac *pd,
int carry)
499 static inline void s6gmac_stats_interrupt(
struct s6gmac *pd,
int carry)
502 mask = s6gmac_stats_pending(pd, carry);
505 s6gmac_stats_carry(pd, &statinf[carry][0], mask);
512 struct s6gmac *pd = netdev_priv(dev);
515 spin_lock(&pd->
lock);
517 s6gmac_rx_interrupt(dev);
518 s6gmac_rx_fillfifo(dev);
520 s6gmac_tx_interrupt(dev);
521 s6gmac_stats_interrupt(pd, 0);
522 s6gmac_stats_interrupt(pd, 1);
523 spin_unlock(&pd->
lock);
527 static inline void s6gmac_set_dstaddr(
struct s6gmac *pd,
int n,
536 static inline void s6gmac_stop_device(
struct net_device *dev)
538 struct s6gmac *pd = netdev_priv(dev);
542 static inline void s6gmac_init_device(
struct net_device *dev)
544 struct s6gmac *pd = netdev_priv(dev);
545 int is_rgmii = !!(pd->
phydev->supported
620 s6gmac_set_dstaddr(pd, 0,
621 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFFFF, 0x0000FFFF);
622 s6gmac_set_dstaddr(pd, 1,
629 0xFFFFFFFF, 0x0000FFFF);
630 s6gmac_set_dstaddr(pd, 2,
631 0x00000000, 0x00000100, 0x00000000, 0x00000100);
632 s6gmac_set_dstaddr(pd, 3,
633 0x00000000, 0x00000000, 0x00000000, 0x00000000);
644 static void s6mii_enable(
struct s6gmac *pd)
655 static int s6mii_busy(
struct s6gmac *pd,
int tmo)
665 static int s6mii_read(
struct mii_bus *
bus,
int phy_addr,
int regnum)
669 if (s6mii_busy(pd, 256))
676 if (s6mii_busy(pd, 256))
681 static int s6mii_write(
struct mii_bus *bus,
int phy_addr,
int regnum,
u16 value)
685 if (s6mii_busy(pd, 256))
691 if (s6mii_busy(pd, 256))
696 static int s6mii_reset(
struct mii_bus *bus)
705 static void s6gmac_set_rgmii_txclock(
struct s6gmac *pd)
709 switch (pd->
link.mbit) {
725 static inline void s6gmac_linkisup(
struct net_device *dev,
int isup)
727 struct s6gmac *pd = netdev_priv(dev);
734 s6gmac_set_rgmii_txclock(pd);
736 pd->
link.isup = isup;
742 static void s6gmac_adjust_link(
struct net_device *dev)
744 struct s6gmac *pd = netdev_priv(dev);
751 netif_tx_disable(dev);
757 if (!pd->
link.isup && phydev->
link) {
767 if (pd->
link.giga != (phydev->
speed == 1000)) {
772 if (phydev->
speed == 1000) {
786 netif_wake_queue(dev);
787 s6gmac_linkisup(dev, 1);
791 static inline int s6gmac_phy_start(
struct net_device *dev)
793 struct s6gmac *pd = netdev_priv(dev);
810 static inline void s6gmac_init_stats(
struct net_device *dev)
812 struct s6gmac *pd = netdev_priv(dev);
843 static inline void s6gmac_init_dmac(
struct net_device *dev)
845 struct s6gmac *pd = netdev_priv(dev);
854 struct s6gmac *pd = netdev_priv(dev);
867 netif_stop_queue(dev);
874 spin_unlock_irqrestore(&pd->
lock, flags);
878 static void s6gmac_tx_timeout(
struct net_device *dev)
880 struct s6gmac *pd = netdev_priv(dev);
883 s6gmac_tx_interrupt(dev);
884 spin_unlock_irqrestore(&pd->
lock, flags);
887 static int s6gmac_open(
struct net_device *dev)
889 struct s6gmac *pd = netdev_priv(dev);
891 phy_read_status(pd->
phydev);
894 s6gmac_linkisup(dev, pd->
phydev->link);
895 s6gmac_init_device(dev);
896 s6gmac_init_stats(dev);
897 s6gmac_init_dmac(dev);
898 s6gmac_rx_fillfifo(dev);
900 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1);
902 2, 0, 1, 0, 0, 0, 0, 7, -1, 2, 0, 1);
909 spin_unlock_irqrestore(&pd->
lock, flags);
911 netif_start_queue(dev);
915 static int s6gmac_stop(
struct net_device *dev)
917 struct s6gmac *pd = netdev_priv(dev);
919 netif_stop_queue(dev);
922 s6gmac_init_dmac(dev);
923 s6gmac_stop_device(dev);
928 spin_unlock_irqrestore(&pd->
lock, flags);
934 struct s6gmac *pd = netdev_priv(dev);
943 s6gmac_stats_collect(pd, &statinf[0][0]);
944 s6gmac_stats_collect(pd, &statinf[1][0]);
945 i = s6gmac_stats_pending(pd, 0) |
946 s6gmac_stats_pending(pd, 1);
947 spin_unlock_irqrestore(&pd->
lock, flags);
965 dev = alloc_etherdev(
sizeof(*pd));
969 dev->open = s6gmac_open;
970 dev->stop = s6gmac_stop;
971 dev->hard_start_xmit = s6gmac_tx;
972 dev->tx_timeout = s6gmac_tx_timeout;
974 dev->get_stats = s6gmac_stats;
976 pd = netdev_priv(dev);
977 memset(pd, 0,
sizeof(*pd));
998 mb = mdiobus_alloc();
1003 mb->
name =
"s6gmac_mii";
1004 mb->
read = s6mii_read;
1005 mb->
write = s6mii_write;
1006 mb->
reset = s6mii_reset;
1010 mb->
irq = &pd->
mii.irq[0];
1019 res = s6gmac_phy_start(dev);
1022 platform_set_drvdata(pdev, dev);
1035 struct net_device *dev = platform_get_drvdata(pdev);
1037 struct s6gmac *pd = netdev_priv(dev);
1042 platform_set_drvdata(pdev,
NULL);
1048 .probe = s6gmac_probe,
1056 static int __init s6gmac_init(
void)
1063 static void __exit s6gmac_exit(
void)