Add mmc driver for Sunplus SP7021 SOC
Subsystems (3)
Tony Huang
maintainerv5 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 | 64 ++ MAINTAINERS | 7 + drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sunplus-mmc.c | 1212 ++++++++++++++++++++ 5 files changed, 1293 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 v5 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.
.../devicetree/bindings/mmc/sunplus,mmc.yaml | 64 ++++++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +64 -0
@@ -0,0 +1,64 @@ +# 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 + + max-frequency: true + +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,mmc-v2"; + 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
@@ -18242,6 +18242,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/sunplu,mmc.yaml + SUPERH M: Yoshinori Sato <[email protected]> M: Rich Felker <[email protected]>
Signature · 1 line
2.7.4
Re: [PATCH v5 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus SP7021
Quoted 1 line · Tony Huang
Add mmc yaml file for Sunplus SP7021
s/mmc/MMC/
s/yaml/YAML/
And a full stop.
Please rebase your changes on recent Linux kernel, because you skip Cc-ing me all the time, so I assume you have some old Maintainers file.
Quoted 41 lines
Signed-off-by Tony Huang <[email protected]>---
Changes in v5:
- Addressed comments from Krzysztof..../devicetree/bindings/mmc/sunplus,mmc.yaml | 64 ++++++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sunplus,mmc.yamlDocumentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +24
-0@@ -0,0 +1,64 @@ +# 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 +
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +10
-0+ interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + max-frequency: true
I think you do not need this.
Quoted 35 lines
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +30
-0+ +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,mmc-v2"; + 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 +0
-0
MAINTAINERS L: [email protected] · line 18249
Quoted 8 lines
MAINTAINERS +5
-0@@ -18242,6 +18242,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/sunplu,mmc.yaml
I pointed this already for your v4.
MAINTAINERS L: [email protected] · line 18253
Quoted 4 lines
MAINTAINERS +1
-0+ SUPERH M: Yoshinori Sato <[email protected]> M: Rich Felker <[email protected]>
Best regards,
Krzysztof
RE: [PATCH v5 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus SP7021
Dear Krzysztof:
Quoted 6 lines
Quoted 1 line
Add mmc yaml file for Sunplus SP7021
s/mmc/MMC/
s/yaml/YAML/
And a full stop.
OK, I will modify it.
Quoted 3 lines
Please rebase your changes on recent Linux kernel, because you skip Cc-ing me all the time, so I assume you have some old Maintainers file.
OK, I will pay attention.
Quoted 47 lines
Quoted 7 lines
Signed-off-by Tony Huang <[email protected]>---
Changes in v5:
- Addressed comments from Krzysztof..../devicetree/bindings/mmc/sunplus,mmc.yaml | 64++++++++++++++++++++++
Quoted 39 lines
MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644
Documentation/devicetree/bindings/mmc/sunplus,mmc.yamlDocumentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +27
-0@@ -0,0 +1,64 @@ +# 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:
Quoted 9 lines
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml line 34
Quoted 6 lines
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +6
-0+ maxItems: 1 + + resets: + maxItems: 1 + + max-frequency: trueI think you do not need this.
OK, I will modify it.
Quoted 37 lines
Quoted 37 lines
Documentation/devicetree/bindings/mmc/sunplus,mmc.yaml new file +30
-0+ +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,mmc-v2"; + 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 +0
-0@@ -18242,6 +18242,12 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/dlink/sundance.c
Quoted 8 lines
MAINTAINERS L: [email protected] · line 18249
Quoted 5 lines
MAINTAINERS +5
-0+SUNPLUS MMC DRIVER +M: Tony Huang <[email protected]> +M: Li-hao Kuo <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/mmc/sunplu,mmc.yamlI pointed this already for your v4.
Sorry, I will modify it.
Tony Huang
maintainerPATCH v5 2/2 mmc: Add mmc driver for Sunplus SP7021
In reply to Tony HuangAdd mmc driver for Sunplus SP7021
---
Changes in v5:
- Addressed comments from Krzysztof.
- Remove the relevant sdcard code.
- Submit the emmc code only.
MAINTAINERS | 1 + drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sunplus-mmc.c | 1212 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1223 insertions(+) create mode 100644 drivers/mmc/host/sunplus-mmc.c
MAINTAINERS +1 -0
@@ -18247,6 +18247,7 @@ M: Tony Huang <[email protected]> M: Li-hao Kuo <[email protected]> S: Maintained F: Documentation/devicetree/bindings/mmc/sunplu,mmc.yaml +F: drivers/mmc/host/sunplus-mmc.c SUPERH M: Yoshinori Sato <[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 +1212 -0
1,212 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 2/2] mmc: Add mmc driver for Sunplus SP7021
Quoted 4 lines · Tony Huang
Add mmc driver for Sunplus SP7021
Signed-off-by Tony Huang <[email protected]>
There should be a description of the device in the changelog, not just the same text as the subject.
drivers/mmc/host/sunplus-mmc.c line 835
Quoted 10 lines
drivers/mmc/host/sunplus-mmc.c new file +10
-0+static void spmmc_request (struct mmc_host *mmc,struct mmc_request *mrq) +{ +struct spmmc_host *host =mmc_priv (mmc); +struct mmc_data *data; +struct mmc_command *cmd; +int ret; + + ret =mutex_lock_interruptible (&host->mrq_lock); +if (ret) +return ;
I don't think it's valid to just return here when you get a signal. If nothing can
handle the signal, doesn't it just hang?
It also appears that you don't release the mutex until the tasklet runs, but it is not valid to release a mutex from a different context.
You should get a warning about this when running a kernel with lockdep enabled at compile time. Please rework the locking to make this work.
drivers/mmc/host/sunplus-mmc.c line 1184
Quoted 9 lines
drivers/mmc/host/sunplus-mmc.c new file +9
-0+#endif /* ifdef CONFIG_PM_RUNTIME */ + +static const struct dev_pm_ops spmmc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume) +#ifdef CONFIG_PM_RUNTIME +SET_RUNTIME_PM_OPS (spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume,NULL ) +#endif +}; +#endif /* ifdef CONFIG_PM */
It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of the SET_ version, then you can remove all the #ifdef checks.
Arnd
RE: [PATCH v5 2/2] mmc: Add mmc driver for Sunplus SP7021
Dear Arnd:
Quoted 6 lines
Quoted 3 lines
Add mmc driver for Sunplus SP7021
Signed-off-by Tony Huang <[email protected]>There should be a description of the device in the changelog, not just the same text as the subject.
OK, I will add description.
Quoted 14 lines
drivers/mmc/host/sunplus-mmc.c line 835
Quoted 10 lines
drivers/mmc/host/sunplus-mmc.c new file +10
-0+static void spmmc_request (struct mmc_host *mmc,struct mmc_request +*mrq) { +struct spmmc_host *host =mmc_priv (mmc); +struct mmc_data *data; +struct mmc_command *cmd; +int ret; + + ret =mutex_lock_interruptible (&host->mrq_lock); +if (ret) +return ;I don't think it's valid to just return here when you get a signal. If nothing can handle the signal, doesn't it just hang?
Quoted 6 lines
It also appears that you don't release the mutex until the tasklet runs, but it is not valid to release a mutex from a different context.
You should get a warning about this when running a kernel with lockdep enabled at compile time. Please rework the locking to make this work.
Reomve code:
ret = mutex_lock_interruptible(&host->mrq_lock);
if (ret)
return;
Below is my modification:. mutex_lock(&host->mrq_lock);
Quoted 5 lines
drivers/mmc/host/sunplus-mmc.c
Quoted 4 lines
drivers/mmc/host/sunplus-mmc.c new file +4
-0+#endif /* ifdef CONFIG_PM_RUNTIME */ + +static const struct dev_pm_ops spmmc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend,
spmmc_pm_resume)
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+#ifdef CONFIG_PM_RUNTIME + SET_RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, +spmmc_pm_runtime_resume, NULL) #endif }; #endif /* ifdef CONFIG_PM*/
It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of the
SET_version, then you can remove all the #ifdef checks.
I use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS.
Compile shows error. Error: implicit declaration of function ? ? SYSTEM_SLEEP_PM_OPS? ? Did you mean ? ? SET_SYSTEM_SLEEP_PM_OPS? ? [-Werror=implicit-function-declaration]
I reference other mmc driver.
Below is my modification:
Compiler is pass.
#ifdef CONFIG_PM_SLEEP
static int spmmc_pm_suspend(struct device *dev)
{
pm_runtime_force_suspend(dev);
return 0;
}
static int spmmc_pm_resume(struct device *dev)
{
pm_runtime_force_resume(dev);
return 0;
}
#endif
#ifdef CONFIG_PM
static int spmmc_pm_runtime_suspend(struct device *dev)
{
struct spmmc_host *host;
host = dev_get_drvdata(dev);
clk_disable(host->clk);
return 0;
}
static int spmmc_pm_runtime_resume(struct device *dev)
{
struct spmmc_host *host;
host = dev_get_drvdata(dev);
return clk_enable(host->clk);
}
#endif
static const struct dev_pm_ops spmmc_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume)
SET_RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume, NULL)
}; Re: [PATCH v5 2/2] mmc: Add mmc driver for Sunplus SP7021
Quoted 20 lines · Tony Huang 黃懷厚
Quoted 14 lines
drivers/mmc/host/sunplus-mmc.c line 835
Quoted 10 lines
drivers/mmc/host/sunplus-mmc.c new file +10
-0+static void spmmc_request (struct mmc_host *mmc,struct mmc_request +*mrq) { +struct spmmc_host *host =mmc_priv (mmc); +struct mmc_data *data; +struct mmc_command *cmd; +int ret; + + ret =mutex_lock_interruptible (&host->mrq_lock); +if (ret) +return ;I don't think it's valid to just return here when you get a signal. If nothing can handle the signal, doesn't it just hang?
Quoted 6 lines
It also appears that you don't release the mutex until the tasklet runs, but it is not valid to release a mutex from a different context.
You should get a warning about this when running a kernel with lockdep enabled at compile time. Please rework the locking to make this work.
Quoted 7 lines
Reomve code: ret = mutex_lock_interruptible(&host->mrq_lock); if (ret) return; Below is my modification:.
mutex_lock(&host->mrq_lock);
That addresses the problem with the signal handling, but not the lock imbalance. Please fix that as well.
Quoted 7 lines
Quoted 4 lines
It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of the
SET_version, then you can remove all the #ifdef checks.I use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS.
Compile shows error. Error: implicit declaration of function ? ?SYSTEM_SLEEP_PM_OPS? ? Did you mean ? ?SET_SYSTEM_SLEEP_PM_OPS? ? [-Werror=implicit-function-declaration]
Maybe you are on an old kernel release?
Quoted 11 lines
I reference other mmc driver.
Below is my modification:
Compiler is pass.
#ifdef CONFIG_PM_SLEEP
static int spmmc_pm_suspend(struct device *dev)
{
pm_runtime_force_suspend(dev);
return 0;
}We should fix the other drivers as well. For the moment, just do it the right way now
instead of copying the #ifdefs.
Arnd
RE: [PATCH v5 2/2] mmc: Add mmc driver for Sunplus SP7021
Dear Arnd:
Quoted 28 lines
Quoted 15 lines · <[email protected]> wrote:
Quoted 15 lines
drivers/mmc/host/sunplus-mmc.c line 835
Quoted 11 lines
drivers/mmc/host/sunplus-mmc.c new file +11
-0+static void spmmc_request (struct mmc_host *mmc,struct +mmc_request +*mrq) { +struct spmmc_host *host =mmc_priv (mmc); +struct mmc_data *data; +struct mmc_command *cmd; +int ret; + + ret =mutex_lock_interruptible (&host->mrq_lock); +if (ret) +return ;I don't think it's valid to just return here when you get a signal. If nothing can handle the signal, doesn't it just hang?
Quoted 5 lines
Quoted 5 lines
It also appears that you don't release the mutex until the tasklet runs, but it is not valid to release a mutex from a different context.
You should get a warning about this when running a kernel with lockdep enabled at compile time. Please rework the locking to make this
work.
Quoted 6 lines
Quoted 1 line
Reomve code: ret = mutex_lock_interruptible(&host->mrq_lock); if (ret) return;
Quoted 5 lines
Quoted 2 lines
Below is my modification:
.mutex_lock(&host->mrq_lock);That addresses the problem with the signal handling, but not the lock imbalance. Please fix that as well.
Ok, I will modify lock imbalance issue.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of
the
Quoted 3 lines
Quoted 2 lines
SET_version, then you can remove all the #ifdef checks.
Quoted 7 lines
Quoted 2 lines
I use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS.
Compile shows error. Error: implicit declaration of function ? ?
SYSTEM_SLEEP_PM_OPS? ? Did you mean ? ?SET_SYSTEM_SLEEP_PM_OPS? ? [-Werror=implicit-function-declaration]Maybe you are on an old kernel release?
OK,I will use new kernel release to compiler.
Quoted 9 lines
Quoted 9 lines
I reference other mmc driver.
Below is my modification:
Compiler is pass.#ifdef
CONFIG_PM_SLEEP
static intspmmc_pm_suspend(struct device *dev){
pm_runtime_force_suspend(dev);
Quoted 6 lines
Quoted 2 lines
return 0; }We should fix the other drivers as well. For the moment, just do it the right way now instead of copying the #ifdefs.
OK, I will follow right way to remove #ifdef.