linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: aisheng.dong@nxp.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V5 4/5] soc: imx: sc: add pad svc support
Date: Tue, 21 Aug 2018 00:08:24 +0800	[thread overview]
Message-ID: <1534781305-4770-5-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1534781305-4770-1-git-send-email-aisheng.dong@nxp.com>

Add SCU PAD SVC support which provides pad get/set functions.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/soc/imx/sc/Makefile           |  1 +
 drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 82 +++++++++++++++++++++++++++++++++++
 include/soc/imx/sc/sci.h              |  1 +
 include/soc/imx/sc/svc/pad/api.h      | 60 +++++++++++++++++++++++++
 4 files changed, 144 insertions(+)
 create mode 100644 drivers/soc/imx/sc/svc/pad/rpc_clnt.c
 create mode 100644 include/soc/imx/sc/svc/pad/api.h

diff --git a/drivers/soc/imx/sc/Makefile b/drivers/soc/imx/sc/Makefile
index 6898815..3a709b2 100644
--- a/drivers/soc/imx/sc/Makefile
+++ b/drivers/soc/imx/sc/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-y += main/ipc.o
+obj-y += svc/pad/rpc_clnt.o
 obj-y += svc/pm/rpc_clnt.o
diff --git a/drivers/soc/imx/sc/svc/pad/rpc_clnt.c b/drivers/soc/imx/sc/svc/pad/rpc_clnt.c
new file mode 100644
index 0000000..f300aef
--- /dev/null
+++ b/drivers/soc/imx/sc/svc/pad/rpc_clnt.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ * Copyright 2017~2018 NXP
+ *
+ * File containing client-side RPC functions for the PAD service. These
+ * function are ported to clients that communicate to the SC.
+ *
+ */
+
+#include <soc/imx/sc/svc/pad/api.h>
+#include "../../main/rpc.h"
+
+/*
+ * This type is used to indicate RPC PAD function calls.
+ */
+enum pad_func_e {
+	PAD_FUNC_SET = 15,
+	PAD_FUNC_GET = 16,
+};
+
+struct imx_sc_msg_req_pad_set {
+	struct sc_rpc_msg hdr;
+	u32 val;
+	u16 pad;
+} __packed;
+
+struct imx_sc_msg_req_pad_get {
+	struct sc_rpc_msg hdr;
+	u16 pad;
+} __packed;
+
+struct imx_sc_msg_resp_pad_get {
+	struct sc_rpc_msg hdr;
+	u32 val;
+} __packed;
+
+sc_err_t sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, uint32_t val)
+{
+	struct imx_sc_msg_req_pad_set msg;
+	struct sc_rpc_msg *hdr = &msg.hdr;
+	int ret;
+
+	hdr->ver = SC_RPC_VERSION;
+	hdr->svc = (uint8_t)SC_RPC_SVC_PAD;
+	hdr->func = (uint8_t)PAD_FUNC_SET;
+	hdr->size = 3;
+
+	msg.val = val;
+	msg.pad = pad;
+
+	ret = sc_call_rpc(ipc, (void *)&msg, false);
+	if (ret)
+		return SC_ERR_FAIL;
+
+	return (sc_err_t)hdr->func;
+}
+
+sc_err_t sc_pad_get(sc_ipc_t ipc, sc_pad_t pad, uint32_t *val)
+{
+	struct imx_sc_msg_req_pad_get msg;
+	struct imx_sc_msg_resp_pad_get *resp;
+	struct sc_rpc_msg *hdr = &msg.hdr;
+	int ret;
+
+	hdr->ver = SC_RPC_VERSION;
+	hdr->svc = (uint8_t)SC_RPC_SVC_PAD;
+	hdr->func = (uint8_t)PAD_FUNC_GET;
+	hdr->size = 2;
+
+	msg.pad = pad;
+
+	ret = sc_call_rpc(ipc, (void *)&msg, false);
+	if (ret)
+		return SC_ERR_FAIL;
+
+	resp = (struct imx_sc_msg_resp_pad_get *)&msg;
+	if (val != NULL)
+		*val = resp->val;
+
+	return (sc_err_t)resp->hdr.func;
+}
diff --git a/include/soc/imx/sc/sci.h b/include/soc/imx/sc/sci.h
index b7248cf..2407890 100644
--- a/include/soc/imx/sc/sci.h
+++ b/include/soc/imx/sc/sci.h
@@ -13,6 +13,7 @@
 #include <soc/imx/sc/ipc.h>
 #include <soc/imx/sc/types.h>
 
+#include <soc/imx/sc/svc/pad/api.h>
 #include <soc/imx/sc/svc/pm/api.h>
 
 #endif /* _SC_SCI_H */
