41 #include <linux/slab.h>
114 sas_phy->
enabled = (phy_id < pm8001_ha->
chip->n_phy) ? 1 : 0;
144 pm8001_ha->
memoryMap.region[i].element_size,
146 pm8001_ha->
memoryMap.region[i].phys_addr);
150 if (pm8001_ha->
shost)
157 #ifdef PM8001_USE_TASKLET
158 static void pm8001_tasklet(
unsigned long opaque)
185 #ifdef PM8001_USE_TASKLET
186 tasklet_schedule(&pm8001_ha->
tasklet);
202 for (i = 0; i < pm8001_ha->
chip->n_phy; i++) {
203 pm8001_phy_init(pm8001_ha, i);
204 pm8001_ha->
port[
i].wide_port_phymap = 0;
205 pm8001_ha->
port[
i].port_attached = 0;
206 pm8001_ha->
port[
i].port_state = 0;
207 INIT_LIST_HEAD(&pm8001_ha->
port[i].list);
211 if (!pm8001_ha->
tags)
269 &pm8001_ha->
memoryMap.region[i].virt_ptr,
270 &pm8001_ha->
memoryMap.region[i].phys_addr,
271 &pm8001_ha->
memoryMap.region[i].phys_addr_hi,
272 &pm8001_ha->
memoryMap.region[i].phys_addr_lo,
273 pm8001_ha->
memoryMap.region[i].total_len,
274 pm8001_ha->
memoryMap.region[i].alignment) != 0) {
287 pm8001_ha->
devices[
i].running_req = 0;
295 pm8001_ha->
ccb_info[
i].ccb_tag = 0xffffffff;
318 pdev = pm8001_ha->
pdev;
320 for (bar = 0; bar < 6; bar++) {
329 if ((bar == 1) || (bar == 3))
332 pm8001_ha->
io_mem[logicalBar].membase =
334 pm8001_ha->
io_mem[logicalBar].membase &=
336 pm8001_ha->
io_mem[logicalBar].memsize =
338 pm8001_ha->
io_mem[logicalBar].memvirtaddr =
340 pm8001_ha->
io_mem[logicalBar].memsize);
343 "virt_addr=%lx,len=%d\n", bar, logicalBar,
345 pm8001_ha->
io_mem[logicalBar].memvirtaddr,
346 pm8001_ha->
io_mem[logicalBar].memsize));
348 pm8001_ha->
io_mem[logicalBar].membase = 0;
349 pm8001_ha->
io_mem[logicalBar].memsize = 0;
350 pm8001_ha->
io_mem[logicalBar].memvirtaddr = 0;
374 pm8001_ha->
pdev = pdev;
375 pm8001_ha->
dev = &pdev->
dev;
377 pm8001_ha->
chip = &pm8001_chips[pm8001_ha->
chip_id];
378 pm8001_ha->
irq = pdev->
irq;
379 pm8001_ha->
sas = sha;
381 pm8001_ha->
id = pm8001_id++;
384 #ifdef PM8001_USE_TASKLET
386 (
unsigned long)pm8001_ha);
388 pm8001_ioremap(pm8001_ha);
389 if (!pm8001_alloc(pm8001_ha))
391 pm8001_free(pm8001_ha);
399 static int pci_go_44(
struct pci_dev *pdev)
404 rc = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(44));
406 rc = pci_set_consistent_dma_mask(pdev,
410 "44-bit DMA enable failed\n");
418 "32-bit DMA enable failed\n");
421 rc = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
424 "32-bit consistent DMA enable failed\n");
444 phy_nr = chip_info->
n_phy;
446 memset(sha, 0x00,
sizeof(*sha));
447 arr_phy = kcalloc(phy_nr,
sizeof(
void *),
GFP_KERNEL);
450 arr_port = kcalloc(port_nr,
sizeof(
void *),
GFP_KERNEL);
490 for (i = 0; i < chip_info->
n_phy; i++) {
495 sha->
dev = pm8001_ha->
dev;
515 #ifdef PM8001_READ_VPD
524 for (i = 0; i < pm8001_ha->
chip->n_phy; i++) {
529 pm8001_ha->
phy[i].dev_sas_addr));
532 for (i = 0; i < pm8001_ha->
chip->n_phy; i++) {
533 pm8001_ha->
phy[
i].dev_sas_addr = 0x50010c600047f9d0ULL;
534 pm8001_ha->
phy[
i].dev_sas_addr =
536 (*(
u64 *)&pm8001_ha->
phy[i].dev_sas_addr));
543 #ifdef PM8001_USE_MSIX
553 u32 number_of_intr = 1;
560 for (i = 0; i < max_entry ; i++)
566 for (i = 0; i < number_of_intr; i++) {
570 for (
j = 0;
j <
i;
j++)
593 pdev = pm8001_ha->
pdev;
595 #ifdef PM8001_USE_MSIX
597 return pm8001_setup_msix(pm8001_ha, irq_handler);
638 pci_read_config_dword(pdev,
PCI_COMMAND, &pci_reg);
640 pci_write_config_dword(pdev,
PCI_COMMAND, pci_reg);
643 goto err_out_disable;
644 rc = pci_go_44(pdev);
646 goto err_out_regions;
651 goto err_out_regions;
658 goto err_out_free_host;
661 rc = pm8001_prep_sas_ha_init(shost, chip);
667 pm8001_ha = pm8001_pci_alloc(pdev,
chip_8001, shost);
676 goto err_out_ha_free;
678 rc = scsi_add_host(shost, &pdev->
dev);
680 goto err_out_ha_free;
681 rc = pm8001_request_irq(pm8001_ha);
686 pm8001_init_sas_add(pm8001_ha);
687 pm8001_post_sas_ha_init(shost, chip);
697 pm8001_free(pm8001_ha);
716 pci_set_drvdata(pdev,
NULL);
724 #ifdef PM8001_USE_MSIX
733 #ifdef PM8001_USE_TASKLET
736 pm8001_free(pm8001_ha);
767 #ifdef PM8001_USE_MSIX
776 #ifdef PM8001_USE_TASKLET
781 "operating state [D%d]\n", pdev,
782 pm8001_ha->
name, device_state);
795 static int pm8001_pci_resume(
struct pci_dev *pdev)
805 "operating state [D%d]\n", pdev, pm8001_ha->
name, device_state);
808 pci_enable_wake(pdev,
PCI_D0, 0);
812 pm8001_printk(
"slot=%s Enable device failed during resume\n",
818 rc = pci_go_44(pdev);
820 goto err_out_disable;
825 goto err_out_disable;
827 rc = pm8001_request_irq(pm8001_ha);
829 goto err_out_disable;
830 #ifdef PM8001_USE_TASKLET
832 (
unsigned long)pm8001_ha);
856 static struct pci_driver pm8001_pci_driver = {
858 .id_table = pm8001_pci_table,
859 .probe = pm8001_pci_probe,
861 .suspend = pm8001_pci_suspend,
862 .resume = pm8001_pci_resume,
868 static int __init pm8001_init(
void)
880 rc = pci_register_driver(&pm8001_pci_driver);
893 static void __exit pm8001_exit(
void)