1139749Simp/*- 2113584Ssimokawa * Copyright (c) 2003 Hidetoshi SHimokawa 3103285Sikob * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi SHimokawa 4103285Sikob * All rights reserved. 5103285Sikob * 6103285Sikob * Redistribution and use in source and binary forms, with or without 7103285Sikob * modification, are permitted provided that the following conditions 8103285Sikob * are met: 9103285Sikob * 1. Redistributions of source code must retain the above copyright 10103285Sikob * notice, this list of conditions and the following disclaimer. 11103285Sikob * 2. Redistributions in binary form must reproduce the above copyright 12103285Sikob * notice, this list of conditions and the following disclaimer in the 13103285Sikob * documentation and/or other materials provided with the distribution. 14103285Sikob * 3. All advertising materials mentioning features or use of this software 15103285Sikob * must display the acknowledgement as bellow: 16103285Sikob * 17103285Sikob * This product includes software developed by K. Kobayashi and H. Shimokawa 18103285Sikob * 19103285Sikob * 4. The name of the author may not be used to endorse or promote products 20103285Sikob * derived from this software without specific prior written permission. 21103285Sikob * 22103285Sikob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23103285Sikob * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24103285Sikob * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25103285Sikob * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 26103285Sikob * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27103285Sikob * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28103285Sikob * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29103285Sikob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30103285Sikob * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31103285Sikob * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32103285Sikob * POSSIBILITY OF SUCH DAMAGE. 33103285Sikob * 34103285Sikob * $FreeBSD$ 35103285Sikob * 36103285Sikob */ 37113584Ssimokawa 38170374Ssimokawa#include <sys/taskqueue.h> 39170374Ssimokawa 40103285Sikobtypedef struct fwohci_softc { 41103285Sikob struct firewire_comm fc; 42103285Sikob bus_space_tag_t bst; 43103285Sikob bus_space_handle_t bsh; 44103285Sikob void *ih; 45103285Sikob struct resource *bsr; 46103285Sikob struct resource *irq_res; 47272214Skan struct fwohci_dbch { 48103285Sikob u_int ndb; 49103285Sikob u_int ndesc; 50103285Sikob STAILQ_HEAD(, fwohcidb_tr) db_trq; 51103285Sikob struct fwohcidb_tr *top, *bottom, *pdb_tr; 52103285Sikob struct fw_xferq xferq; 53103285Sikob int flags; 54108527Ssimokawa#define FWOHCI_DBCH_INIT (1<<0) 55103285Sikob#define FWOHCI_DBCH_FULL (1<<1) 56113584Ssimokawa /* used only in receive context */ 57113584Ssimokawa int buf_offset; /* signed */ 58109379Ssimokawa#define FWOHCI_DBCH_MAX_PAGES 32 59113584Ssimokawa /* Context programs buffer */ 60113584Ssimokawa struct fwdma_alloc_multi *am; 61113584Ssimokawa bus_dma_tag_t dmat; 62108276Ssimokawa } arrq, arrs, atrq, atrs, it[OHCI_DMA_ITCH], ir[OHCI_DMA_IRCH]; 63103285Sikob u_int maxrec; 64129585Sdfr uint32_t *sid_buf; 65113584Ssimokawa struct fwdma_alloc sid_dma; 66113584Ssimokawa struct fwdma_alloc crom_dma; 67113584Ssimokawa struct fwdma_alloc dummy_dma; 68129585Sdfr uint32_t intmask, irstat, itstat; 69129585Sdfr uint32_t intstat; 70170374Ssimokawa struct task fwohci_task_busreset; 71170374Ssimokawa struct task fwohci_task_sid; 72170374Ssimokawa struct task fwohci_task_dma; 73167628Ssimokawa int cycle_lost; 74103285Sikob} fwohci_softc_t; 75113584Ssimokawa 76124169Ssimokawavoid fwohci_intr (void *arg); 77124169Ssimokawaint fwohci_init (struct fwohci_softc *, device_t); 78124169Ssimokawavoid fwohci_poll (struct firewire_comm *, int, int); 79124169Ssimokawavoid fwohci_reset (struct fwohci_softc *, device_t); 80124169Ssimokawaint fwohci_detach (struct fwohci_softc *, device_t); 81124169Ssimokawaint fwohci_resume (struct fwohci_softc *, device_t); 82124169Ssimokawaint fwohci_stop (struct fwohci_softc *, device_t dev); 83