Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp269670pxb; Sat, 10 Apr 2021 02:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybSo4GNV9gH5K1tjLzVlBI0rjzTj9ADBEvo0cMUB/9VTUMC3LcSBkfN1/OCxs7FhFIcRt/ X-Received: by 2002:a63:5807:: with SMTP id m7mr16701761pgb.73.1618046007107; Sat, 10 Apr 2021 02:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618046007; cv=none; d=google.com; s=arc-20160816; b=IkMGEt5aHwaq6FILHiz2wFrhxsM+RwmoukUglZ3dDJb18L+VB5ObqJ1do2PhUMO8U6 BiYUOE37iPxL8XqlR7FUyQNKEgXtIog1HRVNZTJSXF/YLS98uAsefF6kN0Bv3b6GsJhU EWvzgIi3E35iBH9ErgUQ4z39zhxpGnWVeP783/ZxaOMcicTIE9p4s9k5U2wLaCH9XQZ6 T54M4ZnBQ2f4hamhHb5qD7AwbtXvdUtrLRBrghA1y5d7AkvCNzQ/SrSFEOlxohKbZvo6 To631bkLXM8QiD9dsOqEjU1Y7fZi6bJxFCRp2kBPh80+sSkfjSyl6iWt8w7RnjoXz53D zTaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ZAtz0DIKgoecQ78bE3SZQ/9bkUbSdPXg0Tc/VZ83V0I=; b=bN34bP11BzCAg93Faaze3ABrNpueZP5IHGZ3lvOoYt56O0jL6KWCdVg+jAnHtXsDRa fRin8hWzm1zyE6LLty1I+uABsxuWHUm2XifNc5CdURkvvoDbuYmNgU0oNLZnjorLQA6G rhTiEMG87RkMK+eQ9x2pPJ63JZ1OoMAkQxJPXcpwsusx5E/NSgG8HATwVeI09RyHREg2 y28d21I/SkeWmmlTczSNyv2X8a6or4CAC4g2/B1PfrCw0+ldpjVQgc/xLqiAlT0BGYpV gRZTXFDS8bQecYmiADB5/qSsUNAy9KbCm2tYbSmajl2Rs2QlE1kLsWFaMpn+YK8JyHAZ w+pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id s6si5539946pgm.428.2021.04.10.02.13.14; Sat, 10 Apr 2021 02:13:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234454AbhDJJMt (ORCPT + 99 others); Sat, 10 Apr 2021 05:12:49 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:33696 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234436AbhDJJMt (ORCPT ); Sat, 10 Apr 2021 05:12:49 -0400 X-UUID: f7066cfd7d7f4d3c834fb3165c9e3c13-20210410 X-UUID: f7066cfd7d7f4d3c834fb3165c9e3c13-20210410 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1025467400; Sat, 10 Apr 2021 17:12:33 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 17:12:31 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 17:12:30 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring , Krzysztof Kozlowski CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , , , Subject: [PATCH v5 04/16] memory: mtk-smi: Add device-link between smi-larb and smi-common Date: Sat, 10 Apr 2021 17:11:16 +0800 Message-ID: <20210410091128.31823-5-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210410091128.31823-1-yong.wu@mediatek.com> References: <20210410091128.31823-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N 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 b396253fcf4b..c5fb51f73b34 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -319,6 +319,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) @@ -358,6 +359,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; @@ -370,6 +377,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; @@ -381,17 +391,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_resume_and_get(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; } @@ -406,7 +408,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; } -- 2.18.0