2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2005, M. Warner Losh
6 * Copyright (c) 1995, David Greenman
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice unmodified, this list of conditions, and the following
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/sockio.h>
42 #include <sys/kernel.h>
43 #include <sys/socket.h>
44 #include <sys/syslog.h>
48 #include <machine/bus.h>
50 #include <machine/resource.h>
52 #include <net/ethernet.h>
54 #include <net/if_arp.h>
55 #include <net/if_dl.h>
56 #include <net/if_mib.h>
57 #include <net/if_media.h>
61 #include <dev/ed/if_edreg.h>
62 #include <dev/ed/if_edvar.h>
65 * Probe and vendor-specific initialization routine for SIC boards
68 ed_probe_SIC(device_t dev, int port_rid, int flags)
70 struct ed_softc *sc = device_get_softc(dev);
77 error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS);
81 sc->asic_offset = ED_SIC_ASIC_OFFSET;
82 sc->nic_offset = ED_SIC_NIC_OFFSET;
85 /* XXX Needs to allow different msize */
86 error = ed_alloc_memory(dev, 0, memsize);
91 sc->mem_size = memsize;
93 pmem = rman_get_start(sc->mem_res);
94 error = ed_isa_mem_ok(dev, pmem, memsize);
98 /* Reset card to force it into a known state. */
99 ed_asic_outb(sc, 0, 0x00);
103 * Here we check the card ROM, if the checksum passes, and the
104 * type code and ethernet address check out, then we know we have
107 ed_asic_outb(sc, 0, 0x81);
110 sum = bus_space_read_1(sc->mem_bst, sc->mem_bsh, 6);
111 for (i = 0; i < ETHER_ADDR_LEN; i++)
112 sum ^= (sc->enaddr[i] =
113 bus_space_read_1(sc->mem_bst, sc->mem_bsh, i));
115 device_printf(dev, "ed_probe_sic: got address %6D\n",
120 if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
123 sc->vendor = ED_VENDOR_SIC;
124 sc->type_str = "SIC";
129 * SIC RAM page 0x0000-0x3fff(or 0x7fff)
131 ed_asic_outb(sc, 0, 0x80);
134 error = ed_clear_memory(dev);
139 sc->mem_end = sc->mem_start + sc->mem_size;
142 * allocate one xmit buffer if < 16k, two buffers otherwise
144 if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING))
148 sc->tx_page_start = 0;
150 sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt;
151 sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE;
153 sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
155 sc->sc_write_mbufs = ed_shmem_write_mbufs;