xref: /freebsd/sys/dev/bhnd/bhndb/bhndbvar.h (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
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 /** bhndb child instance state */
69 struct bhndb_devinfo {
70         struct resource_list    resources;	/**< child resources. */
71 };
72 
73 /**
74  * bhndb driver instance state. Must be first member of all subclass
75  * softc structures.
76  */
77 struct bhndb_softc {
78 	device_t			 dev;		/**< bridge device */
79 	struct bhnd_chipid		 chipid;	/**< chip identification */
80 	bhnd_devclass_t			 bridge_class;	/**< bridge core type */
81 
82 	device_t			 parent_dev;	/**< parent device */
83 	device_t			 bus_dev;	/**< child bhnd(4) bus */
84 	device_t			 hostb_dev;	/**< child host bridge device, or NULL
85 							     if the @p bus_dev has not yet
86 							     called BHNDB_INIT_FULL_CONFIG() */
87 
88 	struct rman			 mem_rman;	/**< bridged bus memory manager */
89 	struct mtx			 sc_mtx;	/**< resource lock. */
90 
91 	struct bhndb_resources		*bus_res;	/**< bus resource state */
92 };
93 
94 #endif /* _BHND_BHNDBVAR_H_ */
95