Add mmc driver for Sunplus SP7021 SOC
Subsystems (3)
Tony Huang
maintainerv10 cover Add mmc driver for Sunplus SP7021 SOC
This is a patch series for mmc driver for Sunplus SP7021 SOC.
Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD card and etc.) into a single chip. It is designed for industrial control.
Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html
Tony Huang (2):
dt-binding: mmc: Add mmc yaml file for Sunplus SP7021
mmc: Add mmc driver for Sunplus SP7021
.../devicetree/bindings/mmc/sunplus,mmc.yaml | 62 ++ MAINTAINERS | 7 + drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sunplus-mmc.c | 959 +++++++++++++++++++++ 5 files changed, 1038 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml create mode 100644 drivers/mmc/host/sunplus-mmc.c
Signature · 1 line
2.7.4
Tony Huang
maintainerPATCH v10 1/2 dt-binding: mmc: Add mmc yaml file for Sunplus SP7021
Add MMC YAML file for Sunplus SP7021.
---
Changes in v5:
- Addressed comments from Krzysztof.
Changes in v6:
- Addressed comments from Krzysztof.
- To substitute MMC for mmc. To substitute YMAL for ymal.
- Remove max-frequency.
- Fixed wrong file name.
Changes in v7:
-No change.
Changes in v8:
-No change.
Changes in v9:
-No change.
Changes in v10:
-No change.
.../devicetree/bindings/mmc/sunplus,mmc.yaml | 62 ++++++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) Sunplus Ltd. Co. 2021 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mmc/sunplus,mmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sunplus MMC Controller + +maintainers: + - Tony Huang <[email protected]> + - Li-hao Kuo <[email protected]> + +allOf: + - $ref: "mmc-controller.yaml" + +properties: + compatible: + enum: + - sunplus,sp7021-mmc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - resets + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + mmc0: mmc@9c003b00 { + compatible = "sunplus,sp7021-mmc"; + reg = <0x9c003b00 0x180>; + interrupts = <20 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clkc 0x4e>; + resets = <&rstc 0x3e>; + bus-width = <8>; + max-frequency = <52000000>; + non-removable; + disable-wp; + cap-mmc-highspeed; + mmc-ddr-3_3v; + no-sdio; + no-sd; + }; +
MAINTAINERS +6 -0
@@ -18869,6 +18869,12 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/dlink/sundance.c +SUNPLUS MMC DRIVER +M: Tony Huang <[email protected]> +M: Li-hao Kuo <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml + SUNPLUS OCOTP DRIVER M: Vincent Shih <[email protected]> S: Maintained
Signature · 1 line
2.7.4
Tony Huang
maintainerPATCH v10 2/2 mmc: Add mmc driver for Sunplus SP7021
In reply to Tony HuangThis is a patch for mmc driver for Sunplus SP7021 SOC. Supports eMMC 4.41 DDR 104MB/s speed mode.
---
Changes in v5:
- Addressed comments from Krzysztof.
- Remove the relevant sdcard code.
- Submit the emmc code only.
Changes in v6:
- Addressed comments from Arnd.
- Use SYSTEM_SLEEP_PM_OPS instead of SET_SYSTEM_SLEEP_PM_OPS.
- Use RUNTIME_PM_OPS instead of SET_RUNTIME_PM_OPS.
- Remove #ifdef check.
- Fixed mutex lock and unlock imbalance issue.
Changes in v7:
- Addressed comments from kernel test robot.
- Remove unused vairable.
- Add previous prototype.
- Addressed make error and warning in kernel 5.18-rc1.
Changes in v8:
- Addressed comments from Uffe.
Changes in v9:
- Addressed comments from Uffe.
Changes in v10:
- Addressed comments from Uffe.
- Addressed MMC test failed.
MAINTAINERS | 1 + drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sunplus-mmc.c | 959 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 970 insertions(+) create mode 100644 drivers/mmc/host/sunplus-mmc.c
MAINTAINERS +1 -0
@@ -18874,6 +18874,7 @@ M: Tony Huang <[email protected]> M: Li-hao Kuo <[email protected]> S: Maintained F: Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml +F: drivers/mmc/host/sunplus-mmc.c SUNPLUS OCOTP DRIVER M: Vincent Shih <[email protected]>
drivers/mmc/host/Kconfig +9 -0
@@ -14,6 +14,15 @@ config MMC_DEBUG added host drivers please don't invent their private macro for debugging. +config MMC_SUNPLUS + tristate "Sunplus SP7021 MMC Controller" + depends on ARCH_SUNPLUS || COMPILE_TEST + help + If you say yes here, you will get support for eMMC host interface + on Sunplus SoCs. + + If unsure, say N + config MMC_ARMMMCI tristate "ARM AMBA Multimedia Card Interface support" depends on ARM_AMBA
drivers/mmc/host/Makefile +1 -0
@@ -97,6 +97,7 @@ obj-$(CONFIG_MMC_SDHCI_MICROCHIP_PIC32) += sdhci-pic32.o obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o obj-$(CONFIG_MMC_SDHCI_OMAP) += sdhci-omap.o obj-$(CONFIG_MMC_SDHCI_SPRD) += sdhci-sprd.o +obj-$(CONFIG_MMC_SUNPLUS) += sunplus-mmc.o obj-$(CONFIG_MMC_CQHCI) += cqhci.o cqhci-y += cqhci-core.o cqhci-$(CONFIG_MMC_CRYPTO) += cqhci-crypto.o
drivers/mmc/host/sunplus-mmc.c new file +959 -0
959 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v10 2/2] mmc: Add mmc driver for Sunplus SP7021
Quoted 4 lines · Tony Huang
This is a patch for mmc driver for Sunplus SP7021 SOC. Supports eMMC 4.41 DDR 104MB/s speed mode.
Signed-off-by Tony Huang <[email protected]>
Looks ok to me me overall.
Just one more thing I noticed:
Quoted 1 line
+#define
SPMMC_TIMEOUT500000
...
Quoted 16 lines
drivers/mmc/host/sunplus-mmc.c new file +5
-0+static inline int spmmc_wait_finish (struct spmmc_host *host) +{ +u32 state; + + return readl_poll_timeout_atomic(host->base + SPMMC_SD_STATE_REG,state,
drivers/mmc/host/sunplus-mmc.c new file +4
-0+ (state & SPMMC_SDSTATE_FINISH), 1, SPMMC_TIMEOUT); +} + +static inline int spmmc_wait_sdstatus(struct spmmc_host *host,unsigned int
status_bit)drivers/mmc/host/sunplus-mmc.c new file +4
-0+{ +u32 status; + + return readl_poll_timeout_atomic(host->base + SPMMC_SD_STATUS_REG,status,
Review
Quoted 2 lines
(quoted diff) +2
-0+ (status & status_bit), 1, SPMMC_TIMEOUT); +}
500ms seems like an awfully long time for a busy-wait, I wonder if this could be improved in some way. Is this always called from atomic context?
If not, any callers from non-atomic context could use readl_poll_timeout() instead, or maybe there could be a shorter timeout in atomic context, with a fallback to a non-atomic workqueue if that times out, so only the MMC access will stall but not the entire system.
The same problem does appear to be in dw_mmc.c and mtk-sd.c but not in sdhci*.c, so I don't know if this is avoidable.
Arnd
黃懷厚
maintainerRe: [PATCH v10 2/2] mmc: Add mmc driver for Sunplus SP7021
Dear Arnd, Ulf:
Arnd Bergmann <[email protected]> 於 2022年10月17日 週一 下午3:25寫道:
Quoted 37 lines · Tony Huang
Quoted 4 lines
This is a patch for mmc driver for Sunplus SP7021 SOC. Supports eMMC 4.41 DDR 104MB/s speed mode.
Signed-off-by Tony Huang <[email protected]>Looks ok to me me overall.
Acked-by Arnd Bergmann <[email protected]>Just one more thing I noticed:
Quoted 1 line
+#define
SPMMC_TIMEOUT500000...
Quoted 16 lines
drivers/mmc/host/sunplus-mmc.c new file +5
-0+static inline int spmmc_wait_finish (struct spmmc_host *host) +{ +u32 state; + + return readl_poll_timeout_atomic(host->base + SPMMC_SD_STATE_REG,state,
drivers/mmc/host/sunplus-mmc.c new file +4
-0+ (state & SPMMC_SDSTATE_FINISH), 1, SPMMC_TIMEOUT); +} + +static inline int spmmc_wait_sdstatus(struct spmmc_host *host,unsigned int
status_bit)drivers/mmc/host/sunplus-mmc.c new file +4
-0+{ +u32 status; + + return readl_poll_timeout_atomic(host->base + SPMMC_SD_STATUS_REG,status,
Review
Quoted 2 lines
(quoted diff) +2
-0+ (status & status_bit), 1, SPMMC_TIMEOUT); +}500ms seems like an awfully long time for a busy-wait, I wonder if this could be improved in some way. Is this always called from atomic context?
Quoted 5 lines
If not, any callers from non-atomic context could use
readl_poll_timeout()instead, or maybe there could be a shorter timeout in atomic context, with a fallback to a non-atomic workqueue if that times out, so only the MMC access will stall but not the entire system.
OK, I would use real_poll_timeout() instead. Because I see "BUG: scheduling while atomic" issue before. I have solved this problem.
Quoted 5 lines
The same problem does appear to be in
dw_mmc.candmtk-sd.cbut not in sdhci*.c, so I don't know if this is avoidable.Arnd