Use Cases
1367
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Serial ATA (SATA) Controller
CmdSlotNum->cfis.DW4.DWResv=0x0;
}
char startCmdListProcessing(void) {
// Make sure that a device is present and HBA has established communications.
while ((sataRegs->P0SSTS & AHCI_PxSCTL_PxSSTS_DET) !=0x3);
// Clear P0SERR.DIAG.X (RWC bit field) so that the P0TFD is updated by HBA.
// Make sure it is cleared.
sataRegs->P0SERR |= 0x04000000;
// Make sure the Command List is not Running.
if (sataRegs->P0CMD & AHCI_PxCMD_CR)
return(1);
//
Task file regs and look for Device ready status.
while ((sataRegs->P0TFD & AHCI_PxTFD_STS_BSY_DRQ_ERR) != 0);
// Make sure the the Receive FIS DMA is running.
if ((sataRegs->P0CMD & (AHCI_PxCMD_FRE | AHCI_PxCMD_FRE)) !=
(AHCI_PxCMD_FRE | AHCI_PxCMD_FRE))
return(1);
// Enable the Cmd List DMA Engine.
sataRegs->P0CMD |= AHCI_PxCMD_ST;
// Wait here a bit until the Command List DMA Engine has started to run
while ((sataRegs->P0CMD & AHCI_PxCMD_CR) == 0)
waitForXms(1);
return(0);
}
char submitCmd(Uint8 commandType, Uint8 commandSlot) {
// Make sure both the Command List and Receive FIS DMAs are eanbled and running prior to
//
submiting command
Uint16 I;
if ((sataRegs->P0CMD & (AHCI_PxCMD_FRE | AHCI_PxCMD_FRE | AHCI_PxCMD_CR | AHCI_PxCMD_ST)) !=
(AHCI_PxCMD_FRE | AHCI_PxCMD_FRE | AHCI_PxCMD_CR | AHCI_PxCMD_ST))
return(1);
switch (commandType) {
case NON_QUEUED_CMD:
sataRegs->P0CI |= (0x1 << commandSlot);
break;
case QUEUED_CMD:
sataRegs->P0SACT |= (0x1 << commandSlot);
sataRegs->P0CI |= (0x1 << commandSlot);
break;
default:
break;
}
return(0);
}
void sata_intc_setup(void) {
#if defined(__TMS470__)
dvSetIsr(&sataIsr, CSL_INTC_SATAINT);
// SATA INTC Interrupt Event # 67: See
arm_int_index.h or Freon_ch_14_interrupt_????.pdf
#elif defined(_TMS320C6X)
CSL_IntcParam vectId;
CSL_Status intStat;