Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/etherswitch/rtl8366/rtl8366rb.c
Show All 21 Lines | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include "opt_platform.h" | |||||
#include "opt_etherswitch.h" | #include "opt_etherswitch.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/errno.h> | #include <sys/errno.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
Show All 16 Lines | |||||
#include <dev/iicbus/iicbus.h> | #include <dev/iicbus/iicbus.h> | ||||
#include <dev/mii/mii.h> | #include <dev/mii/mii.h> | ||||
#include <dev/mii/miivar.h> | #include <dev/mii/miivar.h> | ||||
#include <dev/mdio/mdio.h> | #include <dev/mdio/mdio.h> | ||||
#include <dev/etherswitch/etherswitch.h> | #include <dev/etherswitch/etherswitch.h> | ||||
#include <dev/etherswitch/rtl8366/rtl8366rbvar.h> | #include <dev/etherswitch/rtl8366/rtl8366rbvar.h> | ||||
#ifdef FDT | |||||
#include <dev/fdt/fdt_common.h> | |||||
#include <dev/ofw/ofw_bus.h> | |||||
#include <dev/ofw/ofw_bus_subr.h> | |||||
#endif | |||||
#include "mdio_if.h" | #include "mdio_if.h" | ||||
#include "iicbus_if.h" | #include "iicbus_if.h" | ||||
#include "miibus_if.h" | #include "miibus_if.h" | ||||
#include "etherswitch_if.h" | #include "etherswitch_if.h" | ||||
struct rtl8366rb_softc { | struct rtl8366rb_softc { | ||||
struct mtx sc_mtx; /* serialize access to softc */ | struct mtx sc_mtx; /* serialize access to softc */ | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if (device_find_child(parent, "rtl8366rb", -1) == NULL) { | ||||
devi->addr = RTL8366_IIC_ADDR; | devi->addr = RTL8366_IIC_ADDR; | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
rtl8366rb_probe(device_t dev) | rtl8366rb_probe(device_t dev) | ||||
{ | { | ||||
struct rtl8366rb_softc *sc; | struct rtl8366rb_softc *sc; | ||||
#ifdef FDT | |||||
phandle_t rtl8366_node; | |||||
if (!ofw_bus_status_okay(dev)) | |||||
return (ENXIO); | |||||
rtl8366_node = fdt_find_compatible(OF_finddevice("/"), | |||||
"realtek,rtl8366rb", 0); | |||||
if (rtl8366_node == 0) | |||||
return (ENXIO); | |||||
#endif | |||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
bzero(sc, sizeof(*sc)); | bzero(sc, sizeof(*sc)); | ||||
if (smi_probe(dev) != 0) | if (smi_probe(dev) != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
if (sc->chip_type == RTL8366RB) | if (sc->chip_type == RTL8366RB) | ||||
device_set_desc(dev, "RTL8366RB Ethernet Switch Controller"); | device_set_desc(dev, "RTL8366RB Ethernet Switch Controller"); | ||||
else | else | ||||
device_set_desc(dev, "RTL8366SR Ethernet Switch Controller"); | device_set_desc(dev, "RTL8366SR Ethernet Switch Controller"); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
▲ Show 20 Lines • Show All 790 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
DEFINE_CLASS_0(rtl8366rb, rtl8366rb_driver, rtl8366rb_methods, | DEFINE_CLASS_0(rtl8366rb, rtl8366rb_driver, rtl8366rb_methods, | ||||
sizeof(struct rtl8366rb_softc)); | sizeof(struct rtl8366rb_softc)); | ||||
static devclass_t rtl8366rb_devclass; | static devclass_t rtl8366rb_devclass; | ||||
DRIVER_MODULE(rtl8366rb, iicbus, rtl8366rb_driver, rtl8366rb_devclass, 0, 0); | DRIVER_MODULE(rtl8366rb, iicbus, rtl8366rb_driver, rtl8366rb_devclass, 0, 0); | ||||
DRIVER_MODULE(miibus, rtl8366rb, miibus_driver, miibus_devclass, 0, 0); | DRIVER_MODULE(miibus, rtl8366rb, miibus_driver, miibus_devclass, 0, 0); | ||||
DRIVER_MODULE(mdio, rtl8366rb, mdio_driver, mdio_devclass, 0, 0); | |||||
DRIVER_MODULE(etherswitch, rtl8366rb, etherswitch_driver, etherswitch_devclass, 0, 0); | DRIVER_MODULE(etherswitch, rtl8366rb, etherswitch_driver, etherswitch_devclass, 0, 0); | ||||
MODULE_VERSION(rtl8366rb, 1); | MODULE_VERSION(rtl8366rb, 1); | ||||
#ifdef FDT | |||||
MODULE_DEPEND(rtl8366rb, ofwbus, 1, 1, 1); /* XXX which versions? */ | |||||
#else | |||||
DRIVER_MODULE(mdio, rtl8366rb, mdio_driver, mdio_devclass, 0, 0); | |||||
MODULE_DEPEND(rtl8366rb, iicbus, 1, 1, 1); /* XXX which versions? */ | MODULE_DEPEND(rtl8366rb, iicbus, 1, 1, 1); /* XXX which versions? */ | ||||
MODULE_DEPEND(rtl8366rb, miibus, 1, 1, 1); /* XXX which versions? */ | MODULE_DEPEND(rtl8366rb, miibus, 1, 1, 1); /* XXX which versions? */ | ||||
MODULE_DEPEND(rtl8366rb, etherswitch, 1, 1, 1); /* XXX which versions? */ | MODULE_DEPEND(rtl8366rb, etherswitch, 1, 1, 1); /* XXX which versions? */ | ||||
#endif |