if_cs_isa.c revision 179597
171316Simp/*- 271316Simp * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko. 371316Simp * All rights reserved. 471316Simp * 571316Simp * Redistribution and use in source and binary forms, with or without 671316Simp * modification, are permitted provided that the following conditions 771316Simp * are met: 871316Simp * 1. Redistributions of source code must retain the above copyright 971316Simp * notice unmodified, this list of conditions, and the following 1071316Simp * disclaimer. 1171316Simp * 2. Redistributions in binary form must reproduce the above copyright 1271316Simp * notice, this list of conditions and the following disclaimer in the 1371316Simp * documentation and/or other materials provided with the distribution. 1471316Simp * 1571316Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1671316Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1771316Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1871316Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1971316Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2071316Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2171316Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2271316Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2371316Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2471316Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2571316Simp * SUCH DAMAGE. 2671316Simp * 2771316Simp */ 2871316Simp 2971316Simp#include <sys/cdefs.h> 3071316Simp__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs_isa.c 179597 2008-06-06 05:25:24Z imp $"); 3171316Simp 3271316Simp#include <sys/param.h> 3371316Simp#include <sys/kernel.h> 3471316Simp#include <sys/socket.h> 3571316Simp 3671316Simp#include <sys/module.h> 3771316Simp#include <sys/bus.h> 3871316Simp 3971316Simp#include <machine/bus.h> 4071316Simp#include <machine/resource.h> 4171316Simp 4271316Simp#include <net/ethernet.h> 4371316Simp#include <net/if.h> 4471316Simp#include <net/if_arp.h> 4571316Simp 4671316Simp#include <isa/isavar.h> 4772940Simp 4871316Simp#include <dev/cs/if_csvar.h> 4971316Simp#include <dev/cs/if_csreg.h> 5071316Simp 5171316Simpstatic int cs_isa_probe(device_t); 5271316Simpstatic int cs_isa_attach(device_t); 5371316Simp 5471316Simpstatic struct isa_pnp_id cs_ids[] = { 5571316Simp { 0x4060630e, NULL }, /* CSC6040 */ 5671316Simp { 0x10104d24, NULL }, /* IBM EtherJet */ 5771316Simp { 0, NULL } 5871316Simp}; 5971316Simp 6071316Simp/* 6171316Simp * Determine if the device is present 6271316Simp */ 6371316Simpstatic int 6471316Simpcs_isa_probe(device_t dev) 6571316Simp{ 6671316Simp int error; 6771316Simp 6871316Simp /* Check isapnp ids */ 6971316Simp error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_ids); 7071316Simp 7171316Simp /* If the card had a PnP ID that didn't match any we know about */ 7271316Simp if (error == ENXIO) 7371316Simp goto end; 7471316Simp 7571316Simp /* If we've matched, or there's no PNP ID, probe chip */ 7671316Simp if (error == 0 || error == ENOENT) 7771316Simp error = cs_cs89x0_probe(dev); 7871316Simpend: 7972940Simp /* Make sure IRQ is assigned for probe message and available */ 8071316Simp if (error == 0) 8171316Simp error = cs_alloc_irq(dev, 0, 0); 8271316Simp 8371316Simp cs_release_resources(dev); 8471316Simp return (error); 8571316Simp} 8671316Simp 8771316Simpstatic int 8871316Simpcs_isa_attach(device_t dev) 8971316Simp{ 9071316Simp struct cs_softc *sc = device_get_softc(dev); 9171316Simp 9271316Simp cs_alloc_port(dev, 0, CS_89x0_IO_PORTS); 9371316Simp cs_alloc_irq(dev, sc->irq_rid, 0); 9472940Simp 9572940Simp return (cs_attach(dev)); 9671316Simp} 9771316Simp 9871316Simpstatic device_method_t cs_isa_methods[] = { 9971316Simp /* Device interface */ 10071316Simp DEVMETHOD(device_probe, cs_isa_probe), 10171316Simp DEVMETHOD(device_attach, cs_isa_attach), 10271316Simp DEVMETHOD(device_detach, cs_detach), 10371316Simp 10471316Simp { 0, 0 } 10571316Simp}; 10671316Simp 10771316Simpstatic driver_t cs_isa_driver = { 10871316Simp "cs", 10971316Simp cs_isa_methods, 11071316Simp sizeof(struct cs_softc), 11171316Simp}; 11271316Simp 11371316Simpextern devclass_t cs_devclass; 11471316Simp 11571316SimpDRIVER_MODULE(cs, isa, cs_isa_driver, cs_devclass, 0, 0); 11671316SimpMODULE_DEPEND(cs, isa, 1, 1, 1); 11771316SimpMODULE_DEPEND(cs, ether, 1, 1, 1); 11871316Simp