Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11533260imu; Tue, 1 Jan 2019 01:15:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Jp0x7yxN/rob8b+KnrfpIp+fw0S0GcdR5RFHT4jfZKMpX+1rahiVY7ZeRU4sec7qtKhZt X-Received: by 2002:a63:165e:: with SMTP id 30mr10081541pgw.103.1546334150352; Tue, 01 Jan 2019 01:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546334150; cv=none; d=google.com; s=arc-20160816; b=xB19XHKlHbcXsC5ngCJUnuNGyd8g7q9vvRJyyKCLKWnysOWbw0x+3Q69KB+QIOLWSN E8aP9GwygUmLzmTq7IN5ljy5z164cu8eolibMFF3htkIe7fQ0mtDfG+u8PKREy4ghD9p VfYtGW27YAYFNe9CELNPr6q1oKtGDIqOcXxIFADDcXwXovQARhmiEc0tWL9iBSnEXmor opNBQxpbw54BU7Kut2Vb6E3oGZnpqYrYTuQnG13gO1m+i+wL/dtA131UZh8CtkORs8p1 3BIpR/9bNPKhJ1XLSEPh2DxTYkuWP5cLu04pCgGHUHbgpmxmHIdTGLykcwy3na079FhU mv4Q== 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=lSFxS0jqXYugIthctvs6wuqXBNZ/NWGNZOJ0SrNQmho=; b=i2wKEhLscBRvH4SupgA8Yhm5uvvMY4NeO+X6rvEdDadulkeTrDNL0QQ31SZ+fPFl5t 189J7IivBPXvbMTVJi92TyitjV3RfeYdM/TXBzX2+UmA8DHJ+8FcWZ2IWrao0atP5L5u iwmjFev42qMo32cu5/s5qOVH5a6jKHsmjfXUsgkGwnBwzTnpLojWjZfhDmBGce91uHRs 9F+w5JeehUQw6/nypaZq0/3EEgKHVsxHX2Sr8BeOHGnYTBV+kvzc94FgKNQ4kdB+DCTR 6B+M5r4aXoalFGypUuDOHO2e+hFqh0k4U6ZPslZC79CAvr6kzmYfJzQv93q/T8LuEjia 7xww== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d189si4660301pfa.70.2019.01.01.01.15.12; Tue, 01 Jan 2019 01:15:50 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728484AbfAAEwZ (ORCPT + 99 others); Mon, 31 Dec 2018 23:52:25 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:65431 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728425AbfAAEwX (ORCPT ); Mon, 31 Dec 2018 23:52:23 -0500 X-UUID: edfd3464949c4a3481c41c86c2fac3ec-20190101 X-UUID: edfd3464949c4a3481c41c86c2fac3ec-20190101 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1286082275; Tue, 01 Jan 2019 12:52:17 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 12:52:16 +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, 1 Jan 2019 12:52:15 +0800 From: Yong Wu To: Joerg Roedel , Greg Kroah-Hartman , Matthias Brugger , Rob Herring CC: Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH 05/13] memory: mtk-smi: Add device-link between smi-larb and smi-common Date: Tue, 1 Jan 2019 12:51:08 +0800 Message-ID: <1546318276-18993-6-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> References: <1546318276-18993-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. Since smi is built-in driver like IOMMU and never unbound, DL_FLAG_AUTOREMOVE_* is not needed. CC: Matthias Brugger Suggested-by: Tomasz Figa Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 9688341..30930e4 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -271,6 +271,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) @@ -310,6 +311,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); + 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; @@ -333,17 +340,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; } @@ -358,7 +357,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