* [PATCH v4 0/2]Adds status interface for zynqmp-fpga
@ 2022-12-23 11:58 ` Nava kishore Manne
0 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds status interface for zynqmp-fpga, It's a read only interface
which allows the user to get the Programmable Logic(PL) status.
-Device Initialization error.
-Device internal signal error.
-All I/Os are placed in High-Z state.
-Device start-up sequence error.
-Firmware error.
For more details refer the ug570.
https://docs.xilinx.com/v/u/en-US/ug570-ultrascale-configuration
Nava kishore Manne (2):
firmware: xilinx: Add pm api function for PL config reg readback
fpga: zynqmp-fpga: Adds status interface
drivers/firmware/xilinx/zynqmp.c | 33 +++++++++++
drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 10 ++++
3 files changed, 130 insertions(+)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 0/2]Adds status interface for zynqmp-fpga
@ 2022-12-23 11:58 ` Nava kishore Manne
0 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds status interface for zynqmp-fpga, It's a read only interface
which allows the user to get the Programmable Logic(PL) status.
-Device Initialization error.
-Device internal signal error.
-All I/Os are placed in High-Z state.
-Device start-up sequence error.
-Firmware error.
For more details refer the ug570.
https://docs.xilinx.com/v/u/en-US/ug570-ultrascale-configuration
Nava kishore Manne (2):
firmware: xilinx: Add pm api function for PL config reg readback
fpga: zynqmp-fpga: Adds status interface
drivers/firmware/xilinx/zynqmp.c | 33 +++++++++++
drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 10 ++++
3 files changed, 130 insertions(+)
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/2] firmware: xilinx: Add pm api function for PL config reg readback
2022-12-23 11:58 ` Nava kishore Manne
@ 2022-12-23 11:58 ` Nava kishore Manne
-1 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds PM API for performing Programmable Logic(PL) configuration
register readback. It provides an interface to the firmware(pmufw)
to readback the FPGA configuration register.
Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
---
changes for v2:
- None.
Changes for v3:
- Updated API and config reg read-back handling logic
- Updated the commit msg to align with the changes.
Changes for v4:
- Fix some minor coding issues. No functional changes.
- Updated Return value comments as suggested by Xu Yilun.
drivers/firmware/xilinx/zynqmp.c | 33 ++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 10 +++++++++
2 files changed, 43 insertions(+)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index ff5cabe70a2b..ca954e1119b5 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -941,6 +941,39 @@ int zynqmp_pm_fpga_get_status(u32 *value)
}
EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
+/**
+ * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
+ * @value: Buffer to store FPGA configuration status.
+ *
+ * This function provides access to the pmufw to get the FPGA configuration
+ * status
+ *
+ * Return: 0 on success, a negative value on error
+ */
+int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+ u32 buf, phys_lower_addr, phys_upper_addr;
+ u32 ret_payload[PAYLOAD_ARG_CNT];
+ int ret;
+
+ if (!value)
+ return -EINVAL;
+
+ phys_lower_addr = lower_32_bits((u64)&buf);
+ phys_upper_addr = upper_32_bits((u64)&buf);
+
+ ret = zynqmp_pm_invoke_fn(PM_FPGA_READ,
+ XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET,
+ phys_lower_addr, phys_upper_addr,
+ XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG,
+ ret_payload);
+
+ *value = ret_payload[1];
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
+
/**
* zynqmp_pm_pinctrl_request - Request Pin from firmware
* @pin: Pin number to request
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 76d2b3ebad84..29e8964f4297 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -70,6 +70,10 @@
#define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
#define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
+/* FPGA Status Reg */
+#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U
+#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG 0U
+
/*
* Node IDs for the Error Events.
*/
@@ -117,6 +121,7 @@ enum pm_api_id {
PM_CLOCK_GETRATE = 42,
PM_CLOCK_SETPARENT = 43,
PM_CLOCK_GETPARENT = 44,
+ PM_FPGA_READ = 46,
PM_SECURE_AES = 47,
PM_FEATURE_CHECK = 63,
};
@@ -505,6 +510,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
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_fpga_get_config_status(u32 *value);
#else
static inline int zynqmp_pm_get_api_version(u32 *version)
{
@@ -790,6 +796,10 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
return -ENODEV;
}
+static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+ return -ENODEV;
+}
#endif
#endif /* __FIRMWARE_ZYNQMP_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 1/2] firmware: xilinx: Add pm api function for PL config reg readback
@ 2022-12-23 11:58 ` Nava kishore Manne
0 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds PM API for performing Programmable Logic(PL) configuration
register readback. It provides an interface to the firmware(pmufw)
to readback the FPGA configuration register.
Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
---
changes for v2:
- None.
Changes for v3:
- Updated API and config reg read-back handling logic
- Updated the commit msg to align with the changes.
Changes for v4:
- Fix some minor coding issues. No functional changes.
- Updated Return value comments as suggested by Xu Yilun.
drivers/firmware/xilinx/zynqmp.c | 33 ++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 10 +++++++++
2 files changed, 43 insertions(+)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index ff5cabe70a2b..ca954e1119b5 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -941,6 +941,39 @@ int zynqmp_pm_fpga_get_status(u32 *value)
}
EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
+/**
+ * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
+ * @value: Buffer to store FPGA configuration status.
+ *
+ * This function provides access to the pmufw to get the FPGA configuration
+ * status
+ *
+ * Return: 0 on success, a negative value on error
+ */
+int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+ u32 buf, phys_lower_addr, phys_upper_addr;
+ u32 ret_payload[PAYLOAD_ARG_CNT];
+ int ret;
+
+ if (!value)
+ return -EINVAL;
+
+ phys_lower_addr = lower_32_bits((u64)&buf);
+ phys_upper_addr = upper_32_bits((u64)&buf);
+
+ ret = zynqmp_pm_invoke_fn(PM_FPGA_READ,
+ XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET,
+ phys_lower_addr, phys_upper_addr,
+ XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG,
+ ret_payload);
+
+ *value = ret_payload[1];
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
+
/**
* zynqmp_pm_pinctrl_request - Request Pin from firmware
* @pin: Pin number to request
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 76d2b3ebad84..29e8964f4297 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -70,6 +70,10 @@
#define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
#define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
+/* FPGA Status Reg */
+#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U
+#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG 0U
+
/*
* Node IDs for the Error Events.
*/
@@ -117,6 +121,7 @@ enum pm_api_id {
PM_CLOCK_GETRATE = 42,
PM_CLOCK_SETPARENT = 43,
PM_CLOCK_GETPARENT = 44,
+ PM_FPGA_READ = 46,
PM_SECURE_AES = 47,
PM_FEATURE_CHECK = 63,
};
@@ -505,6 +510,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
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_fpga_get_config_status(u32 *value);
#else
static inline int zynqmp_pm_get_api_version(u32 *version)
{
@@ -790,6 +796,10 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
return -ENODEV;
}
+static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
+{
+ return -ENODEV;
+}
#endif
#endif /* __FIRMWARE_ZYNQMP_H__ */
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 2/2] fpga: zynqmp-fpga: Adds status interface
2022-12-23 11:58 ` Nava kishore Manne
@ 2022-12-23 11:58 ` Nava kishore Manne
-1 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds status interface for zynqmp-fpga, It's a read only interface
which allows the user to get the Programmable Logic(PL) configuration
status.
Usage:
To read the Programmable Logic(PL) configuration status
cat /sys/class/fpga_manager/<fpga>/device/status
Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
---
Changes for v2:
- Updated status messages handling logic as suggested by Xu Yilun.
Changes for v3:
- Updated status interface handling logic (Restrict the status
interface to the device-specific instead of handled by the core)
as suggested by Xu Yilun.
Changes for v4:
- Limit the error strings to one word for each as suggested by
Xu Yilun
drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index c60f20949c47..81d3e18527ee 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -15,6 +15,37 @@
/* Constant Definitions */
#define IXR_FPGA_DONE_MASK BIT(3)
+/* Error Register */
+#define IXR_FPGA_ERR_CRC_ERR BIT(0)
+#define IXR_FPGA_ERR_SECURITY_ERR BIT(16)
+
+/* Signal Status Register */
+#define IXR_FPGA_END_OF_STARTUP BIT(4)
+#define IXR_FPGA_GST_CFG_B BIT(5)
+#define IXR_FPGA_INIT_B_INTERNAL BIT(11)
+#define IXR_FPGA_DONE_INTERNAL_SIGNAL BIT(13)
+
+/* FPGA error status. */
+enum {
+ ZYNQMP_FPGA_STATUS_CRC_ERR,
+ ZYNQMP_FPGA_STATUS_SECURITY_ERR,
+ ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR,
+ ZYNQMP_FPGA_STATUS_SIGNAL_ERR,
+ ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR,
+ ZYNQMP_FPGA_STATUS_EOS_ERR,
+ ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR,
+};
+
+static const char * const zynqmp_fpga_error_statuses[] = {
+ [ZYNQMP_FPGA_STATUS_CRC_ERR] = "CRC-Error",
+ [ZYNQMP_FPGA_STATUS_SECURITY_ERR] = "Security-Error",
+ [ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR] = "Initialization-Error",
+ [ZYNQMP_FPGA_STATUS_SIGNAL_ERR] = "Internal-Signal-Error",
+ [ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR] = "I/Os-High-Z-state",
+ [ZYNQMP_FPGA_STATUS_EOS_ERR] = "Sequence-Error",
+ [ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR] = "Firmware-Error",
+};
+
/**
* struct zynqmp_fpga_priv - Private data structure
* @dev: Device data structure
@@ -77,6 +108,54 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
return FPGA_MGR_STATE_UNKNOWN;
}
+static ssize_t status_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ unsigned long status = 0;
+ ssize_t len = 0;
+ u32 reg_val;
+ int ret;
+ u8 i;
+
+ ret = zynqmp_pm_fpga_get_config_status(®_val);
+ if (!ret) {
+ if (reg_val & IXR_FPGA_ERR_CRC_ERR)
+ status |= ZYNQMP_FPGA_STATUS_CRC_ERR;
+ if (reg_val & IXR_FPGA_ERR_SECURITY_ERR)
+ status |= ZYNQMP_FPGA_STATUS_SECURITY_ERR;
+ if (!(reg_val & IXR_FPGA_INIT_B_INTERNAL))
+ status |= ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR;
+ if (!(reg_val & IXR_FPGA_DONE_INTERNAL_SIGNAL))
+ status |= ZYNQMP_FPGA_STATUS_SIGNAL_ERR;
+ if (!(reg_val & IXR_FPGA_GST_CFG_B))
+ status |= ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR;
+ if (!(reg_val & IXR_FPGA_END_OF_STARTUP))
+ status |= ZYNQMP_FPGA_STATUS_EOS_ERR;
+ } else {
+ status = ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR;
+ }
+
+ for_each_set_bit(i, &status, ARRAY_SIZE(zynqmp_fpga_error_statuses))
+ len += sysfs_emit_at(buf, len, "%s ",
+ zynqmp_fpga_error_statuses[i]);
+
+ if (len)
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static DEVICE_ATTR_RO(status);
+
+static struct attribute *zynqmp_fpga_device_attrs[] = {
+ &dev_attr_status.attr,
+ NULL,
+};
+
+static const struct attribute_group zynqmp_fpga_attr_group = {
+ .attrs = zynqmp_fpga_device_attrs,
+};
+
static const struct fpga_manager_ops zynqmp_fpga_ops = {
.state = zynqmp_fpga_ops_state,
.write_init = zynqmp_fpga_ops_write_init,
@@ -88,6 +167,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct zynqmp_fpga_priv *priv;
struct fpga_manager *mgr;
+ int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -95,6 +175,13 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
priv->dev = dev;
+ /* Add the device attributes */
+ ret = sysfs_create_group(&dev->kobj, &zynqmp_fpga_attr_group);
+ if (ret) {
+ dev_err(dev, "Error creating sysfs files\n");
+ return ret;
+ }
+
mgr = devm_fpga_mgr_register(dev, "Xilinx ZynqMP FPGA Manager",
&zynqmp_fpga_ops, priv);
return PTR_ERR_OR_ZERO(mgr);
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 2/2] fpga: zynqmp-fpga: Adds status interface
@ 2022-12-23 11:58 ` Nava kishore Manne
0 siblings, 0 replies; 10+ messages in thread
From: Nava kishore Manne @ 2022-12-23 11:58 UTC (permalink / raw)
To: michal.simek, mdf, hao.wu, yilun.xu, trix, ronak.jain, gregkh,
tanmay.shah, ben.levinsky, harsha.harsha, rajan.vaja,
nava.kishore.manne, mathieu.poirier, linux-arm-kernel,
linux-kernel, linux-fpga
Adds status interface for zynqmp-fpga, It's a read only interface
which allows the user to get the Programmable Logic(PL) configuration
status.
Usage:
To read the Programmable Logic(PL) configuration status
cat /sys/class/fpga_manager/<fpga>/device/status
Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
---
Changes for v2:
- Updated status messages handling logic as suggested by Xu Yilun.
Changes for v3:
- Updated status interface handling logic (Restrict the status
interface to the device-specific instead of handled by the core)
as suggested by Xu Yilun.
Changes for v4:
- Limit the error strings to one word for each as suggested by
Xu Yilun
drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index c60f20949c47..81d3e18527ee 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -15,6 +15,37 @@
/* Constant Definitions */
#define IXR_FPGA_DONE_MASK BIT(3)
+/* Error Register */
+#define IXR_FPGA_ERR_CRC_ERR BIT(0)
+#define IXR_FPGA_ERR_SECURITY_ERR BIT(16)
+
+/* Signal Status Register */
+#define IXR_FPGA_END_OF_STARTUP BIT(4)
+#define IXR_FPGA_GST_CFG_B BIT(5)
+#define IXR_FPGA_INIT_B_INTERNAL BIT(11)
+#define IXR_FPGA_DONE_INTERNAL_SIGNAL BIT(13)
+
+/* FPGA error status. */
+enum {
+ ZYNQMP_FPGA_STATUS_CRC_ERR,
+ ZYNQMP_FPGA_STATUS_SECURITY_ERR,
+ ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR,
+ ZYNQMP_FPGA_STATUS_SIGNAL_ERR,
+ ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR,
+ ZYNQMP_FPGA_STATUS_EOS_ERR,
+ ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR,
+};
+
+static const char * const zynqmp_fpga_error_statuses[] = {
+ [ZYNQMP_FPGA_STATUS_CRC_ERR] = "CRC-Error",
+ [ZYNQMP_FPGA_STATUS_SECURITY_ERR] = "Security-Error",
+ [ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR] = "Initialization-Error",
+ [ZYNQMP_FPGA_STATUS_SIGNAL_ERR] = "Internal-Signal-Error",
+ [ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR] = "I/Os-High-Z-state",
+ [ZYNQMP_FPGA_STATUS_EOS_ERR] = "Sequence-Error",
+ [ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR] = "Firmware-Error",
+};
+
/**
* struct zynqmp_fpga_priv - Private data structure
* @dev: Device data structure
@@ -77,6 +108,54 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
return FPGA_MGR_STATE_UNKNOWN;
}
+static ssize_t status_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ unsigned long status = 0;
+ ssize_t len = 0;
+ u32 reg_val;
+ int ret;
+ u8 i;
+
+ ret = zynqmp_pm_fpga_get_config_status(®_val);
+ if (!ret) {
+ if (reg_val & IXR_FPGA_ERR_CRC_ERR)
+ status |= ZYNQMP_FPGA_STATUS_CRC_ERR;
+ if (reg_val & IXR_FPGA_ERR_SECURITY_ERR)
+ status |= ZYNQMP_FPGA_STATUS_SECURITY_ERR;
+ if (!(reg_val & IXR_FPGA_INIT_B_INTERNAL))
+ status |= ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR;
+ if (!(reg_val & IXR_FPGA_DONE_INTERNAL_SIGNAL))
+ status |= ZYNQMP_FPGA_STATUS_SIGNAL_ERR;
+ if (!(reg_val & IXR_FPGA_GST_CFG_B))
+ status |= ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR;
+ if (!(reg_val & IXR_FPGA_END_OF_STARTUP))
+ status |= ZYNQMP_FPGA_STATUS_EOS_ERR;
+ } else {
+ status = ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR;
+ }
+
+ for_each_set_bit(i, &status, ARRAY_SIZE(zynqmp_fpga_error_statuses))
+ len += sysfs_emit_at(buf, len, "%s ",
+ zynqmp_fpga_error_statuses[i]);
+
+ if (len)
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static DEVICE_ATTR_RO(status);
+
+static struct attribute *zynqmp_fpga_device_attrs[] = {
+ &dev_attr_status.attr,
+ NULL,
+};
+
+static const struct attribute_group zynqmp_fpga_attr_group = {
+ .attrs = zynqmp_fpga_device_attrs,
+};
+
static const struct fpga_manager_ops zynqmp_fpga_ops = {
.state = zynqmp_fpga_ops_state,
.write_init = zynqmp_fpga_ops_write_init,
@@ -88,6 +167,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct zynqmp_fpga_priv *priv;
struct fpga_manager *mgr;
+ int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -95,6 +175,13 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
priv->dev = dev;
+ /* Add the device attributes */
+ ret = sysfs_create_group(&dev->kobj, &zynqmp_fpga_attr_group);
+ if (ret) {
+ dev_err(dev, "Error creating sysfs files\n");
+ return ret;
+ }
+
mgr = devm_fpga_mgr_register(dev, "Xilinx ZynqMP FPGA Manager",
&zynqmp_fpga_ops, priv);
return PTR_ERR_OR_ZERO(mgr);
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/2] firmware: xilinx: Add pm api function for PL config reg readback
2022-12-23 11:58 ` Nava kishore Manne
@ 2022-12-26 5:56 ` Xu Yilun
-1 siblings, 0 replies; 10+ messages in thread
From: Xu Yilun @ 2022-12-26 5:56 UTC (permalink / raw)
To: Nava kishore Manne
Cc: michal.simek, mdf, hao.wu, trix, ronak.jain, gregkh, tanmay.shah,
ben.levinsky, harsha.harsha, rajan.vaja, mathieu.poirier,
linux-arm-kernel, linux-kernel, linux-fpga
On 2022-12-23 at 17:28:49 +0530, Nava kishore Manne wrote:
> Adds PM API for performing Programmable Logic(PL) configuration
> register readback. It provides an interface to the firmware(pmufw)
> to readback the FPGA configuration register.
>
> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
> ---
> changes for v2:
> - None.
>
> Changes for v3:
> - Updated API and config reg read-back handling logic
> - Updated the commit msg to align with the changes.
>
> Changes for v4:
> - Fix some minor coding issues. No functional changes.
> - Updated Return value comments as suggested by Xu Yilun.
>
> drivers/firmware/xilinx/zynqmp.c | 33 ++++++++++++++++++++++++++++
> include/linux/firmware/xlnx-zynqmp.h | 10 +++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index ff5cabe70a2b..ca954e1119b5 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -941,6 +941,39 @@ int zynqmp_pm_fpga_get_status(u32 *value)
> }
> EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
>
> +/**
> + * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
> + * @value: Buffer to store FPGA configuration status.
> + *
> + * This function provides access to the pmufw to get the FPGA configuration
> + * status
> + *
> + * Return: 0 on success, a negative value on error
> + */
> +int zynqmp_pm_fpga_get_config_status(u32 *value)
> +{
> + u32 buf, phys_lower_addr, phys_upper_addr;
Why naming them phys_xxx?
> + u32 ret_payload[PAYLOAD_ARG_CNT];
> + int ret;
> +
> + if (!value)
> + return -EINVAL;
> +
> + phys_lower_addr = lower_32_bits((u64)&buf);
> + phys_upper_addr = upper_32_bits((u64)&buf);
> +
> + ret = zynqmp_pm_invoke_fn(PM_FPGA_READ,
> + XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET,
> + phys_lower_addr, phys_upper_addr,
> + XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG,
> + ret_payload);
> +
> + *value = ret_payload[1];
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
> +
> /**
> * zynqmp_pm_pinctrl_request - Request Pin from firmware
> * @pin: Pin number to request
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 76d2b3ebad84..29e8964f4297 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -70,6 +70,10 @@
> #define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
> #define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
>
> +/* FPGA Status Reg */
> +#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U
> +#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG 0U
> +
> /*
> * Node IDs for the Error Events.
> */
> @@ -117,6 +121,7 @@ enum pm_api_id {
> PM_CLOCK_GETRATE = 42,
> PM_CLOCK_SETPARENT = 43,
> PM_CLOCK_GETPARENT = 44,
> + PM_FPGA_READ = 46,
> PM_SECURE_AES = 47,
> PM_FEATURE_CHECK = 63,
> };
> @@ -505,6 +510,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
> 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_fpga_get_config_status(u32 *value);
Is it better put it along with zynqmp_pm_fpga_get_status()?
Thanks,
Yilun
> #else
> static inline int zynqmp_pm_get_api_version(u32 *version)
> {
> @@ -790,6 +796,10 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
> return -ENODEV;
> }
>
> +static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
> +{
> + return -ENODEV;
> +}
> #endif
>
> #endif /* __FIRMWARE_ZYNQMP_H__ */
> --
> 2.25.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/2] firmware: xilinx: Add pm api function for PL config reg readback
@ 2022-12-26 5:56 ` Xu Yilun
0 siblings, 0 replies; 10+ messages in thread
From: Xu Yilun @ 2022-12-26 5:56 UTC (permalink / raw)
To: Nava kishore Manne
Cc: michal.simek, mdf, hao.wu, trix, ronak.jain, gregkh, tanmay.shah,
ben.levinsky, harsha.harsha, rajan.vaja, mathieu.poirier,
linux-arm-kernel, linux-kernel, linux-fpga
On 2022-12-23 at 17:28:49 +0530, Nava kishore Manne wrote:
> Adds PM API for performing Programmable Logic(PL) configuration
> register readback. It provides an interface to the firmware(pmufw)
> to readback the FPGA configuration register.
>
> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
> ---
> changes for v2:
> - None.
>
> Changes for v3:
> - Updated API and config reg read-back handling logic
> - Updated the commit msg to align with the changes.
>
> Changes for v4:
> - Fix some minor coding issues. No functional changes.
> - Updated Return value comments as suggested by Xu Yilun.
>
> drivers/firmware/xilinx/zynqmp.c | 33 ++++++++++++++++++++++++++++
> include/linux/firmware/xlnx-zynqmp.h | 10 +++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index ff5cabe70a2b..ca954e1119b5 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -941,6 +941,39 @@ int zynqmp_pm_fpga_get_status(u32 *value)
> }
> EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status);
>
> +/**
> + * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status.
> + * @value: Buffer to store FPGA configuration status.
> + *
> + * This function provides access to the pmufw to get the FPGA configuration
> + * status
> + *
> + * Return: 0 on success, a negative value on error
> + */
> +int zynqmp_pm_fpga_get_config_status(u32 *value)
> +{
> + u32 buf, phys_lower_addr, phys_upper_addr;
Why naming them phys_xxx?
> + u32 ret_payload[PAYLOAD_ARG_CNT];
> + int ret;
> +
> + if (!value)
> + return -EINVAL;
> +
> + phys_lower_addr = lower_32_bits((u64)&buf);
> + phys_upper_addr = upper_32_bits((u64)&buf);
> +
> + ret = zynqmp_pm_invoke_fn(PM_FPGA_READ,
> + XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET,
> + phys_lower_addr, phys_upper_addr,
> + XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG,
> + ret_payload);
> +
> + *value = ret_payload[1];
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status);
> +
> /**
> * zynqmp_pm_pinctrl_request - Request Pin from firmware
> * @pin: Pin number to request
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 76d2b3ebad84..29e8964f4297 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -70,6 +70,10 @@
> #define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U
> #define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0)
>
> +/* FPGA Status Reg */
> +#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U
> +#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG 0U
> +
> /*
> * Node IDs for the Error Events.
> */
> @@ -117,6 +121,7 @@ enum pm_api_id {
> PM_CLOCK_GETRATE = 42,
> PM_CLOCK_SETPARENT = 43,
> PM_CLOCK_GETPARENT = 44,
> + PM_FPGA_READ = 46,
> PM_SECURE_AES = 47,
> PM_FEATURE_CHECK = 63,
> };
> @@ -505,6 +510,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
> 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_fpga_get_config_status(u32 *value);
Is it better put it along with zynqmp_pm_fpga_get_status()?
Thanks,
Yilun
> #else
> static inline int zynqmp_pm_get_api_version(u32 *version)
> {
> @@ -790,6 +796,10 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
> return -ENODEV;
> }
>
> +static inline int zynqmp_pm_fpga_get_config_status(u32 *value)
> +{
> + return -ENODEV;
> +}
> #endif
>
> #endif /* __FIRMWARE_ZYNQMP_H__ */
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/2] fpga: zynqmp-fpga: Adds status interface
2022-12-23 11:58 ` Nava kishore Manne
@ 2022-12-26 6:08 ` Xu Yilun
-1 siblings, 0 replies; 10+ messages in thread
From: Xu Yilun @ 2022-12-26 6:08 UTC (permalink / raw)
To: Nava kishore Manne
Cc: michal.simek, mdf, hao.wu, trix, ronak.jain, gregkh, tanmay.shah,
ben.levinsky, harsha.harsha, rajan.vaja, mathieu.poirier,
linux-arm-kernel, linux-kernel, linux-fpga
On 2022-12-23 at 17:28:50 +0530, Nava kishore Manne wrote:
> Adds status interface for zynqmp-fpga, It's a read only interface
> which allows the user to get the Programmable Logic(PL) configuration
> status.
>
> Usage:
> To read the Programmable Logic(PL) configuration status
> cat /sys/class/fpga_manager/<fpga>/device/status
>
> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
> ---
> Changes for v2:
> - Updated status messages handling logic as suggested by Xu Yilun.
>
> Changes for v3:
> - Updated status interface handling logic (Restrict the status
> interface to the device-specific instead of handled by the core)
> as suggested by Xu Yilun.
>
> Changes for v4:
> - Limit the error strings to one word for each as suggested by
> Xu Yilun
Please fix the comments from Greg,
https://lore.kernel.org/all/Y0fYjyXrMEo6M76k@kroah.com/
>
> drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 87 insertions(+)
>
> diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
> index c60f20949c47..81d3e18527ee 100644
> --- a/drivers/fpga/zynqmp-fpga.c
> +++ b/drivers/fpga/zynqmp-fpga.c
> @@ -15,6 +15,37 @@
> /* Constant Definitions */
> #define IXR_FPGA_DONE_MASK BIT(3)
>
> +/* Error Register */
> +#define IXR_FPGA_ERR_CRC_ERR BIT(0)
> +#define IXR_FPGA_ERR_SECURITY_ERR BIT(16)
> +
> +/* Signal Status Register */
> +#define IXR_FPGA_END_OF_STARTUP BIT(4)
> +#define IXR_FPGA_GST_CFG_B BIT(5)
> +#define IXR_FPGA_INIT_B_INTERNAL BIT(11)
> +#define IXR_FPGA_DONE_INTERNAL_SIGNAL BIT(13)
> +
> +/* FPGA error status. */
> +enum {
> + ZYNQMP_FPGA_STATUS_CRC_ERR,
> + ZYNQMP_FPGA_STATUS_SECURITY_ERR,
> + ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR,
> + ZYNQMP_FPGA_STATUS_SIGNAL_ERR,
> + ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR,
> + ZYNQMP_FPGA_STATUS_EOS_ERR,
> + ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR,
> +};
> +
> +static const char * const zynqmp_fpga_error_statuses[] = {
> + [ZYNQMP_FPGA_STATUS_CRC_ERR] = "CRC-Error",
> + [ZYNQMP_FPGA_STATUS_SECURITY_ERR] = "Security-Error",
> + [ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR] = "Initialization-Error",
> + [ZYNQMP_FPGA_STATUS_SIGNAL_ERR] = "Internal-Signal-Error",
> + [ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR] = "I/Os-High-Z-state",
> + [ZYNQMP_FPGA_STATUS_EOS_ERR] = "Sequence-Error",
> + [ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR] = "Firmware-Error",
> +};
> +
> /**
> * struct zynqmp_fpga_priv - Private data structure
> * @dev: Device data structure
> @@ -77,6 +108,54 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
> return FPGA_MGR_STATE_UNKNOWN;
> }
>
> +static ssize_t status_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + unsigned long status = 0;
> + ssize_t len = 0;
> + u32 reg_val;
> + int ret;
> + u8 i;
> +
> + ret = zynqmp_pm_fpga_get_config_status(®_val);
> + if (!ret) {
> + if (reg_val & IXR_FPGA_ERR_CRC_ERR)
> + status |= ZYNQMP_FPGA_STATUS_CRC_ERR;
> + if (reg_val & IXR_FPGA_ERR_SECURITY_ERR)
> + status |= ZYNQMP_FPGA_STATUS_SECURITY_ERR;
> + if (!(reg_val & IXR_FPGA_INIT_B_INTERNAL))
> + status |= ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR;
> + if (!(reg_val & IXR_FPGA_DONE_INTERNAL_SIGNAL))
> + status |= ZYNQMP_FPGA_STATUS_SIGNAL_ERR;
> + if (!(reg_val & IXR_FPGA_GST_CFG_B))
> + status |= ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR;
> + if (!(reg_val & IXR_FPGA_END_OF_STARTUP))
> + status |= ZYNQMP_FPGA_STATUS_EOS_ERR;
> + } else {
> + status = ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR;
> + }
> +
> + for_each_set_bit(i, &status, ARRAY_SIZE(zynqmp_fpga_error_statuses))
> + len += sysfs_emit_at(buf, len, "%s ",
> + zynqmp_fpga_error_statuses[i]);
> +
> + if (len)
> + buf[len - 1] = '\n';
> +
> + return len;
> +}
> +
> +static DEVICE_ATTR_RO(status);
> +
> +static struct attribute *zynqmp_fpga_device_attrs[] = {
> + &dev_attr_status.attr,
> + NULL,
> +};
> +
> +static const struct attribute_group zynqmp_fpga_attr_group = {
> + .attrs = zynqmp_fpga_device_attrs,
> +};
> +
> static const struct fpga_manager_ops zynqmp_fpga_ops = {
> .state = zynqmp_fpga_ops_state,
> .write_init = zynqmp_fpga_ops_write_init,
> @@ -88,6 +167,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct zynqmp_fpga_priv *priv;
> struct fpga_manager *mgr;
> + int ret;
>
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -95,6 +175,13 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
>
> priv->dev = dev;
>
> + /* Add the device attributes */
> + ret = sysfs_create_group(&dev->kobj, &zynqmp_fpga_attr_group);
> + if (ret) {
> + dev_err(dev, "Error creating sysfs files\n");
> + return ret;
> + }
> +
> mgr = devm_fpga_mgr_register(dev, "Xilinx ZynqMP FPGA Manager",
> &zynqmp_fpga_ops, priv);
> return PTR_ERR_OR_ZERO(mgr);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/2] fpga: zynqmp-fpga: Adds status interface
@ 2022-12-26 6:08 ` Xu Yilun
0 siblings, 0 replies; 10+ messages in thread
From: Xu Yilun @ 2022-12-26 6:08 UTC (permalink / raw)
To: Nava kishore Manne
Cc: michal.simek, mdf, hao.wu, trix, ronak.jain, gregkh, tanmay.shah,
ben.levinsky, harsha.harsha, rajan.vaja, mathieu.poirier,
linux-arm-kernel, linux-kernel, linux-fpga
On 2022-12-23 at 17:28:50 +0530, Nava kishore Manne wrote:
> Adds status interface for zynqmp-fpga, It's a read only interface
> which allows the user to get the Programmable Logic(PL) configuration
> status.
>
> Usage:
> To read the Programmable Logic(PL) configuration status
> cat /sys/class/fpga_manager/<fpga>/device/status
>
> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com>
> ---
> Changes for v2:
> - Updated status messages handling logic as suggested by Xu Yilun.
>
> Changes for v3:
> - Updated status interface handling logic (Restrict the status
> interface to the device-specific instead of handled by the core)
> as suggested by Xu Yilun.
>
> Changes for v4:
> - Limit the error strings to one word for each as suggested by
> Xu Yilun
Please fix the comments from Greg,
https://lore.kernel.org/all/Y0fYjyXrMEo6M76k@kroah.com/
>
> drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 87 insertions(+)
>
> diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
> index c60f20949c47..81d3e18527ee 100644
> --- a/drivers/fpga/zynqmp-fpga.c
> +++ b/drivers/fpga/zynqmp-fpga.c
> @@ -15,6 +15,37 @@
> /* Constant Definitions */
> #define IXR_FPGA_DONE_MASK BIT(3)
>
> +/* Error Register */
> +#define IXR_FPGA_ERR_CRC_ERR BIT(0)
> +#define IXR_FPGA_ERR_SECURITY_ERR BIT(16)
> +
> +/* Signal Status Register */
> +#define IXR_FPGA_END_OF_STARTUP BIT(4)
> +#define IXR_FPGA_GST_CFG_B BIT(5)
> +#define IXR_FPGA_INIT_B_INTERNAL BIT(11)
> +#define IXR_FPGA_DONE_INTERNAL_SIGNAL BIT(13)
> +
> +/* FPGA error status. */
> +enum {
> + ZYNQMP_FPGA_STATUS_CRC_ERR,
> + ZYNQMP_FPGA_STATUS_SECURITY_ERR,
> + ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR,
> + ZYNQMP_FPGA_STATUS_SIGNAL_ERR,
> + ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR,
> + ZYNQMP_FPGA_STATUS_EOS_ERR,
> + ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR,
> +};
> +
> +static const char * const zynqmp_fpga_error_statuses[] = {
> + [ZYNQMP_FPGA_STATUS_CRC_ERR] = "CRC-Error",
> + [ZYNQMP_FPGA_STATUS_SECURITY_ERR] = "Security-Error",
> + [ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR] = "Initialization-Error",
> + [ZYNQMP_FPGA_STATUS_SIGNAL_ERR] = "Internal-Signal-Error",
> + [ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR] = "I/Os-High-Z-state",
> + [ZYNQMP_FPGA_STATUS_EOS_ERR] = "Sequence-Error",
> + [ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR] = "Firmware-Error",
> +};
> +
> /**
> * struct zynqmp_fpga_priv - Private data structure
> * @dev: Device data structure
> @@ -77,6 +108,54 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
> return FPGA_MGR_STATE_UNKNOWN;
> }
>
> +static ssize_t status_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + unsigned long status = 0;
> + ssize_t len = 0;
> + u32 reg_val;
> + int ret;
> + u8 i;
> +
> + ret = zynqmp_pm_fpga_get_config_status(®_val);
> + if (!ret) {
> + if (reg_val & IXR_FPGA_ERR_CRC_ERR)
> + status |= ZYNQMP_FPGA_STATUS_CRC_ERR;
> + if (reg_val & IXR_FPGA_ERR_SECURITY_ERR)
> + status |= ZYNQMP_FPGA_STATUS_SECURITY_ERR;
> + if (!(reg_val & IXR_FPGA_INIT_B_INTERNAL))
> + status |= ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR;
> + if (!(reg_val & IXR_FPGA_DONE_INTERNAL_SIGNAL))
> + status |= ZYNQMP_FPGA_STATUS_SIGNAL_ERR;
> + if (!(reg_val & IXR_FPGA_GST_CFG_B))
> + status |= ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR;
> + if (!(reg_val & IXR_FPGA_END_OF_STARTUP))
> + status |= ZYNQMP_FPGA_STATUS_EOS_ERR;
> + } else {
> + status = ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR;
> + }
> +
> + for_each_set_bit(i, &status, ARRAY_SIZE(zynqmp_fpga_error_statuses))
> + len += sysfs_emit_at(buf, len, "%s ",
> + zynqmp_fpga_error_statuses[i]);
> +
> + if (len)
> + buf[len - 1] = '\n';
> +
> + return len;
> +}
> +
> +static DEVICE_ATTR_RO(status);
> +
> +static struct attribute *zynqmp_fpga_device_attrs[] = {
> + &dev_attr_status.attr,
> + NULL,
> +};
> +
> +static const struct attribute_group zynqmp_fpga_attr_group = {
> + .attrs = zynqmp_fpga_device_attrs,
> +};
> +
> static const struct fpga_manager_ops zynqmp_fpga_ops = {
> .state = zynqmp_fpga_ops_state,
> .write_init = zynqmp_fpga_ops_write_init,
> @@ -88,6 +167,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct zynqmp_fpga_priv *priv;
> struct fpga_manager *mgr;
> + int ret;
>
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> @@ -95,6 +175,13 @@ static int zynqmp_fpga_probe(struct platform_device *pdev)
>
> priv->dev = dev;
>
> + /* Add the device attributes */
> + ret = sysfs_create_group(&dev->kobj, &zynqmp_fpga_attr_group);
> + if (ret) {
> + dev_err(dev, "Error creating sysfs files\n");
> + return ret;
> + }
> +
> mgr = devm_fpga_mgr_register(dev, "Xilinx ZynqMP FPGA Manager",
> &zynqmp_fpga_ops, priv);
> return PTR_ERR_OR_ZERO(mgr);
> --
> 2.25.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-12-26 6:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 11:58 [PATCH v4 0/2]Adds status interface for zynqmp-fpga Nava kishore Manne
2022-12-23 11:58 ` Nava kishore Manne
2022-12-23 11:58 ` [PATCH v4 1/2] firmware: xilinx: Add pm api function for PL config reg readback Nava kishore Manne
2022-12-23 11:58 ` Nava kishore Manne
2022-12-26 5:56 ` Xu Yilun
2022-12-26 5:56 ` Xu Yilun
2022-12-23 11:58 ` [PATCH v4 2/2] fpga: zynqmp-fpga: Adds status interface Nava kishore Manne
2022-12-23 11:58 ` Nava kishore Manne
2022-12-26 6:08 ` Xu Yilun
2022-12-26 6:08 ` Xu Yilun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.