Deleted Added
full compact
cxgb_vsc8211.c (176472) cxgb_vsc8211.c (180583)
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/common/cxgb_vsc8211.c 176472 2008-02-23 01:06:17Z kmacy $");
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/common/cxgb_vsc8211.c 180583 2008-07-18 06:12:31Z kmacy $");
32
33#ifdef CONFIG_DEFINED
34#include <cxgb_include.h>
35#else
36#include <dev/cxgb/cxgb_include.h>
37#endif
38
39#undef msleep
40#define msleep t3_os_sleep
41
42/* VSC8211 PHY specific registers. */
43enum {
44 VSC8211_SIGDET_CTRL = 19,
45 VSC8211_EXT_CTRL = 23,
46 VSC8211_INTR_ENABLE = 25,
47 VSC8211_INTR_STATUS = 26,
32
33#ifdef CONFIG_DEFINED
34#include <cxgb_include.h>
35#else
36#include <dev/cxgb/cxgb_include.h>
37#endif
38
39#undef msleep
40#define msleep t3_os_sleep
41
42/* VSC8211 PHY specific registers. */
43enum {
44 VSC8211_SIGDET_CTRL = 19,
45 VSC8211_EXT_CTRL = 23,
46 VSC8211_INTR_ENABLE = 25,
47 VSC8211_INTR_STATUS = 26,
48 VSC8211_LED_CTRL = 27,
48 VSC8211_AUX_CTRL_STAT = 28,
49 VSC8211_EXT_PAGE_AXS = 31,
50};
51
52enum {
53 VSC_INTR_RX_ERR = 1 << 0,
54 VSC_INTR_MS_ERR = 1 << 1, /* master/slave resolution error */
55 VSC_INTR_CABLE = 1 << 2, /* cable impairment */

--- 332 unchanged lines hidden (view full) ---

388 SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Full |
389 SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_MII |
390 SUPPORTED_TP | SUPPORTED_IRQ, "10/100/1000BASE-T");
391 msleep(20); /* PHY needs ~10ms to start responding to MDIO */
392
393 err = mdio_read(phy, 0, VSC8211_EXT_CTRL, &val);
394 if (err)
395 return err;
49 VSC8211_AUX_CTRL_STAT = 28,
50 VSC8211_EXT_PAGE_AXS = 31,
51};
52
53enum {
54 VSC_INTR_RX_ERR = 1 << 0,
55 VSC_INTR_MS_ERR = 1 << 1, /* master/slave resolution error */
56 VSC_INTR_CABLE = 1 << 2, /* cable impairment */

--- 332 unchanged lines hidden (view full) ---

389 SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Full |
390 SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg | SUPPORTED_MII |
391 SUPPORTED_TP | SUPPORTED_IRQ, "10/100/1000BASE-T");
392 msleep(20); /* PHY needs ~10ms to start responding to MDIO */
393
394 err = mdio_read(phy, 0, VSC8211_EXT_CTRL, &val);
395 if (err)
396 return err;
396 if (val & VSC_CTRL_MEDIA_MODE_HI)
397 return 0; /* copper interface, done */
397 if (val & VSC_CTRL_MEDIA_MODE_HI) {
398 /* copper interface, just need to configure the LEDs */
399 return mdio_write(phy, 0, VSC8211_LED_CTRL, 0x100);
400 }
398
399 phy->caps = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
400 SUPPORTED_MII | SUPPORTED_FIBRE | SUPPORTED_IRQ;
401 phy->desc = "1000BASE-X";
402 phy->ops = &vsc8211_fiber_ops;
403
404 if ((err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 1)) != 0 ||
405 (err = mdio_write(phy, 0, VSC8211_SIGDET_CTRL, 1)) != 0 ||
406 (err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0)) != 0 ||
407 (err = mdio_write(phy, 0, VSC8211_EXT_CTRL,
408 val | VSC_CTRL_CLAUSE37_VIEW)) != 0 ||
409 (err = vsc8211_reset(phy, 0)) != 0)
410 return err;
411
412 udelay(5); /* delay after reset before next SMI */
413 return 0;
414}
401
402 phy->caps = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
403 SUPPORTED_MII | SUPPORTED_FIBRE | SUPPORTED_IRQ;
404 phy->desc = "1000BASE-X";
405 phy->ops = &vsc8211_fiber_ops;
406
407 if ((err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 1)) != 0 ||
408 (err = mdio_write(phy, 0, VSC8211_SIGDET_CTRL, 1)) != 0 ||
409 (err = mdio_write(phy, 0, VSC8211_EXT_PAGE_AXS, 0)) != 0 ||
410 (err = mdio_write(phy, 0, VSC8211_EXT_CTRL,
411 val | VSC_CTRL_CLAUSE37_VIEW)) != 0 ||
412 (err = vsc8211_reset(phy, 0)) != 0)
413 return err;
414
415 udelay(5); /* delay after reset before next SMI */
416 return 0;
417}