Skip to content

Commit a5e5698

Browse files
bentheredonethatmathieupoirier
authored andcommitted
firmware: xilinx: Add RPU configuration APIs
This patch adds APIs to access to configure RPU and its processor-specific memory. That is query the run-time mode of RPU as either split or lockstep as well as API to set this mode. In addition add APIs to access configuration of the RPUs' tightly coupled memory (TCM). Signed-off-by: Ben Levinsky <[email protected]> Signed-off-by: Tanmay Shah <[email protected]> Acked-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent da22a04 commit a5e5698

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

drivers/firmware/xilinx/zynqmp.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,68 @@ int zynqmp_pm_release_node(const u32 node)
11591159
}
11601160
EXPORT_SYMBOL_GPL(zynqmp_pm_release_node);
11611161

1162+
/**
1163+
* zynqmp_pm_get_rpu_mode() - Get RPU mode
1164+
* @node_id: Node ID of the device
1165+
* @rpu_mode: return by reference value
1166+
* either split or lockstep
1167+
*
1168+
* Return: return 0 on success or error+reason.
1169+
* if success, then rpu_mode will be set
1170+
* to current rpu mode.
1171+
*/
1172+
int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode)
1173+
{
1174+
u32 ret_payload[PAYLOAD_ARG_CNT];
1175+
int ret;
1176+
1177+
ret = zynqmp_pm_invoke_fn(PM_IOCTL, node_id,
1178+
IOCTL_GET_RPU_OPER_MODE, 0, 0, ret_payload);
1179+
1180+
/* only set rpu_mode if no error */
1181+
if (ret == XST_PM_SUCCESS)
1182+
*rpu_mode = ret_payload[0];
1183+
1184+
return ret;
1185+
}
1186+
EXPORT_SYMBOL_GPL(zynqmp_pm_get_rpu_mode);
1187+
1188+
/**
1189+
* zynqmp_pm_set_rpu_mode() - Set RPU mode
1190+
* @node_id: Node ID of the device
1191+
* @rpu_mode: Argument 1 to requested IOCTL call. either split or lockstep
1192+
*
1193+
* This function is used to set RPU mode to split or
1194+
* lockstep
1195+
*
1196+
* Return: Returns status, either success or error+reason
1197+
*/
1198+
int zynqmp_pm_set_rpu_mode(u32 node_id, enum rpu_oper_mode rpu_mode)
1199+
{
1200+
return zynqmp_pm_invoke_fn(PM_IOCTL, node_id,
1201+
IOCTL_SET_RPU_OPER_MODE, (u32)rpu_mode,
1202+
0, NULL);
1203+
}
1204+
EXPORT_SYMBOL_GPL(zynqmp_pm_set_rpu_mode);
1205+
1206+
/**
1207+
* zynqmp_pm_set_tcm_config - configure TCM
1208+
* @node_id: Firmware specific TCM subsystem ID
1209+
* @tcm_mode: Argument 1 to requested IOCTL call
1210+
* either PM_RPU_TCM_COMB or PM_RPU_TCM_SPLIT
1211+
*
1212+
* This function is used to set RPU mode to split or combined
1213+
*
1214+
* Return: status: 0 for success, else failure
1215+
*/
1216+
int zynqmp_pm_set_tcm_config(u32 node_id, enum rpu_tcm_comb tcm_mode)
1217+
{
1218+
return zynqmp_pm_invoke_fn(PM_IOCTL, node_id,
1219+
IOCTL_TCM_COMB_CONFIG, (u32)tcm_mode, 0,
1220+
NULL);
1221+
}
1222+
EXPORT_SYMBOL_GPL(zynqmp_pm_set_tcm_config);
1223+
11621224
/**
11631225
* zynqmp_pm_force_pwrdwn - PM call to request for another PU or subsystem to
11641226
* be powered down forcefully

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,9 @@ int zynqmp_pm_request_wake(const u32 node,
530530
const bool set_addr,
531531
const u64 address,
532532
const enum zynqmp_pm_request_ack ack);
533+
int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode);
534+
int zynqmp_pm_set_rpu_mode(u32 node_id, u32 arg1);
535+
int zynqmp_pm_set_tcm_config(u32 node_id, u32 arg1);
533536
int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value);
534537
int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
535538
u32 value);
@@ -818,6 +821,21 @@ static inline int zynqmp_pm_request_wake(const u32 node,
818821
return -ENODEV;
819822
}
820823

824+
static inline int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode)
825+
{
826+
return -ENODEV;
827+
}
828+
829+
static inline int zynqmp_pm_set_rpu_mode(u32 node_id, u32 arg1)
830+
{
831+
return -ENODEV;
832+
}
833+
834+
static inline int zynqmp_pm_set_tcm_config(u32 node_id, u32 arg1)
835+
{
836+
return -ENODEV;
837+
}
838+
821839
static inline int zynqmp_pm_set_sd_config(u32 node,
822840
enum pm_sd_config_type config,
823841
u32 value)

0 commit comments

Comments
 (0)