mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amit Sunil Dhamne <amit.sunil.dhamne@xilinx.com>
To: ard.biesheuvel@linaro.org, mingo@kernel.org,
	gregkh@linuxfoundation.org, matt@codeblueprint.co.uk,
	sudeep.holla@arm.com, hkallweit1@gmail.com,
	keescook@chromium.org, dmitry.torokhov@gmail.com,
	michal.simek@xilinx.com, rajanv@xilinx.com,
	tejas.patel@xilinx.com, jollys@xilinx.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, rajan.vaja@xilinx.com,
	jolly.shah@xilinx.com,
	Amit Sunil Dhamne <amit.sunil.dhamne@xilinx.com>
Subject: [PATCH 2/3] firmware: xilinx: Add support for GET_LAST_RESET_REASON IOCTL
Date: Wed,  9 Sep 2020 17:20:03 -0700	[thread overview]
Message-ID: <1599697204-32103-3-git-send-email-amit.sunil.dhamne@xilinx.com> (raw)
In-Reply-To: <1599697204-32103-1-git-send-email-amit.sunil.dhamne@xilinx.com>

From: Tejas Patel <tejas.patel@xilinx.com>

Add support to get last reason using IOCTL API. Also validate IOCTL
ID for Versal or ZynqMP platforms before calling
zynqmp_pm_invoke_fn().

Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
Signed-off-by: Amit Sunil Dhamne <amit.sunil.dhamne@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 20 ++++++++++++++++++++
 include/linux/firmware/xlnx-zynqmp.h |  7 +++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 8fe0912..c5db34f 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -533,6 +533,7 @@ static inline int versal_is_valid_ioctl(u32 ioctl_id)
        case IOCTL_WRITE_PGGS:
        case IOCTL_READ_PGGS:
        case IOCTL_SET_BOOT_HEALTH_STATUS:
+       case IOCTL_GET_LAST_RESET_REASON:
                return 1;
        default:
                return 0;
@@ -772,6 +773,25 @@ int zynqmp_pm_set_boot_health_status(u32 value)
 }

 /**
+ * zynqmp_pm_get_last_reset_reason() - PM API for getting last reset reason
+ *
+ * @reset_reason:      last reset reason
+ *
+ * This function returns last reset reason
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_get_last_reset_reason(u32 *reset_reason)
+{
+       if (!reset_reason)
+               return -EINVAL;
+
+       return zynqmp_pm_ioctl(0, IOCTL_GET_LAST_RESET_REASON, 0, 0,
+                              reset_reason);
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_get_last_reset_reason);
+
+/**
  * zynqmp_pm_reset_assert - Request setting of reset (1 - assert, 0 - release)
  * @reset:             Reset to be configured
  * @assert_flag:       Flag stating should reset be asserted (1) or
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 5968df8..90c8664 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -116,6 +116,8 @@ enum pm_ioctl_id {
        IOCTL_READ_PGGS = 15,
        /* Set healthy bit value */
        IOCTL_SET_BOOT_HEALTH_STATUS = 17,
+       /* IOCTL to get last reset reason */
+       IOCTL_GET_LAST_RESET_REASON = 23,
 };

 enum pm_query_id {
@@ -357,6 +359,7 @@ int zynqmp_pm_write_pggs(u32 index, u32 value);
 int zynqmp_pm_read_pggs(u32 index, u32 *value);
 int zynqmp_pm_system_shutdown(const u32 type, const u32 subtype);
 int zynqmp_pm_set_boot_health_status(u32 value);
+int zynqmp_pm_get_last_reset_reason(u32 *reset_reason);
 #else
 static inline struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
 {
@@ -507,6 +510,10 @@ static inline int zynqmp_pm_set_boot_health_status(u32 value)
 {
        return -ENODEV;
 }
+static inline int zynqmp_pm_get_last_reset_reason(u32 *reset_reason)
+{
+       return -ENODEV;
+}
 #endif

 #endif /* __FIRMWARE_ZYNQMP_H__ */
--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

  parent reply	other threads:[~2020-09-10  2:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  0:20 [PATCH 0/3] firmware: xilinx: Add support to get last reset reason Amit Sunil Dhamne
2020-09-10  0:20 ` [PATCH 1/3] firmware: xilinx: Add validation check for IOCTL Amit Sunil Dhamne
2020-09-16 11:33   ` Greg KH
2020-09-16 16:53     ` Amit Sunil Dhamne
2020-09-17  6:45   ` Punit Agrawal
2020-09-10  0:20 ` Amit Sunil Dhamne [this message]
2020-09-10  0:20 ` [PATCH 3/3] firmware: xilinx: Add sysfs to get last reset reason Amit Sunil Dhamne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1599697204-32103-3-git-send-email-amit.sunil.dhamne@xilinx.com \
    --to=amit.sunil.dhamne@xilinx.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=jolly.shah@xilinx.com \
    --cc=jollys@xilinx.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=michal.simek@xilinx.com \
    --cc=mingo@kernel.org \
    --cc=rajan.vaja@xilinx.com \
    --cc=rajanv@xilinx.com \
    --cc=sudeep.holla@arm.com \
    --cc=tejas.patel@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®