2002-05-21 06:47:04 +04:00
|
|
|
/* $NetBSD: cs89x0var.h,v 1.3 2002/05/21 02:47:04 augustss Exp $ */
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997
|
|
|
|
* Digital Equipment Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is furnished under license and may be used and
|
|
|
|
* copied only in accordance with the following terms and conditions.
|
|
|
|
* Subject to these conditions, you may download, copy, install,
|
|
|
|
* use, modify and distribute this software in source and/or binary
|
|
|
|
* form. No title or ownership is transferred hereby.
|
|
|
|
*
|
|
|
|
* 1) Any source code used, modified or distributed must reproduce
|
|
|
|
* and retain this copyright notice and list of conditions as
|
|
|
|
* they appear in the source file.
|
|
|
|
*
|
|
|
|
* 2) No right is granted to use any trade name, trademark, or logo of
|
|
|
|
* Digital Equipment Corporation. Neither the "Digital Equipment
|
|
|
|
* Corporation" name nor any trademark or logo of Digital Equipment
|
|
|
|
* Corporation may be used to endorse or promote products derived
|
|
|
|
* from this software without the prior written permission of
|
|
|
|
* Digital Equipment Corporation.
|
|
|
|
*
|
|
|
|
* 3) This software is provided "AS-IS" and any express or implied
|
|
|
|
* warranties, including but not limited to, any implied warranties
|
|
|
|
* of merchantability, fitness for a particular purpose, or
|
|
|
|
* non-infringement are disclaimed. In no event shall DIGITAL be
|
|
|
|
* liable for any damages whatsoever, and in particular, DIGITAL
|
|
|
|
* shall not be liable for special, indirect, consequential, or
|
|
|
|
* incidental damages or damages for lost profits, loss of
|
|
|
|
* revenue or loss of use, whether such damages arise in contract,
|
|
|
|
* negligence, tort, under statute, in equity, at law or otherwise,
|
|
|
|
* even if advised of the possibility of such damage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
**++
|
|
|
|
** FACILITY Crystal CS8900 Ethernet driver header file
|
|
|
|
**
|
|
|
|
** ABSTRACT
|
|
|
|
**
|
|
|
|
** This module provides CS8900 driver softc and related definitions
|
|
|
|
**
|
|
|
|
** AUTHORS
|
|
|
|
**
|
|
|
|
** Peter Dettori SEA - Software Engineering.
|
|
|
|
**
|
|
|
|
** CREATION DATE:
|
|
|
|
**
|
|
|
|
** 13-Feb-1997.
|
|
|
|
**
|
|
|
|
** MODIFICATION HISTORY:
|
|
|
|
**
|
|
|
|
**--
|
|
|
|
*/
|
|
|
|
|
2001-11-26 22:17:05 +03:00
|
|
|
#ifndef _DEV_IC_CS89X0VAR_H_
|
|
|
|
#define _DEV_IC_CS89X0VAR_H_
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethernet software status per interface.
|
|
|
|
*
|
|
|
|
* Each interface is referenced by a network interface structure,
|
|
|
|
* arpcom.ac_if, which the routing code uses to locate the interface.
|
|
|
|
* This structure contains the output queue for the interface,
|
|
|
|
* its address, ...
|
|
|
|
*/
|
|
|
|
struct cs_softc {
|
|
|
|
struct device sc_dev; /* base device glue */
|
|
|
|
struct ethercom sc_ethercom; /* Ethernet common */
|
1998-07-22 02:58:31 +04:00
|
|
|
struct ifmedia sc_media; /* media control structures */
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
void *sc_ih; /* interupt handler */
|
|
|
|
void *sc_sh; /* shutdown hook */
|
|
|
|
|
|
|
|
bus_space_tag_t sc_iot; /* bus space tag for IO */
|
|
|
|
bus_space_tag_t sc_memt; /* bus space tag for memory mode */
|
|
|
|
bus_space_handle_t sc_ioh; /* bus space handles */
|
|
|
|
bus_space_handle_t sc_memh;
|
|
|
|
|
2001-11-26 22:17:05 +03:00
|
|
|
#if 0
|
1998-07-21 05:04:01 +04:00
|
|
|
isa_chipset_tag_t sc_ic; /* ISA chipset */
|
2001-11-26 22:17:05 +03:00
|
|
|
#endif
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
int sc_irq; /* IRQ line */
|
|
|
|
|
1998-07-23 23:25:52 +04:00
|
|
|
int sc_prodid; /* saved product ID */
|
|
|
|
int sc_prodrev; /* saved product rev */
|
|
|
|
|
1998-07-21 05:04:01 +04:00
|
|
|
bus_addr_t sc_pktpgaddr; /* PacketPage bus memory address */
|
|
|
|
|
|
|
|
int sc_cfgflags; /* software configuration flags */
|
|
|
|
|
|
|
|
int sc_memorymode; /* are we in memory mode? */
|
|
|
|
int sc_txbusy; /* transmit in progress */
|
|
|
|
int sc_resetting; /* reset in progress */
|
|
|
|
|
|
|
|
int sc_xe_ent; /* current early-xmit table entry */
|
|
|
|
int sc_xe_togo; /* # of packets to go at this ent */
|
|
|
|
|
1998-08-07 09:55:14 +04:00
|
|
|
int sc_carrier; /* has carrier */
|
|
|
|
|
2000-09-28 14:29:42 +04:00
|
|
|
u_int8_t sc_enaddr[ETHER_ADDR_LEN]; /* MAC address */
|
1999-03-31 01:02:41 +04:00
|
|
|
|
|
|
|
#if NRND > 0
|
|
|
|
rndsource_element_t rnd_source; /* random source */
|
|
|
|
#endif
|
2001-11-26 14:14:50 +03:00
|
|
|
|
|
|
|
/* power management */
|
2002-05-14 23:23:45 +04:00
|
|
|
int (*sc_enable)(struct cs_softc *);
|
|
|
|
void (*sc_disable)(struct cs_softc *);
|
2001-11-26 14:14:50 +03:00
|
|
|
void *sc_powerhook;
|
2001-11-26 22:17:05 +03:00
|
|
|
|
|
|
|
/* dma hooks */
|
2002-05-14 23:23:45 +04:00
|
|
|
void (*sc_dma_process_rx)(struct cs_softc *);
|
|
|
|
void (*sc_dma_chipinit)(struct cs_softc *);
|
|
|
|
void (*sc_dma_attach)(struct cs_softc *);
|
2002-05-21 06:47:04 +04:00
|
|
|
|
|
|
|
/* register access hooks */
|
|
|
|
u_int8_t (*sc_io_read_1)(struct cs_softc *, bus_size_t);
|
|
|
|
u_int16_t (*sc_io_read_2)(struct cs_softc *, bus_size_t);
|
|
|
|
void (*sc_io_read_multi_2)(struct cs_softc *, bus_size_t, u_int16_t *,
|
|
|
|
bus_size_t);
|
|
|
|
void (*sc_io_write_2)(struct cs_softc *, bus_size_t, u_int16_t);
|
|
|
|
void (*sc_io_write_multi_2)(struct cs_softc *, bus_size_t,
|
|
|
|
const u_int16_t *, bus_size_t);
|
|
|
|
u_int16_t (*sc_mem_read_2)(struct cs_softc *, bus_size_t);
|
|
|
|
void (*sc_mem_write_2)(struct cs_softc *, bus_size_t, u_int16_t);
|
|
|
|
void (*sc_mem_write_region_2)(struct cs_softc *, bus_size_t,
|
|
|
|
const u_int16_t *, bus_size_t);
|
1998-07-21 05:04:01 +04:00
|
|
|
};
|
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
#define IO_READ_1(sc, a) \
|
|
|
|
(sc)->sc_io_read_1 ? \
|
|
|
|
(sc)->sc_io_read_1((sc), (a)) : \
|
|
|
|
bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (a))
|
|
|
|
#define IO_READ_2(sc, a) \
|
|
|
|
(sc)->sc_io_read_2 ? \
|
|
|
|
(sc)->sc_io_read_2((sc), (a)) : \
|
|
|
|
bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (a))
|
|
|
|
#define IO_READ_MULTI_2(sc, a, b, c) \
|
|
|
|
if ((sc)->sc_io_read_multi_2) \
|
|
|
|
(sc)->sc_io_read_multi_2((sc), (a), (b), (c)); else \
|
|
|
|
bus_space_read_multi_2((sc)->sc_iot, (sc)->sc_ioh, (a), (b), (c))
|
|
|
|
#define IO_WRITE_2(sc, a, d) \
|
|
|
|
if ((sc)->sc_io_write_2) \
|
|
|
|
(sc)->sc_io_write_2((sc), (a), (d)); else \
|
|
|
|
bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (a), (d))
|
|
|
|
#define IO_WRITE_MULTI_2(sc, a, d, c) \
|
|
|
|
if ((sc)->sc_io_write_multi_2) \
|
|
|
|
(sc)->sc_io_write_multi_2((sc), (a), (d), (c)); else \
|
|
|
|
bus_space_write_multi_2((sc)->sc_iot, (sc)->sc_ioh, (a), (d), (c))
|
|
|
|
#define MEM_READ_2(sc, a) \
|
|
|
|
(sc)->sc_mem_read_2 ? \
|
|
|
|
(sc)->sc_mem_read_2((sc), (a)) : \
|
|
|
|
bus_space_read_2((sc)->sc_memt, (sc)->sc_memh, (a))
|
|
|
|
#define MEM_WRITE_2(sc, a, d) \
|
|
|
|
if ((sc)->sc_mem_write_2) \
|
|
|
|
(sc)->sc_mem_write_2((sc), (a), (d)); else \
|
|
|
|
bus_space_write_2((sc)->sc_memt, (sc)->sc_memh, (a), (d))
|
|
|
|
#define MEM_WRITE_REGION_2(sc, a, d, c) \
|
|
|
|
if ((sc)->sc_mem_write_region_2) \
|
|
|
|
(sc)->sc_mem_write_region_2((sc), (a), (d), (c)); else \
|
|
|
|
bus_space_write_region_2((sc)->sc_memt, (sc)->sc_memh, (a), (d), (c))
|
|
|
|
|
2001-11-24 23:18:55 +03:00
|
|
|
|
|
|
|
/* Config Flags in cs_softc */
|
|
|
|
|
|
|
|
#define CFGFLG_MEM_MODE 0x0001
|
|
|
|
#define CFGFLG_USE_SA 0x0002
|
|
|
|
#define CFGFLG_IOCHRDY 0x0004
|
|
|
|
#define CFGFLG_DCDC_POL 0x0008
|
|
|
|
#define CFGFLG_DMA_MODE 0x0020
|
|
|
|
#define CFGFLG_ATTACHED 0x0040 /* XXX should not be here? */
|
|
|
|
#define CFGFLG_CARDBUS_HACK 0x0080
|
2001-11-26 14:14:50 +03:00
|
|
|
#define CFGFLG_ENABLED 0x0100 /* XXX should not be here? */
|
2001-11-24 23:18:55 +03:00
|
|
|
#define CFGFLG_NOT_EEPROM 0x8000
|
|
|
|
|
|
|
|
|
1998-07-21 05:04:01 +04:00
|
|
|
/*
|
1998-07-27 05:20:19 +04:00
|
|
|
* Inlines for reading/writing the packet page area.
|
1998-07-21 05:04:01 +04:00
|
|
|
*/
|
2001-11-24 23:18:55 +03:00
|
|
|
|
|
|
|
static __inline__ u_int16_t _cs_read_port(struct cs_softc *, int);
|
|
|
|
|
|
|
|
static __inline__ u_int16_t
|
|
|
|
_cs_read_port(struct cs_softc *sc, int off)
|
|
|
|
{
|
|
|
|
u_int16_t result;
|
|
|
|
|
|
|
|
if (sc->sc_cfgflags & CFGFLG_CARDBUS_HACK) {
|
|
|
|
/*
|
|
|
|
* hack for EtherJet PCMCIA and cardbus (obtained from freebsd)
|
|
|
|
*
|
|
|
|
* EtherJet PCMCIA don't work with cardbus bridges
|
|
|
|
* (at least TI1250) without this hack.
|
|
|
|
*/
|
2002-05-21 06:47:04 +04:00
|
|
|
result = (IO_READ_1(sc, off) & 0xff);
|
|
|
|
result |= ((IO_READ_1(sc, off+1) & 0xff) << 8);
|
2001-11-24 23:18:55 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-05-21 06:47:04 +04:00
|
|
|
result = IO_READ_2(sc, off);
|
2001-11-24 23:18:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ u_int16_t _CS_READ_PACKET_PAGE_IO(struct cs_softc *, int);
|
|
|
|
|
|
|
|
static __inline__ u_int16_t
|
|
|
|
_CS_READ_PACKET_PAGE_IO(struct cs_softc *sc, int offset)
|
|
|
|
{
|
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
IO_WRITE_2(sc, PORT_PKTPG_PTR, offset);
|
2001-11-24 23:18:55 +03:00
|
|
|
return (_cs_read_port(sc, PORT_PKTPG_DATA));
|
|
|
|
}
|
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
static __inline__ u_int16_t CS_READ_PACKET_PAGE_IO(struct cs_softc *, int);
|
1998-07-27 05:20:19 +04:00
|
|
|
|
|
|
|
static __inline__ u_int16_t
|
2002-05-21 06:47:04 +04:00
|
|
|
CS_READ_PACKET_PAGE_IO(struct cs_softc *sc, int offset)
|
1998-07-27 05:20:19 +04:00
|
|
|
{
|
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
IO_WRITE_2(sc, PORT_PKTPG_PTR, offset);
|
|
|
|
return (IO_READ_2(sc, PORT_PKTPG_DATA));
|
1998-07-27 05:20:19 +04:00
|
|
|
}
|
1998-07-21 05:04:01 +04:00
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
#define CS_READ_PACKET_PAGE_MEM(sc, offset) \
|
|
|
|
MEM_READ_2((sc), (offset))
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
#define CS_READ_PACKET_PAGE(sc, offset) \
|
2002-05-21 06:47:04 +04:00
|
|
|
((sc)->sc_memorymode ? CS_READ_PACKET_PAGE_MEM((sc), (offset)) :\
|
2001-11-24 23:18:55 +03:00
|
|
|
_CS_READ_PACKET_PAGE_IO((sc), (offset)))
|
1998-07-21 05:04:01 +04:00
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
#define CS_WRITE_PACKET_PAGE_IO(sc, offset, val) \
|
1998-07-21 05:04:01 +04:00
|
|
|
do { \
|
2002-05-21 06:47:04 +04:00
|
|
|
IO_WRITE_2((sc), PORT_PKTPG_PTR, (offset)); \
|
|
|
|
IO_WRITE_2((sc), PORT_PKTPG_DATA, (val)); \
|
1998-07-21 05:04:01 +04:00
|
|
|
} while (0)
|
|
|
|
|
2002-05-21 06:47:04 +04:00
|
|
|
#define CS_WRITE_PACKET_PAGE_MEM(sc, offset, val) \
|
|
|
|
MEM_WRITE_2((sc), (offset), (val))
|
1998-07-21 05:04:01 +04:00
|
|
|
|
|
|
|
#define CS_WRITE_PACKET_PAGE(sc, offset, val) \
|
|
|
|
do { \
|
|
|
|
if ((sc)->sc_memorymode) \
|
2002-05-21 06:47:04 +04:00
|
|
|
CS_WRITE_PACKET_PAGE_MEM((sc), (offset), (val)); \
|
1998-07-21 05:04:01 +04:00
|
|
|
else \
|
2002-05-21 06:47:04 +04:00
|
|
|
CS_WRITE_PACKET_PAGE_IO((sc), (offset), (val)); \
|
1998-07-21 05:04:01 +04:00
|
|
|
} while (0)
|
|
|
|
|
2001-11-24 23:18:55 +03:00
|
|
|
#define CS_READ_PORT(sc, off)\
|
2002-05-21 06:47:04 +04:00
|
|
|
IO_READ_2((sc), (off))
|
2001-11-24 23:18:55 +03:00
|
|
|
|
|
|
|
#define CS_WRITE_PORT(sc, off, val)\
|
2002-05-21 06:47:04 +04:00
|
|
|
IO_WRITE_2((sc), (off), (val))
|
2001-11-24 23:18:55 +03:00
|
|
|
|
|
|
|
|
1998-07-21 05:04:01 +04:00
|
|
|
/* Return Status */
|
|
|
|
#define CS_ERROR -1
|
|
|
|
#define CS_OK 1
|
|
|
|
|
|
|
|
|
|
|
|
/* Media Type in cs_softc */
|
|
|
|
|
|
|
|
#define MEDIA_AUI 0x0001
|
|
|
|
#define MEDIA_10BASE2 0x0002
|
|
|
|
#define MEDIA_10BASET 0x0003
|
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous definitions */
|
|
|
|
|
|
|
|
#define MAXLOOP 0x8888
|
|
|
|
|
2002-05-14 23:23:45 +04:00
|
|
|
int cs_attach(struct cs_softc *sc, u_int8_t *enaddr,
|
|
|
|
int *media, int nmedia, int defmedia);
|
|
|
|
int cs_detach(struct cs_softc *sc);
|
2002-05-21 06:47:04 +04:00
|
|
|
int cs_verify_eeprom(struct cs_softc *sc);
|
|
|
|
int cs_read_eeprom(struct cs_softc *, int, u_int16_t *);
|
2002-05-14 23:23:45 +04:00
|
|
|
int cs_intr(void *);
|
|
|
|
int cs_activate(struct device *, enum devact);
|
|
|
|
void cs_ether_input(struct cs_softc *, struct mbuf *);
|
|
|
|
void cs_print_rx_errors(struct cs_softc *, u_int16_t);
|
|
|
|
int cs_init(struct ifnet *);
|
2001-11-26 14:14:50 +03:00
|
|
|
|
|
|
|
#define CS_IS_ENABLED(sc) ((sc)->sc_cfgflags & CFGFLG_ENABLED)
|
1998-07-27 05:08:51 +04:00
|
|
|
|
2001-11-26 22:17:05 +03:00
|
|
|
#endif /* _DEV_IC_CS89X0VAR_H_ */
|