1*cce19cc2Sjmcneill /* $NetBSD: mvpexvar.h,v 1.7 2018/11/16 15:06:23 jmcneill Exp $ */ 2f99b65b3Skiyohara /* 3f99b65b3Skiyohara * Copyright (c) 2009 KIYOHARA Takashi 4f99b65b3Skiyohara * All rights reserved. 5f99b65b3Skiyohara * 6f99b65b3Skiyohara * Redistribution and use in source and binary forms, with or without 7f99b65b3Skiyohara * modification, are permitted provided that the following conditions 8f99b65b3Skiyohara * are met: 9f99b65b3Skiyohara * 1. Redistributions of source code must retain the above copyright 10f99b65b3Skiyohara * notice, this list of conditions and the following disclaimer. 11f99b65b3Skiyohara * 2. Redistributions in binary form must reproduce the above copyright 12f99b65b3Skiyohara * notice, this list of conditions and the following disclaimer in the 13f99b65b3Skiyohara * documentation and/or other materials provided with the distribution. 14f99b65b3Skiyohara * 15f99b65b3Skiyohara * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16f99b65b3Skiyohara * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17f99b65b3Skiyohara * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18f99b65b3Skiyohara * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 19f99b65b3Skiyohara * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20f99b65b3Skiyohara * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21f99b65b3Skiyohara * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22f99b65b3Skiyohara * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 23f99b65b3Skiyohara * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 24f99b65b3Skiyohara * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25f99b65b3Skiyohara * POSSIBILITY OF SUCH DAMAGE. 26f99b65b3Skiyohara */ 27f99b65b3Skiyohara 28f99b65b3Skiyohara #ifndef _MVPEXVAR_H_ 29f99b65b3Skiyohara #define _MVPEXVAR_H_ 30f99b65b3Skiyohara 31c51a6569Skiyohara extern enum marvell_tags *mvpex_bar2_tags; 32c51a6569Skiyohara 33f99b65b3Skiyohara struct mvpex_intrhand { 34f99b65b3Skiyohara LIST_ENTRY(mvpex_intrhand) ih_q; 35f99b65b3Skiyohara int (*ih_func)(void *); 36f99b65b3Skiyohara void *ih_arg; 37f99b65b3Skiyohara int ih_type; 38f99b65b3Skiyohara 39f99b65b3Skiyohara void *ih_intrtab; 40f99b65b3Skiyohara 411770f95fSknakahara char ih_evname[PCI_INTRSTR_LEN]; 42f99b65b3Skiyohara struct evcnt ih_evcnt; 43f99b65b3Skiyohara }; 44f99b65b3Skiyohara 45f99b65b3Skiyohara struct mvpex_intrtab { 46f99b65b3Skiyohara int intr_pin; 47f99b65b3Skiyohara int intr_refcnt; 48f99b65b3Skiyohara LIST_HEAD(, mvpex_intrhand) intr_list; 49f99b65b3Skiyohara }; 50f99b65b3Skiyohara 51f99b65b3Skiyohara struct mvpex_softc { 52f99b65b3Skiyohara device_t sc_dev; 53f99b65b3Skiyohara 54f99b65b3Skiyohara int sc_model; 55f99b65b3Skiyohara int sc_rev; 56f99b65b3Skiyohara 57f99b65b3Skiyohara bus_size_t sc_offset; 58f99b65b3Skiyohara bus_space_tag_t sc_iot; 59f99b65b3Skiyohara bus_space_handle_t sc_ioh; 60f99b65b3Skiyohara 61f99b65b3Skiyohara struct mvpex_intrtab sc_intrtab[PCI_INTERRUPT_PIN_MAX]; 62f99b65b3Skiyohara }; 63f99b65b3Skiyohara 64f99b65b3Skiyohara #if NPCI > 0 65f99b65b3Skiyohara void mvpex_attach_hook(device_t, device_t, struct pcibus_attach_args *); 66f99b65b3Skiyohara int mvpex_bus_maxdevs(void *, int); 67f99b65b3Skiyohara pcitag_t mvpex_make_tag(void *, int, int, int); 68f99b65b3Skiyohara void mvpex_decompose_tag(void *, pcitag_t, int *, int *, int *); 69f99b65b3Skiyohara pcireg_t mvpex_conf_read(void *, pcitag_t, int); 70f99b65b3Skiyohara void mvpex_conf_write(void *, pcitag_t, int, pcireg_t); 71a8140c3aSmatt int mvpex_conf_hook(void *, int, int, int, pcireg_t); 72a8140c3aSmatt void mvpex_conf_interrupt(void *, int, int, int, int, int *); 73d3e53912Sdyoung int mvpex_intr_map(const struct pci_attach_args *, pci_intr_handle_t *); 74070dd9a4Schristos const char *mvpex_intr_string(void *, pci_intr_handle_t, char *, size_t); 75f99b65b3Skiyohara const struct evcnt *mvpex_intr_evcnt(void *, pci_intr_handle_t); 76f99b65b3Skiyohara void *mvpex_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *), 77*cce19cc2Sjmcneill void *, const char *); 78f99b65b3Skiyohara void mvpex_intr_disestablish(void *, void *); 79f99b65b3Skiyohara #endif 80f99b65b3Skiyohara 81f99b65b3Skiyohara #endif /* _MVPEXVAR_H_ */ 82