smc911x.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. /*------------------------------------------------------------------------
  2. . smc911x.h - macros for SMSC's LAN911{5,6,7,8} single-chip Ethernet device.
  3. .
  4. . Copyright (C) 2005 Sensoria Corp.
  5. . Derived from the unified SMC91x driver by Nicolas Pitre
  6. .
  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.
  11. .
  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.
  16. .
  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
  20. .
  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.
  24. .
  25. . Authors
  26. . Dustin McIntire <dustin@sensoria.com>
  27. .
  28. ---------------------------------------------------------------------------*/
  29. #ifndef _SMC911X_H_
  30. #define _SMC911X_H_
  31. /*
  32. * Use the DMA feature on PXA chips
  33. */
  34. #ifdef CONFIG_ARCH_PXA
  35. #define SMC_USE_PXA_DMA 1
  36. #define SMC_USE_16BIT 0
  37. #define SMC_USE_32BIT 1
  38. #define SMC_IRQ_SENSE IRQF_TRIGGER_FALLING
  39. #elif defined(CONFIG_SH_MAGIC_PANEL_R2)
  40. #define SMC_USE_SH_DMA 0
  41. #define SMC_USE_16BIT 0
  42. #define SMC_USE_32BIT 1
  43. #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
  44. #endif
  45. /* store this information for the driver.. */
  46. struct smc911x_local {
  47. /*
  48. * If I have to wait until the DMA is finished and ready to reload a
  49. * packet, I will store the skbuff here. Then, the DMA will send it
  50. * out and free it.
  51. */
  52. struct sk_buff *pending_tx_skb;
  53. /* version/revision of the SMC911x chip */
  54. u16 version;
  55. u16 revision;
  56. /* FIFO sizes */
  57. int tx_fifo_kb;
  58. int tx_fifo_size;
  59. int rx_fifo_size;
  60. int afc_cfg;
  61. /* Contains the current active receive/phy mode */
  62. int ctl_rfduplx;
  63. int ctl_rspeed;
  64. u32 msg_enable;
  65. u32 phy_type;
  66. struct mii_if_info mii;
  67. /* work queue */
  68. struct work_struct phy_configure;
  69. int work_pending;
  70. int tx_throttle;
  71. spinlock_t lock;
  72. struct net_device *netdev;
  73. #ifdef SMC_USE_DMA
  74. /* DMA needs the physical address of the chip */
  75. u_long physaddr;
  76. int rxdma;
  77. int txdma;
  78. int rxdma_active;
  79. int txdma_active;
  80. struct sk_buff *current_rx_skb;
  81. struct sk_buff *current_tx_skb;
  82. struct device *dev;
  83. #endif
  84. void __iomem *base;
  85. };
  86. /*
  87. * Define the bus width specific IO macros
  88. */
  89. #if SMC_USE_16BIT
  90. #define SMC_inl(lp, r) ((readw((lp)->base + (r)) & 0xFFFF) + (readw((lp)->base + (r) + 2) << 16))
  91. #define SMC_outl(v, lp, r) \
  92. do{ \
  93. writew(v & 0xFFFF, (lp)->base + (r)); \
  94. writew(v >> 16, (lp)->base + (r) + 2); \
  95. } while (0)
  96. #define SMC_insl(lp, r, p, l) readsw((short*)((lp)->base + (r)), p, l*2)
  97. #define SMC_outsl(lp, r, p, l) writesw((short*)((lp)->base + (r)), p, l*2)
  98. #elif SMC_USE_32BIT
  99. #define SMC_inl(lp, r) readl((lp)->base + (r))
  100. #define SMC_outl(v, lp, r) writel(v, (lp)->base + (r))
  101. #define SMC_insl(lp, r, p, l) readsl((int*)((lp)->base + (r)), p, l)
  102. #define SMC_outsl(lp, r, p, l) writesl((int*)((lp)->base + (r)), p, l)
  103. #endif /* SMC_USE_16BIT */
  104. #ifdef SMC_USE_PXA_DMA
  105. #define SMC_USE_DMA
  106. /*
  107. * Define the request and free functions
  108. * These are unfortunately architecture specific as no generic allocation
  109. * mechanism exits
  110. */
  111. #define SMC_DMA_REQUEST(dev, handler) \
  112. pxa_request_dma(dev->name, DMA_PRIO_LOW, handler, dev)
  113. #define SMC_DMA_FREE(dev, dma) \
  114. pxa_free_dma(dma)
  115. #define SMC_DMA_ACK_IRQ(dev, dma) \
  116. { \
  117. if (DCSR(dma) & DCSR_BUSERR) { \
  118. printk("%s: DMA %d bus error!\n", dev->name, dma); \
  119. } \
  120. DCSR(dma) = DCSR_STARTINTR|DCSR_ENDINTR|DCSR_BUSERR; \
  121. }
  122. /*
  123. * Use a DMA for RX and TX packets.
  124. */
  125. #include <linux/dma-mapping.h>
  126. #include <asm/dma.h>
  127. #include <asm/arch/pxa-regs.h>
  128. static dma_addr_t rx_dmabuf, tx_dmabuf;
  129. static int rx_dmalen, tx_dmalen;
  130. #ifdef SMC_insl
  131. #undef SMC_insl
  132. #define SMC_insl(lp, r, p, l) \
  133. smc_pxa_dma_insl(lp, lp->physaddr, r, lp->rxdma, p, l)
  134. static inline void
  135. smc_pxa_dma_insl(struct smc911x_local *lp, u_long physaddr,
  136. int reg, int dma, u_char *buf, int len)
  137. {
  138. /* 64 bit alignment is required for memory to memory DMA */
  139. if ((long)buf & 4) {
  140. *((u32 *)buf) = SMC_inl(lp, reg);
  141. buf += 4;
  142. len--;
  143. }
  144. len *= 4;
  145. rx_dmabuf = dma_map_single(lp->dev, buf, len, DMA_FROM_DEVICE);
  146. rx_dmalen = len;
  147. DCSR(dma) = DCSR_NODESC;
  148. DTADR(dma) = rx_dmabuf;
  149. DSADR(dma) = physaddr + reg;
  150. DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
  151. DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & rx_dmalen));
  152. DCSR(dma) = DCSR_NODESC | DCSR_RUN;
  153. }
  154. #endif
  155. #ifdef SMC_outsl
  156. #undef SMC_outsl
  157. #define SMC_outsl(lp, r, p, l) \
  158. smc_pxa_dma_outsl(lp, lp->physaddr, r, lp->txdma, p, l)
  159. static inline void
  160. smc_pxa_dma_outsl(struct smc911x_local *lp, u_long physaddr,
  161. int reg, int dma, u_char *buf, int len)
  162. {
  163. /* 64 bit alignment is required for memory to memory DMA */
  164. if ((long)buf & 4) {
  165. SMC_outl(*((u32 *)buf), lp, reg);
  166. buf += 4;
  167. len--;
  168. }
  169. len *= 4;
  170. tx_dmabuf = dma_map_single(lp->dev, buf, len, DMA_TO_DEVICE);
  171. tx_dmalen = len;
  172. DCSR(dma) = DCSR_NODESC;
  173. DSADR(dma) = tx_dmabuf;
  174. DTADR(dma) = physaddr + reg;
  175. DCMD(dma) = (DCMD_INCSRCADDR | DCMD_BURST32 |
  176. DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & tx_dmalen));
  177. DCSR(dma) = DCSR_NODESC | DCSR_RUN;
  178. }
  179. #endif
  180. #endif /* SMC_USE_PXA_DMA */
  181. /* Chip Parameters and Register Definitions */
  182. #define SMC911X_TX_FIFO_LOW_THRESHOLD (1536*2)
  183. #define SMC911X_IO_EXTENT 0x100
  184. #define SMC911X_EEPROM_LEN 7
  185. /* Below are the register offsets and bit definitions
  186. * of the Lan911x memory space
  187. */
  188. #define RX_DATA_FIFO (0x00)
  189. #define TX_DATA_FIFO (0x20)
  190. #define TX_CMD_A_INT_ON_COMP_ (0x80000000)
  191. #define TX_CMD_A_INT_BUF_END_ALGN_ (0x03000000)
  192. #define TX_CMD_A_INT_4_BYTE_ALGN_ (0x00000000)
  193. #define TX_CMD_A_INT_16_BYTE_ALGN_ (0x01000000)
  194. #define TX_CMD_A_INT_32_BYTE_ALGN_ (0x02000000)
  195. #define TX_CMD_A_INT_DATA_OFFSET_ (0x001F0000)
  196. #define TX_CMD_A_INT_FIRST_SEG_ (0x00002000)
  197. #define TX_CMD_A_INT_LAST_SEG_ (0x00001000)
  198. #define TX_CMD_A_BUF_SIZE_ (0x000007FF)
  199. #define TX_CMD_B_PKT_TAG_ (0xFFFF0000)
  200. #define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000)
  201. #define TX_CMD_B_DISABLE_PADDING_ (0x00001000)
  202. #define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF)
  203. #define RX_STATUS_FIFO (0x40)
  204. #define RX_STS_PKT_LEN_ (0x3FFF0000)
  205. #define RX_STS_ES_ (0x00008000)
  206. #define RX_STS_BCST_ (0x00002000)
  207. #define RX_STS_LEN_ERR_ (0x00001000)
  208. #define RX_STS_RUNT_ERR_ (0x00000800)
  209. #define RX_STS_MCAST_ (0x00000400)
  210. #define RX_STS_TOO_LONG_ (0x00000080)
  211. #define RX_STS_COLL_ (0x00000040)
  212. #define RX_STS_ETH_TYPE_ (0x00000020)
  213. #define RX_STS_WDOG_TMT_ (0x00000010)
  214. #define RX_STS_MII_ERR_ (0x00000008)
  215. #define RX_STS_DRIBBLING_ (0x00000004)
  216. #define RX_STS_CRC_ERR_ (0x00000002)
  217. #define RX_STATUS_FIFO_PEEK (0x44)
  218. #define TX_STATUS_FIFO (0x48)
  219. #define TX_STS_TAG_ (0xFFFF0000)
  220. #define TX_STS_ES_ (0x00008000)
  221. #define TX_STS_LOC_ (0x00000800)
  222. #define TX_STS_NO_CARR_ (0x00000400)
  223. #define TX_STS_LATE_COLL_ (0x00000200)
  224. #define TX_STS_MANY_COLL_ (0x00000100)
  225. #define TX_STS_COLL_CNT_ (0x00000078)
  226. #define TX_STS_MANY_DEFER_ (0x00000004)
  227. #define TX_STS_UNDERRUN_ (0x00000002)
  228. #define TX_STS_DEFERRED_ (0x00000001)
  229. #define TX_STATUS_FIFO_PEEK (0x4C)
  230. #define ID_REV (0x50)
  231. #define ID_REV_CHIP_ID_ (0xFFFF0000) /* RO */
  232. #define ID_REV_REV_ID_ (0x0000FFFF) /* RO */
  233. #define INT_CFG (0x54)
  234. #define INT_CFG_INT_DEAS_ (0xFF000000) /* R/W */
  235. #define INT_CFG_INT_DEAS_CLR_ (0x00004000)
  236. #define INT_CFG_INT_DEAS_STS_ (0x00002000)
  237. #define INT_CFG_IRQ_INT_ (0x00001000) /* RO */
  238. #define INT_CFG_IRQ_EN_ (0x00000100) /* R/W */
  239. #define INT_CFG_IRQ_POL_ (0x00000010) /* R/W Not Affected by SW Reset */
  240. #define INT_CFG_IRQ_TYPE_ (0x00000001) /* R/W Not Affected by SW Reset */
  241. #define INT_STS (0x58)
  242. #define INT_STS_SW_INT_ (0x80000000) /* R/WC */
  243. #define INT_STS_TXSTOP_INT_ (0x02000000) /* R/WC */
  244. #define INT_STS_RXSTOP_INT_ (0x01000000) /* R/WC */
  245. #define INT_STS_RXDFH_INT_ (0x00800000) /* R/WC */
  246. #define INT_STS_RXDF_INT_ (0x00400000) /* R/WC */
  247. #define INT_STS_TX_IOC_ (0x00200000) /* R/WC */
  248. #define INT_STS_RXD_INT_ (0x00100000) /* R/WC */
  249. #define INT_STS_GPT_INT_ (0x00080000) /* R/WC */
  250. #define INT_STS_PHY_INT_ (0x00040000) /* RO */
  251. #define INT_STS_PME_INT_ (0x00020000) /* R/WC */
  252. #define INT_STS_TXSO_ (0x00010000) /* R/WC */
  253. #define INT_STS_RWT_ (0x00008000) /* R/WC */
  254. #define INT_STS_RXE_ (0x00004000) /* R/WC */
  255. #define INT_STS_TXE_ (0x00002000) /* R/WC */
  256. //#define INT_STS_ERX_ (0x00001000) /* R/WC */
  257. #define INT_STS_TDFU_ (0x00000800) /* R/WC */
  258. #define INT_STS_TDFO_ (0x00000400) /* R/WC */
  259. #define INT_STS_TDFA_ (0x00000200) /* R/WC */
  260. #define INT_STS_TSFF_ (0x00000100) /* R/WC */
  261. #define INT_STS_TSFL_ (0x00000080) /* R/WC */
  262. //#define INT_STS_RXDF_ (0x00000040) /* R/WC */
  263. #define INT_STS_RDFO_ (0x00000040) /* R/WC */
  264. #define INT_STS_RDFL_ (0x00000020) /* R/WC */
  265. #define INT_STS_RSFF_ (0x00000010) /* R/WC */
  266. #define INT_STS_RSFL_ (0x00000008) /* R/WC */
  267. #define INT_STS_GPIO2_INT_ (0x00000004) /* R/WC */
  268. #define INT_STS_GPIO1_INT_ (0x00000002) /* R/WC */
  269. #define INT_STS_GPIO0_INT_ (0x00000001) /* R/WC */
  270. #define INT_EN (0x5C)
  271. #define INT_EN_SW_INT_EN_ (0x80000000) /* R/W */
  272. #define INT_EN_TXSTOP_INT_EN_ (0x02000000) /* R/W */
  273. #define INT_EN_RXSTOP_INT_EN_ (0x01000000) /* R/W */
  274. #define INT_EN_RXDFH_INT_EN_ (0x00800000) /* R/W */
  275. //#define INT_EN_RXDF_INT_EN_ (0x00400000) /* R/W */
  276. #define INT_EN_TIOC_INT_EN_ (0x00200000) /* R/W */
  277. #define INT_EN_RXD_INT_EN_ (0x00100000) /* R/W */
  278. #define INT_EN_GPT_INT_EN_ (0x00080000) /* R/W */
  279. #define INT_EN_PHY_INT_EN_ (0x00040000) /* R/W */
  280. #define INT_EN_PME_INT_EN_ (0x00020000) /* R/W */
  281. #define INT_EN_TXSO_EN_ (0x00010000) /* R/W */
  282. #define INT_EN_RWT_EN_ (0x00008000) /* R/W */
  283. #define INT_EN_RXE_EN_ (0x00004000) /* R/W */
  284. #define INT_EN_TXE_EN_ (0x00002000) /* R/W */
  285. //#define INT_EN_ERX_EN_ (0x00001000) /* R/W */
  286. #define INT_EN_TDFU_EN_ (0x00000800) /* R/W */
  287. #define INT_EN_TDFO_EN_ (0x00000400) /* R/W */
  288. #define INT_EN_TDFA_EN_ (0x00000200) /* R/W */
  289. #define INT_EN_TSFF_EN_ (0x00000100) /* R/W */
  290. #define INT_EN_TSFL_EN_ (0x00000080) /* R/W */
  291. //#define INT_EN_RXDF_EN_ (0x00000040) /* R/W */
  292. #define INT_EN_RDFO_EN_ (0x00000040) /* R/W */
  293. #define INT_EN_RDFL_EN_ (0x00000020) /* R/W */
  294. #define INT_EN_RSFF_EN_ (0x00000010) /* R/W */
  295. #define INT_EN_RSFL_EN_ (0x00000008) /* R/W */
  296. #define INT_EN_GPIO2_INT_ (0x00000004) /* R/W */
  297. #define INT_EN_GPIO1_INT_ (0x00000002) /* R/W */
  298. #define INT_EN_GPIO0_INT_ (0x00000001) /* R/W */
  299. #define BYTE_TEST (0x64)
  300. #define FIFO_INT (0x68)
  301. #define FIFO_INT_TX_AVAIL_LEVEL_ (0xFF000000) /* R/W */
  302. #define FIFO_INT_TX_STS_LEVEL_ (0x00FF0000) /* R/W */
  303. #define FIFO_INT_RX_AVAIL_LEVEL_ (0x0000FF00) /* R/W */
  304. #define FIFO_INT_RX_STS_LEVEL_ (0x000000FF) /* R/W */
  305. #define RX_CFG (0x6C)
  306. #define RX_CFG_RX_END_ALGN_ (0xC0000000) /* R/W */
  307. #define RX_CFG_RX_END_ALGN4_ (0x00000000) /* R/W */
  308. #define RX_CFG_RX_END_ALGN16_ (0x40000000) /* R/W */
  309. #define RX_CFG_RX_END_ALGN32_ (0x80000000) /* R/W */
  310. #define RX_CFG_RX_DMA_CNT_ (0x0FFF0000) /* R/W */
  311. #define RX_CFG_RX_DUMP_ (0x00008000) /* R/W */
  312. #define RX_CFG_RXDOFF_ (0x00001F00) /* R/W */
  313. //#define RX_CFG_RXBAD_ (0x00000001) /* R/W */
  314. #define TX_CFG (0x70)
  315. //#define TX_CFG_TX_DMA_LVL_ (0xE0000000) /* R/W */
  316. //#define TX_CFG_TX_DMA_CNT_ (0x0FFF0000) /* R/W Self Clearing */
  317. #define TX_CFG_TXS_DUMP_ (0x00008000) /* Self Clearing */
  318. #define TX_CFG_TXD_DUMP_ (0x00004000) /* Self Clearing */
  319. #define TX_CFG_TXSAO_ (0x00000004) /* R/W */
  320. #define TX_CFG_TX_ON_ (0x00000002) /* R/W */
  321. #define TX_CFG_STOP_TX_ (0x00000001) /* Self Clearing */
  322. #define HW_CFG (0x74)
  323. #define HW_CFG_TTM_ (0x00200000) /* R/W */
  324. #define HW_CFG_SF_ (0x00100000) /* R/W */
  325. #define HW_CFG_TX_FIF_SZ_ (0x000F0000) /* R/W */
  326. #define HW_CFG_TR_ (0x00003000) /* R/W */
  327. #define HW_CFG_PHY_CLK_SEL_ (0x00000060) /* R/W */
  328. #define HW_CFG_PHY_CLK_SEL_INT_PHY_ (0x00000000) /* R/W */
  329. #define HW_CFG_PHY_CLK_SEL_EXT_PHY_ (0x00000020) /* R/W */
  330. #define HW_CFG_PHY_CLK_SEL_CLK_DIS_ (0x00000040) /* R/W */
  331. #define HW_CFG_SMI_SEL_ (0x00000010) /* R/W */
  332. #define HW_CFG_EXT_PHY_DET_ (0x00000008) /* RO */
  333. #define HW_CFG_EXT_PHY_EN_ (0x00000004) /* R/W */
  334. #define HW_CFG_32_16_BIT_MODE_ (0x00000004) /* RO */
  335. #define HW_CFG_SRST_TO_ (0x00000002) /* RO */
  336. #define HW_CFG_SRST_ (0x00000001) /* Self Clearing */
  337. #define RX_DP_CTRL (0x78)
  338. #define RX_DP_CTRL_RX_FFWD_ (0x80000000) /* R/W */
  339. #define RX_DP_CTRL_FFWD_BUSY_ (0x80000000) /* RO */
  340. #define RX_FIFO_INF (0x7C)
  341. #define RX_FIFO_INF_RXSUSED_ (0x00FF0000) /* RO */
  342. #define RX_FIFO_INF_RXDUSED_ (0x0000FFFF) /* RO */
  343. #define TX_FIFO_INF (0x80)
  344. #define TX_FIFO_INF_TSUSED_ (0x00FF0000) /* RO */
  345. #define TX_FIFO_INF_TDFREE_ (0x0000FFFF) /* RO */
  346. #define PMT_CTRL (0x84)
  347. #define PMT_CTRL_PM_MODE_ (0x00003000) /* Self Clearing */
  348. #define PMT_CTRL_PHY_RST_ (0x00000400) /* Self Clearing */
  349. #define PMT_CTRL_WOL_EN_ (0x00000200) /* R/W */
  350. #define PMT_CTRL_ED_EN_ (0x00000100) /* R/W */
  351. #define PMT_CTRL_PME_TYPE_ (0x00000040) /* R/W Not Affected by SW Reset */
  352. #define PMT_CTRL_WUPS_ (0x00000030) /* R/WC */
  353. #define PMT_CTRL_WUPS_NOWAKE_ (0x00000000) /* R/WC */
  354. #define PMT_CTRL_WUPS_ED_ (0x00000010) /* R/WC */
  355. #define PMT_CTRL_WUPS_WOL_ (0x00000020) /* R/WC */
  356. #define PMT_CTRL_WUPS_MULTI_ (0x00000030) /* R/WC */
  357. #define PMT_CTRL_PME_IND_ (0x00000008) /* R/W */
  358. #define PMT_CTRL_PME_POL_ (0x00000004) /* R/W */
  359. #define PMT_CTRL_PME_EN_ (0x00000002) /* R/W Not Affected by SW Reset */
  360. #define PMT_CTRL_READY_ (0x00000001) /* RO */
  361. #define GPIO_CFG (0x88)
  362. #define GPIO_CFG_LED3_EN_ (0x40000000) /* R/W */
  363. #define GPIO_CFG_LED2_EN_ (0x20000000) /* R/W */
  364. #define GPIO_CFG_LED1_EN_ (0x10000000) /* R/W */
  365. #define GPIO_CFG_GPIO2_INT_POL_ (0x04000000) /* R/W */
  366. #define GPIO_CFG_GPIO1_INT_POL_ (0x02000000) /* R/W */
  367. #define GPIO_CFG_GPIO0_INT_POL_ (0x01000000) /* R/W */
  368. #define GPIO_CFG_EEPR_EN_ (0x00700000) /* R/W */
  369. #define GPIO_CFG_GPIOBUF2_ (0x00040000) /* R/W */
  370. #define GPIO_CFG_GPIOBUF1_ (0x00020000) /* R/W */
  371. #define GPIO_CFG_GPIOBUF0_ (0x00010000) /* R/W */
  372. #define GPIO_CFG_GPIODIR2_ (0x00000400) /* R/W */
  373. #define GPIO_CFG_GPIODIR1_ (0x00000200) /* R/W */
  374. #define GPIO_CFG_GPIODIR0_ (0x00000100) /* R/W */
  375. #define GPIO_CFG_GPIOD4_ (0x00000010) /* R/W */
  376. #define GPIO_CFG_GPIOD3_ (0x00000008) /* R/W */
  377. #define GPIO_CFG_GPIOD2_ (0x00000004) /* R/W */
  378. #define GPIO_CFG_GPIOD1_ (0x00000002) /* R/W */
  379. #define GPIO_CFG_GPIOD0_ (0x00000001) /* R/W */
  380. #define GPT_CFG (0x8C)
  381. #define GPT_CFG_TIMER_EN_ (0x20000000) /* R/W */
  382. #define GPT_CFG_GPT_LOAD_ (0x0000FFFF) /* R/W */
  383. #define GPT_CNT (0x90)
  384. #define GPT_CNT_GPT_CNT_ (0x0000FFFF) /* RO */
  385. #define ENDIAN (0x98)
  386. #define FREE_RUN (0x9C)
  387. #define RX_DROP (0xA0)
  388. #define MAC_CSR_CMD (0xA4)
  389. #define MAC_CSR_CMD_CSR_BUSY_ (0x80000000) /* Self Clearing */
  390. #define MAC_CSR_CMD_R_NOT_W_ (0x40000000) /* R/W */
  391. #define MAC_CSR_CMD_CSR_ADDR_ (0x000000FF) /* R/W */
  392. #define MAC_CSR_DATA (0xA8)
  393. #define AFC_CFG (0xAC)
  394. #define AFC_CFG_AFC_HI_ (0x00FF0000) /* R/W */
  395. #define AFC_CFG_AFC_LO_ (0x0000FF00) /* R/W */
  396. #define AFC_CFG_BACK_DUR_ (0x000000F0) /* R/W */
  397. #define AFC_CFG_FCMULT_ (0x00000008) /* R/W */
  398. #define AFC_CFG_FCBRD_ (0x00000004) /* R/W */
  399. #define AFC_CFG_FCADD_ (0x00000002) /* R/W */
  400. #define AFC_CFG_FCANY_ (0x00000001) /* R/W */
  401. #define E2P_CMD (0xB0)
  402. #define E2P_CMD_EPC_BUSY_ (0x80000000) /* Self Clearing */
  403. #define E2P_CMD_EPC_CMD_ (0x70000000) /* R/W */
  404. #define E2P_CMD_EPC_CMD_READ_ (0x00000000) /* R/W */
  405. #define E2P_CMD_EPC_CMD_EWDS_ (0x10000000) /* R/W */
  406. #define E2P_CMD_EPC_CMD_EWEN_ (0x20000000) /* R/W */
  407. #define E2P_CMD_EPC_CMD_WRITE_ (0x30000000) /* R/W */
  408. #define E2P_CMD_EPC_CMD_WRAL_ (0x40000000) /* R/W */
  409. #define E2P_CMD_EPC_CMD_ERASE_ (0x50000000) /* R/W */
  410. #define E2P_CMD_EPC_CMD_ERAL_ (0x60000000) /* R/W */
  411. #define E2P_CMD_EPC_CMD_RELOAD_ (0x70000000) /* R/W */
  412. #define E2P_CMD_EPC_TIMEOUT_ (0x00000200) /* RO */
  413. #define E2P_CMD_MAC_ADDR_LOADED_ (0x00000100) /* RO */
  414. #define E2P_CMD_EPC_ADDR_ (0x000000FF) /* R/W */
  415. #define E2P_DATA (0xB4)
  416. #define E2P_DATA_EEPROM_DATA_ (0x000000FF) /* R/W */
  417. /* end of LAN register offsets and bit definitions */
  418. /*
  419. ****************************************************************************
  420. ****************************************************************************
  421. * MAC Control and Status Register (Indirect Address)
  422. * Offset (through the MAC_CSR CMD and DATA port)
  423. ****************************************************************************
  424. ****************************************************************************
  425. *
  426. */
  427. #define MAC_CR (0x01) /* R/W */
  428. /* MAC_CR - MAC Control Register */
  429. #define MAC_CR_RXALL_ (0x80000000)
  430. // TODO: delete this bit? It is not described in the data sheet.
  431. #define MAC_CR_HBDIS_ (0x10000000)
  432. #define MAC_CR_RCVOWN_ (0x00800000)
  433. #define MAC_CR_LOOPBK_ (0x00200000)
  434. #define MAC_CR_FDPX_ (0x00100000)
  435. #define MAC_CR_MCPAS_ (0x00080000)
  436. #define MAC_CR_PRMS_ (0x00040000)
  437. #define MAC_CR_INVFILT_ (0x00020000)
  438. #define MAC_CR_PASSBAD_ (0x00010000)
  439. #define MAC_CR_HFILT_ (0x00008000)
  440. #define MAC_CR_HPFILT_ (0x00002000)
  441. #define MAC_CR_LCOLL_ (0x00001000)
  442. #define MAC_CR_BCAST_ (0x00000800)
  443. #define MAC_CR_DISRTY_ (0x00000400)
  444. #define MAC_CR_PADSTR_ (0x00000100)
  445. #define MAC_CR_BOLMT_MASK_ (0x000000C0)
  446. #define MAC_CR_DFCHK_ (0x00000020)
  447. #define MAC_CR_TXEN_ (0x00000008)
  448. #define MAC_CR_RXEN_ (0x00000004)
  449. #define ADDRH (0x02) /* R/W mask 0x0000FFFFUL */
  450. #define ADDRL (0x03) /* R/W mask 0xFFFFFFFFUL */
  451. #define HASHH (0x04) /* R/W */
  452. #define HASHL (0x05) /* R/W */
  453. #define MII_ACC (0x06) /* R/W */
  454. #define MII_ACC_PHY_ADDR_ (0x0000F800)
  455. #define MII_ACC_MIIRINDA_ (0x000007C0)
  456. #define MII_ACC_MII_WRITE_ (0x00000002)
  457. #define MII_ACC_MII_BUSY_ (0x00000001)
  458. #define MII_DATA (0x07) /* R/W mask 0x0000FFFFUL */
  459. #define FLOW (0x08) /* R/W */
  460. #define FLOW_FCPT_ (0xFFFF0000)
  461. #define FLOW_FCPASS_ (0x00000004)
  462. #define FLOW_FCEN_ (0x00000002)
  463. #define FLOW_FCBSY_ (0x00000001)
  464. #define VLAN1 (0x09) /* R/W mask 0x0000FFFFUL */
  465. #define VLAN1_VTI1_ (0x0000ffff)
  466. #define VLAN2 (0x0A) /* R/W mask 0x0000FFFFUL */
  467. #define VLAN2_VTI2_ (0x0000ffff)
  468. #define WUFF (0x0B) /* WO */
  469. #define WUCSR (0x0C) /* R/W */
  470. #define WUCSR_GUE_ (0x00000200)
  471. #define WUCSR_WUFR_ (0x00000040)
  472. #define WUCSR_MPR_ (0x00000020)
  473. #define WUCSR_WAKE_EN_ (0x00000004)
  474. #define WUCSR_MPEN_ (0x00000002)
  475. /*
  476. ****************************************************************************
  477. * Chip Specific MII Defines
  478. ****************************************************************************
  479. *
  480. * Phy register offsets and bit definitions
  481. *
  482. */
  483. #define PHY_MODE_CTRL_STS ((u32)17) /* Mode Control/Status Register */
  484. //#define MODE_CTRL_STS_FASTRIP_ ((u16)0x4000)
  485. #define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000)
  486. //#define MODE_CTRL_STS_LOWSQEN_ ((u16)0x0800)
  487. //#define MODE_CTRL_STS_MDPREBP_ ((u16)0x0400)
  488. //#define MODE_CTRL_STS_FARLOOPBACK_ ((u16)0x0200)
  489. //#define MODE_CTRL_STS_FASTEST_ ((u16)0x0100)
  490. //#define MODE_CTRL_STS_REFCLKEN_ ((u16)0x0010)
  491. //#define MODE_CTRL_STS_PHYADBP_ ((u16)0x0008)
  492. //#define MODE_CTRL_STS_FORCE_G_LINK_ ((u16)0x0004)
  493. #define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002)
  494. #define PHY_INT_SRC ((u32)29)
  495. #define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080)
  496. #define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040)
  497. #define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020)
  498. #define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010)
  499. #define PHY_INT_SRC_ANEG_LP_ACK_ ((u16)0x0008)
  500. #define PHY_INT_SRC_PAR_DET_FAULT_ ((u16)0x0004)
  501. #define PHY_INT_SRC_ANEG_PGRX_ ((u16)0x0002)
  502. #define PHY_INT_MASK ((u32)30)
  503. #define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080)
  504. #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
  505. #define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020)
  506. #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
  507. #define PHY_INT_MASK_ANEG_LP_ACK_ ((u16)0x0008)
  508. #define PHY_INT_MASK_PAR_DET_FAULT_ ((u16)0x0004)
  509. #define PHY_INT_MASK_ANEG_PGRX_ ((u16)0x0002)
  510. #define PHY_SPECIAL ((u32)31)
  511. #define PHY_SPECIAL_ANEG_DONE_ ((u16)0x1000)
  512. #define PHY_SPECIAL_RES_ ((u16)0x0040)
  513. #define PHY_SPECIAL_RES_MASK_ ((u16)0x0FE1)
  514. #define PHY_SPECIAL_SPD_ ((u16)0x001C)
  515. #define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004)
  516. #define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014)
  517. #define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008)
  518. #define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018)
  519. #define LAN911X_INTERNAL_PHY_ID (0x0007C000)
  520. /* Chip ID values */
  521. #define CHIP_9115 0x115
  522. #define CHIP_9116 0x116
  523. #define CHIP_9117 0x117
  524. #define CHIP_9118 0x118
  525. struct chip_id {
  526. u16 id;
  527. char *name;
  528. };
  529. static const struct chip_id chip_ids[] = {
  530. { CHIP_9115, "LAN9115" },
  531. { CHIP_9116, "LAN9116" },
  532. { CHIP_9117, "LAN9117" },
  533. { CHIP_9118, "LAN9118" },
  534. { 0, NULL },
  535. };
  536. #define IS_REV_A(x) ((x & 0xFFFF)==0)
  537. /*
  538. * Macros to abstract register access according to the data bus
  539. * capabilities. Please use those and not the in/out primitives.
  540. */
  541. /* FIFO read/write macros */
  542. #define SMC_PUSH_DATA(lp, p, l) SMC_outsl( lp, TX_DATA_FIFO, p, (l) >> 2 )
  543. #define SMC_PULL_DATA(lp, p, l) SMC_insl ( lp, RX_DATA_FIFO, p, (l) >> 2 )
  544. #define SMC_SET_TX_FIFO(lp, x) SMC_outl( x, lp, TX_DATA_FIFO )
  545. #define SMC_GET_RX_FIFO(lp) SMC_inl( lp, RX_DATA_FIFO )
  546. /* I/O mapped register read/write macros */
  547. #define SMC_GET_TX_STS_FIFO(lp) SMC_inl( lp, TX_STATUS_FIFO )
  548. #define SMC_GET_RX_STS_FIFO(lp) SMC_inl( lp, RX_STATUS_FIFO )
  549. #define SMC_GET_RX_STS_FIFO_PEEK(lp) SMC_inl( lp, RX_STATUS_FIFO_PEEK )
  550. #define SMC_GET_PN(lp) (SMC_inl( lp, ID_REV ) >> 16)
  551. #define SMC_GET_REV(lp) (SMC_inl( lp, ID_REV ) & 0xFFFF)
  552. #define SMC_GET_IRQ_CFG(lp) SMC_inl( lp, INT_CFG )
  553. #define SMC_SET_IRQ_CFG(lp, x) SMC_outl( x, lp, INT_CFG )
  554. #define SMC_GET_INT(lp) SMC_inl( lp, INT_STS )
  555. #define SMC_ACK_INT(lp, x) SMC_outl( x, lp, INT_STS )
  556. #define SMC_GET_INT_EN(lp) SMC_inl( lp, INT_EN )
  557. #define SMC_SET_INT_EN(lp, x) SMC_outl( x, lp, INT_EN )
  558. #define SMC_GET_BYTE_TEST(lp) SMC_inl( lp, BYTE_TEST )
  559. #define SMC_SET_BYTE_TEST(lp, x) SMC_outl( x, lp, BYTE_TEST )
  560. #define SMC_GET_FIFO_INT(lp) SMC_inl( lp, FIFO_INT )
  561. #define SMC_SET_FIFO_INT(lp, x) SMC_outl( x, lp, FIFO_INT )
  562. #define SMC_SET_FIFO_TDA(lp, x) \
  563. do { \
  564. unsigned long __flags; \
  565. int __mask; \
  566. local_irq_save(__flags); \
  567. __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<24); \
  568. SMC_SET_FIFO_INT( (lp), __mask | (x)<<24 ); \
  569. local_irq_restore(__flags); \
  570. } while (0)
  571. #define SMC_SET_FIFO_TSL(lp, x) \
  572. do { \
  573. unsigned long __flags; \
  574. int __mask; \
  575. local_irq_save(__flags); \
  576. __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<16); \
  577. SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<16)); \
  578. local_irq_restore(__flags); \
  579. } while (0)
  580. #define SMC_SET_FIFO_RSA(lp, x) \
  581. do { \
  582. unsigned long __flags; \
  583. int __mask; \
  584. local_irq_save(__flags); \
  585. __mask = SMC_GET_FIFO_INT((lp)) & ~(0xFF<<8); \
  586. SMC_SET_FIFO_INT( (lp), __mask | (((x) & 0xFF)<<8)); \
  587. local_irq_restore(__flags); \
  588. } while (0)
  589. #define SMC_SET_FIFO_RSL(lp, x) \
  590. do { \
  591. unsigned long __flags; \
  592. int __mask; \
  593. local_irq_save(__flags); \
  594. __mask = SMC_GET_FIFO_INT((lp)) & ~0xFF; \
  595. SMC_SET_FIFO_INT( (lp),__mask | ((x) & 0xFF)); \
  596. local_irq_restore(__flags); \
  597. } while (0)
  598. #define SMC_GET_RX_CFG(lp) SMC_inl( lp, RX_CFG )
  599. #define SMC_SET_RX_CFG(lp, x) SMC_outl( x, lp, RX_CFG )
  600. #define SMC_GET_TX_CFG(lp) SMC_inl( lp, TX_CFG )
  601. #define SMC_SET_TX_CFG(lp, x) SMC_outl( x, lp, TX_CFG )
  602. #define SMC_GET_HW_CFG(lp) SMC_inl( lp, HW_CFG )
  603. #define SMC_SET_HW_CFG(lp, x) SMC_outl( x, lp, HW_CFG )
  604. #define SMC_GET_RX_DP_CTRL(lp) SMC_inl( lp, RX_DP_CTRL )
  605. #define SMC_SET_RX_DP_CTRL(lp, x) SMC_outl( x, lp, RX_DP_CTRL )
  606. #define SMC_GET_PMT_CTRL(lp) SMC_inl( lp, PMT_CTRL )
  607. #define SMC_SET_PMT_CTRL(lp, x) SMC_outl( x, lp, PMT_CTRL )
  608. #define SMC_GET_GPIO_CFG(lp) SMC_inl( lp, GPIO_CFG )
  609. #define SMC_SET_GPIO_CFG(lp, x) SMC_outl( x, lp, GPIO_CFG )
  610. #define SMC_GET_RX_FIFO_INF(lp) SMC_inl( lp, RX_FIFO_INF )
  611. #define SMC_SET_RX_FIFO_INF(lp, x) SMC_outl( x, lp, RX_FIFO_INF )
  612. #define SMC_GET_TX_FIFO_INF(lp) SMC_inl( lp, TX_FIFO_INF )
  613. #define SMC_SET_TX_FIFO_INF(lp, x) SMC_outl( x, lp, TX_FIFO_INF )
  614. #define SMC_GET_GPT_CFG(lp) SMC_inl( lp, GPT_CFG )
  615. #define SMC_SET_GPT_CFG(lp, x) SMC_outl( x, lp, GPT_CFG )
  616. #define SMC_GET_RX_DROP(lp) SMC_inl( lp, RX_DROP )
  617. #define SMC_SET_RX_DROP(lp, x) SMC_outl( x, lp, RX_DROP )
  618. #define SMC_GET_MAC_CMD(lp) SMC_inl( lp, MAC_CSR_CMD )
  619. #define SMC_SET_MAC_CMD(lp, x) SMC_outl( x, lp, MAC_CSR_CMD )
  620. #define SMC_GET_MAC_DATA(lp) SMC_inl( lp, MAC_CSR_DATA )
  621. #define SMC_SET_MAC_DATA(lp, x) SMC_outl( x, lp, MAC_CSR_DATA )
  622. #define SMC_GET_AFC_CFG(lp) SMC_inl( lp, AFC_CFG )
  623. #define SMC_SET_AFC_CFG(lp, x) SMC_outl( x, lp, AFC_CFG )
  624. #define SMC_GET_E2P_CMD(lp) SMC_inl( lp, E2P_CMD )
  625. #define SMC_SET_E2P_CMD(lp, x) SMC_outl( x, lp, E2P_CMD )
  626. #define SMC_GET_E2P_DATA(lp) SMC_inl( lp, E2P_DATA )
  627. #define SMC_SET_E2P_DATA(lp, x) SMC_outl( x, lp, E2P_DATA )
  628. /* MAC register read/write macros */
  629. #define SMC_GET_MAC_CSR(lp,a,v) \
  630. do { \
  631. while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  632. SMC_SET_MAC_CMD((lp),MAC_CSR_CMD_CSR_BUSY_ | \
  633. MAC_CSR_CMD_R_NOT_W_ | (a) ); \
  634. while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  635. v = SMC_GET_MAC_DATA((lp)); \
  636. } while (0)
  637. #define SMC_SET_MAC_CSR(lp,a,v) \
  638. do { \
  639. while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  640. SMC_SET_MAC_DATA((lp), v); \
  641. SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_CSR_BUSY_ | (a) ); \
  642. while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  643. } while (0)
  644. #define SMC_GET_MAC_CR(lp, x) SMC_GET_MAC_CSR( (lp), MAC_CR, x )
  645. #define SMC_SET_MAC_CR(lp, x) SMC_SET_MAC_CSR( (lp), MAC_CR, x )
  646. #define SMC_GET_ADDRH(lp, x) SMC_GET_MAC_CSR( (lp), ADDRH, x )
  647. #define SMC_SET_ADDRH(lp, x) SMC_SET_MAC_CSR( (lp), ADDRH, x )
  648. #define SMC_GET_ADDRL(lp, x) SMC_GET_MAC_CSR( (lp), ADDRL, x )
  649. #define SMC_SET_ADDRL(lp, x) SMC_SET_MAC_CSR( (lp), ADDRL, x )
  650. #define SMC_GET_HASHH(lp, x) SMC_GET_MAC_CSR( (lp), HASHH, x )
  651. #define SMC_SET_HASHH(lp, x) SMC_SET_MAC_CSR( (lp), HASHH, x )
  652. #define SMC_GET_HASHL(lp, x) SMC_GET_MAC_CSR( (lp), HASHL, x )
  653. #define SMC_SET_HASHL(lp, x) SMC_SET_MAC_CSR( (lp), HASHL, x )
  654. #define SMC_GET_MII_ACC(lp, x) SMC_GET_MAC_CSR( (lp), MII_ACC, x )
  655. #define SMC_SET_MII_ACC(lp, x) SMC_SET_MAC_CSR( (lp), MII_ACC, x )
  656. #define SMC_GET_MII_DATA(lp, x) SMC_GET_MAC_CSR( (lp), MII_DATA, x )
  657. #define SMC_SET_MII_DATA(lp, x) SMC_SET_MAC_CSR( (lp), MII_DATA, x )
  658. #define SMC_GET_FLOW(lp, x) SMC_GET_MAC_CSR( (lp), FLOW, x )
  659. #define SMC_SET_FLOW(lp, x) SMC_SET_MAC_CSR( (lp), FLOW, x )
  660. #define SMC_GET_VLAN1(lp, x) SMC_GET_MAC_CSR( (lp), VLAN1, x )
  661. #define SMC_SET_VLAN1(lp, x) SMC_SET_MAC_CSR( (lp), VLAN1, x )
  662. #define SMC_GET_VLAN2(lp, x) SMC_GET_MAC_CSR( (lp), VLAN2, x )
  663. #define SMC_SET_VLAN2(lp, x) SMC_SET_MAC_CSR( (lp), VLAN2, x )
  664. #define SMC_SET_WUFF(lp, x) SMC_SET_MAC_CSR( (lp), WUFF, x )
  665. #define SMC_GET_WUCSR(lp, x) SMC_GET_MAC_CSR( (lp), WUCSR, x )
  666. #define SMC_SET_WUCSR(lp, x) SMC_SET_MAC_CSR( (lp), WUCSR, x )
  667. /* PHY register read/write macros */
  668. #define SMC_GET_MII(lp,a,phy,v) \
  669. do { \
  670. u32 __v; \
  671. do { \
  672. SMC_GET_MII_ACC((lp), __v); \
  673. } while ( __v & MII_ACC_MII_BUSY_ ); \
  674. SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
  675. MII_ACC_MII_BUSY_); \
  676. do { \
  677. SMC_GET_MII_ACC( (lp), __v); \
  678. } while ( __v & MII_ACC_MII_BUSY_ ); \
  679. SMC_GET_MII_DATA((lp), v); \
  680. } while (0)
  681. #define SMC_SET_MII(lp,a,phy,v) \
  682. do { \
  683. u32 __v; \
  684. do { \
  685. SMC_GET_MII_ACC((lp), __v); \
  686. } while ( __v & MII_ACC_MII_BUSY_ ); \
  687. SMC_SET_MII_DATA((lp), v); \
  688. SMC_SET_MII_ACC( (lp), ((phy)<<11) | ((a)<<6) | \
  689. MII_ACC_MII_BUSY_ | \
  690. MII_ACC_MII_WRITE_ ); \
  691. do { \
  692. SMC_GET_MII_ACC((lp), __v); \
  693. } while ( __v & MII_ACC_MII_BUSY_ ); \
  694. } while (0)
  695. #define SMC_GET_PHY_BMCR(lp,phy,x) SMC_GET_MII( (lp), MII_BMCR, phy, x )
  696. #define SMC_SET_PHY_BMCR(lp,phy,x) SMC_SET_MII( (lp), MII_BMCR, phy, x )
  697. #define SMC_GET_PHY_BMSR(lp,phy,x) SMC_GET_MII( (lp), MII_BMSR, phy, x )
  698. #define SMC_GET_PHY_ID1(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID1, phy, x )
  699. #define SMC_GET_PHY_ID2(lp,phy,x) SMC_GET_MII( (lp), MII_PHYSID2, phy, x )
  700. #define SMC_GET_PHY_MII_ADV(lp,phy,x) SMC_GET_MII( (lp), MII_ADVERTISE, phy, x )
  701. #define SMC_SET_PHY_MII_ADV(lp,phy,x) SMC_SET_MII( (lp), MII_ADVERTISE, phy, x )
  702. #define SMC_GET_PHY_MII_LPA(lp,phy,x) SMC_GET_MII( (lp), MII_LPA, phy, x )
  703. #define SMC_SET_PHY_MII_LPA(lp,phy,x) SMC_SET_MII( (lp), MII_LPA, phy, x )
  704. #define SMC_GET_PHY_CTRL_STS(lp,phy,x) SMC_GET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
  705. #define SMC_SET_PHY_CTRL_STS(lp,phy,x) SMC_SET_MII( (lp), PHY_MODE_CTRL_STS, phy, x )
  706. #define SMC_GET_PHY_INT_SRC(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_SRC, phy, x )
  707. #define SMC_SET_PHY_INT_SRC(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_SRC, phy, x )
  708. #define SMC_GET_PHY_INT_MASK(lp,phy,x) SMC_GET_MII( (lp), PHY_INT_MASK, phy, x )
  709. #define SMC_SET_PHY_INT_MASK(lp,phy,x) SMC_SET_MII( (lp), PHY_INT_MASK, phy, x )
  710. #define SMC_GET_PHY_SPECIAL(lp,phy,x) SMC_GET_MII( (lp), PHY_SPECIAL, phy, x )
  711. /* Misc read/write macros */
  712. #ifndef SMC_GET_MAC_ADDR
  713. #define SMC_GET_MAC_ADDR(lp, addr) \
  714. do { \
  715. unsigned int __v; \
  716. \
  717. SMC_GET_MAC_CSR((lp), ADDRL, __v); \
  718. addr[0] = __v; addr[1] = __v >> 8; \
  719. addr[2] = __v >> 16; addr[3] = __v >> 24; \
  720. SMC_GET_MAC_CSR((lp), ADDRH, __v); \
  721. addr[4] = __v; addr[5] = __v >> 8; \
  722. } while (0)
  723. #endif
  724. #define SMC_SET_MAC_ADDR(lp, addr) \
  725. do { \
  726. SMC_SET_MAC_CSR((lp), ADDRL, \
  727. addr[0] | \
  728. (addr[1] << 8) | \
  729. (addr[2] << 16) | \
  730. (addr[3] << 24)); \
  731. SMC_SET_MAC_CSR((lp), ADDRH, addr[4]|(addr[5] << 8));\
  732. } while (0)
  733. #define SMC_WRITE_EEPROM_CMD(lp, cmd, addr) \
  734. do { \
  735. while (SMC_GET_E2P_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  736. SMC_SET_MAC_CMD((lp), MAC_CSR_CMD_R_NOT_W_ | a ); \
  737. while (SMC_GET_MAC_CMD((lp)) & MAC_CSR_CMD_CSR_BUSY_); \
  738. } while (0)
  739. #endif /* _SMC911X_H_ */