From: Ronak Jain <ronak.j...@amd.com>

Add IOCTL support for the AIE run time operations listed below
- Column Reset
- Shim Reset
- Enabling of column clock buffer
- Zeroisation of Program and data memories
- Disabling of column clock buffer
- Enabling AXI-MM error event
- Set L2 controller NPI INTR

Signed-off-by: Ronak Jain <ronak.j...@amd.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 20 +++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h | 30 ++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 7356e860e65c..d9fdfd232d11 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1039,6 +1039,26 @@ int zynqmp_pm_set_boot_health_status(u32 value)
        return zynqmp_pm_invoke_fn(PM_IOCTL, NULL, 3, 0, 
IOCTL_SET_BOOT_HEALTH_STATUS, value);
 }
 
+/**
+ * zynqmp_pm_aie_operation - AI engine run time operations
+ * @node:      AI engine node id
+ * @start_col: Starting column of AI partition
+ * @num_col:   Number of column in AI partition
+ * @operation: ORed value of operations
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_aie_operation(u32 node, u16 start_col, u16 num_col, u32 
operation)
+{
+       u32 partition;
+
+       partition = num_col;
+       partition = ((partition << 16U) | start_col);
+       return zynqmp_pm_invoke_fn(PM_IOCTL, NULL, 4, node, IOCTL_AIE_OPS,
+                                  partition, operation);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_aie_operation);
+
 /**
  * zynqmp_pm_reset_assert - Request setting of reset (1 - assert, 0 - release)
  * @reset:             Reset to be configured
diff --git a/include/linux/firmware/xlnx-zynqmp.h 
b/include/linux/firmware/xlnx-zynqmp.h
index 6d4dbc196b93..1d30366f741b 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -136,6 +136,16 @@
 #define SD_ITAPDLY     0xFF180314
 #define SD_OTAPDLYSEL  0xFF180318
 
+/**
+ * XPM_VERSAL_EVENT_ERROR_MASK_AIE_CR: Error event mask for ME Correctable 
Error.
+ */
+#define XPM_VERSAL_EVENT_ERROR_MASK_AIE_CR     BIT(16)
+
+/**
+ * XPM_VERSAL_EVENT_ERROR_MASK_AIE_NCR: Error event mask for ME 
Non-Correctable Error.
+ */
+#define XPM_VERSAL_EVENT_ERROR_MASK_AIE_NCR    BIT(17)
+
 /**
  * XPM_EVENT_ERROR_MASK_DDRMC_CR: Error event mask for DDRMC MC Correctable 
ECC Error.
  */
@@ -155,6 +165,17 @@ enum pm_module_id {
        TF_A_MODULE_ID = 0xa,
 };
 
+/* AIE Operation */
+#define XILINX_AIE_OPS_COL_RST                 BIT(0)
+#define XILINX_AIE_OPS_SHIM_RST                        BIT(1)
+#define XILINX_AIE_OPS_ENB_COL_CLK_BUFF                BIT(2)
+#define XILINX_AIE_OPS_ZEROISATION             BIT(3)
+#define XILINX_AIE_OPS_DIS_COL_CLK_BUFF                BIT(4)
+#define XILINX_AIE_OPS_ENB_AXI_MM_ERR_EVENT    BIT(5)
+#define XILINX_AIE_OPS_SET_L2_CTRL_NPI_INTR    BIT(6)
+#define XILINX_AIE_OPS_DATA_MEM_ZEROIZATION    BIT(8U)
+#define XILINX_AIE_OPS_MEM_TILE_ZEROIZATION    BIT(9U)
+
 enum pm_api_cb_id {
        PM_INIT_SUSPEND_CB = 30,
        PM_ACKNOWLEDGE_CB = 31,
@@ -244,6 +265,8 @@ enum pm_ioctl_id {
        /* Dynamic SD/GEM configuration */
        IOCTL_SET_SD_CONFIG = 30,
        IOCTL_SET_GEM_CONFIG = 31,
+       /* AIE/AIEML Operations */
+       IOCTL_AIE_OPS = 33,
        /* IOCTL to get default/current QoS */
        IOCTL_GET_QOS = 34,
 };
@@ -633,6 +656,7 @@ int zynqmp_pm_set_tcm_config(u32 node_id, enum rpu_tcm_comb 
tcm_mode);
 int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 
value);
 int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
                             u32 value);
+int zynqmp_pm_aie_operation(u32 node, u16 start_col, u16 num_col, u32 
operation);
 #else
 static inline int zynqmp_pm_get_api_version(u32 *version)
 {
@@ -951,6 +975,12 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
        return -ENODEV;
 }
 
+static inline int zynqmp_pm_aie_operation(u32 node, u16 start_col,
+                                         u16 num_col, u32 operation)
+{
+       return -ENODEV;
+}
+
 #endif
 
 #endif /* __FIRMWARE_ZYNQMP_H__ */
-- 
2.34.1

Reply via email to