isp_pci.c (237210) | isp_pci.c (237537) |
---|---|
1/*- 2 * Copyright (c) 1997-2008 by Matthew Jacob 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 --- 14 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26/* 27 * PCI specific probe and attach routines for Qlogic ISP SCSI adapters. 28 * FreeBSD Version. 29 */ 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2008 by Matthew Jacob 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 --- 14 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26/* 27 * PCI specific probe and attach routines for Qlogic ISP SCSI adapters. 28 * FreeBSD Version. 29 */ 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/isp/isp_pci.c 237210 2012-06-17 21:39:40Z mjacob $"); | 31__FBSDID("$FreeBSD: head/sys/dev/isp/isp_pci.c 237537 2012-06-24 17:30:54Z mjacob $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/module.h> 37#include <sys/linker.h> 38#include <sys/firmware.h> 39#include <sys/bus.h> --- 329 unchanged lines hidden (view full) --- 369 370static driver_t isp_pci_driver = { 371 "isp", isp_pci_methods, sizeof (struct isp_pcisoftc) 372}; 373static devclass_t isp_devclass; 374DRIVER_MODULE(isp, pci, isp_pci_driver, isp_devclass, 0, 0); 375MODULE_DEPEND(isp, cam, 1, 1, 1); 376MODULE_DEPEND(isp, firmware, 1, 1, 1); | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/module.h> 37#include <sys/linker.h> 38#include <sys/firmware.h> 39#include <sys/bus.h> --- 329 unchanged lines hidden (view full) --- 369 370static driver_t isp_pci_driver = { 371 "isp", isp_pci_methods, sizeof (struct isp_pcisoftc) 372}; 373static devclass_t isp_devclass; 374DRIVER_MODULE(isp, pci, isp_pci_driver, isp_devclass, 0, 0); 375MODULE_DEPEND(isp, cam, 1, 1, 1); 376MODULE_DEPEND(isp, firmware, 1, 1, 1); |
377static int isp_nvports = 0; |
|
377 378static int 379isp_pci_probe(device_t dev) 380{ 381 switch ((pci_get_device(dev) << 16) | (pci_get_vendor(dev))) { 382 case PCI_QLOGIC_ISP1020: 383 device_set_desc(dev, "Qlogic ISP 1020/1040 PCI SCSI Adapter"); 384 break; --- 61 unchanged lines hidden (view full) --- 446 /* 447 * XXXX: Here is where we might load the f/w module 448 * XXXX: (or increase a reference count to it). 449 */ 450 return (BUS_PROBE_DEFAULT); 451} 452 453static void | 378 379static int 380isp_pci_probe(device_t dev) 381{ 382 switch ((pci_get_device(dev) << 16) | (pci_get_vendor(dev))) { 383 case PCI_QLOGIC_ISP1020: 384 device_set_desc(dev, "Qlogic ISP 1020/1040 PCI SCSI Adapter"); 385 break; --- 61 unchanged lines hidden (view full) --- 447 /* 448 * XXXX: Here is where we might load the f/w module 449 * XXXX: (or increase a reference count to it). 450 */ 451 return (BUS_PROBE_DEFAULT); 452} 453 454static void |
454isp_get_generic_options(device_t dev, ispsoftc_t *isp, int *nvp) | 455isp_get_generic_options(device_t dev, ispsoftc_t *isp) |
455{ 456 int tval; 457 458 /* 459 * Figure out if we're supposed to skip this one. 460 */ 461 tval = 0; 462 if (resource_int_value(device_get_name(dev), device_get_unit(dev), "disable", &tval) == 0 && tval) { --- 15 unchanged lines hidden (view full) --- 478 if (tval) { 479 isp->isp_dblev = tval; 480 } else { 481 isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; 482 } 483 if (bootverbose) { 484 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; 485 } | 456{ 457 int tval; 458 459 /* 460 * Figure out if we're supposed to skip this one. 461 */ 462 tval = 0; 463 if (resource_int_value(device_get_name(dev), device_get_unit(dev), "disable", &tval) == 0 && tval) { --- 15 unchanged lines hidden (view full) --- 479 if (tval) { 480 isp->isp_dblev = tval; 481 } else { 482 isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; 483 } 484 if (bootverbose) { 485 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; 486 } |
486 tval = 0; | 487 tval = -1; |
487 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "vports", &tval); 488 if (tval > 0 && tval < 127) { | 488 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "vports", &tval); 489 if (tval > 0 && tval < 127) { |
489 *nvp = tval; 490 } else { 491 *nvp = 0; | 490 isp_nvports = tval; |
492 } 493 tval = 1; 494 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "autoconfig", &tval); 495 isp_autoconfig = tval; 496 tval = 7; 497 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "quickboot_time", &tval); 498 isp_quickboot_time = tval; 499} --- 22 unchanged lines hidden (view full) --- 522 *m2 = PCIM_CMD_PORTEN; 523 } 524} 525 526static void 527isp_get_specific_options(device_t dev, int chan, ispsoftc_t *isp) 528{ 529 const char *sptr; | 491 } 492 tval = 1; 493 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "autoconfig", &tval); 494 isp_autoconfig = tval; 495 tval = 7; 496 (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "quickboot_time", &tval); 497 isp_quickboot_time = tval; 498} --- 22 unchanged lines hidden (view full) --- 521 *m2 = PCIM_CMD_PORTEN; 522 } 523} 524 525static void 526isp_get_specific_options(device_t dev, int chan, ispsoftc_t *isp) 527{ 528 const char *sptr; |
530 int tval; | 529 int tval = 0; |
531 532 if (resource_int_value(device_get_name(dev), device_get_unit(dev), "iid", &tval)) { 533 if (IS_FC(isp)) { 534 ISP_FC_PC(isp, chan)->default_id = 109 - chan; 535 } else { 536#ifdef __sparc64__ 537 ISP_SPI_PC(isp, chan)->iid = OF_getscsinitid(dev); 538#else --- 104 unchanged lines hidden (view full) --- 643 ISP_FC_PC(isp, chan)->gone_device_time = isp_gone_device_time; 644 } 645} 646 647static int 648isp_pci_attach(device_t dev) 649{ 650 int i, m1, m2, locksetup = 0; | 530 531 if (resource_int_value(device_get_name(dev), device_get_unit(dev), "iid", &tval)) { 532 if (IS_FC(isp)) { 533 ISP_FC_PC(isp, chan)->default_id = 109 - chan; 534 } else { 535#ifdef __sparc64__ 536 ISP_SPI_PC(isp, chan)->iid = OF_getscsinitid(dev); 537#else --- 104 unchanged lines hidden (view full) --- 642 ISP_FC_PC(isp, chan)->gone_device_time = isp_gone_device_time; 643 } 644} 645 646static int 647isp_pci_attach(device_t dev) 648{ 649 int i, m1, m2, locksetup = 0; |
651 int isp_nvports = 0; | |
652 uint32_t data, cmd, linesz, did; 653 struct isp_pcisoftc *pcs; 654 ispsoftc_t *isp; 655 size_t psize, xsize; 656 char fwname[32]; 657 658 pcs = device_get_softc(dev); 659 if (pcs == NULL) { --- 5 unchanged lines hidden (view full) --- 665 pcs->pci_dev = dev; 666 isp = &pcs->pci_isp; 667 isp->isp_dev = dev; 668 isp->isp_nchan = 1; 669 670 /* 671 * Get Generic Options 672 */ | 650 uint32_t data, cmd, linesz, did; 651 struct isp_pcisoftc *pcs; 652 ispsoftc_t *isp; 653 size_t psize, xsize; 654 char fwname[32]; 655 656 pcs = device_get_softc(dev); 657 if (pcs == NULL) { --- 5 unchanged lines hidden (view full) --- 663 pcs->pci_dev = dev; 664 isp = &pcs->pci_isp; 665 isp->isp_dev = dev; 666 isp->isp_nchan = 1; 667 668 /* 669 * Get Generic Options 670 */ |
673 isp_get_generic_options(dev, isp, &isp_nvports); | 671 isp_nvports = 0; 672 isp_get_generic_options(dev, isp); |
674 675 /* 676 * Check to see if options have us disabled 677 */ 678 if (isp->isp_osinfo.disabled) { 679 /* 680 * But return zero to preserve unit numbering 681 */ --- 189 unchanged lines hidden (view full) --- 871 if (isp->isp_osinfo.fw != NULL) { 872 isp_prt(isp, ISP_LOGCONFIG, "loaded firmware %s", fwname); 873 isp->isp_mdvec->dv_ispfw = isp->isp_osinfo.fw->data; 874 } 875 876 /* 877 * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set. 878 */ | 673 674 /* 675 * Check to see if options have us disabled 676 */ 677 if (isp->isp_osinfo.disabled) { 678 /* 679 * But return zero to preserve unit numbering 680 */ --- 189 unchanged lines hidden (view full) --- 870 if (isp->isp_osinfo.fw != NULL) { 871 isp_prt(isp, ISP_LOGCONFIG, "loaded firmware %s", fwname); 872 isp->isp_mdvec->dv_ispfw = isp->isp_osinfo.fw->data; 873 } 874 875 /* 876 * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set. 877 */ |
879 cmd |= PCIM_CMD_SEREN | PCIM_CMD_PERRESPEN | 880 PCIM_CMD_BUSMASTEREN | PCIM_CMD_INVEN; 881 | 878 cmd |= PCIM_CMD_SEREN | PCIM_CMD_PERRESPEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_INVEN; |
882 if (IS_2300(isp)) { /* per QLogic errata */ 883 cmd &= ~PCIM_CMD_INVEN; 884 } | 879 if (IS_2300(isp)) { /* per QLogic errata */ 880 cmd &= ~PCIM_CMD_INVEN; 881 } |
885 | |
886 if (IS_2322(isp) || pci_get_devid(dev) == PCI_QLOGIC_ISP6312) { 887 cmd &= ~PCIM_CMD_INTX_DISABLE; 888 } | 882 if (IS_2322(isp) || pci_get_devid(dev) == PCI_QLOGIC_ISP6312) { 883 cmd &= ~PCIM_CMD_INTX_DISABLE; 884 } |
889 | |
890 if (IS_24XX(isp)) { 891 cmd &= ~PCIM_CMD_INTX_DISABLE; 892 } | 885 if (IS_24XX(isp)) { 886 cmd &= ~PCIM_CMD_INTX_DISABLE; 887 } |
893 | |
894 pci_write_config(dev, PCIR_COMMAND, cmd, 2); 895 896 /* 897 * Make sure the Cache Line Size register is set sensibly. 898 */ 899 data = pci_read_config(dev, PCIR_CACHELNSZ, 1); 900 if (data == 0 || (linesz != PCI_DFLT_LNSZ && data != linesz)) { 901 isp_prt(isp, ISP_LOGDEBUG0, "set PCI line size to %d from %d", linesz, data); --- 1109 unchanged lines hidden --- | 888 pci_write_config(dev, PCIR_COMMAND, cmd, 2); 889 890 /* 891 * Make sure the Cache Line Size register is set sensibly. 892 */ 893 data = pci_read_config(dev, PCIR_CACHELNSZ, 1); 894 if (data == 0 || (linesz != PCI_DFLT_LNSZ && data != linesz)) { 895 isp_prt(isp, ISP_LOGDEBUG0, "set PCI line size to %d from %d", linesz, data); --- 1109 unchanged lines hidden --- |