2001-05-15 10:52:30 +04:00
|
|
|
/* $NetBSD: fwohcivar.h,v 1.14 2001/05/15 06:52:31 jmc Exp $ */
|
2000-12-13 14:30:14 +03:00
|
|
|
|
2000-05-30 10:56:13 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Matt Thomas of the 3am Software Foundry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DEV_IEEE1394_FWOHCIVAR_H_
|
|
|
|
#define _DEV_IEEE1394_FWOHCIVAR_H_
|
|
|
|
|
2000-11-08 09:00:18 +03:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
#define OHCI_PAGE_SIZE 0x0800
|
|
|
|
#define OHCI_BUF_ARRQ_CNT 16
|
|
|
|
#define OHCI_BUF_ARRS_CNT 8
|
|
|
|
#define OHCI_BUF_ATRQ_CNT (8*8)
|
|
|
|
#define OHCI_BUF_ATRS_CNT (8*8)
|
|
|
|
#define OHCI_BUF_IR_CNT 16
|
2001-05-01 10:15:42 +04:00
|
|
|
#define OHCI_BUF_CNT \
|
|
|
|
(OHCI_BUF_ARRQ_CNT + OHCI_BUF_ARRS_CNT + OHCI_BUF_ATRQ_CNT + \
|
|
|
|
OHCI_BUF_ATRS_CNT + OHCI_BUF_IR_CNT + 1 + 1)
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
#define OHCI_LOOP 1000
|
2000-11-08 09:00:18 +03:00
|
|
|
#define OHCI_SELFID_TIMEOUT (hz * 3)
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
struct fwohci_softc;
|
2001-05-11 10:06:03 +04:00
|
|
|
struct fwohci_pkt;
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
struct fwohci_buf {
|
|
|
|
TAILQ_ENTRY(fwohci_buf) fb_list;
|
|
|
|
bus_dma_segment_t fb_seg;
|
|
|
|
int fb_nseg;
|
|
|
|
bus_dmamap_t fb_dmamap;
|
|
|
|
caddr_t fb_buf;
|
|
|
|
struct fwohci_desc *fb_desc;
|
|
|
|
bus_addr_t fb_daddr;
|
|
|
|
int fb_off;
|
|
|
|
struct mbuf *fb_m;
|
2001-05-11 10:06:03 +04:00
|
|
|
void *fb_statusarg;
|
2000-11-05 20:17:12 +03:00
|
|
|
void (*fb_callback)(struct device *, struct mbuf *);
|
2001-05-11 10:06:03 +04:00
|
|
|
int (*fb_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
|
2000-11-05 20:17:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fwohci_pkt {
|
|
|
|
int fp_tcode;
|
|
|
|
int fp_hlen;
|
|
|
|
int fp_dlen;
|
|
|
|
u_int32_t fp_hdr[4];
|
2000-11-20 15:12:18 +03:00
|
|
|
struct uio fp_uio;
|
|
|
|
struct iovec fp_iov[6];
|
2000-11-05 20:17:12 +03:00
|
|
|
u_int32_t *fp_trail;
|
2001-05-01 10:15:42 +04:00
|
|
|
struct mbuf *fp_m;
|
2001-05-11 10:06:03 +04:00
|
|
|
u_int16_t fp_status;
|
|
|
|
void *fp_statusarg;
|
|
|
|
int (*fp_statuscb)(struct fwohci_softc *, void *, struct fwohci_pkt *);
|
2000-11-05 20:17:12 +03:00
|
|
|
void (*fp_callback)(struct device *, struct mbuf *);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fwohci_handler {
|
|
|
|
LIST_ENTRY(fwohci_handler) fh_list;
|
|
|
|
u_int32_t fh_tcode; /* ARRQ / ARRS / IR */
|
|
|
|
u_int32_t fh_key1; /* addrhi / srcid / chan */
|
|
|
|
u_int32_t fh_key2; /* addrlo / tlabel / tag */
|
|
|
|
int (*fh_handler)(struct fwohci_softc *, void *,
|
2001-05-03 08:37:43 +04:00
|
|
|
struct fwohci_pkt *);
|
2000-11-05 20:17:12 +03:00
|
|
|
void *fh_handarg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fwohci_ctx {
|
|
|
|
int fc_ctx;
|
2000-11-20 15:12:18 +03:00
|
|
|
int fc_isoch;
|
2000-11-05 20:17:12 +03:00
|
|
|
int fc_bufcnt;
|
|
|
|
u_int32_t *fc_branch;
|
2000-11-20 15:12:18 +03:00
|
|
|
TAILQ_HEAD(fwohci_buf_s, fwohci_buf) fc_buf;
|
2000-11-05 20:17:12 +03:00
|
|
|
LIST_HEAD(, fwohci_handler) fc_handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fwohci_uidtbl {
|
2000-11-14 14:14:55 +03:00
|
|
|
int fu_valid;
|
|
|
|
u_int8_t fu_uid[8];
|
2000-11-05 20:17:12 +03:00
|
|
|
};
|
|
|
|
|
2001-05-15 10:52:30 +04:00
|
|
|
/*
|
|
|
|
* Needed to keep track of outstanding packets during a read op. Since the
|
|
|
|
* packet stream is asynch it's possible to parse a response packet before the
|
|
|
|
* ack bits are processed. In this case something needs to track whether the
|
|
|
|
* abuf is still valid before possibly attempting to use items from within it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct fwohci_cb {
|
|
|
|
struct ieee1394_abuf *ab;
|
|
|
|
int count;
|
|
|
|
int abuf_valid;
|
|
|
|
};
|
|
|
|
|
2000-05-30 10:56:13 +04:00
|
|
|
struct fwohci_softc {
|
|
|
|
struct ieee1394_softc sc_sc1394;
|
2000-11-06 01:35:56 +03:00
|
|
|
struct evcnt sc_intrcnt;
|
2000-05-30 10:56:13 +04:00
|
|
|
|
|
|
|
bus_space_tag_t sc_memt;
|
|
|
|
bus_space_handle_t sc_memh;
|
|
|
|
bus_dma_tag_t sc_dmat;
|
|
|
|
bus_size_t sc_memsize;
|
2000-11-06 01:35:56 +03:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
/* Mandatory structures to get the link enabled
|
|
|
|
*/
|
|
|
|
bus_dmamap_t sc_configrom_map;
|
|
|
|
bus_dmamap_t sc_selfid_map;
|
|
|
|
u_int32_t *sc_selfid_buf;
|
|
|
|
u_int32_t *sc_configrom;
|
|
|
|
#endif
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
bus_dma_segment_t sc_dseg;
|
|
|
|
int sc_dnseg;
|
|
|
|
bus_dmamap_t sc_ddmamap;
|
2000-11-08 09:00:18 +03:00
|
|
|
struct fwohci_desc *sc_desc;
|
2000-11-20 15:12:18 +03:00
|
|
|
u_int8_t *sc_descmap;
|
2000-11-05 20:17:12 +03:00
|
|
|
int sc_descsize;
|
|
|
|
int sc_isoctx;
|
2000-11-08 09:00:18 +03:00
|
|
|
|
|
|
|
void *sc_shutdownhook;
|
|
|
|
void *sc_powerhook;
|
|
|
|
struct callout sc_selfid_callout;
|
2000-11-20 15:12:18 +03:00
|
|
|
int sc_selfid_fail;
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
struct fwohci_ctx *sc_ctx_arrq;
|
|
|
|
struct fwohci_ctx *sc_ctx_arrs;
|
|
|
|
struct fwohci_ctx *sc_ctx_atrq;
|
|
|
|
struct fwohci_ctx *sc_ctx_atrs;
|
|
|
|
struct fwohci_ctx **sc_ctx_ir;
|
|
|
|
struct fwohci_buf sc_buf_cnfrom;
|
|
|
|
struct fwohci_buf sc_buf_selfid;
|
|
|
|
|
2001-05-01 10:15:42 +04:00
|
|
|
struct proc *sc_event_thread;
|
|
|
|
|
|
|
|
int sc_dying;
|
|
|
|
u_int32_t sc_intmask;
|
|
|
|
u_int32_t sc_iso;
|
2001-05-01 08:48:10 +04:00
|
|
|
|
2001-05-01 10:15:42 +04:00
|
|
|
u_int8_t sc_csr[CSR_SB_END];
|
2000-11-05 20:17:12 +03:00
|
|
|
|
|
|
|
struct fwohci_uidtbl *sc_uidtbl;
|
2000-11-08 09:00:18 +03:00
|
|
|
u_int16_t sc_nodeid; /* Full Node ID of this node */
|
|
|
|
u_int8_t sc_rootid; /* Phy ID of Root */
|
|
|
|
u_int8_t sc_irmid; /* Phy ID of IRM */
|
|
|
|
u_int8_t sc_tlabel; /* Transaction Label */
|
2001-05-03 08:37:43 +04:00
|
|
|
|
2001-05-01 08:48:10 +04:00
|
|
|
LIST_HEAD(, ieee1394_softc) sc_nodelist;
|
2000-05-30 10:56:13 +04:00
|
|
|
};
|
|
|
|
|
2000-11-06 01:35:56 +03:00
|
|
|
int fwohci_init (struct fwohci_softc *, const struct evcnt *);
|
|
|
|
int fwohci_intr (void *);
|
|
|
|
int fwohci_print (void *, const char *);
|
2000-05-30 10:56:13 +04:00
|
|
|
|
|
|
|
/* Macros to read and write the OHCI registers
|
|
|
|
*/
|
2001-03-16 02:01:33 +03:00
|
|
|
#define OHCI_CSR_WRITE(sc, reg, val) \
|
|
|
|
bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, htole32(val))
|
|
|
|
#define OHCI_CSR_READ(sc, reg) \
|
|
|
|
le32toh(bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg))
|
2000-05-30 10:56:13 +04:00
|
|
|
|
2001-05-13 09:01:42 +04:00
|
|
|
/* Locators. */
|
|
|
|
|
|
|
|
#include "locators.h"
|
|
|
|
|
|
|
|
#define fwbuscf_idhi cf_loc[FWBUSCF_IDHI]
|
|
|
|
#define FWBUS_UNK_IDHI FWBUSCF_IDHI_DEFAULT
|
|
|
|
|
|
|
|
#define fwbuscf_idlo cf_loc[FWBUSCF_IDLO]
|
|
|
|
#define FWBUS_UNK_IDLO FWBUSCF_IDLO_DEFAULT
|
|
|
|
|
2000-05-30 10:56:13 +04:00
|
|
|
#endif /* _DEV_IEEE1394_FWOHCIVAR_H_ */
|