From patchwork Thu Feb 10 14:19:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12741980 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 4EDC8C433F5 for ; Thu, 10 Feb 2022 14:21:10 +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=w3QlWRYJD8+7Fd3rMIJihggvo7MypkB1JEqWYSC3wDM=; b=n/Nr8eTPlcq8OA xVeQ/jvqOVVB1IZwJpMFf3tL9J4hzR1rCqPbfx84qVpBokhBjoWuqq8ux675OKgxlYhcEKhO1OLmf 6qg/6vCv70/2iHow3V32E8cTYyL1mIPDLoEDNa79rXW9cOWRMU3jIhYsjeya3QIfgZfqZZnXkko8j 7Eq90xfHDYT2ID0hr2h9+HT6FDrDUaTdnFVpJGK10HFZzn7w2BdMgPDfLdAhSFapK3l/Fvmkl35MM x93hGSTqsKSR2nwhVKw2mEq0rOfYH3mHgAUOLiFxgLkXX8y3BdL8toaAYUz4j1dB8/DR1xnd8rVS4 a7Ra4QnptDRS3UCzXE6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIa-0041ps-KD; Thu, 10 Feb 2022 14:19:52 +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 1nIAIL-0041kI-SL; Thu, 10 Feb 2022 14:19:39 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 242C31F46564 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644502776; bh=zG0bldBWB2nx02kMBfqhQzYNwC5linFfUnYedSv8FaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxqmqOSsefZzZGq90wPl9wLr3zJokFwvL2I/V0TceAKt8PC/ES67xF49aiJkz601R KdsdTFSIgvy6ufY85glDTHDa6F25wtIlx5oqJOFDzcWur7TKVx+woUmNINkdPxXu+X /xiBehiki0o7MELMOcdMpuwToodQDsedC5PrAPvBcXSuXNyXr9kGkKO07yg0Rxn3cb ccCPwYADesGDSgYFrxMjMw8d0uEiJdWrdklIYWznosOM57JLI72QMuRizay9vOlFbc l7oUrMY/syUO0RHkuAFEDShzuwSNW4sVBmLdhZ2QcqwxndKcWN+WCZL3nrqcKU696x 7ZQG2Xx3pGbow== From: AngeloGioacchino Del Regno To: sean.wang@kernel.org Cc: linus.walleij@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 1/5] pinctrl: mediatek: paris: Unify probe function by using OF match data Date: Thu, 10 Feb 2022 15:19:27 +0100 Message-Id: <20220210141931.291712-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220210141931.291712-1-angelogioacchino.delregno@collabora.com> References: <20220210141931.291712-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-20220210_061938_203493_2CCCE4D0 X-CRM114-Status: GOOD ( 16.40 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All of the SoCs using Paris pinctrl are defining a custom probe function that is simply calling mtk_paris_pinctrl_probe() passing a pointer to the SoC specific mtk_pin_soc structure and nothing else. Simplify the probe mechanism across all pinctrl drivers that are using pinctrl-paris by passing the specific mtk_pin_soc as match data and using function mtk_paris_pinctrl_probe as a common probe function for all of them. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-mt6765.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt6779.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt6797.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt8183.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt8192.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt8195.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-paris.c | 9 ++++++--- drivers/pinctrl/mediatek/pinctrl-paris.h | 3 +-- 8 files changed, 19 insertions(+), 47 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6765.c b/drivers/pinctrl/mediatek/pinctrl-mt6765.c index 2c59d3936256..c57b19fcda03 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt6765.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt6765.c @@ -1082,21 +1082,16 @@ static const struct mtk_pin_soc mt6765_data = { }; static const struct of_device_id mt6765_pinctrl_of_match[] = { - { .compatible = "mediatek,mt6765-pinctrl", }, + { .compatible = "mediatek,mt6765-pinctrl", .data = &mt6765_data }, { } }; -static int mt6765_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt6765_data); -} - static struct platform_driver mt6765_pinctrl_driver = { .driver = { .name = "mt6765-pinctrl", .of_match_table = mt6765_pinctrl_of_match, }, - .probe = mt6765_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt6765_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6779.c b/drivers/pinctrl/mediatek/pinctrl-mt6779.c index bb0851c73304..4ddf8bda6827 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt6779.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt6779.c @@ -758,21 +758,16 @@ static const struct mtk_pin_soc mt6779_data = { }; static const struct of_device_id mt6779_pinctrl_of_match[] = { - { .compatible = "mediatek,mt6779-pinctrl", }, + { .compatible = "mediatek,mt6779-pinctrl", .data = &mt6779_data }, { } }; -static int mt6779_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt6779_data); -} - static struct platform_driver mt6779_pinctrl_driver = { .driver = { .name = "mt6779-pinctrl", .of_match_table = mt6779_pinctrl_of_match, }, - .probe = mt6779_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt6779_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6797.c b/drivers/pinctrl/mediatek/pinctrl-mt6797.c index adebe4333ed9..53f240491259 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt6797.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt6797.c @@ -58,21 +58,16 @@ static const struct mtk_pin_soc mt6797_data = { }; static const struct of_device_id mt6797_pinctrl_of_match[] = { - { .compatible = "mediatek,mt6797-pinctrl", }, + { .compatible = "mediatek,mt6797-pinctrl", .data = &mt6797_data }, { } }; -static int mt6797_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt6797_data); -} - static struct platform_driver mt6797_pinctrl_driver = { .driver = { .name = "mt6797-pinctrl", .of_match_table = mt6797_pinctrl_of_match, }, - .probe = mt6797_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt6797_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c b/drivers/pinctrl/mediatek/pinctrl-mt8183.c index 60318339b618..fecb1e64fff4 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c @@ -567,22 +567,17 @@ static const struct mtk_pin_soc mt8183_data = { }; static const struct of_device_id mt8183_pinctrl_of_match[] = { - { .compatible = "mediatek,mt8183-pinctrl", }, + { .compatible = "mediatek,mt8183-pinctrl", .data = &mt8183_data }, { } }; -static int mt8183_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt8183_data); -} - static struct platform_driver mt8183_pinctrl_driver = { .driver = { .name = "mt8183-pinctrl", .of_match_table = mt8183_pinctrl_of_match, .pm = &mtk_paris_pinctrl_pm_ops, }, - .probe = mt8183_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt8183_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8192.c b/drivers/pinctrl/mediatek/pinctrl-mt8192.c index 0c16b2c756bf..acccde9262ba 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8192.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8192.c @@ -1381,22 +1381,17 @@ static const struct mtk_pin_soc mt8192_data = { }; static const struct of_device_id mt8192_pinctrl_of_match[] = { - { .compatible = "mediatek,mt8192-pinctrl", }, + { .compatible = "mediatek,mt8192-pinctrl", .data = &mt8192_data }, { } }; -static int mt8192_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt8192_data); -} - static struct platform_driver mt8192_pinctrl_driver = { .driver = { .name = "mt8192-pinctrl", .of_match_table = mt8192_pinctrl_of_match, .pm = &mtk_paris_pinctrl_pm_ops, }, - .probe = mt8192_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt8192_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c b/drivers/pinctrl/mediatek/pinctrl-mt8195.c index 275b7ba4386d..563693d3d4c2 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c @@ -959,22 +959,17 @@ static const struct mtk_pin_soc mt8195_data = { }; static const struct of_device_id mt8195_pinctrl_of_match[] = { - { .compatible = "mediatek,mt8195-pinctrl", }, + { .compatible = "mediatek,mt8195-pinctrl", .data = &mt8195_data }, { } }; -static int mt8195_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_paris_pinctrl_probe(pdev, &mt8195_data); -} - static struct platform_driver mt8195_pinctrl_driver = { .driver = { .name = "mt8195-pinctrl", .of_match_table = mt8195_pinctrl_of_match, .pm = &mtk_paris_pinctrl_pm_ops, }, - .probe = mt8195_pinctrl_probe, + .probe = mtk_paris_pinctrl_probe, }; static int __init mt8195_pinctrl_init(void) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index 784eb152b637..6d9e4d625517 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -1036,8 +1036,7 @@ static int mtk_pctrl_build_state(struct platform_device *pdev) return 0; } -int mtk_paris_pinctrl_probe(struct platform_device *pdev, - const struct mtk_pin_soc *soc) +int mtk_paris_pinctrl_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct pinctrl_pin_desc *pins; @@ -1049,7 +1048,11 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev, return -ENOMEM; platform_set_drvdata(pdev, hw); - hw->soc = soc; + + hw->soc = device_get_match_data(dev); + if (!hw->soc) + return -ENOENT; + hw->dev = &pdev->dev; if (!hw->soc->nbase_names) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.h b/drivers/pinctrl/mediatek/pinctrl-paris.h index afb7650fd25b..8762ac599329 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.h +++ b/drivers/pinctrl/mediatek/pinctrl-paris.h @@ -57,8 +57,7 @@ id##_funcs, \ } -int mtk_paris_pinctrl_probe(struct platform_device *pdev, - const struct mtk_pin_soc *soc); +int mtk_paris_pinctrl_probe(struct platform_device *pdev); ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw, unsigned int gpio, char *buf, unsigned int bufLen); From patchwork Thu Feb 10 14:19:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12741981 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 B9572C433F5 for ; Thu, 10 Feb 2022 14:21:22 +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=xVKBxUATGS2+bvfUzDyL+nsIeyM6ldE6NdL/YlsPq6A=; b=XJyLDIQ52AR6Re Bml/KpT9hkmxZ1imMxwv5n4EBMuW+32z6nj1cYa+BJJqTxt02Tdv3s303V617OKQsxwAQ7fEBUc4z BkJpo26TFT/zCtjKgocaMwBe7mLJEsdj/PFGFfo0TtUFxPcZnZtpAeMQE/ZTB+Y4u7mXmBHwkLzTs 6rxXJLfyTNmjdYga0+TjWeZNKRuAVUTjn6GTX2q+XWysnTy/AL+mzqvGI9pu0CF9BEN+4UC7q67z5 GZPN09TvjsO5mOBSBYpClvFcNGB40nHwTWzkKl9uOzO7r8bACxxqVZPsaKUnvr2ygUO4BD6448b6R HYQsfAJDZMqgW7d88zDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIl-0041uJ-Ec; Thu, 10 Feb 2022 14:20:03 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIM-0041kU-Nm; Thu, 10 Feb 2022 14:19:40 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id CCACB1F4656A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644502777; bh=sQ+FKkicNUDc/dNX696E1r1KBxy8rCFNJOXpjtexupY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZM0WFhkt1W5EvBOeUJpFadV9V97cO6GR6en/cvtgJtW2zYjFEGTgI6cCNtDul8Zgm SqHciHMaFJrknyO9tr8lImjDW6ArvKNQjc2YOfmjFJ8Qzf7l1o3uAHRO1gL44HF/Az 5ejkGtb+uRTdytPAs2oWQz72Rp7sxrPgtJFVOJjHDJGjp3ovUyZdaxmp9jx3PU4GZV LdY6/iovw4q2SGd3CjG3qRlC/WpltpHLBbevtQ1BtCeJTY6+YyNUbz7r7BJVjv7bJY oIK82HNjxoGZhKB8dvpoMgtePTXQlqRtPZ916fdPLGY2knsUgf7CqZCdR/Z8T2lPJy msHrq6V9Am/rg== From: AngeloGioacchino Del Regno To: sean.wang@kernel.org Cc: linus.walleij@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 2/5] pinctrl: mediatek: common-v1: Add common probe function Date: Thu, 10 Feb 2022 15:19:28 +0100 Message-Id: <20220210141931.291712-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220210141931.291712-1-angelogioacchino.delregno@collabora.com> References: <20220210141931.291712-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-20220210_061938_923551_3461FE1D X-CRM114-Status: GOOD ( 10.48 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As a preparation to cleanup the probe mechanism of mediatek pinctrl drivers that are using the v1 controller, add a common probe function to this driver. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 11 +++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 6f8dfa6ae5a0..007da39b68c9 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -1115,3 +1115,14 @@ int mtk_pctrl_init(struct platform_device *pdev, gpiochip_remove(pctl->chip); return ret; } + +int mtk_pctrl_common_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + const struct mtk_pinctrl_devdata *data = device_get_match_data(dev); + + if (!data) + return -ENOENT; + + return mtk_pctrl_init(pdev, data, NULL); +} diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index 98f27cdc609a..cd264cc3547b 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -277,6 +277,8 @@ int mtk_pctrl_init(struct platform_device *pdev, const struct mtk_pinctrl_devdata *data, struct regmap *regmap); +int mtk_pctrl_common_probe(struct platform_device *pdev); + int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, const struct mtk_pin_spec_pupd_set_samereg *pupd_infos, unsigned int info_num, unsigned int pin, From patchwork Thu Feb 10 14:19:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12741982 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 5946FC433EF for ; Thu, 10 Feb 2022 14:21:24 +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=rVHwSJrtCV2Xh/Q73QHSwNpBJMr4ImVQztPDvfThB5k=; b=UGLSfpxcLR6+Xu 03aYv+03yl/asUAaVIb0vH9//gbPFZYrnGvDK+CfFaXm42nqPkvB/44pQPjbJTD/mtJREBVFtUbFs dPooLfyWk+WUyWq9NNY/Qv9xlkiwnHcih+euSm5z3Edzmfevb9N3TgkpPd6bGXYF6BPItWkf66VCx nhXvJhtqO6kBrL+2yZQ4DQwaUGAZsGMgqf/Tdry4+ockmzfOekJUhjRU9tbGEwvX+GmEjk5z8cFtk 4CqGqJIYOqDZkG5rUwp40Uzna7xGSDhOhm5r+tPQXoK+7E+G8JuErsPm7/rWr4osWkvv6MwT/Amj/ E92RXjMC4noHneoqGoOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIw-0041yu-0E; Thu, 10 Feb 2022 14:20:14 +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 1nIAIN-0041ki-7O; Thu, 10 Feb 2022 14:19:41 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 7D17A1F4656E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644502778; bh=n8CGqf0yuDMBl0AcIjnWSW/xsE0lZFScDerKAcE+A7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gad6W7Ew1fVLAM3hq6/Ky7hnUp7hlPAFKvhC25rQNx3rOZUAY3j9pTP4bAq8vkihc fd3QS/eFV7iN2TSBXUPZVpXE7A3tcre6pC+zJdpLufIfz+yYpGJWOY41gKo1kBZUj2 3vIejAXc8ezkRiHuBUGgB6tGPHyGhCndqy/o65ytldcjeOh0zfu6qV0XRDJnjvv2wz TvQdzpT77/r9eKGhscKxM056jpFEyxdhcpdSOiD/WRYMRCmHUm+m7ixCRlrO5N34Aa u7SprP+fRMPfXafBTYAFfz/07XPSP44kkWMOw4fLEPlglzHg1T36M1rX6Hap0UboOw eAzCIWuN8MXRw== From: AngeloGioacchino Del Regno To: sean.wang@kernel.org Cc: linus.walleij@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 3/5] pinctrl: mediatek: common-v1: Use common probe function Date: Thu, 10 Feb 2022 15:19:29 +0100 Message-Id: <20220210141931.291712-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220210141931.291712-1-angelogioacchino.delregno@collabora.com> References: <20220210141931.291712-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-20220210_061939_549793_EB0129ED X-CRM114-Status: GOOD ( 12.54 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Most of the mediatek pinctrl drivers are calling mtk_pctrl_init() and passing only a pointer to struct mtk_pinctrl_devdata, as the regmap handle it passed from device-tree, with the exception of mt6397. For all of the drivers that don't require passing a struct regmap pointer from a parent device, simplify the probe mechanism by assigning the required structure as match data and use mtk_pctrl_common_probe() as their probe function. While at it, also collapse the of_device_id entries to a single line, as they all fit in max 83 columns, which is acceptable. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-mt2701.c | 11 +++-------- drivers/pinctrl/mediatek/pinctrl-mt2712.c | 11 ++--------- drivers/pinctrl/mediatek/pinctrl-mt8127.c | 9 ++------- drivers/pinctrl/mediatek/pinctrl-mt8135.c | 11 ++--------- drivers/pinctrl/mediatek/pinctrl-mt8167.c | 11 ++--------- drivers/pinctrl/mediatek/pinctrl-mt8365.c | 11 ++--------- drivers/pinctrl/mediatek/pinctrl-mt8516.c | 11 ++--------- 7 files changed, 15 insertions(+), 60 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2701.c b/drivers/pinctrl/mediatek/pinctrl-mt2701.c index 37228dd5103e..2f8821207395 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2701.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2701.c @@ -534,20 +534,15 @@ static const struct mtk_pinctrl_devdata mt2701_pinctrl_data = { }, }; -static int mt2701_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt2701_pinctrl_data, NULL); -} - static const struct of_device_id mt2701_pctrl_match[] = { - { .compatible = "mediatek,mt2701-pinctrl", }, - { .compatible = "mediatek,mt7623-pinctrl", }, + { .compatible = "mediatek,mt2701-pinctrl", .data = &mt2701_pinctrl_data }, + { .compatible = "mediatek,mt7623-pinctrl", .data = &mt2701_pinctrl_data }, {} }; MODULE_DEVICE_TABLE(of, mt2701_pctrl_match); static struct platform_driver mtk_pinctrl_driver = { - .probe = mt2701_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt2701-pinctrl", .of_match_table = mt2701_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2712.c b/drivers/pinctrl/mediatek/pinctrl-mt2712.c index ba35fc6cc138..03aa14445034 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2712.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2712.c @@ -587,21 +587,14 @@ static const struct mtk_pinctrl_devdata mt2712_pinctrl_data = { }, }; -static int mt2712_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt2712_pinctrl_data, NULL); -} - static const struct of_device_id mt2712_pctrl_match[] = { - { - .compatible = "mediatek,mt2712-pinctrl", - }, + { .compatible = "mediatek,mt2712-pinctrl", .data = &mt2712_pinctrl_data }, { } }; MODULE_DEVICE_TABLE(of, mt2712_pctrl_match); static struct platform_driver mtk_pinctrl_driver = { - .probe = mt2712_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt2712-pinctrl", .of_match_table = mt2712_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8127.c b/drivers/pinctrl/mediatek/pinctrl-mt8127.c index eaf5c76b14c7..76cb525374f2 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8127.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8127.c @@ -303,18 +303,13 @@ static const struct mtk_pinctrl_devdata mt8127_pinctrl_data = { }, }; -static int mt8127_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt8127_pinctrl_data, NULL); -} - static const struct of_device_id mt8127_pctrl_match[] = { - { .compatible = "mediatek,mt8127-pinctrl", }, + { .compatible = "mediatek,mt8127-pinctrl", .data = &mt8127_pinctrl_data }, { } }; static struct platform_driver mtk_pinctrl_driver = { - .probe = mt8127_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt8127-pinctrl", .of_match_table = mt8127_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8135.c b/drivers/pinctrl/mediatek/pinctrl-mt8135.c index b8f4080aab45..4c20b79dec67 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8135.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8135.c @@ -316,20 +316,13 @@ static const struct mtk_pinctrl_devdata mt8135_pinctrl_data = { }, }; -static int mt8135_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt8135_pinctrl_data, NULL); -} - static const struct of_device_id mt8135_pctrl_match[] = { - { - .compatible = "mediatek,mt8135-pinctrl", - }, + { .compatible = "mediatek,mt8135-pinctrl", .data = &mt8135_pinctrl_data }, { } }; static struct platform_driver mtk_pinctrl_driver = { - .probe = mt8135_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt8135-pinctrl", .of_match_table = mt8135_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8167.c b/drivers/pinctrl/mediatek/pinctrl-mt8167.c index ba12ef795e52..08aabf408c9c 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8167.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8167.c @@ -335,22 +335,15 @@ static const struct mtk_pinctrl_devdata mt8167_pinctrl_data = { }, }; -static int mt8167_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt8167_pinctrl_data, NULL); -} - static const struct of_device_id mt8167_pctrl_match[] = { - { - .compatible = "mediatek,mt8167-pinctrl", - }, + { .compatible = "mediatek,mt8167-pinctrl", .data = &mt8167_pinctrl_data }, {} }; MODULE_DEVICE_TABLE(of, mt8167_pctrl_match); static struct platform_driver mtk_pinctrl_driver = { - .probe = mt8167_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt8167-pinctrl", .of_match_table = mt8167_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8365.c b/drivers/pinctrl/mediatek/pinctrl-mt8365.c index 79b1fee5a1eb..6863a8150a2b 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8365.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8365.c @@ -469,20 +469,13 @@ static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = { }, }; -static int mtk_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt8365_pinctrl_data, NULL); -} - static const struct of_device_id mt8365_pctrl_match[] = { - { - .compatible = "mediatek,mt8365-pinctrl", - }, + { .compatible = "mediatek,mt8365-pinctrl", .data = &mt8365_pinctrl_data }, {} }; static struct platform_driver mtk_pinctrl_driver = { - .probe = mtk_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt8365-pinctrl", .of_match_table = mt8365_pctrl_match, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c index 219fb4bc341f..99c1a04c7fd8 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c @@ -335,22 +335,15 @@ static const struct mtk_pinctrl_devdata mt8516_pinctrl_data = { }, }; -static int mt8516_pinctrl_probe(struct platform_device *pdev) -{ - return mtk_pctrl_init(pdev, &mt8516_pinctrl_data, NULL); -} - static const struct of_device_id mt8516_pctrl_match[] = { - { - .compatible = "mediatek,mt8516-pinctrl", - }, + { .compatible = "mediatek,mt8516-pinctrl", .data = &mt8516_pinctrl_data }, {} }; MODULE_DEVICE_TABLE(of, mt8516_pctrl_match); static struct platform_driver mtk_pinctrl_driver = { - .probe = mt8516_pinctrl_probe, + .probe = mtk_pctrl_common_probe, .driver = { .name = "mediatek-mt8516-pinctrl", .of_match_table = mt8516_pctrl_match, From patchwork Thu Feb 10 14:19:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12741983 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 65106C433EF for ; Thu, 10 Feb 2022 14:21:48 +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=J7m/jJPwC1YoVgAs5Pzc4Wd4JgRY9dgvDfC9ABg/lAg=; b=mDHuk9doaH0Fqe te7Fl/PwA6rLIAcmy59ya7zRn/y0LpeSbttbsWNHgGHvXsd6eUTGtUSj2knnCvMhaX0T+E+6GDfHB igh56vKzFxAQKBPxI5cACSPfidliBQv7FZOJCJno57gTLik3esE7PVGWeO76S910mCms7qtUhUtga zUS91AN5VAhF56xzi1GURguYkeIBdxcimIPmaG4Y5wP73hALkAls1NIlucL8mtvvK8y8fHJrh+66p GGGqFrGmLqE1VAhIZP4rvRdWULjUwUprr0eNazZ+S8P+WIRV3qdDyHR3ey8DRXWyRu/901BTwL01a g4391lKtvmYLKMo4aklQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAJ8-004257-1v; Thu, 10 Feb 2022 14:20:26 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIN-0041kx-TO; Thu, 10 Feb 2022 14:19:42 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 384A41F46573 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644502778; bh=T6oCvxGI02ejeib653keltA8aaT+DmTLdUz6lyCdlFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JsXM+8uQAknm04CPPO9RTgZvKYuoZ0HeLrkU6+q2yr/XeCQJ93ujwet1qJmTA7a1t dtSgUEX+LVmNAG1j2dYYtmdFE0CFZVFvAUf+lHHH68qd6bZmfpzGXbApfJlI5IoakR jSinthleORHHJgMahN3QM+X5AtOeoiR2b/s3Cj68ETG8ksItV4as7ykXtNyeD9LLc9 +oykn56hO9RYtmZJXNXNtiyv2FnJg3ncH+t7kQh1NT8WPgOAY5LdtXTtolWa2MW9tp ysfPCwR7dgGyHg63PfsYOeTBmRZ0zhRFs1/1yZDHN6BGnLKvsGmOvFRBt8gvOhlPFO aWMg6enlLvdKg== From: AngeloGioacchino Del Regno To: sean.wang@kernel.org Cc: linus.walleij@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 4/5] pinctrl: mediatek: common-v1: Commonize spec_pupd callback Date: Thu, 10 Feb 2022 15:19:30 +0100 Message-Id: <20220210141931.291712-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220210141931.291712-1-angelogioacchino.delregno@collabora.com> References: <20220210141931.291712-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-20220210_061940_269489_EAE6D09F X-CRM114-Status: GOOD ( 16.47 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce code size and duplication by using a common spec_pupd callback, which is possible to use on all of the pinctrl drivers that are using the v1 pinctrl-mtk-common code, with the exception of mt8135, which has a different handling compared to the others. Since the callback function signature was changed, this had to be propagated to pinctrl-mt8135's spec_pull_set(). Signed-off-by: AngeloGioacchino Del Regno Signed-off-by: Chen-Yu Tsai Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-mt2701.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mt2712.c | 14 +++-------- drivers/pinctrl/mediatek/pinctrl-mt8127.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mt8135.c | 6 +++-- drivers/pinctrl/mediatek/pinctrl-mt8167.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mt8173.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mt8365.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mt8516.c | 11 +++------ drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 23 +++++++++++-------- drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 14 +++++++---- 10 files changed, 47 insertions(+), 76 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2701.c b/drivers/pinctrl/mediatek/pinctrl-mt2701.c index 2f8821207395..816de39858f8 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2701.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2701.c @@ -270,13 +270,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt2701_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(261, 0x140, 8, 9, 10), /* ms1 ins */ }; -static int mt2701_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt2701_spec_pupd, - ARRAY_SIZE(mt2701_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt2701_ies_set[] = { MTK_PIN_IES_SMT_SPEC(0, 6, 0xb20, 0), MTK_PIN_IES_SMT_SPEC(7, 9, 0xb20, 1), @@ -508,7 +501,9 @@ static const struct mtk_pinctrl_devdata mt2701_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt2701_drv_grp), .pin_drv_grp = mt2701_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt2701_pin_drv), - .spec_pull_set = mt2701_spec_pull_set, + .spec_pupd = mt2701_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt2701_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt2701_ies_smt_set, .spec_pinmux_set = mt2701_spec_pinmux_set, .spec_dir_set = mt2701_spec_dir_set, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2712.c b/drivers/pinctrl/mediatek/pinctrl-mt2712.c index 03aa14445034..b6182b06584b 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2712.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2712.c @@ -81,16 +81,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt2712_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(142, 0xe60, 5, 4, 3) }; -static int mt2712_spec_pull_set(struct regmap *regmap, - unsigned int pin, - unsigned char align, - bool isup, - unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt2712_spec_pupd, - ARRAY_SIZE(mt2712_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt2712_smt_set[] = { MTK_PIN_IES_SMT_SPEC(0, 3, 0x900, 2), MTK_PIN_IES_SMT_SPEC(4, 7, 0x900, 0), @@ -563,7 +553,9 @@ static const struct mtk_pinctrl_devdata mt2712_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt2712_drv_grp), .pin_drv_grp = mt2712_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt2712_pin_drv), - .spec_pull_set = mt2712_spec_pull_set, + .spec_pupd = mt2712_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt2712_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt2712_ies_smt_set, .dir_offset = 0x0000, .pullen_offset = 0x0100, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8127.c b/drivers/pinctrl/mediatek/pinctrl-mt8127.c index 76cb525374f2..9745d15f93ec 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8127.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8127.c @@ -172,13 +172,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt8127_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(142, 0xdc0, 2, 0, 1), /* EINT21 */ }; -static int mt8127_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt8127_spec_pupd, - ARRAY_SIZE(mt8127_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt8127_ies_set[] = { MTK_PIN_IES_SMT_SPEC(0, 9, 0x900, 0), MTK_PIN_IES_SMT_SPEC(10, 13, 0x900, 1), @@ -279,7 +272,9 @@ static const struct mtk_pinctrl_devdata mt8127_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8127_drv_grp), .pin_drv_grp = mt8127_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8127_pin_drv), - .spec_pull_set = mt8127_spec_pull_set, + .spec_pupd = mt8127_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt8127_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt8127_ies_smt_set, .dir_offset = 0x0000, .pullen_offset = 0x0100, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8135.c b/drivers/pinctrl/mediatek/pinctrl-mt8135.c index 4c20b79dec67..562846756517 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8135.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8135.c @@ -230,12 +230,14 @@ static const struct mtk_spec_pull_set spec_pupd[] = { SPEC_PULL(202, PUPD_BASE2+0xc0, 10, R0_BASE1, 12, R1_BASE2+0xc0, 10) }; -static int spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) +static int spec_pull_set(struct regmap *regmap, + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, bool isup, unsigned int r1r0) { unsigned int i; unsigned int reg_pupd, reg_set_r0, reg_set_r1; unsigned int reg_rst_r0, reg_rst_r1; + unsigned char align = devdata->port_align; bool find = false; for (i = 0; i < ARRAY_SIZE(spec_pupd); i++) { diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8167.c b/drivers/pinctrl/mediatek/pinctrl-mt8167.c index 08aabf408c9c..118ddcba18fc 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8167.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8167.c @@ -186,13 +186,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt8167_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(120, 0xe00, 2, 1, 0), }; -static int mt8167_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt8167_spec_pupd, - ARRAY_SIZE(mt8167_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt8167_ies_set[] = { MTK_PIN_IES_SMT_SPEC(0, 6, 0x900, 2), MTK_PIN_IES_SMT_SPEC(7, 10, 0x900, 3), @@ -311,7 +304,9 @@ static const struct mtk_pinctrl_devdata mt8167_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8167_drv_grp), .pin_drv_grp = mt8167_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8167_pin_drv), - .spec_pull_set = mt8167_spec_pull_set, + .spec_pupd = mt8167_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt8167_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt8167_ies_smt_set, .dir_offset = 0x0000, .pullen_offset = 0x0500, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8173.c b/drivers/pinctrl/mediatek/pinctrl-mt8173.c index fc99df8a11c6..b34c9778e131 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8173.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8173.c @@ -61,13 +61,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt8173_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(27, 0xcd0, 2, 1, 0) /* ms3 cmd */ }; -static int mt8173_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt8173_spec_pupd, - ARRAY_SIZE(mt8173_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt8173_smt_set[] = { MTK_PIN_IES_SMT_SPEC(0, 4, 0x930, 1), MTK_PIN_IES_SMT_SPEC(5, 9, 0x930, 2), @@ -319,7 +312,9 @@ static const struct mtk_pinctrl_devdata mt8173_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8173_drv_grp), .pin_drv_grp = mt8173_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8173_pin_drv), - .spec_pull_set = mt8173_spec_pull_set, + .spec_pupd = mt8173_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt8173_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt8173_ies_smt_set, .dir_offset = 0x0000, .pullen_offset = 0x0100, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8365.c b/drivers/pinctrl/mediatek/pinctrl-mt8365.c index 6863a8150a2b..dbff7a831235 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8365.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8365.c @@ -416,13 +416,6 @@ static const struct mtk_pin_ies_smt_set mt8365_smt_set[] = { MTK_PIN_IES_SMT_SPEC(144, 144, 0x480, 22), }; -static int mt8365_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt8365_spec_pupd, - ARRAY_SIZE(mt8365_spec_pupd), pin, align, isup, r1r0); -} - static int mt8365_ies_smt_set(struct regmap *regmap, unsigned int pin, unsigned char align, int value, enum pin_config_param arg) { @@ -442,7 +435,9 @@ static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8365_drv_grp), .pin_drv_grp = mt8365_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8365_pin_drv), - .spec_pull_set = mt8365_spec_pull_set, + .spec_pupd = mt8365_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt8365_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt8365_ies_smt_set, .dir_offset = 0x0140, .dout_offset = 0x00A0, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c index 99c1a04c7fd8..8ad2006857c0 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c @@ -186,13 +186,6 @@ static const struct mtk_pin_spec_pupd_set_samereg mt8516_spec_pupd[] = { MTK_PIN_PUPD_SPEC_SR(120, 0xe00, 2, 1, 0), }; -static int mt8516_spec_pull_set(struct regmap *regmap, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) -{ - return mtk_pctrl_spec_pull_set_samereg(regmap, mt8516_spec_pupd, - ARRAY_SIZE(mt8516_spec_pupd), pin, align, isup, r1r0); -} - static const struct mtk_pin_ies_smt_set mt8516_ies_set[] = { MTK_PIN_IES_SMT_SPEC(0, 6, 0x900, 2), MTK_PIN_IES_SMT_SPEC(7, 10, 0x900, 3), @@ -311,7 +304,9 @@ static const struct mtk_pinctrl_devdata mt8516_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8516_drv_grp), .pin_drv_grp = mt8516_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8516_pin_drv), - .spec_pull_set = mt8516_spec_pull_set, + .spec_pupd = mt8516_spec_pupd, + .n_spec_pupd = ARRAY_SIZE(mt8516_spec_pupd), + .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, .spec_ies_smt_set = mt8516_ies_smt_set, .dir_offset = 0x0000, .pullen_offset = 0x0500, diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 007da39b68c9..5e1d17512a0d 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -222,9 +222,8 @@ static int mtk_pconf_set_driving(struct mtk_pinctrl *pctl, } int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, - const struct mtk_pin_spec_pupd_set_samereg *pupd_infos, - unsigned int info_num, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0) + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, bool isup, unsigned int r1r0) { unsigned int i; unsigned int reg_pupd, reg_set, reg_rst; @@ -232,8 +231,11 @@ int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, const struct mtk_pin_spec_pupd_set_samereg *spec_pupd_pin; bool find = false; - for (i = 0; i < info_num; i++) { - if (pin == pupd_infos[i].pin) { + if (!devdata->spec_pupd) + return -EINVAL; + + for (i = 0; i < devdata->n_spec_pupd; i++) { + if (pin == devdata->spec_pupd[i].pin) { find = true; break; } @@ -242,9 +244,9 @@ int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, if (!find) return -EINVAL; - spec_pupd_pin = pupd_infos + i; - reg_set = spec_pupd_pin->offset + align; - reg_rst = spec_pupd_pin->offset + (align << 1); + spec_pupd_pin = devdata->spec_pupd + i; + reg_set = spec_pupd_pin->offset + devdata->port_align; + reg_rst = spec_pupd_pin->offset + (devdata->port_align << 1); if (isup) reg_pupd = reg_rst; @@ -293,12 +295,13 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl *pctl, * resistor bit, so we need this special handle. */ if (pctl->devdata->spec_pull_set) { - /* For special pins, bias-disable is set by R1R0, + /* For special pins, bias-disable is set by R1R0 * the parameter should be "MTK_PUPD_SET_R1R0_00". */ r1r0 = enable ? arg : MTK_PUPD_SET_R1R0_00; ret = pctl->devdata->spec_pull_set(mtk_get_regmap(pctl, pin), - pin, pctl->devdata->port_align, isup, r1r0); + pctl->devdata, pin, isup, + r1r0); if (!ret) return 0; } diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index cd264cc3547b..f7968a6ac563 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -193,6 +193,8 @@ struct mtk_eint_offsets { * * @grp_desc: The driving group info. * @pin_drv_grp: The driving group for all pins. + * @spec_pupd: Special pull up/down setting + * @n_spec_pupd: Number of entries in spec_pupd * @spec_pull_set: Each SoC may have special pins for pull up/down setting, * these pins' pull setting are very different, they have separate pull * up/down bit, R0 and R1 resistor bit, so they need special pull setting. @@ -231,8 +233,11 @@ struct mtk_pinctrl_devdata { unsigned int n_grp_cls; const struct mtk_pin_drv_grp *pin_drv_grp; unsigned int n_pin_drv_grps; - int (*spec_pull_set)(struct regmap *reg, unsigned int pin, - unsigned char align, bool isup, unsigned int arg); + const struct mtk_pin_spec_pupd_set_samereg *spec_pupd; + unsigned int n_spec_pupd; + int (*spec_pull_set)(struct regmap *regmap, + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, bool isup, unsigned int r1r0); int (*spec_ies_smt_set)(struct regmap *reg, unsigned int pin, unsigned char align, int value, enum pin_config_param arg); void (*spec_pinmux_set)(struct regmap *reg, unsigned int pin, @@ -280,9 +285,8 @@ int mtk_pctrl_init(struct platform_device *pdev, int mtk_pctrl_common_probe(struct platform_device *pdev); int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, - const struct mtk_pin_spec_pupd_set_samereg *pupd_infos, - unsigned int info_num, unsigned int pin, - unsigned char align, bool isup, unsigned int r1r0); + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, bool isup, unsigned int r1r0); int mtk_pconf_spec_set_ies_smt_range(struct regmap *regmap, const struct mtk_pin_ies_smt_set *ies_smt_infos, unsigned int info_num, From patchwork Thu Feb 10 14:19:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12741984 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 68620C433F5 for ; Thu, 10 Feb 2022 14:22:01 +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=I0RWAvJe2CFX6/5mvH9DgUPdzF6LRNIaPorRWVz84j4=; b=ttT+/X1i4Uf1wq 4jveJkvXprKmnwdPEMS1IhLmR+yoPOxRu9Co2fV8x6ePaN01KORNFuigqJOCpGQFX5uEuMzguamKg ZR9Zot2p0lQ6xQfYs6C/I6bUFsKx8VkJgc2iN81rPG2yRA7kI2jN5j4Ulc2Hr/7Hk7Fll28VELjHH 0mzx/f70/x4rzH2VbJCjLnhOXL7h+bAa7NRZ4EA6SNlWIshO7PlEnHMSx67b0NHH7Lu6SPz5qLyw7 3nG7oMGARHznP7VeznFkHxFKUc2D+Lckgr2TlYOc22ycWGL0qjALGmf+PTBsohU72KsPs2iC03yRe xKQnZkRqy3E8k9790aUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAJL-0042DC-4y; Thu, 10 Feb 2022 14:20:39 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIAIO-0041lN-Mu; Thu, 10 Feb 2022 14:19:44 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id E0A3B1F46578 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1644502779; bh=57NHOvClgJm7JxVBdTIcEvBV3nuCjfG86wP9Y0a7m1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfL/COH0a5oZR/uHg1FmqsJFL40Wf7035LZVcE38Dj56hAdCnYxr5QcIUbD1WTWt4 Zgtkd/b7EdzXlCsvfpmqgVMDA0TmpxCU2xks1V8qGbJ9u8xiejMZHP5Rx0kFjZgT7O Kobm6NlCD0mYSWXcxKNlDrICfCoR+Rw+d2CvboJFFGRTjzT0wMQ/PLQ3xiRcILSQEf FAcV9A83DH0oapMNe05gKc+yAfVguXG9dHkNM85kAb/NEdpph2vT4O8iiBm0oPLj/z ERFK+NrBPAfNMyJxdlKUe1cGF5PG685jboeHMcJBF81TTxGUzfq3TBMQ6beDJUKQdG HBTvJYIkVNlwg== From: AngeloGioacchino Del Regno To: sean.wang@kernel.org Cc: linus.walleij@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH 5/5] pinctrl: mediatek: common-v1: Commonize spec_ies_smt_set callback Date: Thu, 10 Feb 2022 15:19:31 +0100 Message-Id: <20220210141931.291712-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220210141931.291712-1-angelogioacchino.delregno@collabora.com> References: <20220210141931.291712-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-20220210_061941_051485_0322BDCF X-CRM114-Status: GOOD ( 12.18 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All of the MediaTek pinctrl drivers registering with pinctrl-mtk-common that are offering a .spec_ies_smt_set() callback are declaring their own function which is doing exactly the same on all drivers: calling mtk_pconf_spec_set_ies_smt_range() with their struct and a simple check. Commonize this callback by adding the ies and smt structure pointers to struct mtk_pinctrl_devdata and changing the callback signature to take it. Removing the callback and checking for the existence of the spec_smt and/or spec_ies data would allow us to staticize the function mtk_pconf_spec_set_ies_smt_range(), but this solution was avoided as to keep flexibility, as some SoCs may need to perform a very different operation compared to what this commonized function is doing. Signed-off-by: AngeloGioacchino Del Regno Signed-off-by: Chen-Yu Tsai Reviewed-by: Chen-Yu Tsai --- drivers/pinctrl/mediatek/pinctrl-mt2701.c | 18 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt2712.c | 19 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt8127.c | 19 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt8167.c | 18 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt8173.c | 18 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt8365.c | 18 ++++-------- drivers/pinctrl/mediatek/pinctrl-mt8516.c | 18 ++++-------- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 29 +++++++++++++++---- drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 17 ++++++++--- 9 files changed, 71 insertions(+), 103 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2701.c b/drivers/pinctrl/mediatek/pinctrl-mt2701.c index 816de39858f8..d1583b4fdd9d 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2701.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2701.c @@ -429,18 +429,6 @@ static const struct mtk_pin_ies_smt_set mt2701_smt_set[] = { MTK_PIN_IES_SMT_SPEC(278, 278, 0xb70, 13), }; -static int mt2701_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt2701_ies_set, - ARRAY_SIZE(mt2701_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt2701_smt_set, - ARRAY_SIZE(mt2701_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_spec_pinmux_set mt2701_spec_pinmux[] = { MTK_PINMUX_SPEC(22, 0xb10, 3), MTK_PINMUX_SPEC(23, 0xb10, 4), @@ -501,10 +489,14 @@ static const struct mtk_pinctrl_devdata mt2701_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt2701_drv_grp), .pin_drv_grp = mt2701_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt2701_pin_drv), + .spec_ies = mt2701_ies_set, + .n_spec_ies = ARRAY_SIZE(mt2701_ies_set), .spec_pupd = mt2701_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt2701_spec_pupd), + .spec_smt = mt2701_smt_set, + .n_spec_smt = ARRAY_SIZE(mt2701_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt2701_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .spec_pinmux_set = mt2701_spec_pinmux_set, .spec_dir_set = mt2701_spec_dir_set, .dir_offset = 0x0000, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt2712.c b/drivers/pinctrl/mediatek/pinctrl-mt2712.c index b6182b06584b..b921068f9e69 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt2712.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt2712.c @@ -275,19 +275,6 @@ static const struct mtk_pin_ies_smt_set mt2712_ies_set[] = { MTK_PIN_IES_SMT_SPEC(207, 209, 0x8b0, 15) }; -static int mt2712_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, - int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt2712_ies_set, - ARRAY_SIZE(mt2712_ies_set), pin, align, value); - if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt2712_smt_set, - ARRAY_SIZE(mt2712_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_drv_group_desc mt2712_drv_grp[] = { /* 0E4E8SR 4/8/12/16 */ MTK_DRV_GRP(4, 16, 1, 2, 4), @@ -553,10 +540,14 @@ static const struct mtk_pinctrl_devdata mt2712_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt2712_drv_grp), .pin_drv_grp = mt2712_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt2712_pin_drv), + .spec_ies = mt2712_ies_set, + .n_spec_ies = ARRAY_SIZE(mt2712_ies_set), .spec_pupd = mt2712_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt2712_spec_pupd), + .spec_smt = mt2712_smt_set, + .n_spec_smt = ARRAY_SIZE(mt2712_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt2712_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0000, .pullen_offset = 0x0100, .pullsel_offset = 0x0200, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8127.c b/drivers/pinctrl/mediatek/pinctrl-mt8127.c index 9745d15f93ec..91c530e7b00e 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8127.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8127.c @@ -252,19 +252,6 @@ static const struct mtk_pin_ies_smt_set mt8127_smt_set[] = { MTK_PIN_IES_SMT_SPEC(142, 142, 0x920, 13), }; -static int mt8127_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8127_ies_set, - ARRAY_SIZE(mt8127_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8127_smt_set, - ARRAY_SIZE(mt8127_smt_set), pin, align, value); - return -EINVAL; -} - - static const struct mtk_pinctrl_devdata mt8127_pinctrl_data = { .pins = mtk_pins_mt8127, .npins = ARRAY_SIZE(mtk_pins_mt8127), @@ -272,10 +259,14 @@ static const struct mtk_pinctrl_devdata mt8127_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8127_drv_grp), .pin_drv_grp = mt8127_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8127_pin_drv), + .spec_ies = mt8127_ies_set, + .n_spec_ies = ARRAY_SIZE(mt8127_ies_set), .spec_pupd = mt8127_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt8127_spec_pupd), + .spec_smt = mt8127_smt_set, + .n_spec_smt = ARRAY_SIZE(mt8127_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt8127_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0000, .pullen_offset = 0x0100, .pullsel_offset = 0x0200, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8167.c b/drivers/pinctrl/mediatek/pinctrl-mt8167.c index 118ddcba18fc..825167f5d020 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8167.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8167.c @@ -285,18 +285,6 @@ static const struct mtk_pin_ies_smt_set mt8167_smt_set[] = { MTK_PIN_IES_SMT_SPEC(121, 124, 0xA10, 9), }; -static int mt8167_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8167_ies_set, - ARRAY_SIZE(mt8167_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8167_smt_set, - ARRAY_SIZE(mt8167_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_pinctrl_devdata mt8167_pinctrl_data = { .pins = mtk_pins_mt8167, .npins = ARRAY_SIZE(mtk_pins_mt8167), @@ -304,10 +292,14 @@ static const struct mtk_pinctrl_devdata mt8167_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8167_drv_grp), .pin_drv_grp = mt8167_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8167_pin_drv), + .spec_ies = mt8167_ies_set, + .n_spec_ies = ARRAY_SIZE(mt8167_ies_set), .spec_pupd = mt8167_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt8167_spec_pupd), + .spec_smt = mt8167_smt_set, + .n_spec_smt = ARRAY_SIZE(mt8167_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt8167_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0000, .pullen_offset = 0x0500, .pullsel_offset = 0x0600, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8173.c b/drivers/pinctrl/mediatek/pinctrl-mt8173.c index b34c9778e131..1d7d11a32e7d 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8173.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8173.c @@ -167,18 +167,6 @@ static const struct mtk_pin_ies_smt_set mt8173_ies_set[] = { MTK_PIN_IES_SMT_SPEC(133, 134, 0x910, 8) }; -static int mt8173_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8173_ies_set, - ARRAY_SIZE(mt8173_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8173_smt_set, - ARRAY_SIZE(mt8173_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_drv_group_desc mt8173_drv_grp[] = { /* 0E4E8SR 4/8/12/16 */ MTK_DRV_GRP(4, 16, 1, 2, 4), @@ -312,10 +300,14 @@ static const struct mtk_pinctrl_devdata mt8173_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8173_drv_grp), .pin_drv_grp = mt8173_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8173_pin_drv), + .spec_ies = mt8173_ies_set, + .n_spec_ies = ARRAY_SIZE(mt8173_ies_set), .spec_pupd = mt8173_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt8173_spec_pupd), + .spec_smt = mt8173_smt_set, + .n_spec_smt = ARRAY_SIZE(mt8173_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt8173_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0000, .pullen_offset = 0x0100, .pullsel_offset = 0x0200, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8365.c b/drivers/pinctrl/mediatek/pinctrl-mt8365.c index dbff7a831235..727c65221aef 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8365.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8365.c @@ -416,18 +416,6 @@ static const struct mtk_pin_ies_smt_set mt8365_smt_set[] = { MTK_PIN_IES_SMT_SPEC(144, 144, 0x480, 22), }; -static int mt8365_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8365_ies_set, - ARRAY_SIZE(mt8365_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8365_smt_set, - ARRAY_SIZE(mt8365_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = { .pins = mtk_pins_mt8365, .npins = ARRAY_SIZE(mtk_pins_mt8365), @@ -435,10 +423,14 @@ static const struct mtk_pinctrl_devdata mt8365_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8365_drv_grp), .pin_drv_grp = mt8365_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8365_pin_drv), + .spec_ies = mt8365_ies_set, + .n_spec_ies = ARRAY_SIZE(mt8365_ies_set), + .spec_smt = mt8365_smt_set, + .n_spec_smt = ARRAY_SIZE(mt8365_smt_set), .spec_pupd = mt8365_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt8365_spec_pupd), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt8365_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0140, .dout_offset = 0x00A0, .din_offset = 0x0000, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c index 8ad2006857c0..939a1932b8dc 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c @@ -285,18 +285,6 @@ static const struct mtk_pin_ies_smt_set mt8516_smt_set[] = { MTK_PIN_IES_SMT_SPEC(121, 124, 0xA10, 9), }; -static int mt8516_ies_smt_set(struct regmap *regmap, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg) -{ - if (arg == PIN_CONFIG_INPUT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8516_ies_set, - ARRAY_SIZE(mt8516_ies_set), pin, align, value); - else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE) - return mtk_pconf_spec_set_ies_smt_range(regmap, mt8516_smt_set, - ARRAY_SIZE(mt8516_smt_set), pin, align, value); - return -EINVAL; -} - static const struct mtk_pinctrl_devdata mt8516_pinctrl_data = { .pins = mtk_pins_mt8516, .npins = ARRAY_SIZE(mtk_pins_mt8516), @@ -304,10 +292,14 @@ static const struct mtk_pinctrl_devdata mt8516_pinctrl_data = { .n_grp_cls = ARRAY_SIZE(mt8516_drv_grp), .pin_drv_grp = mt8516_pin_drv, .n_pin_drv_grps = ARRAY_SIZE(mt8516_pin_drv), + .spec_ies = mt8516_ies_set, + .n_spec_ies = ARRAY_SIZE(mt8516_ies_set), .spec_pupd = mt8516_spec_pupd, .n_spec_pupd = ARRAY_SIZE(mt8516_spec_pupd), + .spec_smt = mt8516_smt_set, + .n_spec_smt = ARRAY_SIZE(mt8516_smt_set), .spec_pull_set = mtk_pctrl_spec_pull_set_samereg, - .spec_ies_smt_set = mt8516_ies_smt_set, + .spec_ies_smt_set = mtk_pconf_spec_set_ies_smt_range, .dir_offset = 0x0000, .pullen_offset = 0x0500, .pullsel_offset = 0x0600, diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 5e1d17512a0d..a515fdc43b85 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -131,7 +131,7 @@ static int mtk_pconf_set_ies_smt(struct mtk_pinctrl *pctl, unsigned pin, */ if (pctl->devdata->spec_ies_smt_set) { return pctl->devdata->spec_ies_smt_set(mtk_get_regmap(pctl, pin), - pin, pctl->devdata->port_align, value, arg); + pctl->devdata, pin, value, arg); } if (arg == PIN_CONFIG_INPUT_ENABLE) @@ -151,10 +151,27 @@ static int mtk_pconf_set_ies_smt(struct mtk_pinctrl *pctl, unsigned pin, } int mtk_pconf_spec_set_ies_smt_range(struct regmap *regmap, - const struct mtk_pin_ies_smt_set *ies_smt_infos, unsigned int info_num, - unsigned int pin, unsigned char align, int value) + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, int value, enum pin_config_param arg) { - unsigned int i, reg_addr, bit; + const struct mtk_pin_ies_smt_set *ies_smt_infos = NULL; + unsigned int i, info_num, reg_addr, bit; + + switch (arg) { + case PIN_CONFIG_INPUT_ENABLE: + ies_smt_infos = devdata->spec_ies; + info_num = devdata->n_spec_ies; + break; + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + ies_smt_infos = devdata->spec_smt; + info_num = devdata->n_spec_smt; + break; + default: + break; + }; + + if (!ies_smt_infos) + return -EINVAL; for (i = 0; i < info_num; i++) { if (pin >= ies_smt_infos[i].start && @@ -167,9 +184,9 @@ int mtk_pconf_spec_set_ies_smt_range(struct regmap *regmap, return -EINVAL; if (value) - reg_addr = ies_smt_infos[i].offset + align; + reg_addr = ies_smt_infos[i].offset + devdata->port_align; else - reg_addr = ies_smt_infos[i].offset + (align << 1); + reg_addr = ies_smt_infos[i].offset + (devdata->port_align << 1); bit = BIT(ies_smt_infos[i].bit); regmap_write(regmap, reg_addr, bit); diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index f7968a6ac563..6fe8564334c9 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -193,8 +193,12 @@ struct mtk_eint_offsets { * * @grp_desc: The driving group info. * @pin_drv_grp: The driving group for all pins. + * @spec_ies: Special pin setting for input enable + * @n_spec_ies: Number of entries in spec_ies * @spec_pupd: Special pull up/down setting * @n_spec_pupd: Number of entries in spec_pupd + * @spec_smt: Special pin setting for schmitt + * @n_spec_smt: Number of entries in spec_smt * @spec_pull_set: Each SoC may have special pins for pull up/down setting, * these pins' pull setting are very different, they have separate pull * up/down bit, R0 and R1 resistor bit, so they need special pull setting. @@ -233,13 +237,18 @@ struct mtk_pinctrl_devdata { unsigned int n_grp_cls; const struct mtk_pin_drv_grp *pin_drv_grp; unsigned int n_pin_drv_grps; + const struct mtk_pin_ies_smt_set *spec_ies; + unsigned int n_spec_ies; const struct mtk_pin_spec_pupd_set_samereg *spec_pupd; unsigned int n_spec_pupd; + const struct mtk_pin_ies_smt_set *spec_smt; + unsigned int n_spec_smt; int (*spec_pull_set)(struct regmap *regmap, const struct mtk_pinctrl_devdata *devdata, unsigned int pin, bool isup, unsigned int r1r0); - int (*spec_ies_smt_set)(struct regmap *reg, unsigned int pin, - unsigned char align, int value, enum pin_config_param arg); + int (*spec_ies_smt_set)(struct regmap *reg, + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, int value, enum pin_config_param arg); void (*spec_pinmux_set)(struct regmap *reg, unsigned int pin, unsigned int mode); void (*spec_dir_set)(unsigned int *reg_addr, unsigned int pin); @@ -289,8 +298,8 @@ int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap, unsigned int pin, bool isup, unsigned int r1r0); int mtk_pconf_spec_set_ies_smt_range(struct regmap *regmap, - const struct mtk_pin_ies_smt_set *ies_smt_infos, unsigned int info_num, - unsigned int pin, unsigned char align, int value); + const struct mtk_pinctrl_devdata *devdata, + unsigned int pin, int value, enum pin_config_param arg); extern const struct dev_pm_ops mtk_eint_pm_ops;