From mboxrd@z Thu Jan 1 00:00:00 1970 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 59332C433EF for ; Wed, 18 May 2022 10:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234956AbiERKFu (ORCPT ); Wed, 18 May 2022 06:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbiERKFS (ORCPT ); Wed, 18 May 2022 06:05:18 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF2B6FD31; Wed, 18 May 2022 03:05:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 34E7B1F44E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652868312; bh=A5k1VBFcKvGxrzqgH+3j6bGmcr4uqfHwo1Y08EGhiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxNE4pApZ8gh9Nj1TIILgEFkkMYNj8c5ZFBNhdR3LX1qK9xEJqpKrQlj6db7I6LE/ xqZGZOlzU3Usnq6zer2AUyTJ0/mNbdFSwaT3/3KxVzrx6Bgpr/4rtXQsawOtTctRwd TG/32fPPLILxUCMYM+SRCUhzpSO1O/+3Iaj1DHLkw6nJ4n5q3qe0gqGtDzTO8z9ZUB KTVgGh9tupltX8Vl0D3HlJZoTculsbCa0yxgSHoqPdBRlfdJsSOOgT9uxveF5vS/FD fHLEh9xGmPR2HWr2kJJQ3iF+IDYFSfyplWGf8nnHKtzK3f2sc8H3kUKcoTvUEkMII6 6rZry0GnZnZaw== 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, AngeloGioacchino Del Regno Subject: [PATCH v2 2/7] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg Date: Wed, 18 May 2022 12:04:58 +0200 Message-Id: <20220518100503.37279-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> References: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, but also a dev_warn() was added to advertise this change in hope that the user will see it and eventually update the devicetree if this is possible. Signed-off-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 71b2ace74cd6..d16b95e71ded 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1134,22 +1134,34 @@ static int mtk_iommu_probe(struct platform_device *pdev) data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN); if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) { - switch (data->plat_data->m4u_plat) { - case M4U_MT2712: - p = "mediatek,mt2712-infracfg"; - break; - case M4U_MT8173: - p = "mediatek,mt8173-infracfg"; - break; - default: - p = NULL; + infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg"); + if (IS_ERR(infracfg)) { + dev_info(dev, "Cannot find phandle to mediatek,infracfg:" + " Please update your devicetree.\n"); + /* + * 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 = "mediatek,mt2712-infracfg"; + break; + case M4U_MT8173: + p = "mediatek,mt8173-infracfg"; + break; + default: + p = NULL; + } + + infracfg = syscon_regmap_lookup_by_compatible(p); + if (IS_ERR(infracfg)) + return PTR_ERR(infracfg); } - infracfg = syscon_regmap_lookup_by_compatible(p); - - if (IS_ERR(infracfg)) - return PTR_ERR(infracfg); - ret = regmap_read(infracfg, REG_INFRA_MISC, &val); if (ret) return ret; -- 2.35.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1ECD9C433FE for ; Wed, 18 May 2022 10:05:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BE7304012E; Wed, 18 May 2022 10:05:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B26C4X-5W7T0; Wed, 18 May 2022 10:05:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id A69CE405DF; Wed, 18 May 2022 10:05:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60B8CC0084; Wed, 18 May 2022 10:05:21 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 35724C0032 for ; Wed, 18 May 2022 10:05:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 73C7C611F1 for ; Wed, 18 May 2022 10:05:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=collabora.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zCWA9Fzsd7aG for ; Wed, 18 May 2022 10:05:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9A472611E6 for ; Wed, 18 May 2022 10:05:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 34E7B1F44E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652868312; bh=A5k1VBFcKvGxrzqgH+3j6bGmcr4uqfHwo1Y08EGhiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxNE4pApZ8gh9Nj1TIILgEFkkMYNj8c5ZFBNhdR3LX1qK9xEJqpKrQlj6db7I6LE/ xqZGZOlzU3Usnq6zer2AUyTJ0/mNbdFSwaT3/3KxVzrx6Bgpr/4rtXQsawOtTctRwd TG/32fPPLILxUCMYM+SRCUhzpSO1O/+3Iaj1DHLkw6nJ4n5q3qe0gqGtDzTO8z9ZUB KTVgGh9tupltX8Vl0D3HlJZoTculsbCa0yxgSHoqPdBRlfdJsSOOgT9uxveF5vS/FD fHLEh9xGmPR2HWr2kJJQ3iF+IDYFSfyplWGf8nnHKtzK3f2sc8H3kUKcoTvUEkMII6 6rZry0GnZnZaw== From: AngeloGioacchino Del Regno To: yong.wu@mediatek.com Subject: [PATCH v2 2/7] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg Date: Wed, 18 May 2022 12:04:58 +0200 Message-Id: <20220518100503.37279-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> References: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, krzysztof.kozlowski@linaro.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, linux-mediatek@lists.infradead.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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, but also a dev_warn() was added to advertise this change in hope that the user will see it and eventually update the devicetree if this is possible. Signed-off-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 71b2ace74cd6..d16b95e71ded 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1134,22 +1134,34 @@ static int mtk_iommu_probe(struct platform_device *pdev) data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN); if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) { - switch (data->plat_data->m4u_plat) { - case M4U_MT2712: - p = "mediatek,mt2712-infracfg"; - break; - case M4U_MT8173: - p = "mediatek,mt8173-infracfg"; - break; - default: - p = NULL; + infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg"); + if (IS_ERR(infracfg)) { + dev_info(dev, "Cannot find phandle to mediatek,infracfg:" + " Please update your devicetree.\n"); + /* + * 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 = "mediatek,mt2712-infracfg"; + break; + case M4U_MT8173: + p = "mediatek,mt8173-infracfg"; + break; + default: + p = NULL; + } + + infracfg = syscon_regmap_lookup_by_compatible(p); + if (IS_ERR(infracfg)) + return PTR_ERR(infracfg); } - infracfg = syscon_regmap_lookup_by_compatible(p); - - if (IS_ERR(infracfg)) - return PTR_ERR(infracfg); - ret = regmap_read(infracfg, REG_INFRA_MISC, &val); if (ret) return ret; -- 2.35.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E416C433F5 for ; Wed, 18 May 2022 10:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8EXB/sWdLBTQggiKmASgC33Y4+qasCFGzSItsugOmp0=; b=kokCgXfTkqMumj C5Sm0Q0Ag9QIyV3LTyPAUAzBsGewrUzvawDclSS9myUz5elag8Js77sqBfMpPi2v2L/piORTgVo9l UYNAdKUcw1fnUNnqZBT3wtyh9vNyLvbMx3EJ3qN8bZbrgVu7csHU3zcqVpY243qnlfUZP+osd+nxW HAOJqNCXE08dJJFR0ZaYskgr2lfmV0INryVhwWkM7f3dAlEr2urhfIiz45rdGH18rnyIfwxyBtw/m 2UbGrQG2aPmGKICfl+1Oxkwvxk4A7M4fcVopw4uVj0X6qEtHxH0yOu+v98qF5wZzorkwUxA8eh9WX O0SlqxNE+bmosr7JXlZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrGZF-001F52-Cs; Wed, 18 May 2022 10:06:09 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrGYN-001Eew-35; Wed, 18 May 2022 10:05:17 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 34E7B1F44E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652868312; bh=A5k1VBFcKvGxrzqgH+3j6bGmcr4uqfHwo1Y08EGhiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxNE4pApZ8gh9Nj1TIILgEFkkMYNj8c5ZFBNhdR3LX1qK9xEJqpKrQlj6db7I6LE/ xqZGZOlzU3Usnq6zer2AUyTJ0/mNbdFSwaT3/3KxVzrx6Bgpr/4rtXQsawOtTctRwd TG/32fPPLILxUCMYM+SRCUhzpSO1O/+3Iaj1DHLkw6nJ4n5q3qe0gqGtDzTO8z9ZUB KTVgGh9tupltX8Vl0D3HlJZoTculsbCa0yxgSHoqPdBRlfdJsSOOgT9uxveF5vS/FD fHLEh9xGmPR2HWr2kJJQ3iF+IDYFSfyplWGf8nnHKtzK3f2sc8H3kUKcoTvUEkMII6 6rZry0GnZnZaw== 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, AngeloGioacchino Del Regno Subject: [PATCH v2 2/7] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg Date: Wed, 18 May 2022 12:04:58 +0200 Message-Id: <20220518100503.37279-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> References: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_030515_303593_EC8DE989 X-CRM114-Status: GOOD ( 15.93 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org 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, but also a dev_warn() was added to advertise this change in hope that the user will see it and eventually update the devicetree if this is possible. Signed-off-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 71b2ace74cd6..d16b95e71ded 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1134,22 +1134,34 @@ static int mtk_iommu_probe(struct platform_device *pdev) data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN); if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) { - switch (data->plat_data->m4u_plat) { - case M4U_MT2712: - p = "mediatek,mt2712-infracfg"; - break; - case M4U_MT8173: - p = "mediatek,mt8173-infracfg"; - break; - default: - p = NULL; + infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg"); + if (IS_ERR(infracfg)) { + dev_info(dev, "Cannot find phandle to mediatek,infracfg:" + " Please update your devicetree.\n"); + /* + * 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 = "mediatek,mt2712-infracfg"; + break; + case M4U_MT8173: + p = "mediatek,mt8173-infracfg"; + break; + default: + p = NULL; + } + + infracfg = syscon_regmap_lookup_by_compatible(p); + if (IS_ERR(infracfg)) + return PTR_ERR(infracfg); } - infracfg = syscon_regmap_lookup_by_compatible(p); - - if (IS_ERR(infracfg)) - return PTR_ERR(infracfg); - ret = regmap_read(infracfg, REG_INFRA_MISC, &val); if (ret) return ret; -- 2.35.1 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B38DC433EF for ; Wed, 18 May 2022 10:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=s0qRztZZxbvUd0KFComOiMRCajCsjPO/xrvbSqimFcc=; b=IAfd50yzKl5rRL I06jLGzuAyBmQPEGKLgjkfes+mSmWuV53pYlPDexy7wkmcz5C4LtpnzC44zP1UiR53hPaOBQyXuzG K2bBD7JCscEGLYqEwEO42XR/Gf6BwxH8oyy44BGU5a5MaKusoST0oRRIeBjDxrEzAT9Dwjij8noHo bkWfH0//wSIWAVmuyHSZ3WYQ8uGaf5XYBRVpAFyYFi5SR8wzfSBtNSkc4smSRciBg0vd9CHGMyTwt bDMKsRT5uKVUhlt2drbONWdB9Kq5vLpGOHQko5ja1mQdxz+el1ZXZwGKCMk3Ch2cysD4HBYFnPpQA SkpL19CujNEtAEmrprFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrGYm-001EsV-L2; Wed, 18 May 2022 10:05:40 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrGYN-001Eew-35; Wed, 18 May 2022 10:05:17 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 34E7B1F44E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652868312; bh=A5k1VBFcKvGxrzqgH+3j6bGmcr4uqfHwo1Y08EGhiiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxNE4pApZ8gh9Nj1TIILgEFkkMYNj8c5ZFBNhdR3LX1qK9xEJqpKrQlj6db7I6LE/ xqZGZOlzU3Usnq6zer2AUyTJ0/mNbdFSwaT3/3KxVzrx6Bgpr/4rtXQsawOtTctRwd TG/32fPPLILxUCMYM+SRCUhzpSO1O/+3Iaj1DHLkw6nJ4n5q3qe0gqGtDzTO8z9ZUB KTVgGh9tupltX8Vl0D3HlJZoTculsbCa0yxgSHoqPdBRlfdJsSOOgT9uxveF5vS/FD fHLEh9xGmPR2HWr2kJJQ3iF+IDYFSfyplWGf8nnHKtzK3f2sc8H3kUKcoTvUEkMII6 6rZry0GnZnZaw== 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, AngeloGioacchino Del Regno Subject: [PATCH v2 2/7] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg Date: Wed, 18 May 2022 12:04:58 +0200 Message-Id: <20220518100503.37279-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> References: <20220518100503.37279-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220518_030515_303593_EC8DE989 X-CRM114-Status: GOOD ( 15.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, but also a dev_warn() was added to advertise this change in hope that the user will see it and eventually update the devicetree if this is possible. Signed-off-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 40 +++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 71b2ace74cd6..d16b95e71ded 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1134,22 +1134,34 @@ static int mtk_iommu_probe(struct platform_device *pdev) data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN); if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) { - switch (data->plat_data->m4u_plat) { - case M4U_MT2712: - p = "mediatek,mt2712-infracfg"; - break; - case M4U_MT8173: - p = "mediatek,mt8173-infracfg"; - break; - default: - p = NULL; + infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg"); + if (IS_ERR(infracfg)) { + dev_info(dev, "Cannot find phandle to mediatek,infracfg:" + " Please update your devicetree.\n"); + /* + * 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 = "mediatek,mt2712-infracfg"; + break; + case M4U_MT8173: + p = "mediatek,mt8173-infracfg"; + break; + default: + p = NULL; + } + + infracfg = syscon_regmap_lookup_by_compatible(p); + if (IS_ERR(infracfg)) + return PTR_ERR(infracfg); } - infracfg = syscon_regmap_lookup_by_compatible(p); - - if (IS_ERR(infracfg)) - return PTR_ERR(infracfg); - ret = regmap_read(infracfg, REG_INFRA_MISC, &val); if (ret) return ret; -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel