2 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
32 #ifndef _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_
33 #define _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_
35 #include <sys/param.h>
36 #include <sys/kernel.h>
40 #include <machine/bus.h>
41 #include <machine/resource.h>
43 #include <dev/bhnd/bhnd.h>
44 #include <dev/bhnd/bhndvar.h>
47 * Private bhnd_chipc(4) driver definitions.
54 int chipc_init_child_resource(struct resource *r,
55 struct resource *parent,
56 bhnd_size_t offset, bhnd_size_t size);
58 int chipc_set_resource(struct chipc_softc *sc,
59 device_t child, int type, int rid,
60 rman_res_t start, rman_res_t count, u_int port,
63 struct chipc_region *chipc_alloc_region(struct chipc_softc *sc,
64 bhnd_port_type type, u_int port,
66 void chipc_free_region(struct chipc_softc *sc,
67 struct chipc_region *cr);
68 struct chipc_region *chipc_find_region(struct chipc_softc *sc,
69 rman_res_t start, rman_res_t end);
70 struct chipc_region *chipc_find_region_by_rid(struct chipc_softc *sc,
73 int chipc_retain_region(struct chipc_softc *sc,
74 struct chipc_region *cr, int flags);
75 int chipc_release_region(struct chipc_softc *sc,
76 struct chipc_region *cr, int flags);
78 void chipc_print_caps(device_t dev,
79 struct chipc_caps *caps);
82 * chipc SYS_RES_MEMORY region allocation record.
85 bhnd_port_type cr_port_type; /**< bhnd port type */
86 u_int cr_port_num; /**< bhnd port number */
87 u_int cr_region_num; /**< bhnd region number */
89 bhnd_addr_t cr_addr; /**< region base address */
90 bhnd_addr_t cr_end; /**< region end address */
91 bhnd_size_t cr_count; /**< region count */
92 int cr_rid; /**< rid to use when performing
93 resource allocation, or -1
94 if region has no assigned
97 struct bhnd_resource *cr_res; /**< bus resource, or NULL */
98 int cr_res_rid; /**< cr_res RID, if any. */
99 u_int cr_refs; /**< RF_ALLOCATED refcount */
100 u_int cr_act_refs; /**< RF_ACTIVE refcount */
102 STAILQ_ENTRY(chipc_region) cr_link;
105 #endif /* _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_ */