lib/sw_apps/zynqmp_pmufw/src/idle_hooks.c
void NodeSataIdle(u32 BaseAddress)
{
	u32 regVal, timeOut = MAX_TIMEOUT;

	/* Disable Interrupt */
	regVal = Xil_In32(BaseAddress + SATA_HOST_CTL);
	regVal &= ~SATA_HOST_IRQ_EN;
	Xil_Out32(BaseAddress + SATA_HOST_CTL, regVal);

	/* Stop HBA engine for PORT0 and PORT1 */
	regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
			  SATA_AHCI_PORT_PXCMD);
	regVal &= ~SATA_AHCI_PORT_PXCMD_ST;
	Xil_Out32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
		  SATA_AHCI_PORT_PXCMD, regVal);

	regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
			  SATA_AHCI_PORT_PXCMD);
	regVal &= ~SATA_AHCI_PORT_PXCMD_ST;
	Xil_Out32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
		  SATA_AHCI_PORT_PXCMD, regVal);

	/* Wait for command list DMA engine to stop running */

	do {
		regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
				  SATA_AHCI_PORT_PXCMD);
	} while ((regVal & SATA_AHCI_PORT_PXCMD_CR) && --timeOut);

	if (!timeOut) {
		PmWarn("Command list DMA engine not stopped for PORT0\r\n");
	}

	timeOut = MAX_TIMEOUT;

	do {
		regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
				  SATA_AHCI_PORT_PXCMD);
	} while ((regVal & SATA_AHCI_PORT_PXCMD_CR) && --timeOut);

	if (!timeOut) {
		PmWarn("Command list DMA engine not stopped for PORT1\r\n");
	}

	/* Disable AHCI */
	regVal = Xil_In32(BaseAddress + SATA_HOST_CTL);
	regVal &= ~SATA_HOST_AHCI_EN;
	Xil_Out32(BaseAddress + SATA_HOST_CTL, regVal);
	Xil_In32(BaseAddress + SATA_HOST_CTL); /* flush */
}
/**
 * NodeSataIdle() - Custom code to idle the SATA
 *
 * @BaseAddress: SATA base address
 */
Custom code to idle the SATA
@BaseAddress: SATA base address
Custom code to idle the SATA @BaseAddress : SATA base address
void NodeSataIdle(u32 BaseAddress)
{
	u32 regVal, timeOut = MAX_TIMEOUT;
	regVal = Xil_In32(BaseAddress + SATA_HOST_CTL);
	regVal &= ~SATA_HOST_IRQ_EN;
	Xil_Out32(BaseAddress + SATA_HOST_CTL, regVal);
	regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
			  SATA_AHCI_PORT_PXCMD);
	regVal &= ~SATA_AHCI_PORT_PXCMD_ST;
	Xil_Out32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
		  SATA_AHCI_PORT_PXCMD, regVal);
	regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
			  SATA_AHCI_PORT_PXCMD);
	regVal &= ~SATA_AHCI_PORT_PXCMD_ST;
	Xil_Out32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
		  SATA_AHCI_PORT_PXCMD, regVal);
	do {
		regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET +
				  SATA_AHCI_PORT_PXCMD);
	} while ((regVal & SATA_AHCI_PORT_PXCMD_CR) && --timeOut);
	if (!timeOut) {
		PmWarn("Command list DMA engine not stopped for PORT0\r\n");
	}
	timeOut = MAX_TIMEOUT;
	do {
		regVal = Xil_In32(BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET +
				  SATA_AHCI_PORT_PXCMD);
	} while ((regVal & SATA_AHCI_PORT_PXCMD_CR) && --timeOut);
	if (!timeOut) {
		PmWarn("Command list DMA engine not stopped for PORT1\r\n");
	}
	regVal = Xil_In32(BaseAddress + SATA_HOST_CTL);
	regVal &= ~SATA_HOST_AHCI_EN;
	Xil_Out32(BaseAddress + SATA_HOST_CTL, regVal);
	Xil_In32(BaseAddress + SATA_HOST_CTL); 
}
void NodeSataIdle ( u32 BaseAddress ) { u32 regVal , timeOut = MAX_TIMEOUT ; regVal = Xil_In32 ( BaseAddress + SATA_HOST_CTL ) ; regVal &= ~ SATA_HOST_IRQ_EN ; Xil_Out32 ( BaseAddress + SATA_HOST_CTL , regVal ) ; regVal = Xil_In32 ( BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD ) ; regVal &= ~ SATA_AHCI_PORT_PXCMD_ST ; Xil_Out32 ( BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD , regVal ) ; regVal = Xil_In32 ( BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD ) ; regVal &= ~ SATA_AHCI_PORT_PXCMD_ST ; Xil_Out32 ( BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD , regVal ) ; do { regVal = Xil_In32 ( BaseAddress + SATA_AHCI_PORT0_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD ) ; } while ( ( regVal & SATA_AHCI_PORT_PXCMD_CR ) && -- timeOut ) ; if ( ! timeOut ) { PmWarn ( " \r \n " ) ; } timeOut = MAX_TIMEOUT ; do { regVal = Xil_In32 ( BaseAddress + SATA_AHCI_PORT1_CTRL_OFFSET + SATA_AHCI_PORT_PXCMD ) ; } while ( ( regVal & SATA_AHCI_PORT_PXCMD_CR ) && -- timeOut ) ; if ( ! timeOut ) { PmWarn ( " \r \n " ) ; } regVal = Xil_In32 ( BaseAddress + SATA_HOST_CTL ) ; regVal &= ~ SATA_HOST_AHCI_EN ; Xil_Out32 ( BaseAddress + SATA_HOST_CTL , regVal ) ; Xil_In32 ( BaseAddress + SATA_HOST_CTL ) ; }
NodeSataIdle() - Custom code to idle the SATA
 @BaseAddress: SATA base address
NodeSataIdle () - Custom code to idle the SATA @BaseAddress : SATA base address
/* Disable Interrupt */ /* Stop HBA engine for PORT0 and PORT1 */ /* Wait for command list DMA engine to stop running */ /* Disable AHCI */ /* flush */