lib/sw_apps/zynqmp_pmufw/src/pm_system.c
s32 PmSystemResumePowerOffSuspend(void)
{
	s32 status;
	u32 i;
	PmRequirement* req;

	/* Wait for FSBL to start and get boot type */
	do {
		i = XPfw_Read32(PMU_GLOBAL_GLOBAL_GEN_STORAGE2);
	} while (0U == i);

	/* Clear Gen Storage register so it can be used later in system */
	XPfw_Write32(PMU_GLOBAL_GLOBAL_GEN_STORAGE2, 0U);

	/* DDR context restore */
	status = PmHookRestoreDdrContext();
	if (status != XST_SUCCESS) {
		goto done;
	}

	/* Resume DDR operation */
	status = PmDdrPowerOffSuspendResume();
	if (status != XST_SUCCESS) {
		goto done;
	}

	/* System context restore */
	PmSystemRestoreContext();

	pmSystem.suspendType = PM_SUSPEND_TYPE_REGULAR;

	/* Update state of slave nodes */
	for (i = 0U; i < pmNodeClassSlave_g.bucketSize; i++) {
		PmSlave* slave = pmNodeClassSlave_g.bucket[i]->derived;
		slave->node.currState = slave->slvFsm->statesCnt - 1U;
		status = PmUpdateSlave(slave);
		if (status != XST_SUCCESS) {
			goto done;
		}
	}

	/* Update state of proc nodes */
	for (i = 0U; i < pmNodeClassProc_g.bucketSize; i++) {
		PmProc* proc = pmNodeClassProc_g.bucket[i]->derived;
		status = PmProcSleep(proc);
		if (status != XST_SUCCESS) {
			goto done;
		}
	}

	/* Update state of power nodes */
	for (i = 0U; i < pmNodeClassPower_g.bucketSize; i++) {
		PmPower* power = pmNodeClassPower_g.bucket[i]->derived;
		power->node.currState = PM_PWR_STATE_ON;
		if (power->useCount == 0U) {
			status = PmPowerDown(power);
			if (status != XST_SUCCESS) {
				goto done;
			}
		}
	}

	/* Wake masters that have external node as wake source */
	status = PmExternWakeMasters();
	if (status != XST_SUCCESS) {
		goto done;
	}

	/* Set default value for system requirements */
	for (i = 0U; i < ARRAY_SIZE(pmSystemReqs); i++) {
		u32 caps = pmSystemReqs[i].caps;
		req = PmRequirementGetNoMaster(pmSystemReqs[i].slave);
		if (NULL != req) {
			if (req->currReq != caps) {
				status = PmRequirementUpdate(req, caps);
				if (XST_SUCCESS != status) {
					goto done;
				}
			}
		} else {
			status = XST_FAILURE;
			goto done;
		}
	}

	/* Release DDR context saving slave capabilities */
	status = PmSystemPosFinalizeDdrCaps();

done:
	return status;
}
/**
 * PmSystemResumePowerOffSuspend() - Resume from Power Off Suspend state
 *
 * @return	XST_SUCCESS if system is resumed properly, error code otherwise
 */
