firmware: tegra: Add helper to check for supported MRQs
authorTimo Alho <talho@nvidia.com>
Mon, 22 Oct 2018 13:19:36 +0000 (16:19 +0300)
committerThierry Reding <treding@nvidia.com>
Thu, 8 Nov 2018 11:49:25 +0000 (12:49 +0100)
Add a helper function to check that firmware is supporting a given MRQ
command.

Signed-off-by: Timo Alho <talho@nvidia.com>
Acked-by: Sivaram Nair <sivaramn@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/firmware/tegra/bpmp.c
include/soc/tegra/bpmp.h

index a3d5b518c10e4a13deeba7c6e9309c13c33cdded..90c6089fed84e4577c77edf6ef68c499413c5c8d 100644 (file)
@@ -470,6 +470,31 @@ unlock:
 }
 EXPORT_SYMBOL_GPL(tegra_bpmp_free_mrq);
 
+bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq)
+{
+       struct mrq_query_abi_request req = { .mrq = cpu_to_le32(mrq) };
+       struct mrq_query_abi_response resp;
+       struct tegra_bpmp_message msg = {
+               .mrq = MRQ_QUERY_ABI,
+               .tx = {
+                       .data = &req,
+                       .size = sizeof(req),
+               },
+               .rx = {
+                       .data = &resp,
+                       .size = sizeof(resp),
+               },
+       };
+       int ret;
+
+       ret = tegra_bpmp_transfer(bpmp, &msg);
+       if (ret || msg.rx.ret)
+               return false;
+
+       return resp.status == 0;
+}
+EXPORT_SYMBOL_GPL(tegra_bpmp_mrq_is_supported);
+
 static void tegra_bpmp_mrq_handle_ping(unsigned int mrq,
                                       struct tegra_bpmp_channel *channel,
                                       void *data)
index e69e4c4d80ae91d053c32a2cf2c84fc3220a3968..b02f926a02166af960c25da152ca457c905d4451 100644 (file)
@@ -129,6 +129,7 @@ int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
                           tegra_bpmp_mrq_handler_t handler, void *data);
 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
                         void *data);
+bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq);
 #else
 static inline struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
 {
@@ -164,6 +165,12 @@ static inline void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp,
                                       unsigned int mrq, void *data)
 {
 }
+
+static inline bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp,
+                                             unsigned int mrq)
+{
+       return false;
+}
 #endif
 
 #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)