Skip to content

Commit f689a0c

Browse files
jbuddhabgregkh
authored andcommitted
firmware: xilinx: Expand feature check to support all PLM modules
To support feature check for all modules, append the module id of the API that is being checked to the feature check API so it could be routed to the target module for processing. There is no need to check compatible string because the board information is taken via firmware interface. Co-developed-by: Saeed Nowshadi <saeed.nowshadi@amd.com> Signed-off-by: Saeed Nowshadi <saeed.nowshadi@amd.com> Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com> Link: https://lore.kernel.org/r/20231129112713.22718-3-jay.buddhabhatti@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f922b16 commit f689a0c

2 files changed

Lines changed: 35 additions & 17 deletions

File tree

drivers/firmware/xilinx/zynqmp.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,29 @@ static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
199199
{
200200
int ret;
201201
u64 smc_arg[2];
202+
u32 module_id;
203+
u32 feature_check_api_id;
202204

203-
smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
204-
smc_arg[1] = api_id;
205+
module_id = FIELD_GET(MODULE_ID_MASK, api_id);
206+
207+
/*
208+
* Feature check of APIs belonging to PM, XSEM, and TF-A are handled by calling
209+
* PM_FEATURE_CHECK API. For other modules, call PM_API_FEATURES API.
210+
*/
211+
if (module_id == PM_MODULE_ID || module_id == XSEM_MODULE_ID || module_id == TF_A_MODULE_ID)
212+
feature_check_api_id = PM_FEATURE_CHECK;
213+
else
214+
feature_check_api_id = PM_API_FEATURES;
215+
216+
/*
217+
* Feature check of TF-A APIs is done in the TF-A layer and it expects for
218+
* MODULE_ID_MASK bits of SMC's arg[0] to be the same as PM_MODULE_ID.
219+
*/
220+
if (module_id == TF_A_MODULE_ID)
221+
module_id = PM_MODULE_ID;
222+
223+
smc_arg[0] = PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, module_id) | feature_check_api_id;
224+
smc_arg[1] = (api_id & API_ID_MASK);
205225

206226
ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
207227
if (ret)
@@ -1904,22 +1924,9 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
19041924
if (ret)
19051925
return ret;
19061926

1907-
np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp");
1908-
if (!np) {
1909-
np = of_find_compatible_node(NULL, NULL, "xlnx,versal");
1910-
if (!np)
1911-
return 0;
1912-
1927+
ret = do_feature_check_call(PM_FEATURE_CHECK);
1928+
if (ret >= 0 && ((ret & FIRMWARE_VERSION_MASK) >= PM_API_VERSION_1))
19131929
feature_check_enabled = true;
1914-
}
1915-
1916-
if (!feature_check_enabled) {
1917-
ret = do_feature_check_call(PM_FEATURE_CHECK);
1918-
if (ret >= 0)
1919-
feature_check_enabled = true;
1920-
}
1921-
1922-
of_node_put(np);
19231930

19241931
devinfo = devm_kzalloc(dev, sizeof(*devinfo), GFP_KERNEL);
19251932
if (!devinfo)

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define PM_SIP_SVC 0xC2000000
3333

3434
/* PM API versions */
35+
#define PM_API_VERSION_1 1
3536
#define PM_API_VERSION_2 2
3637

3738
#define PM_PINCTRL_PARAM_SET_VERSION 2
@@ -47,6 +48,9 @@
4748
#define FAMILY_CODE_MASK GENMASK(27, 21)
4849
#define SUB_FAMILY_CODE_MASK GENMASK(20, 19)
4950

51+
#define API_ID_MASK GENMASK(7, 0)
52+
#define MODULE_ID_MASK GENMASK(11, 8)
53+
5054
/* ATF only commands */
5155
#define TF_A_PM_REGISTER_SGI 0xa04
5256
#define PM_GET_TRUSTZONE_VERSION 0xa03
@@ -112,13 +116,20 @@
112116
#define XPM_EVENT_ERROR_MASK_NOC_NCR BIT(13)
113117
#define XPM_EVENT_ERROR_MASK_NOC_CR BIT(12)
114118

119+
enum pm_module_id {
120+
PM_MODULE_ID = 0x0,
121+
XSEM_MODULE_ID = 0x3,
122+
TF_A_MODULE_ID = 0xa,
123+
};
124+
115125
enum pm_api_cb_id {
116126
PM_INIT_SUSPEND_CB = 30,
117127
PM_ACKNOWLEDGE_CB = 31,
118128
PM_NOTIFY_CB = 32,
119129
};
120130

121131
enum pm_api_id {
132+
PM_API_FEATURES = 0,
122133
PM_GET_API_VERSION = 1,
123134
PM_REGISTER_NOTIFIER = 5,
124135
PM_FORCE_POWERDOWN = 8,

0 commit comments

Comments
 (0)