if_msk.c (212378) | if_msk.c (213893) |
---|---|
1/****************************************************************************** 2 * 3 * Name : sky2.c 4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x 5 * Version: $Revision: 1.23 $ 6 * Date : $Date: 2005/12/22 09:04:11 $ 7 * Purpose: Main driver source file 8 * --- 85 unchanged lines hidden (view full) --- 94 95/* 96 * Device driver for the Marvell Yukon II Ethernet controller. 97 * Due to lack of documentation, this driver is based on the code from 98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x. 99 */ 100 101#include <sys/cdefs.h> | 1/****************************************************************************** 2 * 3 * Name : sky2.c 4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x 5 * Version: $Revision: 1.23 $ 6 * Date : $Date: 2005/12/22 09:04:11 $ 7 * Purpose: Main driver source file 8 * --- 85 unchanged lines hidden (view full) --- 94 95/* 96 * Device driver for the Marvell Yukon II Ethernet controller. 97 * Due to lack of documentation, this driver is based on the code from 98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x. 99 */ 100 101#include <sys/cdefs.h> |
102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 212378 2010-09-09 20:26:30Z jhb $"); | 102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 213893 2010-10-15 14:52:11Z marius $"); |
103 104#include <sys/param.h> 105#include <sys/systm.h> 106#include <sys/bus.h> 107#include <sys/endian.h> 108#include <sys/mbuf.h> 109#include <sys/malloc.h> 110#include <sys/kernel.h> --- 285 unchanged lines hidden (view full) --- 396 { -1, 0, 0 } 397}; 398 399static int 400msk_miibus_readreg(device_t dev, int phy, int reg) 401{ 402 struct msk_if_softc *sc_if; 403 | 103 104#include <sys/param.h> 105#include <sys/systm.h> 106#include <sys/bus.h> 107#include <sys/endian.h> 108#include <sys/mbuf.h> 109#include <sys/malloc.h> 110#include <sys/kernel.h> --- 285 unchanged lines hidden (view full) --- 396 { -1, 0, 0 } 397}; 398 399static int 400msk_miibus_readreg(device_t dev, int phy, int reg) 401{ 402 struct msk_if_softc *sc_if; 403 |
404 if (phy != PHY_ADDR_MARV) 405 return (0); 406 | |
407 sc_if = device_get_softc(dev); 408 409 return (msk_phy_readreg(sc_if, phy, reg)); 410} 411 412static int 413msk_phy_readreg(struct msk_if_softc *sc_if, int phy, int reg) 414{ --- 22 unchanged lines hidden (view full) --- 437 return (val); 438} 439 440static int 441msk_miibus_writereg(device_t dev, int phy, int reg, int val) 442{ 443 struct msk_if_softc *sc_if; 444 | 404 sc_if = device_get_softc(dev); 405 406 return (msk_phy_readreg(sc_if, phy, reg)); 407} 408 409static int 410msk_phy_readreg(struct msk_if_softc *sc_if, int phy, int reg) 411{ --- 22 unchanged lines hidden (view full) --- 434 return (val); 435} 436 437static int 438msk_miibus_writereg(device_t dev, int phy, int reg, int val) 439{ 440 struct msk_if_softc *sc_if; 441 |
445 if (phy != PHY_ADDR_MARV) 446 return (0); 447 | |
448 sc_if = device_get_softc(dev); 449 450 return (msk_phy_writereg(sc_if, phy, reg, val)); 451} 452 453static int 454msk_phy_writereg(struct msk_if_softc *sc_if, int phy, int reg, int val) 455{ --- 1186 unchanged lines hidden (view full) --- 1642 * ether_ifattach() sets ifi_hdrlen to the default value. 1643 */ 1644 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); 1645 1646 /* 1647 * Do miibus setup. 1648 */ 1649 MSK_IF_UNLOCK(sc_if); | 442 sc_if = device_get_softc(dev); 443 444 return (msk_phy_writereg(sc_if, phy, reg, val)); 445} 446 447static int 448msk_phy_writereg(struct msk_if_softc *sc_if, int phy, int reg, int val) 449{ --- 1186 unchanged lines hidden (view full) --- 1636 * ether_ifattach() sets ifi_hdrlen to the default value. 1637 */ 1638 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); 1639 1640 /* 1641 * Do miibus setup. 1642 */ 1643 MSK_IF_UNLOCK(sc_if); |
1650 error = mii_phy_probe(dev, &sc_if->msk_miibus, msk_mediachange, 1651 msk_mediastatus); | 1644 error = mii_attach(dev, &sc_if->msk_miibus, ifp, msk_mediachange, 1645 msk_mediastatus, BMSR_DEFCAPMASK, PHY_ADDR_MARV, MII_OFFSET_ANY, 1646 mmd->mii_flags); |
1652 if (error != 0) { | 1647 if (error != 0) { |
1653 device_printf(sc_if->msk_if_dev, "no PHY found!\n"); | 1648 device_printf(sc_if->msk_if_dev, "attaching PHYs failed\n"); |
1654 ether_ifdetach(ifp); 1655 error = ENXIO; 1656 goto fail; 1657 } 1658 1659fail: 1660 if (error != 0) { 1661 /* Access should be ok even though lock has been dropped */ --- 224 unchanged lines hidden (view full) --- 1886 if (mmd == NULL) { 1887 device_printf(dev, "failed to allocate memory for " 1888 "ivars of PORT_A\n"); 1889 error = ENXIO; 1890 goto fail; 1891 } 1892 mmd->port = MSK_PORT_A; 1893 mmd->pmd = sc->msk_pmd; | 1649 ether_ifdetach(ifp); 1650 error = ENXIO; 1651 goto fail; 1652 } 1653 1654fail: 1655 if (error != 0) { 1656 /* Access should be ok even though lock has been dropped */ --- 224 unchanged lines hidden (view full) --- 1881 if (mmd == NULL) { 1882 device_printf(dev, "failed to allocate memory for " 1883 "ivars of PORT_A\n"); 1884 error = ENXIO; 1885 goto fail; 1886 } 1887 mmd->port = MSK_PORT_A; 1888 mmd->pmd = sc->msk_pmd; |
1894 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S' || sc->msk_pmd == 'P') | 1889 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S') |
1895 mmd->mii_flags |= MIIF_HAVEFIBER; | 1890 mmd->mii_flags |= MIIF_HAVEFIBER; |
1891 if (sc->msk_pmd == 'P') 1892 mmd->mii_flags |= MIIF_HAVEFIBER | MIIF_MACPRIV0; |
|
1896 device_set_ivars(sc->msk_devs[MSK_PORT_A], mmd); 1897 1898 if (sc->msk_num_port > 1) { 1899 sc->msk_devs[MSK_PORT_B] = device_add_child(dev, "msk", -1); 1900 if (sc->msk_devs[MSK_PORT_B] == NULL) { 1901 device_printf(dev, "failed to add child for PORT_B\n"); 1902 error = ENXIO; 1903 goto fail; 1904 } 1905 mmd = malloc(sizeof(struct msk_mii_data), M_DEVBUF, M_WAITOK | M_ZERO); 1906 if (mmd == NULL) { 1907 device_printf(dev, "failed to allocate memory for " 1908 "ivars of PORT_B\n"); 1909 error = ENXIO; 1910 goto fail; 1911 } 1912 mmd->port = MSK_PORT_B; 1913 mmd->pmd = sc->msk_pmd; | 1893 device_set_ivars(sc->msk_devs[MSK_PORT_A], mmd); 1894 1895 if (sc->msk_num_port > 1) { 1896 sc->msk_devs[MSK_PORT_B] = device_add_child(dev, "msk", -1); 1897 if (sc->msk_devs[MSK_PORT_B] == NULL) { 1898 device_printf(dev, "failed to add child for PORT_B\n"); 1899 error = ENXIO; 1900 goto fail; 1901 } 1902 mmd = malloc(sizeof(struct msk_mii_data), M_DEVBUF, M_WAITOK | M_ZERO); 1903 if (mmd == NULL) { 1904 device_printf(dev, "failed to allocate memory for " 1905 "ivars of PORT_B\n"); 1906 error = ENXIO; 1907 goto fail; 1908 } 1909 mmd->port = MSK_PORT_B; 1910 mmd->pmd = sc->msk_pmd; |
1914 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S' || sc->msk_pmd == 'P') | 1911 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S') |
1915 mmd->mii_flags |= MIIF_HAVEFIBER; | 1912 mmd->mii_flags |= MIIF_HAVEFIBER; |
1913 if (sc->msk_pmd == 'P') 1914 mmd->mii_flags |= MIIF_HAVEFIBER | MIIF_MACPRIV0; |
|
1916 device_set_ivars(sc->msk_devs[MSK_PORT_B], mmd); 1917 } 1918 1919 error = bus_generic_attach(dev); 1920 if (error) { 1921 device_printf(dev, "failed to attach port(s)\n"); 1922 goto fail; 1923 } --- 2591 unchanged lines hidden --- | 1915 device_set_ivars(sc->msk_devs[MSK_PORT_B], mmd); 1916 } 1917 1918 error = bus_generic_attach(dev); 1919 if (error) { 1920 device_printf(dev, "failed to attach port(s)\n"); 1921 goto fail; 1922 } --- 2591 unchanged lines hidden --- |