x86: i915 needs pgprot_writecombine() and is_io_mapping_possible()
[linux-2.6/mini2440.git] / drivers / net / smc911x.h
blob870b4c33f108d87b384b3fe46c506d4f1cb1107e
1 /*------------------------------------------------------------------------
2 . smc911x.h - macros for SMSC's LAN911{5,6,7,8} single-chip Ethernet device.
4 . Copyright (C) 2005 Sensoria Corp.
5 . Derived from the unified SMC91x driver by Nicolas Pitre
7 . This program is free software; you can redistribute it and/or modify
8 . it under the terms of the GNU General Public License as published by
9 . the Free Software Foundation; either version 2 of the License, or
10 . (at your option) any later version.
12 . This program is distributed in the hope that it will be useful,
13 . but WITHOUT ANY WARRANTY; without even the implied warranty of
14 . MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 . GNU General Public License for more details.
17 . You should have received a copy of the GNU General Public License
18 . along with this program; if not, write to the Free Software
19 . Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 . Information contained in this file was obtained from the LAN9118
22 . manual from SMC. To get a copy, if you really want one, you can find
23 . information under www.smsc.com.
25 . Authors
26 . Dustin McIntire <dustin@sensoria.com>
28 ---------------------------------------------------------------------------*/
29 #ifndef _SMC911X_H_
30 #define _SMC911X_H_
32 #include <linux/smc911x.h>
34 * Use the DMA feature on PXA chips
36 #ifdef CONFIG_ARCH_PXA
37 #define SMC_USE_PXA_DMA 1
38 #define SMC_USE_16BIT 0
39 #define SMC_USE_32BIT 1
40 #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING
41 #elif defined(CONFIG_SH_MAGIC_PANEL_R2)
42 #define SMC_USE_16BIT 0
43 #define SMC_USE_32BIT 1
44 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
45 #else
47 * Default configuration
50 #define SMC_DYNAMIC_BUS_CONFIG
51 #endif
53 #ifdef SMC_USE_PXA_DMA
54 #define SMC_USE_DMA
55 #endif
57 /* store this information for the driver.. */
58 struct smc911x_local {
60 * If I have to wait until the DMA is finished and ready to reload a
61 * packet, I will store the skbuff here. Then, the DMA will send it
62 * out and free it.
64 struct sk_buff *pending_tx_skb;
66 /* version/revision of the SMC911x chip */
67 u16 version;
68 u16 revision;
70 /* FIFO sizes */
71 int tx_fifo_kb;
72 int tx_fifo_size;
73 int rx_fifo_size;
74 int afc_cfg;
76 /* Contains the current active receive/phy mode */
77 int ctl_rfduplx;
78 int ctl_rspeed;
80 u32 msg_enable;
81 u32 phy_type;
82 struct mii_if_info mii;
84 /* work queue */
85 struct work_struct phy_configure;
87 int tx_throttle;
88 spinlock_t lock;
90 struct net_device *netdev;
92 #ifdef SMC_USE_DMA
93 /* DMA needs the physical address of the chip */
94 u_long physaddr;
95 int rxdma;
96 int txdma;
97 int rxdma_active;
98 int txdma_active;
99 struct sk_buff *current_rx_skb;
100 struct sk_buff *current_tx_skb;
101 struct device *dev;
102 #endif
103 void __iomem *base;
104 #ifdef SMC_DYNAMIC_BUS_CONFIG
105 struct smc911x_platdata cfg;
106 #endif
110 * Define the bus width specific IO macros
113 #ifdef SMC_DYNAMIC_BUS_CONFIG
114 static inline unsigned int SMC_inl(struct smc911x_local *lp, int reg)
116 void __iomem *ioaddr = lp->base + reg;
118 if (lp->cfg.flags & SMC911X_USE_32BIT)
119 return readl(ioaddr);
121 if (lp->cfg.flags & SMC911X_USE_16BIT)
122 return readw(ioaddr) | (readw(ioaddr + 2) << 16);
124 BUG();
127 static inline void SMC_outl(unsigned int value, struct smc911x_local *lp,
128 int reg)
130 void __iomem *ioaddr = lp->base + reg;
132 if (lp->cfg.flags & SMC911X_USE_32BIT) {
133 writel(value, ioaddr);
134 return;
137 if (lp->cfg.flags & SMC911X_USE_16BIT) {
138 writew(value & 0xffff, ioaddr);
139 writew(value >> 16, ioaddr + 2);
140 return;
143 BUG();
146 static inline void SMC_insl(struct smc911x_local *lp, int reg,
147 void *addr, unsigned int count)
149 void __iomem *ioaddr = lp->base + reg;
151 if (lp->cfg.flags & SMC911X_USE_32BIT) {
152 readsl(ioaddr, addr, count);
153 return;
156 if (lp->cfg.flags & SMC911X_USE_16BIT) {
157 readsw(ioaddr, addr, count * 2);
158 return;
161 BUG();
164 static inline void SMC_outsl(struct smc911x_local *lp, int reg,
165 void *addr, unsigned int count)
167 void __iomem *ioaddr = lp->base + reg;
169 if (lp->cfg.flags & SMC911X_USE_32BIT) {
170 writesl(ioaddr, addr, count);
171 return;
174 if (lp->cfg.flags & SMC911X_USE_16BIT) {
175 writesw(ioaddr, addr, count * 2);
176 return;
179 BUG();
181 #else
182 #if SMC_USE_16BIT
183 #define SMC_inl(lp, r) ((readw((lp)->base + (r)) & 0xFFFF) + (readw((lp)->base + (r) + 2) << 16))
184 #define SMC_outl(v, lp, r) \
185 do{ \
186 writew(v & 0xFFFF, (lp)->base + (r)); \
187 writew(v >> 16, (lp)->base + (r) + 2); \
188 } while (0)
189 #define SMC_insl(lp, r, p, l) readsw((short*)((lp)->base + (r)), p, l*2)
190 #define SMC_outsl(lp, r, p, l) writesw((short*)((lp)->base + (r)), p, l*2)
192 #elif SMC_USE_32BIT
193 #define SMC_inl(lp, r) readl((lp)->base + (r))
194 #define SMC_outl(v, lp, r) writel(v, (lp)->base + (r))
195 #define SMC_insl(lp, r, p, l) readsl((int*)((lp)->base + (r)), p, l)
196 #define SMC_outsl(lp, r, p, l) writesl((int*)((lp)->base + (r)), p, l)
198 #endif /* SMC_USE_16BIT */
199 #endif /* SMC_DYNAMIC_BUS_CONFIG */
202 #ifdef SMC_USE_PXA_DMA
204 #include <mach/dma.h>
207 * Define the request and free functions
208 * These are unfortunately architecture specific as no generic allocation
209 * mechanism exits
211 #define SMC_DMA_REQUEST(dev, handler) \
212 pxa_request_dma(dev->name, DMA_PRIO_LOW, handler, dev)
214 #define SMC_DMA_FREE(dev, dma) \
215 pxa_free_dma(dma)
217 #define SMC_DMA_ACK_IRQ(dev, dma) \
219 if (DCSR(dma) & DCSR_BUSERR) { \
220 printk("%s: DMA %d bus error!\n", dev->name, dma); \
222 DCSR(dma) = DCSR_STARTINTR|DCSR_ENDINTR|DCSR_BUSERR; \
226 * Use a DMA for RX and TX packets.
228 #include <linux/dma-mapping.h>
229 #include <asm/dma.h>
230 #include <mach/pxa-regs.h>
232 static dma_addr_t rx_dmabuf, tx_dmabuf;
233 static int rx_dmalen, tx_dmalen;
235 #ifdef SMC_insl
236 #undef SMC_insl
237 #define SMC_insl(lp, r, p, l) \
238 smc_pxa_dma_insl(lp, lp->physaddr, r, lp->rxdma, p, l)
240 static inline void
241 smc_pxa_dma_insl(struct smc911x_local *lp, u_long physaddr,
242 int reg, int dma, u_char *buf, int len)
244 /* 64 bit alignment is required for memory to memory DMA */
245 if ((long)buf & 4) {
246 *((u32 *)buf) = SMC_inl(lp, reg);
247 buf += 4;
248 len--;
251 len *= 4;
252 rx_dmabuf = dma_map_single(lp->dev, buf, len, DMA_FROM_DEVICE);
253 rx_dmalen = len;
254 DCSR(dma) = DCSR_NODESC;
255 DTADR(dma) = rx_dmabuf;
256 DSADR(dma) = physaddr + reg;
257 DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
258 DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & rx_dmalen));
259 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
261 #endif
263 #ifdef SMC_outsl
264 #undef SMC_outsl
265 #define SMC_outsl(lp, r, p, l) \
266 smc_pxa_dma_outsl(lp, lp->physaddr, r, lp->txdma, p, l)
268 static inline void
269 smc_pxa_dma_outsl(struct smc911x_local *lp, u_long physaddr,
270 int reg, int dma, u_char *buf, int len)
272 /* 64 bit alignment is required for memory to memory DMA */
273 if ((long)buf & 4) {
274 SMC_outl(*((u32 *)buf), lp, reg);
275 buf += 4;
276 len--;
279 len *= 4;
280 tx_dmabuf = dma_map_single(lp->dev, buf, len, DMA_TO_DEVICE);
281 tx_dmalen = len;
282 DCSR(dma) = DCSR_NODESC;
283 DSADR(dma) = tx_dmabuf;
284 DTADR(dma) = physaddr + reg;
285 DCMD(dma) = (DCMD_INCSRCADDR | DCMD_BURST32 |
286 DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & tx_dmalen));
287 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
289 #endif
290 #endif /* SMC_USE_PXA_DMA */
293 /* Chip Parameters and Register Definitions */
295 #define SMC911X_TX_FIFO_LOW_THRESHOLD (1536*2)
297 #define SMC911X_IO_EXTENT 0x100
299 #define SMC911X_EEPROM_LEN 7
301 /* Below are the register offsets and bit definitions
302 * of the Lan911x memory space
304 #define RX_DATA_FIFO (0x00)
306 #define TX_DATA_FIFO (0x20)
307 #define TX_CMD_A_INT_ON_COMP_ (0x80000000)
308 #define TX_CMD_A_INT_BUF_END_ALGN_ (0x03000000)
309 #define TX_CMD_A_INT_4_BYTE_ALGN_ (0x00000000)
310 #define TX_CMD_A_INT_16_BYTE_ALGN_ (0x01000000)
311 #define TX_CMD_A_INT_32_BYTE_ALGN_ (0x02000000)
312 #define TX_CMD_A_INT_DATA_OFFSET_ (0x001F0000)
313 #define TX_CMD_A_INT_FIRST_SEG_ (0x00002000)
314 #define TX_CMD_A_INT_LAST_SEG_ (0x00001000)
315 #define TX_CMD_A_BUF_SIZE_ (0x000007FF)
316 #define TX_CMD_B_PKT_TAG_ (0xFFFF0000)
317 #define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000)
318 #define TX_CMD_B_DISABLE_PADDING_ (0x00001000)
319 #define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF)
321 #define RX_STATUS_FIFO (0x40)
322 #define RX_STS_PKT_LEN_ (0x3FFF0000)
323 #define RX_STS_ES_ (0x00008000)
324 #define RX_STS_BCST_ (0x00002000)
325 #define RX_STS_LEN_ERR_ (0x00001000)
326 #define RX_STS_RUNT_ERR_ (0x00000800)
327 #define RX_STS_MCAST_ (0x00000400)
328 #define RX_STS_TOO_LONG_ (0x00000080)
329 #define RX_STS_COLL_ (0x00000040)
330 #define RX_STS_ETH_TYPE_ (0x00000020)
331 #define RX_STS_WDOG_TMT_ (0x00000010)
332 #define RX_STS_MII_ERR_ (0x00000008)
333 #define RX_STS_DRIBBLING_ (0x00000004)
334 #define RX_STS_CRC_ERR_ (0x00000002)
335 #define RX_STATUS_FIFO_PEEK (0x44)
336 #define TX_STATUS_FIFO (0x48)
337 #define TX_STS_TAG_ (0xFFFF0000)
338 #define TX_STS_ES_ (0x00008000)
339 #define TX_STS_LOC_ (0x00000800)
340 #define TX_STS_NO_CARR_ (0x00000400)
341 #define TX_STS_LATE_COLL_ (0x00000200)
342 #define TX_STS_MANY_COLL_ (0x00000100)
343 #define TX_STS_COLL_CNT_ (0x00000078)
344 #define TX_STS_MANY_DEFER_ (0x00000004)
345 #define TX_STS_UNDERRUN_ (0x00000002)
346 #define TX_STS_DEFERRED_ (0x00000001)
347 #define TX_STATUS_FIFO_PEEK (0x4C)
348 #define ID_REV (0x50)
349 #define ID_REV_CHIP_ID_ (0xFFFF0000) /* RO */
350 #define ID_REV_REV_ID_ (0x0000FFFF) /* RO */
352 #define INT_CFG (0x54)
353 #define INT_CFG_INT_DEAS_ (0xFF000000) /* R/W */
354 #define INT_CFG_INT_DEAS_CLR_ (0x00004000)
355 #define INT_CFG_INT_DEAS_STS_ (0x00002000)
356 #define INT_CFG_IRQ_INT_ (0x00001000) /* RO */
357 #define INT_CFG_IRQ_EN_ (0x00000100) /* R/W */
358 #define INT_CFG_IRQ_POL_ (0x00000010) /* R/W Not Affected by SW Reset */
359 #define INT_CFG_IRQ_TYPE_ (0x00000001) /* R/W Not Affected by SW Reset */
361 #define INT_STS (0x58)
362 #define INT_STS_SW_INT_ (0x80000000) /* R/WC */
363 #define INT_STS_TXSTOP_INT_ (0x02000000) /* R/WC */
364 #define INT_STS_RXSTOP_INT_ (0x01000000) /* R/WC */
365 #define INT_STS_RXDFH_INT_ (0x00800000) /* R/WC */
366 #define INT_STS_RXDF_INT_ (0x00400000) /* R/WC */
367 #define INT_STS_TX_IOC_ (0x00200000) /* R/WC */
368 #define INT_STS_RXD_INT_ (0x00100000) /* R/WC */
369 #define INT_STS_GPT_INT_ (0x00080000) /* R/WC */
370 #define INT_STS_PHY_INT_ (0x00040000) /* RO */
371 #define INT_STS_PME_INT_ (0x00020000) /* R/WC */
372 #define INT_STS_TXSO_ (0x00010000) /* R/WC */
373 #define INT_STS_RWT_ (0x00008000) /* R/WC */
374 #define INT_STS_RXE_ (0x00004000) /* R/WC */
375 #define INT_STS_TXE_ (0x00002000) /* R/WC */
376 //#define INT_STS_ERX_ (0x00001000) /* R/WC */
377 #define INT_STS_TDFU_ (0x00000800) /* R/WC */
378 #define INT_STS_TDFO_ (0x00000400) /* R/WC */
379 #define INT_STS_TDFA_ (0x00000200) /* R/WC */
380 #define INT_STS_TSFF_ (0x00000100) /* R/WC */
381 #define INT_STS_TSFL_ (0x00000080) /* R/WC */
382 //#define INT_STS_RXDF_ (0x00000040) /* R/WC */
383 #define INT_STS_RDFO_ (0x00000040) /* R/WC */
384 #define INT_STS_RDFL_ (0x00000020) /* R/WC */
385 #define INT_STS_RSFF_ (0x00000010) /* R/WC */
386 #define INT_STS_RSFL_ (0x00000008) /* R/WC */
387 #define INT_STS_GPIO2_INT_ (0x00000004) /* R/WC */
388 #define INT_STS_GPIO1_INT_ (0x00000002) /* R/WC */
389 #define INT_STS_GPIO0_INT_ (0x00000001) /* R/WC */
391 #define INT_EN (0x5C)
392 #define INT_EN_SW_INT_EN_ (0x80000000) /* R/W */
393 #define INT_EN_TXSTOP_INT_EN_ (0x02000000) /* R/W */
394 #define INT_EN_RXSTOP_INT_EN_ (0x01000000) /* R/W */
395 #define INT_EN_RXDFH_INT_EN_ (0x00800000) /* R/W */
396 //#define INT_EN_RXDF_INT_EN_ (0x00400000) /* R/W */
397 #define INT_EN_TIOC_INT_EN_ (0x00200000) /* R/W */
398 #define INT_EN_RXD_INT_EN_ (0x00100000) /* R/W */
399 #define INT_EN_GPT_INT_EN_ (0x00080000) /* R/W */
400 #define INT_EN_PHY_INT_EN_ (0x00040000) /* R/W */
401 #define INT_EN_PME_INT_EN_ (0x00020000) /* R/W */
402 #define INT_EN_TXSO_EN_ (0x00010000) /* R/W */
403 #define INT_EN_RWT_EN_ (0x00008000) /* R/W */
404 #define INT_EN_RXE_EN_ (0x00004000) /* R/W */
405 #define INT_EN_TXE_EN_ (0x00002000) /* R/W */
406 //#define INT_EN_ERX_EN_ (0x00001000) /* R/W */
407 #define INT_EN_TDFU_EN_ (0x00000800) /* R/W */
408 #define INT_EN_TDFO_EN_ (0x00000400) /* R/W */
409 #define INT_EN_TDFA_EN_ (0x00000200) /* R/W */
410 #define INT_EN_TSFF_EN_ (0x00000100) /* R/W */
411 #define INT_EN_TSFL_EN_ (0x00000080) /* R/W */
412 //#define INT_EN_RXDF_EN_ (0x00000040) /* R/W */
413 #define INT_EN_RDFO_EN_ (0x00000040) /* R/W */
414 #define INT_EN_RDFL_EN_ (0x00000020) /* R/W */
415 #define INT_EN_RSFF_EN_ (0x00000010) /* R/W */
416 #define INT_EN_RSFL_EN_ (0x00000008) /* R/W */
417 #define INT_EN_GPIO2_INT_ (0x00000004) /* R/W */
418 #define INT_EN_GPIO1_INT_ (0x00000002) /* R/W */
419 #define INT_EN_GPIO0_INT_ (0x00000001) /* R/W */
421 #define BYTE_TEST (0x64)
422 #define FIFO_INT (0x68)
423 #define FIFO_INT_TX_AVAIL_LEVEL_ (0xFF000000) /* R/W */
424 #define FIFO_INT_TX_STS_LEVEL_ (0x00FF0000) /* R/W */
425 #define FIFO_INT_RX_AVAIL_LEVEL_ (0x0000FF00) /* R/W */
426 #define FIFO_INT_RX_STS_LEVEL_ (0x000000FF) /* R/W */
428 #define RX_CFG (0x6C)
429 #define RX_CFG_RX_END_ALGN_ (0xC0000000) /* R/W */
430 #define RX_CFG_RX_END_ALGN4_ (0x00000000) /* R/W */
431 #define RX_CFG_RX_END_ALGN16_ (0x40000000) /* R/W */
432 #define RX_CFG_RX_END_ALGN32_ (0x80000000) /* R/W */
433 #define RX_CFG_RX_DMA_CNT_ (0x0FFF0000) /* R/W */
434 #define RX_CFG_RX_DUMP_ (0x00008000) /* R/W */
435 #define RX_CFG_RXDOFF_ (0x00001F00) /* R/W */
436 //#define RX_CFG_RXBAD_ (0x00000001) /* R/W */
438 #define TX_CFG (0x70)
439 //#define TX_CFG_TX_DMA_LVL_ (0xE0000000) /* R/W */
440 //#define TX_CFG_TX_DMA_CNT_ (0x0FFF0000) /* R/W Self Clearing */
441 #define TX_CFG_TXS_DUMP_ (0x00008000) /* Self Clearing */
442 #define TX_CFG_TXD_DUMP_ (0x00004000) /* Self Clearing */
443 #define TX_CFG_TXSAO_ (0x00000004) /* R/W */
444 #define TX_CFG_TX_ON_ (0x00000002) /* R/W */
445 #define TX_CFG_STOP_TX_ (0x00000001) /* Self Clearing */
447 #define HW_CFG (0x74)
448 #define HW_CFG_TTM_ (0x00200000) /* R/W */
449 #define HW_CFG_SF_ (0x00100000) /* R/W */
450 #define HW_CFG_TX_FIF_SZ_ (0x000F0000) /* R/W */
451 #define HW_CFG_TR_ (0x00003000) /* R/W */
452 #define HW_CFG_PHY_CLK_SEL_ (0x00000060) /* R/W */
453 #define HW_CFG_PHY_CLK_SEL_INT_PHY_ (0x00000000) /* R/W */
454 #define HW_CFG_PHY_CLK_SEL_EXT_PHY_ (0x00000020) /* R/W */
455 #define HW_CFG_PHY_CLK_SEL_CLK_DIS_ (0x00000040) /* R/W */
456 #define HW_CFG_SMI_SEL_ (0x00000010) /* R/W */
457 #define HW_CFG_EXT_PHY_DET_ (0x00000008) /* RO */
458 #define HW_CFG_EXT_PHY_EN_ (0x00000004) /* R/W */
459 #define HW_CFG_32_16_BIT_MODE_ (0x00000004) /* RO */
460 #define HW_CFG_SRST_TO_ (0x00000002) /* RO */
461 #define HW_CFG_SRST_ (0x00000001) /* Self Clearing */
463 #define RX_DP_CTRL (0x78)
464 #define RX_DP_CTRL_RX_FFWD_ (0x80000000) /* R/W */
465 #define RX_DP_CTRL_FFWD_BUSY_ (0x80000000) /* RO */
467 #define RX_FIFO_INF (0x7C)
468 #define RX_FIFO_INF_RXSUSED_ (0x00FF0000) /* RO */
469 #define RX_FIFO_INF_RXDUSED_ (0x0000FFFF) /* RO */
471 #define TX_FIFO_INF (0x80)
472 #define TX_FIFO_INF_TSUSED_ (0x00FF0000) /* RO */
473 #define TX_FIFO_INF_TDFREE_ (0x0000FFFF) /* RO */
475 #define PMT_CTRL (0x84)
476 #define PMT_CTRL_PM_MODE_ (0x00003000) /* Self Clearing */
477 #define PMT_CTRL_PHY_RST_ (0x00000400) /* Self Clearing */
478 #define PMT_CTRL_WOL_EN_ (0x00000200) /* R/W */
479 #define PMT_CTRL_ED_EN_ (0x00000100) /* R/W */
480 #define PMT_CTRL_PME_TYPE_ (0x00000040) /* R/W Not Affected by SW Reset */
481 #define PMT_CTRL_WUPS_ (0x00000030) /* R/WC */
482 #define PMT_CTRL_WUPS_NOWAKE_ (0x00000000) /* R/WC */
483 #define PMT_CTRL_WUPS_ED_ (0x00000010) /* R/WC */
484 #define PMT_CTRL_WUPS_WOL_ (0x00000020) /* R/WC */
485 #define PMT_CTRL_WUPS_MULTI_ (0x00000030) /* R/WC */
486 #define PMT_CTRL_PME_IND_ (0x00000008) /* R/W */
487 #define PMT_CTRL_PME_POL_ (0x00000004) /* R/W */
488 #define PMT_CTRL_PME_EN_ (0x00000002) /* R/W Not Affected by SW Reset */
489 #define PMT_CTRL_READY_ (0x00000001) /* RO */
491 #define GPIO_CFG (0x88)
492 #define GPIO_CFG_LED3_EN_ (0x40000000) /* R/W */
493 #define GPIO_CFG_LED2_EN_ (0x20000000) /* R/W */
494 #define GPIO_CFG_LED1_EN_ (0x10000000) /* R/W */
495 #define GPIO_CFG_GPIO2_INT_POL_ (0x04000000) /* R/W */
496 #define GPIO_CFG_GPIO1_INT_POL_ (0x02000000) /* R/W */
497 #define GPIO_CFG_GPIO0_INT_POL_ (0x01000000) /* R/W */
498 #define GPIO_CFG_EEPR_EN_ (0x00700000) /* R/W */
499 #define GPIO_CFG_GPIOBUF2_ (0x00040000) /* R/W */
500 #define GPIO_CFG_GPIOBUF1_ (0x00020000) /* R/W */
501 #define GPIO_CFG_GPIOBUF0_ (0x00010000) /* R/W */
502 #define GPIO_CFG_GPIODIR2_ (0x00000400) /* R/W */
503 #define GPIO_CFG_GPIODIR1_ (0x00000200) /* R/W */
504 #define GPIO_CFG_GPIODIR0_ (0x00000100) /* R/W */
505 #define GPIO_CFG_GPIOD4_ (0x00000010) /* R/W */
506 #define GPIO_CFG_GPIOD3_ (0x00000008) /* R/W */
507 #define GPIO_CFG_GPIOD2_ (0x00000004) /* R/W */
508 #define GPIO_CFG_GPIOD1_ (0x00000002) /* R/W */
509 #define GPIO_CFG_GPIOD0_ (0x00000001) /* R/W */
511 #define GPT_CFG (0x8C)
512 #define GPT_CFG_TIMER_EN_ (0x20000000) /* R/W */
513 #define GPT_CFG_GPT_LOAD_ (0x0000FFFF) /* R/W */
515 #define GPT_CNT (0x90)
516 #define GPT_CNT_GPT_CNT_ (0x0000FFFF) /* RO */
518 #define ENDIAN (0x98)
519 #define FREE_RUN (0x9C)
520 #define RX_DROP (0xA0)
521 #define MAC_CSR_CMD (0xA4)
522 #define MAC_CSR_CMD_CSR_BUSY_ (0x80000000) /* Self Clearing */
523 #define MAC_CSR_CMD_R_NOT_W_ (0x40000000) /* R/W */
524 #define MAC_CSR_CMD_CSR_ADDR_ (0x000000FF) /* R/W */
526 #define MAC_CSR_DATA (0xA8)
527 #define AFC_CFG (0xAC)
528 #define AFC_CFG_AFC_HI_ (0x00FF0000) /* R/W */
529 #define AFC_CFG_AFC_LO_ (0x0000FF00) /* R/W */
530 #define AFC_CFG_BACK_DUR_ (0x000000F0) /* R/W */
531 #define AFC_CFG_FCMULT_ (0x00000008) /* R/W */
532 #define AFC_CFG_FCBRD_ (0x00000004) /* R/W */
533 #define AFC_CFG_FCADD_ (0x00000002) /* R/W */
534 #define AFC_CFG_FCANY_ (0x00000001) /* R/W */
536 #define E2P_CMD (0xB0)
537 #define E2P_CMD_EPC_BUSY_ (0x80000000) /* Self Clearing */
538 #define E2P_CMD_EPC_CMD_ (0x70000000) /* R/W */
539 #define E2P_CMD_EPC_CMD_READ_ (0x00000000) /* R/W */
540 #define E2P_CMD_EPC_CMD_EWDS_ (0x10000000) /* R/W */
541 #define E2P_CMD_EPC_CMD_EWEN_ (0x20000000) /* R/W */
542 #define E2P_CMD_EPC_CMD_WRITE_ (0x30000000) /* R/W */
543 #define E2P_CMD_EPC_CMD_WRAL_ (0x40000000) /* R/W */
544 #define E2P_CMD_EPC_CMD_ERASE_ (0x50000000) /* R/W */
545 #define E2P_CMD_EPC_CMD_ERAL_ (0x60000000) /* R/W */
546 #define E2P_CMD_EPC_CMD_RELOAD_ (0x70000000) /* R/W */
547 #define E2P_CMD_EPC_TIMEOUT_ (0x00000200) /* RO */
548 #define E2P_CMD_MAC_ADDR_LOADED_ (0x00000100) /* RO */
549 #define E2P_CMD_EPC_ADDR_ (0x000000FF) /* R/W */
551 #define E2P_DATA (0xB4)
552 #define E2P_DATA_EEPROM_DATA_ (0x000000FF) /* R/W */
553 /* end of LAN register offsets and bit definitions */
556 ****************************************************************************
557 ****************************************************************************
558 * MAC Control and Status Register (Indirect Address)
559 * Offset (through the MAC_CSR CMD and DATA port)
560 ****************************************************************************
561 ****************************************************************************
564 #define MAC_CR (0x01) /* R/W */
566 /* MAC_CR - MAC Control Register */
567 #define MAC_CR_RXALL_ (0x80000000)
568 // TODO: delete this bit? It is not described in the data sheet.
569 #define MAC_CR_HBDIS_ (0x10000000)
570 #define MAC_CR_RCVOWN_ (0x00800000)
571 #define MAC_CR_LOOPBK_ (0x00200000)
572 #define MAC_CR_FDPX_ (0x00100000)
573 #define MAC_CR_MCPAS_ (0x00080000)
574 #define MAC_CR_PRMS_ (0x00040000)
575 #define MAC_CR_INVFILT_ (0x00020000)
576 #define MAC_CR_PASSBAD_ (0x00010000)
577 #define MAC_CR_HFILT_ (0x00008000)
578 #define MAC_CR_HPFILT_ (0x00002000)
579 #define MAC_CR_LCOLL_ (0x00001000)
580 #define MAC_CR_BCAST_ (0x00000800)
581 #define MAC_CR_DISRTY_ (0x00000400)
582 #define MAC_CR_PADSTR_ (0x00000100)
583 #define MAC_CR_BOLMT_MASK_ (0x000000C0)
584 #define MAC_CR_DFCHK_ (0x00000020)
585 #define MAC_CR_TXEN_ (0x00000008)
586 #define MAC_CR_RXEN_ (0x00000004)
588 #define ADDRH (0x02) /* R/W mask 0x0000FFFFUL */
589 #define ADDRL (0x03) /* R/W mask 0xFFFFFFFFUL */
590 #define HASHH (0x04) /* R/W */
591 #define HASHL (0x05) /* R/W */
593 #define MII_ACC (0x06) /* R/W */
594 #define MII_ACC_PHY_ADDR_ (0x0000F800)
595 #define MII_ACC_MIIRINDA_ (0x000007C0)
596 #define MII_ACC_MII_WRITE_ (0x00000002)
597 #define MII_ACC_MII_BUSY_ (0x00000001)
599 #define MII_DATA (0x07) /* R/W mask 0x0000FFFFUL */
601 #define FLOW (0x08) /* R/W */
602 #define FLOW_FCPT_ (0xFFFF0000)
603 #define FLOW_FCPASS_ (0x00000004)
604 #define FLOW_FCEN_ (0x00000002)
605 #define FLOW_FCBSY_ (0x00000001)
607 #define VLAN1 (0x09) /* R/W mask 0x0000FFFFUL */
608 #define VLAN1_VTI1_ (0x0000ffff)
610 #define VLAN2 (0x0A) /* R/W mask 0x0000FFFFUL */
611 #define VLAN2_VTI2_ (0x0000ffff)
613 #define WUFF (0x0B) /* WO */
615 #define WUCSR (0x0C) /* R/W */
616 #define WUCSR_GUE_ (0x00000200)
617 #define WUCSR_WUFR_ (0x00000040)
618 #define WUCSR_MPR_ (0x00000020)
619 #define WUCSR_WAKE_EN_ (0x00000004)
620 #define WUCSR_MPEN_ (0x00000002)
623 ****************************************************************************
624 * Chip Specific MII Defines
625 ****************************************************************************
627 * Phy register offsets and bit definitions
631 #define PHY_MODE_CTRL_STS ((u32)17) /* Mode Control/Status Register */
632 //#define MODE_CTRL_STS_FASTRIP_ ((u16)0x4000)
633 #define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000)
634 //#define MODE_CTRL_STS_LOWSQEN_ ((u16)0x0800)
635 //#define MODE_CTRL_STS_MDPREBP_ ((u16)0x0400)
636 //#define MODE_CTRL_STS_FARLOOPBACK_ ((u16)0x0200)
637 //#define MODE_CTRL_STS_FASTEST_ ((u16)0x0100)
638 //#define MODE_CTRL_STS_REFCLKEN_ ((u16)0x0010)
639 //#define MODE_CTRL_STS_PHYADBP_ ((u16)0x0008)
640 //#define MODE_CTRL_STS_FORCE_G_LINK_ ((u16)0x0004)
641 #define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002)
643 #define PHY_INT_SRC ((u32)29)
644 #define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080)
645 #define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040)
646 #define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020)
647 #define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010)
648 #define PHY_INT_SRC_ANEG_LP_ACK_ ((u16)0x0008)
649 #define PHY_INT_SRC_PAR_DET_FAULT_ ((u16)0x0004)
650 #define PHY_INT_SRC_ANEG_PGRX_ ((u16)0x0002)
652 #define PHY_INT_MASK ((u32)30)
653 #define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080)
654 #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
655 #define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020)
656 #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
657 #define PHY_INT_MASK_ANEG_LP_ACK_ ((u16)0x0008)
658 #define PHY_INT_MASK_PAR_DET_FAULT_ ((u16)0x0004)
659 #define PHY_INT_MASK_ANEG_PGRX_ ((u16)0x0002)
661 #define PHY_SPECIAL ((u32)31)
662 #define PHY_SPECIAL_ANEG_DONE_ ((u16)0x1000)
663 #define PHY_SPECIAL_RES_ ((u16)0x0040)
664 #define PHY_SPECIAL_RES_MASK_ ((u16)0x0FE1)
665 #define PHY_SPECIAL_SPD_ ((u16)0x001C)
666 #define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004)
667 #define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014)
668 #define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008)
669 #define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018)
671 #define LAN911X_INTERNAL_PHY_ID (0x0007C000)
673 /* Chip ID values */
674 #define CHIP_9115 0x0115
675 #define CHIP_9116 0x0116
676 #define CHIP_9117 0x0117
677 #define CHIP_9118 0x0118
678 #define CHIP_9215 0x115A
679 #define CHIP_9217 0x117A
680 #define CHIP_9218 0x118A
682 struct chip_id {
683 u16 id;
684 char *name;
687 static const struct chip_id chip_ids[] = {
688 { CHIP_9115, "LAN9115" },
689 { CHIP_9116, "LAN9116" },
690 { CHIP_9117, "LAN9117" },
691 { CHIP_9118, "LAN9118" },
692 { CHIP_9215, "LAN9215" },
693 { CHIP_9217, "LAN9217" },
694 { CHIP_9218, "LAN9218" },
695 { 0, NULL },
698 #define IS_REV_A(x) ((x & 0xFFFF)==0)
701 * Macros to abstract register access according to the data bus
702 * capabilities. Please use those and not the in/out primitives.
704 /* FIFO read/write macros */
705 #define SMC_PUSH_DATA(lp, p, l) SMC_outsl( lp, TX_DATA_FIFO, p, (l) >> 2 )
706 #define SMC_PULL_DATA(lp, p, l) SMC_insl ( lp, RX_DATA_FIFO, p, (l) >> 2 )
707 #define SMC_SET_TX_FIFO(lp, x) SMC_outl( x, lp, TX_DATA_FIFO )
708 #define SMC_GET_RX_FIFO(lp) SMC_inl( lp, RX_DATA_FIFO )
711 /* I/O mapped register read/write macros */
712 #define SMC_GET_TX_STS_FIFO(lp) SMC_inl( lp, TX_STATUS_FIFO )
713 #define SMC_GET_RX_STS_FIFO(lp) SMC_inl( lp, RX_STATUS_FIFO )
714 #define SMC_GET_RX_STS_FIFO_PEEK(lp) SMC_inl( lp, RX_STATUS_FIFO_PEEK )
715 #define SMC_GET_PN(lp) (SMC_inl( lp, ID_REV ) >> 16)
716 #define SMC_GET_REV(lp) (SMC_inl( lp, ID_REV ) & 0xFFFF)
717 #define SMC_GET_IRQ_CFG(lp) SMC_inl( lp, INT_CFG )
718 #define SMC_SET_IRQ_CFG(lp, x) SMC_outl( x, lp, INT_CFG )
719 #define SMC_GET_INT(lp) SMC_inl( lp, INT_STS )
720 #define SMC_ACK_INT(lp, x) SMC_outl( x, lp, INT_STS )
721 #define SMC_GET_INT_EN(lp) SMC_inl( lp, INT_EN )
722 #define SMC_SET_INT_EN(lp, x) SMC_outl( x, lp, INT_EN )
723 #define SMC_GET_BYTE_TEST(lp) SMC_inl( lp, BYTE_TEST )
724 #define SMC_SET_BYTE_TEST(lp, x) SMC_outl( x, lp, BYTE_TEST )
725 #define SMC_GET_FIFO_INT(lp) SMC_inl( lp, FIFO_INT )
726 #define SMC_SET_FIFO_INT(lp, x) SMC_outl( x, lp, FIFO_INT )
727 #define SMC_SET_FIFO_TDA(lp, x) \
728 do { \
729 unsigned long __flags; \
730 int __mask; \
731 local_irq_save(__flags); \
732 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<24); \
733 SMC_SET_FIFO_INT( (lp), __mask | (x)<<24 ); \
734 local_irq_restore(__flags); \
735 } while (0)
736 #define SMC_SET_FIFO_TSL(lp, x) \
737 do { \
738 unsigned long __flags; \
739 int __mask; \
740 local_irq_save(__flags); \
741 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<16); \
742 SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<16)); \
743 local_irq_restore(__flags); \
744 } while (0)
745 #define SMC_SET_FIFO_RSA(lp, x) \
746 do { \
747 unsigned long __flags; \
748 int __mask; \
749 local_irq_save(__flags); \
750 __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<8); \
751 SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<8)); \
752 local_irq_restore(__flags); \
753 } while (0)
754 #define SMC_SET_FIFO_RSL(lp, x) \
755 do { \
756 unsigned long __flags; \
757 int __mask; \
758 local_irq_save(__flags); \
759 __mask = SMC_GET_FIFO_INT((lp)) & ~0xFF; \
760 SMC_SET_FIFO_INT( (lp),__mask | ((x) & 0xFF)); \
761 local_irq_restore(__flags); \
762 } while (0)
763 #define SMC_GET_RX_CFG(lp) SMC_inl( lp, RX_CFG )
764 #define SMC_SET_RX_CFG(lp, x) SMC_outl( x, lp, RX_CFG )
765 #define SMC_GET_TX_CFG(lp) SMC_inl( lp, TX_CFG )
766 #define SMC_SET_TX_CFG(lp, x) SMC_outl( x, lp, TX_CFG )
767 #define SMC_GET_HW_CFG(lp) SMC_inl( lp, HW_CFG )
768 #define SMC_SET_HW_CFG(lp, x) SMC_outl( x, lp, HW_CFG )
769 #define SMC_GET_RX_DP_CTRL(lp) SMC_inl( lp, RX_DP_CTRL )
770 #define SMC_SET_RX_DP_CTRL(lp, x) SMC_outl( x, lp, RX_DP_CTRL )
771 #define SMC_GET_PMT_CTRL(lp) SMC_inl( lp, PMT_CTRL )
772 #define SMC_SET_PMT_CTRL(lp, x) SMC_outl( x, lp, PMT_CTRL )
773 #define SMC_GET_GPIO_CFG(lp) SMC_inl( lp, GPIO_CFG )
774 #define SMC_SET_GPIO_CFG(lp, x) SMC_outl( x, lp, GPIO_CFG )
775 #define SMC_GET_RX_FIFO_INF(lp) SMC_inl( lp, RX_FIFO_INF )
776 #define SMC_SET_RX_FIFO_INF(lp, x) SMC_outl( x, lp, RX_FIFO_INF )
777 #define SMC_GET_TX_FIFO_INF(lp) SMC_inl( lp, TX_FIFO_INF )
778 #define SMC_SET_TX_FIFO_INF(lp, x) SMC_outl( x, lp, TX_FIFO_INF )
779 #define SMC_GET_GPT_CFG(lp) SMC_inl( lp, GPT_CFG )
780 #define SMC_SET_GPT_CFG(lp, x) SMC_outl( x, lp, GPT_CFG )
781 #define SMC_GET_RX_DROP(lp) SMC_inl( lp, RX_DROP )
782 #define SMC_SET_RX_DROP(lp, x) SMC_outl( x, lp, RX_DROP )
783 #define SMC_GET_MAC_CMD(lp) SMC_inl( lp, MAC_CSR_CMD )
784 #define SMC_SET_MAC_CMD(lp, x) SMC_outl( x, lp, MAC_CSR_CMD )
785 #define SMC_GET_MAC_DATA(lp) SMC_inl( lp, MAC_CSR_DATA )
786 #define SMC_SET_MAC_DATA(lp, x) SMC_outl( x, lp, MAC_CSR_DATA )
787 #define SMC_GET_AFC_CFG(lp) SMC_inl( lp, AFC_CFG )
788 #define SMC_SET_AFC_CFG(lp, x) SMC_outl( x, lp, AFC_CFG )
789 #define SMC_GET_E2P_CMD(lp) SMC_inl( lp, E2P_CMD )
790 #define SMC_SET_E2P_CMD(lp, x) SMC_outl( x, lp, E2P_CMD )
791 #define SMC_GET_E2P_DATA(lp) SMC_inl( lp, E2P_DATA )
792 #define SMC_SET_E2P_DATA(lp, x) SMC_outl( x, lp, E2P_DATA )
794 /* MAC register read/write macros */
795 #define SMC_GET_MAC_CSR(lp,a,v) \
796 do { \
797 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
798 SMC_SET_MAC_CMD((lp),MAC_CSR_CMD_CSR_BUSY_ | \
799 MAC_CSR_CMD_R_NOT_W_ | (a) ); \
800 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
801 v = SMC_GET_MAC_DATA((lp)); \
802 } while (0)
803 #define SMC_SET_MAC_CSR(lp,a,v) \
804 do { \
805 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
806 SMC_SET_MAC_DATA((lp), v); \
807 SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_CSR_BUSY_ | (a) ); \
808 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
809 } while (0)
810 #define SMC_GET_MAC_CR(lp, x) SMC_GET_MAC_CSR( (lp), MAC_CR, x )
811 #define SMC_SET_MAC_CR(lp, x) SMC_SET_MAC_CSR( (lp), MAC_CR, x )
812 #define SMC_GET_ADDRH(lp, x) SMC_GET_MAC_CSR( (lp), ADDRH, x )
813 #define SMC_SET_ADDRH(lp, x) SMC_SET_MAC_CSR( (lp), ADDRH, x )
814 #define SMC_GET_ADDRL(lp, x) SMC_GET_MAC_CSR( (lp), ADDRL, x )
815 #define SMC_SET_ADDRL(lp, x) SMC_SET_MAC_CSR( (lp), ADDRL, x )
816 #define SMC_GET_HASHH(lp, x) SMC_GET_MAC_CSR( (lp), HASHH, x )
817 #define SMC_SET_HASHH(lp, x) SMC_SET_MAC_CSR( (lp), HASHH, x )
818 #define SMC_GET_HASHL(lp, x) SMC_GET_MAC_CSR( (lp), HASHL, x )
819 #define SMC_SET_HASHL(lp, x) SMC_SET_MAC_CSR( (lp), HASHL, x )
820 #define SMC_GET_MII_ACC(lp, x) SMC_GET_MAC_CSR( (lp), MII_ACC, x )
821 #define SMC_SET_MII_ACC(lp, x) SMC_SET_MAC_CSR( (lp), MII_ACC, x )
822 #define SMC_GET_MII_DATA(lp, x) SMC_GET_MAC_CSR( (lp), MII_DATA, x )
823 #define SMC_SET_MII_DATA(lp, x) SMC_SET_MAC_CSR( (lp), MII_DATA, x )
824 #define SMC_GET_FLOW(lp, x) SMC_GET_MAC_CSR( (lp), FLOW, x )
825 #define SMC_SET_FLOW(lp, x) SMC_SET_MAC_CSR( (lp), FLOW, x )
826 #define SMC_GET_VLAN1(lp, x) SMC_GET_MAC_CSR( (lp), VLAN1, x )
827 #define SMC_SET_VLAN1(lp, x) SMC_SET_MAC_CSR( (lp), VLAN1, x )
828 #define SMC_GET_VLAN2(lp, x) SMC_GET_MAC_CSR( (lp), VLAN2, x )
829 #define SMC_SET_VLAN2(lp, x) SMC_SET_MAC_CSR( (lp), VLAN2, x )
830 #define SMC_SET_WUFF(lp, x) SMC_SET_MAC_CSR( (lp), WUFF, x )
831 #define SMC_GET_WUCSR(lp, x) SMC_GET_MAC_CSR( (lp), WUCSR, x )
832 #define SMC_SET_WUCSR(lp, x) SMC_SET_MAC_CSR( (lp), WUCSR, x )
834 /* PHY register read/write macros */
835 #define SMC_GET_MII(lp,a,phy,v) \
836 do { \
837 u32 __v; \
838 do { \
839 SMC_GET_MII_ACC((lp), __v); \
840 } while ( __v & MII_ACC_MII_BUSY_ ); \
841 SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
842 MII_ACC_MII_BUSY_); \
843 do { \
844 SMC_GET_MII_ACC( (lp), __v); \
845 } while ( __v & MII_ACC_MII_BUSY_ ); \
846 SMC_GET_MII_DATA((lp), v); \
847 } while (0)
848 #define SMC_SET_MII(lp,a,phy,v) \
849 do { \
850 u32 __v; \
851 do { \
852 SMC_GET_MII_ACC((lp), __v); \
853 } while ( __v & MII_ACC_MII_BUSY_ ); \
854 SMC_SET_MII_DATA((lp), v); \
855 SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
856 MII_ACC_MII_BUSY_ | \
857 MII_ACC_MII_WRITE_ ); \
858 do { \
859 SMC_GET_MII_ACC((lp), __v); \
860 } while ( __v & MII_ACC_MII_BUSY_ ); \
861 } while (0)
862 #define SMC_GET_PHY_BMCR(lp,phy,x) SMC_GET_MII( (lp), MII_BMCR, phy, x )
863 #define SMC_SET_PHY_BMCR(lp,phy,x) SMC_SET_MII( (lp), MII_BMCR, phy, x )
864 #define SMC_GET_PHY_BMSR(lp,phy,x) SMC_GET_MII( (lp), MII_BMSR, phy, x )
865 #define SMC_GET_PHY_ID1(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID1, phy, x )
866 #define SMC_GET_PHY_ID2(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID2, phy, x )
867 #define SMC_GET_PHY_MII_ADV(lp,phy,x) SMC_GET_MII( (lp), MII_ADVERTISE, phy, x )
868 #define SMC_SET_PHY_MII_ADV(lp,phy,x) SMC_SET_MII( (lp), MII_ADVERTISE, phy, x )
869 #define SMC_GET_PHY_MII_LPA(lp,phy,x) SMC_GET_MII( (lp), MII_LPA, phy, x )
870 #define SMC_SET_PHY_MII_LPA(lp,phy,x) SMC_SET_MII( (lp), MII_LPA, phy, x )
871 #define SMC_GET_PHY_CTRL_STS(lp,phy,x) SMC_GET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
872 #define SMC_SET_PHY_CTRL_STS(lp,phy,x) SMC_SET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
873 #define SMC_GET_PHY_INT_SRC(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_SRC, phy, x )
874 #define SMC_SET_PHY_INT_SRC(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_SRC, phy, x )
875 #define SMC_GET_PHY_INT_MASK(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_MASK, phy, x )
876 #define SMC_SET_PHY_INT_MASK(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_MASK, phy, x )
877 #define SMC_GET_PHY_SPECIAL(lp,phy,x) SMC_GET_MII( (lp), PHY_SPECIAL, phy, x )
881 /* Misc read/write macros */
883 #ifndef SMC_GET_MAC_ADDR
884 #define SMC_GET_MAC_ADDR(lp, addr) \
885 do { \
886 unsigned int __v; \
888 SMC_GET_MAC_CSR((lp), ADDRL, __v); \
889 addr[0] = __v; addr[1] = __v >> 8; \
890 addr[2] = __v >> 16; addr[3] = __v >> 24; \
891 SMC_GET_MAC_CSR((lp), ADDRH, __v); \
892 addr[4] = __v; addr[5] = __v >> 8; \
893 } while (0)
894 #endif
896 #define SMC_SET_MAC_ADDR(lp, addr) \
897 do { \
898 SMC_SET_MAC_CSR((lp), ADDRL, \
899 addr[0] | \
900 (addr[1] << 8) | \
901 (addr[2] << 16) | \
902 (addr[3] << 24)); \
903 SMC_SET_MAC_CSR((lp), ADDRH, addr[4]|(addr[5] << 8));\
904 } while (0)
907 #define SMC_WRITE_EEPROM_CMD(lp, cmd, addr) \
908 do { \
909 while (SMC_GET_E2P_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
910 SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_R_NOT_W_ | a ); \
911 while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
912 } while (0)
914 #endif /* _SMC911X_H_ */