Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/rt/if_rt.c
Show First 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
rt_attach(device_t dev) | rt_attach(device_t dev) | ||||
{ | { | ||||
struct rt_softc *sc; | struct rt_softc *sc; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int error, i; | int error, i; | ||||
#ifdef FDT | |||||
phandle_t node; | |||||
char fdtval[32]; | |||||
#endif | |||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
sc->dev = dev; | sc->dev = dev; | ||||
#ifdef FDT | |||||
node = ofw_bus_get_node(sc->dev); | |||||
#endif | |||||
mtx_init(&sc->lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, | mtx_init(&sc->lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, | ||||
MTX_DEF | MTX_RECURSE); | MTX_DEF | MTX_RECURSE); | ||||
sc->mem_rid = 0; | sc->mem_rid = 0; | ||||
sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, | sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, | ||||
RF_ACTIVE | RF_SHAREABLE); | RF_ACTIVE | RF_SHAREABLE); | ||||
if (sc->mem == NULL) { | if (sc->mem == NULL) { | ||||
device_printf(dev, "could not allocate memory resource\n"); | device_printf(dev, "could not allocate memory resource\n"); | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | if (sc->gdma1_base != 0) | ||||
GDM_UCS_EN | /* Enable UDP Csum */ | GDM_UCS_EN | /* Enable UDP Csum */ | ||||
GDM_STRPCRC | /* Strip CRC from packet */ | GDM_STRPCRC | /* Strip CRC from packet */ | ||||
GDM_DST_PORT_CPU << GDM_UFRC_P_SHIFT | /* fwd UCast to CPU */ | GDM_DST_PORT_CPU << GDM_UFRC_P_SHIFT | /* fwd UCast to CPU */ | ||||
GDM_DST_PORT_CPU << GDM_BFRC_P_SHIFT | /* fwd BCast to CPU */ | GDM_DST_PORT_CPU << GDM_BFRC_P_SHIFT | /* fwd BCast to CPU */ | ||||
GDM_DST_PORT_CPU << GDM_MFRC_P_SHIFT | /* fwd MCast to CPU */ | GDM_DST_PORT_CPU << GDM_MFRC_P_SHIFT | /* fwd MCast to CPU */ | ||||
GDM_DST_PORT_CPU << GDM_OFRC_P_SHIFT /* fwd Other to CPU */ | GDM_DST_PORT_CPU << GDM_OFRC_P_SHIFT /* fwd Other to CPU */ | ||||
)); | )); | ||||
if (sc->rt_chipid == RT_CHIPID_RT2880) | /* RT2880 is only support FDT */ | ||||
#ifdef FDT | |||||
if (sc->rt_chipid == RT_CHIPID_RT2880) { | |||||
if (OF_getprop(node, "port-mode", fdtval, sizeof(fdtval)) > 0 && | |||||
strcmp(fdtval, "gigasw") == 0) | |||||
RT_WRITE(sc, MDIO_CFG, MDIO_2880_GIGA_INIT); | |||||
else | |||||
RT_WRITE(sc, MDIO_CFG, MDIO_2880_100T_INIT); | RT_WRITE(sc, MDIO_CFG, MDIO_2880_100T_INIT); | ||||
} | |||||
#endif | |||||
/* allocate Tx and Rx rings */ | /* allocate Tx and Rx rings */ | ||||
for (i = 0; i < RT_SOFTC_TX_RING_COUNT; i++) { | for (i = 0; i < RT_SOFTC_TX_RING_COUNT; i++) { | ||||
error = rt_alloc_tx_ring(sc, &sc->tx_ring[i], i); | error = rt_alloc_tx_ring(sc, &sc->tx_ring[i], i); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(dev, "could not allocate Tx ring #%d\n", | device_printf(dev, "could not allocate Tx ring #%d\n", | ||||
i); | i); | ||||
goto fail; | goto fail; | ||||
▲ Show 20 Lines • Show All 2,414 Lines • ▼ Show 20 Lines | |||||
rtmdio_probe(device_t dev) | rtmdio_probe(device_t dev) | ||||
{ | { | ||||
if (!ofw_bus_status_okay(dev)) | if (!ofw_bus_status_okay(dev)) | ||||
return (ENXIO); | return (ENXIO); | ||||
if (!ofw_bus_is_compatible(dev, "ralink,rt2880-mdio")) | if (!ofw_bus_is_compatible(dev, "ralink,rt2880-mdio")) | ||||
return (ENXIO); | return (ENXIO); | ||||
device_set_desc(dev, "FV built-in ethernet interface, MDIO controller"); | device_set_desc(dev, "RT built-in ethernet interface, MDIO controller"); | ||||
return(0); | return(0); | ||||
} | } | ||||
static int | static int | ||||
rtmdio_attach(device_t dev) | rtmdio_attach(device_t dev) | ||||
{ | { | ||||
struct rt_softc *sc; | struct rt_softc *sc; | ||||
int error; | int error; | ||||
Show All 28 Lines |