Lines Matching refs:asd_ha

65 static int asd_map_memio(struct asd_ha_struct *asd_ha)  in asd_map_memio()  argument
70 asd_ha->iospace = 0; in asd_map_memio()
72 io_handle = &asd_ha->io_handle[i==0?0:1]; in asd_map_memio()
73 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_memio()
74 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_memio()
75 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_memio()
79 i==0?0:1, pci_name(asd_ha->pcidev)); in asd_map_memio()
82 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_memio()
85 pci_name(asd_ha->pcidev)); in asd_map_memio()
91 pci_name(asd_ha->pcidev)); in asd_map_memio()
99 pci_release_region(asd_ha->pcidev, i); in asd_map_memio()
102 io_handle = &asd_ha->io_handle[0]; in asd_map_memio()
104 pci_release_region(asd_ha->pcidev, 0); in asd_map_memio()
109 static void asd_unmap_memio(struct asd_ha_struct *asd_ha) in asd_unmap_memio() argument
113 io_handle = &asd_ha->io_handle[1]; in asd_unmap_memio()
115 pci_release_region(asd_ha->pcidev, 2); in asd_unmap_memio()
117 io_handle = &asd_ha->io_handle[0]; in asd_unmap_memio()
119 pci_release_region(asd_ha->pcidev, 0); in asd_unmap_memio()
122 static int asd_map_ioport(struct asd_ha_struct *asd_ha) in asd_map_ioport() argument
125 struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; in asd_map_ioport()
127 asd_ha->iospace = 1; in asd_map_ioport()
128 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_ioport()
129 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_ioport()
130 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_ioport()
134 pci_name(asd_ha->pcidev)); in asd_map_ioport()
137 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_ioport()
140 pci_name(asd_ha->pcidev)); in asd_map_ioport()
146 static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) in asd_unmap_ioport() argument
148 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); in asd_unmap_ioport()
151 static int asd_map_ha(struct asd_ha_struct *asd_ha) in asd_map_ha() argument
156 err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); in asd_map_ha()
159 pci_name(asd_ha->pcidev)); in asd_map_ha()
165 if ((err = asd_map_memio(asd_ha))) in asd_map_ha()
168 if ((err = asd_map_ioport(asd_ha))) in asd_map_ha()
171 pci_name(asd_ha->pcidev)); in asd_map_ha()
174 pci_name(asd_ha->pcidev)); in asd_map_ha()
183 static void asd_unmap_ha(struct asd_ha_struct *asd_ha) in asd_unmap_ha() argument
185 if (asd_ha->iospace) in asd_unmap_ha()
186 asd_unmap_ioport(asd_ha); in asd_unmap_ha()
188 asd_unmap_memio(asd_ha); in asd_unmap_ha()
197 static int asd_common_setup(struct asd_ha_struct *asd_ha) in asd_common_setup() argument
201 asd_ha->revision_id = asd_ha->pcidev->revision; in asd_common_setup()
204 if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { in asd_common_setup()
206 pci_name(asd_ha->pcidev), in asd_common_setup()
207 asd_dev_rev[asd_ha->revision_id], in asd_common_setup()
208 asd_ha->revision_id); in asd_common_setup()
212 asd_ha->hw_prof.max_scbs = 512; in asd_common_setup()
213 asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; in asd_common_setup()
214 asd_ha->hw_prof.num_phys = ASD_MAX_PHYS; in asd_common_setup()
216 asd_ha->hw_prof.enabled_phys = 0xFF; in asd_common_setup()
218 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_common_setup()
220 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_common_setup()
222 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_common_setup()
224 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_common_setup()
233 static int asd_aic9410_setup(struct asd_ha_struct *asd_ha) in asd_aic9410_setup() argument
235 int err = asd_common_setup(asd_ha); in asd_aic9410_setup()
240 asd_ha->hw_prof.addr_range = 8; in asd_aic9410_setup()
241 asd_ha->hw_prof.port_name_base = 0; in asd_aic9410_setup()
242 asd_ha->hw_prof.dev_name_base = 8; in asd_aic9410_setup()
243 asd_ha->hw_prof.sata_name_base = 16; in asd_aic9410_setup()
248 static int asd_aic9405_setup(struct asd_ha_struct *asd_ha) in asd_aic9405_setup() argument
250 int err = asd_common_setup(asd_ha); in asd_aic9405_setup()
255 asd_ha->hw_prof.addr_range = 4; in asd_aic9405_setup()
256 asd_ha->hw_prof.port_name_base = 0; in asd_aic9405_setup()
257 asd_ha->hw_prof.dev_name_base = 4; in asd_aic9405_setup()
258 asd_ha->hw_prof.sata_name_base = 8; in asd_aic9405_setup()
266 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_rev() local
268 asd_dev_rev[asd_ha->revision_id]); in asd_show_dev_rev()
275 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_bios_build() local
276 return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); in asd_show_dev_bios_build()
283 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_pcba_sn() local
284 return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); in asd_show_dev_pcba_sn()
331 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_store_update_bios() local
365 if (asd_ha->bios_status == FLASH_IN_PROGRESS) { in asd_store_update_bios()
369 err = request_firmware(&asd_ha->bios_image, in asd_store_update_bios()
371 &asd_ha->pcidev->dev); in asd_store_update_bios()
379 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data; in asd_store_update_bios()
381 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
382 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) && in asd_store_update_bios()
383 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
384 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) { in asd_store_update_bios()
393 asd_ha->pcidev->vendor, in asd_store_update_bios()
394 asd_ha->pcidev->device); in asd_store_update_bios()
399 if (hdr_ptr->filelen != asd_ha->bios_image->size) { in asd_store_update_bios()
406 csum += asd_ha->bios_image->data[i]; in asd_store_update_bios()
414 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
415 err = asd_write_flash_seg(asd_ha, in asd_store_update_bios()
416 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
419 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
420 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
423 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
424 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
425 &asd_ha->bios_image->data[sizeof(header)], in asd_store_update_bios()
430 release_firmware(asd_ha->bios_image); in asd_store_update_bios()
434 asd_ha->bios_status = err; in asd_store_update_bios()
446 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_update_bios() local
449 if (flash_error_table[i].err_code == asd_ha->bios_status) in asd_show_update_bios()
452 if (asd_ha->bios_status != FLASH_IN_PROGRESS) in asd_show_update_bios()
453 asd_ha->bios_status = FLASH_OK; in asd_show_update_bios()
463 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) in asd_create_dev_attrs() argument
467 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
471 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
475 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
478 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_create_dev_attrs()
485 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
487 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
489 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
493 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) in asd_remove_dev_attrs() argument
495 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_remove_dev_attrs()
496 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_remove_dev_attrs()
497 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_remove_dev_attrs()
498 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_remove_dev_attrs()
506 int (*setup)(struct asd_ha_struct *asd_ha);
520 static int asd_create_ha_caches(struct asd_ha_struct *asd_ha) in asd_create_ha_caches() argument
522 asd_ha->scb_pool = dma_pool_create(ASD_DRIVER_NAME "_scb_pool", in asd_create_ha_caches()
523 &asd_ha->pcidev->dev, in asd_create_ha_caches()
526 if (!asd_ha->scb_pool) { in asd_create_ha_caches()
538 static void asd_free_edbs(struct asd_ha_struct *asd_ha) in asd_free_edbs() argument
540 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_edbs()
544 asd_free_coherent(asd_ha, seq->edb_arr[i]); in asd_free_edbs()
549 static void asd_free_escbs(struct asd_ha_struct *asd_ha) in asd_free_escbs() argument
551 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_escbs()
564 static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) in asd_destroy_ha_caches() argument
568 if (asd_ha->hw_prof.ddb_ext) in asd_destroy_ha_caches()
569 asd_free_coherent(asd_ha, asd_ha->hw_prof.ddb_ext); in asd_destroy_ha_caches()
570 if (asd_ha->hw_prof.scb_ext) in asd_destroy_ha_caches()
571 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext); in asd_destroy_ha_caches()
573 kfree(asd_ha->hw_prof.ddb_bitmap); in asd_destroy_ha_caches()
574 asd_ha->hw_prof.ddb_bitmap = NULL; in asd_destroy_ha_caches()
577 struct asd_phy *phy = &asd_ha->phys[i]; in asd_destroy_ha_caches()
579 asd_free_coherent(asd_ha, phy->id_frm_tok); in asd_destroy_ha_caches()
581 if (asd_ha->seq.escb_arr) in asd_destroy_ha_caches()
582 asd_free_escbs(asd_ha); in asd_destroy_ha_caches()
583 if (asd_ha->seq.edb_arr) in asd_destroy_ha_caches()
584 asd_free_edbs(asd_ha); in asd_destroy_ha_caches()
585 if (asd_ha->hw_prof.ue.area) { in asd_destroy_ha_caches()
586 kfree(asd_ha->hw_prof.ue.area); in asd_destroy_ha_caches()
587 asd_ha->hw_prof.ue.area = NULL; in asd_destroy_ha_caches()
589 if (asd_ha->seq.tc_index_array) { in asd_destroy_ha_caches()
590 kfree(asd_ha->seq.tc_index_array); in asd_destroy_ha_caches()
591 kfree(asd_ha->seq.tc_index_bitmap); in asd_destroy_ha_caches()
592 asd_ha->seq.tc_index_array = NULL; in asd_destroy_ha_caches()
593 asd_ha->seq.tc_index_bitmap = NULL; in asd_destroy_ha_caches()
595 if (asd_ha->seq.actual_dl) { in asd_destroy_ha_caches()
596 asd_free_coherent(asd_ha, asd_ha->seq.actual_dl); in asd_destroy_ha_caches()
597 asd_ha->seq.actual_dl = NULL; in asd_destroy_ha_caches()
598 asd_ha->seq.dl = NULL; in asd_destroy_ha_caches()
600 if (asd_ha->seq.next_scb.vaddr) { in asd_destroy_ha_caches()
601 dma_pool_free(asd_ha->scb_pool, asd_ha->seq.next_scb.vaddr, in asd_destroy_ha_caches()
602 asd_ha->seq.next_scb.dma_handle); in asd_destroy_ha_caches()
603 asd_ha->seq.next_scb.vaddr = NULL; in asd_destroy_ha_caches()
605 dma_pool_destroy(asd_ha->scb_pool); in asd_destroy_ha_caches()
606 asd_ha->scb_pool = NULL; in asd_destroy_ha_caches()
655 static int asd_register_sas_ha(struct asd_ha_struct *asd_ha) in asd_register_sas_ha() argument
669 asd_ha->sas_ha.sas_ha_name = (char *) asd_ha->name; in asd_register_sas_ha()
670 asd_ha->sas_ha.lldd_module = THIS_MODULE; in asd_register_sas_ha()
671 asd_ha->sas_ha.sas_addr = &asd_ha->hw_prof.sas_addr[0]; in asd_register_sas_ha()
674 sas_phys[i] = &asd_ha->phys[i].sas_phy; in asd_register_sas_ha()
675 sas_ports[i] = &asd_ha->ports[i]; in asd_register_sas_ha()
678 asd_ha->sas_ha.sas_phy = sas_phys; in asd_register_sas_ha()
679 asd_ha->sas_ha.sas_port= sas_ports; in asd_register_sas_ha()
680 asd_ha->sas_ha.num_phys= ASD_MAX_PHYS; in asd_register_sas_ha()
682 return sas_register_ha(&asd_ha->sas_ha); in asd_register_sas_ha()
685 static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) in asd_unregister_sas_ha() argument
689 err = sas_unregister_ha(&asd_ha->sas_ha); in asd_unregister_sas_ha()
691 sas_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
692 scsi_host_put(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
694 kfree(asd_ha->sas_ha.sas_phy); in asd_unregister_sas_ha()
695 kfree(asd_ha->sas_ha.sas_port); in asd_unregister_sas_ha()
704 struct asd_ha_struct *asd_ha; in asd_pci_probe() local
728 asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); in asd_pci_probe()
729 if (!asd_ha) { in asd_pci_probe()
733 asd_ha->pcidev = dev; in asd_pci_probe()
734 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; in asd_pci_probe()
735 asd_ha->sas_ha.lldd_ha = asd_ha; in asd_pci_probe()
737 asd_ha->bios_status = FLASH_OK; in asd_pci_probe()
738 asd_ha->name = asd_dev->name; in asd_pci_probe()
739 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev)); in asd_pci_probe()
741 SHOST_TO_SAS_HA(shost) = &asd_ha->sas_ha; in asd_pci_probe()
742 asd_ha->sas_ha.core.shost = shost; in asd_pci_probe()
752 err = asd_dev->setup(asd_ha); in asd_pci_probe()
765 pci_set_drvdata(dev, asd_ha); in asd_pci_probe()
767 err = asd_map_ha(asd_ha); in asd_pci_probe()
771 err = asd_create_ha_caches(asd_ha); in asd_pci_probe()
775 err = asd_init_hw(asd_ha); in asd_pci_probe()
781 pci_name(dev), SAS_ADDR(asd_ha->hw_prof.sas_addr), in asd_pci_probe()
782 asd_ha->hw_prof.pcba_sn, asd_ha->hw_prof.max_phys, in asd_pci_probe()
783 asd_ha->hw_prof.num_phys, in asd_pci_probe()
784 asd_ha->hw_prof.flash.present ? "present" : "not present", in asd_pci_probe()
785 asd_ha->hw_prof.bios.present ? "build " : "not present", in asd_pci_probe()
786 asd_ha->hw_prof.bios.bld); in asd_pci_probe()
788 shost->can_queue = asd_ha->seq.can_queue; in asd_pci_probe()
791 pci_enable_msi(asd_ha->pcidev); in asd_pci_probe()
793 err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, in asd_pci_probe()
794 ASD_DRIVER_NAME, asd_ha); in asd_pci_probe()
797 asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); in asd_pci_probe()
800 asd_enable_ints(asd_ha); in asd_pci_probe()
802 err = asd_init_post_escbs(asd_ha); in asd_pci_probe()
805 pci_name(asd_ha->pcidev)); in asd_pci_probe()
810 err = asd_create_dev_attrs(asd_ha); in asd_pci_probe()
814 err = asd_register_sas_ha(asd_ha); in asd_pci_probe()
823 asd_remove_dev_attrs(asd_ha); in asd_pci_probe()
826 asd_disable_ints(asd_ha); in asd_pci_probe()
827 free_irq(dev->irq, asd_ha); in asd_pci_probe()
831 asd_chip_hardrst(asd_ha); in asd_pci_probe()
833 asd_destroy_ha_caches(asd_ha); in asd_pci_probe()
835 asd_unmap_ha(asd_ha); in asd_pci_probe()
839 kfree(asd_ha); in asd_pci_probe()
847 static void asd_free_queues(struct asd_ha_struct *asd_ha) in asd_free_queues() argument
853 spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
854 asd_ha->seq.pending = 0; in asd_free_queues()
855 list_splice_init(&asd_ha->seq.pend_q, &pending); in asd_free_queues()
856 spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
878 static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) in asd_turn_off_leds() argument
880 u8 phy_mask = asd_ha->hw_prof.enabled_phys; in asd_turn_off_leds()
884 asd_turn_led(asd_ha, i, 0); in asd_turn_off_leds()
885 asd_control_led(asd_ha, i, 0); in asd_turn_off_leds()
891 struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); in asd_pci_remove() local
893 if (!asd_ha) in asd_pci_remove()
896 asd_unregister_sas_ha(asd_ha); in asd_pci_remove()
898 asd_disable_ints(asd_ha); in asd_pci_remove()
900 asd_remove_dev_attrs(asd_ha); in asd_pci_remove()
904 free_irq(dev->irq, asd_ha); in asd_pci_remove()
906 pci_disable_msi(asd_ha->pcidev); in asd_pci_remove()
907 asd_turn_off_leds(asd_ha); in asd_pci_remove()
908 asd_chip_hardrst(asd_ha); in asd_pci_remove()
909 asd_free_queues(asd_ha); in asd_pci_remove()
910 asd_destroy_ha_caches(asd_ha); in asd_pci_remove()
911 asd_unmap_ha(asd_ha); in asd_pci_remove()
912 kfree(asd_ha); in asd_pci_remove()
919 struct asd_ha_struct *asd_ha; in asd_scan_start() local
922 asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; in asd_scan_start()
923 err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); in asd_scan_start()