From nobody Sat Nov 23 01:24:40 2024 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749DF13A878; Fri, 22 Nov 2024 14:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.30.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287183; cv=none; b=jEzXi85ksZEmvWN1on92LvkT0o89JIMl+lRriPbE35UsDrwuQc0xDbnTuQxd3hQgkFw3gcgv7ThKsgB2queWWRgM3cQKxX5dXXSn040GG2lc16JeoelP5WANdUblpE/UIUPpeISlw83JDpMWnZTn0qLBXhQfAXINnvhemVHhB3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287183; c=relaxed/simple; bh=IxCNHelaMrEjh5uqr6QwN2TyLcl0N2cfe8sWplCp9GQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQE6Dtq0yTVdn4sn0tZEhPE3W2SwDfpOCcIEhua7ZDzVLWdNFa2CcZ8cHMWMRFky4YWrqtEu2xOt/a0cdsUB05Uu4zgpa3WEQ+CnSwCd9bCksED5qiLibegUVmSv9OuFXjcbTXFGZtO4UpzrThD2IjnyJFKQB4b6/5tH0R1vqSc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com; spf=pass smtp.mailfrom=geanix.com; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b=WopVSqhx; arc=none smtp.client-ip=188.40.30.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geanix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="WopVSqhx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=s/g999F984FmZQoAKj5iV8ej5wGcgW8M4SRdlhH5yNU=; b=WopVSqhxTsRhzFVhdC0CNCVWc5 6JSrbu1hWuM7Y0p8urzEZDLeFAhcGFMtzetR/n85XIaumpvc1MMUyaEV2nK6NWaR/Lyuv1eYXWXcz ULPnXdPbqpc+DQKop6kJ+s1E7Cvr7sPubdmaRy5/zLxvKWeXQ9gDCNMg+ljawj20YJK7rDZsWs3Ki A0BfbMG7W6LtH+golBYyrbwNwmQwAyBbn0TcqiCBjN+VY8Ism5Q/BXFZ5KWVcmcKeKVlG+dMOw3FR kf95Edhek25HMqamJagrr4ru+3FGtAZF6m88Lmp3mDslyXkA6rpHpaaUYVUAu2OV+t0RV3Dqas8cu dvVu/3NA==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEV1W-000KID-9L; Fri, 22 Nov 2024 15:52:42 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy03.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tEV1W-000HFz-06; Fri, 22 Nov 2024 15:52:41 +0100 From: Sean Nyekjaer Date: Fri, 22 Nov 2024 15:52:22 +0100 Subject: [PATCH can-next v3 1/3] can: m_can: add deinit callback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-tcan-standby-v3-1-90bafaf5eccd@geanix.com> References: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> In-Reply-To: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27465/Fri Nov 22 10:41:26 2024) This is added in preparation for calling standby mode in the tcan4x5x driver or other users of m_can. For the tcan4x5x; If Vsup 12V, standby mode will save 7-8mA, when the interface is down. Signed-off-by: Sean Nyekjaer --- drivers/net/can/m_can/m_can.c | 7 +++++++ drivers/net/can/m_can/m_can.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 16e9e7d7527d9762d73a7ec47940c73c0976e05d..e31ce973892a96f47d26d06464e= 0f6e2245550fd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1756,6 +1756,13 @@ static void m_can_stop(struct net_device *dev) =20 /* set the state as STOPPED */ cdev->can.state =3D CAN_STATE_STOPPED; + + if (cdev->ops->deinit) { + ret =3D cdev->ops->deinit(cdev); + if (ret) + netdev_err(dev, "failed to deinitialize: %pe\n", + ERR_PTR(ret)); + } } =20 static int m_can_close(struct net_device *dev) diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 92b2bd8628e6b31370f4accbc2e28f3b2257a71d..6206535341a22a68d7c5570f619= e6c4d05e6fcf4 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -68,6 +68,7 @@ struct m_can_ops { int (*write_fifo)(struct m_can_classdev *cdev, int addr_offset, const void *val, size_t val_count); int (*init)(struct m_can_classdev *cdev); + int (*deinit)(struct m_can_classdev *cdev); }; =20 struct m_can_tx_op { --=20 2.46.2 From nobody Sat Nov 23 01:24:40 2024 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749A113959D; Fri, 22 Nov 2024 14:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.30.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287183; cv=none; b=o+US0VHeVkJxvE8StXOQPSTxPKz+NKYmmlgMzPm4YL3pXsHcHztaMoCSgVu2xM643iOyxdQ4Qube6hNiuQImS4874rvr9S90wqk5ijs60fL2AtaXuYtMV+9MS0o40ot/U9kAM7X8Ud2qxIT1OSQx+C79T+s7VrjsCrSJyI1qnnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287183; c=relaxed/simple; bh=ocC1FPl0f88WHZezE3pi1ctPnNrY3v/QbLLjCuAJfG4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CoPDiLJW0L0yCefcHd5K9ctvcvzroC1L8V2gJ+5dbL1ahNk0tNDi/HKXuQsrALRSRkwrCXxRH55ToBPe7eQF5Rbzvd6l4r5Iel1Q67APZ1WtqPnXGuz+z3hw6iGHhL/VnshmBFpNb479LJtj4ZWOY7/VNep2MN+Jat+pVN9GUdw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com; spf=pass smtp.mailfrom=geanix.com; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b=Bvgf4Gh5; arc=none smtp.client-ip=188.40.30.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geanix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="Bvgf4Gh5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=cNrGz3wwQWKgtKhUWoIpdHoNu/ZJ8RPPnQ7AxElL624=; b=Bvgf4Gh5ZRVRmnx3mEYF3cuLw4 Hj5bVTomEgsJa2zqHl0XKrCSHJT+jRCKs5C6Ct8LTeIv/uN0O8T4F/lWdXQMcP5IlPJchlgQ7Ng/D 4uP9hveaHVOHcsWl70F4KjI0xqWMr5WsRvQSUjDHKYm1Lqp7htcLwyqxNCs0W1Fexruui3Y0NtQbQ TpP86taAcmKZM/A72PDIovGvxAmnVH3bmK2NtujOscGlSMVmSWDFmx8MoHvsUhe21Q2U0J1QH8nov F+ahQ7Y4xYwLygxfIfbvJxkTs8tkmewVs1m8Lu1ojx/elmXH36shvmT09SK5zw/FBwgBaevv+PMbl 8JefKioA==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEV1W-000KIE-F6; Fri, 22 Nov 2024 15:52:42 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy03.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tEV1W-000HFz-0n; Fri, 22 Nov 2024 15:52:41 +0100 From: Sean Nyekjaer Date: Fri, 22 Nov 2024 15:52:23 +0100 Subject: [PATCH can-next v3 2/3] can: tcan4x5x: add deinit callback to set standby mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-tcan-standby-v3-2-90bafaf5eccd@geanix.com> References: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> In-Reply-To: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27465/Fri Nov 22 10:41:26 2024) At Vsup 12V, standby mode will save 7-8mA, when the interface is down. Signed-off-by: Sean Nyekjaer --- drivers/net/can/m_can/tcan4x5x-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/= tcan4x5x-core.c index 7213d9894c82d079bf92f1ec62d4eebb500cdfa4..13014be4ab37d24680d25806de6= 42a9c5c197020 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -279,6 +279,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) return ret; } =20 +static int tcan4x5x_deinit(struct m_can_classdev *cdev) +{ + struct tcan4x5x_priv *tcan4x5x =3D cdev_to_priv(cdev); + + return regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, + TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_STANDBY); +}; + static int tcan4x5x_disable_wake(struct m_can_classdev *cdev) { struct tcan4x5x_priv *tcan4x5x =3D cdev_to_priv(cdev); @@ -377,6 +385,7 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cd= ev, =20 static const struct m_can_ops tcan4x5x_ops =3D { .init =3D tcan4x5x_init, + .deinit =3D tcan4x5x_deinit, .read_reg =3D tcan4x5x_read_reg, .write_reg =3D tcan4x5x_write_reg, .write_fifo =3D tcan4x5x_write_fifo, --=20 2.46.2 From nobody Sat Nov 23 01:24:40 2024 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6036113B298; Fri, 22 Nov 2024 14:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.30.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287181; cv=none; b=K0EAzOQ6Mmg2VuZJXMhysyX/68RfXZEy0IWltVV8mNZJIGqOqbca7X4fCsFyR073exVtdYIsSNYuXSLgHm2fUOvX/F+REepNMG/BFWIgh+u6IpRjG3YwuqQeeIbGJwshf51FjpOS/XG1UcSyXPfulwGMLN3z0KymUeF1BP7645k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732287181; c=relaxed/simple; bh=aFi5zF3dMYrTZJtFjbLKmRl7u3piNrt0b5TZjGxN6qU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uk3tdqeDUwy8HhQ9XhRiCsD3oIxUhfNSghAoYhsoAfG9pp6eZ5vYcD24V7SSVurUN8k/HIJmvx7DRT/2dOLPUalByfTvEju96c34gWYFDpvJe8AcdsfOKOaawAVGh3ud1MnXTc6bEwU0rylMPcjgvhL112jcN1H9cJ/bs6av+Ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com; spf=pass smtp.mailfrom=geanix.com; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b=LzCLfG+G; arc=none smtp.client-ip=188.40.30.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=geanix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geanix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="LzCLfG+G" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=USN4L66UJITCUR+qW8nXpFIAvm6RhtpdO923SmyUnvI=; b=LzCLfG+GXRj0txFYscxL9W73iG V0C3xgDYiiqttu+iINNLYe4Z6IGS2SfooBSdm6aBO4RciEWAiUvriJQQywI4Uoq70+1JBJJ/6/qMn o+LH2/8PssXVn3odg6pa55GxNU1Bmy0QX1AHM68Di/KYHrHUOCVJ6H8j/t3oGV+kpek8Ni+4ltb5P 8nzD7R5A9gtbxuiDjhIphGU314bvpr1oIgdexFyv3+fAz2J3SFMrbHPft2f38kjW4vI6YySCxtJ1P AhzpGibl8gHVc7kwVZYRzcl7b7rOZCyg0h0n1lzvz7asguwxhQy2YWyNwmu3UtJnQmigXd2GFHS3/ pkehmVFg==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEV1W-000KIH-LG; Fri, 22 Nov 2024 15:52:42 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy03.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tEV1W-000HFz-1T; Fri, 22 Nov 2024 15:52:42 +0100 From: Sean Nyekjaer Date: Fri, 22 Nov 2024 15:52:24 +0100 Subject: [PATCH can-next v3 3/3] can: m_can: call deinit/init callback when going into suspend/resume Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-tcan-standby-v3-3-90bafaf5eccd@geanix.com> References: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> In-Reply-To: <20241122-tcan-standby-v3-0-90bafaf5eccd@geanix.com> To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27465/Fri Nov 22 10:41:26 2024) m_can user like the tcan4x5x device, can go into standby mode. Low power RX mode is enabled to allow wake on can. Signed-off-by: Sean Nyekjaer --- drivers/net/can/m_can/m_can.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index e31ce973892a96f47d26d06464e0f6e2245550fd..777dfb23c6fa2052e9544d0808c= 0c4980e9c8b0f 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2444,6 +2444,7 @@ int m_can_class_suspend(struct device *dev) { struct m_can_classdev *cdev =3D dev_get_drvdata(dev); struct net_device *ndev =3D cdev->net; + int ret =3D 0; =20 if (netif_running(ndev)) { netif_stop_queue(ndev); @@ -2456,6 +2457,9 @@ int m_can_class_suspend(struct device *dev) if (cdev->pm_wake_source) { hrtimer_cancel(&cdev->hrtimer); m_can_write(cdev, M_CAN_IE, IR_RF0N); + + if (cdev->ops->deinit) + ret =3D cdev->ops->deinit(cdev); } else { m_can_stop(ndev); } @@ -2467,7 +2471,7 @@ int m_can_class_suspend(struct device *dev) =20 cdev->can.state =3D CAN_STATE_SLEEPING; =20 - return 0; + return ret; } EXPORT_SYMBOL_GPL(m_can_class_suspend); =20 @@ -2475,14 +2479,13 @@ int m_can_class_resume(struct device *dev) { struct m_can_classdev *cdev =3D dev_get_drvdata(dev); struct net_device *ndev =3D cdev->net; + int ret =3D 0; =20 pinctrl_pm_select_default_state(dev); =20 cdev->can.state =3D CAN_STATE_ERROR_ACTIVE; =20 if (netif_running(ndev)) { - int ret; - ret =3D m_can_clk_start(cdev); if (ret) return ret; @@ -2495,6 +2498,10 @@ int m_can_class_resume(struct device *dev) * again. */ cdev->active_interrupts |=3D IR_RF0N | IR_TEFN; + + if (cdev->ops->init) + ret =3D cdev->ops->init(cdev); + m_can_write(cdev, M_CAN_IE, cdev->active_interrupts); } else { ret =3D m_can_start(ndev); @@ -2508,7 +2515,7 @@ int m_can_class_resume(struct device *dev) netif_start_queue(ndev); } =20 - return 0; + return ret; } EXPORT_SYMBOL_GPL(m_can_class_resume); =20 --=20 2.46.2