Home | History | Annotate | Line # | Download | only in ic
cs89x0var.h revision 1.11.84.1
      1  1.11.84.1       jym /*	$NetBSD: cs89x0var.h,v 1.11.84.1 2009/05/13 17:19:22 jym Exp $	*/
      2        1.1      yamt 
      3        1.1      yamt /*
      4        1.1      yamt  * Copyright 1997
      5        1.1      yamt  * Digital Equipment Corporation. All rights reserved.
      6        1.1      yamt  *
      7        1.1      yamt  * This software is furnished under license and may be used and
      8        1.1      yamt  * copied only in accordance with the following terms and conditions.
      9        1.1      yamt  * Subject to these conditions, you may download, copy, install,
     10        1.1      yamt  * use, modify and distribute this software in source and/or binary
     11        1.1      yamt  * form. No title or ownership is transferred hereby.
     12        1.1      yamt  *
     13        1.1      yamt  * 1) Any source code used, modified or distributed must reproduce
     14        1.1      yamt  *    and retain this copyright notice and list of conditions as
     15        1.1      yamt  *    they appear in the source file.
     16        1.1      yamt  *
     17        1.1      yamt  * 2) No right is granted to use any trade name, trademark, or logo of
     18        1.1      yamt  *    Digital Equipment Corporation. Neither the "Digital Equipment
     19        1.1      yamt  *    Corporation" name nor any trademark or logo of Digital Equipment
     20        1.1      yamt  *    Corporation may be used to endorse or promote products derived
     21        1.1      yamt  *    from this software without the prior written permission of
     22        1.1      yamt  *    Digital Equipment Corporation.
     23        1.1      yamt  *
     24        1.1      yamt  * 3) This software is provided "AS-IS" and any express or implied
     25        1.1      yamt  *    warranties, including but not limited to, any implied warranties
     26        1.1      yamt  *    of merchantability, fitness for a particular purpose, or
     27        1.1      yamt  *    non-infringement are disclaimed. In no event shall DIGITAL be
     28        1.1      yamt  *    liable for any damages whatsoever, and in particular, DIGITAL
     29        1.1      yamt  *    shall not be liable for special, indirect, consequential, or
     30        1.1      yamt  *    incidental damages or damages for lost profits, loss of
     31        1.1      yamt  *    revenue or loss of use, whether such damages arise in contract,
     32        1.1      yamt  *    negligence, tort, under statute, in equity, at law or otherwise,
     33        1.1      yamt  *    even if advised of the possibility of such damage.
     34        1.1      yamt  */
     35        1.1      yamt 
     36        1.1      yamt /*
     37        1.1      yamt **++
     38        1.1      yamt **  FACILITY  Crystal CS8900 Ethernet driver header file
     39        1.1      yamt **
     40        1.1      yamt **  ABSTRACT
     41        1.1      yamt **
     42        1.1      yamt **     This module provides CS8900 driver softc and related definitions
     43        1.1      yamt **
     44        1.1      yamt **  AUTHORS
     45        1.1      yamt **
     46        1.1      yamt **     Peter Dettori   SEA - Software Engineering.
     47        1.1      yamt **
     48        1.1      yamt **  CREATION DATE:
     49        1.1      yamt **
     50        1.1      yamt **       13-Feb-1997.
     51        1.1      yamt **
     52        1.1      yamt **  MODIFICATION HISTORY:
     53        1.1      yamt **
     54        1.1      yamt **--
     55        1.1      yamt */
     56        1.1      yamt 
     57        1.1      yamt #ifndef _DEV_IC_CS89X0VAR_H_
     58        1.1      yamt #define	_DEV_IC_CS89X0VAR_H_
     59        1.1      yamt 
     60        1.1      yamt /*
     61        1.1      yamt  * Ethernet software status per interface.
     62        1.1      yamt  *
     63        1.1      yamt  * Each interface is referenced by a network interface structure,
     64        1.1      yamt  * arpcom.ac_if, which the routing code uses to locate the interface.
     65        1.8     perry  * This structure contains the output queue for the interface,
     66        1.1      yamt  * its address, ...
     67        1.1      yamt  */
     68        1.1      yamt struct cs_softc {
     69        1.1      yamt 	struct device sc_dev;		/* base device glue */
     70        1.1      yamt 	struct ethercom sc_ethercom;	/* Ethernet common */
     71        1.1      yamt 	struct ifmedia sc_media;	/* media control structures */
     72        1.1      yamt 
     73        1.4       wiz 	void	*sc_ih;			/* interrupt handler */
     74        1.1      yamt 	void 	*sc_sh;			/* shutdown hook */
     75        1.1      yamt 
     76        1.1      yamt 	bus_space_tag_t sc_iot;		/* bus space tag for IO */
     77        1.1      yamt 	bus_space_tag_t sc_memt;	/* bus space tag for memory mode */
     78        1.1      yamt 	bus_space_handle_t sc_ioh;	/* bus space handles */
     79        1.1      yamt 	bus_space_handle_t sc_memh;
     80        1.1      yamt 
     81        1.1      yamt #if 0
     82        1.1      yamt 	isa_chipset_tag_t sc_ic;	/* ISA chipset */
     83        1.1      yamt #endif
     84        1.1      yamt 
     85        1.1      yamt 	int	sc_irq;			/* IRQ line */
     86        1.1      yamt 
     87        1.1      yamt 	int	sc_prodid;		/* saved product ID */
     88        1.1      yamt 	int	sc_prodrev;		/* saved product rev */
     89        1.1      yamt 
     90        1.1      yamt 	bus_addr_t sc_pktpgaddr;	/* PacketPage bus memory address */
     91        1.1      yamt 
     92        1.1      yamt 	int	sc_cfgflags;		/* software configuration flags */
     93        1.1      yamt 
     94        1.1      yamt 	int	sc_memorymode;		/* are we in memory mode? */
     95        1.1      yamt 	int	sc_txbusy;		/* transmit in progress */
     96        1.1      yamt 	int	sc_resetting;		/* reset in progress */
     97        1.1      yamt 
     98        1.1      yamt 	int	sc_xe_ent;		/* current early-xmit table entry */
     99        1.1      yamt 	int	sc_xe_togo;		/* # of packets to go at this ent */
    100        1.1      yamt 
    101        1.1      yamt 	int	sc_carrier;		/* has carrier */
    102        1.1      yamt 
    103        1.1      yamt 	u_int8_t sc_enaddr[ETHER_ADDR_LEN];	/* MAC address */
    104        1.1      yamt 
    105        1.7     chris 	int	eeprom_size;		/* how large is the eeprom (in bytes) */
    106        1.7     chris 	u_int16_t *eeprom_data;		/* copy of the eeprom data */
    107        1.7     chris 
    108        1.1      yamt #if NRND > 0
    109        1.1      yamt 	rndsource_element_t rnd_source; /* random source */
    110        1.1      yamt #endif
    111        1.1      yamt 
    112        1.1      yamt 	/* power management */
    113        1.2  augustss 	int (*sc_enable)(struct cs_softc *);
    114        1.2  augustss 	void (*sc_disable)(struct cs_softc *);
    115        1.1      yamt 	void *sc_powerhook;
    116        1.1      yamt 
    117        1.5       wiz 	/* DMA hooks */
    118        1.2  augustss 	void (*sc_dma_process_rx)(struct cs_softc *);
    119        1.2  augustss 	void (*sc_dma_chipinit)(struct cs_softc *);
    120        1.2  augustss 	void (*sc_dma_attach)(struct cs_softc *);
    121        1.3  augustss 
    122        1.3  augustss 	/* register access hooks */
    123        1.3  augustss 	u_int8_t (*sc_io_read_1)(struct cs_softc *, bus_size_t);
    124        1.3  augustss 	u_int16_t (*sc_io_read_2)(struct cs_softc *, bus_size_t);
    125        1.3  augustss 	void (*sc_io_read_multi_2)(struct cs_softc *, bus_size_t, u_int16_t *,
    126        1.3  augustss 				bus_size_t);
    127        1.3  augustss 	void (*sc_io_write_2)(struct cs_softc *, bus_size_t, u_int16_t);
    128        1.3  augustss 	void (*sc_io_write_multi_2)(struct cs_softc *, bus_size_t,
    129        1.3  augustss 				 const u_int16_t *, bus_size_t);
    130        1.3  augustss 	u_int16_t (*sc_mem_read_2)(struct cs_softc *, bus_size_t);
    131        1.3  augustss 	void (*sc_mem_write_2)(struct cs_softc *, bus_size_t, u_int16_t);
    132        1.3  augustss 	void (*sc_mem_write_region_2)(struct cs_softc *, bus_size_t,
    133        1.3  augustss 				      const u_int16_t *, bus_size_t);
    134        1.1      yamt };
    135        1.1      yamt 
    136        1.3  augustss #define IO_READ_1(sc, a) \
    137        1.3  augustss 	(sc)->sc_io_read_1 ? \
    138        1.3  augustss 		(sc)->sc_io_read_1((sc), (a)) : \
    139        1.3  augustss 		bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (a))
    140        1.3  augustss #define IO_READ_2(sc, a) \
    141        1.3  augustss 	(sc)->sc_io_read_2 ? \
    142        1.3  augustss 		(sc)->sc_io_read_2((sc), (a)) : \
    143        1.3  augustss 		bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (a))
    144        1.3  augustss #define IO_READ_MULTI_2(sc, a, b, c) \
    145        1.3  augustss 	if ((sc)->sc_io_read_multi_2) \
    146        1.3  augustss 		(sc)->sc_io_read_multi_2((sc), (a), (b), (c)); else \
    147        1.3  augustss 		bus_space_read_multi_2((sc)->sc_iot, (sc)->sc_ioh, (a), (b), (c))
    148        1.3  augustss #define IO_WRITE_2(sc, a, d) \
    149        1.3  augustss 	if ((sc)->sc_io_write_2) \
    150        1.3  augustss 		(sc)->sc_io_write_2((sc), (a), (d)); else \
    151        1.3  augustss 		bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (a), (d))
    152        1.3  augustss #define IO_WRITE_MULTI_2(sc, a, d, c) \
    153        1.3  augustss 	if ((sc)->sc_io_write_multi_2) \
    154        1.3  augustss 		(sc)->sc_io_write_multi_2((sc), (a), (d), (c)); else \
    155        1.3  augustss 		bus_space_write_multi_2((sc)->sc_iot, (sc)->sc_ioh, (a), (d), (c))
    156        1.3  augustss #define MEM_READ_2(sc, a) \
    157        1.3  augustss 	(sc)->sc_mem_read_2 ? \
    158        1.3  augustss 		(sc)->sc_mem_read_2((sc), (a)) : \
    159        1.3  augustss 		bus_space_read_2((sc)->sc_memt, (sc)->sc_memh, (a))
    160        1.3  augustss #define MEM_WRITE_2(sc, a, d) \
    161        1.3  augustss 	if ((sc)->sc_mem_write_2) \
    162        1.3  augustss 		(sc)->sc_mem_write_2((sc), (a), (d)); else \
    163        1.3  augustss 		bus_space_write_2((sc)->sc_memt, (sc)->sc_memh, (a), (d))
    164        1.3  augustss #define MEM_WRITE_REGION_2(sc, a, d, c) \
    165        1.3  augustss 	if ((sc)->sc_mem_write_region_2) \
    166        1.3  augustss 		(sc)->sc_mem_write_region_2((sc), (a), (d), (c)); else \
    167        1.3  augustss 		bus_space_write_region_2((sc)->sc_memt, (sc)->sc_memh, (a), (d), (c))
    168        1.3  augustss 
    169        1.1      yamt 
    170        1.1      yamt /* Config Flags in cs_softc */
    171        1.1      yamt 
    172        1.1      yamt #define CFGFLG_MEM_MODE     0x0001
    173        1.1      yamt #define CFGFLG_USE_SA       0x0002
    174        1.1      yamt #define CFGFLG_IOCHRDY      0x0004
    175        1.1      yamt #define CFGFLG_DCDC_POL     0x0008
    176        1.1      yamt #define CFGFLG_DMA_MODE	    0x0020
    177        1.1      yamt #define CFGFLG_ATTACHED     0x0040 /* XXX should not be here? */
    178        1.1      yamt #define CFGFLG_CARDBUS_HACK 0x0080
    179        1.1      yamt #define CFGFLG_ENABLED      0x0100 /* XXX should not be here? */
    180        1.7     chris #define CFGFLG_PARSE_EEPROM 0x0200
    181        1.1      yamt #define CFGFLG_NOT_EEPROM   0x8000
    182        1.1      yamt 
    183        1.1      yamt 
    184        1.1      yamt /*
    185        1.1      yamt  * Inlines for reading/writing the packet page area.
    186        1.1      yamt  */
    187        1.1      yamt 
    188       1.11     perry static __inline u_int16_t _cs_read_port(struct cs_softc *, int);
    189        1.1      yamt 
    190       1.11     perry static __inline u_int16_t
    191        1.1      yamt _cs_read_port(struct cs_softc *sc, int off)
    192        1.1      yamt {
    193        1.1      yamt 	u_int16_t result;
    194        1.1      yamt 
    195        1.1      yamt 	if (sc->sc_cfgflags & CFGFLG_CARDBUS_HACK) {
    196        1.1      yamt 	    /*
    197        1.1      yamt 		 * hack for EtherJet PCMCIA and cardbus (obtained from freebsd)
    198        1.1      yamt 		 *
    199        1.1      yamt 	     * EtherJet PCMCIA don't work with cardbus bridges
    200        1.1      yamt 	     * (at least TI1250) without this hack.
    201        1.1      yamt 	     */
    202        1.3  augustss 	    result = (IO_READ_1(sc, off) & 0xff);
    203        1.3  augustss 	    result |= ((IO_READ_1(sc, off+1) & 0xff) << 8);
    204        1.1      yamt 	}
    205        1.1      yamt 	else {
    206        1.3  augustss 	    result = IO_READ_2(sc, off);
    207        1.1      yamt 	}
    208        1.1      yamt 
    209        1.1      yamt 	return result;
    210        1.1      yamt }
    211        1.1      yamt 
    212       1.11     perry static __inline u_int16_t _CS_READ_PACKET_PAGE_IO(struct cs_softc *, int);
    213        1.1      yamt 
    214       1.11     perry static __inline u_int16_t
    215        1.1      yamt _CS_READ_PACKET_PAGE_IO(struct cs_softc *sc, int offset)
    216        1.1      yamt {
    217        1.1      yamt 
    218        1.3  augustss 	IO_WRITE_2(sc, PORT_PKTPG_PTR, offset);
    219        1.1      yamt 	return (_cs_read_port(sc, PORT_PKTPG_DATA));
    220        1.1      yamt }
    221        1.1      yamt 
    222       1.11     perry static __inline u_int16_t CS_READ_PACKET_PAGE_IO(struct cs_softc *, int);
    223        1.1      yamt 
    224       1.11     perry static __inline u_int16_t
    225        1.3  augustss CS_READ_PACKET_PAGE_IO(struct cs_softc *sc, int offset)
    226        1.1      yamt {
    227        1.1      yamt 
    228        1.3  augustss 	IO_WRITE_2(sc, PORT_PKTPG_PTR, offset);
    229        1.3  augustss 	return (IO_READ_2(sc, PORT_PKTPG_DATA));
    230        1.1      yamt }
    231        1.1      yamt 
    232        1.3  augustss #define	CS_READ_PACKET_PAGE_MEM(sc, offset)				\
    233        1.3  augustss 	MEM_READ_2((sc), (offset))
    234        1.1      yamt 
    235        1.1      yamt #define	CS_READ_PACKET_PAGE(sc, offset)					\
    236        1.3  augustss 	((sc)->sc_memorymode ? CS_READ_PACKET_PAGE_MEM((sc), (offset)) :\
    237        1.1      yamt 	 _CS_READ_PACKET_PAGE_IO((sc), (offset)))
    238        1.1      yamt 
    239        1.3  augustss #define	CS_WRITE_PACKET_PAGE_IO(sc, offset, val)			\
    240        1.1      yamt do {									\
    241        1.3  augustss 	IO_WRITE_2((sc), PORT_PKTPG_PTR, (offset));			\
    242        1.3  augustss 	IO_WRITE_2((sc), PORT_PKTPG_DATA, (val));			\
    243        1.1      yamt } while (0)
    244        1.1      yamt 
    245        1.3  augustss #define	CS_WRITE_PACKET_PAGE_MEM(sc, offset, val)		\
    246        1.3  augustss 	MEM_WRITE_2((sc), (offset), (val))
    247        1.1      yamt 
    248        1.1      yamt #define	CS_WRITE_PACKET_PAGE(sc, offset, val)				\
    249        1.1      yamt do {									\
    250        1.1      yamt 	if ((sc)->sc_memorymode)					\
    251        1.3  augustss 		CS_WRITE_PACKET_PAGE_MEM((sc), (offset), (val));	\
    252        1.1      yamt 	else								\
    253        1.3  augustss 		CS_WRITE_PACKET_PAGE_IO((sc), (offset), (val));		\
    254        1.1      yamt } while (0)
    255        1.1      yamt 
    256        1.1      yamt #define CS_READ_PORT(sc, off)\
    257        1.3  augustss 	IO_READ_2((sc), (off))
    258        1.1      yamt 
    259        1.1      yamt #define CS_WRITE_PORT(sc, off, val)\
    260        1.3  augustss 	IO_WRITE_2((sc), (off), (val))
    261        1.1      yamt 
    262        1.1      yamt 
    263        1.1      yamt /* Return Status */
    264        1.1      yamt #define	CS_ERROR   -1
    265        1.1      yamt #define CS_OK       1
    266        1.8     perry 
    267        1.1      yamt 
    268        1.1      yamt /* Media Type in cs_softc */
    269        1.1      yamt 
    270        1.1      yamt #define MEDIA_AUI           0x0001
    271        1.1      yamt #define MEDIA_10BASE2       0x0002
    272        1.1      yamt #define MEDIA_10BASET       0x0003
    273        1.1      yamt 
    274        1.1      yamt 
    275        1.1      yamt /* Miscellaneous definitions */
    276        1.1      yamt 
    277        1.1      yamt #define MAXLOOP            0x8888
    278        1.1      yamt 
    279        1.6    itojun int	cs_attach(struct cs_softc *, u_int8_t *, int *, int, int);
    280        1.6    itojun int	cs_detach(struct cs_softc *);
    281        1.6    itojun int	cs_verify_eeprom(struct cs_softc *);
    282        1.3  augustss int	cs_read_eeprom(struct cs_softc *, int, u_int16_t *);
    283        1.2  augustss int	cs_intr(void *);
    284  1.11.84.1       jym int	cs_activate(device_t, enum devact);
    285        1.2  augustss void	cs_ether_input(struct cs_softc *, struct mbuf *);
    286        1.2  augustss void	cs_print_rx_errors(struct cs_softc *, u_int16_t);
    287        1.2  augustss int	cs_init(struct ifnet *);
    288        1.1      yamt 
    289        1.1      yamt #define CS_IS_ENABLED(sc)	((sc)->sc_cfgflags & CFGFLG_ENABLED)
    290        1.1      yamt 
    291        1.1      yamt #endif /* _DEV_IC_CS89X0VAR_H_ */
    292