diff mbox series

[v3,4/5] pinctrl: freescale: add pad wakeup config

Message ID 20221025183244.615318-5-shenwei.wang@nxp.com (mailing list archive)
State New, archived
Headers show
Series add suspend/resume support for i.mx8x SoCs | expand

Commit Message

Shenwei Wang Oct. 25, 2022, 6:32 p.m. UTC
add the logic to configure the pad wakeup function via
the pin_config_set handler.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
 drivers/pinctrl/freescale/pinctrl-scu.c | 30 +++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Peng Fan Oct. 26, 2022, 8:21 a.m. UTC | #1
On Tue, Oct 25, 2022 at 01:32:43PM -0500, Shenwei Wang wrote:
>add the logic to configure the pad wakeup function via
>the pin_config_set handler.
>
>Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
>---
> drivers/pinctrl/freescale/pinctrl-scu.c | 30 +++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
>diff --git a/drivers/pinctrl/freescale/pinctrl-scu.c b/drivers/pinctrl/freescale/pinctrl-scu.c
>index 59b5f8a35111..0b172f7e7261 100644
>--- a/drivers/pinctrl/freescale/pinctrl-scu.c
>+++ b/drivers/pinctrl/freescale/pinctrl-scu.c
>@@ -15,6 +15,11 @@
> #include "../core.h"
> #include "pinctrl-imx.h"
> 
>+#define IMX_SC_PAD_FUNC_GET_WAKEUP	9
>+#define IMX_SC_PAD_FUNC_SET_WAKEUP	4
>+#define IMX_SC_IRQ_GROUP_WAKE           3   /* Wakeup interrupts */
>+#define IMX_SC_IRQ_PAD			2   /* Pad wakeup */
>+
> enum pad_func_e {
> 	IMX_SC_PAD_FUNC_SET = 15,
> 	IMX_SC_PAD_FUNC_GET = 16,
>@@ -36,10 +41,18 @@ struct imx_sc_msg_resp_pad_get {
> 	u32 val;
> } __packed;
> 
>+struct imx_sc_msg_gpio_set_pad_wakeup {
>+	struct imx_sc_rpc_msg hdr;
>+	u16 pad;
>+	u8 wakeup;
>+} __packed __aligned(4);
>+
> static struct imx_sc_ipc *pinctrl_ipc_handle;
> 
> int imx_pinctrl_sc_ipc_init(struct platform_device *pdev)
> {
>+	imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE,
>+					 IMX_SC_IRQ_PAD, true);
> 	return imx_scu_get_handle(&pinctrl_ipc_handle);
> }
> EXPORT_SYMBOL_GPL(imx_pinctrl_sc_ipc_init);
>@@ -81,6 +94,23 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
> 	unsigned int val;
> 	int ret;
> 
>+	if (num_configs == 1) {
>+		struct imx_sc_msg_gpio_set_pad_wakeup wmsg;
>+
>+		hdr = &wmsg.hdr;
>+		hdr->ver = IMX_SC_RPC_VERSION;
>+		hdr->svc = IMX_SC_RPC_SVC_PAD;
>+		hdr->func = IMX_SC_PAD_FUNC_SET_WAKEUP;
>+		hdr->size = 2;
>+		wmsg.pad = pin_id;
>+		wmsg.wakeup = *configs;
>+		ret = imx_scu_call_rpc(pinctrl_ipc_handle, &wmsg, true);
>+
>+		dev_dbg(ipctl->dev, "wakeup pin_id: %d type: %d\n",
>+				pin_id, *configs);

Format issue, and configs should be unsigned long type. Otherwise, looks good
to me.

Regards,
Peng.

>+		return ret;
>+	}
>+
> 	/*
> 	 * Set mux and conf together in one IPC call
> 	 */
>-- 
>2.34.1
>
diff mbox series

Patch

diff --git a/drivers/pinctrl/freescale/pinctrl-scu.c b/drivers/pinctrl/freescale/pinctrl-scu.c
index 59b5f8a35111..0b172f7e7261 100644
--- a/drivers/pinctrl/freescale/pinctrl-scu.c
+++ b/drivers/pinctrl/freescale/pinctrl-scu.c
@@ -15,6 +15,11 @@ 
 #include "../core.h"
 #include "pinctrl-imx.h"
 
+#define IMX_SC_PAD_FUNC_GET_WAKEUP	9
+#define IMX_SC_PAD_FUNC_SET_WAKEUP	4
+#define IMX_SC_IRQ_GROUP_WAKE           3   /* Wakeup interrupts */
+#define IMX_SC_IRQ_PAD			2   /* Pad wakeup */
+
 enum pad_func_e {
 	IMX_SC_PAD_FUNC_SET = 15,
 	IMX_SC_PAD_FUNC_GET = 16,
@@ -36,10 +41,18 @@  struct imx_sc_msg_resp_pad_get {
 	u32 val;
 } __packed;
 
+struct imx_sc_msg_gpio_set_pad_wakeup {
+	struct imx_sc_rpc_msg hdr;
+	u16 pad;
+	u8 wakeup;
+} __packed __aligned(4);
+
 static struct imx_sc_ipc *pinctrl_ipc_handle;
 
 int imx_pinctrl_sc_ipc_init(struct platform_device *pdev)
 {
+	imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE,
+					 IMX_SC_IRQ_PAD, true);
 	return imx_scu_get_handle(&pinctrl_ipc_handle);
 }
 EXPORT_SYMBOL_GPL(imx_pinctrl_sc_ipc_init);
@@ -81,6 +94,23 @@  int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
 	unsigned int val;
 	int ret;
 
+	if (num_configs == 1) {
+		struct imx_sc_msg_gpio_set_pad_wakeup wmsg;
+
+		hdr = &wmsg.hdr;
+		hdr->ver = IMX_SC_RPC_VERSION;
+		hdr->svc = IMX_SC_RPC_SVC_PAD;
+		hdr->func = IMX_SC_PAD_FUNC_SET_WAKEUP;
+		hdr->size = 2;
+		wmsg.pad = pin_id;
+		wmsg.wakeup = *configs;
+		ret = imx_scu_call_rpc(pinctrl_ipc_handle, &wmsg, true);
+
+		dev_dbg(ipctl->dev, "wakeup pin_id: %d type: %d\n",
+				pin_id, *configs);
+		return ret;
+	}
+
 	/*
 	 * Set mux and conf together in one IPC call
 	 */