Home | History | Annotate | Line # | Download | only in ic
hd64570var.h revision 1.5.2.1
      1  1.5.2.1     skrll /*	$NetBSD: hd64570var.h,v 1.5.2.1 2004/08/03 10:46:13 skrll Exp $	*/
      2      1.1  explorer 
      3      1.1  explorer /*
      4      1.3    chopps  * Copyright (c) 1999 Christian E. Hopps
      5      1.1  explorer  * Copyright (c) 1998 Vixie Enterprises
      6      1.1  explorer  * All rights reserved.
      7      1.1  explorer  *
      8      1.1  explorer  * Redistribution and use in source and binary forms, with or without
      9      1.1  explorer  * modification, are permitted provided that the following conditions
     10      1.1  explorer  * are met:
     11      1.1  explorer  *
     12      1.1  explorer  * 1. Redistributions of source code must retain the above copyright
     13      1.1  explorer  *    notice, this list of conditions and the following disclaimer.
     14      1.1  explorer  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.1  explorer  *    notice, this list of conditions and the following disclaimer in the
     16      1.1  explorer  *    documentation and/or other materials provided with the distribution.
     17      1.1  explorer  * 3. Neither the name of Vixie Enterprises nor the names
     18      1.1  explorer  *    of its contributors may be used to endorse or promote products derived
     19      1.1  explorer  *    from this software without specific prior written permission.
     20      1.1  explorer  *
     21      1.1  explorer  * THIS SOFTWARE IS PROVIDED BY VIXIE ENTERPRISES AND
     22      1.1  explorer  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     23      1.1  explorer  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     24      1.1  explorer  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     25      1.1  explorer  * DISCLAIMED.  IN NO EVENT SHALL VIXIE ENTERPRISES OR
     26      1.1  explorer  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27      1.1  explorer  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     28      1.1  explorer  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
     29      1.1  explorer  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     30      1.1  explorer  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     31      1.1  explorer  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     32      1.1  explorer  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33      1.1  explorer  * SUCH DAMAGE.
     34      1.1  explorer  *
     35      1.1  explorer  * This software has been written for Vixie Enterprises by Michael Graff
     36      1.1  explorer  * <explorer (at) flame.org>.  To learn more about Vixie Enterprises, see
     37      1.1  explorer  * ``http://www.vix.com''.
     38      1.1  explorer  */
     39      1.1  explorer 
     40      1.2    kleink #ifndef _DEV_IC_HD64570VAR_H_
     41      1.2    kleink #define _DEV_IC_HD64570VAR_H_
     42      1.1  explorer 
     43      1.1  explorer #include "bpfilter.h"
     44      1.1  explorer 
     45      1.1  explorer #define SCA_USE_FASTQ		/* use a split queue, one for fast traffic */
     46      1.1  explorer 
     47      1.3    chopps #define SCA_MTU		1500	/* hard coded */
     48      1.3    chopps 
     49      1.3    chopps #ifndef SCA_BSIZE
     50      1.3    chopps #define SCA_BSIZE	(SCA_MTU + 4)	/* room for HDLC as well */
     51      1.3    chopps #endif
     52      1.3    chopps 
     53      1.3    chopps 
     54      1.1  explorer struct sca_softc;
     55      1.1  explorer typedef struct sca_port sca_port_t;
     56      1.1  explorer typedef struct sca_desc sca_desc_t;
     57      1.1  explorer 
     58      1.1  explorer /*
     59      1.1  explorer  * device DMA descriptor
     60      1.1  explorer  */
     61      1.1  explorer struct sca_desc {
     62      1.3    chopps 	u_int16_t	sd_chainp;	/* chain pointer */
     63      1.3    chopps 	u_int16_t	sd_bufp;	/* buffer pointer (low bits) */
     64      1.3    chopps 	u_int8_t	sd_hbufp;	/* buffer pointer (high bits) */
     65      1.3    chopps 	u_int8_t	sd_unused0;
     66      1.3    chopps 	u_int16_t	sd_buflen;		/* total length */
     67      1.3    chopps 	u_int8_t	sd_stat;	/* status */
     68      1.3    chopps 	u_int8_t	sd_unused1;
     69      1.1  explorer };
     70      1.1  explorer #define SCA_DESC_EOT            0x01
     71      1.1  explorer #define SCA_DESC_CRC            0x04
     72      1.1  explorer #define SCA_DESC_OVRN           0x08
     73      1.1  explorer #define SCA_DESC_RESD           0x10
     74      1.1  explorer #define SCA_DESC_ABORT          0x20
     75      1.1  explorer #define SCA_DESC_SHRTFRM        0x40
     76      1.1  explorer #define SCA_DESC_EOM            0x80
     77      1.1  explorer #define SCA_DESC_ERRORS         0x7C
     78      1.1  explorer 
     79      1.1  explorer /*
     80      1.1  explorer  * softc structure for each port
     81      1.1  explorer  */
     82      1.1  explorer struct sca_port {
     83      1.1  explorer 	u_int msci_off;		/* offset for msci address for this port */
     84      1.1  explorer 	u_int dmac_off;		/* offset of dmac address for this port */
     85      1.1  explorer 
     86      1.1  explorer 	u_int sp_port;
     87      1.1  explorer 
     88      1.1  explorer 	/*
     89      1.1  explorer 	 * CISCO keepalive stuff
     90      1.1  explorer 	 */
     91      1.1  explorer 	u_int32_t	cka_lasttx;
     92      1.1  explorer 	u_int32_t	cka_lastrx;
     93      1.1  explorer 
     94      1.1  explorer 	/*
     95      1.3    chopps 	 * clock values, clockrate = sysclock / tmc / 2^div;
     96      1.3    chopps 	 */
     97      1.3    chopps 	u_int8_t	sp_eclock;	/* enable external clock generate */
     98      1.3    chopps 	u_int8_t	sp_rxs;		/* recv clock source */
     99      1.3    chopps 	u_int8_t	sp_txs;		/* transmit clock source */
    100      1.3    chopps 	u_int8_t	sp_tmc;		/* clock constant */
    101      1.3    chopps 
    102      1.3    chopps 	/*
    103      1.1  explorer 	 * start of each important bit of information for transmit and
    104      1.1  explorer 	 * receive buffers.
    105      1.3    chopps 	 *
    106      1.5       wiz 	 * note: for non-DMA the phys and virtual version should be
    107      1.3    chopps 	 * the same value and should be an _offset_ from the beginning
    108      1.3    chopps 	 * of mapped memory described by sc_memt/sc_memh.
    109      1.1  explorer 	 */
    110      1.3    chopps 	u_int sp_ntxdesc;		/* number of tx descriptors */
    111      1.3    chopps 	u_int32_t sp_txdesc_p;		/* paddress of first tx desc */
    112      1.3    chopps 	sca_desc_t *sp_txdesc;		/* vaddress of first tx desc */
    113      1.3    chopps 	u_int32_t sp_txbuf_p;		/* paddress of first tx buffer */
    114      1.3    chopps 	u_int8_t *sp_txbuf;		/* vaddress of first tx buffer */
    115      1.3    chopps 
    116      1.3    chopps 	volatile u_int sp_txcur;	/* last descriptor in chain */
    117      1.3    chopps 	volatile u_int sp_txinuse;	/* descriptors in use */
    118      1.3    chopps 	volatile u_int sp_txstart;	/* start descriptor */
    119      1.3    chopps 
    120      1.3    chopps 	u_int sp_nrxdesc;		/* number of rx descriptors */
    121      1.3    chopps 	u_int32_t sp_rxdesc_p;		/* paddress of first rx desc */
    122      1.3    chopps 	sca_desc_t *sp_rxdesc;		/* vaddress of first rx desc */
    123      1.3    chopps 	u_int32_t sp_rxbuf_p;		/* paddress of first rx buffer */
    124      1.3    chopps 	u_int8_t *sp_rxbuf;		/* vaddress of first rx buffer */
    125      1.3    chopps 
    126      1.3    chopps 	u_int sp_rxstart;		/* index of first descriptor */
    127      1.3    chopps 	u_int sp_rxend;			/* index of last descriptor */
    128      1.1  explorer 
    129      1.1  explorer 	struct ifnet sp_if;		/* the network information */
    130      1.1  explorer 	struct ifqueue linkq;		/* link-level packets are high prio */
    131      1.1  explorer #ifdef SCA_USE_FASTQ
    132      1.1  explorer 	struct ifqueue fastq;		/* interactive packets */
    133      1.1  explorer #endif
    134      1.1  explorer 
    135      1.1  explorer 	struct sca_softc *sca;		/* pointer to parent */
    136      1.1  explorer };
    137      1.1  explorer 
    138      1.1  explorer /*
    139      1.1  explorer  * softc structure for the chip itself
    140      1.1  explorer  */
    141      1.1  explorer struct sca_softc {
    142      1.3    chopps 	struct device	*sc_parent;	/* our parent device, or NULL */
    143      1.3    chopps 	int		sc_numports;	/* number of ports present */
    144      1.3    chopps 	u_int32_t	sc_baseclock;	/* the base operating clock */
    145      1.1  explorer 
    146      1.1  explorer 	/*
    147      1.1  explorer 	 * a callback into the parent, since the SCA chip has no control
    148      1.1  explorer 	 * over DTR, we have to make a callback into the parent, which
    149      1.1  explorer 	 * might know about DTR.
    150      1.1  explorer 	 *
    151      1.1  explorer 	 * If the function pointer is NULL, no callback is specified.
    152      1.1  explorer 	 */
    153      1.3    chopps 	void *sc_aux;
    154  1.5.2.1     skrll 	void (*sc_dtr_callback)(void *, int, int);
    155  1.5.2.1     skrll 	void (*sc_clock_callback)(void *, int, int);
    156      1.3    chopps 
    157      1.3    chopps 	/* used to read and write the device registers */
    158      1.3    chopps 	u_int8_t	(*sc_read_1)(struct sca_softc *, u_int);
    159      1.3    chopps 	u_int16_t	(*sc_read_2)(struct sca_softc *, u_int);
    160      1.3    chopps 	void		(*sc_write_1)(struct sca_softc *, u_int, u_int8_t);
    161      1.3    chopps 	void		(*sc_write_2)(struct sca_softc *, u_int, u_int16_t);
    162      1.3    chopps 
    163      1.3    chopps 	sca_port_t		sc_ports[2];
    164      1.3    chopps 
    165      1.3    chopps 	bus_space_tag_t		sc_iot;		/* io space for registers */
    166      1.3    chopps 	bus_space_handle_t	sc_ioh;		/* io space for registers */
    167      1.3    chopps 
    168      1.3    chopps 	int			sc_usedma;
    169      1.3    chopps 	union {
    170      1.3    chopps 		struct {
    171      1.5       wiz 			bus_space_tag_t	p_memt;		/* mem for non-DMA */
    172      1.5       wiz 			bus_space_handle_t p_memh;	/* mem for non-DMA */
    173      1.3    chopps 			bus_space_handle_t p_sca_ioh[16]; /* io for sca regs */
    174      1.3    chopps 			bus_size_t 	p_pagesize;	/* memory page size */
    175      1.3    chopps 			bus_size_t 	p_pagemask;	/* memory page mask */
    176      1.3    chopps 			u_int 		p_pageshift;	/* memory page shift */
    177      1.3    chopps 			bus_size_t 	p_npages;	/* num mem pages */
    178      1.3    chopps 
    179      1.3    chopps 			void	(*p_set_page)(struct sca_softc *, bus_addr_t);
    180      1.3    chopps 			void	(*p_page_on)(struct sca_softc *);
    181      1.3    chopps 			void	(*p_page_off)(struct sca_softc *);
    182      1.3    chopps 		} u_paged;
    183      1.3    chopps 		struct {
    184      1.5       wiz 			bus_dma_tag_t	d_dmat;	/* bus DMA tag */
    185      1.5       wiz 			bus_dmamap_t	d_dmam;	/* bus DMA map */
    186      1.5       wiz 			bus_dma_segment_t d_seg;	/* bus DMA segment */
    187      1.3    chopps 			caddr_t		d_dma_addr;	/* kva  of segment */
    188      1.3    chopps 			bus_size_t	d_allocsize;	/* size of region */
    189      1.3    chopps 		} u_dma;
    190      1.3    chopps 	} sc_u;
    191      1.1  explorer };
    192      1.3    chopps #define	scu_memt	sc_u.u_paged.p_memt
    193      1.3    chopps #define	scu_memh	sc_u.u_paged.p_memh
    194      1.3    chopps #define	scu_sca_ioh	sc_u.u_paged.p_sca_ioh
    195      1.3    chopps #define	scu_pagesize	sc_u.u_paged.p_pagesize
    196      1.3    chopps #define	scu_pagemask	sc_u.u_paged.p_pagemask
    197      1.3    chopps #define	scu_pageshift	sc_u.u_paged.p_pageshift
    198      1.3    chopps #define	scu_npages	sc_u.u_paged.p_npages
    199      1.3    chopps #define	scu_set_page	sc_u.u_paged.p_set_page
    200      1.3    chopps #define	scu_page_on	sc_u.u_paged.p_page_on
    201      1.3    chopps #define	scu_page_off	sc_u.u_paged.p_page_off
    202      1.3    chopps #define	scu_dmat	sc_u.u_dma.d_dmat
    203      1.3    chopps #define	scu_dmam	sc_u.u_dma.d_dmam
    204      1.3    chopps #define	scu_seg		sc_u.u_dma.d_seg
    205      1.3    chopps #define	scu_dma_addr	sc_u.u_dma.d_dma_addr
    206      1.3    chopps #define	scu_allocsize	sc_u.u_dma.d_allocsize
    207      1.1  explorer 
    208      1.3    chopps void	sca_init(struct sca_softc *);
    209      1.1  explorer void	sca_port_attach(struct sca_softc *, u_int);
    210      1.1  explorer int	sca_hardintr(struct sca_softc *);
    211      1.1  explorer void	sca_shutdown(struct sca_softc *);
    212      1.3    chopps void	sca_get_base_clock(struct sca_softc *);
    213      1.3    chopps void	sca_print_clock_info(struct sca_softc *);
    214      1.1  explorer 
    215      1.2    kleink #endif /* _DEV_IC_HD64570VAR_H_ */
    216