From: Peng Fan <peng.fan@oss.nxp.com>
To: Eric Chung <eric.chung@riscstar.com>
Cc: u-boot-spacemit@groups.io, u-boot@lists.denx.de,
Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
Huan Zhou <pericycle.cc@gmail.com>,
Raymond Mao <raymond.mao@riscstar.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Bhimeswararao Matsa <bhimeswararao.matsa@gmail.com>,
Tanmay Kathpalia <tanmay.kathpalia@altera.com>,
Kaustabh Chakraborty <kauschluss@disroot.org>,
Han Xu <han.xu@nxp.com>, Yanir Levin <yanir.levin@tandemg.com>,
Christoph Stoidner <c.stoidner@phytec.de>,
Balsundar Ponnusamy <balsundar.ponnusamy@altera.com>,
Daniel Palmer <daniel@thingy.jp>, Anshul Dalal <anshuld@ti.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Angelo Dureghello <angelo@kernel-space.org>,
Johan Jonker <jbx6244@gmail.com>, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
Guodong Xu <guodong.xu@riscstar.com>
Subject: Re: [PATCH v2 v2 3/8] mmc: k1: add sdhci platform driver
Date: Tue, 30 Jun 2026 10:52:55 +0800 [thread overview]
Message-ID: <akMvh1LxFlNBgT9u@shlinux89> (raw)
In-Reply-To: <20260629-m4-v2-3-cbc91c6b83d8@riscstar.com>
On Mon, Jun 29, 2026 at 11:51:17PM +0800, Eric Chung wrote:
>Add SDHCI platform driver support for SpacemiT K1 SoC. This driver
>implements the necessary platform-specific operations for the SDHCI
>controller, enabling MMC/SD card functionality on K1-based platforms.
>
>Signed-off-by: Eric Chung <eric.chung@riscstar.com>
>
>---
>v2:
>- Enable ADMA mode support.
>- Use CMD23 for multi-block read/write.
>- Move ASR/AIB register into pinctrl driver.
>- Correct pinctrl state from "fast" to "uhs".
>- Migrate tuning support from the spacemit linux driver.
>---
> drivers/mmc/Kconfig | 7 +
> drivers/mmc/Makefile | 1 +
> drivers/mmc/spacemit_sdhci.c | 681 +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 689 insertions(+)
>
>diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>index 131be3106a1..f05b376ab72 100644
>--- a/drivers/mmc/Kconfig
>+++ b/drivers/mmc/Kconfig
>@@ -722,6 +722,13 @@ config MMC_SDHCI_SNPS
>
> If unsure, say N.
>
>+config MMC_SDHCI_SPACEMIT
>+ bool "Spacemit SDHCI controller"
>+ depends on MMC_SDHCI
>+ help
>+ Support for Secure Digital Host Controller Interface (SDHCI) on
>+ Spacemit K1 SoC.
>+
> config MMC_SDHCI_STI
> bool "SDHCI support for STMicroelectronics SoC"
> depends on MMC_SDHCI && OF_CONTROL && ARCH_STI
>diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
>index a23336d7d8d..aa05cec23be 100644
>--- a/drivers/mmc/Makefile
>+++ b/drivers/mmc/Makefile
>@@ -71,6 +71,7 @@ obj-$(CONFIG_MMC_SDHCI_ROCKCHIP) += rockchip_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_ADI) += adi_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_S5P) += s5p_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_SNPS) += snps_sdhci.o
>+obj-$(CONFIG_MMC_SDHCI_SPACEMIT) += spacemit_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_STI) += sti_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_TANGIER) += tangier_sdhci.o
> obj-$(CONFIG_MMC_SDHCI_TEGRA) += tegra_mmc.o
>diff --git a/drivers/mmc/spacemit_sdhci.c b/drivers/mmc/spacemit_sdhci.c
>new file mode 100644
>index 00000000000..c905c33b2af
>--- /dev/null
>+++ b/drivers/mmc/spacemit_sdhci.c
>@@ -0,0 +1,681 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * Driver for Spacemit K1 Mobile Storage Host Controller
>+ *
>+ * Copyright (C) 2023-2026 Spacemit Inc.
>+ * Copyright (C) 2026 RISCstar Ltd.
>+ */
>+
>+#define LOG_CATEGORY UCLASS_MMC
>+
>+#include <clk.h>
>+#include <dm.h>
>+#include <fdtdec.h>
>+#include <log.h>
>+#include <malloc.h>
>+#include <sdhci.h>
>+#include <reset-uclass.h>
>+#include <mapmem.h>
>+#include <dm/pinctrl.h>
>+#include <linux/libfdt.h>
>+#include <linux/delay.h>
>+#include <power/regulator.h>
>+
>+#define FIELD_PREP(mask, val) (((val) << __ffs(mask)) & (mask))
Please use the one in bitfield.h
>+
>+
>+struct spacemit_sdhci_plat {
>+ struct mmc_config cfg;
>+ struct mmc mmc;
>+ struct reset_ctl_bulk resets;
>+ struct clk_bulk clks;
>+};
>+
>+struct spacemit_sdhci_priv {
>+ struct sdhci_host host;
>+};
>+
...
>+
>+ /* Wait for DLL lock */
>+ i = 0;
>+ while (i++ < 100) {
>+ if (sdhci_readl(host, SPACEMIT_SDHC_PHY_DLLSTS) & SDHC_DLL_LOCK_STATE)
>+ break;
>+ udelay(10);
Please use poll timeout.
>+ }
>+ if (i == 100) {
>+ log_err("%s: phy dll lock timeout\n", host->name);
>+ return -ETIMEDOUT;
>+ }
>+}
>+
>+static const struct udevice_id spacemit_sdhci_ids[] = {
>+ {
>+ .compatible = "spacemit,k1-sdhci",
>+ .data = 0,
No need set .data as 0.
>+ }, {
>+ }
>+};
Regards
Peng
next prev parent reply other threads:[~2026-06-30 2:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 15:51 [PATCH v2 0/8] spacemit mmc driver Eric Chung
2026-06-29 15:51 ` [PATCH v2 v2 1/8] pinctrl: k1: add IO power domain configuration support Eric Chung
2026-06-30 8:55 ` Yao Zi
2026-06-29 15:51 ` [PATCH v2 v2 2/8] mmc: sdhci: add quirk to enable CMD23 for multi-block transfers Eric Chung
2026-06-30 2:47 ` Peng Fan
2026-06-29 15:51 ` [PATCH v2 v2 3/8] mmc: k1: add sdhci platform driver Eric Chung
2026-06-30 2:52 ` Peng Fan [this message]
2026-06-29 15:51 ` [PATCH v2 v2 4/8] dts: k1: add SD card support in u-boot overlay Eric Chung
2026-06-30 2:56 ` Peng Fan
2026-06-29 15:51 ` [PATCH v2 v2 5/8] configs: k1: enable SD and eMMC support Eric Chung
2026-06-29 15:51 ` [PATCH v2 v2 6/8] doc: spacemit: flash on K1 SoC based boards Eric Chung
2026-06-29 15:51 ` [PATCH v2 v2 7/8] config: k1: enable ENV support for eMMC Eric Chung
2026-06-29 15:51 ` [PATCH v2 v2 8/8] spacemit: k1: load product name from environment variable Eric Chung
2026-06-30 2:55 ` Peng Fan
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=akMvh1LxFlNBgT9u@shlinux89 \
--to=peng.fan@oss.nxp.com \
--cc=angelo@kernel-space.org \
--cc=anshuld@ti.com \
--cc=balsundar.ponnusamy@altera.com \
--cc=bastien.curutchet@bootlin.com \
--cc=bhimeswararao.matsa@gmail.com \
--cc=c.stoidner@phytec.de \
--cc=daniel@thingy.jp \
--cc=eric.chung@riscstar.com \
--cc=guodong.xu@riscstar.com \
--cc=han.xu@nxp.com \
--cc=jbx6244@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=kauschluss@disroot.org \
--cc=peng.fan@nxp.com \
--cc=pericycle.cc@gmail.com \
--cc=raymond.mao@riscstar.com \
--cc=rick@andestech.com \
--cc=semen.protsenko@linaro.org \
--cc=tanmay.kathpalia@altera.com \
--cc=trini@konsulko.com \
--cc=u-boot-spacemit@groups.io \
--cc=u-boot@lists.denx.de \
--cc=yanir.levin@tandemg.com \
--cc=ycliang@andestech.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.