Resume from Power Off Suspend state
@return      XST_SUCCESS if system is resumed properly, error code otherwise
Resume from Power Off Suspend state @return XST_SUCCESS if system is resumed properly error code otherwise
s32 PmSystemResumePowerOffSuspend(void)
{
	s32 status;
	u32 i;
	PmRequirement* req;
	do {
		i = XPfw_Read32(PMU_GLOBAL_GLOBAL_GEN_STORAGE2);
	} while (0U == i);
	XPfw_Write32(PMU_GLOBAL_GLOBAL_GEN_STORAGE2, 0U);
	status = PmHookRestoreDdrContext();
	if (status != XST_SUCCESS) {
		goto done;
	}
	status = PmDdrPowerOffSuspendResume();
	if (status != XST_SUCCESS) {
		goto done;
	}
	PmSystemRestoreContext();
	pmSystem.suspendType = PM_SUSPEND_TYPE_REGULAR;
	for (i = 0U; i < pmNodeClassSlave_g.bucketSize; i++) {
		PmSlave* slave = pmNodeClassSlave_g.bucket[i]->derived;
		slave->node.currState = slave->slvFsm->statesCnt - 1U;
		status = PmUpdateSlave(slave);
		if (status != XST_SUCCESS) {
			goto done;
		}
	}
	for (i = 0U; i < pmNodeClassProc_g.bucketSize; i++) {
		PmProc* proc = pmNodeClassProc_g.bucket[i]->derived;
		status = PmProcSleep(proc);
		if (status != XST_SUCCESS) {
			goto done;
		}
	}
	for (i = 0U; i < pmNodeClassPower_g.bucketSize; i++) {
		PmPower* power = pmNodeClassPower_g.bucket[i]->derived;
		power->node.currState = PM_PWR_STATE_ON;
		if (power->useCount == 0U) {
			status = PmPowerDown(power);
			if (status != XST_SUCCESS) {
				goto done;
			}
		}
	}
	status = PmExternWakeMasters();
	if (status != XST_SUCCESS) {
		goto done;
	}
	for (i = 0U; i < ARRAY_SIZE(pmSystemReqs); i++) {
		u32 caps = pmSystemReqs[i].caps;
		req = PmRequirementGetNoMaster(pmSystemReqs[i].slave);
		if (NULL != req) {
			if (req->currReq != caps) {
				status = PmRequirementUpdate(req, caps);
				if (XST_SUCCESS != status) {
					goto done;
				}
			}
		} else {
			status = XST_FAILURE;
			goto done;
		}
	}
	status = PmSystemPosFinalizeDdrCaps();
done:
	return status;
}
s32 PmSystemResumePowerOffSuspend ( void ) { s32 status ; u32 i ; PmRequirement * req ; do { i = XPfw_Read32 ( PMU_GLOBAL_GLOBAL_GEN_STORAGE2 ) ; } while ( 0U == i ) ; XPfw_Write32 ( PMU_GLOBAL_GLOBAL_GEN_STORAGE2 , 0U ) ; status = PmHookRestoreDdrContext ( ) ; if ( status != XST_SUCCESS ) { goto done ; } status = PmDdrPowerOffSuspendResume ( ) ; if ( status != XST_SUCCESS ) { goto done ; } PmSystemRestoreContext ( ) ; pmSystem . suspendType = PM_SUSPEND_TYPE_REGULAR ; for ( i = 0U ; i < pmNodeClassSlave_g . bucketSize ; i ++ ) { PmSlave * slave = pmNodeClassSlave_g . bucket [ i ] -> derived ; slave -> node . currState = slave -> slvFsm -> statesCnt - 1U ; status = PmUpdateSlave ( slave ) ; if ( status != XST_SUCCESS ) { goto done ; } } for ( i = 0U ; i < pmNodeClassProc_g . bucketSize ; i ++ ) { PmProc * proc = pmNodeClassProc_g . bucket [ i ] -> derived ; status = PmProcSleep ( proc ) ; if ( status != XST_SUCCESS ) { goto done ; } } for ( i = 0U ; i < pmNodeClassPower_g . bucketSize ; i ++ ) { PmPower * power = pmNodeClassPower_g . bucket [ i ] -> derived ; power -> node . currState = PM_PWR_STATE_ON ; if ( power -> useCount == 0U ) { status = PmPowerDown ( power ) ; if ( status != XST_SUCCESS ) { goto done ; } } } status = PmExternWakeMasters ( ) ; if ( status != XST_SUCCESS ) { goto done ; } for ( i = 0U ; i < ARRAY_SIZE ( pmSystemReqs ) ; i ++ ) { u32 caps = pmSystemReqs [ i ] . caps ; req = PmRequirementGetNoMaster ( pmSystemReqs [ i ] . slave ) ; if ( NULL != req ) { if ( req -> currReq != caps ) { status = PmRequirementUpdate ( req , caps ) ; if ( XST_SUCCESS != status ) { goto done ; } } } else { status = XST_FAILURE ; goto done ; } } status = PmSystemPosFinalizeDdrCaps ( ) ; done : return status ; }
PmSystemResumePowerOffSuspend() - Resume from Power Off Suspend state
 @return      XST_SUCCESS if system is resumed properly, error code otherwise
PmSystemResumePowerOffSuspend () - Resume from Power Off Suspend state @return XST_SUCCESS if system is resumed properly error code otherwise
/* Wait for FSBL to start and get boot type */ /* Clear Gen Storage register so it can be used later in system */ /* DDR context restore */ /* Resume DDR operation */ /* System context restore */ /* Update state of slave nodes */ /* Update state of proc nodes */ /* Update state of power nodes */ /* Wake masters that have external node as wake source */ /* Set default value for system requirements */ /* Release DDR context saving slave capabilities */