Home | History | Annotate | Line # | Download | only in ieee1394
fwohcivar.h revision 1.13
      1 /*	$NetBSD: fwohcivar.h,v 1.13 2001/05/13 05:01:43 jmc Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Matt Thomas of the 3am Software Foundry.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     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.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _DEV_IEEE1394_FWOHCIVAR_H_
     40 #define	_DEV_IEEE1394_FWOHCIVAR_H_
     41 
     42 #include <sys/mbuf.h>
     43 #include <sys/callout.h>
     44 #include <sys/queue.h>
     45 
     46 #include <machine/bus.h>
     47 
     48 #define	OHCI_PAGE_SIZE		0x0800
     49 #define	OHCI_BUF_ARRQ_CNT	16
     50 #define	OHCI_BUF_ARRS_CNT	8
     51 #define	OHCI_BUF_ATRQ_CNT	(8*8)
     52 #define	OHCI_BUF_ATRS_CNT	(8*8)
     53 #define	OHCI_BUF_IR_CNT		16
     54 #define	OHCI_BUF_CNT							\
     55 	(OHCI_BUF_ARRQ_CNT + OHCI_BUF_ARRS_CNT + OHCI_BUF_ATRQ_CNT +	\
     56 	    OHCI_BUF_ATRS_CNT + OHCI_BUF_IR_CNT + 1 + 1)
     57 
     58 #define	OHCI_LOOP		1000
     59 #define	OHCI_SELFID_TIMEOUT	(hz * 3)
     60 
     61 struct fwohci_softc;
     62 struct fwohci_pkt;
     63 
     64 struct fwohci_buf {
     65 	TAILQ_ENTRY(fwohci_buf) fb_list;
     66 	bus_dma_segment_t fb_seg;
     67 	int fb_nseg;
     68 	bus_dmamap_t fb_dmamap;
     69 	caddr_t fb_buf;
     70 	struct fwohci_desc *fb_desc;
     71 	bus_addr_t fb_daddr;
     72 	int fb_off;
     73 	struct mbuf *fb_m;
     74 	void *fb_statusarg;
     75 	void (*fb_callback)(struct device *, struct mbuf *);
     76 	int (*fb_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
     77 };
     78 
     79 struct fwohci_pkt {
     80 	int	fp_tcode;
     81 	int	fp_hlen;
     82 	int	fp_dlen;
     83 	u_int32_t fp_hdr[4];
     84 	struct uio fp_uio;
     85 	struct iovec fp_iov[6];
     86 	u_int32_t *fp_trail;
     87 	struct mbuf *fp_m;
     88 	u_int16_t fp_status;
     89 	void *fp_statusarg;
     90 	int (*fp_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
     91 	void (*fp_callback)(struct device *, struct mbuf *);
     92 };
     93 
     94 struct fwohci_handler {
     95 	LIST_ENTRY(fwohci_handler) fh_list;
     96 	u_int32_t	fh_tcode;	/* ARRQ   / ARRS   / IR   */
     97 	u_int32_t	fh_key1;	/* addrhi / srcid  / chan */
     98 	u_int32_t	fh_key2;	/* addrlo / tlabel / tag  */
     99 	int		(*fh_handler)(struct fwohci_softc *, void *,
    100 	    struct fwohci_pkt *);
    101 	void		*fh_handarg;
    102 };
    103 
    104 struct fwohci_ctx {
    105 	int	fc_ctx;
    106 	int	fc_isoch;
    107 	int	fc_bufcnt;
    108 	u_int32_t	*fc_branch;
    109 	TAILQ_HEAD(fwohci_buf_s, fwohci_buf) fc_buf;
    110 	LIST_HEAD(, fwohci_handler) fc_handler;
    111 };
    112 
    113 struct fwohci_uidtbl {
    114 	int		fu_valid;
    115 	u_int8_t	fu_uid[8];
    116 };
    117 
    118 struct fwohci_softc {
    119 	struct ieee1394_softc sc_sc1394;
    120 	struct evcnt sc_intrcnt;
    121 
    122 	bus_space_tag_t sc_memt;
    123 	bus_space_handle_t sc_memh;
    124 	bus_dma_tag_t sc_dmat;
    125 	bus_size_t sc_memsize;
    126 #if 0
    127 
    128 /* Mandatory structures to get the link enabled
    129  */
    130 	bus_dmamap_t sc_configrom_map;
    131 	bus_dmamap_t sc_selfid_map;
    132 	u_int32_t *sc_selfid_buf;
    133 	u_int32_t *sc_configrom;
    134 #endif
    135 
    136 	bus_dma_segment_t sc_dseg;
    137 	int sc_dnseg;
    138 	bus_dmamap_t sc_ddmamap;
    139 	struct fwohci_desc *sc_desc;
    140 	u_int8_t *sc_descmap;
    141 	int sc_descsize;
    142 	int sc_isoctx;
    143 
    144 	void *sc_shutdownhook;
    145 	void *sc_powerhook;
    146 	struct callout sc_selfid_callout;
    147 	int sc_selfid_fail;
    148 
    149 	struct fwohci_ctx *sc_ctx_arrq;
    150 	struct fwohci_ctx *sc_ctx_arrs;
    151 	struct fwohci_ctx *sc_ctx_atrq;
    152 	struct fwohci_ctx *sc_ctx_atrs;
    153 	struct fwohci_ctx **sc_ctx_ir;
    154 	struct fwohci_buf sc_buf_cnfrom;
    155 	struct fwohci_buf sc_buf_selfid;
    156 
    157 	struct proc *sc_event_thread;
    158 
    159 	int sc_dying;
    160 	u_int32_t sc_intmask;
    161 	u_int32_t sc_iso;
    162 
    163 	u_int8_t sc_csr[CSR_SB_END];
    164 
    165 	struct fwohci_uidtbl *sc_uidtbl;
    166 	u_int16_t sc_nodeid;			/* Full Node ID of this node */
    167 	u_int8_t sc_rootid;			/* Phy ID of Root */
    168 	u_int8_t sc_irmid;			/* Phy ID of IRM */
    169 	u_int8_t sc_tlabel;			/* Transaction Label */
    170 
    171 	LIST_HEAD(, ieee1394_softc) sc_nodelist;
    172 };
    173 
    174 int fwohci_init (struct fwohci_softc *, const struct evcnt *);
    175 int fwohci_intr (void *);
    176 int fwohci_print (void *, const char *);
    177 
    178 /* Macros to read and write the OHCI registers
    179  */
    180 #define	OHCI_CSR_WRITE(sc, reg, val) \
    181 	bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, htole32(val))
    182 #define	OHCI_CSR_READ(sc, reg) \
    183 	le32toh(bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg))
    184 
    185 /* Locators. */
    186 
    187 #include "locators.h"
    188 
    189 #define fwbuscf_idhi cf_loc[FWBUSCF_IDHI]
    190 #define FWBUS_UNK_IDHI FWBUSCF_IDHI_DEFAULT
    191 
    192 #define fwbuscf_idlo cf_loc[FWBUSCF_IDLO]
    193 #define FWBUS_UNK_IDLO FWBUSCF_IDLO_DEFAULT
    194 
    195 #endif	/* _DEV_IEEE1394_FWOHCIVAR_H_ */
    196