1 /*- 2 * Copyright (c) 2015 Landon Fuller <landon@landonf.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13 * redistribution must be conditioned upon including a substantially 14 * similar Disclaimer requirement for further binary redistribution. 15 * 16 * NO WARRANTY 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * 29 * $FreeBSD$ 30 */ 31 32 #ifndef _BHND_BHNDBVAR_H_ 33 #define _BHND_BHNDBVAR_H_ 34 35 #include <sys/param.h> 36 #include <sys/bus.h> 37 #include <sys/kernel.h> 38 #include <sys/lock.h> 39 #include <sys/malloc.h> 40 #include <sys/mutex.h> 41 #include <sys/rman.h> 42 43 #include <dev/bhnd/bhndvar.h> 44 #include "bhndb.h" 45 46 #include "bhndb_if.h" 47 48 /* 49 * Definitions shared by bhndb(4) driver implementations. 50 */ 51 52 DECLARE_CLASS(bhndb_driver); 53 54 struct bhndb_resources; 55 56 int bhndb_attach(device_t dev, bhnd_devclass_t bridge_devclass); 57 58 int bhndb_generic_probe(device_t dev); 59 int bhndb_generic_detach(device_t dev); 60 int bhndb_generic_suspend(device_t dev); 61 int bhndb_generic_resume(device_t dev); 62 int bhndb_generic_init_full_config(device_t dev, device_t child, 63 const struct bhndb_hw_priority *hw_prio_table); 64 65 int bhnd_generic_br_suspend_child(device_t dev, device_t child); 66 int bhnd_generic_br_resume_child(device_t dev, device_t child); 67 68 /** 69 * bhndb child address space. Children either operate in the bridged 70 * SoC address space, or within the address space mapped to the host 71 * device (e.g. the PCI BAR(s)). 72 */ 73 typedef enum { 74 BHNDB_ADDRSPACE_BRIDGED, /**< bridged (SoC) address space */ 75 BHNDB_ADDRSPACE_NATIVE /**< host address space */ 76 } bhndb_addrspace; 77 78 /** bhndb child instance state */ 79 struct bhndb_devinfo { 80 bhndb_addrspace addrspace; /**< child address space. */ 81 struct resource_list resources; /**< child resources. */ 82 }; 83 84 /** 85 * bhndb driver instance state. Must be first member of all subclass 86 * softc structures. 87 */ 88 struct bhndb_softc { 89 device_t dev; /**< bridge device */ 90 struct bhnd_chipid chipid; /**< chip identification */ 91 bhnd_devclass_t bridge_class; /**< bridge core type */ 92 struct bhnd_core_info bridge_core; /**< bridge core. not populated until 93 * full bridge config is initialized */ 94 bool have_br_core; /**< false if not yet available */ 95 96 device_t parent_dev; /**< parent device */ 97 device_t bus_dev; /**< child bhnd(4) bus */ 98 99 struct mtx sc_mtx; /**< resource lock. */ 100 struct bhndb_resources *bus_res; /**< bus resource state */ 101 }; 102 103 #endif /* _BHND_BHNDBVAR_H_ */ 104