2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
5 * Copyright (c) 2017 The FreeBSD Foundation
8 * Portions of this software were developed by Landon Fuller
9 * under sponsorship from the FreeBSD Foundation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
19 * redistribution must be conditioned upon including a substantially
20 * similar Disclaimer requirement for further binary redistribution.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
26 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
28 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGES.
38 #ifndef _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_
39 #define _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_
41 #include <sys/param.h>
42 #include <sys/kernel.h>
46 #include <machine/bus.h>
47 #include <machine/resource.h>
49 #include <dev/bhnd/bhnd.h>
50 #include <dev/bhnd/bhndvar.h>
53 * Private bhnd_chipc(4) driver definitions.
60 int chipc_init_child_resource(struct resource *r,
61 struct resource *parent,
62 bhnd_size_t offset, bhnd_size_t size);
64 int chipc_set_irq_resource(struct chipc_softc *sc,
65 device_t child, int rid, u_int intr);
66 int chipc_set_mem_resource(struct chipc_softc *sc,
67 device_t child, int rid, rman_res_t start,
68 rman_res_t count, u_int port, u_int region);
70 struct chipc_region *chipc_alloc_region(struct chipc_softc *sc,
71 bhnd_port_type type, u_int port,
73 void chipc_free_region(struct chipc_softc *sc,
74 struct chipc_region *cr);
75 struct chipc_region *chipc_find_region(struct chipc_softc *sc,
76 rman_res_t start, rman_res_t end);
77 struct chipc_region *chipc_find_region_by_rid(struct chipc_softc *sc,
80 int chipc_retain_region(struct chipc_softc *sc,
81 struct chipc_region *cr, int flags);
82 int chipc_release_region(struct chipc_softc *sc,
83 struct chipc_region *cr, int flags);
85 void chipc_print_caps(device_t dev,
86 struct chipc_caps *caps);
89 * chipc SYS_RES_MEMORY region allocation record.
92 bhnd_port_type cr_port_type; /**< bhnd port type */
93 u_int cr_port_num; /**< bhnd port number */
94 u_int cr_region_num; /**< bhnd region number */
96 bhnd_addr_t cr_addr; /**< region base address */
97 bhnd_addr_t cr_end; /**< region end address */
98 bhnd_size_t cr_count; /**< region count */
99 int cr_rid; /**< rid to use when performing
100 resource allocation, or -1
101 if region has no assigned
104 struct bhnd_resource *cr_res; /**< bus resource, or NULL */
105 int cr_res_rid; /**< cr_res RID, if any. */
106 u_int cr_refs; /**< RF_ALLOCATED refcount */
107 u_int cr_act_refs; /**< RF_ACTIVE refcount */
109 STAILQ_ENTRY(chipc_region) cr_link;
112 #endif /* _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_ */