]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/cores/chipc/chipc_private.h
MFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / cores / chipc / chipc_private.h
1 /*-
2  * Copyright (c) 2015-2016 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_CORES_CHIPC_CHIPC_PRIVATE_H_
33 #define _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_
34
35 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/bus.h>
38 #include <sys/rman.h>
39
40 #include <machine/bus.h>
41 #include <machine/resource.h>
42
43 #include <dev/bhnd/bhnd.h>
44 #include <dev/bhnd/bhndvar.h>
45
46 /*
47  * Private bhnd_chipc(4) driver definitions.
48  */
49
50 struct chipc_caps;
51 struct chipc_region;
52 struct chipc_softc;
53
54 int                      chipc_init_child_resource(struct resource *r,
55                              struct resource *parent, 
56                              bhnd_size_t offset, bhnd_size_t size);
57
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,
61                              u_int region);
62
63 struct chipc_region     *chipc_alloc_region(struct chipc_softc *sc,
64                              bhnd_port_type type, u_int port,
65                              u_int region);
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,
71                              int rid);
72
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);
77
78 void                     chipc_print_caps(device_t dev,
79                              struct chipc_caps *caps);
80
81 /**
82  * chipc SYS_RES_MEMORY region allocation record.
83  */
84 struct chipc_region {
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 */
88
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
95                                                      resource ID */
96
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 */
101
102         STAILQ_ENTRY(chipc_region) cr_link;
103 };
104
105 #endif /* _BHND_CORES_CHIPC_CHIPC_PRIVATE_H_ */