1098ca2bdSWarner Losh /*- 2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3*718cf2ccSPedro F. Giffuni * 477ee030bSHidetoshi Shimokawa * Copyright (c) 2003 Hidetoshi SHimokawa 53c60ba66SKatsushi Kobayashi * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi SHimokawa 63c60ba66SKatsushi Kobayashi * All rights reserved. 73c60ba66SKatsushi Kobayashi * 83c60ba66SKatsushi Kobayashi * Redistribution and use in source and binary forms, with or without 93c60ba66SKatsushi Kobayashi * modification, are permitted provided that the following conditions 103c60ba66SKatsushi Kobayashi * are met: 113c60ba66SKatsushi Kobayashi * 1. Redistributions of source code must retain the above copyright 123c60ba66SKatsushi Kobayashi * notice, this list of conditions and the following disclaimer. 133c60ba66SKatsushi Kobayashi * 2. Redistributions in binary form must reproduce the above copyright 143c60ba66SKatsushi Kobayashi * notice, this list of conditions and the following disclaimer in the 153c60ba66SKatsushi Kobayashi * documentation and/or other materials provided with the distribution. 163c60ba66SKatsushi Kobayashi * 3. All advertising materials mentioning features or use of this software 173c60ba66SKatsushi Kobayashi * must display the acknowledgement as bellow: 183c60ba66SKatsushi Kobayashi * 193c60ba66SKatsushi Kobayashi * This product includes software developed by K. Kobayashi and H. Shimokawa 203c60ba66SKatsushi Kobayashi * 213c60ba66SKatsushi Kobayashi * 4. The name of the author may not be used to endorse or promote products 223c60ba66SKatsushi Kobayashi * derived from this software without specific prior written permission. 233c60ba66SKatsushi Kobayashi * 243c60ba66SKatsushi Kobayashi * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 253c60ba66SKatsushi Kobayashi * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 263c60ba66SKatsushi Kobayashi * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 273c60ba66SKatsushi Kobayashi * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 283c60ba66SKatsushi Kobayashi * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 293c60ba66SKatsushi Kobayashi * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 303c60ba66SKatsushi Kobayashi * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 313c60ba66SKatsushi Kobayashi * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 323c60ba66SKatsushi Kobayashi * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 333c60ba66SKatsushi Kobayashi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 343c60ba66SKatsushi Kobayashi * POSSIBILITY OF SUCH DAMAGE. 353c60ba66SKatsushi Kobayashi * 363c60ba66SKatsushi Kobayashi * 373c60ba66SKatsushi Kobayashi */ 3877ee030bSHidetoshi Shimokawa 3977ee030bSHidetoshi Shimokawa #include <sys/taskqueue.h> 409950b741SHidetoshi Shimokawa 413c60ba66SKatsushi Kobayashi typedef struct fwohci_softc { 423c60ba66SKatsushi Kobayashi struct firewire_comm fc; 433c60ba66SKatsushi Kobayashi bus_space_tag_t bst; 443c60ba66SKatsushi Kobayashi bus_space_handle_t bsh; 453c60ba66SKatsushi Kobayashi void *ih; 463c60ba66SKatsushi Kobayashi struct resource *bsr; 473c60ba66SKatsushi Kobayashi struct resource *irq_res; 483c60ba66SKatsushi Kobayashi struct fwohci_dbch { 493c60ba66SKatsushi Kobayashi u_int ndb; 503c60ba66SKatsushi Kobayashi u_int ndesc; 513c60ba66SKatsushi Kobayashi STAILQ_HEAD(, fwohcidb_tr) db_trq; 523c60ba66SKatsushi Kobayashi struct fwohcidb_tr *top, *bottom, *pdb_tr; 533c60ba66SKatsushi Kobayashi struct fw_xferq xferq; 543c60ba66SKatsushi Kobayashi int flags; 551f2361f8SHidetoshi Shimokawa #define FWOHCI_DBCH_INIT (1<<0) 563c60ba66SKatsushi Kobayashi #define FWOHCI_DBCH_FULL (1<<1) 5777ee030bSHidetoshi Shimokawa /* used only in receive context */ 5877ee030bSHidetoshi Shimokawa int buf_offset; /* signed */ 59e2ad5d6eSHidetoshi Shimokawa #define FWOHCI_DBCH_MAX_PAGES 32 6077ee030bSHidetoshi Shimokawa /* Context programs buffer */ 6177ee030bSHidetoshi Shimokawa struct fwdma_alloc_multi *am; 6277ee030bSHidetoshi Shimokawa bus_dma_tag_t dmat; 63ac9f6692SHidetoshi Shimokawa } arrq, arrs, atrq, atrs, it[OHCI_DMA_ITCH], ir[OHCI_DMA_IRCH]; 643c60ba66SKatsushi Kobayashi u_int maxrec; 6503161bbcSDoug Rabson uint32_t *sid_buf; 6677ee030bSHidetoshi Shimokawa struct fwdma_alloc sid_dma; 6777ee030bSHidetoshi Shimokawa struct fwdma_alloc crom_dma; 6877ee030bSHidetoshi Shimokawa struct fwdma_alloc dummy_dma; 6903161bbcSDoug Rabson uint32_t intmask, irstat, itstat; 7003161bbcSDoug Rabson uint32_t intstat; 719950b741SHidetoshi Shimokawa struct task fwohci_task_busreset; 729950b741SHidetoshi Shimokawa struct task fwohci_task_sid; 739950b741SHidetoshi Shimokawa struct task fwohci_task_dma; 74d0581de8SHidetoshi Shimokawa int cycle_lost; 753c60ba66SKatsushi Kobayashi } fwohci_softc_t; 7677ee030bSHidetoshi Shimokawa 77d09a5d6fSHidetoshi Shimokawa void fwohci_intr (void *arg); 78d09a5d6fSHidetoshi Shimokawa int fwohci_init (struct fwohci_softc *, device_t); 79d09a5d6fSHidetoshi Shimokawa void fwohci_poll (struct firewire_comm *, int, int); 80d09a5d6fSHidetoshi Shimokawa void fwohci_reset (struct fwohci_softc *, device_t); 81d09a5d6fSHidetoshi Shimokawa int fwohci_detach (struct fwohci_softc *, device_t); 82d09a5d6fSHidetoshi Shimokawa int fwohci_resume (struct fwohci_softc *, device_t); 83d09a5d6fSHidetoshi Shimokawa int fwohci_stop (struct fwohci_softc *, device_t dev); 84