PMUFW: IPI: Add IPI Framework
Basic APIs are provided for modules to send/receive IPI messages. These are wrappers around IPI driver functions and are intended to support a common message structure. Currently only a module's IPI ID is considered.This can be extended to include checksum and other fields in IPI message and dispatching IPIs based on module id. Signed-off-by: Jyotheeswar Reddy <jyothee@xilinx.com>
This commit is contained in:
parent
15dfa120ad
commit
fd53261bc5
3 changed files with 271 additions and 1 deletions
167
lib/sw_apps/zynqmp_pmufw/src/xpfw_ipi_manager.c
Normal file
167
lib/sw_apps/zynqmp_pmufw/src/xpfw_ipi_manager.c
Normal file
|
@ -0,0 +1,167 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "xpfw_ipi_manager.h"
|
||||
|
||||
/**
|
||||
* This file provides a framework for modules to send and receive IPI messages
|
||||
* PMU IPI-0 is used as the default channel for communication
|
||||
*
|
||||
* Currently this framework supports for checking/embedding IPI ID of a module.
|
||||
* IPI ID is the MSB 16-bits of the first word in pay load.
|
||||
* Depending on the application requirements, more features like CheckSum,
|
||||
* Message Sequencing etc can be added.
|
||||
*/
|
||||
|
||||
/* Instance of IPI Driver */
|
||||
static XIpiPsu IpiInst;
|
||||
static XIpiPsu *IpiInstPtr = &IpiInst;
|
||||
|
||||
s32 XPfw_IpiManagerInit(void)
|
||||
{
|
||||
s32 Status;
|
||||
XIpiPsu_Config *IpiCfgPtr;
|
||||
|
||||
/* Load Config for PMU IPI-0 */
|
||||
IpiCfgPtr = XIpiPsu_LookupConfig(XPAR_XIPIPSU_0_DEVICE_ID);
|
||||
|
||||
if (IpiCfgPtr == NULL) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Initialize the IPI driver */
|
||||
Status = XIpiPsu_CfgInitialize(IpiInstPtr, IpiCfgPtr,
|
||||
IpiCfgPtr->BaseAddress);
|
||||
|
||||
Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
s32 XPfw_IpiWriteMessage(const XPfw_Module_t *ModPtr, u32 DestCpuMask, u32 *MsgPtr, u32 MsgLen)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
if ((ModPtr == NULL) || (MsgPtr == NULL)) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
MsgPtr[0] = (MsgPtr[0] & 0x0000FFFFU) | (ModPtr->IpiId << 16U);
|
||||
Status = XIpiPsu_WriteMessage(IpiInstPtr, DestCpuMask, MsgPtr, MsgLen,
|
||||
XIPIPSU_BUF_TYPE_MSG);
|
||||
|
||||
Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
s32 XPfw_IpiWriteResponse(const XPfw_Module_t *ModPtr, u32 DestCpuMask, u32 *MsgPtr, u32 MsgLen)
|
||||
{
|
||||
s32 Status;
|
||||
|
||||
if ((ModPtr == NULL) || (MsgPtr == NULL)) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
MsgPtr[0] = (MsgPtr[0] & 0x0000FFFFU) | (ModPtr->IpiId << 16U);
|
||||
Status = XIpiPsu_WriteMessage(IpiInstPtr, DestCpuMask, MsgPtr, MsgLen,
|
||||
XIPIPSU_BUF_TYPE_RESP);
|
||||
|
||||
Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
s32 XPfw_IpiReadMessage(const XPfw_Module_t *ModPtr, u32 SrcCpuMask, u32 *MsgPtr, u32 MsgLen)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 MsgHeader;
|
||||
|
||||
if ((ModPtr == NULL) || (MsgPtr == NULL)) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Read the first word */
|
||||
Status = XIpiPsu_ReadMessage(IpiInstPtr, SrcCpuMask, &MsgHeader, 1U,
|
||||
XIPIPSU_BUF_TYPE_MSG);
|
||||
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Check if IPI Id matches the upper 16 bits of first word*/
|
||||
if ((MsgHeader >> 16) != ModPtr->IpiId) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Read Entire Message to Buffer */
|
||||
Status = XIpiPsu_ReadMessage(IpiInstPtr, SrcCpuMask, MsgPtr, MsgLen,
|
||||
XIPIPSU_BUF_TYPE_MSG);
|
||||
|
||||
Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
s32 XPfw_IpiReadResponse(const XPfw_Module_t *ModPtr, u32 SrcCpuMask, u32 *MsgPtr, u32 MsgLen)
|
||||
{
|
||||
s32 Status = XST_FAILURE;
|
||||
u32 MsgHeader;
|
||||
|
||||
if ((ModPtr == NULL) || (MsgPtr == NULL)) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Read the first word */
|
||||
Status = XIpiPsu_ReadMessage(IpiInstPtr, SrcCpuMask, &MsgHeader, 1U,
|
||||
XIPIPSU_BUF_TYPE_RESP);
|
||||
|
||||
if (Status != XST_SUCCESS) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Check if IPI Id matches the upper 16 bits of first word*/
|
||||
if ((MsgHeader >> 16) != ModPtr->IpiId) {
|
||||
Status = XST_FAILURE;
|
||||
goto Done;
|
||||
}
|
||||
/* Read Entire Message to Buffer */
|
||||
Status = XIpiPsu_ReadMessage(IpiInstPtr, SrcCpuMask, MsgPtr, MsgLen,
|
||||
XIPIPSU_BUF_TYPE_RESP);
|
||||
|
||||
Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
inline s32 XPfw_IpiTrigger(u32 DestCpuMask)
|
||||
{
|
||||
return XIpiPsu_TriggerIpi(IpiInstPtr, DestCpuMask);
|
||||
}
|
103
lib/sw_apps/zynqmp_pmufw/src/xpfw_ipi_manager.h
Normal file
103
lib/sw_apps/zynqmp_pmufw/src/xpfw_ipi_manager.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Use of the Software is limited solely to applications:
|
||||
* (a) running on a Xilinx device, or
|
||||
* (b) that interact with a Xilinx device through a bus or interconnect.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the Xilinx shall not be used
|
||||
* in advertising or otherwise to promote the sale, use or other dealings in
|
||||
* this Software without prior written authorization from Xilinx.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef XPFW_IPI_MANAGER_H_
|
||||
#define XPFW_IPI_MANAGER_H_
|
||||
|
||||
#include "xstatus.h"
|
||||
#include "xpfw_default.h"
|
||||
#include "xpfw_module.h"
|
||||
#include "xipipsu.h"
|
||||
#include "xparameters.h"
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the IPI driver instance
|
||||
* This should be called in the core init
|
||||
*/
|
||||
s32 XPfw_IpiInit(void);
|
||||
|
||||
/**
|
||||
* Write a message to IPI Message Buffer
|
||||
* @param ModPtr is the pointer to module that is sending the message
|
||||
* @param DestCpuMask is mask for the destination CPU
|
||||
* @param MsgPtr is pointer to the buffer containing the message to be sent
|
||||
* @param MsgLen is the number of 32-bit words to be sent
|
||||
* @return XST_SUCCESS if success
|
||||
* XST_FAILURE if failure
|
||||
*/
|
||||
s32 XPfw_IpiWriteMessage(const XPfw_Module_t *ModPtr, u32 DestCpuMask, u32 *MsgPtr, u32 MsgLen);
|
||||
|
||||
/**
|
||||
* Write a message to IPI Response Buffer
|
||||
* This function is preferably called from with in a IPI interrupt handler to send a response
|
||||
* for that IPI request
|
||||
* @param ModPtr is the pointer to module that is sending the message
|
||||
* @param DestCpuMask is mask for the destination CPU
|
||||
* @param MsgPtr is pointer to the buffer containing the message to be sent
|
||||
* @param MsgLen is the number of 32-bit words to be sent
|
||||
* @return XST_SUCCESS if success
|
||||
* XST_FAILURE if failure
|
||||
*/
|
||||
s32 XPfw_IpiWriteResponse(const XPfw_Module_t *ModPtr, u32 DestCpuMask, u32 *MsgPtr, u32 MsgLen);
|
||||
|
||||
/**
|
||||
* Read Message buffer contents
|
||||
* @param ModPtr is the pointer to module that is requesting teh message
|
||||
* @param SrcCpuMask is mask for the Source CPU
|
||||
* @param MsgPtr is pointer to the buffer to which message is to be retrieved
|
||||
* @param MsgLen is the number of 32-bits to be retrieved
|
||||
* @return XST_SUCCESS if IPI ID of the module matches and the message is read into buffer
|
||||
* XST_FAILURE if a mismatch in IPI ID or failure to read message
|
||||
*/
|
||||
s32 XPfw_IpiReadMessage(const XPfw_Module_t *ModPtr, u32 SrcCpuMask, u32 *MsgPtr, u32 MsgLen);
|
||||
|
||||
/**
|
||||
* Read Response buffer contents
|
||||
* @param ModPtr is the pointer to module that is requesting the message
|
||||
* @param SrcCpuMask is mask for the Source CPU
|
||||
* @param MsgPtr is pointer to the buffer to which message is to be retrieved
|
||||
* @param MsgLen is the number of 32-bits to be retrieved
|
||||
* @return XST_SUCCESS if IPI ID of the module matches and the message is read into buffer
|
||||
* XST_FAILURE if a mismatch in IPI ID or failure to read message
|
||||
*/
|
||||
s32 XPfw_IpiReadResponse(const XPfw_Module_t *ModPtr, u32 SrcCpuMask, u32 *MsgPtr, u32 MsgLen);
|
||||
|
||||
/**
|
||||
* Trigger an IPI interrupt to a target processor
|
||||
*
|
||||
* @param DestCpuMask is the mask corresponding to Dest CPU
|
||||
*
|
||||
* @return XST_SUCCESS if IPI was triggered
|
||||
* XST_FAILURE if an error occurred while triggering
|
||||
*/
|
||||
s32 XPfw_IpiTrigger(u32 DestCpuMask);
|
||||
|
||||
#endif /* XPFW_IPI_MANAGER_H_ */
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef ZYNQMP_XPFW_VERSION__H_
|
||||
#define ZYNQMP_XPFW_VERSION__H_
|
||||
#define ZYNQMP_XPFW_VERSION "2015.3-rc1-14-g00965c45d411"
|
||||
#define ZYNQMP_XPFW_VERSION "2015.3-rc1-15-gea64c7dae039"
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue