lib/sw_apps/zynqmp_pmufw/src/pm_proc.c
s32 PmProcFsm(PmProc* const proc, const PmProcEvent event)
{
	s32 status = XST_PM_INTERNAL;
	PmStateId currState = proc->node.currState;

	switch (event) {
	case PM_PROC_EVENT_SELF_SUSPEND:
		if (PM_PROC_STATE_ACTIVE == currState) {
			status = PmProcTrActiveToSuspend(proc);
		}
		break;
	case PM_PROC_EVENT_FORCE_PWRDN:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			DISABLE_WFI(proc->mask);
		}
		status = PmProcTrToForcedOff(proc);

		/* Reset latency requirement */
		proc->latencyReq = MAX_LATENCY;
		break;
	case PM_PROC_EVENT_ABORT_SUSPEND:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			status = PmProcTrSuspendToActive(proc);
		} else {
			status = XST_SUCCESS;
		}
		if (true == PmIsRequestedToSuspend(proc->master)) {
			status = PmMasterSuspendAck(proc->master,
						    XST_PM_ABORT_SUSPEND);
		}

		/* Reset latency requirement */
		proc->latencyReq = MAX_LATENCY;
		break;
	case PM_PROC_EVENT_SLEEP:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			status = PmProcTrSuspendToSleep(proc);
		}
		break;
	case PM_PROC_EVENT_WAKE:
		if (PM_PROC_STATE_SLEEP == currState) {
			status = PmProcTrSleepToActive(proc);
		} else if (PM_PROC_STATE_FORCEDOFF == currState) {
			status = PmProcTrForcePwrdnToActive(proc);
		} else if (PM_PROC_STATE_ACTIVE == currState) {
			status = XST_SUCCESS;
		} else if (PM_PROC_STATE_SUSPENDING == currState) {
			status = XST_PM_CONFLICT;
		} else {
			/* For MISRA compliance */
		}

		/* Reset latency requirement */
		proc->latencyReq = MAX_LATENCY;
		break;
	default:
		PmErr("Unknown event %d\r\n", event);
		break;
	}
	if (status == XST_PM_INTERNAL) {
		PmErr("state #%d event #%d\r\n", currState, event);
	}

	return status;
}
/**
 * PmProcFsm() - Implements finite state machine (FSM) for a processor
 * @proc    Pointer to the processor the event is for
 * @event   Processor-specific event to act upon
 *
 * @return  Status of the processor state change operation
 *
 * @note    This FSM coordinates the state transitions for an individual
 *          processor.
 */
Implements finite state machine (FSM) for a processor
@proc    Pointer to the processor the event is for
@event   Processor-specific event to act upon

@return  Status of the processor state change operation

@note    This FSM coordinates the state transitions for an individual
processor.
Implements finite state machine ( FSM ) for a processor @proc Pointer to the processor the event is for @event Processor - specific event to act upon @return Status of the processor state change operation @note This FSM coordinates the state transitions for an individual processor .
s32 PmProcFsm(PmProc* const proc, const PmProcEvent event)
{
	s32 status = XST_PM_INTERNAL;
	PmStateId currState = proc->node.currState;
	switch (event) {
	case PM_PROC_EVENT_SELF_SUSPEND:
		if (PM_PROC_STATE_ACTIVE == currState) {
			status = PmProcTrActiveToSuspend(proc);
		}
		break;
	case PM_PROC_EVENT_FORCE_PWRDN:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			DISABLE_WFI(proc->mask);
		}
		status = PmProcTrToForcedOff(proc);
		proc->latencyReq = MAX_LATENCY;
		break;
	case PM_PROC_EVENT_ABORT_SUSPEND:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			status = PmProcTrSuspendToActive(proc);
		} else {
			status = XST_SUCCESS;
		}
		if (true == PmIsRequestedToSuspend(proc->master)) {
			status = PmMasterSuspendAck(proc->master,
						    XST_PM_ABORT_SUSPEND);
		}
		proc->latencyReq = MAX_LATENCY;
		break;
	case PM_PROC_EVENT_SLEEP:
		if (PM_PROC_STATE_SUSPENDING == currState) {
			status = PmProcTrSuspendToSleep(proc);
		}
		break;
	case PM_PROC_EVENT_WAKE:
		if (PM_PROC_STATE_SLEEP == currState) {
			status = PmProcTrSleepToActive(proc);
		} else if (PM_PROC_STATE_FORCEDOFF == currState) {
			status = PmProcTrForcePwrdnToActive(proc);
		} else if (PM_PROC_STATE_ACTIVE == currState) {
			status = XST_SUCCESS;
		} else if (PM_PROC_STATE_SUSPENDING == currState) {
			status = XST_PM_CONFLICT;
		} else {
		}
		proc->latencyReq = MAX_LATENCY;
		break;
	default:
		PmErr("Unknown event %d\r\n", event);
		break;
	}
	if (status == XST_PM_INTERNAL) {
		PmErr("state #%d event #%d\r\n", currState, event);
	}
	return status;
}
s32 PmProcFsm ( PmProc * const proc , const PmProcEvent event ) { s32 status = XST_PM_INTERNAL ; PmStateId currState = proc -> node . currState ; switch ( event ) { case PM_PROC_EVENT_SELF_SUSPEND : if ( PM_PROC_STATE_ACTIVE == currState ) { status = PmProcTrActiveToSuspend ( proc ) ; } break ; case PM_PROC_EVENT_FORCE_PWRDN : if ( PM_PROC_STATE_SUSPENDING == currState ) { DISABLE_WFI ( proc -> mask ) ; } status = PmProcTrToForcedOff ( proc ) ; proc -> latencyReq = MAX_LATENCY ; break ; case PM_PROC_EVENT_ABORT_SUSPEND : if ( PM_PROC_STATE_SUSPENDING == currState ) { status = PmProcTrSuspendToActive ( proc ) ; } else { status = XST_SUCCESS ; } if ( true == PmIsRequestedToSuspend ( proc -> master ) ) { status = PmMasterSuspendAck ( proc -> master , XST_PM_ABORT_SUSPEND ) ; } proc -> latencyReq = MAX_LATENCY ; break ; case PM_PROC_EVENT_SLEEP : if ( PM_PROC_STATE_SUSPENDING == currState ) { status = PmProcTrSuspendToSleep ( proc ) ; } break ; case PM_PROC_EVENT_WAKE : if ( PM_PROC_STATE_SLEEP == currState ) { status = PmProcTrSleepToActive ( proc ) ; } else if ( PM_PROC_STATE_FORCEDOFF == currState ) { status = PmProcTrForcePwrdnToActive ( proc ) ; } else if ( PM_PROC_STATE_ACTIVE == currState ) { status = XST_SUCCESS ; } else if ( PM_PROC_STATE_SUSPENDING == currState ) { status = XST_PM_CONFLICT ; } else { } proc -> latencyReq = MAX_LATENCY ; break ; default : PmErr ( " \r \n " , event ) ; break ; } if ( status == XST_PM_INTERNAL ) { PmErr ( " \r \n " , currState , event ) ; } return status ; }
PmProcFsm() - Implements finite state machine (FSM) for a processor
 @proc    Pointer to the processor the event is for
 @event   Processor-specific event to act upon
PmProcFsm () - Implements finite state machine ( FSM ) for a processor @proc Pointer to the processor the event is for @event Processor - specific event to act upon
/* Reset latency requirement */ /* Reset latency requirement */ /* For MISRA compliance */ /* Reset latency requirement */