From: Christian Marangi <ansuelsmth@gmail.com>
To: Chaotian Jing <chaotian.jing@mediatek.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Wenbin Mei <wenbin.mei@mediatek.com>,
linux-mmc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, upstream@airoha.com
Cc: Christian Marangi <ansuelsmth@gmail.com>
Subject: [PATCH v2 2/2] mmc: mtk-sd: add support for AN7581 MMC Host
Date: Mon, 20 Jan 2025 19:47:02 +0100 [thread overview]
Message-ID: <20250120184728.18325-2-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20250120184728.18325-1-ansuelsmth@gmail.com>
Add support for AN7581 MMC Host. The MMC Host controller is based on
mt7622 with the difference of not having regulator supply and state_uhs
pins and hclk clock.
Some minor fixes are applied to check if the state_uhs pins are defined
and make hclk optional for the new airoha compatible.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
Changes v2:
- Drop redundant if condition where regulator is not supported
- Correctly set pin in msdc_ops_switch_volt
drivers/mmc/host/mtk-sd.c | 59 +++++++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index efb0d2d5716b..f76f20502409 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -666,6 +666,20 @@ static const struct mtk_mmc_compatible mt8196_compat = {
.support_new_rx = true,
};
+static const struct mtk_mmc_compatible an7581_compat = {
+ .clk_div_bits = 12,
+ .recheck_sdio_irq = true,
+ .hs400_tune = false,
+ .pad_tune_reg = MSDC_PAD_TUNE0,
+ .async_fifo = true,
+ .data_tune = true,
+ .busy_check = true,
+ .stop_clk_fix = true,
+ .stop_dly_sel = 3,
+ .enhance_rx = true,
+ .support_64g = false,
+};
+
static const struct of_device_id msdc_of_ids[] = {
{ .compatible = "mediatek,mt2701-mmc", .data = &mt2701_compat},
{ .compatible = "mediatek,mt2712-mmc", .data = &mt2712_compat},
@@ -680,7 +694,7 @@ static const struct of_device_id msdc_of_ids[] = {
{ .compatible = "mediatek,mt8183-mmc", .data = &mt8183_compat},
{ .compatible = "mediatek,mt8196-mmc", .data = &mt8196_compat},
{ .compatible = "mediatek,mt8516-mmc", .data = &mt8516_compat},
-
+ { .compatible = "airoha,an7581-mmc", .data = &an7581_compat},
{}
};
MODULE_DEVICE_TABLE(of, msdc_of_ids);
@@ -1614,12 +1628,15 @@ static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
return ret;
}
- /* Apply different pinctrl settings for different signal voltage */
- if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
- pinctrl_select_state(host->pinctrl, host->pins_uhs);
- else
- pinctrl_select_state(host->pinctrl, host->pins_default);
}
+
+ /* Apply different pinctrl settings for different signal voltage */
+ if (!IS_ERR(mmc->supply.vqmmc) &&
+ ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
+ pinctrl_select_state(host->pinctrl, host->pins_uhs);
+ else
+ pinctrl_select_state(host->pinctrl, host->pins_default);
+
return 0;
}
@@ -1699,7 +1716,9 @@ static void msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
dev_dbg(host->dev, "SDIO eint irq: %d!\n", host->eint_irq);
}
- pinctrl_select_state(host->pinctrl, host->pins_uhs);
+ /* Skip setting uhs pins if not supported */
+ if (host->pins_uhs)
+ pinctrl_select_state(host->pinctrl, host->pins_uhs);
} else {
dev_pm_clear_wake_irq(host->dev);
}
@@ -2816,9 +2835,12 @@ static int msdc_of_clock_parse(struct platform_device *pdev,
if (IS_ERR(host->src_clk))
return PTR_ERR(host->src_clk);
- host->h_clk = devm_clk_get(&pdev->dev, "hclk");
- if (IS_ERR(host->h_clk))
- return PTR_ERR(host->h_clk);
+ /* AN7581 SoC doesn't have hclk */
+ if (!device_is_compatible(&pdev->dev, "airoha,an7581-mmc")) {
+ host->h_clk = devm_clk_get(&pdev->dev, "hclk");
+ if (IS_ERR(host->h_clk))
+ return PTR_ERR(host->h_clk);
+ }
host->bus_clk = devm_clk_get_optional(&pdev->dev, "bus_clk");
if (IS_ERR(host->bus_clk))
@@ -2926,10 +2948,13 @@ static int msdc_drv_probe(struct platform_device *pdev)
return PTR_ERR(host->pins_default);
}
- host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
- if (IS_ERR(host->pins_uhs)) {
- dev_err(&pdev->dev, "Cannot find pinctrl uhs!\n");
- return PTR_ERR(host->pins_uhs);
+ /* AN7581 doesn't have state_uhs pins */
+ if (!device_is_compatible(&pdev->dev, "airoha,an7581-mmc")) {
+ host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
+ if (IS_ERR(host->pins_uhs)) {
+ dev_err(&pdev->dev, "Cannot find pinctrl uhs!\n");
+ return PTR_ERR(host->pins_uhs);
+ }
}
/* Support for SDIO eint irq ? */
@@ -3010,6 +3035,12 @@ static int msdc_drv_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Cannot ungate clocks!\n");
goto release_clk;
}
+
+ /* AN7581 without regulator require tune to OCR values */
+ if (device_is_compatible(&pdev->dev, "airoha,an7581-mmc") &&
+ !mmc->ocr_avail)
+ mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+
msdc_init_hw(host);
if (mmc->caps2 & MMC_CAP2_CQE) {
--
2.47.1
next prev parent reply other threads:[~2025-01-20 18:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 18:47 [PATCH v2 1/2] dt-bindings: mmc: mtk-sd: Add eMMC for AN7581 Christian Marangi
2025-01-20 18:47 ` Christian Marangi [this message]
2025-01-21 7:59 ` [PATCH v2 2/2] mmc: mtk-sd: add support for AN7581 MMC Host Krzysztof Kozlowski
2025-01-27 11:41 ` Christian Marangi
2025-01-27 15:15 ` Ulf Hansson
2025-01-20 20:29 ` [PATCH v2 1/2] dt-bindings: mmc: mtk-sd: Add eMMC for AN7581 Rob Herring (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250120184728.18325-2-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chaotian.jing@mediatek.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=upstream@airoha.com \
--cc=wenbin.mei@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).