Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11424439imu; Mon, 31 Dec 2018 22:20:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN4T1yFXt1gZfEWRnWUWrYaQoIBlSSJ2vQjUcDNtZDRLbwrxva0+IlCB4fkzIhIkw4Vn/XG0 X-Received: by 2002:a63:4456:: with SMTP id t22mr9887455pgk.0.1546323619461; Mon, 31 Dec 2018 22:20:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546323619; cv=none; d=google.com; s=arc-20160816; b=q+fWtottGNe/BNn8fwvDmS+dqlcbHFVrELRPszfcCBxH1ROGFFq9lDvNFgywgl8QeD wZO8O24sXECttQluJblK9ZMQgRDWN+X4OWXRK15EzF9Wz8lHNGhdk1RFqvHotOwGHDl4 5NbQ4wx1id3JbUJyjMDSZHKj7H1edjmMkwsHyqmfFZBmjclu1/a+Z6YPLvq5oM8fG/5C wCFQOWWsxhiqCTV1/7bi6UrGhgUOVyTlFGOOUga/4yjWQH2wBdyHZNIcmdLwRvMdQcrZ fOAUOjSQld0M190j7/3MVCBEbdx27Wv77GYzZBMN5onOFA5GZgrbHeS1G6wPwLze0fek 1ZDA== 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=ROYJ/mKGO8WtqNGjINY57jN93Pg/HDsnGEd9TV0ClTY=; b=DT3TDxrP3ZV5uYw+sdS6tVjsS6nw2XQSzJKdlceUIXW7yb6aOt4iF+LSq+A8SPBf1v CbDDCgaLCqaLqd9t3ny8QQNwSDhxXxnrl9kJyd5GkBC2lgXbxPaqex7w+4TbFGq0RwW4 kdf50hYxYku+RMAQdrLhQExNIW0WAuEcrJs4sg0/qCFuCC279JD0vtVEGj5XsZyp/Yeu QyAGV1ai+bgCdobVucka+sFX3+sKYUCC/GNulI4U2CT/ouqQNkGf48u07nhRY3OOuK2Q U2HsxQL/5BlZHhTILVhTF5GHmFuXVlY1ck4SJr9Ee1NEXLx+D3P61Et86dNzAFV/BxHh u19A== 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 x10si26467413pgl.209.2018.12.31.22.19.49; Mon, 31 Dec 2018 22:20:19 -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 S1728167AbfAAD5A (ORCPT + 99 others); Mon, 31 Dec 2018 22:57:00 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:39305 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726686AbfAAD5A (ORCPT ); Mon, 31 Dec 2018 22:57:00 -0500 X-UUID: 1283bcc3b3c0432fbcb3f5e2d334cca7-20190101 X-UUID: 1283bcc3b3c0432fbcb3f5e2d334cca7-20190101 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1749971124; Tue, 01 Jan 2019 11:56:50 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 11:56:48 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 1 Jan 2019 11:56:48 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH v5 03/20] memory: mtk-smi: Use a general config_port interface Date: Tue, 1 Jan 2019 11:55:35 +0800 Message-ID: <1546314952-15990-4-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> References: <1546314952-15990-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 The config_port of mt2712 and mt8183 are the same. Use a general config_port interface instead. In addition, in mt2712, larb8 and larb9 are the bdpsys larbs which are not the normal larb, their register space are different from the normal one. thus, we can not call the general config_port. In mt8183, IPU0/1 and CCU connect with smi-common directly, they also are not the normal larb. Hence, we add a "larb_direct_to_common_mask" for these larbs which connect to smi-commmon directly. This is also a preparing patch for adding mt8183 SMI support. Signed-off-by: Yong Wu Reviewed-by: Matthias Brugger --- drivers/memory/mtk-smi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 8f2d152..9fd6b3d 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -53,6 +53,7 @@ struct mtk_smi_larb_gen { bool need_larbid; int port_in_larb[MTK_LARB_NR_MAX + 1]; void (*config_port)(struct device *); + unsigned int larb_direct_to_common_mask; }; struct mtk_smi { @@ -176,17 +177,13 @@ void mtk_smi_larb_put(struct device *larbdev) return -ENODEV; } -static void mtk_smi_larb_config_port_mt2712(struct device *dev) +static void mtk_smi_larb_config_port_gen2_general(struct device *dev) { struct mtk_smi_larb *larb = dev_get_drvdata(dev); u32 reg; int i; - /* - * larb 8/9 is the bdpsys larb, the iommu_en is enabled defaultly. - * Don't need to set it again. - */ - if (larb->larbid == 8 || larb->larbid == 9) + if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask) return; for_each_set_bit(i, (unsigned long *)larb->mmu, 32) { @@ -261,7 +258,8 @@ static void mtk_smi_larb_config_port_gen1(struct device *dev) static const struct mtk_smi_larb_gen mtk_smi_larb_mt2712 = { .need_larbid = true, - .config_port = mtk_smi_larb_config_port_mt2712, + .config_port = mtk_smi_larb_config_port_gen2_general, + .larb_direct_to_common_mask = BIT(8) | BIT(9), /* bdpsys */ }; static const struct of_device_id mtk_smi_larb_of_ids[] = { -- 1.9.1