[openwrt/openwrt] airoha: an7581: replace eMMC support with upstream version

LEDE Commits lede-commits at lists.infradead.org
Mon Jan 27 03:03:56 PST 2025


ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b7edf88b0fe15b32be802c7de54036ff8e66dcc1

commit b7edf88b0fe15b32be802c7de54036ff8e66dcc1
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Mon Jan 27 12:02:24 2025 +0100

    airoha: an7581: replace eMMC support with upstream version
    
    Replace eMMC support with upstream version where we declare dummy clock
    and dummy regulator instead of a specific compatible. Also drop the
    downstream patch for it.
    
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 target/linux/airoha/an7581/config-6.6              |   2 +
 target/linux/airoha/dts/an7581-evb-emmc.dts        |   3 +-
 target/linux/airoha/dts/an7581.dtsi                |  23 +++-
 ...mc-mtk-sd-add-support-for-AN7581-MMC-Host.patch | 136 ---------------------
 4 files changed, 24 insertions(+), 140 deletions(-)

diff --git a/target/linux/airoha/an7581/config-6.6 b/target/linux/airoha/an7581/config-6.6
index d86aa8bbbb..812dcd76bb 100644
--- a/target/linux/airoha/an7581/config-6.6
+++ b/target/linux/airoha/an7581/config-6.6
@@ -496,6 +496,8 @@ CONFIG_RATIONAL=y
 CONFIG_RCU_CPU_STALL_TIMEOUT=21
 CONFIG_REGMAP=y
 CONFIG_REGMAP_MMIO=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_RELOCATABLE=y
 CONFIG_RESET_CONTROLLER=y
 CONFIG_RFS_ACCEL=y
diff --git a/target/linux/airoha/dts/an7581-evb-emmc.dts b/target/linux/airoha/dts/an7581-evb-emmc.dts
index 91d7977795..26d446e2a1 100644
--- a/target/linux/airoha/dts/an7581-evb-emmc.dts
+++ b/target/linux/airoha/dts/an7581-evb-emmc.dts
@@ -100,8 +100,9 @@
 };
 
 &mmc0 {
-	pinctrl-names = "default";
+	pinctrl-names = "default", "state_uhs";
 	pinctrl-0 = <&mmc_pins>;
+	pinctrl-1 = <&mmc_pins>;
 	status = "okay";
 
 	#address-cells = <1>;
diff --git a/target/linux/airoha/dts/an7581.dtsi b/target/linux/airoha/dts/an7581.dtsi
index 2b4c1b716b..762a6aa1a8 100644
--- a/target/linux/airoha/dts/an7581.dtsi
+++ b/target/linux/airoha/dts/an7581.dtsi
@@ -332,6 +332,21 @@
 		};
 	};
 
+	clk25m: oscillator {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <25000000>;
+		clock-output-names = "clkxtal";
+	};
+
+	vmmc_3v3: regulator-vmmc-3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "vmmc";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-always-on;
+	};
+
 	soc {
 		compatible = "simple-bus";
 		#address-cells = <2>;
@@ -535,13 +550,15 @@
 		};
 
 		mmc0: mmc at 1fa0e000 {
-			compatible = "airoha,an7581-mmc";
+			compatible = "mediatek,mt7622-mmc";
 			reg = <0x0 0x1fa0e000 0x0 0x1000>,
 			      <0x0 0x1fa0c000 0x0 0x60>;
 			interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&scuclk EN7581_CLK_EMMC>;
-			clock-names = "source";			bus-width = <4>;
+			clocks = <&scuclk EN7581_CLK_EMMC>, <&clk25m>;
+			clock-names = "source", "hclk";
+			bus-width = <4>;
 			max-frequency = <52000000>;
+			vmmc-supply = <&vmmc_3v3>;
 			disable-wp;
 			cap-mmc-highspeed;
 			non-removable;
diff --git a/target/linux/airoha/patches-6.6/111-mmc-mtk-sd-add-support-for-AN7581-MMC-Host.patch b/target/linux/airoha/patches-6.6/111-mmc-mtk-sd-add-support-for-AN7581-MMC-Host.patch
deleted file mode 100644
index d116bb9ee0..0000000000
--- a/target/linux/airoha/patches-6.6/111-mmc-mtk-sd-add-support-for-AN7581-MMC-Host.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-From f38f16925e1aa7cc71f63d3d52997b1c98cd7781 Mon Sep 17 00:00:00 2001
-From: Christian Marangi <ansuelsmth at gmail.com>
-Date: Wed, 11 Dec 2024 11:27:10 +0100
-Subject: [PATCH 4/4] mmc: mtk-sd: add support for AN7581 MMC Host
-
-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 at gmail.com>
----
- drivers/mmc/host/mtk-sd.c | 55 ++++++++++++++++++++++++++++++++-------
- 1 file changed, 46 insertions(+), 9 deletions(-)
-
---- a/drivers/mmc/host/mtk-sd.c
-+++ b/drivers/mmc/host/mtk-sd.c
-@@ -615,6 +615,19 @@ static const struct mtk_mmc_compatible m
- 	.stop_clk_fix = 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,
-+	.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},
-@@ -627,7 +640,7 @@ static const struct of_device_id msdc_of
- 	{ .compatible = "mediatek,mt8173-mmc", .data = &mt8173_compat},
- 	{ .compatible = "mediatek,mt8183-mmc", .data = &mt8183_compat},
- 	{ .compatible = "mediatek,mt8516-mmc", .data = &mt8516_compat},
--
-+	{ .compatible = "airoha,an7581-mmc", .data = &an7581_compat},
- 	{}
- };
- MODULE_DEVICE_TABLE(of, msdc_of_ids);
-@@ -1479,6 +1492,10 @@ static int msdc_ops_switch_volt(struct m
- 	struct msdc_host *host = mmc_priv(mmc);
- 	int ret;
- 
-+	/* Skip setting supply if not supported */
-+	if (!mmc->supply.vqmmc)
-+		return 0;
-+
- 	if (!IS_ERR(mmc->supply.vqmmc)) {
- 		if (ios->signal_voltage != MMC_SIGNAL_VOLTAGE_330 &&
- 		    ios->signal_voltage != MMC_SIGNAL_VOLTAGE_180) {
-@@ -1578,7 +1595,9 @@ static void msdc_enable_sdio_irq(struct
- 				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);
- 		}
-@@ -1886,6 +1905,10 @@ static void msdc_ops_set_ios(struct mmc_
- 
- 	msdc_set_buswidth(host, ios->bus_width);
- 
-+	/* Skip regulator if not supported */
-+	if (!mmc->supply.vmmc)
-+		goto skip_regulator;
-+
- 	/* Suspend/Resume will do power off/on */
- 	switch (ios->power_mode) {
- 	case MMC_POWER_UP:
-@@ -1921,6 +1944,7 @@ static void msdc_ops_set_ios(struct mmc_
- 		break;
- 	}
- 
-+skip_regulator:
- 	if (host->mclk != ios->clock || host->timing != ios->timing)
- 		msdc_set_mclk(host, ios->timing, ios->clock);
- }
-@@ -2617,9 +2641,12 @@ static int msdc_of_clock_parse(struct pl
- 	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))
-@@ -2731,10 +2758,13 @@ static int msdc_drv_probe(struct platfor
- 		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 ? */
-@@ -2815,6 +2845,12 @@ static int msdc_drv_probe(struct platfor
- 		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) {




More information about the lede-commits mailing list