Deleted Added
full compact
ahc_pci.c (232882) ahc_pci.c (254263)
1/*-
2 * FreeBSD, PCI product support functions
3 *
4 * Copyright (c) 1995-2001 Justin T. Gibbs
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 18 unchanged lines hidden (view full) ---

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#19 $
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * FreeBSD, PCI product support functions
3 *
4 * Copyright (c) 1995-2001 Justin T. Gibbs
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 18 unchanged lines hidden (view full) ---

27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#19 $
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/aic7xxx/ahc_pci.c 232882 2012-03-12 19:29:32Z jmallett $");
35__FBSDID("$FreeBSD: head/sys/dev/aic7xxx/ahc_pci.c 254263 2013-08-12 23:30:01Z scottl $");
36
37#include <dev/aic7xxx/aic7xxx_osm.h>
38
39static int ahc_pci_probe(device_t dev);
40static int ahc_pci_attach(device_t dev);
41
42static device_method_t ahc_pci_device_methods[] = {
43 /* Device interface */

--- 90 unchanged lines hidden (view full) ---

134 ahc_attach(ahc);
135 return (0);
136}
137
138int
139ahc_pci_map_registers(struct ahc_softc *ahc)
140{
141 struct resource *regs;
36
37#include <dev/aic7xxx/aic7xxx_osm.h>
38
39static int ahc_pci_probe(device_t dev);
40static int ahc_pci_attach(device_t dev);
41
42static device_method_t ahc_pci_device_methods[] = {
43 /* Device interface */

--- 90 unchanged lines hidden (view full) ---

134 ahc_attach(ahc);
135 return (0);
136}
137
138int
139ahc_pci_map_registers(struct ahc_softc *ahc)
140{
141 struct resource *regs;
142 u_int command;
143 int regs_type;
144 int regs_id;
145 int allow_memio;
146
142 int regs_type;
143 int regs_id;
144 int allow_memio;
145
147 command = aic_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
148 regs = NULL;
149 regs_type = 0;
150 regs_id = 0;
151
152 /* Retrieve the per-device 'allow_memio' hint */
153 if (resource_int_value(device_get_name(ahc->dev_softc),
154 device_get_unit(ahc->dev_softc),
155 "allow_memio", &allow_memio) != 0) {

--- 5 unchanged lines hidden (view full) ---

161 allow_memio = 1;
162#else
163 if (bootverbose)
164 printf("off\n");
165 allow_memio = 0;
166#endif
167 }
168
146 regs = NULL;
147 regs_type = 0;
148 regs_id = 0;
149
150 /* Retrieve the per-device 'allow_memio' hint */
151 if (resource_int_value(device_get_name(ahc->dev_softc),
152 device_get_unit(ahc->dev_softc),
153 "allow_memio", &allow_memio) != 0) {

--- 5 unchanged lines hidden (view full) ---

159 allow_memio = 1;
160#else
161 if (bootverbose)
162 printf("off\n");
163 allow_memio = 0;
164#endif
165 }
166
169 if ((allow_memio != 0) && (command & PCIM_CMD_MEMEN) != 0) {
167 if (allow_memio != 0) {
170
171 regs_type = SYS_RES_MEMORY;
172 regs_id = AHC_PCI_MEMADDR;
173 regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
174 &regs_id, RF_ACTIVE);
175 if (regs != NULL) {
176 ahc->tag = rman_get_bustag(regs);
177 ahc->bsh = rman_get_bushandle(regs);

--- 7 unchanged lines hidden (view full) ---

185 "PCI Device %d:%d:%d failed memory "
186 "mapped test. Using PIO.\n",
187 aic_get_pci_bus(ahc->dev_softc),
188 aic_get_pci_slot(ahc->dev_softc),
189 aic_get_pci_function(ahc->dev_softc));
190 bus_release_resource(ahc->dev_softc, regs_type,
191 regs_id, regs);
192 regs = NULL;
168
169 regs_type = SYS_RES_MEMORY;
170 regs_id = AHC_PCI_MEMADDR;
171 regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
172 &regs_id, RF_ACTIVE);
173 if (regs != NULL) {
174 ahc->tag = rman_get_bustag(regs);
175 ahc->bsh = rman_get_bushandle(regs);

--- 7 unchanged lines hidden (view full) ---

183 "PCI Device %d:%d:%d failed memory "
184 "mapped test. Using PIO.\n",
185 aic_get_pci_bus(ahc->dev_softc),
186 aic_get_pci_slot(ahc->dev_softc),
187 aic_get_pci_function(ahc->dev_softc));
188 bus_release_resource(ahc->dev_softc, regs_type,
189 regs_id, regs);
190 regs = NULL;
193 } else {
194 command &= ~PCIM_CMD_PORTEN;
195 aic_pci_write_config(ahc->dev_softc,
196 PCIR_COMMAND,
197 command, /*bytes*/1);
198 }
199 }
200 }
201
191 }
192 }
193 }
194
202 if (regs == NULL && (command & PCIM_CMD_PORTEN) != 0) {
195 if (regs == NULL) {
203 regs_type = SYS_RES_IOPORT;
204 regs_id = AHC_PCI_IOADDR;
205 regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
206 &regs_id, RF_ACTIVE);
207 if (regs != NULL) {
208 ahc->tag = rman_get_bustag(regs);
209 ahc->bsh = rman_get_bushandle(regs);
210 if (ahc_pci_test_register_access(ahc) != 0) {
211 device_printf(ahc->dev_softc,
212 "PCI Device %d:%d:%d failed I/O "
213 "mapped test.\n",
214 aic_get_pci_bus(ahc->dev_softc),
215 aic_get_pci_slot(ahc->dev_softc),
216 aic_get_pci_function(ahc->dev_softc));
217 bus_release_resource(ahc->dev_softc, regs_type,
218 regs_id, regs);
219 regs = NULL;
196 regs_type = SYS_RES_IOPORT;
197 regs_id = AHC_PCI_IOADDR;
198 regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
199 &regs_id, RF_ACTIVE);
200 if (regs != NULL) {
201 ahc->tag = rman_get_bustag(regs);
202 ahc->bsh = rman_get_bushandle(regs);
203 if (ahc_pci_test_register_access(ahc) != 0) {
204 device_printf(ahc->dev_softc,
205 "PCI Device %d:%d:%d failed I/O "
206 "mapped test.\n",
207 aic_get_pci_bus(ahc->dev_softc),
208 aic_get_pci_slot(ahc->dev_softc),
209 aic_get_pci_function(ahc->dev_softc));
210 bus_release_resource(ahc->dev_softc, regs_type,
211 regs_id, regs);
212 regs = NULL;
220 } else {
221 command &= ~PCIM_CMD_MEMEN;
222 aic_pci_write_config(ahc->dev_softc,
223 PCIR_COMMAND,
224 command, /*bytes*/1);
225 }
226 }
227 }
228 if (regs == NULL) {
229 device_printf(ahc->dev_softc,
230 "can't allocate register resources\n");
231 return (ENOMEM);
232 }
233 ahc->platform_data->regs_res_type = regs_type;
234 ahc->platform_data->regs_res_id = regs_id;
235 ahc->platform_data->regs = regs;
236 return (0);
237}
213 }
214 }
215 }
216 if (regs == NULL) {
217 device_printf(ahc->dev_softc,
218 "can't allocate register resources\n");
219 return (ENOMEM);
220 }
221 ahc->platform_data->regs_res_type = regs_type;
222 ahc->platform_data->regs_res_id = regs_id;
223 ahc->platform_data->regs = regs;
224 return (0);
225}