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: 24710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2605907wrr; Tue, 22 Nov 2022 21:35:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf63/rRyFJNsV3tfbE8H1VJNHLE9qf03CsU8OSqBTIY+C0jc00qJ1xEX4WViPxk3CrzKGr7k X-Received: by 2002:a17:906:d1c7:b0:7ad:fd3e:7762 with SMTP id bs7-20020a170906d1c700b007adfd3e7762mr7887498ejb.717.1669181714938; Tue, 22 Nov 2022 21:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669181714; cv=none; d=google.com; s=arc-20160816; b=Be8LcJlqH0SzrVHjlFhJ2DPnJEqAH9fytA1j3rGNqodGYBNcfrDohkC03ZDS8vwDso i14mE757ft2zCSV7Kn7VLdAd0eDmeJM7RWYGgcq3i6+NYZrT0qY4R1nVs5dr0GZXdDn6 bVZcrk2okMgCaHp6MAvdaYQYqWbgVYsab9K52C0K79IPkaacNSuXDcO8b19aW4u2Hr1m HM0ITa9bASFr2bftKquX1S9cerroFCh7hM2bkxIJjzTh05JIgyLp+VTw/3mYckL2/lGI kKOiFzsuSd6+LoeYDI2GyqqgHrUW7nGlaI6XIP4WfZCvYQi/xaR1VfcLQQ9pCshz6/Ou hc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=uNgkOuD3RPHcSBkSiq6pg/mVd4Fv7cnPoyYY63AMJPU=; b=fuW9QeoGj5Co12XcVp8y+QdEhl4dDFfZB03nyy3PZ6IMu/HkOkXbqIwvGgoAahaFOK BnDqOYfDoJ1YsGJWiCmuIquXyaBxnX1sX5+/mOS1dtmc7duoz73hJj8OGlE2JltxZMow LPYTUSFPdPoz6JpTrIFr+GWdkuEzYwnZZeXdD1gYK0awX5v6ZPEeBkZdzIolnGen31Md 8qyR+1+sNriFLPTt5HskxP3UE5Kzfw9wZeT14DAbSgfTp6TU+vbwaFKDtDOpDJ2VThcU 2UCKfrmc+wTDIP/F02hpnVQ270pYbuIBpzUUXOYtaD2FQJ/Drmh1maHTyQQyF9qQXZF7 WUNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jRC1OQVw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz35-20020a1709077da300b007b5ce4a4360si8235222ejc.151.2022.11.22.21.34.51; Tue, 22 Nov 2022 21:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jRC1OQVw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235823AbiKWFbH (ORCPT + 99 others); Wed, 23 Nov 2022 00:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235741AbiKWFbC (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 8BB2CED714 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 20221123053054epoutp0397fa8e4ee93c68764afe492473adef93~qH7CGHno60030700307epoutp032 for ; Wed, 23 Nov 2022 05:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20221123053054epoutp0397fa8e4ee93c68764afe492473adef93~qH7CGHno60030700307epoutp032 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: H4sIAAAAAAAAA0VTe1BUVRzu3H3cC87GDVBOW9F6s4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wS/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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750263885673412901?= X-GMAIL-MSGID: =?utf-8?q?1750263885673412901?= 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)