Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/smartpqi/smartpqi_sis.c
/*- | /*- | ||||
* Copyright (c) 2018 Microsemi Corporation. | * Copyright (c) 2016-2019 Microsemi Corporation. | ||||
* Copyright (c) 2020 Microchip Technology Inc. and it's subsidiaries. | |||||
* | |||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
Context not available. | |||||
DBG_FUNC("IN\n"); | DBG_FUNC("IN\n"); | ||||
db_reg = PCI_MEM_GET32(softs, &softs->ioa_reg->host_to_ioa_db, | db_reg = PCI_MEM_GET32(softs, &softs->ioa_reg->host_to_ioa_db, | ||||
LEGACY_SIS_IDBR); | LEGACY_SIS_IDBR); | ||||
db_reg |= SIS_ENABLE_INTX; | db_reg |= SIS_ENABLE_INTX; | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | ||||
LEGACY_SIS_IDBR, db_reg); | LEGACY_SIS_IDBR, db_reg); | ||||
if (pqisrc_sis_wait_for_db_bit_to_clear(softs,SIS_ENABLE_INTX) | if (pqisrc_sis_wait_for_db_bit_to_clear(softs,SIS_ENABLE_INTX) | ||||
!= PQI_STATUS_SUCCESS) { | != PQI_STATUS_SUCCESS) { | ||||
DBG_ERR("Failed to wait for enable intx db bit to clear\n"); | DBG_ERR("Failed to wait for enable intx db bit to clear\n"); | ||||
} | } | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
Context not available. | |||||
void sis_disable_interrupt(pqisrc_softstate_t *softs) | void sis_disable_interrupt(pqisrc_softstate_t *softs) | ||||
{ | { | ||||
DBG_FUNC("IN"); | DBG_FUNC("IN"); | ||||
switch(softs->intr_type) { | switch(softs->intr_type) { | ||||
case INTR_TYPE_FIXED: | case INTR_TYPE_FIXED: | ||||
pqisrc_configure_legacy_intx(softs,false); | pqisrc_configure_legacy_intx(softs,false); | ||||
Context not available. | |||||
break; | break; | ||||
case INTR_TYPE_MSI: | case INTR_TYPE_MSI: | ||||
case INTR_TYPE_MSIX: | case INTR_TYPE_MSIX: | ||||
sis_disable_msix(softs); | sis_disable_msix(softs); | ||||
break; | break; | ||||
default: | default: | ||||
DBG_ERR("Inerrupt mode none!\n"); | DBG_ERR("Inerrupt mode none!\n"); | ||||
break; | break; | ||||
} | } | ||||
DBG_FUNC("OUT"); | DBG_FUNC("OUT"); | ||||
} | } | ||||
/* Trigger a NMI as part of taking controller offline procedure */ | /* Trigger a NMI as part of taking controller offline procedure */ | ||||
void pqisrc_trigger_nmi_sis(pqisrc_softstate_t *softs) | void pqisrc_trigger_nmi_sis(pqisrc_softstate_t *softs) | ||||
{ | { | ||||
DBG_FUNC("IN\n"); | DBG_FUNC("IN\n"); | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | ||||
LEGACY_SIS_IDBR, LE_32(TRIGGER_NMI_SIS)); | LEGACY_SIS_IDBR, LE_32(TRIGGER_NMI_SIS)); | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
} | } | ||||
Context not available. | |||||
DBG_FUNC("IN\n"); | DBG_FUNC("IN\n"); | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | ||||
LEGACY_SIS_IDBR, LE_32(REENABLE_SIS)); | LEGACY_SIS_IDBR, LE_32(REENABLE_SIS)); | ||||
COND_WAIT(((PCI_MEM_GET32(softs, &softs->ioa_reg->ioa_to_host_db, LEGACY_SIS_ODBR_R) & | COND_WAIT(((PCI_MEM_GET32(softs, &softs->ioa_reg->ioa_to_host_db, LEGACY_SIS_ODBR_R) & | ||||
Context not available. | |||||
DBG_WARN(" [ %s ] failed to re enable sis\n",__func__); | DBG_WARN(" [ %s ] failed to re enable sis\n",__func__); | ||||
ret = PQI_STATUS_TIMEOUT; | ret = PQI_STATUS_TIMEOUT; | ||||
} | } | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
return ret; | return ret; | ||||
} | } | ||||
Context not available. | |||||
/* Copy Command to mailbox */ | /* Copy Command to mailbox */ | ||||
for (i = 0; i < 6; i++) | for (i = 0; i < 6; i++) | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->mb[i], | PCI_MEM_PUT32(softs, &softs->ioa_reg->mb[i], | ||||
LEGACY_SIS_SRCV_MAILBOX+i*4, LE_32(mb[i])); | LEGACY_SIS_SRCV_MAILBOX+i*4, LE_32(mb[i])); | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->ioa_to_host_db_clr, | /* TODO : Switch to INTX Mode ?*/ | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->ioa_to_host_db_clr, | |||||
LEGACY_SIS_ODBR_R, LE_32(0x1000)); | LEGACY_SIS_ODBR_R, LE_32(0x1000)); | ||||
/* Submit the command */ | /* Submit the command */ | ||||
PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | PCI_MEM_PUT32(softs, &softs->ioa_reg->host_to_ioa_db, | ||||
LEGACY_SIS_IDBR, LE_32(SIS_CMD_SUBMIT)); | LEGACY_SIS_IDBR, LE_32(SIS_CMD_SUBMIT)); | ||||
#ifdef SIS_POLL_WAIT | #ifdef SIS_POLL_WAIT | ||||
Context not available. | |||||
softs->pqi_cap.conf_tab_off = mb[4]; | softs->pqi_cap.conf_tab_off = mb[4]; | ||||
softs->pqi_cap.conf_tab_sz = mb[5]; | softs->pqi_cap.conf_tab_sz = mb[5]; | ||||
os_update_dma_attributes(softs); | |||||
DBG_INIT("max_sg_elem = %x\n", | DBG_INIT("max_sg_elem = %x\n", | ||||
softs->pqi_cap.max_sg_elem); | softs->pqi_cap.max_sg_elem); | ||||
DBG_INIT("max_transfer_size = %x\n", | DBG_INIT("max_transfer_size = %x\n", | ||||
Context not available. | |||||
goto err_out; | goto err_out; | ||||
} | } | ||||
/* We need to allocate DMA memory here , | |||||
* Do any os specific DMA setup. | |||||
*/ | |||||
ret = os_dma_setup(softs); | |||||
if (ret) { | |||||
DBG_ERR("Failed to Setup DMA\n"); | |||||
goto err_out; | |||||
} | |||||
/* Init struct base addr */ | /* Init struct base addr */ | ||||
ret = pqisrc_init_struct_base(softs); | ret = pqisrc_init_struct_base(softs); | ||||
if (ret) { | if (ret) { | ||||
DBG_ERR("Failed to set init struct base addr\n"); | DBG_ERR("Failed to set init struct base addr\n"); | ||||
goto err_out; | goto err_dma; | ||||
} | } | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
return ret; | return ret; | ||||
err_dma: | |||||
os_dma_destroy(softs); | |||||
err_out: | err_out: | ||||
DBG_FUNC("OUT failed\n"); | DBG_FUNC("OUT failed\n"); | ||||
return ret; | return ret; | ||||
Context not available. | |||||
DBG_FUNC("IN\n"); | DBG_FUNC("IN\n"); | ||||
os_dma_mem_free(softs, &softs->err_buf_dma_mem); | os_dma_mem_free(softs, &softs->err_buf_dma_mem); | ||||
os_dma_destroy(softs); | |||||
os_resource_free(softs); | os_resource_free(softs); | ||||
pqi_reset(softs); | pqi_reset(softs); | ||||
DBG_FUNC("OUT\n"); | DBG_FUNC("OUT\n"); | ||||
} | } | ||||
Context not available. |