diff --git a/include/soc/imx/sc/svc/pad/api.h b/include/soc/imx/sc/svc/pad/api.h
new file mode 100644
index 0000000..d7d80b6
--- /dev/null
+++ b/include/soc/imx/sc/svc/pad/api.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ * Copyright 2017~2018 NXP
+ *
+ * Header file containing the public API for the System Controller (SC)
+ * Pad Control (PAD) function.
+ *
+ * PAD_SVC (SVC) Pad Service
+ *
+ * Module for the Pad Control (PAD) service.
+ *
+ */
+
+#ifndef _SC_PAD_API_H
+#define _SC_PAD_API_H
+
+#include <soc/imx/sc/ipc.h>
+#include <soc/imx/sc/types.h>
+
+/*
+ * This type is used to indicate a pad. Valid values are SoC specific.
+ *
+ * Refer to the SoC [Pad List](@ref PADS) for valid pad values.
+ */
+typedef uint16_t sc_pad_t;
+
+/*
+ * This function configures the settings for a pad. This setting is SoC
+ * specific.
+ *
+ * @param [in]	ipc	IPC handle
+ * @param [in]	pad	pad to configure
+ * @param [in]	val	value to set
+ *
+ * @return Returns an error code (SC_ERR_NONE = success).
+ *
+ * Return errors:
+ * - SC_PARM if arguments out of range or invalid,
+ * - SC_ERR_NOACCESS if caller's partition is not the pad owner
+ */
+sc_err_t sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, uint32_t val);
+
+/*
+ * This function gets the settings for a pad. This setting is SoC
+ * specific.
+ *
+ * @param [in]	ipc	IPC handle
+ * @param [in]	pad	pad to query
+ * @param [out]	val	pointer to return setting
+ *
+ * @return Returns an error code (SC_ERR_NONE = success).
+ *
+ * Return errors:
+ * - SC_PARM if arguments out of range or invalid,
+ * - SC_ERR_NOACCESS if caller's partition is not the pad owner
+ */
+sc_err_t sc_pad_get(sc_ipc_t ipc, sc_pad_t pad, uint32_t *val);
+
+#endif /* _SC_PAD_API_H */
-- 
2.7.4

  parent reply	other threads:[~2018-08-20 16:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20 16:08 [PATCH V5 0/5] soc: imx: add scu firmware api support Dong Aisheng
2018-08-20 16:08 ` [PATCH V5 1/5] dt-bindings: arm: fsl: add scu binding doc Dong Aisheng
2018-08-20 18:11   ` Rob Herring
2018-08-21  3:00     ` A.s. Dong
2018-08-21 11:51       ` A.s. Dong
2018-08-24  9:36       ` Jassi Brar
2018-08-24  9:51         ` A.s. Dong
2018-08-20 16:08 ` [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIs Dong Aisheng
2018-09-10  8:40   ` Sascha Hauer
2018-09-10  9:44     ` A.s. Dong
2018-09-10 12:11       ` Sascha Hauer
2018-09-11 10:38         ` A.s. Dong
2018-09-16 13:23           ` A.s. Dong
2018-09-18  6:22           ` Sascha Hauer
2018-09-18  7:54             ` A.s. Dong
2018-08-20 16:08 ` [PATCH V5 3/5] soc: imx: sc: add pm svc support Dong Aisheng
2018-08-20 16:08 ` Dong Aisheng [this message]
2018-08-20 16:08 ` [PATCH V5 5/5] soc: imx: sc: add misc " Dong Aisheng
2018-08-20 16:31 ` [PATCH V5 0/5] soc: imx: add scu firmware api support A.s. Dong
2018-08-24  7:36   ` A.s. Dong
2018-08-24  9:54     ` Jassi Brar
2018-08-24 11:02       ` A.s. Dong
2018-08-27  8:33     ` Sascha Hauer
2018-08-27  9:59       ` A.s. Dong
2018-08-27 10:21         ` A.s. Dong
2018-08-28  6:21           ` Sascha Hauer
2018-08-28  8:53             ` A.s. Dong
2018-08-29  6:53               ` Sascha Hauer
2018-08-29  8:35                 ` A.s. Dong
2018-09-03  8:57                   ` A.s. Dong
2018-09-03 11:44                     ` Sascha Hauer
2018-09-06  3:21                       ` A.s. Dong
2018-09-10  7:03                         ` Sascha Hauer
2018-09-10  7:53                           ` A.s. Dong
2018-08-28  6:15         ` Sascha Hauer
2018-08-28  9:02           ` A.s. Dong

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=1534781305-4770-5-git-send-email-aisheng.dong@nxp.com \
    --to=aisheng.dong@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).