From patchwork Tue Nov 22 10:54:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Yadav X-Patchwork-Id: 628160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD42BC4332F for ; Wed, 23 Nov 2022 05:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235796AbiKWFbE (ORCPT ); Wed, 23 Nov 2022 00:31:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235800AbiKWFbC (ORCPT ); Wed, 23 Nov 2022 00:31:02 -0500 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79638ED713 for ; Tue, 22 Nov 2022 21:30:56 -0800 (PST) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20221123053054epoutp03de7854f6d057177e262d75277bef965c~qH7CGJIkS0249602496epoutp03U for ; Wed, 23 Nov 2022 05:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20221123053054epoutp03de7854f6d057177e262d75277bef965c~qH7CGJIkS0249602496epoutp03U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1669181454; bh=uNgkOuD3RPHcSBkSiq6pg/mVd4Fv7cnPoyYY63AMJPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRC1OQVwG8SXLa5jAG+w5IgGefdc/fMBXKMa+lWJJR0v5Ip2YBNBCGzPv1ISN5vcT IlUfI3IP67yx31JOOp6Ye2CEP6la9p80mXvyXo5NQMgLtk88SOUiagHOsGTowlRMdt ltvL8EESgLh34hwZKLgzT6B6s4B32skUDwxTzohA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20221123053054epcas5p314c5706d2a650b1ccb7e7046bde2854e~qH7BWnxEq2606226062epcas5p3Z; Wed, 23 Nov 2022 05:30:54 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4NH8qH2Nsvz4x9QL; Wed, 23 Nov 2022 05:30:51 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.FF.39477.B00BD736; Wed, 23 Nov 2022 14:30:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b~p4orKHLp42891928919epcas5p3H; Tue, 22 Nov 2022 10:50:22 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221122105022epsmtrp2b68721a6754af3ac3845ff1df5c78888~p4orIvhDV3232832328epsmtrp2S; Tue, 22 Nov 2022 10:50:22 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-f1-637db00bd847 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 09.72.14392.E69AC736; Tue, 22 Nov 2022 19:50:22 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221122105019epsmtip1b22090c23b59f16edbbbe6ac857a6127~p4ooOtWSA0765207652epsmtip1b; Tue, 22 Nov 2022 10:50:19 +0000 (GMT) From: Vivek Yadav To: rcsekar@samsung.com, krzysztof.kozlowski+dt@linaro.org, wg@grandegger.com, mkl@pengutronix.de, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pankaj.dubey@samsung.com, ravi.patel@samsung.com, alim.akhtar@samsung.com, linux-fsd@tesla.com, robh+dt@kernel.org Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, aswani.reddy@samsung.com, sriranjani.p@samsung.com, Vivek Yadav Subject: [PATCH v3 1/2] can: m_can: Move mram init to mcan device setup Date: Tue, 22 Nov 2022 16:24:54 +0530 Message-Id: <20221122105455.39294-2-vivek.2311@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221122105455.39294-1-vivek.2311@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VTe1BUVRzu3H3cC87GDVBOW9F6s4ydAXcRtoOBvQiuSg0zTDk2k8vOcocl 4O62d9dHSUJmDaiAiCnEY0UZZSFYlgVx5bkSqTuBA0Xho1iJYggQoSGVAdtlof77ft/5vvP9 zu+cQ/D8e4ViIo01MHpWlUEJffktV0JeDl1jyVLLztb6oZGKFiFyNDXjqKz/Cz6q7OkToLHe uzjKH3fx0I2WfAGyjg4JkPmfkzzkmtiJBu1lQnS6vwNDDVXFfNRrWofmnZMAVTX/jSPXTBuO Sm+0CtDh9h4c3ZqsF6BHZ67wUfWvlwSvr6NtNcMYbbIa6fsDtwBtNecK6dtDbUK66dxBumBR Rt/r+ElI59vMgF76vByn56zBiWs+SI/WMKoURi9hWLU2JY1NjaF2JCnfUkYqZPJQeRR6hZKw qkwmhopNSAyNS8twH5WS7FFlGN1UoorjqE1bo/Vao4GRaLScIYZidCkZughdGKfK5IxsahjL GLbIZbLwSLcwOV1TXGPBdTOB+xznO0E2qHoqD/gQkIyAjsfFgjzgS/iTlwEcKcrhe4tZACuu 12LeYh7AzgcVvFV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2wefVtWMXr8a5rL7vF5k1wA dxSXTUpqTmZZapG+XQJXxpSVG9gLPohUHFq+n7GBcZFgFyMnh4SAicTWk7uYuhi5OIQEdjNK /Pj8hhkiISUx5cxLFghbWGLlv+fsEEXNTBJ/d81jB0mwCWhJPO5cwAKSEBHYzSTxtnsuWBWz wCImiZdXesFGCQu4S/zd/wasg0VAVeJ850FWEJtXwFpi57mDjBAr5CVWbzgAVs8pYCNx4PoO sHohoJrH8xqYJjDyLWBkWMUomVpQnJueW2xYYJiXWq5XnJhbXJqXrpecn7uJERxDWpo7GLev +qB3iJGJg/EQowQHs5IIb71nTbIQb0piZVVqUX58UWlOavEhRmkOFiVx3gtdJ+OFBNITS1Kz U1MLUotgskwcnFINTKxbZLQfPVV4uFNlxe3ParfEpz3zy52RajM17Id3A1urcOB1n9tV0TPm 7Zi3SrV4yrYqEQM+jXNrmWMePY26Htoh/nBH+er1gj8qHNND55vMDJ7xsHbdyY+b/3zffeuh 3wS/Ob+zJv3ufPGw0cXdnn1yUf3i55dW/tl3Sv0n5+0FZ+N38p9/m8z74M7kFXmBOe6Sun+L CsO385Ub7W6LPBOS2/t3I9dh9xCepUdWOSeY7DdmrQ9oltt+JU/mTM66Axd0rGVLNXi/ymik TI2ZfzLxlc6V2xynf8dMezrjwR2nN2wzNZRmrnN7futwyLYYvk97L99b0LVx5mvWeBExZq7Q sMeNq7wiSxUWBmX9nbNRiaU4I9FQi7moOBEAm1k9ARADAAA= X-CMS-MailID: 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b References: <20221122105455.39294-1-vivek.2311@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org When we try to access the mcan message ram addresses, hclk is gated by any other drivers or disabled, because of that probe gets failed. Move the mram init functionality to mcan device setup called by mcan class register from mcan probe function, by that time clocks are enabled. Signed-off-by: Chandrasekar R Signed-off-by: Vivek Yadav --- drivers/net/can/m_can/m_can.c | 4 ++-- drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/m_can_platform.c | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index a776cab1a5a4..5956f0b4d5b1 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1516,9 +1516,9 @@ static int m_can_dev_setup(struct m_can_classdev *cdev) } if (cdev->ops->init) - cdev->ops->init(cdev); + err = cdev->ops->init(cdev); - return 0; + return err; } static void m_can_stop(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 401410022823..c6e77b93f4a2 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -93,6 +93,7 @@ struct m_can_classdev { int is_peripheral; struct mram_cfg mcfg[MRAM_CFG_NUM]; + bool mram_cfg_flag; }; struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv); diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c index b5a5bedb3116..1a65b0d256fb 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -67,11 +67,28 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset, return 0; } +static int plat_init(struct m_can_classdev *cdev) +{ + int ret = 0; + + if (!cdev->mram_cfg_flag) { + /* Initialize mcan message ram */ + ret = m_can_init_ram(cdev); + if (ret) + return ret; + + cdev->mram_cfg_flag = true; + } + + return 0; +} + static struct m_can_ops m_can_plat_ops = { .read_reg = iomap_read_reg, .write_reg = iomap_write_reg, .write_fifo = iomap_write_fifo, .read_fifo = iomap_read_fifo, + .init = plat_init, }; static int m_can_plat_probe(struct platform_device *pdev) @@ -140,10 +157,6 @@ static int m_can_plat_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mcan_class); - ret = m_can_init_ram(mcan_class); - if (ret) - goto probe_fail; - pm_runtime_enable(mcan_class->dev); ret = m_can_class_register(mcan_class); if (ret)