tws.c (241753) | tws.c (254263) |
---|---|
1/* 2 * Copyright (c) 2010, LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah 5 * Support: freebsdraid@lsi.com 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * 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 35#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2010, LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah 5 * Support: freebsdraid@lsi.com 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 19 unchanged lines hidden (view full) --- 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * 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 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/dev/tws/tws.c 241753 2012-10-19 22:07:40Z delphij $"); | 36__FBSDID("$FreeBSD: head/sys/dev/tws/tws.c 254263 2013-08-12 23:30:01Z scottl $"); |
37 38#include <dev/tws/tws.h> 39#include <dev/tws/tws_services.h> 40#include <dev/tws/tws_hdm.h> 41 42#include <cam/cam.h> 43#include <cam/cam_ccb.h> 44 --- 133 unchanged lines hidden (view full) --- 178} 179 180/* Attach function is only called if the probe is successful. */ 181 182static int 183tws_attach(device_t dev) 184{ 185 struct tws_softc *sc = device_get_softc(dev); | 37 38#include <dev/tws/tws.h> 39#include <dev/tws/tws_services.h> 40#include <dev/tws/tws_hdm.h> 41 42#include <cam/cam.h> 43#include <cam/cam_ccb.h> 44 --- 133 unchanged lines hidden (view full) --- 178} 179 180/* Attach function is only called if the probe is successful. */ 181 182static int 183tws_attach(device_t dev) 184{ 185 struct tws_softc *sc = device_get_softc(dev); |
186 u_int32_t cmd, bar; | 186 u_int32_t bar; |
187 int error=0,i; 188 189 /* no tracing yet */ 190 /* Look up our softc and initialize its fields. */ 191 sc->tws_dev = dev; 192 sc->device_id = pci_get_device(dev); 193 sc->subvendor_id = pci_get_subvendor(dev); 194 sc->subdevice_id = pci_get_subdevice(dev); --- 24 unchanged lines hidden (view full) --- 219 if ( sc->tws_oidp == NULL ) { 220 tws_log(sc, SYSCTL_TREE_NODE_ADD); 221 goto attach_fail_1; 222 } 223 SYSCTL_ADD_STRING(&sc->tws_clist, SYSCTL_CHILDREN(sc->tws_oidp), 224 OID_AUTO, "driver_version", CTLFLAG_RD, 225 TWS_DRIVER_VERSION_STRING, 0, "TWS driver version"); 226 | 187 int error=0,i; 188 189 /* no tracing yet */ 190 /* Look up our softc and initialize its fields. */ 191 sc->tws_dev = dev; 192 sc->device_id = pci_get_device(dev); 193 sc->subvendor_id = pci_get_subvendor(dev); 194 sc->subdevice_id = pci_get_subdevice(dev); --- 24 unchanged lines hidden (view full) --- 219 if ( sc->tws_oidp == NULL ) { 220 tws_log(sc, SYSCTL_TREE_NODE_ADD); 221 goto attach_fail_1; 222 } 223 SYSCTL_ADD_STRING(&sc->tws_clist, SYSCTL_CHILDREN(sc->tws_oidp), 224 OID_AUTO, "driver_version", CTLFLAG_RD, 225 TWS_DRIVER_VERSION_STRING, 0, "TWS driver version"); 226 |
227 cmd = pci_read_config(dev, PCIR_COMMAND, 2); 228 if ( (cmd & PCIM_CMD_PORTEN) == 0) { 229 tws_log(sc, PCI_COMMAND_READ); 230 goto attach_fail_1; 231 } 232 /* Force the busmaster enable bit on. */ 233 cmd |= PCIM_CMD_BUSMASTEREN; 234 pci_write_config(dev, PCIR_COMMAND, cmd, 2); | 227 pci_enable_busmaster(dev); |
235 236 bar = pci_read_config(dev, TWS_PCI_BAR0, 4); 237 TWS_TRACE_DEBUG(sc, "bar0 ", bar, 0); 238 bar = pci_read_config(dev, TWS_PCI_BAR1, 4); 239 bar = bar & ~TWS_BIT2; 240 TWS_TRACE_DEBUG(sc, "bar1 ", bar, 0); 241 242 /* MFA base address is BAR2 register used for --- 213 unchanged lines hidden (view full) --- 456 return(SUCCESS); 457} 458 459 460static int 461tws_setup_irq(struct tws_softc *sc) 462{ 463 int messages; | 228 229 bar = pci_read_config(dev, TWS_PCI_BAR0, 4); 230 TWS_TRACE_DEBUG(sc, "bar0 ", bar, 0); 231 bar = pci_read_config(dev, TWS_PCI_BAR1, 4); 232 bar = bar & ~TWS_BIT2; 233 TWS_TRACE_DEBUG(sc, "bar1 ", bar, 0); 234 235 /* MFA base address is BAR2 register used for --- 213 unchanged lines hidden (view full) --- 449 return(SUCCESS); 450} 451 452 453static int 454tws_setup_irq(struct tws_softc *sc) 455{ 456 int messages; |
464 u_int16_t cmd; | |
465 | 457 |
466 cmd = pci_read_config(sc->tws_dev, PCIR_COMMAND, 2); | |
467 switch(sc->intr_type) { 468 case TWS_INTx : | 458 switch(sc->intr_type) { 459 case TWS_INTx : |
469 cmd = cmd & ~0x0400; 470 pci_write_config(sc->tws_dev, PCIR_COMMAND, cmd, 2); | |
471 sc->irqs = 1; 472 sc->irq_res_id[0] = 0; 473 sc->irq_res[0] = bus_alloc_resource_any(sc->tws_dev, SYS_RES_IRQ, 474 &sc->irq_res_id[0], RF_SHAREABLE | RF_ACTIVE); 475 if ( ! sc->irq_res[0] ) 476 return(FAILURE); 477 if ( tws_setup_intr(sc, sc->irqs) == FAILURE ) 478 return(FAILURE); 479 device_printf(sc->tws_dev, "Using legacy INTx\n"); 480 break; 481 case TWS_MSI : | 460 sc->irqs = 1; 461 sc->irq_res_id[0] = 0; 462 sc->irq_res[0] = bus_alloc_resource_any(sc->tws_dev, SYS_RES_IRQ, 463 &sc->irq_res_id[0], RF_SHAREABLE | RF_ACTIVE); 464 if ( ! sc->irq_res[0] ) 465 return(FAILURE); 466 if ( tws_setup_intr(sc, sc->irqs) == FAILURE ) 467 return(FAILURE); 468 device_printf(sc->tws_dev, "Using legacy INTx\n"); 469 break; 470 case TWS_MSI : |
482 cmd = cmd | 0x0400; 483 pci_write_config(sc->tws_dev, PCIR_COMMAND, cmd, 2); | |
484 sc->irqs = 1; 485 sc->irq_res_id[0] = 1; 486 messages = 1; 487 if (pci_alloc_msi(sc->tws_dev, &messages) != 0 ) { 488 TWS_TRACE(sc, "pci alloc msi fail", 0, messages); 489 return(FAILURE); 490 } 491 sc->irq_res[0] = bus_alloc_resource_any(sc->tws_dev, SYS_RES_IRQ, --- 420 unchanged lines hidden --- | 471 sc->irqs = 1; 472 sc->irq_res_id[0] = 1; 473 messages = 1; 474 if (pci_alloc_msi(sc->tws_dev, &messages) != 0 ) { 475 TWS_TRACE(sc, "pci alloc msi fail", 0, messages); 476 return(FAILURE); 477 } 478 sc->irq_res[0] = bus_alloc_resource_any(sc->tws_dev, SYS_RES_IRQ, --- 420 unchanged lines hidden --- |