media.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. drivers/net/ethernet/dec/tulip/media.c
  3. Copyright 2000,2001 The Linux Kernel Team
  4. Written/copyright 1994-2001 by Donald Becker.
  5. This software may be used and distributed according to the terms
  6. of the GNU General Public License, incorporated herein by reference.
  7. Please submit bugs to http://bugzilla.kernel.org/ .
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/mii.h>
  11. #include <linux/delay.h>
  12. #include <linux/pci.h>
  13. #include "tulip.h"
  14. /* The maximum data clock rate is 2.5 Mhz. The minimum timing is usually
  15. met by back-to-back PCI I/O cycles, but we insert a delay to avoid
  16. "overclocking" issues or future 66Mhz PCI. */
  17. #define mdio_delay() ioread32(mdio_addr)
  18. /* Read and write the MII registers using software-generated serial
  19. MDIO protocol. It is just different enough from the EEPROM protocol
  20. to not share code. The maxium data clock rate is 2.5 Mhz. */
  21. #define MDIO_SHIFT_CLK 0x10000
  22. #define MDIO_DATA_WRITE0 0x00000
  23. #define MDIO_DATA_WRITE1 0x20000
  24. #define MDIO_ENB 0x00000 /* Ignore the 0x02000 databook setting. */
  25. #define MDIO_ENB_IN 0x40000
  26. #define MDIO_DATA_READ 0x80000
  27. static const unsigned char comet_miireg2offset[32] = {
  28. 0xB4, 0xB8, 0xBC, 0xC0, 0xC4, 0xC8, 0xCC, 0, 0,0,0,0, 0,0,0,0,
  29. 0,0xD0,0,0, 0,0,0,0, 0,0,0,0, 0, 0xD4, 0xD8, 0xDC, };
  30. /* MII transceiver control section.
  31. Read and write the MII registers using software-generated serial
  32. MDIO protocol.
  33. See IEEE 802.3-2002.pdf (Section 2, Chapter "22.2.4 Management functions")
  34. or DP83840A data sheet for more details.
  35. */
  36. int tulip_mdio_read(struct net_device *dev, int phy_id, int location)
  37. {
  38. struct tulip_private *tp = netdev_priv(dev);
  39. int i;
  40. int read_cmd = (0xf6 << 10) | ((phy_id & 0x1f) << 5) | location;
  41. int retval = 0;
  42. void __iomem *ioaddr = tp->base_addr;
  43. void __iomem *mdio_addr = ioaddr + CSR9;
  44. unsigned long flags;
  45. if (location & ~0x1f)
  46. return 0xffff;
  47. if (tp->chip_id == COMET && phy_id == 30) {
  48. if (comet_miireg2offset[location])
  49. return ioread32(ioaddr + comet_miireg2offset[location]);
  50. return 0xffff;
  51. }
  52. spin_lock_irqsave(&tp->mii_lock, flags);
  53. if (tp->chip_id == LC82C168) {
  54. iowrite32(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
  55. ioread32(ioaddr + 0xA0);
  56. ioread32(ioaddr + 0xA0);
  57. for (i = 1000; i >= 0; --i) {
  58. barrier();
  59. if ( ! ((retval = ioread32(ioaddr + 0xA0)) & 0x80000000))
  60. break;
  61. }
  62. spin_unlock_irqrestore(&tp->mii_lock, flags);
  63. return retval & 0xffff;
  64. }
  65. /* Establish sync by sending at least 32 logic ones. */
  66. for (i = 32; i >= 0; i--) {
  67. iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
  68. mdio_delay();
  69. iowrite32(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
  70. mdio_delay();
  71. }
  72. /* Shift the read command bits out. */
  73. for (i = 15; i >= 0; i--) {
  74. int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
  75. iowrite32(MDIO_ENB | dataval, mdio_addr);
  76. mdio_delay();
  77. iowrite32(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
  78. mdio_delay();
  79. }
  80. /* Read the two transition, 16 data, and wire-idle bits. */
  81. for (i = 19; i > 0; i--) {
  82. iowrite32(MDIO_ENB_IN, mdio_addr);
  83. mdio_delay();
  84. retval = (retval << 1) | ((ioread32(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
  85. iowrite32(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
  86. mdio_delay();
  87. }
  88. spin_unlock_irqrestore(&tp->mii_lock, flags);
  89. return (retval>>1) & 0xffff;
  90. }
  91. void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val)
  92. {
  93. struct tulip_private *tp = netdev_priv(dev);
  94. int i;
  95. int cmd = (0x5002 << 16) | ((phy_id & 0x1f) << 23) | (location<<18) | (val & 0xffff);
  96. void __iomem *ioaddr = tp->base_addr;
  97. void __iomem *mdio_addr = ioaddr + CSR9;
  98. unsigned long flags;
  99. if (location & ~0x1f)
  100. return;
  101. if (tp->chip_id == COMET && phy_id == 30) {
  102. if (comet_miireg2offset[location])
  103. iowrite32(val, ioaddr + comet_miireg2offset[location]);
  104. return;
  105. }
  106. spin_lock_irqsave(&tp->mii_lock, flags);
  107. if (tp->chip_id == LC82C168) {
  108. iowrite32(cmd, ioaddr + 0xA0);
  109. for (i = 1000; i >= 0; --i) {
  110. barrier();
  111. if ( ! (ioread32(ioaddr + 0xA0) & 0x80000000))
  112. break;
  113. }
  114. spin_unlock_irqrestore(&tp->mii_lock, flags);
  115. return;
  116. }
  117. /* Establish sync by sending 32 logic ones. */
  118. for (i = 32; i >= 0; i--) {
  119. iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
  120. mdio_delay();
  121. iowrite32(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
  122. mdio_delay();
  123. }
  124. /* Shift the command bits out. */
  125. for (i = 31; i >= 0; i--) {
  126. int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
  127. iowrite32(MDIO_ENB | dataval, mdio_addr);
  128. mdio_delay();
  129. iowrite32(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
  130. mdio_delay();
  131. }
  132. /* Clear out extra bits. */
  133. for (i = 2; i > 0; i--) {
  134. iowrite32(MDIO_ENB_IN, mdio_addr);
  135. mdio_delay();
  136. iowrite32(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
  137. mdio_delay();
  138. }
  139. spin_unlock_irqrestore(&tp->mii_lock, flags);
  140. }
  141. /* Set up the transceiver control registers for the selected media type. */
  142. void tulip_select_media(struct net_device *dev, int startup)
  143. {
  144. struct tulip_private *tp = netdev_priv(dev);
  145. void __iomem *ioaddr = tp->base_addr;
  146. struct mediatable *mtable = tp->mtable;
  147. u32 new_csr6;
  148. int i;
  149. if (mtable) {
  150. struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
  151. unsigned char *p = mleaf->leafdata;
  152. switch (mleaf->type) {
  153. case 0: /* 21140 non-MII xcvr. */
  154. if (tulip_debug > 1)
  155. netdev_dbg(dev, "Using a 21140 non-MII transceiver with control setting %02x\n",
  156. p[1]);
  157. dev->if_port = p[0];
  158. if (startup)
  159. iowrite32(mtable->csr12dir | 0x100, ioaddr + CSR12);
  160. iowrite32(p[1], ioaddr + CSR12);
  161. new_csr6 = 0x02000000 | ((p[2] & 0x71) << 18);
  162. break;
  163. case 2: case 4: {
  164. u16 setup[5];
  165. u32 csr13val, csr14val, csr15dir, csr15val;
  166. for (i = 0; i < 5; i++)
  167. setup[i] = get_u16(&p[i*2 + 1]);
  168. dev->if_port = p[0] & MEDIA_MASK;
  169. if (tulip_media_cap[dev->if_port] & MediaAlwaysFD)
  170. tp->full_duplex = 1;
  171. if (startup && mtable->has_reset) {
  172. struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
  173. unsigned char *rst = rleaf->leafdata;
  174. if (tulip_debug > 1)
  175. netdev_dbg(dev, "Resetting the transceiver\n");
  176. for (i = 0; i < rst[0]; i++)
  177. iowrite32(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
  178. }
  179. if (tulip_debug > 1)
  180. netdev_dbg(dev, "21143 non-MII %s transceiver control %04x/%04x\n",
  181. medianame[dev->if_port],
  182. setup[0], setup[1]);
  183. if (p[0] & 0x40) { /* SIA (CSR13-15) setup values are provided. */
  184. csr13val = setup[0];
  185. csr14val = setup[1];
  186. csr15dir = (setup[3]<<16) | setup[2];
  187. csr15val = (setup[4]<<16) | setup[2];
  188. iowrite32(0, ioaddr + CSR13);
  189. iowrite32(csr14val, ioaddr + CSR14);
  190. iowrite32(csr15dir, ioaddr + CSR15); /* Direction */
  191. iowrite32(csr15val, ioaddr + CSR15); /* Data */
  192. iowrite32(csr13val, ioaddr + CSR13);
  193. } else {
  194. csr13val = 1;
  195. csr14val = 0;
  196. csr15dir = (setup[0]<<16) | 0x0008;
  197. csr15val = (setup[1]<<16) | 0x0008;
  198. if (dev->if_port <= 4)
  199. csr14val = t21142_csr14[dev->if_port];
  200. if (startup) {
  201. iowrite32(0, ioaddr + CSR13);
  202. iowrite32(csr14val, ioaddr + CSR14);
  203. }
  204. iowrite32(csr15dir, ioaddr + CSR15); /* Direction */
  205. iowrite32(csr15val, ioaddr + CSR15); /* Data */
  206. if (startup) iowrite32(csr13val, ioaddr + CSR13);
  207. }
  208. if (tulip_debug > 1)
  209. netdev_dbg(dev, "Setting CSR15 to %08x/%08x\n",
  210. csr15dir, csr15val);
  211. if (mleaf->type == 4)
  212. new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
  213. else
  214. new_csr6 = 0x82420000;
  215. break;
  216. }
  217. case 1: case 3: {
  218. int phy_num = p[0];
  219. int init_length = p[1];
  220. u16 *misc_info, tmp_info;
  221. dev->if_port = 11;
  222. new_csr6 = 0x020E0000;
  223. if (mleaf->type == 3) { /* 21142 */
  224. u16 *init_sequence = (u16*)(p+2);
  225. u16 *reset_sequence = &((u16*)(p+3))[init_length];
  226. int reset_length = p[2 + init_length*2];
  227. misc_info = reset_sequence + reset_length;
  228. if (startup) {
  229. int timeout = 10; /* max 1 ms */
  230. for (i = 0; i < reset_length; i++)
  231. iowrite32(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
  232. /* flush posted writes */
  233. ioread32(ioaddr + CSR15);
  234. /* Sect 3.10.3 in DP83840A.pdf (p39) */
  235. udelay(500);
  236. /* Section 4.2 in DP83840A.pdf (p43) */
  237. /* and IEEE 802.3 "22.2.4.1.1 Reset" */
  238. while (timeout-- &&
  239. (tulip_mdio_read (dev, phy_num, MII_BMCR) & BMCR_RESET))
  240. udelay(100);
  241. }
  242. for (i = 0; i < init_length; i++)
  243. iowrite32(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
  244. ioread32(ioaddr + CSR15); /* flush posted writes */
  245. } else {
  246. u8 *init_sequence = p + 2;
  247. u8 *reset_sequence = p + 3 + init_length;
  248. int reset_length = p[2 + init_length];
  249. misc_info = (u16*)(reset_sequence + reset_length);
  250. if (startup) {
  251. int timeout = 10; /* max 1 ms */
  252. iowrite32(mtable->csr12dir | 0x100, ioaddr + CSR12);
  253. for (i = 0; i < reset_length; i++)
  254. iowrite32(reset_sequence[i], ioaddr + CSR12);
  255. /* flush posted writes */
  256. ioread32(ioaddr + CSR12);
  257. /* Sect 3.10.3 in DP83840A.pdf (p39) */
  258. udelay(500);
  259. /* Section 4.2 in DP83840A.pdf (p43) */
  260. /* and IEEE 802.3 "22.2.4.1.1 Reset" */
  261. while (timeout-- &&
  262. (tulip_mdio_read (dev, phy_num, MII_BMCR) & BMCR_RESET))
  263. udelay(100);
  264. }
  265. for (i = 0; i < init_length; i++)
  266. iowrite32(init_sequence[i], ioaddr + CSR12);
  267. ioread32(ioaddr + CSR12); /* flush posted writes */
  268. }
  269. tmp_info = get_u16(&misc_info[1]);
  270. if (tmp_info)
  271. tp->advertising[phy_num] = tmp_info | 1;
  272. if (tmp_info && startup < 2) {
  273. if (tp->mii_advertise == 0)
  274. tp->mii_advertise = tp->advertising[phy_num];
  275. if (tulip_debug > 1)
  276. netdev_dbg(dev, " Advertising %04x on MII %d\n",
  277. tp->mii_advertise,
  278. tp->phys[phy_num]);
  279. tulip_mdio_write(dev, tp->phys[phy_num], 4, tp->mii_advertise);
  280. }
  281. break;
  282. }
  283. case 5: case 6: {
  284. u16 setup[5];
  285. new_csr6 = 0; /* FIXME */
  286. for (i = 0; i < 5; i++)
  287. setup[i] = get_u16(&p[i*2 + 1]);
  288. if (startup && mtable->has_reset) {
  289. struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
  290. unsigned char *rst = rleaf->leafdata;
  291. if (tulip_debug > 1)
  292. netdev_dbg(dev, "Resetting the transceiver\n");
  293. for (i = 0; i < rst[0]; i++)
  294. iowrite32(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
  295. }
  296. break;
  297. }
  298. default:
  299. netdev_dbg(dev, " Invalid media table selection %d\n",
  300. mleaf->type);
  301. new_csr6 = 0x020E0000;
  302. }
  303. if (tulip_debug > 1)
  304. netdev_dbg(dev, "Using media type %s, CSR12 is %02x\n",
  305. medianame[dev->if_port],
  306. ioread32(ioaddr + CSR12) & 0xff);
  307. } else if (tp->chip_id == LC82C168) {
  308. if (startup && ! tp->medialock)
  309. dev->if_port = tp->mii_cnt ? 11 : 0;
  310. if (tulip_debug > 1)
  311. netdev_dbg(dev, "PNIC PHY status is %3.3x, media %s\n",
  312. ioread32(ioaddr + 0xB8),
  313. medianame[dev->if_port]);
  314. if (tp->mii_cnt) {
  315. new_csr6 = 0x810C0000;
  316. iowrite32(0x0001, ioaddr + CSR15);
  317. iowrite32(0x0201B07A, ioaddr + 0xB8);
  318. } else if (startup) {
  319. /* Start with 10mbps to do autonegotiation. */
  320. iowrite32(0x32, ioaddr + CSR12);
  321. new_csr6 = 0x00420000;
  322. iowrite32(0x0001B078, ioaddr + 0xB8);
  323. iowrite32(0x0201B078, ioaddr + 0xB8);
  324. } else if (dev->if_port == 3 || dev->if_port == 5) {
  325. iowrite32(0x33, ioaddr + CSR12);
  326. new_csr6 = 0x01860000;
  327. /* Trigger autonegotiation. */
  328. iowrite32(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
  329. } else {
  330. iowrite32(0x32, ioaddr + CSR12);
  331. new_csr6 = 0x00420000;
  332. iowrite32(0x1F078, ioaddr + 0xB8);
  333. }
  334. } else { /* Unknown chip type with no media table. */
  335. if (tp->default_port == 0)
  336. dev->if_port = tp->mii_cnt ? 11 : 3;
  337. if (tulip_media_cap[dev->if_port] & MediaIsMII) {
  338. new_csr6 = 0x020E0000;
  339. } else if (tulip_media_cap[dev->if_port] & MediaIsFx) {
  340. new_csr6 = 0x02860000;
  341. } else
  342. new_csr6 = 0x03860000;
  343. if (tulip_debug > 1)
  344. netdev_dbg(dev, "No media description table, assuming %s transceiver, CSR12 %02x\n",
  345. medianame[dev->if_port],
  346. ioread32(ioaddr + CSR12));
  347. }
  348. tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
  349. mdelay(1);
  350. }
  351. /*
  352. Check the MII negotiated duplex and change the CSR6 setting if
  353. required.
  354. Return 0 if everything is OK.
  355. Return < 0 if the transceiver is missing or has no link beat.
  356. */
  357. int tulip_check_duplex(struct net_device *dev)
  358. {
  359. struct tulip_private *tp = netdev_priv(dev);
  360. unsigned int bmsr, lpa, negotiated, new_csr6;
  361. bmsr = tulip_mdio_read(dev, tp->phys[0], MII_BMSR);
  362. lpa = tulip_mdio_read(dev, tp->phys[0], MII_LPA);
  363. if (tulip_debug > 1)
  364. dev_info(&dev->dev, "MII status %04x, Link partner report %04x\n",
  365. bmsr, lpa);
  366. if (bmsr == 0xffff)
  367. return -2;
  368. if ((bmsr & BMSR_LSTATUS) == 0) {
  369. int new_bmsr = tulip_mdio_read(dev, tp->phys[0], MII_BMSR);
  370. if ((new_bmsr & BMSR_LSTATUS) == 0) {
  371. if (tulip_debug > 1)
  372. dev_info(&dev->dev,
  373. "No link beat on the MII interface, status %04x\n",
  374. new_bmsr);
  375. return -1;
  376. }
  377. }
  378. negotiated = lpa & tp->advertising[0];
  379. tp->full_duplex = mii_duplex(tp->full_duplex_lock, negotiated);
  380. new_csr6 = tp->csr6;
  381. if (negotiated & LPA_100) new_csr6 &= ~TxThreshold;
  382. else new_csr6 |= TxThreshold;
  383. if (tp->full_duplex) new_csr6 |= FullDuplex;
  384. else new_csr6 &= ~FullDuplex;
  385. if (new_csr6 != tp->csr6) {
  386. tp->csr6 = new_csr6;
  387. tulip_restart_rxtx(tp);
  388. if (tulip_debug > 0)
  389. dev_info(&dev->dev,
  390. "Setting %s-duplex based on MII#%d link partner capability of %04x\n",
  391. tp->full_duplex ? "full" : "half",
  392. tp->phys[0], lpa);
  393. return 1;
  394. }
  395. return 0;
  396. }
  397. void tulip_find_mii(struct net_device *dev, int board_idx)
  398. {
  399. struct tulip_private *tp = netdev_priv(dev);
  400. int phyn, phy_idx = 0;
  401. int mii_reg0;
  402. int mii_advert;
  403. unsigned int to_advert, new_bmcr, ane_switch;
  404. /* Find the connected MII xcvrs.
  405. Doing this in open() would allow detecting external xcvrs later,
  406. but takes much time. */
  407. for (phyn = 1; phyn <= 32 && phy_idx < ARRAY_SIZE(tp->phys); phyn++) {
  408. int phy = phyn & 0x1f;
  409. int mii_status = tulip_mdio_read (dev, phy, MII_BMSR);
  410. if ((mii_status & 0x8301) == 0x8001 ||
  411. ((mii_status & BMSR_100BASE4) == 0 &&
  412. (mii_status & 0x7800) != 0)) {
  413. /* preserve Becker logic, gain indentation level */
  414. } else {
  415. continue;
  416. }
  417. mii_reg0 = tulip_mdio_read (dev, phy, MII_BMCR);
  418. mii_advert = tulip_mdio_read (dev, phy, MII_ADVERTISE);
  419. ane_switch = 0;
  420. /* if not advertising at all, gen an
  421. * advertising value from the capability
  422. * bits in BMSR
  423. */
  424. if ((mii_advert & ADVERTISE_ALL) == 0) {
  425. unsigned int tmpadv = tulip_mdio_read (dev, phy, MII_BMSR);
  426. mii_advert = ((tmpadv >> 6) & 0x3e0) | 1;
  427. }
  428. if (tp->mii_advertise) {
  429. tp->advertising[phy_idx] =
  430. to_advert = tp->mii_advertise;
  431. } else if (tp->advertising[phy_idx]) {
  432. to_advert = tp->advertising[phy_idx];
  433. } else {
  434. tp->advertising[phy_idx] =
  435. tp->mii_advertise =
  436. to_advert = mii_advert;
  437. }
  438. tp->phys[phy_idx++] = phy;
  439. pr_info("tulip%d: MII transceiver #%d config %04x status %04x advertising %04x\n",
  440. board_idx, phy, mii_reg0, mii_status, mii_advert);
  441. /* Fixup for DLink with miswired PHY. */
  442. if (mii_advert != to_advert) {
  443. pr_debug("tulip%d: Advertising %04x on PHY %d, previously advertising %04x\n",
  444. board_idx, to_advert, phy, mii_advert);
  445. tulip_mdio_write (dev, phy, 4, to_advert);
  446. }
  447. /* Enable autonegotiation: some boards default to off. */
  448. if (tp->default_port == 0) {
  449. new_bmcr = mii_reg0 | BMCR_ANENABLE;
  450. if (new_bmcr != mii_reg0) {
  451. new_bmcr |= BMCR_ANRESTART;
  452. ane_switch = 1;
  453. }
  454. }
  455. /* ...or disable nway, if forcing media */
  456. else {
  457. new_bmcr = mii_reg0 & ~BMCR_ANENABLE;
  458. if (new_bmcr != mii_reg0)
  459. ane_switch = 1;
  460. }
  461. /* clear out bits we never want at this point */
  462. new_bmcr &= ~(BMCR_CTST | BMCR_FULLDPLX | BMCR_ISOLATE |
  463. BMCR_PDOWN | BMCR_SPEED100 | BMCR_LOOPBACK |
  464. BMCR_RESET);
  465. if (tp->full_duplex)
  466. new_bmcr |= BMCR_FULLDPLX;
  467. if (tulip_media_cap[tp->default_port] & MediaIs100)
  468. new_bmcr |= BMCR_SPEED100;
  469. if (new_bmcr != mii_reg0) {
  470. /* some phys need the ANE switch to
  471. * happen before forced media settings
  472. * will "take." However, we write the
  473. * same value twice in order not to
  474. * confuse the sane phys.
  475. */
  476. if (ane_switch) {
  477. tulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);
  478. udelay (10);
  479. }
  480. tulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);
  481. }
  482. }
  483. tp->mii_cnt = phy_idx;
  484. if (tp->mtable && tp->mtable->has_mii && phy_idx == 0) {
  485. pr_info("tulip%d: ***WARNING***: No MII transceiver found!\n",
  486. board_idx);
  487. tp->phys[0] = 1;
  488. }
  489. }