2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2001-01-21 04:56:12 +00:00
|
|
|
* Copyright (c) 1999 M. Warner Losh <imp@village.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2001-01-21 04:56:12 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2013-10-29 11:17:49 +00:00
|
|
|
#include <sys/lock.h>
|
2001-01-21 04:56:12 +00:00
|
|
|
#include <sys/kernel.h>
|
2013-10-29 11:17:49 +00:00
|
|
|
#include <sys/mutex.h>
|
2001-01-21 04:56:12 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if.h>
|
2013-10-29 11:17:49 +00:00
|
|
|
#include <net/if_media.h>
|
2001-01-21 04:56:12 +00:00
|
|
|
|
|
|
|
#include <dev/cs/if_csvar.h>
|
2001-02-23 08:08:21 +00:00
|
|
|
#include <dev/cs/if_csreg.h>
|
2001-01-21 04:56:12 +00:00
|
|
|
#include <dev/pccard/pccardvar.h>
|
2005-01-20 19:56:22 +00:00
|
|
|
#include <dev/pccard/pccard_cis.h>
|
2001-01-21 04:56:12 +00:00
|
|
|
|
|
|
|
#include "card_if.h"
|
2004-05-27 03:49:45 +00:00
|
|
|
#include "pccarddevs.h"
|
2001-01-21 04:56:12 +00:00
|
|
|
|
|
|
|
static const struct pccard_product cs_pccard_products[] = {
|
2005-06-24 14:36:54 +00:00
|
|
|
PCMCIA_CARD(IBM, ETHERJET),
|
2001-01-21 04:56:12 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
static int
|
2005-09-20 19:49:33 +00:00
|
|
|
cs_pccard_probe(device_t dev)
|
2001-01-21 04:56:12 +00:00
|
|
|
{
|
|
|
|
const struct pccard_product *pp;
|
2005-01-20 19:56:22 +00:00
|
|
|
uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
|
|
|
|
|
|
|
|
/* Make sure we're a network function */
|
2008-06-06 05:02:36 +00:00
|
|
|
pccard_get_function(dev, &fcn);
|
2005-01-20 19:56:22 +00:00
|
|
|
if (fcn != PCCARD_FUNCTION_NETWORK)
|
|
|
|
return (ENXIO);
|
2001-01-21 04:56:12 +00:00
|
|
|
|
|
|
|
if ((pp = pccard_product_lookup(dev, cs_pccard_products,
|
|
|
|
sizeof(cs_pccard_products[0]), NULL)) != NULL) {
|
2003-04-10 04:36:02 +00:00
|
|
|
if (pp->pp_name != NULL)
|
|
|
|
device_set_desc(dev, pp->pp_name);
|
2001-01-21 04:56:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-09-20 19:49:33 +00:00
|
|
|
cs_pccard_attach(device_t dev)
|
2001-01-21 04:56:12 +00:00
|
|
|
{
|
2005-01-28 06:35:39 +00:00
|
|
|
struct cs_softc *sc = device_get_softc(dev);
|
2001-01-21 04:56:12 +00:00
|
|
|
int error;
|
|
|
|
|
2005-01-28 06:35:39 +00:00
|
|
|
sc->flags |= CS_NO_IRQ;
|
2001-01-21 04:56:12 +00:00
|
|
|
error = cs_cs89x0_probe(dev);
|
2001-02-23 08:08:21 +00:00
|
|
|
if (error != 0)
|
2005-09-20 19:49:33 +00:00
|
|
|
return (error);
|
2008-06-06 16:10:10 +00:00
|
|
|
error = cs_alloc_irq(dev, sc->irq_rid);
|
2001-01-21 04:56:12 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto bad;
|
|
|
|
|
2005-01-28 06:45:42 +00:00
|
|
|
return (cs_attach(dev));
|
2001-01-21 04:56:12 +00:00
|
|
|
bad:
|
|
|
|
cs_release_resources(dev);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static device_method_t cs_pccard_methods[] = {
|
|
|
|
/* Device interface */
|
2005-09-20 19:49:33 +00:00
|
|
|
DEVMETHOD(device_probe, cs_pccard_probe),
|
|
|
|
DEVMETHOD(device_attach, cs_pccard_attach),
|
2001-01-21 04:56:12 +00:00
|
|
|
DEVMETHOD(device_detach, cs_detach),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t cs_pccard_driver = {
|
|
|
|
"cs",
|
|
|
|
cs_pccard_methods,
|
|
|
|
sizeof(struct cs_softc),
|
|
|
|
};
|
|
|
|
|
|
|
|
extern devclass_t cs_devclass;
|
|
|
|
|
2003-04-15 06:37:30 +00:00
|
|
|
DRIVER_MODULE(cs, pccard, cs_pccard_driver, cs_devclass, 0, 0);
|
|
|
|
MODULE_DEPEND(cs, ether, 1, 1, 1);
|