Lines Matching refs:asd_ha
81 static int asd_map_memio(struct asd_ha_struct *asd_ha) in asd_map_memio() argument
86 asd_ha->iospace = 0; in asd_map_memio()
88 io_handle = &asd_ha->io_handle[i==0?0:1]; in asd_map_memio()
89 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_memio()
90 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_memio()
91 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_memio()
95 i==0?0:1, pci_name(asd_ha->pcidev)); in asd_map_memio()
98 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_memio()
101 pci_name(asd_ha->pcidev)); in asd_map_memio()
112 pci_name(asd_ha->pcidev)); in asd_map_memio()
119 pci_release_region(asd_ha->pcidev, i); in asd_map_memio()
122 io_handle = &asd_ha->io_handle[0]; in asd_map_memio()
124 pci_release_region(asd_ha->pcidev, 0); in asd_map_memio()
129 static void asd_unmap_memio(struct asd_ha_struct *asd_ha) in asd_unmap_memio() argument
133 io_handle = &asd_ha->io_handle[1]; in asd_unmap_memio()
135 pci_release_region(asd_ha->pcidev, 2); in asd_unmap_memio()
137 io_handle = &asd_ha->io_handle[0]; in asd_unmap_memio()
139 pci_release_region(asd_ha->pcidev, 0); in asd_unmap_memio()
142 static int asd_map_ioport(struct asd_ha_struct *asd_ha) in asd_map_ioport() argument
145 struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; in asd_map_ioport()
147 asd_ha->iospace = 1; in asd_map_ioport()
148 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_ioport()
149 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_ioport()
150 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_ioport()
154 pci_name(asd_ha->pcidev)); in asd_map_ioport()
157 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_ioport()
160 pci_name(asd_ha->pcidev)); in asd_map_ioport()
166 static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) in asd_unmap_ioport() argument
168 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); in asd_unmap_ioport()
171 static int asd_map_ha(struct asd_ha_struct *asd_ha) in asd_map_ha() argument
176 err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); in asd_map_ha()
179 pci_name(asd_ha->pcidev)); in asd_map_ha()
185 if ((err = asd_map_memio(asd_ha))) in asd_map_ha()
188 if ((err = asd_map_ioport(asd_ha))) in asd_map_ha()
191 pci_name(asd_ha->pcidev)); in asd_map_ha()
194 pci_name(asd_ha->pcidev)); in asd_map_ha()
203 static void asd_unmap_ha(struct asd_ha_struct *asd_ha) in asd_unmap_ha() argument
205 if (asd_ha->iospace) in asd_unmap_ha()
206 asd_unmap_ioport(asd_ha); in asd_unmap_ha()
208 asd_unmap_memio(asd_ha); in asd_unmap_ha()
217 static int asd_common_setup(struct asd_ha_struct *asd_ha) in asd_common_setup() argument
221 asd_ha->revision_id = asd_ha->pcidev->revision; in asd_common_setup()
224 if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { in asd_common_setup()
226 pci_name(asd_ha->pcidev), in asd_common_setup()
227 asd_dev_rev[asd_ha->revision_id], in asd_common_setup()
228 asd_ha->revision_id); in asd_common_setup()
232 asd_ha->hw_prof.max_scbs = 512; in asd_common_setup()
233 asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; in asd_common_setup()
234 asd_ha->hw_prof.num_phys = ASD_MAX_PHYS; in asd_common_setup()
236 asd_ha->hw_prof.enabled_phys = 0xFF; in asd_common_setup()
238 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_common_setup()
240 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_common_setup()
242 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_common_setup()
244 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_common_setup()
253 static int asd_aic9410_setup(struct asd_ha_struct *asd_ha) in asd_aic9410_setup() argument
255 int err = asd_common_setup(asd_ha); in asd_aic9410_setup()
260 asd_ha->hw_prof.addr_range = 8; in asd_aic9410_setup()
261 asd_ha->hw_prof.port_name_base = 0; in asd_aic9410_setup()
262 asd_ha->hw_prof.dev_name_base = 8; in asd_aic9410_setup()
263 asd_ha->hw_prof.sata_name_base = 16; in asd_aic9410_setup()
268 static int asd_aic9405_setup(struct asd_ha_struct *asd_ha) in asd_aic9405_setup() argument
270 int err = asd_common_setup(asd_ha); in asd_aic9405_setup()
275 asd_ha->hw_prof.addr_range = 4; in asd_aic9405_setup()
276 asd_ha->hw_prof.port_name_base = 0; in asd_aic9405_setup()
277 asd_ha->hw_prof.dev_name_base = 4; in asd_aic9405_setup()
278 asd_ha->hw_prof.sata_name_base = 8; in asd_aic9405_setup()
286 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_rev() local
288 asd_dev_rev[asd_ha->revision_id]); in asd_show_dev_rev()
295 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_bios_build() local
296 return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); in asd_show_dev_bios_build()
303 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_pcba_sn() local
304 return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); in asd_show_dev_pcba_sn()
351 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_store_update_bios() local
385 if (asd_ha->bios_status == FLASH_IN_PROGRESS) { in asd_store_update_bios()
389 err = request_firmware(&asd_ha->bios_image, in asd_store_update_bios()
391 &asd_ha->pcidev->dev); in asd_store_update_bios()
399 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data; in asd_store_update_bios()
401 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
402 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) && in asd_store_update_bios()
403 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
404 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) { in asd_store_update_bios()
413 asd_ha->pcidev->vendor, in asd_store_update_bios()
414 asd_ha->pcidev->device); in asd_store_update_bios()
419 if (hdr_ptr->filelen != asd_ha->bios_image->size) { in asd_store_update_bios()
426 csum += asd_ha->bios_image->data[i]; in asd_store_update_bios()
434 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
435 err = asd_write_flash_seg(asd_ha, in asd_store_update_bios()
436 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
439 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
440 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
443 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
444 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
445 &asd_ha->bios_image->data[sizeof(header)], in asd_store_update_bios()
450 release_firmware(asd_ha->bios_image); in asd_store_update_bios()
454 asd_ha->bios_status = err; in asd_store_update_bios()
466 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_update_bios() local
469 if (flash_error_table[i].err_code == asd_ha->bios_status) in asd_show_update_bios()
472 if (asd_ha->bios_status != FLASH_IN_PROGRESS) in asd_show_update_bios()
473 asd_ha->bios_status = FLASH_OK; in asd_show_update_bios()
483 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) in asd_create_dev_attrs() argument
487 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_create_dev_attrs()
491 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
495 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
498 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_create_dev_attrs()
505 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
507 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
509 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_create_dev_attrs()
513 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) in asd_remove_dev_attrs() argument
515 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision); in asd_remove_dev_attrs()
516 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_remove_dev_attrs()
517 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_remove_dev_attrs()
518 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_remove_dev_attrs()
526 int (*setup)(struct asd_ha_struct *asd_ha);
540 static int asd_create_ha_caches(struct asd_ha_struct *asd_ha) in asd_create_ha_caches() argument
542 asd_ha->scb_pool = dma_pool_create(ASD_DRIVER_NAME "_scb_pool", in asd_create_ha_caches()
543 &asd_ha->pcidev->dev, in asd_create_ha_caches()
546 if (!asd_ha->scb_pool) { in asd_create_ha_caches()
558 static void asd_free_edbs(struct asd_ha_struct *asd_ha) in asd_free_edbs() argument
560 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_edbs()
564 asd_free_coherent(asd_ha, seq->edb_arr[i]); in asd_free_edbs()
569 static void asd_free_escbs(struct asd_ha_struct *asd_ha) in asd_free_escbs() argument
571 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_escbs()
584 static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) in asd_destroy_ha_caches() argument
588 if (asd_ha->hw_prof.ddb_ext) in asd_destroy_ha_caches()
589 asd_free_coherent(asd_ha, asd_ha->hw_prof.ddb_ext); in asd_destroy_ha_caches()
590 if (asd_ha->hw_prof.scb_ext) in asd_destroy_ha_caches()
591 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext); in asd_destroy_ha_caches()
593 if (asd_ha->hw_prof.ddb_bitmap) in asd_destroy_ha_caches()
594 kfree(asd_ha->hw_prof.ddb_bitmap); in asd_destroy_ha_caches()
595 asd_ha->hw_prof.ddb_bitmap = NULL; in asd_destroy_ha_caches()
598 struct asd_phy *phy = &asd_ha->phys[i]; in asd_destroy_ha_caches()
600 asd_free_coherent(asd_ha, phy->id_frm_tok); in asd_destroy_ha_caches()
602 if (asd_ha->seq.escb_arr) in asd_destroy_ha_caches()
603 asd_free_escbs(asd_ha); in asd_destroy_ha_caches()
604 if (asd_ha->seq.edb_arr) in asd_destroy_ha_caches()
605 asd_free_edbs(asd_ha); in asd_destroy_ha_caches()
606 if (asd_ha->hw_prof.ue.area) { in asd_destroy_ha_caches()
607 kfree(asd_ha->hw_prof.ue.area); in asd_destroy_ha_caches()
608 asd_ha->hw_prof.ue.area = NULL; in asd_destroy_ha_caches()
610 if (asd_ha->seq.tc_index_array) { in asd_destroy_ha_caches()
611 kfree(asd_ha->seq.tc_index_array); in asd_destroy_ha_caches()
612 kfree(asd_ha->seq.tc_index_bitmap); in asd_destroy_ha_caches()
613 asd_ha->seq.tc_index_array = NULL; in asd_destroy_ha_caches()
614 asd_ha->seq.tc_index_bitmap = NULL; in asd_destroy_ha_caches()
616 if (asd_ha->seq.actual_dl) { in asd_destroy_ha_caches()
617 asd_free_coherent(asd_ha, asd_ha->seq.actual_dl); in asd_destroy_ha_caches()
618 asd_ha->seq.actual_dl = NULL; in asd_destroy_ha_caches()
619 asd_ha->seq.dl = NULL; in asd_destroy_ha_caches()
621 if (asd_ha->seq.next_scb.vaddr) { in asd_destroy_ha_caches()
622 dma_pool_free(asd_ha->scb_pool, asd_ha->seq.next_scb.vaddr, in asd_destroy_ha_caches()
623 asd_ha->seq.next_scb.dma_handle); in asd_destroy_ha_caches()
624 asd_ha->seq.next_scb.vaddr = NULL; in asd_destroy_ha_caches()
626 dma_pool_destroy(asd_ha->scb_pool); in asd_destroy_ha_caches()
627 asd_ha->scb_pool = NULL; in asd_destroy_ha_caches()
678 static int asd_register_sas_ha(struct asd_ha_struct *asd_ha) in asd_register_sas_ha() argument
692 asd_ha->sas_ha.sas_ha_name = (char *) asd_ha->name; in asd_register_sas_ha()
693 asd_ha->sas_ha.lldd_module = THIS_MODULE; in asd_register_sas_ha()
694 asd_ha->sas_ha.sas_addr = &asd_ha->hw_prof.sas_addr[0]; in asd_register_sas_ha()
697 sas_phys[i] = &asd_ha->phys[i].sas_phy; in asd_register_sas_ha()
698 sas_ports[i] = &asd_ha->ports[i]; in asd_register_sas_ha()
701 asd_ha->sas_ha.sas_phy = sas_phys; in asd_register_sas_ha()
702 asd_ha->sas_ha.sas_port= sas_ports; in asd_register_sas_ha()
703 asd_ha->sas_ha.num_phys= ASD_MAX_PHYS; in asd_register_sas_ha()
705 return sas_register_ha(&asd_ha->sas_ha); in asd_register_sas_ha()
708 static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) in asd_unregister_sas_ha() argument
712 err = sas_unregister_ha(&asd_ha->sas_ha); in asd_unregister_sas_ha()
714 sas_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
715 scsi_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
716 scsi_host_put(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
718 kfree(asd_ha->sas_ha.sas_phy); in asd_unregister_sas_ha()
719 kfree(asd_ha->sas_ha.sas_port); in asd_unregister_sas_ha()
728 struct asd_ha_struct *asd_ha; in asd_pci_probe() local
752 asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); in asd_pci_probe()
753 if (!asd_ha) { in asd_pci_probe()
757 asd_ha->pcidev = dev; in asd_pci_probe()
758 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; in asd_pci_probe()
759 asd_ha->sas_ha.lldd_ha = asd_ha; in asd_pci_probe()
761 asd_ha->bios_status = FLASH_OK; in asd_pci_probe()
762 asd_ha->name = asd_dev->name; in asd_pci_probe()
763 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev)); in asd_pci_probe()
765 SHOST_TO_SAS_HA(shost) = &asd_ha->sas_ha; in asd_pci_probe()
766 asd_ha->sas_ha.core.shost = shost; in asd_pci_probe()
776 err = asd_dev->setup(asd_ha); in asd_pci_probe()
792 pci_set_drvdata(dev, asd_ha); in asd_pci_probe()
794 err = asd_map_ha(asd_ha); in asd_pci_probe()
798 err = asd_create_ha_caches(asd_ha); in asd_pci_probe()
802 err = asd_init_hw(asd_ha); in asd_pci_probe()
808 pci_name(dev), SAS_ADDR(asd_ha->hw_prof.sas_addr), in asd_pci_probe()
809 asd_ha->hw_prof.pcba_sn, asd_ha->hw_prof.max_phys, in asd_pci_probe()
810 asd_ha->hw_prof.num_phys, in asd_pci_probe()
811 asd_ha->hw_prof.flash.present ? "present" : "not present", in asd_pci_probe()
812 asd_ha->hw_prof.bios.present ? "build " : "not present", in asd_pci_probe()
813 asd_ha->hw_prof.bios.bld); in asd_pci_probe()
815 shost->can_queue = asd_ha->seq.can_queue; in asd_pci_probe()
818 pci_enable_msi(asd_ha->pcidev); in asd_pci_probe()
820 err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, in asd_pci_probe()
821 ASD_DRIVER_NAME, asd_ha); in asd_pci_probe()
824 asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); in asd_pci_probe()
827 asd_enable_ints(asd_ha); in asd_pci_probe()
829 err = asd_init_post_escbs(asd_ha); in asd_pci_probe()
832 pci_name(asd_ha->pcidev)); in asd_pci_probe()
837 err = asd_create_dev_attrs(asd_ha); in asd_pci_probe()
841 err = asd_register_sas_ha(asd_ha); in asd_pci_probe()
850 asd_remove_dev_attrs(asd_ha); in asd_pci_probe()
853 asd_disable_ints(asd_ha); in asd_pci_probe()
854 free_irq(dev->irq, asd_ha); in asd_pci_probe()
858 asd_chip_hardrst(asd_ha); in asd_pci_probe()
860 asd_destroy_ha_caches(asd_ha); in asd_pci_probe()
862 asd_unmap_ha(asd_ha); in asd_pci_probe()
866 kfree(asd_ha); in asd_pci_probe()
874 static void asd_free_queues(struct asd_ha_struct *asd_ha) in asd_free_queues() argument
880 spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
881 asd_ha->seq.pending = 0; in asd_free_queues()
882 list_splice_init(&asd_ha->seq.pend_q, &pending); in asd_free_queues()
883 spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
905 static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) in asd_turn_off_leds() argument
907 u8 phy_mask = asd_ha->hw_prof.enabled_phys; in asd_turn_off_leds()
911 asd_turn_led(asd_ha, i, 0); in asd_turn_off_leds()
912 asd_control_led(asd_ha, i, 0); in asd_turn_off_leds()
918 struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); in asd_pci_remove() local
920 if (!asd_ha) in asd_pci_remove()
923 asd_unregister_sas_ha(asd_ha); in asd_pci_remove()
925 asd_disable_ints(asd_ha); in asd_pci_remove()
927 asd_remove_dev_attrs(asd_ha); in asd_pci_remove()
931 free_irq(dev->irq, asd_ha); in asd_pci_remove()
933 pci_disable_msi(asd_ha->pcidev); in asd_pci_remove()
934 asd_turn_off_leds(asd_ha); in asd_pci_remove()
935 asd_chip_hardrst(asd_ha); in asd_pci_remove()
936 asd_free_queues(asd_ha); in asd_pci_remove()
937 asd_destroy_ha_caches(asd_ha); in asd_pci_remove()
938 asd_unmap_ha(asd_ha); in asd_pci_remove()
939 kfree(asd_ha); in asd_pci_remove()
946 struct asd_ha_struct *asd_ha; in asd_scan_start() local
949 asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; in asd_scan_start()
950 err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); in asd_scan_start()