Lines Matching refs:asd_ha

64 static int asd_map_memio(struct asd_ha_struct *asd_ha)  in asd_map_memio()  argument
69 asd_ha->iospace = 0; in asd_map_memio()
71 io_handle = &asd_ha->io_handle[i==0?0:1]; in asd_map_memio()
72 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_memio()
73 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_memio()
74 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_memio()
78 i==0?0:1, pci_name(asd_ha->pcidev)); in asd_map_memio()
81 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_memio()
84 pci_name(asd_ha->pcidev)); in asd_map_memio()
90 pci_name(asd_ha->pcidev)); in asd_map_memio()
98 pci_release_region(asd_ha->pcidev, i); in asd_map_memio()
101 io_handle = &asd_ha->io_handle[0]; in asd_map_memio()
103 pci_release_region(asd_ha->pcidev, 0); in asd_map_memio()
108 static void asd_unmap_memio(struct asd_ha_struct *asd_ha) in asd_unmap_memio() argument
112 io_handle = &asd_ha->io_handle[1]; in asd_unmap_memio()
114 pci_release_region(asd_ha->pcidev, 2); in asd_unmap_memio()
116 io_handle = &asd_ha->io_handle[0]; in asd_unmap_memio()
118 pci_release_region(asd_ha->pcidev, 0); in asd_unmap_memio()
121 static int asd_map_ioport(struct asd_ha_struct *asd_ha) in asd_map_ioport() argument
124 struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; in asd_map_ioport()
126 asd_ha->iospace = 1; in asd_map_ioport()
127 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_ioport()
128 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_ioport()
129 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_ioport()
133 pci_name(asd_ha->pcidev)); in asd_map_ioport()
136 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_ioport()
139 pci_name(asd_ha->pcidev)); in asd_map_ioport()
145 static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) in asd_unmap_ioport() argument
147 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); in asd_unmap_ioport()
150 static int asd_map_ha(struct asd_ha_struct *asd_ha) in asd_map_ha() argument
155 err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); in asd_map_ha()
158 pci_name(asd_ha->pcidev)); in asd_map_ha()
164 if ((err = asd_map_memio(asd_ha))) in asd_map_ha()
167 if ((err = asd_map_ioport(asd_ha))) in asd_map_ha()
170 pci_name(asd_ha->pcidev)); in asd_map_ha()
173 pci_name(asd_ha->pcidev)); in asd_map_ha()
182 static void asd_unmap_ha(struct asd_ha_struct *asd_ha) in asd_unmap_ha() argument
184 if (asd_ha->iospace) in asd_unmap_ha()
185 asd_unmap_ioport(asd_ha); in asd_unmap_ha()
187 asd_unmap_memio(asd_ha); in asd_unmap_ha()
196 static int asd_common_setup(struct asd_ha_struct *asd_ha) in asd_common_setup() argument
200 asd_ha->revision_id = asd_ha->pcidev->revision; in asd_common_setup()
203 if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { in asd_common_setup()
205 pci_name(asd_ha->pcidev), in asd_common_setup()
206 asd_dev_rev[asd_ha->revision_id], in asd_common_setup()
207 asd_ha->revision_id); in asd_common_setup()
211 asd_ha->hw_prof.max_scbs = 512; in asd_common_setup()
212 asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; in asd_common_setup()
213 asd_ha->hw_prof.num_phys = ASD_MAX_PHYS; in asd_common_setup()
215 asd_ha->hw_prof.enabled_phys = 0xFF; in asd_common_setup()
217 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_common_setup()
219 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_common_setup()
221 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_common_setup()
223 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_common_setup()
232 static int asd_aic9410_setup(struct asd_ha_struct *asd_ha) in asd_aic9410_setup() argument
234 int err = asd_common_setup(asd_ha); in asd_aic9410_setup()
239 asd_ha->hw_prof.addr_range = 8; in asd_aic9410_setup()
240 asd_ha->hw_prof.port_name_base = 0; in asd_aic9410_setup()
241 asd_ha->hw_prof.dev_name_base = 8; in asd_aic9410_setup()
242 asd_ha->hw_prof.sata_name_base = 16; in asd_aic9410_setup()
247 static int asd_aic9405_setup(struct asd_ha_struct *asd_ha) in asd_aic9405_setup() argument
249 int err = asd_common_setup(asd_ha); in asd_aic9405_setup()
254 asd_ha->hw_prof.addr_range = 4; in asd_aic9405_setup()
255 asd_ha->hw_prof.port_name_base = 0; in asd_aic9405_setup()
256 asd_ha->hw_prof.dev_name_base = 4; in asd_aic9405_setup()
257 asd_ha->hw_prof.sata_name_base = 8; in asd_aic9405_setup()
265 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_rev() local
267 asd_dev_rev[asd_ha->revision_id]); in asd_show_dev_rev()
274 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_bios_build() local
275 return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); in asd_show_dev_bios_build()
282 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_pcba_sn() local
283 return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); in asd_show_dev_pcba_sn()
330 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_store_update_bios() local
364 if (asd_ha->bios_status == FLASH_IN_PROGRESS) { in asd_store_update_bios()
368 err = request_firmware(&asd_ha->bios_image, in asd_store_update_bios()
370 &asd_ha->pcidev->dev); in asd_store_update_bios()
378 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data; in asd_store_update_bios()
380 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
381 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) && in asd_store_update_bios()
382 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
383 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) { in asd_store_update_bios()
392 asd_ha->pcidev->vendor, in asd_store_update_bios()
393 asd_ha->pcidev->device); in asd_store_update_bios()
398 if (hdr_ptr->filelen != asd_ha->bios_image->size) { in asd_store_update_bios()
405 csum += asd_ha->bios_image->data[i]; in asd_store_update_bios()
413 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
414 err = asd_write_flash_seg(asd_ha, in asd_store_update_bios()
415 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
418 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
419 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
422 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
423 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
424 &asd_ha->bios_image->data[sizeof(header)], in asd_store_update_bios()
429 release_firmware(asd_ha->bios_image); in asd_store_update_bios()
433 asd_ha->bios_status = err; in asd_store_update_bios()
445 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_update_bios() local
448 if (flash_error_table[i].err_code == asd_ha->bios_status) in asd_show_update_bios()
451 if (asd_ha->bios_status != FLASH_IN_PROGRESS) in asd_show_update_bios()
452 asd_ha->bios_status = FLASH_OK; in asd_show_update_bios()
462 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) in asd_create_dev_attrs() argument
466 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
470 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
474 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
477 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_create_dev_attrs()
484 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
486 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
488 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
492 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) in asd_remove_dev_attrs() argument
494 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_remove_dev_attrs()
495 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_remove_dev_attrs()
496 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_remove_dev_attrs()
497 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_remove_dev_attrs()
505 int (*setup)(struct asd_ha_struct *asd_ha);
519 static int asd_create_ha_caches(struct asd_ha_struct *asd_ha) in asd_create_ha_caches() argument
521 asd_ha->scb_pool = dma_pool_create(ASD_DRIVER_NAME "_scb_pool", in asd_create_ha_caches()
522 &asd_ha->pcidev->dev, in asd_create_ha_caches()
525 if (!asd_ha->scb_pool) { in asd_create_ha_caches()
537 static void asd_free_edbs(struct asd_ha_struct *asd_ha) in asd_free_edbs() argument
539 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_edbs()
543 asd_free_coherent(asd_ha, seq->edb_arr[i]); in asd_free_edbs()
548 static void asd_free_escbs(struct asd_ha_struct *asd_ha) in asd_free_escbs() argument
550 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_escbs()
563 static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) in asd_destroy_ha_caches() argument
567 if (asd_ha->hw_prof.ddb_ext) in asd_destroy_ha_caches()
568 asd_free_coherent(asd_ha, asd_ha->hw_prof.ddb_ext); in asd_destroy_ha_caches()
569 if (asd_ha->hw_prof.scb_ext) in asd_destroy_ha_caches()
570 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext); in asd_destroy_ha_caches()
572 kfree(asd_ha->hw_prof.ddb_bitmap); in asd_destroy_ha_caches()
573 asd_ha->hw_prof.ddb_bitmap = NULL; in asd_destroy_ha_caches()
576 struct asd_phy *phy = &asd_ha->phys[i]; in asd_destroy_ha_caches()
578 asd_free_coherent(asd_ha, phy->id_frm_tok); in asd_destroy_ha_caches()
580 if (asd_ha->seq.escb_arr) in asd_destroy_ha_caches()
581 asd_free_escbs(asd_ha); in asd_destroy_ha_caches()
582 if (asd_ha->seq.edb_arr) in asd_destroy_ha_caches()
583 asd_free_edbs(asd_ha); in asd_destroy_ha_caches()
584 if (asd_ha->hw_prof.ue.area) { in asd_destroy_ha_caches()
585 kfree(asd_ha->hw_prof.ue.area); in asd_destroy_ha_caches()
586 asd_ha->hw_prof.ue.area = NULL; in asd_destroy_ha_caches()
588 if (asd_ha->seq.tc_index_array) { in asd_destroy_ha_caches()
589 kfree(asd_ha->seq.tc_index_array); in asd_destroy_ha_caches()
590 kfree(asd_ha->seq.tc_index_bitmap); in asd_destroy_ha_caches()
591 asd_ha->seq.tc_index_array = NULL; in asd_destroy_ha_caches()
592 asd_ha->seq.tc_index_bitmap = NULL; in asd_destroy_ha_caches()
594 if (asd_ha->seq.actual_dl) { in asd_destroy_ha_caches()
595 asd_free_coherent(asd_ha, asd_ha->seq.actual_dl); in asd_destroy_ha_caches()
596 asd_ha->seq.actual_dl = NULL; in asd_destroy_ha_caches()
597 asd_ha->seq.dl = NULL; in asd_destroy_ha_caches()
599 if (asd_ha->seq.next_scb.vaddr) { in asd_destroy_ha_caches()
600 dma_pool_free(asd_ha->scb_pool, asd_ha->seq.next_scb.vaddr, in asd_destroy_ha_caches()
601 asd_ha->seq.next_scb.dma_handle); in asd_destroy_ha_caches()
602 asd_ha->seq.next_scb.vaddr = NULL; in asd_destroy_ha_caches()
604 dma_pool_destroy(asd_ha->scb_pool); in asd_destroy_ha_caches()
605 asd_ha->scb_pool = NULL; in asd_destroy_ha_caches()
654 static int asd_register_sas_ha(struct asd_ha_struct *asd_ha) in asd_register_sas_ha() argument
668 asd_ha->sas_ha.sas_ha_name = (char *) asd_ha->name; in asd_register_sas_ha()
669 asd_ha->sas_ha.lldd_module = THIS_MODULE; in asd_register_sas_ha()
670 asd_ha->sas_ha.sas_addr = &asd_ha->hw_prof.sas_addr[0]; in asd_register_sas_ha()
673 sas_phys[i] = &asd_ha->phys[i].sas_phy; in asd_register_sas_ha()
674 sas_ports[i] = &asd_ha->ports[i]; in asd_register_sas_ha()
677 asd_ha->sas_ha.sas_phy = sas_phys; in asd_register_sas_ha()
678 asd_ha->sas_ha.sas_port= sas_ports; in asd_register_sas_ha()
679 asd_ha->sas_ha.num_phys= ASD_MAX_PHYS; in asd_register_sas_ha()
681 return sas_register_ha(&asd_ha->sas_ha); in asd_register_sas_ha()
684 static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) in asd_unregister_sas_ha() argument
688 err = sas_unregister_ha(&asd_ha->sas_ha); in asd_unregister_sas_ha()
690 sas_remove_host(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
691 scsi_host_put(asd_ha->sas_ha.core.shost); in asd_unregister_sas_ha()
693 kfree(asd_ha->sas_ha.sas_phy); in asd_unregister_sas_ha()
694 kfree(asd_ha->sas_ha.sas_port); in asd_unregister_sas_ha()
703 struct asd_ha_struct *asd_ha; in asd_pci_probe() local
727 asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); in asd_pci_probe()
728 if (!asd_ha) { in asd_pci_probe()
732 asd_ha->pcidev = dev; in asd_pci_probe()
733 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; in asd_pci_probe()
734 asd_ha->sas_ha.lldd_ha = asd_ha; in asd_pci_probe()
736 asd_ha->bios_status = FLASH_OK; in asd_pci_probe()
737 asd_ha->name = asd_dev->name; in asd_pci_probe()
738 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev)); in asd_pci_probe()
740 SHOST_TO_SAS_HA(shost) = &asd_ha->sas_ha; in asd_pci_probe()
741 asd_ha->sas_ha.core.shost = shost; in asd_pci_probe()
751 err = asd_dev->setup(asd_ha); in asd_pci_probe()
764 pci_set_drvdata(dev, asd_ha); in asd_pci_probe()
766 err = asd_map_ha(asd_ha); in asd_pci_probe()
770 err = asd_create_ha_caches(asd_ha); in asd_pci_probe()
774 err = asd_init_hw(asd_ha); in asd_pci_probe()
780 pci_name(dev), SAS_ADDR(asd_ha->hw_prof.sas_addr), in asd_pci_probe()
781 asd_ha->hw_prof.pcba_sn, asd_ha->hw_prof.max_phys, in asd_pci_probe()
782 asd_ha->hw_prof.num_phys, in asd_pci_probe()
783 asd_ha->hw_prof.flash.present ? "present" : "not present", in asd_pci_probe()
784 asd_ha->hw_prof.bios.present ? "build " : "not present", in asd_pci_probe()
785 asd_ha->hw_prof.bios.bld); in asd_pci_probe()
787 shost->can_queue = asd_ha->seq.can_queue; in asd_pci_probe()
790 pci_enable_msi(asd_ha->pcidev); in asd_pci_probe()
792 err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, in asd_pci_probe()
793 ASD_DRIVER_NAME, asd_ha); in asd_pci_probe()
796 asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); in asd_pci_probe()
799 asd_enable_ints(asd_ha); in asd_pci_probe()
801 err = asd_init_post_escbs(asd_ha); in asd_pci_probe()
804 pci_name(asd_ha->pcidev)); in asd_pci_probe()
809 err = asd_create_dev_attrs(asd_ha); in asd_pci_probe()
813 err = asd_register_sas_ha(asd_ha); in asd_pci_probe()
822 asd_remove_dev_attrs(asd_ha); in asd_pci_probe()
825 asd_disable_ints(asd_ha); in asd_pci_probe()
826 free_irq(dev->irq, asd_ha); in asd_pci_probe()
830 asd_chip_hardrst(asd_ha); in asd_pci_probe()
832 asd_destroy_ha_caches(asd_ha); in asd_pci_probe()
834 asd_unmap_ha(asd_ha); in asd_pci_probe()
838 kfree(asd_ha); in asd_pci_probe()
846 static void asd_free_queues(struct asd_ha_struct *asd_ha) in asd_free_queues() argument
852 spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
853 asd_ha->seq.pending = 0; in asd_free_queues()
854 list_splice_init(&asd_ha->seq.pend_q, &pending); in asd_free_queues()
855 spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
877 static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) in asd_turn_off_leds() argument
879 u8 phy_mask = asd_ha->hw_prof.enabled_phys; in asd_turn_off_leds()
883 asd_turn_led(asd_ha, i, 0); in asd_turn_off_leds()
884 asd_control_led(asd_ha, i, 0); in asd_turn_off_leds()
890 struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); in asd_pci_remove() local
892 if (!asd_ha) in asd_pci_remove()
895 asd_unregister_sas_ha(asd_ha); in asd_pci_remove()
897 asd_disable_ints(asd_ha); in asd_pci_remove()
899 asd_remove_dev_attrs(asd_ha); in asd_pci_remove()
903 free_irq(dev->irq, asd_ha); in asd_pci_remove()
905 pci_disable_msi(asd_ha->pcidev); in asd_pci_remove()
906 asd_turn_off_leds(asd_ha); in asd_pci_remove()
907 asd_chip_hardrst(asd_ha); in asd_pci_remove()
908 asd_free_queues(asd_ha); in asd_pci_remove()
909 asd_destroy_ha_caches(asd_ha); in asd_pci_remove()
910 asd_unmap_ha(asd_ha); in asd_pci_remove()
911 kfree(asd_ha); in asd_pci_remove()
918 struct asd_ha_struct *asd_ha; in asd_scan_start() local
921 asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; in asd_scan_start()
922 err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); in asd_scan_start()