Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1734504ybe; Tue, 3 Sep 2019 02:41:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdvr9qw23mvnvQsHXWFKA12KVx8pZNoVKCxuofHugoZDKJRp1/yIjj3jltyjj7ej9Dnkn7 X-Received: by 2002:a17:902:3281:: with SMTP id z1mr34051403plb.302.1567503693955; Tue, 03 Sep 2019 02:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567503693; cv=none; d=google.com; s=arc-20160816; b=mPEHTEAbO1x6zxuNZVKg4dMS+yD/0PdcQ3+DsUUZ4T6Xo34iKTuzXn0DJUrGrKrCM2 4G3w1ZnuRUrJ+a0BPIa9F5bU+l6Wroe3lbmYh6epWbtcOngkBGH0+srs0xRfFYoFMHxN Sdd3rnCJWZaKIzn6sh07tdIXRqVnZ2xaVd+ezOdWOYAt+l0aN3wKPCB1HmvELj0fN1pI gV+Mq4kqhsP48jeX3/fz+QFQ9YFSc6Ta9eUXGC+uorZnLMeqfW9/1293l9wTmUIOtBJp kD618u8pWWmpIs0amzWhHhNBdaUbv0C4IBV1oVHG4CDYZeRCx2AKQkHJGGRwqlD7jUgD uylQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ZdqVNU277z5ckpy3VN1mklmDS2MsyxLBty+TTC2tvSM=; b=Uqk+cxdCoOULLEILgrXl6x613kWJf1C58VS04XlhuWWAJr227c4ynE+XBjfNaOpMMS eeRFfuTyFGWADwhyfj3663M2Lwa+H2HFrYZ9q7HyVMhzA0FVaOmAt7FKPAoGGBtBazud WtkRLjrpWiyIqu5XOGOAoAMAxRON0A3WuziW/0z8FTH0b/9UOJKkQSQBBJOJoCA9nXOf C5Xe6oyUF160Ba9p3JGr9ndlgQOC2f3qbXceF4OejavvVQdNAFSWo9Q7UywXip30m+4n Amj4prS+FU7HmLhrs1a4DJhZDWNz0vs1HgfDHDuKBCgwRolu5rGS7v4PXGM/p2W3Ju8k K98w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si839148pjn.83.2019.09.03.02.41.18; Tue, 03 Sep 2019 02:41:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728837AbfICJi4 (ORCPT + 99 others); Tue, 3 Sep 2019 05:38:56 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:33219 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728573AbfICJiy (ORCPT ); Tue, 3 Sep 2019 05:38:54 -0400 X-UUID: 0bd7c60e03fa441e9d7741e6a44261b1-20190903 X-UUID: 0bd7c60e03fa441e9d7741e6a44261b1-20190903 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 21343390; Tue, 03 Sep 2019 17:38:48 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 3 Sep 2019 17:38:48 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 3 Sep 2019 17:38:47 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , Subject: [PATCH v3 04/14] memory: mtk-smi: Add device-link between smi-larb and smi-common Date: Tue, 3 Sep 2019 17:37:26 +0800 Message-ID: <1567503456-24725-5-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> References: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Normally, If the smi-larb HW need work, we should enable the smi-common HW power and clock firstly. This patch adds device-link between the smi-larb dev and the smi-common dev. then If pm_runtime_get_sync(smi-larb-dev), the pm_runtime_get_sync (smi-common-dev) will be called automatically. Also, Add DL_FLAG_STATELESS to avoid the smi-common clocks be gated when probe. CC: Matthias Brugger Suggested-by: Tomasz Figa Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 439d7d8..5dab56c 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -273,6 +273,7 @@ static int mtk_smi_larb_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *smi_node; struct platform_device *smi_pdev; + struct device_link *link; larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL); if (!larb) @@ -312,6 +313,12 @@ static int mtk_smi_larb_probe(struct platform_device *pdev) if (!platform_get_drvdata(smi_pdev)) return -EPROBE_DEFER; larb->smi_common_dev = &smi_pdev->dev; + link = device_link_add(dev, larb->smi_common_dev, + DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); + if (!link) { + dev_err(dev, "Unable to link smi-common dev\n"); + return -ENODEV; + } } else { dev_err(dev, "Failed to get the smi_common device\n"); return -EINVAL; @@ -324,6 +331,9 @@ static int mtk_smi_larb_probe(struct platform_device *pdev) static int mtk_smi_larb_remove(struct platform_device *pdev) { + struct mtk_smi_larb *larb = platform_get_drvdata(pdev); + + device_link_remove(&pdev->dev, larb->smi_common_dev); pm_runtime_disable(&pdev->dev); component_del(&pdev->dev, &mtk_smi_larb_component_ops); return 0; @@ -335,17 +345,9 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev) const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen; int ret; - /* Power on smi-common. */ - ret = pm_runtime_get_sync(larb->smi_common_dev); - if (ret < 0) { - dev_err(dev, "Failed to pm get for smi-common(%d).\n", ret); - return ret; - } - ret = mtk_smi_clk_enable(&larb->smi); if (ret < 0) { dev_err(dev, "Failed to enable clock(%d).\n", ret); - pm_runtime_put_sync(larb->smi_common_dev); return ret; } @@ -360,7 +362,6 @@ static int __maybe_unused mtk_smi_larb_suspend(struct device *dev) struct mtk_smi_larb *larb = dev_get_drvdata(dev); mtk_smi_clk_disable(&larb->smi); - pm_runtime_put_sync(larb->smi_common_dev); return 0; } -- 1.9.1