Deleted Added
full compact
fwohci_pci.c (124877) fwohci_pci.c (125238)
1/*
2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
1/*
2 * Copyright (c) 2003 Hidetoshi Shimokawa
3 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 * $FreeBSD: head/sys/dev/firewire/fwohci_pci.c 124877 2004-01-23 17:37:09Z simokawa $
34 * $FreeBSD: head/sys/dev/firewire/fwohci_pci.c 125238 2004-01-30 14:28:11Z simokawa $
35 */
36
37#define BOUNCE_BUFFER_TEST 0
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/module.h>

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

226 return 0;
227}
228
229static int
230fwohci_pci_attach(device_t self)
231{
232 fwohci_softc_t *sc = device_get_softc(self);
233 int err;
35 */
36
37#define BOUNCE_BUFFER_TEST 0
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/module.h>

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

226 return 0;
227}
228
229static int
230fwohci_pci_attach(device_t self)
231{
232 fwohci_softc_t *sc = device_get_softc(self);
233 int err;
234 int rid, s;
234 int rid;
235#if __FreeBSD_version < 500000
236 int intr;
237 /* For the moment, put in a message stating what is wrong */
238 intr = pci_read_config(self, PCIR_INTLINE, 1);
239 if (intr == 0 || intr == 255) {
240 device_printf(self, "Invalid irq %d\n", intr);
241#ifdef __i386__
242 device_printf(self, "Please switch PNP-OS to 'No' in BIOS\n");

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

264 sc->irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
265 RF_SHAREABLE | RF_ACTIVE);
266 if (sc->irq_res == NULL) {
267 device_printf(self, "Could not allocate irq\n");
268 fwohci_pci_detach(self);
269 return ENXIO;
270 }
271
235#if __FreeBSD_version < 500000
236 int intr;
237 /* For the moment, put in a message stating what is wrong */
238 intr = pci_read_config(self, PCIR_INTLINE, 1);
239 if (intr == 0 || intr == 255) {
240 device_printf(self, "Invalid irq %d\n", intr);
241#ifdef __i386__
242 device_printf(self, "Please switch PNP-OS to 'No' in BIOS\n");

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

264 sc->irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
265 RF_SHAREABLE | RF_ACTIVE);
266 if (sc->irq_res == NULL) {
267 device_printf(self, "Could not allocate irq\n");
268 fwohci_pci_detach(self);
269 return ENXIO;
270 }
271
272 sc->fc.bdev = device_add_child(self, "firewire", -1);
273 if (!sc->fc.bdev) {
274 device_printf(self, "Could not add firewire device\n");
275 fwohci_pci_detach(self);
276 return ENOMEM;
277 }
278 device_set_ivars(sc->fc.bdev, sc);
279
280 err = bus_setup_intr(self, sc->irq_res,
281#if FWOHCI_TASKQUEUE
282 INTR_TYPE_NET | INTR_MPSAFE,
283#else
284 INTR_TYPE_NET,
285#endif
286 (driver_intr_t *) fwohci_intr, sc, &sc->ih);

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

325 err = fwohci_init(sc, self);
326
327 if (err) {
328 device_printf(self, "fwohci_init failed with err=%d\n", err);
329 fwohci_pci_detach(self);
330 return EIO;
331 }
332
272
273 err = bus_setup_intr(self, sc->irq_res,
274#if FWOHCI_TASKQUEUE
275 INTR_TYPE_NET | INTR_MPSAFE,
276#else
277 INTR_TYPE_NET,
278#endif
279 (driver_intr_t *) fwohci_intr, sc, &sc->ih);

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

318 err = fwohci_init(sc, self);
319
320 if (err) {
321 device_printf(self, "fwohci_init failed with err=%d\n", err);
322 fwohci_pci_detach(self);
323 return EIO;
324 }
325
333 err = device_probe_and_attach(sc->fc.bdev);
326 /* probe and attach a child device(firewire) */
327 bus_generic_probe(self);
328 bus_generic_attach(self);
334
329
335 if (err) {
336 device_printf(self, "probe_and_attach failed with err=%d\n",
337 err);
338 fwohci_pci_detach(self);
339 return EIO;
340 }
341
342 /* XXX
343 * Clear the bus reset event flag to start transactions even when
344 * interrupt is disabled during the boot process.
345 */
346 DELAY(250); /* 2 cycles */
347 s = splfw();
348 fwohci_poll((void *)sc, 0, -1);
349 splx(s);
350
351 return 0;
352}
353
354static int
355fwohci_pci_detach(device_t self)
356{
357 fwohci_softc_t *sc = device_get_softc(self);
358 int s;

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

439{
440 fwohci_softc_t *sc = device_get_softc(dev);
441
442 bus_generic_shutdown(dev);
443 fwohci_stop(sc, dev);
444 return 0;
445}
446
330 return 0;
331}
332
333static int
334fwohci_pci_detach(device_t self)
335{
336 fwohci_softc_t *sc = device_get_softc(self);
337 int s;

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

418{
419 fwohci_softc_t *sc = device_get_softc(dev);
420
421 bus_generic_shutdown(dev);
422 fwohci_stop(sc, dev);
423 return 0;
424}
425
426static device_t
427fwohci_pci_add_child(device_t dev, int order, const char *name, int unit)
428{
429 struct fwohci_softc *sc;
430 device_t child;
431 int s, err = 0;
432
433 sc = (struct fwohci_softc *)device_get_softc(dev);
434 child = device_add_child(dev, name, unit);
435 if (child == NULL)
436 return (child);
437
438 sc->fc.bdev = child;
439 device_set_ivars(child, (void *)&sc->fc);
440
441 err = device_probe_and_attach(child);
442 if (err) {
443 device_printf(dev, "probe_and_attach failed with err=%d\n",
444 err);
445 fwohci_pci_detach(dev);
446 device_delete_child(dev, child);
447 return NULL;
448 }
449
450 /* XXX
451 * Clear the bus reset event flag to start transactions even when
452 * interrupt is disabled during the boot process.
453 */
454 DELAY(250); /* 2 cycles */
455 s = splfw();
456 fwohci_poll((void *)sc, 0, -1);
457 splx(s);
458
459 return (child);
460}
461
447static device_method_t fwohci_methods[] = {
448 /* Device interface */
449 DEVMETHOD(device_probe, fwohci_pci_probe),
450 DEVMETHOD(device_attach, fwohci_pci_attach),
451 DEVMETHOD(device_detach, fwohci_pci_detach),
452 DEVMETHOD(device_suspend, fwohci_pci_suspend),
453 DEVMETHOD(device_resume, fwohci_pci_resume),
454 DEVMETHOD(device_shutdown, fwohci_pci_shutdown),
455
456 /* Bus interface */
462static device_method_t fwohci_methods[] = {
463 /* Device interface */
464 DEVMETHOD(device_probe, fwohci_pci_probe),
465 DEVMETHOD(device_attach, fwohci_pci_attach),
466 DEVMETHOD(device_detach, fwohci_pci_detach),
467 DEVMETHOD(device_suspend, fwohci_pci_suspend),
468 DEVMETHOD(device_resume, fwohci_pci_resume),
469 DEVMETHOD(device_shutdown, fwohci_pci_shutdown),
470
471 /* Bus interface */
472 DEVMETHOD(bus_add_child, fwohci_pci_add_child),
457 DEVMETHOD(bus_print_child, bus_generic_print_child),
458
459 { 0, 0 }
460};
461
462static driver_t fwohci_driver = {
463 "fwohci",
464 fwohci_methods,
465 sizeof(fwohci_softc_t),
466};
467
468static devclass_t fwohci_devclass;
469
473 DEVMETHOD(bus_print_child, bus_generic_print_child),
474
475 { 0, 0 }
476};
477
478static driver_t fwohci_driver = {
479 "fwohci",
480 fwohci_methods,
481 sizeof(fwohci_softc_t),
482};
483
484static devclass_t fwohci_devclass;
485
486#ifdef FWOHCI_MODULE
487MODULE_DEPEND(fwohci, firewire, 1, 1, 1);
488#endif
470DRIVER_MODULE(fwohci, pci, fwohci_driver, fwohci_devclass, 0, 0);
471DRIVER_MODULE(fwohci, cardbus, fwohci_driver, fwohci_devclass, 0, 0);
489DRIVER_MODULE(fwohci, pci, fwohci_driver, fwohci_devclass, 0, 0);
490DRIVER_MODULE(fwohci, cardbus, fwohci_driver, fwohci_devclass, 0, 0);