diff options
author | shiba <shiba@FreeBSD.org> | 2003-10-15 17:22:15 +0000 |
---|---|---|
committer | shiba <shiba@FreeBSD.org> | 2003-10-15 17:22:15 +0000 |
commit | 24ea734c5d6692ab2ce863a82ec0a6eb682dbf82 (patch) | |
tree | 00f1cac86cae04099dc7b4c9d6331fa05860052b /sys | |
parent | 127c6b8a398487dfbbaaeaaa5d4bec9036945419 (diff) | |
download | FreeBSD-src-24ea734c5d6692ab2ce863a82ec0a6eb682dbf82.zip FreeBSD-src-24ea734c5d6692ab2ce863a82ec0a6eb682dbf82.tar.gz |
Add Allied Telesis SIC-AT boards support.
Discussed in from [FreeBSD-tech-jp 3396] to [FreeBSD-tech-jp 3407]
at FreeBSD-tech-jp@jp.freebsd.org.
NOTE: We must put ed_probe_SIC() function into if_ed_isa.c because
this is a bus dependent code. But the ed driver code is not
separated explicitly whether it is bus dependent or independent
now.
Refer to: http://plaza17.mbn.or.jp/~chi/myprog/FreeBSD/sicat.html
Submitted by: chi@bd.mbn.or.jp (Chiharu Shibata)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ed/if_ed.c | 114 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_cbus.c | 6 | ||||
-rw-r--r-- | sys/dev/ed/if_ed_isa.c | 5 | ||||
-rw-r--r-- | sys/dev/ed/if_edreg.h | 9 | ||||
-rw-r--r-- | sys/dev/ed/if_edvar.h | 1 |
5 files changed, 132 insertions, 3 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index bcc4671..0f584aa 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -911,6 +911,120 @@ ed_probe_3Com(dev, port_rid, flags) } /* + * Probe and vendor-specific initialization routine for SIC boards + */ +int +ed_probe_SIC(dev, port_rid, flags) + device_t dev; + int port_rid; + int flags; +{ + struct ed_softc *sc = device_get_softc(dev); + int error; + int i; + u_int memsize; + u_long conf_maddr, conf_msize; + u_char sum; + + error = ed_alloc_port(dev, 0, ED_SIC_IO_PORTS); + if (error) + return (error); + + sc->asic_offset = ED_SIC_ASIC_OFFSET; + sc->nic_offset = ED_SIC_NIC_OFFSET; + + error = bus_get_resource(dev, SYS_RES_MEMORY, 0, + &conf_maddr, &conf_msize); + if (error) + return (error); + + memsize = 16384; + if (conf_msize > 1) + memsize = conf_msize; + + error = ed_alloc_memory(dev, 0, memsize); + if (error) + return (error); + + sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res); + sc->mem_size = memsize; + + /* Reset card to force it into a known state. */ + ed_asic_outb(sc, 0, 0x00); + DELAY(100); + + /* + * Here we check the card ROM, if the checksum passes, and the + * type code and ethernet address check out, then we know we have + * an SIC card. + */ + ed_asic_outb(sc, 0, 0x81); + DELAY(100); + + sum = sc->mem_start[6]; + for (i = 0; i < ETHER_ADDR_LEN; i++) { + sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i]); + } +#ifdef ED_DEBUG + device_printf(dev, "ed_probe_sic: got address %6D\n", + sc->arpcom.ac_enaddr, ":"); +#endif + if (sum != 0) { + return (ENXIO); + } + if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] | + sc->arpcom.ac_enaddr[2]) == 0) { + return (ENXIO); + } + + sc->vendor = ED_VENDOR_SIC; + sc->type_str = "SIC"; + sc->isa16bit = 0; + sc->cr_proto = 0; + + /* + * SIC RAM page 0x0000-0x3fff(or 0x7fff) + */ + ed_asic_outb(sc, 0, 0x80); + DELAY(100); + + /* + * Now zero memory and verify that it is clear + */ + bzero(sc->mem_start, sc->mem_size); + + for (i = 0; i < sc->mem_size; i++) { + if (sc->mem_start[i]) { + device_printf(dev, "failed to clear shared memory " + "at %jx - check configuration\n", + (uintmax_t)kvtop(sc->mem_start + i)); + + return (ENXIO); + } + } + + sc->mem_shared = 1; + sc->mem_end = sc->mem_start + sc->mem_size; + + /* + * allocate one xmit buffer if < 16k, two buffers otherwise + */ + if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) { + sc->txb_cnt = 1; + } else { + sc->txb_cnt = 2; + } + sc->tx_page_start = 0; + + sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt; + sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; + + sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; + + return (0); +} + +/* * Probe and vendor-specific initialization routine for NE1000/2000 boards */ int diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c index 4a3c651..d6c37f2 100644 --- a/sys/dev/ed/if_ed_cbus.c +++ b/sys/dev/ed/if_ed_cbus.c @@ -869,8 +869,8 @@ ed_probe_SIC98(dev, port_rid, flags) return (error); } - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; + sc->asic_offset = ED_SIC_ASIC_OFFSET; + sc->nic_offset = ED_SIC_NIC_OFFSET; error = ed98_alloc_memory(dev, 0); if (error) { @@ -916,7 +916,7 @@ ed_probe_SIC98(dev, port_rid, flags) return (ENXIO); } - sc->vendor = ED_VENDOR_MISC; + sc->vendor = ED_VENDOR_SIC; sc->type_str = "SIC98"; sc->isa16bit = 1; sc->cr_proto = 0; diff --git a/sys/dev/ed/if_ed_isa.c b/sys/dev/ed/if_ed_isa.c index 39352b3..bc5e397 100644 --- a/sys/dev/ed/if_ed_isa.c +++ b/sys/dev/ed/if_ed_isa.c @@ -97,6 +97,11 @@ ed_isa_probe(dev) goto end; ed_release_resources(dev); + error = ed_probe_SIC(dev, 0, flags); + if (error == 0) + goto end; + ed_release_resources(dev); + error = ed_probe_Novell(dev, 0, flags); if (error == 0) goto end; diff --git a/sys/dev/ed/if_edreg.h b/sys/dev/ed/if_edreg.h index 068361a..4b08578 100644 --- a/sys/dev/ed/if_edreg.h +++ b/sys/dev/ed/if_edreg.h @@ -578,6 +578,7 @@ struct ed_ring { #define ED_VENDOR_PCCARD 0x03 /* PCMCIA/PCCARD */ #define ED_VENDOR_HP 0x04 /* Hewlett Packard */ #define ED_VENDOR_LINKSYS 0x05 /* Linksys (Dlink) */ +#define ED_VENDOR_SIC 0x06 /* Allied-Telesis SIC */ /* * Compile-time config flags @@ -1101,6 +1102,14 @@ struct ed_ring { #define ED_TYPE_HP_PCLANPLUS 0x00 /* + * Definitions for Allied-Telesis SIC + */ +#define ED_SIC_NIC_OFFSET 0 +#define ED_SIC_ASIC_OFFSET 0x10 /* offset to nic i/o regs */ + +#define ED_SIC_IO_PORTS 17 /* # of i/o addresses used */ + +/* * Chip types. */ diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h index 3855b6d..3b71c8c 100644 --- a/sys/dev/ed/if_edvar.h +++ b/sys/dev/ed/if_edvar.h @@ -199,6 +199,7 @@ int ed_probe_generic8390 (struct ed_softc *); int ed_probe_WD80x3 (device_t, int, int); int ed_probe_WD80x3_generic (device_t, int, unsigned short *[]); int ed_probe_3Com (device_t, int, int); +int ed_probe_SIC (device_t, int, int); int ed_probe_Novell (device_t, int, int); int ed_probe_Novell_generic (device_t, int); int ed_probe_HP_pclanp (device_t, int, int); |