Skip to content

Commit a2cc220

Browse files
rajanv-xilinxgregkh
authored andcommitted
firmware: xilinx: Add sysfs and API to set boot health status
Add sysfs interface to set boot health status from user space. Add API used by this interface to communicate with firmware. If PMUFW is compiled with CHECK_HEALTHY_BOOT, it will check the healthy bit on FPD WDT expiration. If healthy bit is set by a user application running in Linux, PMUFW will do APU only restart. If healthy bit is not set during FPD WDT expiration, PMUFW will do system restart. Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Tejas Patel <tejas.patel@xilinx.com> Signed-off-by: Jolly Shah <jolly.shah@xilinx.com> Link: https://lore.kernel.org/r/1587761887-4279-26-git-send-email-jolly.shah@xilinx.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b3ae24c commit a2cc220

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

‎Documentation/ABI/stable/sysfs-driver-firmware-zynqmp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,24 @@ Description:
8080
# echo "subsystem" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
8181

8282
Users: Xilinx
83+
84+
What: /sys/devices/platform/firmware\:zynqmp-firmware/health_status
85+
Date: March 2020
86+
KernelVersion: 5.6
87+
Contact: "Jolly Shah" <jollys@xilinx.com>
88+
Description:
89+
This sysfs interface allows to set the health status. If PMUFW
90+
is compiled with CHECK_HEALTHY_BOOT, it will check the healthy
91+
bit on FPD WDT expiration. If healthy bit is set by a user
92+
application running in Linux, PMUFW will do APU only restart. If
93+
healthy bit is not set during FPD WDT expiration, PMUFW will do
94+
system restart.
95+
96+
Usage:
97+
Set healthy bit
98+
# echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
99+
100+
Unset healthy bit
101+
# echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
102+
103+
Users: Xilinx

‎drivers/firmware/xilinx/zynqmp.c‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,21 @@ int zynqmp_pm_read_pggs(u32 index, u32 *value)
683683
}
684684
EXPORT_SYMBOL_GPL(zynqmp_pm_read_pggs);
685685

686+
/**
687+
* zynqmp_pm_set_boot_health_status() - PM API for setting healthy boot status
688+
* @value Status value to be written
689+
*
690+
* This function sets healthy bit value to indicate boot health status
691+
* to firmware.
692+
*
693+
* @return Returns status, either success or error+reason
694+
*/
695+
int zynqmp_pm_set_boot_health_status(u32 value)
696+
{
697+
return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_BOOT_HEALTH_STATUS,
698+
value, 0, NULL);
699+
}
700+
686701
/**
687702
* zynqmp_pm_reset_assert - Request setting of reset (1 - assert, 0 - release)
688703
* @reset: Reset to be configured
@@ -984,6 +999,29 @@ static ssize_t shutdown_scope_store(struct device *device,
984999

9851000
static DEVICE_ATTR_RW(shutdown_scope);
9861001

1002+
static ssize_t health_status_store(struct device *device,
1003+
struct device_attribute *attr,
1004+
const char *buf, size_t count)
1005+
{
1006+
int ret;
1007+
unsigned int value;
1008+
1009+
ret = kstrtouint(buf, 10, &value);
1010+
if (ret)
1011+
return ret;
1012+
1013+
ret = zynqmp_pm_set_boot_health_status(value);
1014+
if (ret) {
1015+
dev_err(device, "unable to set healthy bit value to %u\n",
1016+
value);
1017+
return ret;
1018+
}
1019+
1020+
return count;
1021+
}
1022+
1023+
static DEVICE_ATTR_WO(health_status);
1024+
9871025
static ssize_t ggs_show(struct device *device,
9881026
struct device_attribute *attr,
9891027
char *buf,
@@ -1143,6 +1181,7 @@ static struct attribute *zynqmp_firmware_attrs[] = {
11431181
&dev_attr_pggs2.attr,
11441182
&dev_attr_pggs3.attr,
11451183
&dev_attr_shutdown_scope.attr,
1184+
&dev_attr_health_status.attr,
11461185
NULL,
11471186
};
11481187

‎include/linux/firmware/xlnx-zynqmp.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ enum pm_ioctl_id {
114114
IOCTL_READ_GGS = 13,
115115
IOCTL_WRITE_PGGS = 14,
116116
IOCTL_READ_PGGS = 15,
117+
/* Set healthy bit value */
118+
IOCTL_SET_BOOT_HEALTH_STATUS = 17,
117119
};
118120

119121
enum pm_query_id {
@@ -354,6 +356,7 @@ int zynqmp_pm_read_ggs(u32 index, u32 *value);
354356
int zynqmp_pm_write_pggs(u32 index, u32 value);
355357
int zynqmp_pm_read_pggs(u32 index, u32 *value);
356358
int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype);
359+
int zynqmp_pm_set_boot_health_status(u32 value);
357360
#else
358361
static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
359362
{
@@ -500,6 +503,10 @@ static inline int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype)
500503
{
501504
return -ENODEV;
502505
}
506+
static inline int zynqmp_pm_set_boot_health_status(u32 value)
507+
{
508+
return -ENODEV;
509+
}
503510
#endif
504511

505512
#endif /* __FIRMWARE_ZYNQMP_H__ */

0 commit comments

Comments
 (0)