1210311Sjmallett/*- 2210311Sjmallett * Copyright (c) 2010 Juli Mallett <jmallett@FreeBSD.org> 3210311Sjmallett * All rights reserved. 4210311Sjmallett * 5210311Sjmallett * Redistribution and use in source and binary forms, with or without 6210311Sjmallett * modification, are permitted provided that the following conditions 7210311Sjmallett * are met: 8210311Sjmallett * 1. Redistributions of source code must retain the above copyright 9210311Sjmallett * notice, this list of conditions and the following disclaimer. 10210311Sjmallett * 2. Redistributions in binary form must reproduce the above copyright 11210311Sjmallett * notice, this list of conditions and the following disclaimer in the 12210311Sjmallett * documentation and/or other materials provided with the distribution. 13210311Sjmallett * 14210311Sjmallett * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15210311Sjmallett * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16210311Sjmallett * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17210311Sjmallett * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18210311Sjmallett * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19210311Sjmallett * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20210311Sjmallett * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21210311Sjmallett * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22210311Sjmallett * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23210311Sjmallett * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24210311Sjmallett * SUCH DAMAGE. 25210311Sjmallett * 26210311Sjmallett * $FreeBSD: releng/11.0/sys/mips/cavium/octe/octebus.c 219695 2011-03-16 08:56:22Z jmallett $ 27210311Sjmallett */ 28210311Sjmallett 29210311Sjmallett/* 30210311Sjmallett * Cavium Octeon Ethernet pseudo-bus attachment. 31210311Sjmallett */ 32210311Sjmallett 33210311Sjmallett#include <sys/param.h> 34210311Sjmallett#include <sys/systm.h> 35210311Sjmallett#include <sys/bus.h> 36210311Sjmallett#include <sys/endian.h> 37210311Sjmallett#include <sys/kernel.h> 38210311Sjmallett#include <sys/mbuf.h> 39210311Sjmallett#include <sys/lock.h> 40210311Sjmallett#include <sys/module.h> 41210311Sjmallett#include <sys/mutex.h> 42210311Sjmallett#include <sys/rman.h> 43210311Sjmallett#include <sys/socket.h> 44210311Sjmallett#include <sys/sockio.h> 45210311Sjmallett#include <sys/sysctl.h> 46210311Sjmallett 47210311Sjmallett#include "ethernet-common.h" 48210311Sjmallett 49210311Sjmallett#include "octebusvar.h" 50210311Sjmallett 51210311Sjmallettstatic void octebus_identify(driver_t *drv, device_t parent); 52210311Sjmallettstatic int octebus_probe(device_t dev); 53210311Sjmallettstatic int octebus_attach(device_t dev); 54210311Sjmallettstatic int octebus_detach(device_t dev); 55210311Sjmallettstatic int octebus_shutdown(device_t dev); 56210311Sjmallett 57210311Sjmallettstatic device_method_t octebus_methods[] = { 58210311Sjmallett /* Device interface */ 59210311Sjmallett DEVMETHOD(device_identify, octebus_identify), 60210311Sjmallett DEVMETHOD(device_probe, octebus_probe), 61210311Sjmallett DEVMETHOD(device_attach, octebus_attach), 62210311Sjmallett DEVMETHOD(device_detach, octebus_detach), 63210311Sjmallett DEVMETHOD(device_shutdown, octebus_shutdown), 64210311Sjmallett 65210311Sjmallett /* Bus interface. */ 66210311Sjmallett DEVMETHOD(bus_add_child, bus_generic_add_child), 67210311Sjmallett 68210311Sjmallett { 0, 0 } 69210311Sjmallett}; 70210311Sjmallett 71210311Sjmallettstatic driver_t octebus_driver = { 72210311Sjmallett "octebus", 73210311Sjmallett octebus_methods, 74210311Sjmallett sizeof (struct octebus_softc), 75210311Sjmallett}; 76210311Sjmallett 77210311Sjmallettstatic devclass_t octebus_devclass; 78210311Sjmallett 79210311SjmallettDRIVER_MODULE(octebus, ciu, octebus_driver, octebus_devclass, 0, 0); 80210311Sjmallett 81210311Sjmallettstatic void 82210311Sjmallettoctebus_identify(driver_t *drv, device_t parent) 83210311Sjmallett{ 84210311Sjmallett BUS_ADD_CHILD(parent, 0, "octebus", 0); 85210311Sjmallett} 86210311Sjmallett 87210311Sjmallettstatic int 88210311Sjmallettoctebus_probe(device_t dev) 89210311Sjmallett{ 90210311Sjmallett if (device_get_unit(dev) != 0) 91210311Sjmallett return (ENXIO); 92210311Sjmallett device_set_desc(dev, "Cavium Octeon Ethernet pseudo-bus"); 93210311Sjmallett return (0); 94210311Sjmallett} 95210311Sjmallett 96210311Sjmallettstatic int 97210311Sjmallettoctebus_attach(device_t dev) 98210311Sjmallett{ 99210311Sjmallett struct octebus_softc *sc; 100210311Sjmallett int rv; 101210311Sjmallett 102210311Sjmallett sc = device_get_softc(dev); 103210311Sjmallett sc->sc_dev = dev; 104210311Sjmallett 105210311Sjmallett rv = cvm_oct_init_module(dev); 106210311Sjmallett if (rv != 0) 107210311Sjmallett return (ENXIO); 108210311Sjmallett 109210311Sjmallett return (0); 110210311Sjmallett} 111210311Sjmallett 112210311Sjmallettstatic int 113210311Sjmallettoctebus_detach(device_t dev) 114210311Sjmallett{ 115219695Sjmallett cvm_oct_cleanup_module(dev); 116210311Sjmallett return (0); 117210311Sjmallett} 118210311Sjmallett 119210311Sjmallettstatic int 120210311Sjmallettoctebus_shutdown(device_t dev) 121210311Sjmallett{ 122210311Sjmallett return (octebus_detach(dev)); 123210311Sjmallett} 124