Lines Matching refs:asd_ha
79 static int asd_map_memio(struct asd_ha_struct *asd_ha) in asd_map_memio() argument
84 asd_ha->iospace = 0; in asd_map_memio()
86 io_handle = &asd_ha->io_handle[i==0?0:1]; in asd_map_memio()
87 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_memio()
88 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_memio()
89 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_memio()
93 i==0?0:1, pci_name(asd_ha->pcidev)); in asd_map_memio()
96 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_memio()
99 pci_name(asd_ha->pcidev)); in asd_map_memio()
105 pci_name(asd_ha->pcidev)); in asd_map_memio()
113 pci_release_region(asd_ha->pcidev, i); in asd_map_memio()
116 io_handle = &asd_ha->io_handle[0]; in asd_map_memio()
118 pci_release_region(asd_ha->pcidev, 0); in asd_map_memio()
123 static void asd_unmap_memio(struct asd_ha_struct *asd_ha) in asd_unmap_memio() argument
127 io_handle = &asd_ha->io_handle[1]; in asd_unmap_memio()
129 pci_release_region(asd_ha->pcidev, 2); in asd_unmap_memio()
131 io_handle = &asd_ha->io_handle[0]; in asd_unmap_memio()
133 pci_release_region(asd_ha->pcidev, 0); in asd_unmap_memio()
136 static int asd_map_ioport(struct asd_ha_struct *asd_ha) in asd_map_ioport() argument
139 struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; in asd_map_ioport()
141 asd_ha->iospace = 1; in asd_map_ioport()
142 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_ioport()
143 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_ioport()
144 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_ioport()
148 pci_name(asd_ha->pcidev)); in asd_map_ioport()
151 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_ioport()
154 pci_name(asd_ha->pcidev)); in asd_map_ioport()
160 static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) in asd_unmap_ioport() argument
162 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); in asd_unmap_ioport()
165 static int asd_map_ha(struct asd_ha_struct *asd_ha) in asd_map_ha() argument
170 err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); in asd_map_ha()
173 pci_name(asd_ha->pcidev)); in asd_map_ha()
179 if ((err = asd_map_memio(asd_ha))) in asd_map_ha()
182 if ((err = asd_map_ioport(asd_ha))) in asd_map_ha()
185 pci_name(asd_ha->pcidev)); in asd_map_ha()
188 pci_name(asd_ha->pcidev)); in asd_map_ha()
197 static void asd_unmap_ha(struct asd_ha_struct *asd_ha) in asd_unmap_ha() argument
199 if (asd_ha->iospace) in asd_unmap_ha()
200 asd_unmap_ioport(asd_ha); in asd_unmap_ha()
202 asd_unmap_memio(asd_ha); in asd_unmap_ha()
211 static int asd_common_setup(struct asd_ha_struct *asd_ha) in asd_common_setup() argument
215 asd_ha->revision_id = asd_ha->pcidev->revision; in asd_common_setup()
218 if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { in asd_common_setup()
220 pci_name(asd_ha->pcidev), in asd_common_setup()
221 asd_dev_rev[asd_ha->revision_id], in asd_common_setup()
222 asd_ha->revision_id); in asd_common_setup()
226 asd_ha->hw_prof.max_scbs = 512; in asd_common_setup()
227 asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; in asd_common_setup()
228 asd_ha->hw_prof.num_phys = ASD_MAX_PHYS; in asd_common_setup()
230 asd_ha->hw_prof.enabled_phys = 0xFF; in asd_common_setup()
232 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_common_setup()
234 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_common_setup()
236 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_common_setup()
238 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_common_setup()
247 static int asd_aic9410_setup(struct asd_ha_struct *asd_ha) in asd_aic9410_setup() argument
249 int err = asd_common_setup(asd_ha); in asd_aic9410_setup()
254 asd_ha->hw_prof.addr_range = 8; in asd_aic9410_setup()
255 asd_ha->hw_prof.port_name_base = 0; in asd_aic9410_setup()
256 asd_ha->hw_prof.dev_name_base = 8; in asd_aic9410_setup()
257 asd_ha->hw_prof.sata_name_base = 16; in asd_aic9410_setup()
262 static int asd_aic9405_setup(struct asd_ha_struct *asd_ha) in asd_aic9405_setup() argument
264 int err = asd_common_setup(asd_ha); in asd_aic9405_setup()
269 asd_ha->hw_prof.addr_range = 4; in asd_aic9405_setup()
270 asd_ha->hw_prof.port_name_base = 0; in asd_aic9405_setup()
271 asd_ha->hw_prof.dev_name_base = 4; in asd_aic9405_setup()
272 asd_ha->hw_prof.sata_name_base = 8; in asd_aic9405_setup()
280 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_rev() local
282 asd_dev_rev[asd_ha->revision_id]); in asd_show_dev_rev()
289 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_bios_build() local
290 return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); in asd_show_dev_bios_build()
297 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_pcba_sn() local
298 return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); in asd_show_dev_pcba_sn()
345 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_store_update_bios() local
379 if (asd_ha->bios_status == FLASH_IN_PROGRESS) { in asd_store_update_bios()
383 err = request_firmware(&asd_ha->bios_image, in asd_store_update_bios()
385 &asd_ha->pcidev->dev); in asd_store_update_bios()
393 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data; in asd_store_update_bios()
395 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
396 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) && in asd_store_update_bios()
397 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
398 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) { in asd_store_update_bios()
407 asd_ha->pcidev->vendor, in asd_store_update_bios()
408 asd_ha->pcidev->device); in asd_store_update_bios()
413 if (hdr_ptr->filelen != asd_ha->bios_image->size) { in asd_store_update_bios()
420 csum += asd_ha->bios_image->data[i]; in asd_store_update_bios()
428 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
429 err = asd_write_flash_seg(asd_ha, in asd_store_update_bios()
430 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
433 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
434 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
437 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
438 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
439 &asd_ha->bios_image->data[sizeof(header)], in asd_store_update_bios()
444 release_firmware(asd_ha->bios_image); in asd_store_update_bios()
448 asd_ha->bios_status = err; in asd_store_update_bios()
460 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_update_bios() local
463 if (flash_error_table[i].err_code == asd_ha->bios_status) in asd_show_update_bios()
466 if (asd_ha->bios_status != FLASH_IN_PROGRESS) in asd_show_update_bios()
467 asd_ha->bios_status = FLASH_OK; in asd_show_update_bios()
477 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) in asd_create_dev_attrs() argument
481 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_create_dev_attrs()
485 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
489 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
492 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_create_dev_attrs()
499 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
501 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
503 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_create_dev_attrs()
507 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) in asd_remove_dev_attrs() argument
509 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_remove_dev_attrs()
510 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_remove_dev_attrs()
511 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_remove_dev_attrs()
512 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_remove_dev_attrs()
520 int (*setup)(struct asd_ha_struct *asd_ha);
534 static int asd_create_ha_caches(struct asd_ha_struct *asd_ha) in asd_create_ha_caches() argument
536 asd_ha->scb_pool = dma_pool_create(ASD_DRIVER_NAME "_scb_pool", in asd_create_ha_caches()
537 &asd_ha->pcidev->dev, in asd_create_ha_caches()
540 if (!asd_ha->scb_pool) { in asd_create_ha_caches()
552 static void asd_free_edbs(struct asd_ha_struct *asd_ha) in asd_free_edbs() argument
554 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_edbs()
558 asd_free_coherent(asd_ha, seq->edb_arr[i]); in asd_free_edbs()
563 static void asd_free_escbs(struct asd_ha_struct *asd_ha) in asd_free_escbs() argument
565 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_escbs()
578 static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) in asd_destroy_ha_caches() argument
582 if (asd_ha->hw_prof.ddb_ext) in asd_destroy_ha_caches()
583 asd_free_coherent(asd_ha, asd_ha->hw_prof.ddb_ext); in asd_destroy_ha_caches()
584 if (asd_ha->hw_prof.scb_ext) in asd_destroy_ha_caches()
585 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext); in asd_destroy_ha_caches()
587 if (asd_ha->hw_prof.ddb_bitmap) in asd_destroy_ha_caches()
588 kfree(asd_ha->hw_prof.ddb_bitmap); in asd_destroy_ha_caches()
589 asd_ha->hw_prof.ddb_bitmap = NULL; in asd_destroy_ha_caches()
592 struct asd_phy *phy = &asd_ha->phys[i]; in asd_destroy_ha_caches()
594 asd_free_coherent(asd_ha, phy->id_frm_tok); in asd_destroy_ha_caches()
596 if (asd_ha->seq.escb_arr) in asd_destroy_ha_caches()
597 asd_free_escbs(asd_ha); in asd_destroy_ha_caches()
598 if (asd_ha->seq.edb_arr) in asd_destroy_ha_caches()
599 asd_free_edbs(asd_ha); in asd_destroy_ha_caches()
600 if (asd_ha->hw_prof.ue.area) { in asd_destroy_ha_caches()
601 kfree(asd_ha->hw_prof.ue.area); in asd_destroy_ha_caches()
602 asd_ha->hw_prof.ue.area = NULL; in asd_destroy_ha_caches()
604 if (asd_ha->seq.tc_index_array) { in asd_destroy_ha_caches()
605 kfree(asd_ha->seq.tc_index_array); in asd_destroy_ha_caches()
606 kfree(asd_ha->seq.tc_index_bitmap); in asd_destroy_ha_caches()
607 asd_ha->seq.tc_index_array = NULL; in asd_destroy_ha_caches()
608 asd_ha->seq.tc_index_bitmap = NULL; in asd_destroy_ha_caches()
610 if (asd_ha->seq.actual_dl) { in asd_destroy_ha_caches()
611 asd_free_coherent(asd_ha, asd_ha->seq.actual_dl); in asd_destroy_ha_caches()
612 asd_ha->seq.actual_dl = NULL; in asd_destroy_ha_caches()
613 asd_ha->seq.dl = NULL; in asd_destroy_ha_caches()
615 if (asd_ha->seq.next_scb.vaddr) { in asd_destroy_ha_caches()
616 dma_pool_free(asd_ha->scb_pool, asd_ha->seq.next_scb.vaddr, in asd_destroy_ha_caches()
617 asd_ha->seq.next_scb.dma_handle); in asd_destroy_ha_caches()
618 asd_ha->seq.next_scb.vaddr = NULL; in asd_destroy_ha_caches()
620 dma_pool_destroy(asd_ha->scb_pool); in asd_destroy_ha_caches()
621 asd_ha->scb_pool = NULL; in asd_destroy_ha_caches()
672 static int asd_register_sas_ha(struct asd_ha_struct *asd_ha) in asd_register_sas_ha() argument
686 asd_ha->sas_ha.sas_ha_name = (char *) asd_ha->name; in asd_register_sas_ha()
687 asd_ha->sas_ha.lldd_module = THIS_MODULE; in asd_register_sas_ha()
688 asd_ha->sas_ha.sas_addr = &asd_ha->hw_prof.sas_addr[0]; in asd_register_sas_ha()
691 sas_phys[i] = &asd_ha->phys[i].sas_phy; in asd_register_sas_ha()
692 sas_ports[i] = &asd_ha->ports[i]; in asd_register_sas_ha()
695 asd_ha->sas_ha.sas_phy = sas_phys; in asd_register_sas_ha()
696 asd_ha->sas_ha.sas_port= sas_ports; in asd_register_sas_ha()
697 asd_ha->sas_ha.num_phys= ASD_MAX_PHYS; in asd_register_sas_ha()
699 return sas_register_ha(&asd_ha->sas_ha); in asd_register_sas_ha()
702 static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) in asd_unregister_sas_ha() argument
706 scsi_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
707 err = sas_unregister_ha(&asd_ha->sas_ha); in asd_unregister_sas_ha()
709 sas_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
710 scsi_host_put(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
712 kfree(asd_ha->sas_ha.sas_phy); in asd_unregister_sas_ha()
713 kfree(asd_ha->sas_ha.sas_port); in asd_unregister_sas_ha()
722 struct asd_ha_struct *asd_ha; in asd_pci_probe() local
746 asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); in asd_pci_probe()
747 if (!asd_ha) { in asd_pci_probe()
751 asd_ha->pcidev = dev; in asd_pci_probe()
752 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; in asd_pci_probe()
753 asd_ha->sas_ha.lldd_ha = asd_ha; in asd_pci_probe()
755 asd_ha->bios_status = FLASH_OK; in asd_pci_probe()
756 asd_ha->name = asd_dev->name; in asd_pci_probe()
757 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev)); in asd_pci_probe()
759 SHOST_TO_SAS_HA(shost) = &asd_ha->sas_ha; in asd_pci_probe()
760 asd_ha->sas_ha.core.shost = shost; in asd_pci_probe()
770 err = asd_dev->setup(asd_ha); in asd_pci_probe()
786 pci_set_drvdata(dev, asd_ha); in asd_pci_probe()
788 err = asd_map_ha(asd_ha); in asd_pci_probe()
792 err = asd_create_ha_caches(asd_ha); in asd_pci_probe()
796 err = asd_init_hw(asd_ha); in asd_pci_probe()
802 pci_name(dev), SAS_ADDR(asd_ha->hw_prof.sas_addr), in asd_pci_probe()
803 asd_ha->hw_prof.pcba_sn, asd_ha->hw_prof.max_phys, in asd_pci_probe()
804 asd_ha->hw_prof.num_phys, in asd_pci_probe()
805 asd_ha->hw_prof.flash.present ? "present" : "not present", in asd_pci_probe()
806 asd_ha->hw_prof.bios.present ? "build " : "not present", in asd_pci_probe()
807 asd_ha->hw_prof.bios.bld); in asd_pci_probe()
809 shost->can_queue = asd_ha->seq.can_queue; in asd_pci_probe()
812 pci_enable_msi(asd_ha->pcidev); in asd_pci_probe()
814 err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, in asd_pci_probe()
815 ASD_DRIVER_NAME, asd_ha); in asd_pci_probe()
818 asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); in asd_pci_probe()
821 asd_enable_ints(asd_ha); in asd_pci_probe()
823 err = asd_init_post_escbs(asd_ha); in asd_pci_probe()
826 pci_name(asd_ha->pcidev)); in asd_pci_probe()
831 err = asd_create_dev_attrs(asd_ha); in asd_pci_probe()
835 err = asd_register_sas_ha(asd_ha); in asd_pci_probe()
844 asd_remove_dev_attrs(asd_ha); in asd_pci_probe()
847 asd_disable_ints(asd_ha); in asd_pci_probe()
848 free_irq(dev->irq, asd_ha); in asd_pci_probe()
852 asd_chip_hardrst(asd_ha); in asd_pci_probe()
854 asd_destroy_ha_caches(asd_ha); in asd_pci_probe()
856 asd_unmap_ha(asd_ha); in asd_pci_probe()
860 kfree(asd_ha); in asd_pci_probe()
868 static void asd_free_queues(struct asd_ha_struct *asd_ha) in asd_free_queues() argument
874 spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
875 asd_ha->seq.pending = 0; in asd_free_queues()
876 list_splice_init(&asd_ha->seq.pend_q, &pending); in asd_free_queues()
877 spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
899 static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) in asd_turn_off_leds() argument
901 u8 phy_mask = asd_ha->hw_prof.enabled_phys; in asd_turn_off_leds()
905 asd_turn_led(asd_ha, i, 0); in asd_turn_off_leds()
906 asd_control_led(asd_ha, i, 0); in asd_turn_off_leds()
912 struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); in asd_pci_remove() local
914 if (!asd_ha) in asd_pci_remove()
917 asd_unregister_sas_ha(asd_ha); in asd_pci_remove()
919 asd_disable_ints(asd_ha); in asd_pci_remove()
921 asd_remove_dev_attrs(asd_ha); in asd_pci_remove()
925 free_irq(dev->irq, asd_ha); in asd_pci_remove()
927 pci_disable_msi(asd_ha->pcidev); in asd_pci_remove()
928 asd_turn_off_leds(asd_ha); in asd_pci_remove()
929 asd_chip_hardrst(asd_ha); in asd_pci_remove()
930 asd_free_queues(asd_ha); in asd_pci_remove()
931 asd_destroy_ha_caches(asd_ha); in asd_pci_remove()
932 asd_unmap_ha(asd_ha); in asd_pci_remove()
933 kfree(asd_ha); in asd_pci_remove()
940 struct asd_ha_struct *asd_ha; in asd_scan_start() local
943 asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; in asd_scan_start()
944 err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); in asd_scan_start()