Lines Matching +full:sha +full:- +full:1
2 * PMC-Sierra PM8001/8081/8088/8089 SAS/SATA based host adapters driver
4 * Copyright (c) 2008-2009 USI Co., Ltd.
10 * 1. Redistributions of source code must retain the above copyright
18 * 3. Neither the names of the above-listed copyright holders nor the names
54 " 1: Link rate 1.5G\n"
69 [chip_8009] = {1, 8, &pm8001_80xx_dispatch,},
71 [chip_8019] = {1, 16, &pm8001_80xx_dispatch,},
87 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in pm8001_map_queues() local
88 struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; in pm8001_map_queues()
89 struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; in pm8001_map_queues()
91 if (pm8001_ha->number_of_intr > 1) in pm8001_map_queues()
92 blk_mq_pci_map_queues(qmap, pm8001_ha->pdev, 1); in pm8001_map_queues()
112 .can_queue = 1,
113 .this_id = -1,
125 .track_queue_depth = 1,
152 * pm8001_phy_init - initiate our adapter phys
158 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; in pm8001_phy_init()
159 struct asd_sas_phy *sas_phy = &phy->sas_phy; in pm8001_phy_init()
160 phy->phy_state = PHY_LINK_DISABLE; in pm8001_phy_init()
161 phy->pm8001_ha = pm8001_ha; in pm8001_phy_init()
162 phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; in pm8001_phy_init()
163 phy->maximum_linkrate = SAS_LINK_RATE_6_0_GBPS; in pm8001_phy_init()
164 sas_phy->enabled = (phy_id < pm8001_ha->chip->n_phy) ? 1 : 0; in pm8001_phy_init()
165 sas_phy->iproto = SAS_PROTOCOL_ALL; in pm8001_phy_init()
166 sas_phy->tproto = 0; in pm8001_phy_init()
167 sas_phy->role = PHY_ROLE_INITIATOR; in pm8001_phy_init()
168 sas_phy->oob_mode = OOB_NOT_CONNECTED; in pm8001_phy_init()
169 sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN; in pm8001_phy_init()
170 sas_phy->id = phy_id; in pm8001_phy_init()
171 sas_phy->sas_addr = (u8 *)&phy->dev_sas_addr; in pm8001_phy_init()
172 sas_phy->frame_rcvd = &phy->frame_rcvd[0]; in pm8001_phy_init()
173 sas_phy->ha = (struct sas_ha_struct *)pm8001_ha->shost->hostdata; in pm8001_phy_init()
174 sas_phy->lldd_phy = phy; in pm8001_phy_init()
178 * pm8001_free - free hba
189 if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) { in pm8001_free()
190 dma_free_coherent(&pm8001_ha->pdev->dev, in pm8001_free()
191 (pm8001_ha->memoryMap.region[i].total_len + in pm8001_free()
192 pm8001_ha->memoryMap.region[i].alignment), in pm8001_free()
193 pm8001_ha->memoryMap.region[i].virt_ptr, in pm8001_free()
194 pm8001_ha->memoryMap.region[i].phys_addr); in pm8001_free()
197 PM8001_CHIP_DISP->chip_iounmap(pm8001_ha); in pm8001_free()
199 bitmap_free(pm8001_ha->rsvd_tags); in pm8001_free()
206 * pm8001_tasklet() - tasklet for 64 msi-x interrupt handler
216 pm8001_ha = irq_vector->drv_inst; in pm8001_tasklet()
218 BUG_ON(1); in pm8001_tasklet()
219 PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id); in pm8001_tasklet()
224 * pm8001_interrupt_handler_msix - main MSIX interrupt handler.
237 pm8001_ha = irq_vector->drv_inst; in pm8001_interrupt_handler_msix()
241 if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha)) in pm8001_interrupt_handler_msix()
244 tasklet_schedule(&pm8001_ha->tasklet[irq_vector->irq_id]); in pm8001_interrupt_handler_msix()
246 ret = PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id); in pm8001_interrupt_handler_msix()
252 * pm8001_interrupt_handler_intx - main INTx interrupt handler.
261 struct sas_ha_struct *sha = dev_id; in pm8001_interrupt_handler_intx() local
262 pm8001_ha = sha->lldd_ha; in pm8001_interrupt_handler_intx()
265 if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha)) in pm8001_interrupt_handler_intx()
269 tasklet_schedule(&pm8001_ha->tasklet[0]); in pm8001_interrupt_handler_intx()
271 ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0); in pm8001_interrupt_handler_intx()
279 * pm8001_alloc - initiate our hba structure and 6 DMAs area.
291 spin_lock_init(&pm8001_ha->lock); in pm8001_alloc()
292 spin_lock_init(&pm8001_ha->bitmap_lock); in pm8001_alloc()
294 pm8001_ha->chip->n_phy); in pm8001_alloc()
301 count = pm8001_ha->max_q_num; in pm8001_alloc()
303 ib_offset = pm8001_ha->ib_offset = USI_MAX_MEMCNT_BASE; in pm8001_alloc()
304 ci_offset = pm8001_ha->ci_offset = ib_offset + count; in pm8001_alloc()
305 ob_offset = pm8001_ha->ob_offset = ci_offset + count; in pm8001_alloc()
306 pi_offset = pm8001_ha->pi_offset = ob_offset + count; in pm8001_alloc()
307 pm8001_ha->max_memcnt = pi_offset + count; in pm8001_alloc()
309 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { in pm8001_alloc()
311 pm8001_ha->port[i].wide_port_phymap = 0; in pm8001_alloc()
312 pm8001_ha->port[i].port_attached = 0; in pm8001_alloc()
313 pm8001_ha->port[i].port_state = 0; in pm8001_alloc()
314 INIT_LIST_HEAD(&pm8001_ha->port[i].list); in pm8001_alloc()
317 /* MPI Memory region 1 for AAP Event Log for fw */ in pm8001_alloc()
318 pm8001_ha->memoryMap.region[AAP1].num_elements = 1; in pm8001_alloc()
319 pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE; in pm8001_alloc()
320 pm8001_ha->memoryMap.region[AAP1].total_len = PM8001_EVENT_LOG_SIZE; in pm8001_alloc()
321 pm8001_ha->memoryMap.region[AAP1].alignment = 32; in pm8001_alloc()
324 pm8001_ha->memoryMap.region[IOP].num_elements = 1; in pm8001_alloc()
325 pm8001_ha->memoryMap.region[IOP].element_size = PM8001_EVENT_LOG_SIZE; in pm8001_alloc()
326 pm8001_ha->memoryMap.region[IOP].total_len = PM8001_EVENT_LOG_SIZE; in pm8001_alloc()
327 pm8001_ha->memoryMap.region[IOP].alignment = 32; in pm8001_alloc()
330 ibq = &pm8001_ha->inbnd_q_tbl[i]; in pm8001_alloc()
331 spin_lock_init(&ibq->iq_lock); in pm8001_alloc()
333 pm8001_ha->memoryMap.region[ci_offset+i].num_elements = 1; in pm8001_alloc()
334 pm8001_ha->memoryMap.region[ci_offset+i].element_size = 4; in pm8001_alloc()
335 pm8001_ha->memoryMap.region[ci_offset+i].total_len = 4; in pm8001_alloc()
336 pm8001_ha->memoryMap.region[ci_offset+i].alignment = 4; in pm8001_alloc()
338 if ((ent->driver_data) != chip_8001) { in pm8001_alloc()
340 pm8001_ha->memoryMap.region[ib_offset+i].num_elements = in pm8001_alloc()
342 pm8001_ha->memoryMap.region[ib_offset+i].element_size in pm8001_alloc()
344 pm8001_ha->memoryMap.region[ib_offset+i].total_len = in pm8001_alloc()
346 pm8001_ha->memoryMap.region[ib_offset+i].alignment in pm8001_alloc()
349 pm8001_ha->memoryMap.region[ib_offset+i].num_elements = in pm8001_alloc()
351 pm8001_ha->memoryMap.region[ib_offset+i].element_size in pm8001_alloc()
353 pm8001_ha->memoryMap.region[ib_offset+i].total_len = in pm8001_alloc()
355 pm8001_ha->memoryMap.region[ib_offset+i].alignment = 64; in pm8001_alloc()
360 obq = &pm8001_ha->outbnd_q_tbl[i]; in pm8001_alloc()
361 spin_lock_init(&obq->oq_lock); in pm8001_alloc()
363 pm8001_ha->memoryMap.region[pi_offset+i].num_elements = 1; in pm8001_alloc()
364 pm8001_ha->memoryMap.region[pi_offset+i].element_size = 4; in pm8001_alloc()
365 pm8001_ha->memoryMap.region[pi_offset+i].total_len = 4; in pm8001_alloc()
366 pm8001_ha->memoryMap.region[pi_offset+i].alignment = 4; in pm8001_alloc()
368 if (ent->driver_data != chip_8001) { in pm8001_alloc()
370 pm8001_ha->memoryMap.region[ob_offset+i].num_elements = in pm8001_alloc()
372 pm8001_ha->memoryMap.region[ob_offset+i].element_size in pm8001_alloc()
374 pm8001_ha->memoryMap.region[ob_offset+i].total_len = in pm8001_alloc()
376 pm8001_ha->memoryMap.region[ob_offset+i].alignment in pm8001_alloc()
380 pm8001_ha->memoryMap.region[ob_offset+i].num_elements = in pm8001_alloc()
382 pm8001_ha->memoryMap.region[ob_offset+i].element_size in pm8001_alloc()
384 pm8001_ha->memoryMap.region[ob_offset+i].total_len = in pm8001_alloc()
386 pm8001_ha->memoryMap.region[ob_offset+i].alignment = 64; in pm8001_alloc()
391 pm8001_ha->memoryMap.region[NVMD].num_elements = 1; in pm8001_alloc()
392 pm8001_ha->memoryMap.region[NVMD].element_size = 4096; in pm8001_alloc()
393 pm8001_ha->memoryMap.region[NVMD].total_len = 4096; in pm8001_alloc()
396 pm8001_ha->memoryMap.region[FW_FLASH].total_len = 4096; in pm8001_alloc()
398 pm8001_ha->memoryMap.region[FORENSIC_MEM].num_elements = 1; in pm8001_alloc()
399 pm8001_ha->memoryMap.region[FORENSIC_MEM].total_len = 0x10000; in pm8001_alloc()
400 pm8001_ha->memoryMap.region[FORENSIC_MEM].element_size = 0x10000; in pm8001_alloc()
401 pm8001_ha->memoryMap.region[FORENSIC_MEM].alignment = 0x10000; in pm8001_alloc()
402 for (i = 0; i < pm8001_ha->max_memcnt; i++) { in pm8001_alloc()
403 struct mpi_mem *region = &pm8001_ha->memoryMap.region[i]; in pm8001_alloc()
405 if (pm8001_mem_alloc(pm8001_ha->pdev, in pm8001_alloc()
406 ®ion->virt_ptr, in pm8001_alloc()
407 ®ion->phys_addr, in pm8001_alloc()
408 ®ion->phys_addr_hi, in pm8001_alloc()
409 ®ion->phys_addr_lo, in pm8001_alloc()
410 region->total_len, in pm8001_alloc()
411 region->alignment) != 0) { in pm8001_alloc()
418 pm8001_ha->devices = kzalloc(PM8001_MAX_DEVICES in pm8001_alloc()
420 if (!pm8001_ha->devices) { in pm8001_alloc()
421 rc = -ENOMEM; in pm8001_alloc()
425 pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED; in pm8001_alloc()
426 pm8001_ha->devices[i].id = i; in pm8001_alloc()
427 pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES; in pm8001_alloc()
428 atomic_set(&pm8001_ha->devices[i].running_req, 0); in pm8001_alloc()
430 pm8001_ha->flags = PM8001F_INIT_TIME; in pm8001_alloc()
434 for (i = 0; i < pm8001_ha->max_memcnt; i++) { in pm8001_alloc()
435 if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) { in pm8001_alloc()
436 dma_free_coherent(&pm8001_ha->pdev->dev, in pm8001_alloc()
437 (pm8001_ha->memoryMap.region[i].total_len + in pm8001_alloc()
438 pm8001_ha->memoryMap.region[i].alignment), in pm8001_alloc()
439 pm8001_ha->memoryMap.region[i].virt_ptr, in pm8001_alloc()
440 pm8001_ha->memoryMap.region[i].phys_addr); in pm8001_alloc()
444 return 1; in pm8001_alloc()
448 * pm8001_ioremap - remap the pci high physical address to kernel virtual
458 pdev = pm8001_ha->pdev; in pm8001_ioremap()
459 /* map pci mem (PMC pci base 0-3)*/ in pm8001_ioremap()
463 ** bar 0 and 1 - logical BAR0 in pm8001_ioremap()
464 ** bar 2 and 3 - logical BAR1 in pm8001_ioremap()
465 ** bar4 - logical BAR2 in pm8001_ioremap()
466 ** bar5 - logical BAR3 in pm8001_ioremap()
469 if ((bar == 1) || (bar == 3)) in pm8001_ioremap()
472 pm8001_ha->io_mem[logicalBar].membase = in pm8001_ioremap()
474 pm8001_ha->io_mem[logicalBar].memsize = in pm8001_ioremap()
476 pm8001_ha->io_mem[logicalBar].memvirtaddr = in pm8001_ioremap()
477 ioremap(pm8001_ha->io_mem[logicalBar].membase, in pm8001_ioremap()
478 pm8001_ha->io_mem[logicalBar].memsize); in pm8001_ioremap()
479 if (!pm8001_ha->io_mem[logicalBar].memvirtaddr) { in pm8001_ioremap()
483 return -ENOMEM; in pm8001_ioremap()
487 (u64)pm8001_ha->io_mem[logicalBar].membase, in pm8001_ioremap()
489 pm8001_ha->io_mem[logicalBar].memvirtaddr, in pm8001_ioremap()
490 pm8001_ha->io_mem[logicalBar].memsize); in pm8001_ioremap()
492 pm8001_ha->io_mem[logicalBar].membase = 0; in pm8001_ioremap()
493 pm8001_ha->io_mem[logicalBar].memsize = 0; in pm8001_ioremap()
494 pm8001_ha->io_mem[logicalBar].memvirtaddr = NULL; in pm8001_ioremap()
502 * pm8001_pci_alloc - initialize our ha card structure
513 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in pm8001_pci_alloc() local
516 pm8001_ha = sha->lldd_ha; in pm8001_pci_alloc()
520 pm8001_ha->pdev = pdev; in pm8001_pci_alloc()
521 pm8001_ha->dev = &pdev->dev; in pm8001_pci_alloc()
522 pm8001_ha->chip_id = ent->driver_data; in pm8001_pci_alloc()
523 pm8001_ha->chip = &pm8001_chips[pm8001_ha->chip_id]; in pm8001_pci_alloc()
524 pm8001_ha->irq = pdev->irq; in pm8001_pci_alloc()
525 pm8001_ha->sas = sha; in pm8001_pci_alloc()
526 pm8001_ha->shost = shost; in pm8001_pci_alloc()
527 pm8001_ha->id = pm8001_id++; in pm8001_pci_alloc()
528 pm8001_ha->logging_level = logging_level; in pm8001_pci_alloc()
529 pm8001_ha->non_fatal_count = 0; in pm8001_pci_alloc()
530 if (link_rate >= 1 && link_rate <= 15) in pm8001_pci_alloc()
531 pm8001_ha->link_rate = (link_rate << 8); in pm8001_pci_alloc()
533 pm8001_ha->link_rate = LINKRATE_15 | LINKRATE_30 | in pm8001_pci_alloc()
538 sprintf(pm8001_ha->name, "%s%d", DRV_NAME, pm8001_ha->id); in pm8001_pci_alloc()
540 if (pm8001_ha->chip_id != chip_8001) in pm8001_pci_alloc()
541 pm8001_ha->iomb_size = IOMB_SIZE_SPCV; in pm8001_pci_alloc()
543 pm8001_ha->iomb_size = IOMB_SIZE_SPC; in pm8001_pci_alloc()
546 /* Tasklet for non msi-x interrupt handler */ in pm8001_pci_alloc()
547 if ((!pdev->msix_cap || !pci_msi_enabled()) in pm8001_pci_alloc()
548 || (pm8001_ha->chip_id == chip_8001)) in pm8001_pci_alloc()
549 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, in pm8001_pci_alloc()
550 (unsigned long)&(pm8001_ha->irq_vector[0])); in pm8001_pci_alloc()
553 tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet, in pm8001_pci_alloc()
554 (unsigned long)&(pm8001_ha->irq_vector[j])); in pm8001_pci_alloc()
566 * pci_go_44 - pm8001 specified, its DMA is 44 bit rather than 64 bit
573 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); in pci_go_44()
575 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in pci_go_44()
577 dev_printk(KERN_ERR, &pdev->dev, in pci_go_44()
578 "32-bit DMA enable failed\n"); in pci_go_44()
584 * pm8001_prep_sas_ha_init - allocate memory in general hba struct && init them.
594 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in pm8001_prep_sas_ha_init() local
596 phy_nr = chip_info->n_phy; in pm8001_prep_sas_ha_init()
598 memset(sha, 0x00, sizeof(*sha)); in pm8001_prep_sas_ha_init()
606 sha->sas_phy = arr_phy; in pm8001_prep_sas_ha_init()
607 sha->sas_port = arr_port; in pm8001_prep_sas_ha_init()
608 sha->lldd_ha = kzalloc(sizeof(struct pm8001_hba_info), GFP_KERNEL); in pm8001_prep_sas_ha_init()
609 if (!sha->lldd_ha) in pm8001_prep_sas_ha_init()
612 shost->transportt = pm8001_stt; in pm8001_prep_sas_ha_init()
613 shost->max_id = PM8001_MAX_DEVICES; in pm8001_prep_sas_ha_init()
614 shost->unique_id = pm8001_id; in pm8001_prep_sas_ha_init()
615 shost->max_cmd_len = 16; in pm8001_prep_sas_ha_init()
622 return -1; in pm8001_prep_sas_ha_init()
626 * pm8001_post_sas_ha_init - initialize general hba struct defined in libsas
635 struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); in pm8001_post_sas_ha_init() local
637 pm8001_ha = sha->lldd_ha; in pm8001_post_sas_ha_init()
638 for (i = 0; i < chip_info->n_phy; i++) { in pm8001_post_sas_ha_init()
639 sha->sas_phy[i] = &pm8001_ha->phy[i].sas_phy; in pm8001_post_sas_ha_init()
640 sha->sas_port[i] = &pm8001_ha->port[i].sas_port; in pm8001_post_sas_ha_init()
641 sha->sas_phy[i]->sas_addr = in pm8001_post_sas_ha_init()
642 (u8 *)&pm8001_ha->phy[i].dev_sas_addr; in pm8001_post_sas_ha_init()
644 sha->sas_ha_name = DRV_NAME; in pm8001_post_sas_ha_init()
645 sha->dev = pm8001_ha->dev; in pm8001_post_sas_ha_init()
646 sha->strict_wide_ports = 1; in pm8001_post_sas_ha_init()
647 sha->sas_addr = &pm8001_ha->sas_addr[0]; in pm8001_post_sas_ha_init()
648 sha->num_phys = chip_info->n_phy; in pm8001_post_sas_ha_init()
649 sha->shost = shost; in pm8001_post_sas_ha_init()
653 * pm8001_init_sas_add - initialize sas address
674 if (PM8001_CHIP_DISP->fatal_errors(pm8001_ha)) { in pm8001_init_sas_add()
676 return -EIO; in pm8001_init_sas_add()
679 pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid); in pm8001_init_sas_add()
680 pm8001_ha->nvmd_completion = &completion; in pm8001_init_sas_add()
682 if (pm8001_ha->chip_id == chip_8001) { in pm8001_init_sas_add()
690 } else if ((pm8001_ha->chip_id == chip_8070 || in pm8001_init_sas_add()
691 pm8001_ha->chip_id == chip_8072) && in pm8001_init_sas_add()
692 pm8001_ha->pdev->subsystem_vendor == PCI_VENDOR_ID_ATTO) { in pm8001_init_sas_add()
696 payload.minor_function = 1; in pm8001_init_sas_add()
703 return -ENOMEM; in pm8001_init_sas_add()
705 rc = PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); in pm8001_init_sas_add()
709 return -EIO; in pm8001_init_sas_add()
712 msecs_to_jiffies(60*1000)); // 1 min in pm8001_init_sas_add()
716 return -EIO; in pm8001_init_sas_add()
721 if (pm8001_ha->chip_id == chip_8001) { in pm8001_init_sas_add()
723 pm8001_ha->sas_addr[j] = in pm8001_init_sas_add()
726 pm8001_ha->sas_addr[j] = in pm8001_init_sas_add()
728 } else if ((pm8001_ha->chip_id == chip_8070 || in pm8001_init_sas_add()
729 pm8001_ha->chip_id == chip_8072) && in pm8001_init_sas_add()
730 pm8001_ha->pdev->subsystem_vendor == PCI_VENDOR_ID_ATTO) { in pm8001_init_sas_add()
731 pm8001_ha->sas_addr[j] = in pm8001_init_sas_add()
734 pm8001_ha->sas_addr[j] = in pm8001_init_sas_add()
737 memcpy(sas_add, pm8001_ha->sas_addr, SAS_ADDR_SIZE); in pm8001_init_sas_add()
738 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { in pm8001_init_sas_add()
741 memcpy(&pm8001_ha->phy[i].dev_sas_addr, in pm8001_init_sas_add()
744 pm8001_ha->phy[i].dev_sas_addr); in pm8001_init_sas_add()
748 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { in pm8001_init_sas_add()
749 pm8001_ha->phy[i].dev_sas_addr = 0x50010c600047f9d0ULL; in pm8001_init_sas_add()
750 pm8001_ha->phy[i].dev_sas_addr = in pm8001_init_sas_add()
752 (*(u64 *)&pm8001_ha->phy[i].dev_sas_addr)); in pm8001_init_sas_add()
754 memcpy(pm8001_ha->sas_addr, &pm8001_ha->phy[0].dev_sas_addr, in pm8001_init_sas_add()
773 pm8001_ha->nvmd_completion = &completion; in pm8001_get_phy_settings_info()
780 return -ENOMEM; in pm8001_get_phy_settings_info()
782 rc = PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload); in pm8001_get_phy_settings_info()
786 return -ENOMEM; in pm8001_get_phy_settings_info()
808 * pm8001_get_internal_phy_settings - Retrieves the internal PHY settings
816 phycfg->LaneLosCfg = 0x00000132; in pm8001_get_internal_phy_settings()
817 phycfg->LanePgaCfg1 = 0x00203949; in pm8001_get_internal_phy_settings()
818 phycfg->LanePisoCfg1 = 0x000000FF; in pm8001_get_internal_phy_settings()
819 phycfg->LanePisoCfg2 = 0xFF000001; in pm8001_get_internal_phy_settings()
820 phycfg->LanePisoCfg3 = 0xE7011300; in pm8001_get_internal_phy_settings()
821 phycfg->LanePisoCfg4 = 0x631C40C0; in pm8001_get_internal_phy_settings()
822 phycfg->LanePisoCfg5 = 0xF8102036; in pm8001_get_internal_phy_settings()
823 phycfg->LanePisoCfg6 = 0xF74A1000; in pm8001_get_internal_phy_settings()
824 phycfg->LaneBctCtrl = 0x00FB33F8; in pm8001_get_internal_phy_settings()
828 * pm8001_get_external_phy_settings - Retrieves the external PHY settings
836 phycfg->LaneLosCfg = 0x00000132; in pm8001_get_external_phy_settings()
837 phycfg->LanePgaCfg1 = 0x00203949; in pm8001_get_external_phy_settings()
838 phycfg->LanePisoCfg1 = 0x000000FF; in pm8001_get_external_phy_settings()
839 phycfg->LanePisoCfg2 = 0xFF000001; in pm8001_get_external_phy_settings()
840 phycfg->LanePisoCfg3 = 0xE7011300; in pm8001_get_external_phy_settings()
841 phycfg->LanePisoCfg4 = 0x63349140; in pm8001_get_external_phy_settings()
842 phycfg->LanePisoCfg5 = 0xF8102036; in pm8001_get_external_phy_settings()
843 phycfg->LanePisoCfg6 = 0xF80D9300; in pm8001_get_external_phy_settings()
844 phycfg->LaneBctCtrl = 0x00FB33F8; in pm8001_get_external_phy_settings()
848 * pm8001_get_phy_mask - Retrieves the mask that denotes if a PHY is int/ext
855 switch (pm8001_ha->pdev->subsystem_device) { in pm8001_get_phy_mask()
856 case 0x0070: /* H1280 - 8 external 0 internal */ in pm8001_get_phy_mask()
857 case 0x0072: /* H12F0 - 16 external 0 internal */ in pm8001_get_phy_mask()
861 case 0x0071: /* H1208 - 0 external 8 internal */ in pm8001_get_phy_mask()
862 case 0x0073: /* H120F - 0 external 16 internal */ in pm8001_get_phy_mask()
866 case 0x0080: /* H1244 - 4 external 4 internal */ in pm8001_get_phy_mask()
870 case 0x0081: /* H1248 - 4 external 8 internal */ in pm8001_get_phy_mask()
874 case 0x0082: /* H1288 - 8 external 8 internal */ in pm8001_get_phy_mask()
881 pm8001_ha->pdev->subsystem_device); in pm8001_get_phy_mask()
886 * pm8001_set_phy_settings_ven_117c_12G() - Configure ATTO 12Gb PHY settings
904 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { in pm8001_set_phy_settings_ven_117c_12G()
905 if (phymask & (1 << i)) {/* Internal PHY */ in pm8001_set_phy_settings_ven_117c_12G()
921 * pm8001_configure_phy_settings - Configures PHY settings based on vendor ID.
926 switch (pm8001_ha->pdev->subsystem_vendor) { in pm8001_configure_phy_settings()
928 if (pm8001_ha->pdev->device == 0x0042) /* 6Gb */ in pm8001_configure_phy_settings()
944 * pm8001_setup_msix - enable MSI-X interrupt
952 /* SPCv controllers supports 64 msi-x */ in pm8001_setup_msix()
953 if (pm8001_ha->chip_id == chip_8001) { in pm8001_setup_msix()
954 rc = pci_alloc_irq_vectors(pm8001_ha->pdev, 1, 1, in pm8001_setup_msix()
962 .pre_vectors = 1, in pm8001_setup_msix()
965 pm8001_ha->pdev, 2, PM8001_MAX_MSIX_VEC, in pm8001_setup_msix()
974 pm8001_ha->number_of_intr = allocated_irq_vectors; in pm8001_setup_msix()
977 pm8001_ha->max_q_num = allocated_irq_vectors; in pm8001_setup_msix()
981 rc, pm8001_ha->number_of_intr); in pm8001_setup_msix()
989 int nr_irqs = pm8001_ha->number_of_intr; in pm8001_request_msix()
991 if (pm8001_ha->chip_id != chip_8001) in pm8001_request_msix()
996 pm8001_ha->number_of_intr); in pm8001_request_msix()
998 if (nr_irqs > ARRAY_SIZE(pm8001_ha->intr_drvname)) in pm8001_request_msix()
999 nr_irqs = ARRAY_SIZE(pm8001_ha->intr_drvname); in pm8001_request_msix()
1002 snprintf(pm8001_ha->intr_drvname[i], in pm8001_request_msix()
1003 sizeof(pm8001_ha->intr_drvname[0]), in pm8001_request_msix()
1004 "%s-%d", pm8001_ha->name, i); in pm8001_request_msix()
1005 pm8001_ha->irq_vector[i].irq_id = i; in pm8001_request_msix()
1006 pm8001_ha->irq_vector[i].drv_inst = pm8001_ha; in pm8001_request_msix()
1008 rc = request_irq(pci_irq_vector(pm8001_ha->pdev, i), in pm8001_request_msix()
1010 pm8001_ha->intr_drvname[i], in pm8001_request_msix()
1011 &(pm8001_ha->irq_vector[i])); in pm8001_request_msix()
1014 free_irq(pci_irq_vector(pm8001_ha->pdev, i), in pm8001_request_msix()
1015 &(pm8001_ha->irq_vector[i])); in pm8001_request_msix()
1017 pci_free_irq_vectors(pm8001_ha->pdev); in pm8001_request_msix()
1027 * pm8001_request_irq - register interrupt
1032 struct pci_dev *pdev = pm8001_ha->pdev; in pm8001_request_irq()
1044 if (pdev->msix_cap && pci_msi_enabled()) in pm8001_request_irq()
1051 /* initialize the INT-X interrupt */ in pm8001_request_irq()
1052 pm8001_ha->irq_vector[0].irq_id = 0; in pm8001_request_irq()
1053 pm8001_ha->irq_vector[0].drv_inst = pm8001_ha; in pm8001_request_irq()
1055 return request_irq(pdev->irq, pm8001_interrupt_handler_intx, in pm8001_request_irq()
1056 IRQF_SHARED, pm8001_ha->name, in pm8001_request_irq()
1057 SHOST_TO_SAS_HA(pm8001_ha->shost)); in pm8001_request_irq()
1061 * pm8001_pci_probe - probe supported device
1078 struct sas_ha_struct *sha; in pm8001_pci_probe() local
1080 dev_printk(KERN_INFO, &pdev->dev, in pm8001_pci_probe()
1103 rc = -ENOMEM; in pm8001_pci_probe()
1106 chip = &pm8001_chips[ent->driver_data]; in pm8001_pci_probe()
1107 sha = kzalloc(sizeof(struct sas_ha_struct), GFP_KERNEL); in pm8001_pci_probe()
1108 if (!sha) { in pm8001_pci_probe()
1109 rc = -ENOMEM; in pm8001_pci_probe()
1112 SHOST_TO_SAS_HA(shost) = sha; in pm8001_pci_probe()
1116 rc = -ENOMEM; in pm8001_pci_probe()
1120 /* ent->driver variable is used to differentiate between controllers */ in pm8001_pci_probe()
1123 rc = -ENOMEM; in pm8001_pci_probe()
1127 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); in pm8001_pci_probe()
1128 rc = PM8001_CHIP_DISP->chip_init(pm8001_ha); in pm8001_pci_probe()
1140 PM8001_CHIP_DISP->chip_post_init(pm8001_ha); in pm8001_pci_probe()
1142 if (pm8001_ha->number_of_intr > 1) { in pm8001_pci_probe()
1143 shost->nr_hw_queues = pm8001_ha->number_of_intr - 1; in pm8001_pci_probe()
1149 shost->host_tagset = 1; in pm8001_pci_probe()
1152 rc = scsi_add_host(shost, &pdev->dev); in pm8001_pci_probe()
1156 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0); in pm8001_pci_probe()
1157 if (pm8001_ha->chip_id != chip_8001) { in pm8001_pci_probe()
1158 for (i = 1; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_probe()
1159 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i); in pm8001_pci_probe()
1179 list_add_tail(&pm8001_ha->list, &hba_list); in pm8001_pci_probe()
1180 pm8001_ha->flags = PM8001F_RUN_TIME; in pm8001_pci_probe()
1181 scsi_scan_host(pm8001_ha->shost); in pm8001_pci_probe()
1185 scsi_remove_host(pm8001_ha->shost); in pm8001_pci_probe()
1189 kfree(sha); in pm8001_pci_probe()
1201 * pm8001_init_ccb_tag - allocate memory to CCB and tag.
1206 struct Scsi_Host *shost = pm8001_ha->shost; in pm8001_init_ccb_tag()
1207 struct device *dev = pm8001_ha->dev; in pm8001_init_ccb_tag()
1211 max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io; in pm8001_init_ccb_tag()
1214 shost->can_queue = ccb_count - PM8001_RESERVE_SLOT; in pm8001_init_ccb_tag()
1216 pm8001_ha->rsvd_tags = bitmap_zalloc(PM8001_RESERVE_SLOT, GFP_KERNEL); in pm8001_init_ccb_tag()
1217 if (!pm8001_ha->rsvd_tags) in pm8001_init_ccb_tag()
1221 pm8001_ha->ccb_count = ccb_count; in pm8001_init_ccb_tag()
1222 pm8001_ha->ccb_info = in pm8001_init_ccb_tag()
1224 if (!pm8001_ha->ccb_info) { in pm8001_init_ccb_tag()
1230 pm8001_ha->ccb_info[i].buf_prd = dma_alloc_coherent(dev, in pm8001_init_ccb_tag()
1232 &pm8001_ha->ccb_info[i].ccb_dma_handle, in pm8001_init_ccb_tag()
1234 if (!pm8001_ha->ccb_info[i].buf_prd) { in pm8001_init_ccb_tag()
1239 pm8001_ha->ccb_info[i].task = NULL; in pm8001_init_ccb_tag()
1240 pm8001_ha->ccb_info[i].ccb_tag = PM8001_INVALID_TAG; in pm8001_init_ccb_tag()
1241 pm8001_ha->ccb_info[i].device = NULL; in pm8001_init_ccb_tag()
1247 kfree(pm8001_ha->devices); in pm8001_init_ccb_tag()
1249 return -ENOMEM; in pm8001_init_ccb_tag()
1254 struct sas_ha_struct *sha = pci_get_drvdata(pdev); in pm8001_pci_remove() local
1257 pm8001_ha = sha->lldd_ha; in pm8001_pci_remove()
1258 sas_unregister_ha(sha); in pm8001_pci_remove()
1259 sas_remove_host(pm8001_ha->shost); in pm8001_pci_remove()
1260 list_del(&pm8001_ha->list); in pm8001_pci_remove()
1261 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); in pm8001_pci_remove()
1262 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); in pm8001_pci_remove()
1265 for (i = 0; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_remove()
1267 for (i = 0; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_remove()
1268 free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]); in pm8001_pci_remove()
1271 free_irq(pm8001_ha->irq, sha); in pm8001_pci_remove()
1274 /* For non-msix and msix interrupts */ in pm8001_pci_remove()
1275 if ((!pdev->msix_cap || !pci_msi_enabled()) || in pm8001_pci_remove()
1276 (pm8001_ha->chip_id == chip_8001)) in pm8001_pci_remove()
1277 tasklet_kill(&pm8001_ha->tasklet[0]); in pm8001_pci_remove()
1280 tasklet_kill(&pm8001_ha->tasklet[j]); in pm8001_pci_remove()
1282 scsi_host_put(pm8001_ha->shost); in pm8001_pci_remove()
1284 for (i = 0; i < pm8001_ha->ccb_count; i++) { in pm8001_pci_remove()
1285 dma_free_coherent(&pm8001_ha->pdev->dev, in pm8001_pci_remove()
1287 pm8001_ha->ccb_info[i].buf_prd, in pm8001_pci_remove()
1288 pm8001_ha->ccb_info[i].ccb_dma_handle); in pm8001_pci_remove()
1290 kfree(pm8001_ha->ccb_info); in pm8001_pci_remove()
1291 kfree(pm8001_ha->devices); in pm8001_pci_remove()
1294 kfree(sha->sas_phy); in pm8001_pci_remove()
1295 kfree(sha->sas_port); in pm8001_pci_remove()
1296 kfree(sha); in pm8001_pci_remove()
1302 * pm8001_pci_suspend - power management suspend main entry point
1310 struct sas_ha_struct *sha = pci_get_drvdata(pdev); in pm8001_pci_suspend() local
1311 struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; in pm8001_pci_suspend()
1313 sas_suspend_ha(sha); in pm8001_pci_suspend()
1315 scsi_block_requests(pm8001_ha->shost); in pm8001_pci_suspend()
1316 if (!pdev->pm_cap) { in pm8001_pci_suspend()
1318 return -ENODEV; in pm8001_pci_suspend()
1320 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); in pm8001_pci_suspend()
1321 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); in pm8001_pci_suspend()
1323 for (i = 0; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_suspend()
1325 for (i = 0; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_suspend()
1326 free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]); in pm8001_pci_suspend()
1329 free_irq(pm8001_ha->irq, sha); in pm8001_pci_suspend()
1332 /* For non-msix and msix interrupts */ in pm8001_pci_suspend()
1333 if ((!pdev->msix_cap || !pci_msi_enabled()) || in pm8001_pci_suspend()
1334 (pm8001_ha->chip_id == chip_8001)) in pm8001_pci_suspend()
1335 tasklet_kill(&pm8001_ha->tasklet[0]); in pm8001_pci_suspend()
1338 tasklet_kill(&pm8001_ha->tasklet[j]); in pm8001_pci_suspend()
1342 pm8001_ha->name); in pm8001_pci_suspend()
1347 * pm8001_pci_resume - power management resume main entry point
1355 struct sas_ha_struct *sha = pci_get_drvdata(pdev); in pm8001_pci_resume() local
1361 pm8001_ha = sha->lldd_ha; in pm8001_pci_resume()
1365 pdev, pm8001_ha->name, pdev->current_state); in pm8001_pci_resume()
1370 sas_prep_resume_ha(sha); in pm8001_pci_resume()
1372 if (pm8001_ha->chip_id == chip_8001) { in pm8001_pci_resume()
1373 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha); in pm8001_pci_resume()
1376 rc = PM8001_CHIP_DISP->chip_init(pm8001_ha); in pm8001_pci_resume()
1381 PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); in pm8001_pci_resume()
1387 /* Tasklet for non msi-x interrupt handler */ in pm8001_pci_resume()
1388 if ((!pdev->msix_cap || !pci_msi_enabled()) || in pm8001_pci_resume()
1389 (pm8001_ha->chip_id == chip_8001)) in pm8001_pci_resume()
1390 tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet, in pm8001_pci_resume()
1391 (unsigned long)&(pm8001_ha->irq_vector[0])); in pm8001_pci_resume()
1394 tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet, in pm8001_pci_resume()
1395 (unsigned long)&(pm8001_ha->irq_vector[j])); in pm8001_pci_resume()
1397 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0); in pm8001_pci_resume()
1398 if (pm8001_ha->chip_id != chip_8001) { in pm8001_pci_resume()
1399 for (i = 1; i < pm8001_ha->number_of_intr; i++) in pm8001_pci_resume()
1400 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, i); in pm8001_pci_resume()
1408 if (pm8001_ha->chip_id == chip_8070 || in pm8001_pci_resume()
1409 pm8001_ha->chip_id == chip_8072) { in pm8001_pci_resume()
1415 pm8001_ha->flags = PM8001F_RUN_TIME; in pm8001_pci_resume()
1416 for (i = 0; i < pm8001_ha->chip->n_phy; i++) { in pm8001_pci_resume()
1417 pm8001_ha->phy[i].enable_completion = &completion; in pm8001_pci_resume()
1418 PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i); in pm8001_pci_resume()
1421 sas_resume_ha(sha); in pm8001_pci_resume()
1425 scsi_remove_host(pm8001_ha->shost); in pm8001_pci_resume()
1522 * pm8001_init - initialize scsi transport template
1526 int rc = -ENOMEM; in pm8001_init()
1564 "PMC-Sierra PM8001/8006/8081/8088/8089/8074/8076/8077/8070/8072 "