From nobody Sun Sep 22 01:39:39 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF070C433EF for ; Thu, 16 Jun 2022 11:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376721AbiFPLIt (ORCPT ); Thu, 16 Jun 2022 07:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376694AbiFPLIm (ORCPT ); Thu, 16 Jun 2022 07:08:42 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E375E154; Thu, 16 Jun 2022 04:08:42 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2A82A660174D; Thu, 16 Jun 2022 12:08:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655377720; bh=94gH2gUEYPX6/Noy/gMRuNjFYY6o39PnCyXJBIau2C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eygmmvWy1Vbyms9Do7ARLYP4hY6Tznk5iZvIhrwkcz2/4XEnK2WoSvB5ft4IE8bez YKIcumRX4GtNrOg27pQL1KbTsAMmwW0Mc1n1ypAgbhcVRP7cl3skjtxzbV4jfHL3pe phab5z2a6d24IDfGybinrBO5kZh5cghqvkIxiimpvCn0cQ8RTt/gRyf3JWFc6xRAWr MZfRn7uNP+iBtK4GGHGztrBmv8IAqv1JILTs9ZJgti/4zhH7HTUvQ5JfhVukIF4UYq CjQBnXvvvLPkOTTNvnDUA0wiCJ5o15FhrqSIggMBnt0UBmfvW8Tf/QOZIWTXjE2uEZ dURz+RCT8uItw== From: AngeloGioacchino Del Regno To: yong.wu@mediatek.com Cc: joro@8bytes.org, will@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, krzysztof.kozlowski@linaro.org, miles.chen@mediatek.com, AngeloGioacchino Del Regno Subject: [PATCH v4 2/5] iommu/mediatek: Lookup phandle to retrieve syscon to infracfg Date: Thu, 16 Jun 2022 13:08:27 +0200 Message-Id: <20220616110830.26037-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616110830.26037-1-angelogioacchino.delregno@collabora.com> References: <20220616110830.26037-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This driver will get support for more SoCs and the list of infracfg compatibles is expected to grow: in order to prevent getting this situation out of control and see a long list of compatible strings, add support to retrieve a handle to infracfg's regmap through a new "mediatek,infracfg" phandle. In order to keep retrocompatibility with older devicetrees, the old way is kept in place. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Miles Chen Reviewed-by: Yong Wu Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index bb9dd92c9898..90685946fcbe 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1140,22 +1140,32 @@ static int mtk_iommu_probe(struct platform_device *= pdev) data->protect_base =3D ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN); =20 if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) { - switch (data->plat_data->m4u_plat) { - case M4U_MT2712: - p =3D "mediatek,mt2712-infracfg"; - break; - case M4U_MT8173: - p =3D "mediatek,mt8173-infracfg"; - break; - default: - p =3D NULL; + infracfg =3D syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,inf= racfg"); + if (IS_ERR(infracfg)) { + /* + * Legacy devicetrees will not specify a phandle to + * mediatek,infracfg: in that case, we use the older + * way to retrieve a syscon to infra. + * + * This is for retrocompatibility purposes only, hence + * no more compatibles shall be added to this. + */ + switch (data->plat_data->m4u_plat) { + case M4U_MT2712: + p =3D "mediatek,mt2712-infracfg"; + break; + case M4U_MT8173: + p =3D "mediatek,mt8173-infracfg"; + break; + default: + p =3D NULL; + } + + infracfg =3D syscon_regmap_lookup_by_compatible(p); + if (IS_ERR(infracfg)) + return PTR_ERR(infracfg); } =20 - infracfg =3D syscon_regmap_lookup_by_compatible(p); - - if (IS_ERR(infracfg)) - return PTR_ERR(infracfg); - ret =3D regmap_read(infracfg, REG_INFRA_MISC, &val); if (ret) return ret; --=20 2.35.1