Lines Matching refs:asd_ha

51 static int asd_map_memio(struct asd_ha_struct *asd_ha)  in asd_map_memio()  argument
56 asd_ha->iospace = 0; in asd_map_memio()
58 io_handle = &asd_ha->io_handle[i==0?0:1]; in asd_map_memio()
59 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_memio()
60 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_memio()
61 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_memio()
65 i==0?0:1, pci_name(asd_ha->pcidev)); in asd_map_memio()
68 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_memio()
71 pci_name(asd_ha->pcidev)); in asd_map_memio()
77 pci_name(asd_ha->pcidev)); in asd_map_memio()
85 pci_release_region(asd_ha->pcidev, i); in asd_map_memio()
88 io_handle = &asd_ha->io_handle[0]; in asd_map_memio()
90 pci_release_region(asd_ha->pcidev, 0); in asd_map_memio()
95 static void asd_unmap_memio(struct asd_ha_struct *asd_ha) in asd_unmap_memio() argument
99 io_handle = &asd_ha->io_handle[1]; in asd_unmap_memio()
101 pci_release_region(asd_ha->pcidev, 2); in asd_unmap_memio()
103 io_handle = &asd_ha->io_handle[0]; in asd_unmap_memio()
105 pci_release_region(asd_ha->pcidev, 0); in asd_unmap_memio()
108 static int asd_map_ioport(struct asd_ha_struct *asd_ha) in asd_map_ioport() argument
111 struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; in asd_map_ioport()
113 asd_ha->iospace = 1; in asd_map_ioport()
114 io_handle->start = pci_resource_start(asd_ha->pcidev, i); in asd_map_ioport()
115 io_handle->len = pci_resource_len(asd_ha->pcidev, i); in asd_map_ioport()
116 io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); in asd_map_ioport()
120 pci_name(asd_ha->pcidev)); in asd_map_ioport()
123 err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); in asd_map_ioport()
126 pci_name(asd_ha->pcidev)); in asd_map_ioport()
132 static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) in asd_unmap_ioport() argument
134 pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); in asd_unmap_ioport()
137 static int asd_map_ha(struct asd_ha_struct *asd_ha) in asd_map_ha() argument
142 err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); in asd_map_ha()
145 pci_name(asd_ha->pcidev)); in asd_map_ha()
151 if ((err = asd_map_memio(asd_ha))) in asd_map_ha()
154 if ((err = asd_map_ioport(asd_ha))) in asd_map_ha()
157 pci_name(asd_ha->pcidev)); in asd_map_ha()
160 pci_name(asd_ha->pcidev)); in asd_map_ha()
169 static void asd_unmap_ha(struct asd_ha_struct *asd_ha) in asd_unmap_ha() argument
171 if (asd_ha->iospace) in asd_unmap_ha()
172 asd_unmap_ioport(asd_ha); in asd_unmap_ha()
174 asd_unmap_memio(asd_ha); in asd_unmap_ha()
183 static int asd_common_setup(struct asd_ha_struct *asd_ha) in asd_common_setup() argument
187 asd_ha->revision_id = asd_ha->pcidev->revision; in asd_common_setup()
190 if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { in asd_common_setup()
192 pci_name(asd_ha->pcidev), in asd_common_setup()
193 asd_dev_rev[asd_ha->revision_id], in asd_common_setup()
194 asd_ha->revision_id); in asd_common_setup()
198 asd_ha->hw_prof.max_scbs = 512; in asd_common_setup()
199 asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; in asd_common_setup()
200 asd_ha->hw_prof.num_phys = ASD_MAX_PHYS; in asd_common_setup()
202 asd_ha->hw_prof.enabled_phys = 0xFF; in asd_common_setup()
204 asd_ha->hw_prof.phy_desc[i].max_sas_lrate = in asd_common_setup()
206 asd_ha->hw_prof.phy_desc[i].min_sas_lrate = in asd_common_setup()
208 asd_ha->hw_prof.phy_desc[i].max_sata_lrate = in asd_common_setup()
210 asd_ha->hw_prof.phy_desc[i].min_sata_lrate = in asd_common_setup()
219 static int asd_aic9410_setup(struct asd_ha_struct *asd_ha) in asd_aic9410_setup() argument
221 int err = asd_common_setup(asd_ha); in asd_aic9410_setup()
226 asd_ha->hw_prof.addr_range = 8; in asd_aic9410_setup()
227 asd_ha->hw_prof.port_name_base = 0; in asd_aic9410_setup()
228 asd_ha->hw_prof.dev_name_base = 8; in asd_aic9410_setup()
229 asd_ha->hw_prof.sata_name_base = 16; in asd_aic9410_setup()
234 static int asd_aic9405_setup(struct asd_ha_struct *asd_ha) in asd_aic9405_setup() argument
236 int err = asd_common_setup(asd_ha); in asd_aic9405_setup()
241 asd_ha->hw_prof.addr_range = 4; in asd_aic9405_setup()
242 asd_ha->hw_prof.port_name_base = 0; in asd_aic9405_setup()
243 asd_ha->hw_prof.dev_name_base = 4; in asd_aic9405_setup()
244 asd_ha->hw_prof.sata_name_base = 8; in asd_aic9405_setup()
252 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_rev() local
254 asd_dev_rev[asd_ha->revision_id]); in asd_show_dev_rev()
261 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_bios_build() local
262 return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); in asd_show_dev_bios_build()
269 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_dev_pcba_sn() local
270 return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); in asd_show_dev_pcba_sn()
317 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_store_update_bios() local
351 if (asd_ha->bios_status == FLASH_IN_PROGRESS) { in asd_store_update_bios()
355 err = request_firmware(&asd_ha->bios_image, in asd_store_update_bios()
357 &asd_ha->pcidev->dev); in asd_store_update_bios()
365 hdr_ptr = (struct bios_file_header *)asd_ha->bios_image->data; in asd_store_update_bios()
367 if ((hdr_ptr->contrl_id.vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
368 hdr_ptr->contrl_id.device != asd_ha->pcidev->device) && in asd_store_update_bios()
369 (hdr_ptr->contrl_id.sub_vendor != asd_ha->pcidev->vendor || in asd_store_update_bios()
370 hdr_ptr->contrl_id.sub_device != asd_ha->pcidev->device)) { in asd_store_update_bios()
379 asd_ha->pcidev->vendor, in asd_store_update_bios()
380 asd_ha->pcidev->device); in asd_store_update_bios()
385 if (hdr_ptr->filelen != asd_ha->bios_image->size) { in asd_store_update_bios()
392 csum += asd_ha->bios_image->data[i]; in asd_store_update_bios()
400 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
401 err = asd_write_flash_seg(asd_ha, in asd_store_update_bios()
402 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
405 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
406 &asd_ha->bios_image->data[sizeof(*hdr_ptr)], in asd_store_update_bios()
409 asd_ha->bios_status = FLASH_IN_PROGRESS; in asd_store_update_bios()
410 err = asd_verify_flash_seg(asd_ha, in asd_store_update_bios()
411 &asd_ha->bios_image->data[sizeof(header)], in asd_store_update_bios()
416 release_firmware(asd_ha->bios_image); in asd_store_update_bios()
420 asd_ha->bios_status = err; in asd_store_update_bios()
432 struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); in asd_show_update_bios() local
435 if (flash_error_table[i].err_code == asd_ha->bios_status) in asd_show_update_bios()
438 if (asd_ha->bios_status != FLASH_IN_PROGRESS) in asd_show_update_bios()
439 asd_ha->bios_status = FLASH_OK; in asd_show_update_bios()
449 static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) in asd_create_dev_attrs() argument
453 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
457 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
461 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
464 err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_create_dev_attrs()
471 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_create_dev_attrs()
473 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_create_dev_attrs()
475 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_create_dev_attrs()
479 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) in asd_remove_dev_attrs() argument
481 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_aic_revision); in asd_remove_dev_attrs()
482 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); in asd_remove_dev_attrs()
483 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); in asd_remove_dev_attrs()
484 device_remove_file(&asd_ha->pcidev->dev, &dev_attr_update_bios); in asd_remove_dev_attrs()
492 int (*setup)(struct asd_ha_struct *asd_ha);
506 static int asd_create_ha_caches(struct asd_ha_struct *asd_ha) in asd_create_ha_caches() argument
508 asd_ha->scb_pool = dma_pool_create(ASD_DRIVER_NAME "_scb_pool", in asd_create_ha_caches()
509 &asd_ha->pcidev->dev, in asd_create_ha_caches()
512 if (!asd_ha->scb_pool) { in asd_create_ha_caches()
524 static void asd_free_edbs(struct asd_ha_struct *asd_ha) in asd_free_edbs() argument
526 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_edbs()
530 asd_free_coherent(asd_ha, seq->edb_arr[i]); in asd_free_edbs()
535 static void asd_free_escbs(struct asd_ha_struct *asd_ha) in asd_free_escbs() argument
537 struct asd_seq_data *seq = &asd_ha->seq; in asd_free_escbs()
550 static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) in asd_destroy_ha_caches() argument
554 if (asd_ha->hw_prof.ddb_ext) in asd_destroy_ha_caches()
555 asd_free_coherent(asd_ha, asd_ha->hw_prof.ddb_ext); in asd_destroy_ha_caches()
556 if (asd_ha->hw_prof.scb_ext) in asd_destroy_ha_caches()
557 asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext); in asd_destroy_ha_caches()
559 kfree(asd_ha->hw_prof.ddb_bitmap); in asd_destroy_ha_caches()
560 asd_ha->hw_prof.ddb_bitmap = NULL; in asd_destroy_ha_caches()
563 struct asd_phy *phy = &asd_ha->phys[i]; in asd_destroy_ha_caches()
565 asd_free_coherent(asd_ha, phy->id_frm_tok); in asd_destroy_ha_caches()
567 if (asd_ha->seq.escb_arr) in asd_destroy_ha_caches()
568 asd_free_escbs(asd_ha); in asd_destroy_ha_caches()
569 if (asd_ha->seq.edb_arr) in asd_destroy_ha_caches()
570 asd_free_edbs(asd_ha); in asd_destroy_ha_caches()
571 if (asd_ha->hw_prof.ue.area) { in asd_destroy_ha_caches()
572 kfree(asd_ha->hw_prof.ue.area); in asd_destroy_ha_caches()
573 asd_ha->hw_prof.ue.area = NULL; in asd_destroy_ha_caches()
575 if (asd_ha->seq.tc_index_array) { in asd_destroy_ha_caches()
576 kfree(asd_ha->seq.tc_index_array); in asd_destroy_ha_caches()
577 kfree(asd_ha->seq.tc_index_bitmap); in asd_destroy_ha_caches()
578 asd_ha->seq.tc_index_array = NULL; in asd_destroy_ha_caches()
579 asd_ha->seq.tc_index_bitmap = NULL; in asd_destroy_ha_caches()
581 if (asd_ha->seq.actual_dl) { in asd_destroy_ha_caches()
582 asd_free_coherent(asd_ha, asd_ha->seq.actual_dl); in asd_destroy_ha_caches()
583 asd_ha->seq.actual_dl = NULL; in asd_destroy_ha_caches()
584 asd_ha->seq.dl = NULL; in asd_destroy_ha_caches()
586 if (asd_ha->seq.next_scb.vaddr) { in asd_destroy_ha_caches()
587 dma_pool_free(asd_ha->scb_pool, asd_ha->seq.next_scb.vaddr, in asd_destroy_ha_caches()
588 asd_ha->seq.next_scb.dma_handle); in asd_destroy_ha_caches()
589 asd_ha->seq.next_scb.vaddr = NULL; in asd_destroy_ha_caches()
591 dma_pool_destroy(asd_ha->scb_pool); in asd_destroy_ha_caches()
592 asd_ha->scb_pool = NULL; in asd_destroy_ha_caches()
641 static int asd_register_sas_ha(struct asd_ha_struct *asd_ha) in asd_register_sas_ha() argument
655 asd_ha->sas_ha.sas_ha_name = (char *) asd_ha->name; in asd_register_sas_ha()
656 asd_ha->sas_ha.sas_addr = &asd_ha->hw_prof.sas_addr[0]; in asd_register_sas_ha()
659 sas_phys[i] = &asd_ha->phys[i].sas_phy; in asd_register_sas_ha()
660 sas_ports[i] = &asd_ha->ports[i]; in asd_register_sas_ha()
663 asd_ha->sas_ha.sas_phy = sas_phys; in asd_register_sas_ha()
664 asd_ha->sas_ha.sas_port= sas_ports; in asd_register_sas_ha()
665 asd_ha->sas_ha.num_phys= ASD_MAX_PHYS; in asd_register_sas_ha()
667 return sas_register_ha(&asd_ha->sas_ha); in asd_register_sas_ha()
670 static int asd_unregister_sas_ha(struct asd_ha_struct *asd_ha) in asd_unregister_sas_ha() argument
674 err = sas_unregister_ha(&asd_ha->sas_ha); in asd_unregister_sas_ha()
676 sas_remove_host(asd_ha->sas_ha.shost); in asd_unregister_sas_ha()
677 scsi_host_put(asd_ha->sas_ha.shost); in asd_unregister_sas_ha()
679 kfree(asd_ha->sas_ha.sas_phy); in asd_unregister_sas_ha()
680 kfree(asd_ha->sas_ha.sas_port); in asd_unregister_sas_ha()
689 struct asd_ha_struct *asd_ha; in asd_pci_probe() local
713 asd_ha = kzalloc(sizeof(*asd_ha), GFP_KERNEL); in asd_pci_probe()
714 if (!asd_ha) { in asd_pci_probe()
718 asd_ha->pcidev = dev; in asd_pci_probe()
719 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev; in asd_pci_probe()
720 asd_ha->sas_ha.lldd_ha = asd_ha; in asd_pci_probe()
722 asd_ha->bios_status = FLASH_OK; in asd_pci_probe()
723 asd_ha->name = asd_dev->name; in asd_pci_probe()
724 asd_printk("found %s, device %s\n", asd_ha->name, pci_name(dev)); in asd_pci_probe()
726 SHOST_TO_SAS_HA(shost) = &asd_ha->sas_ha; in asd_pci_probe()
727 asd_ha->sas_ha.shost = shost; in asd_pci_probe()
737 err = asd_dev->setup(asd_ha); in asd_pci_probe()
750 pci_set_drvdata(dev, asd_ha); in asd_pci_probe()
752 err = asd_map_ha(asd_ha); in asd_pci_probe()
756 err = asd_create_ha_caches(asd_ha); in asd_pci_probe()
760 err = asd_init_hw(asd_ha); in asd_pci_probe()
766 pci_name(dev), SAS_ADDR(asd_ha->hw_prof.sas_addr), in asd_pci_probe()
767 asd_ha->hw_prof.pcba_sn, asd_ha->hw_prof.max_phys, in asd_pci_probe()
768 asd_ha->hw_prof.num_phys, in asd_pci_probe()
769 asd_ha->hw_prof.flash.present ? "present" : "not present", in asd_pci_probe()
770 asd_ha->hw_prof.bios.present ? "build " : "not present", in asd_pci_probe()
771 asd_ha->hw_prof.bios.bld); in asd_pci_probe()
773 shost->can_queue = asd_ha->seq.can_queue; in asd_pci_probe()
776 pci_enable_msi(asd_ha->pcidev); in asd_pci_probe()
778 err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, in asd_pci_probe()
779 ASD_DRIVER_NAME, asd_ha); in asd_pci_probe()
782 asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); in asd_pci_probe()
785 asd_enable_ints(asd_ha); in asd_pci_probe()
787 err = asd_init_post_escbs(asd_ha); in asd_pci_probe()
790 pci_name(asd_ha->pcidev)); in asd_pci_probe()
795 err = asd_create_dev_attrs(asd_ha); in asd_pci_probe()
799 err = asd_register_sas_ha(asd_ha); in asd_pci_probe()
808 asd_remove_dev_attrs(asd_ha); in asd_pci_probe()
811 asd_disable_ints(asd_ha); in asd_pci_probe()
812 free_irq(dev->irq, asd_ha); in asd_pci_probe()
816 asd_chip_hardrst(asd_ha); in asd_pci_probe()
818 asd_destroy_ha_caches(asd_ha); in asd_pci_probe()
820 asd_unmap_ha(asd_ha); in asd_pci_probe()
824 kfree(asd_ha); in asd_pci_probe()
832 static void asd_free_queues(struct asd_ha_struct *asd_ha) in asd_free_queues() argument
838 spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
839 asd_ha->seq.pending = 0; in asd_free_queues()
840 list_splice_init(&asd_ha->seq.pend_q, &pending); in asd_free_queues()
841 spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); in asd_free_queues()
863 static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) in asd_turn_off_leds() argument
865 u8 phy_mask = asd_ha->hw_prof.enabled_phys; in asd_turn_off_leds()
869 asd_turn_led(asd_ha, i, 0); in asd_turn_off_leds()
870 asd_control_led(asd_ha, i, 0); in asd_turn_off_leds()
876 struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); in asd_pci_remove() local
878 if (!asd_ha) in asd_pci_remove()
881 asd_unregister_sas_ha(asd_ha); in asd_pci_remove()
883 asd_disable_ints(asd_ha); in asd_pci_remove()
885 asd_remove_dev_attrs(asd_ha); in asd_pci_remove()
889 free_irq(dev->irq, asd_ha); in asd_pci_remove()
891 pci_disable_msi(asd_ha->pcidev); in asd_pci_remove()
892 asd_turn_off_leds(asd_ha); in asd_pci_remove()
893 asd_chip_hardrst(asd_ha); in asd_pci_remove()
894 asd_free_queues(asd_ha); in asd_pci_remove()
895 asd_destroy_ha_caches(asd_ha); in asd_pci_remove()
896 asd_unmap_ha(asd_ha); in asd_pci_remove()
897 kfree(asd_ha); in asd_pci_remove()
904 struct asd_ha_struct *asd_ha; in asd_scan_start() local
907 asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; in asd_scan_start()
908 err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); in asd_scan_start()