]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/siba/sibavar.h
siba(4): Adopt bcma-compatible mapping of bhnd(4) port/region identifiers.
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / siba / sibavar.h
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 _SIBA_SIBAVAR_H_
33 #define _SIBA_SIBAVAR_H_
34
35 #include <sys/param.h>
36 #include <sys/bus.h>
37 #include <sys/limits.h>
38
39 #include <machine/bus.h>
40 #include <sys/rman.h>
41
42 #include "siba.h"
43
44 /*
45  * Internal definitions shared by siba(4) driver implementations.
46  */
47
48 struct siba_addrspace;
49 struct siba_devinfo;
50 struct siba_core_id;
51
52 int                      siba_probe(device_t dev);
53 int                      siba_attach(device_t dev);
54 int                      siba_detach(device_t dev);
55 int                      siba_resume(device_t dev);
56 int                      siba_suspend(device_t dev);
57
58 uint16_t                 siba_get_bhnd_mfgid(uint16_t ocp_vendor);
59
60 struct siba_core_id      siba_parse_core_id(uint32_t idhigh, uint32_t idlow,
61                              u_int core_idx, int unit);
62
63 int                      siba_add_children(device_t bus,
64                              const struct bhnd_chipid *chipid);
65
66 struct siba_devinfo     *siba_alloc_dinfo(device_t dev,
67                              const struct siba_core_id *core_id);
68 void                     siba_free_dinfo(device_t dev,
69                              struct siba_devinfo *dinfo);
70
71 u_int                    siba_addrspace_port_count(struct siba_devinfo *dinfo);
72 u_int                    siba_addrspace_region_count(struct siba_devinfo *dinfo,
73                              u_int port);
74
75 u_int                    siba_addrspace_port(u_int addrspace);
76 u_int                    siba_addrspace_region(u_int addrspace);
77
78 bool                     siba_is_port_valid(struct siba_devinfo *dinfo,
79                              bhnd_port_type type, u_int port);
80
81 struct siba_addrspace   *siba_find_addrspace(struct siba_devinfo *dinfo,
82                              bhnd_port_type type, u_int port, u_int region);
83
84 int                      siba_append_dinfo_region(struct siba_devinfo *dinfo,
85                              uint8_t sid, uint32_t base, uint32_t size,
86                              uint32_t bus_reserved);
87
88 u_int                    siba_admatch_offset(uint8_t addrspace);
89 int                      siba_parse_admatch(uint32_t am, uint32_t *addr,
90                              uint32_t *size);
91
92                                                              
93 /* Sonics configuration register blocks */
94 #define SIBA_CFG_NUM_2_2        1                       /**< sonics <= 2.2 maps SIBA_CFG0. */
95 #define SIBA_CFG_NUM_2_3        2                       /**< sonics <= 2.3 maps SIBA_CFG0 and SIBA_CFG1 */
96 #define SIBA_MAX_CFG            SIBA_CFG_NUM_2_3        /**< maximum number of supported config
97                                                              register blocks */
98
99 /* Sonics/OCP address space mappings */
100 #define SIBA_CORE_ADDRSPACE     0       /**< Address space mapping the primary
101                                              device registers */
102
103 #define SIBA_MAX_ADDRSPACE      4       /**< Maximum number of Sonics/OCP
104                                           *  address space mappings for a
105                                           *  single core. */
106
107 /* bhnd(4) (port,region) representation of siba address space mappings */
108 #define SIBA_MAX_PORT           2       /**< maximum number of advertised
109                                           *  bhnd(4) ports */
110
111 /** siba(4) address space descriptor */
112 struct siba_addrspace {
113         uint32_t        sa_base;        /**< base address */
114         uint32_t        sa_size;        /**< size */
115         int             sa_rid;         /**< bus resource id */
116         uint32_t        sa_bus_reserved;/**< number of bytes at high end of
117                                           *  address space reserved for the bus */
118 };
119
120 /**
121  * siba(4) per-core identification info.
122  */
123 struct siba_core_id {
124         struct bhnd_core_info   core_info;      /**< standard bhnd(4) core info */
125         uint16_t                sonics_vendor;  /**< OCP vendor identifier used to generate
126                                                   *  the JEDEC-106 bhnd(4) vendor identifier. */
127         uint8_t                 sonics_rev;     /**< sonics backplane revision code */
128         uint8_t                 num_addrspace;  /**< number of address ranges mapped to
129                                                      this core. */
130         uint8_t                 num_cfg_blocks; /**< number of Sonics configuration register
131                                                      blocks mapped to the core's enumeration
132                                                      space */
133 };
134
135 /**
136  * siba(4) per-device info
137  */
138 struct siba_devinfo {
139         struct resource_list     resources;     /**< per-core memory regions. */
140         struct siba_core_id      core_id;       /**< core identification info */
141         struct siba_addrspace    addrspace[SIBA_MAX_ADDRSPACE]; /**< memory map descriptors */
142
143         struct bhnd_resource    *cfg[SIBA_MAX_CFG];     /**< SIBA_CFG_* registers */
144         int                      cfg_rid[SIBA_MAX_CFG]; /**< SIBA_CFG_* resource IDs */
145 };
146
147
148 /** siba(4) per-instance state */
149 struct siba_softc {
150         struct bhnd_softc       bhnd_sc;        /**< bhnd state */
151         device_t                dev;            /**< siba device */
152         device_t                hostb_dev;      /**< host bridge core, or NULL */
153 };
154
155 #endif /* _SIBA_SIBAVAR_H_ */