2 * Copyright (c) 2005, M. Warner Losh
4 * Copyright (c) 1995, David Greenman
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/sockio.h>
40 #include <sys/kernel.h>
41 #include <sys/socket.h>
42 #include <sys/syslog.h>
46 #include <machine/bus.h>
48 #include <machine/resource.h>
50 #include <net/ethernet.h>
52 #include <net/if_arp.h>
53 #include <net/if_dl.h>
54 #include <net/if_mib.h>
55 #include <net/if_media.h>
59 #include <dev/ed/if_edreg.h>
60 #include <dev/ed/if_edvar.h>
63 * Probe and vendor-specific initialization routine for SIC boards
66 ed_probe_SIC(device_t dev, int port_rid, int flags)
68 struct ed_softc *sc = device_get_softc(dev);
75 error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS);
79 sc->asic_offset = ED_SIC_ASIC_OFFSET;
80 sc->nic_offset = ED_SIC_NIC_OFFSET;
83 /* XXX Needs to allow different msize */
84 error = ed_alloc_memory(dev, 0, memsize);
89 sc->mem_size = memsize;
91 pmem = rman_get_start(sc->mem_res);
92 error = ed_isa_mem_ok(dev, pmem, memsize);
96 /* Reset card to force it into a known state. */
97 ed_asic_outb(sc, 0, 0x00);
101 * Here we check the card ROM, if the checksum passes, and the
102 * type code and ethernet address check out, then we know we have
105 ed_asic_outb(sc, 0, 0x81);
108 sum = bus_space_read_1(sc->mem_bst, sc->mem_bsh, 6);
109 for (i = 0; i < ETHER_ADDR_LEN; i++)
110 sum ^= (sc->enaddr[i] =
111 bus_space_read_1(sc->mem_bst, sc->mem_bsh, i));
113 device_printf(dev, "ed_probe_sic: got address %6D\n",
118 if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
121 sc->vendor = ED_VENDOR_SIC;
122 sc->type_str = "SIC";
127 * SIC RAM page 0x0000-0x3fff(or 0x7fff)
129 ed_asic_outb(sc, 0, 0x80);
132 error = ed_clear_memory(dev);
137 sc->mem_end = sc->mem_start + sc->mem_size;
140 * allocate one xmit buffer if < 16k, two buffers otherwise
142 if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING))
146 sc->tx_page_start = 0;
148 sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt;
149 sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE;
151 sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
153 sc->sc_write_mbufs = ed_shmem_write_mbufs;