xilpm: Clean up

Fix some white space and comment issues.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
This commit is contained in:
Soren Brinkmann 2015-04-12 20:24:23 -07:00 committed by Nava kishore Manne
parent 4350a1fa00
commit bb2e0bdb77
11 changed files with 73 additions and 78 deletions

View file

@ -30,10 +30,10 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* Generic functions for gic initialization and interrupt enabling
*********************************************************************/
*/
#include "gic_setup.h"
@ -49,14 +49,14 @@ XScuGic GicInst;
int32_t GicSetupHandler(uint32_t IntId, void *PeriphInstPtr, Xil_ExceptionHandler Handler)
{
int32_t status;
/*
* Connect a device driver Handler that will be called when an
* interrupt for the device occurs, the device driver Handler
* performs the specific interrupt processing for the device
*/
status = XScuGic_Connect(&GicInst, IntId,
Handler,
PeriphInstPtr);
status = XScuGic_Connect(&GicInst, IntId, Handler, PeriphInstPtr);
return status;
}
/**
@ -72,12 +72,11 @@ void GicEnableInterrupt(uint32_t IntId)
*
* @return Status of operation success (XST_* from xstatus.h)
*/
int32_t GicInit()
int32_t GicInit(void)
{
int32_t Status;
XScuGic_Config *GicCfgPtr;
/* Initialize the interrupt controller driver */
GicCfgPtr = XScuGic_LookupConfig(INTC_DEVICE_ID);
XScuGic_Config *GicCfgPtr = XScuGic_LookupConfig(INTC_DEVICE_ID);
if (NULL == GicCfgPtr)
return XST_FAILURE;
@ -85,7 +84,7 @@ int32_t GicInit()
if (XST_SUCCESS != Status)
return Status;
/*
/*
* Connect the interrupt controller interrupt Handler to the
* hardware interrupt handling logic in the processor.
*/

View file

@ -30,11 +30,11 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* Timer peripheral driver. Code is mostly reused from
* hello_ttc0_interrupt application.
*********************************************************************/
*/
#include <xil_exception.h>
#include <xil_printf.h>
@ -54,6 +54,7 @@ static XTtcPs timer0_inst;
static void TickHandler(XTtcPs *timer_inst)
{
uint32_t int_status = XTtcPs_GetInterruptStatus(timer_inst);
int_status &= XTtcPs_ReadReg(timer_inst->Config.BaseAddress, XTTCPS_IER_OFFSET);
XTtcPs_ClearInterruptStatus(timer_inst, int_status);
TickCount++;
@ -85,24 +86,24 @@ static void TimerSetIntervalMode(XTtcPs *TimerInstPtr, uint32_t PeriodInSec)
int32_t TimerInit(uint32_t PeriodInSec)
{
int32_t status;
XTtcPs_Config *timer_config;
/* Look up the configuration based on the device identifier */
timer_config = XTtcPs_LookupConfig(TTC0_0_DEVICE_ID);
XTtcPs_Config *timer_config = XTtcPs_LookupConfig(TTC0_0_DEVICE_ID);
if (NULL == timer_config) {
return XST_FAILURE;
}
/* Initialize the device */
status = XTtcPs_CfgInitialize(&timer0_inst, timer_config, timer_config->BaseAddress);
if (XST_SUCCESS != status) {
return status;
}
/* Setup interrupts */
status = GicSetupInterruptSystem(TTC_INT_ID0,
&timer0_inst, (Xil_ExceptionHandler) TickHandler);
if (XST_SUCCESS == status) {
TimerSetIntervalMode(&timer0_inst, PeriodInSec);
XTtcPs_Start(&timer0_inst);
}
return status;
}
@ -115,6 +116,7 @@ int32_t TimerInit(uint32_t PeriodInSec)
int32_t TimerConfigure(uint32_t Period)
{
int32_t ret_status = TimerInit(Period);
switch (ret_status) {
case XST_SUCCESS:
pm_dbg("OK, configured timer\n");
@ -129,5 +131,6 @@ int32_t TimerConfigure(uint32_t Period)
pm_dbg("??? unhandled status %d\n", ret_status);
break;
}
return ret_status;
}

View file

@ -30,8 +30,7 @@
*
******************************************************************************/
/*********************************************************************
/*
*
* CONTENT
* Assumptions: only PROCESSOR core is executing this code,
@ -50,7 +49,7 @@
* level (CPSR) and handle timer interrupt that caused wake-up.
* 5) PROCESSOR waits for few more timer interrupts and repeats the suspend
* procedure.
*********************************************************************/
*/
#include <xil_exception.h>
#include <xil_printf.h>
@ -85,12 +84,15 @@ static void SaveContext(void)
{
uint8_t *MemPtr;
uint8_t *ContextMemPtr = (uint8_t *)CONTEXT_MEM_BASE;
for (MemPtr = &__data_start; MemPtr < &__data_end; MemPtr++, ContextMemPtr++) {
*ContextMemPtr = *MemPtr;
}
for (MemPtr = &__bss_start__; MemPtr < &__bss_end__; MemPtr++, ContextMemPtr++) {
*ContextMemPtr = *MemPtr;
}
pm_dbg("Saved context (tick_count = %d)\n", TickCount);
}
@ -101,12 +103,15 @@ static void RestoreContext(void)
{
uint8_t *MemPtr;
uint8_t *ContextMemPtr = (uint8_t *)CONTEXT_MEM_BASE;
for (MemPtr = &__data_start; MemPtr < &__data_end; MemPtr++, ContextMemPtr++) {
*MemPtr = *ContextMemPtr;
}
for (MemPtr = &__bss_start__; MemPtr < &__bss_end__; MemPtr++, ContextMemPtr++) {
*MemPtr = *ContextMemPtr;
}
pm_dbg("Restored context (tick_count = %d)\n", TickCount);
}
@ -202,10 +207,9 @@ static void PrepareSuspend(void)
*/
static uint32_t InitApp(void)
{
enum XPmBootStatus status;
enum XPmBootStatus status = XPm_GetBootStatus();
pm_dbg("Main\n");
/* Get boot status for APU core #0 */
status = XPm_GetBootStatus();
if (PM_INITIAL_BOOT == status) {
pm_dbg("INITIAL BOOT\n");
/* Configure timer, if configuration fails return from main */
@ -221,6 +225,7 @@ static uint32_t InitApp(void)
} else {
pm_dbg("ERROR cannot identify boot reason\n");
}
return XST_SUCCESS;
}
@ -228,6 +233,7 @@ int main(void)
{
Xil_DCacheDisable();
uint32_t Status = InitApp();
if (XST_SUCCESS != Status) {
return XST_FAILURE;
}
@ -239,10 +245,12 @@ int main(void)
PrepareSuspend();
pm_dbg("Going to WFI...\n");
__asm__("wfi");
/*
* Can execute code below only if interrupt is generated between calling
* the PrepareSuspend and executing wfi. Shouldn't happen.
*/
pm_dbg("Error! WFI exit...\n");
return XST_FAILURE;
}

View file

@ -30,12 +30,12 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* Each PU client in the system have such file with definitions of
* masters in the subsystem and functions for getting informations
* about the master.
*********************************************************************/
*/
#include "pm_client.h"
@ -69,9 +69,7 @@ static const struct XPm_Master pm_apu_3_master = {
.ipi = &apu_ipi,
};
/*
* Order in pm_master_all array must match cpu ids
*/
/* Order in pm_master_all array must match cpu ids */
static const struct XPm_Master *const pm_masters_all[] = {
&pm_apu_0_master,
&pm_apu_1_master,
@ -90,6 +88,7 @@ const struct XPm_Master *pm_get_master(const uint32_t cpuid)
if (cpuid >=0 && PM_ARRAY_SIZE(pm_masters_all)) {
return pm_masters_all[cpuid];
}
return NULL;
}
@ -102,22 +101,26 @@ const struct XPm_Master *pm_get_master(const uint32_t cpuid)
const struct XPm_Master *pm_get_master_by_node(const enum XPmNodeId nid)
{
uint8_t i;
for (i = 0; i < PM_ARRAY_SIZE(pm_masters_all); i++) {
if (nid == pm_masters_all[i]->node_id) {
return pm_masters_all[i];
}
}
return NULL;
}
static uint32_t pm_get_cpuid(const enum XPmNodeId node)
{
uint32_t i;
for (i = 0; i < PM_ARRAY_SIZE(pm_masters_all); i++) {
if (pm_masters_all[i]->node_id == node) {
return i;
}
}
return UNDEFINED_CPUID;
}
@ -132,7 +135,7 @@ void XPm_ClientSuspend(const struct XPm_Master *const master)
pm_write(MASTER_PWRCTL, pm_read(MASTER_PWRCTL) | master->pwrdn_mask);
}
void XPm_ClientAbortSuspend()
void XPm_ClientAbortSuspend(void)
{
/* Enable interrupts at processor level */
pm_enable_int();

View file

@ -30,13 +30,13 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* File is specific for each PU instance and must exist in order to
* port Power Management code for some new PU.
* Contains PU specific macros and macros to be defined depending on
* the execution environment.
*********************************************************************/
*/
#ifndef _PM_CLIENT_H_
#define _PM_CLIENT_H_
@ -85,7 +85,7 @@
#endif
void XPm_ClientSuspend(const struct XPm_Master *const master);
void XPm_ClientAbortSuspend();
void XPm_ClientAbortSuspend(void);
void XPm_ClientWakeup(const struct XPm_Master *const master);
/* Do not modify below this line */

View file

@ -49,7 +49,7 @@
pm_dbg("%s(%d, %d, %d, %d)\n", __func__, arg1, arg2, arg3, arg4);
/**
* pm_get_boot_status() - checks for reason of boot
* XPm_GetBootStatus() - checks for reason of boot
*
* Function returns information about the boot reason.
* If the boot is not a system startup but a resume,
@ -150,7 +150,7 @@ static enum XPmStatus pm_ipi_buff_read32(const struct XPm_Master *const master,
}
/**
* pm_self_suspend() - PM call for master to suspend itself
* XPm_SelfSuspend() - PM call for master to suspend itself
* @node Node id of the master or subsystem
* @latency Requested maximum wakeup latency (not supported)
* @state Requested state (not supported)
@ -194,7 +194,7 @@ enum XPmStatus XPm_SelfSuspend(const enum XPmNodeId nid,
}
/**
* pm_req_suspend() - PM call to request for another PU or subsystem to
* XPm_ReqSuspend() - PM call to request for another PU or subsystem to
* be suspended gracefully.
* @target Node id of the targeted PU or subsystem
* @ack Flag to specify whether acknowledge is requested
@ -221,7 +221,7 @@ enum XPmStatus XPm_ReqSuspend(const enum XPmNodeId target,
}
/**
* pm_req_wakeup() - PM call for master to wake up selected master or subsystem
* XPm_ReqWakeUp() - PM call for master to wake up selected master or subsystem
* @node Node id of the master or subsystem
* @ack Flag to specify whether acknowledge requested
*
@ -246,7 +246,7 @@ enum XPmStatus XPm_ReqWakeUp(const enum XPmNodeId target,
}
/**
* pm_force_powerdown() - PM call to request for another PU or subsystem to
* XPm_ForcePowerDown() - PM call to request for another PU or subsystem to
* be powered down forcefully
* @target Node id of the targeted PU or subsystem
* @ack Flag to specify whether acknowledge is requested
@ -270,7 +270,7 @@ enum XPmStatus XPm_ForcePowerDown(const enum XPmNodeId target,
}
/**
* pm_abort_suspend() - PM call to announce that a prior suspend request
* XPm_AbortSuspend() - PM call to announce that a prior suspend request
* is to be aborted.
* @reason Reason for the abort
*
@ -299,7 +299,7 @@ enum XPmStatus XPm_AbortSuspend(const enum XPmAbortReason reason)
}
/**
* pm_set_wakeup_source() - PM call to specify the wakeup source while suspended
* XPm_SetWakeUpSource() - PM call to specify the wakeup source while suspended
* @target Node id of the targeted PU or subsystem
* @wkup_node Node id of the wakeup peripheral
* @enable Enable or disable the specified peripheral as wake source
@ -316,7 +316,7 @@ enum XPmStatus XPm_SetWakeUpSource(const enum XPmNodeId target,
}
/**
* pm_system_shutdown() - PM call to request a system shutdown or restart
* XPm_SystemShutdown() - PM call to request a system shutdown or restart
* @restart Shutdown or restart? 0 for shutdown, 1 for restart
*
* @return Returns status, either success or error+reason
@ -331,7 +331,7 @@ enum XPmStatus XPm_SystemShutdown(const uint8_t restart)
/* APIs for managing PM slaves: */
/**
* pm_req_node() - PM call to request a node with specifc capabilities
* XPm_ReqNode() - PM call to request a node with specifc capabilities
* @node Node id of the slave
* @capabilities Requested capabilities of the slave
* @qos Quality of service (not supported)
@ -357,7 +357,7 @@ enum XPmStatus XPm_ReqNode(const enum XPmNodeId node,
}
/**
* pm_set_requirement() - PM call to set requirement for PM slaves
* XPm_SetRequirement() - PM call to set requirement for PM slaves
* @node Node id of the slave
* @capabilities Requested capabilities of the slave
* @qos Quality of service (not supported)
@ -384,7 +384,7 @@ enum XPmStatus XPm_SetRequirement(const enum XPmNodeId nid,
}
/**
* pm_release_node() - PM call to release a node
* XPm_ReleaseNode() - PM call to release a node
* @node Node id of the slave
* @latency Requested maximum wakeup latency
*
@ -399,7 +399,7 @@ enum XPmStatus XPm_ReleaseNode(const enum XPmNodeId node,
}
/**
* pm_set_max_latency() - PM call to set wakeup latency requirements
* XPm_SetMaxLatency() - PM call to set wakeup latency requirements
* @node Node id of the slave
* @latency Requested maximum wakeup latency
*
@ -418,7 +418,7 @@ enum XPmStatus XPm_SetMaxLatency(const enum XPmNodeId node,
/* Miscellaneous API functions */
/**
* pm_get_api_version() - Get version number of PMU PM firmware
* XPm_GetApiVersion() - Get version number of PMU PM firmware
* @version Returns 32-bit version number of PMU Power Management Firmware
*
* @return Returns status, either success or error+reason
@ -441,7 +441,7 @@ enum XPmStatus XPm_GetApiVersion(uint32_t *version)
/**
* pm_get_node_status() - PM call to request a node's current power state
* XPm_GetNodeStatus() - PM call to request a node's current power state
* @node Node id of the slave
*
* @return Returns status, either success or error+reason

View file

@ -38,9 +38,7 @@
enum XPmBootStatus XPm_GetBootStatus();
/**********************************************************
* System-level API function declarations
**********************************************************/
/* System-level API function declarations */
enum XPmStatus XPm_ReqSuspend(const enum XPmNodeId node,
const enum XPmRequestAck ack,
const uint32_t latency,
@ -64,8 +62,6 @@ enum XPmStatus XPm_SetWakeUpSource(const enum XPmNodeId target,
enum XPmStatus XPm_SystemShutdown(const uint8_t restart);
/* API functions for managing PM Slaves */
enum XPmStatus XPm_ReqNode(const enum XPmNodeId node,
const uint32_t capabilities,
@ -85,7 +81,4 @@ enum XPmStatus XPm_GetApiVersion(uint32_t *version);
enum XPmStatus XPm_GetNodeStatus(const enum XPmNodeId node);
#endif /* _PM_API_SYS_H_ */

View file

@ -30,11 +30,11 @@
*
******************************************************************************/
/**********************************************************************
/*
* CONTENT
* Definitions of commonly used macros and data types needed for
* PU Power Management. This file should be common for all PU's.
*********************************************************************/
*/
#ifndef _PM_COMMON_H_
#define _PM_COMMON_H_
@ -74,5 +74,4 @@ const enum XPmNodeId pm_get_subsystem_node(void);
const struct XPm_Master *pm_get_master(const uint32_t cpuid);
const struct XPm_Master *pm_get_master_by_node(const enum XPmNodeId nid);
#endif /* _PM_COMMON_H_ */

View file

@ -33,14 +33,6 @@
#ifndef PM_DEFS_H_
#define PM_DEFS_H_
/*********************************************************************
* Macro definitions
********************************************************************/
/*
* Version number is a 32bit value, like:
* (PM_VERSION_MAJOR << 16) | PM_VERSION_MINOR
*/
#define PM_VERSION_MAJOR 0
#define PM_VERSION_MINOR 1
@ -53,10 +45,6 @@
#define MAX_LATENCY (~0U)
#define MAX_QOS 100U
/*********************************************************************
* Enum definitions
********************************************************************/
enum XPmApiId {
/* Miscellaneous API functions: */
PM_GET_API_VERSION = 1, /* Do not change or move */

View file

@ -30,12 +30,12 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* Each PU client in the system have such file with definitions of
* masters in the subsystem and functions for getting informations
* about the master.
*********************************************************************/
*/
#include "pm_client.h"
@ -59,9 +59,7 @@ static const struct XPm_Master pm_rpu_1_master = {
};
#endif
/*
* Order in pm_master_all array must match cpu ids
*/
/* Order in pm_master_all array must match cpu ids */
static const struct XPm_Master *const pm_masters_all[] = {
&pm_rpu_0_master,
#if 0
@ -92,22 +90,26 @@ const struct XPm_Master *pm_get_master(const uint32_t cpuid)
const struct XPm_Master *pm_get_master_by_node(const enum XPmNodeId nid)
{
uint8_t i;
for (i = 0; i < PM_ARRAY_SIZE(pm_masters_all); i++) {
if (nid == pm_masters_all[i]->node_id) {
return pm_masters_all[i];
}
}
return NULL;
}
static uint32_t pm_get_cpuid(const enum XPmNodeId node)
{
uint32_t i;
for (i = 0; i < PM_ARRAY_SIZE(pm_masters_all); i++) {
if (pm_masters_all[i]->node_id == node) {
return i;
}
}
return UNDEFINED_CPUID;
}
@ -122,7 +124,7 @@ void XPm_ClientSuspend(const struct XPm_Master *const master)
pm_write(MASTER_PWRCTL, pm_read(MASTER_PWRCTL) | master->pwrdn_mask);
}
void XPm_ClientAbortSuspend()
void XPm_ClientAbortSuspend(void)
{
/* Enable interrupts at processor level */
pm_enable_int();

View file

@ -30,13 +30,13 @@
*
******************************************************************************/
/*********************************************************************
/*
* CONTENT
* File is specific for each PU instance and must exist in order to
* port Power Management code for some new PU.
* Contains PU specific macros and macros to be defined depending on
* the execution environment.
*********************************************************************/
*/
#ifndef _PM_CLIENT_H_
#define _PM_CLIENT_H_
@ -80,7 +80,7 @@
#endif
void XPm_ClientSuspend(const struct XPm_Master *const master);
void XPm_ClientAbortSuspend();
void XPm_ClientAbortSuspend(void);
void XPm_ClientWakeup(const struct XPm_Master *const master);
/* Do not modify below this line */