Skip to contentSkip to conversation

Add mmc driver for Sunplus SP7021 SOC

PATCH Superseded Tony Huang 4 participants 9 messages Apr 6, 2022 – Apr 13, 2022 1 message not in the archive

Subsystems (3)

v6 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Tony Huang

author maintainer
#0 lore raw

v6 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                     | 1200 ++++++++++++++++++++
 5 files changed, 1279 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
author maintainer
#1 lore raw

PATCH v6 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.

 .../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
new file mode 100644
index 0000000..8ba623e
@@ -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,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
index fb18ce7..75746ec 100644
@@ -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/sunplus,mmc.yaml
+
 SUPERH
 M:	Yoshinori Sato <[email protected]>
 M:	Rich Felker <[email protected]>
Signature · 1 line
2.7.4
Reviewed-by on v6 1/2
#2 lore raw

Re: [PATCH v6 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus SP7021

Quoted 7 lines · Tony Huang

Add MMC YAML file for Sunplus SP7021.

---
Changes in v5:
- Addressed comments from Krzysztof.

Quoted 6 lines

Changes in v6:
- Addressed comments from Krzysztof.
- To substitute MMC for mmc. To substitute YMAL for ymal.
- Remove max-frequency.
- Fixed wrong file name.

Best regards,
Krzysztof

author maintainer
#3 lore raw

PATCH v6 2/2 mmc: Add mmc driver for Sunplus SP7021

In reply to Tony Huang

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 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.

 MAINTAINERS                    |    1 +
 drivers/mmc/host/Kconfig       |    9 +
 drivers/mmc/host/Makefile      |    1 +
 drivers/mmc/host/sunplus-mmc.c | 1200 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1211 insertions(+)
 create mode 100644 drivers/mmc/host/sunplus-mmc.c
MAINTAINERS +1 -0
index 75746ec..88c315a 100644
@@ -18247,6 +18247,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
 
 SUPERH
 M:	Yoshinori Sato <[email protected]>
drivers/mmc/host/Kconfig +9 -0
index 5af8494..0d34a4b 100644
@@ -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
index ea36d37..72c67d5 100644
@@ -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 +1200 -0

1,200 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v6 2/2] mmc: Add mmc driver for Sunplus SP7021

I love your patch! Perhaps something to improve:

Hi Tony,

I love your patch! Perhaps something to improve:

[auto build test WARNING on ulf-hansson-mmc-mirror/next] [cannot apply to robh/for-next linus/master v5.18-rc1 next-20220406] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106
base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220406/[email protected]/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/325a0d9ca9d65f5616f794e0dbb04256312f739d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106 git checkout 325a0d9ca9d65f5616f794e0dbb04256312f739d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/mmc/host/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_set_bus_timing':

>> drivers/mmc/host/sunplus-mmc.c:311:15: warning: variable 'timing_name' set but not used [-Wunused-but-set-variable]
     311 |         char *timing_name;
         |               ^~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
>> drivers/mmc/host/sunplus-mmc.c:798:13: warning: no previous prototype for 'spmmc_irq' [-Wmissing-prototypes]
     798 | irqreturn_t spmmc_irq(int irq, void *dev_id)
         |             ^~~~~~~~~
>> drivers/mmc/host/sunplus-mmc.c:894:5: warning: no previous prototype for 'spmmc_get_cd' [-Wmissing-prototypes]
     894 | int spmmc_get_cd(struct mmc_host *mmc)
         |     ^~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_drv_probe':
>> drivers/mmc/host/sunplus-mmc.c:1021:22: warning: variable 'mode' set but not used [-Wunused-but-set-variable]
    1021 |         unsigned int mode;
         |                      ^~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
   drivers/mmc/host/sunplus-mmc.c:1170:9: error: implicit declaration of function 'SYSTEM_SLEEP_PM_OPS'; did you mean 'SET_SYSTEM_SLEEP_PM_OPS'? [-Werror=implicit-function-declaration]
    1170 |         SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume)
         |         ^~~~~~~~~~~~~~~~~~~
         |         SET_SYSTEM_SLEEP_PM_OPS
>> drivers/mmc/host/sunplus-mmc.c:1170:9: warning: initialization of 'int (*)(struct device *)' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
   drivers/mmc/host/sunplus-mmc.c:1170:9: error: initializer element is not constant
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
   drivers/mmc/host/sunplus-mmc.c:1171:9: error: expected '}' before 'RUNTIME_PM_OPS'
    1171 |         RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume, NULL)
         |         ^~~~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c:1169:47: note: to match this '{'
    1169 | static const struct dev_pm_ops spmmc_pm_ops = {
         |                                               ^

drivers/mmc/host/sunplus-mmc.c:1160:12: warning: 'spmmc_pm_runtime_resume' defined but not used [-Wunused-function]
1160 | static int spmmc_pm_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sunplus-mmc.c:1150:12: warning: 'spmmc_pm_runtime_suspend' defined but not used [-Wunused-function]
1150 | static int spmmc_pm_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/timing_name +311 drivers/mmc/host/sunplus-mmc.c

304
305 static void spmmc_set_bus_timing(struct spmmc_host *host, unsigned int timing)
306 {
307 u32 value = readl(host->base + SPMMC_SD_CONFIG1_REG);
308 int clkdiv = FIELD_GET(SPMMC_CLOCK_DIVISION, readl(host->base + SPMMC_SD_CONFIG0_REG));
309 int delay = clkdiv / 2 < 7 ? clkdiv / 2 : 7;
310 int hs_en = 1;

 > 311		char *timing_name;

312
313 host->ddr_enabled = 0;
314 switch (timing) {
315 case MMC_TIMING_LEGACY:
316 hs_en = 0;
317 timing_name = "legacy";
318 break;
319 case MMC_TIMING_MMC_HS:
320 timing_name = "mmc high-speed";
321 break;
322 case MMC_TIMING_SD_HS:
323 timing_name = "sd high-speed";
324 break;
325 case MMC_TIMING_UHS_SDR50:
326 timing_name = "sd uhs SDR50";
327 break;
328 case MMC_TIMING_UHS_SDR104:
329 timing_name = "sd uhs SDR104";
330 break;
331 case MMC_TIMING_UHS_DDR50:
332 host->ddr_enabled = 1;
333 timing_name = "sd uhs DDR50";
334 break;
335 case MMC_TIMING_MMC_DDR52:
336 host->ddr_enabled = 1;
337 timing_name = "mmc DDR52";
338 break;
339 case MMC_TIMING_MMC_HS200:
340 timing_name = "mmc HS200";
341 break;
342 default:
343 timing_name = "invalid";
344 hs_en = 0;
345 break;
346 }
347
348 if (hs_en) {
349 value |= SPMMC_SD_HIGH_SPEED_EN; /* sd_high_speed_en */
350 writel(value, host->base + SPMMC_SD_CONFIG1_REG);
351 value = readl(host->base + SPMMC_SD_TIMING_CONFIG0_REG);
352 value |= FIELD_PREP(SPMMC_SD_WRITE_DATA_DELAY, delay); /* sd_wr_dat_dly_sel */
353 value |= FIELD_PREP(SPMMC_SD_WRITE_COMMAND_DELAY, delay); /* sd_wr_cmd_dly_sel */
354 writel(value, host->base + SPMMC_SD_TIMING_CONFIG0_REG);
355 } else {
356 value &= ~SPMMC_SD_HIGH_SPEED_EN;
357 writel(value, host->base + SPMMC_SD_CONFIG1_REG);
358 }
359 if (host->ddr_enabled) {
360 value = readl(host->base + SPMMC_SD_CONFIG0_REG);
361 value |= SPMMC_SD_DDR_MODE; /* sdddrmode */
362 writel(value, host->base + SPMMC_SD_CONFIG0_REG);
363 } else {
364 value = readl(host->base + SPMMC_SD_CONFIG0_REG);
365 value &= ~SPMMC_SD_DDR_MODE;
366 writel(value, host->base + SPMMC_SD_CONFIG0_REG);
367 }
368 }
369

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#5 lore raw

Re: [PATCH v6 2/2] mmc: Add mmc driver for Sunplus SP7021

In reply to Tony Huang
I love your patch! Perhaps something to improve:

Hi Tony,

I love your patch! Perhaps something to improve:

[auto build test WARNING on ulf-hansson-mmc-mirror/next] [cannot apply to robh/for-next linus/master v5.18-rc1 next-20220406] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106
base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220407/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/325a0d9ca9d65f5616f794e0dbb04256312f739d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106 git checkout 325a0d9ca9d65f5616f794e0dbb04256312f739d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/mmc/host/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_set_bus_timing':
drivers/mmc/host/sunplus-mmc.c:311:15: warning: variable 'timing_name' set but not used [-Wunused-but-set-variable]

     311 |         char *timing_name;
         |               ^~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
   drivers/mmc/host/sunplus-mmc.c:798:13: warning: no previous prototype for 'spmmc_irq' [-Wmissing-prototypes]
     798 | irqreturn_t spmmc_irq(int irq, void *dev_id)
         |             ^~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c:894:5: warning: no previous prototype for 'spmmc_get_cd' [-Wmissing-prototypes]
     894 | int spmmc_get_cd(struct mmc_host *mmc)
         |     ^~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_drv_probe':
>> drivers/mmc/host/sunplus-mmc.c:1085:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    1085 |         mode = (int)of_device_get_match_data(&pdev->dev);
         |                ^
   drivers/mmc/host/sunplus-mmc.c:1021:22: warning: variable 'mode' set but not used [-Wunused-but-set-variable]
    1021 |         unsigned int mode;
         |                      ^~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
   drivers/mmc/host/sunplus-mmc.c:1170:9: error: implicit declaration of function 'SYSTEM_SLEEP_PM_OPS'; did you mean 'SET_SYSTEM_SLEEP_PM_OPS'? [-Werror=implicit-function-declaration]
    1170 |         SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume)
         |         ^~~~~~~~~~~~~~~~~~~
         |         SET_SYSTEM_SLEEP_PM_OPS
   drivers/mmc/host/sunplus-mmc.c:1170:9: warning: initialization of 'int (*)(struct device *)' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
   drivers/mmc/host/sunplus-mmc.c:1170:9: error: initializer element is not constant
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
   drivers/mmc/host/sunplus-mmc.c:1171:9: error: expected '}' before 'RUNTIME_PM_OPS'
    1171 |         RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume, NULL)
         |         ^~~~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c:1169:47: note: to match this '{'
    1169 | static const struct dev_pm_ops spmmc_pm_ops = {
         |                                               ^
   drivers/mmc/host/sunplus-mmc.c:1169:32: warning: 'spmmc_pm_ops' defined but not used [-Wunused-const-variable=]
    1169 | static const struct dev_pm_ops spmmc_pm_ops = {
         |                                ^~~~~~~~~~~~

drivers/mmc/host/sunplus-mmc.c:1160:12: warning: 'spmmc_pm_runtime_resume' defined but not used [-Wunused-function]
1160 | static int spmmc_pm_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sunplus-mmc.c:1150:12: warning: 'spmmc_pm_runtime_suspend' defined but not used [-Wunused-function]
1150 | static int spmmc_pm_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +1085 drivers/mmc/host/sunplus-mmc.c

1015
1016 static int spmmc_drv_probe(struct platform_device *pdev)
1017 {
1018 struct mmc_host *mmc;
1019 struct resource *res;
1020 struct spmmc_host *host;
1021 unsigned int mode;
1022 int ret = 0;
1023
1024 mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
1025 if (!mmc) {
1026 ret = -ENOMEM;
1027 goto probe_free_host;
1028 }
1029
1030 host = mmc_priv(mmc);
1031 host->mmc = mmc;
1032 host->power_state = MMC_POWER_OFF;
1033 host->dma_int_threshold = 1024;
1034 host->dmapio_mode = SPMMC_DMA_MODE;
1035
1036 host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
1037 if (IS_ERR(host->base))
1038 return PTR_ERR(host->base);
1039
1040 host->clk = devm_clk_get(&pdev->dev, NULL);
1041 if (IS_ERR(host->clk))
1042 return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n");
1043
1044 host->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
1045 if (IS_ERR(host->rstc))
1046 return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n");
1047
1048 host->irq = platform_get_irq(pdev, 0);
1049 if (host->irq <= 0)
1050 return host->irq;
1051
1052 ret = devm_request_irq(&pdev->dev, host->irq, spmmc_irq, IRQF_SHARED,
1053 dev_name(&pdev->dev), host);
1054 if (ret)
1055 return ret;
1056
1057 ret = clk_prepare_enable(host->clk);
1058 if (ret)
1059 return dev_err_probe(&pdev->dev, ret, "failed to enable clk\n");
1060
1061 ret = mmc_of_parse(mmc);
1062 if (ret)
1063 goto probe_free_host;
1064
1065 spin_lock_init(&host->lock);
1066 mutex_init(&host->mrq_lock);
1067 tasklet_init(&host->tsklet_finish_req, tsklet_func_finish_req, (unsigned long)host);
1068 mmc->ops = &spmmc_ops;
1069 mmc->f_min = SPMMC_MIN_CLK;
1070 if (mmc->f_max > SPMMC_MAX_CLK)
1071 mmc->f_max = SPMMC_MAX_CLK;
1072
1073 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1074 mmc->max_seg_size = SPMMC_MAX_BLK_COUNT * 512;
1075 /* Host controller supports up to "SPMMC_MAX_DMA_MEMORY_SECTORS"*/
1076 /* a.k.a. max scattered memory segments per request*/
1077 mmc->max_segs = SPMMC_MAX_DMA_MEMORY_SECTORS;
1078 mmc->max_req_size = SPMMC_MAX_BLK_COUNT * 512;
1079 /* Limited by the max value of dma_size & data_length, set it to 512 bytes for now */
1080 mmc->max_blk_size = 512;
1081 mmc->max_blk_count = SPMMC_MAX_BLK_COUNT; /* Limited by sd_page_num */
1082
1083 dev_set_drvdata(&pdev->dev, host);
1084 spmmc_controller_init(host);

> 1085		mode = (int)of_device_get_match_data(&pdev->dev);

1086 spmmc_select_mode(host);
1087 mmc_add_host(mmc);
1088 host->tuning_info.enable_tuning = 1;
1089 pm_runtime_set_active(&pdev->dev);
1090 pm_runtime_enable(&pdev->dev);
1091
1092 return ret;
1093
1094 probe_free_host:
1095 if (mmc)
1096 mmc_free_host(mmc);
1097
1098 return ret;
1099 }
1100

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#6 lore raw

Re: [PATCH v6 2/2] mmc: Add mmc driver for Sunplus SP7021

In reply to Tony Huang
I love your patch! Yet something to improve:

Hi Tony,

I love your patch! Yet something to improve:

[auto build test ERROR on ulf-hansson-mmc-mirror/next] [cannot apply to robh/for-next linus/master v5.18-rc1 next-20220406] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106
base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
config: nds32-buildonly-randconfig-r003-20220406 (https://download.01.org/0day-ci/archive/20220407/[email protected]/config)
compiler: nds32le-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/325a0d9ca9d65f5616f794e0dbb04256312f739d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106 git checkout 325a0d9ca9d65f5616f794e0dbb04256312f739d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=nds32 SHELL=/bin/bash drivers/mmc/host/

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_set_bus_timing':

>> drivers/mmc/host/sunplus-mmc.c:311:15: warning: variable 'timing_name' set but not used [-Wunused-but-set-variable]
     311 |         char *timing_name;
         |               ^~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
>> drivers/mmc/host/sunplus-mmc.c:798:13: warning: no previous prototype for 'spmmc_irq' [-Wmissing-prototypes]
     798 | irqreturn_t spmmc_irq(int irq, void *dev_id)
         |             ^~~~~~~~~
>> drivers/mmc/host/sunplus-mmc.c:894:5: warning: no previous prototype for 'spmmc_get_cd' [-Wmissing-prototypes]
     894 | int spmmc_get_cd(struct mmc_host *mmc)
         |     ^~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_drv_probe':
>> drivers/mmc/host/sunplus-mmc.c:1021:22: warning: variable 'mode' set but not used [-Wunused-but-set-variable]
    1021 |         unsigned int mode;
         |                      ^~~~
   drivers/mmc/host/sunplus-mmc.c: At top level:
>> drivers/mmc/host/sunplus-mmc.c:1170:9: error: implicit declaration of function 'SYSTEM_SLEEP_PM_OPS'; did you mean 'SET_SYSTEM_SLEEP_PM_OPS'? [-Werror=implicit-function-declaration]
    1170 |         SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume)
         |         ^~~~~~~~~~~~~~~~~~~
         |         SET_SYSTEM_SLEEP_PM_OPS
>> drivers/mmc/host/sunplus-mmc.c:1170:9: warning: initialization of 'int (*)(struct device *)' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
>> drivers/mmc/host/sunplus-mmc.c:1170:9: error: initializer element is not constant
   drivers/mmc/host/sunplus-mmc.c:1170:9: note: (near initialization for 'spmmc_pm_ops.prepare')
>> drivers/mmc/host/sunplus-mmc.c:1171:9: error: expected '}' before 'RUNTIME_PM_OPS'
    1171 |         RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume, NULL)
         |         ^~~~~~~~~~~~~~
   drivers/mmc/host/sunplus-mmc.c:1169:47: note: to match this '{'
    1169 | static const struct dev_pm_ops spmmc_pm_ops = {
         |                                               ^
   drivers/mmc/host/sunplus-mmc.c:1169:32: warning: 'spmmc_pm_ops' defined but not used [-Wunused-const-variable=]
    1169 | static const struct dev_pm_ops spmmc_pm_ops = {
         |                                ^~~~~~~~~~~~

drivers/mmc/host/sunplus-mmc.c:1160:12: warning: 'spmmc_pm_runtime_resume' defined but not used [-Wunused-function]
1160 | static int spmmc_pm_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sunplus-mmc.c:1150:12: warning: 'spmmc_pm_runtime_suspend' defined but not used [-Wunused-function]
1150 | static int spmmc_pm_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +1170 drivers/mmc/host/sunplus-mmc.c

1015
1016 static int spmmc_drv_probe(struct platform_device *pdev)
1017 {
1018 struct mmc_host *mmc;
1019 struct resource *res;
1020 struct spmmc_host *host;

> 1021		unsigned int mode;
  1022		int ret = 0;
  1023	
  1024		mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
  1025		if (!mmc) {
  1026			ret = -ENOMEM;
  1027			goto probe_free_host;
  1028		}
  1029	
  1030		host = mmc_priv(mmc);
  1031		host->mmc = mmc;
  1032		host->power_state = MMC_POWER_OFF;
  1033		host->dma_int_threshold = 1024;
  1034		host->dmapio_mode = SPMMC_DMA_MODE;
  1035	
  1036		host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
  1037		if (IS_ERR(host->base))
  1038			return PTR_ERR(host->base);
  1039	
  1040		host->clk = devm_clk_get(&pdev->dev, NULL);
  1041		if (IS_ERR(host->clk))
  1042			return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n");
  1043	
  1044		host->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
  1045		if (IS_ERR(host->rstc))
  1046			return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n");
  1047	
  1048		host->irq = platform_get_irq(pdev, 0);
  1049		if (host->irq <= 0)
  1050			return host->irq;
  1051	
  1052		ret = devm_request_irq(&pdev->dev, host->irq, spmmc_irq, IRQF_SHARED,
  1053				       dev_name(&pdev->dev), host);
  1054		if (ret)
  1055			return ret;
  1056	
  1057		ret = clk_prepare_enable(host->clk);
  1058		if (ret)
  1059			return dev_err_probe(&pdev->dev, ret, "failed to enable clk\n");
  1060	
  1061		ret = mmc_of_parse(mmc);
  1062		if (ret)
  1063			goto probe_free_host;
  1064	
  1065		spin_lock_init(&host->lock);
  1066		mutex_init(&host->mrq_lock);
  1067		tasklet_init(&host->tsklet_finish_req, tsklet_func_finish_req, (unsigned long)host);
  1068		mmc->ops = &spmmc_ops;
  1069		mmc->f_min = SPMMC_MIN_CLK;
  1070		if (mmc->f_max > SPMMC_MAX_CLK)
  1071			mmc->f_max = SPMMC_MAX_CLK;
  1072	
  1073		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
  1074		mmc->max_seg_size = SPMMC_MAX_BLK_COUNT * 512;
  1075		/* Host controller supports up to "SPMMC_MAX_DMA_MEMORY_SECTORS"*/
  1076		/* a.k.a. max scattered memory segments per request*/
  1077		mmc->max_segs = SPMMC_MAX_DMA_MEMORY_SECTORS;
  1078		mmc->max_req_size = SPMMC_MAX_BLK_COUNT * 512;
  1079		/* Limited by the max value of dma_size & data_length, set it to 512 bytes for now */
  1080		mmc->max_blk_size = 512;
  1081		mmc->max_blk_count = SPMMC_MAX_BLK_COUNT; /* Limited by sd_page_num */
  1082	
  1083		dev_set_drvdata(&pdev->dev, host);
  1084		spmmc_controller_init(host);
  1085		mode = (int)of_device_get_match_data(&pdev->dev);
  1086		spmmc_select_mode(host);
  1087		mmc_add_host(mmc);
  1088		host->tuning_info.enable_tuning = 1;
  1089		pm_runtime_set_active(&pdev->dev);
  1090		pm_runtime_enable(&pdev->dev);
  1091	
  1092		return ret;
  1093	
  1094	probe_free_host:
  1095		if (mmc)
  1096			mmc_free_host(mmc);
  1097	
  1098		return ret;
  1099	}
  1100	
  1101	static int spmmc_drv_remove(struct platform_device *dev)
  1102	{
  1103		struct spmmc_host *host = platform_get_drvdata(dev);
  1104	
  1105		mmc_remove_host(host->mmc);
  1106		clk_disable(host->clk);
  1107		clk_unprepare(host->clk);
  1108		pm_runtime_disable(&dev->dev);
  1109		platform_set_drvdata(dev, NULL);
  1110		mmc_free_host(host->mmc);
  1111	
  1112		return 0;
  1113	}
  1114	
  1115	static int spmmc_drv_suspend(struct platform_device *dev, pm_message_t state)
  1116	{
  1117		struct spmmc_host *host;
  1118	
  1119		host = platform_get_drvdata(dev);
  1120		mutex_lock(&host->mrq_lock); /* Make sure that no one is holding the controller */
  1121		mutex_unlock(&host->mrq_lock);
  1122		clk_disable(host->clk);
  1123	
  1124		return 0;
  1125	}
  1126	
  1127	static int spmmc_drv_resume(struct platform_device *dev)
  1128	{
  1129		struct spmmc_host *host;
  1130	
  1131		host = platform_get_drvdata(dev);
  1132	
  1133		return clk_enable(host->clk);
  1134	}
  1135	
  1136	static int spmmc_pm_suspend(struct device *dev)
  1137	{
  1138		pm_runtime_force_suspend(dev);
  1139	
  1140		return 0;
  1141	}
  1142	
  1143	static int spmmc_pm_resume(struct device *dev)
  1144	{
  1145		pm_runtime_force_resume(dev);
  1146	
  1147		return 0;
  1148	}
  1149	
  1150	static int spmmc_pm_runtime_suspend(struct device *dev)
  1151	{
  1152		struct spmmc_host *host;
  1153	
  1154		host = dev_get_drvdata(dev);
  1155		clk_disable(host->clk);
  1156	
  1157		return 0;
  1158	}
  1159	
  1160	static int spmmc_pm_runtime_resume(struct device *dev)
  1161	{
  1162		struct spmmc_host *host;
  1163	
  1164		host = dev_get_drvdata(dev);
  1165	
  1166		return clk_enable(host->clk);
  1167	}
  1168	
  1169	static const struct dev_pm_ops spmmc_pm_ops = {
> 1170		SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend, spmmc_pm_resume)
> 1171		RUNTIME_PM_OPS(spmmc_pm_runtime_suspend, spmmc_pm_runtime_resume, NULL)

1172 };
1173

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp

A message that is not in the archive (sent off-list or not yet received): CAHpW4oQc0=SinXTVW=ph8BgKQ4bN1mXOtWDv46MCNgXED+9TGQ@mail.gmail.com

#8 lore raw

RE: [PATCH v6 2/2] mmc: Add mmc driver for Sunplus SP7021

Dear Arnd:

Quoted 59 lines

Hi Tony,

I love your patch! Yet something to improve:

[auto build test ERROR on ulf-hansson-mmc-mirror/next] [cannot apply to robh/for-next linus/master v5.18-rc1 next-20220406] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/intel-lab-lkp/linux/commits/Tony-Huang/Add-mmc-driver-f
or-Sunplus-SP7021-SOC/20220406-194106

base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
config: nds32-buildonly-randconfig-r003-20220406

(https://download.01.org/0day-ci/archive/20220407/202204070029.JvyEor8F-l
[email protected]/config)
compiler: nds32le-linux-gcc (GCC) 11.2.0 reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
-O ~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/intel-lab-lkp/linux/commit/325a0d9ca9d65f5616f794e0dbb
04256312f739d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review
Tony-Huang/Add-mmc-driver-for-Sunplus-SP7021-SOC/20220406-194106

        git checkout 325a0d9ca9d65f5616f794e0dbb04256312f739d
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0

make.cross O=build_dir ARCH=nds32 SHELL=/bin/bash drivers/mmc/host/

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_set_bus_timing':

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:311:15: warning: variable 'timing_name' set but not used [-Wunused-but-set-variable]

     311 |         char *timing_name;
         |               ^~~~~~~~~~~

drivers/mmc/host/sunplus-mmc.c: At top level:

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:798:13: warning: no previous prototype for 'spmmc_irq' [-Wmissing-prototypes]

798 | irqreturn_t spmmc_irq(int irq, void *dev_id)
| ^~~~~~~~~

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:894:5: warning: no previous prototype for 'spmmc_get_cd' [-Wmissing-prototypes]

894 | int spmmc_get_cd(struct mmc_host *mmc)
| ^~~~~~~~~~~~
drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_drv_probe':

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:1021:22: warning: variable 'mode' set but not used [-Wunused-but-set-variable]

    1021 |         unsigned int mode;
         |                      ^~~~
Quoted 8 lines

drivers/mmc/host/sunplus-mmc.c: At top level:

Quoted 3 lines
Quoted 3 lines

drivers/mmc/host/sunplus-mmc.c:1170:9: error: implicit declaration of function 'SYSTEM_SLEEP_PM_OPS'; did you mean 'SET_SYSTEM_SLEEP_PM_OPS'? [-Werror=implicit-function-declaration]

1170 | SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend,
spmmc_pm_resume)

         |         ^~~~~~~~~~~~~~~~~~~
         |         SET_SYSTEM_SLEEP_PM_OPS

I follow your sugguest in v5.
"It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of the SET_ version" But kernel test robot shows error.

#9 lore raw

Re: [PATCH v6 2/2] mmc: Add mmc driver for Sunplus SP7021

Quoted 28 lines · Tony Huang 黃懷厚

Dear Arnd:

Quoted 26 lines

All error/warnings (new ones prefixed by >>):

drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_set_bus_timing':

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:311:15: warning: variable 'timing_name' set but not used [-Wunused-but-set-variable]

     311 |         char *timing_name;
         |               ^~~~~~~~~~~

drivers/mmc/host/sunplus-mmc.c: At top level:

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:798:13: warning: no previous prototype for 'spmmc_irq' [-Wmissing-prototypes]

798 | irqreturn_t spmmc_irq(int irq, void *dev_id)
| ^~~~~~~~~

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:894:5: warning: no previous prototype for 'spmmc_get_cd' [-Wmissing-prototypes]

894 | int spmmc_get_cd(struct mmc_host *mmc)
| ^~~~~~~~~~~~
drivers/mmc/host/sunplus-mmc.c: In function 'spmmc_drv_probe':

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sunplus-mmc.c:1021:22: warning: variable 'mode' set but not used [-Wunused-but-set-variable]

    1021 |         unsigned int mode;
         |                      ^~~~

drivers/mmc/host/sunplus-mmc.c: At top level:

Quoted 3 lines
Quoted 3 lines

drivers/mmc/host/sunplus-mmc.c:1170:9: error: implicit declaration of function 'SYSTEM_SLEEP_PM_OPS'; did you mean 'SET_SYSTEM_SLEEP_PM_OPS'? [-Werror=implicit-function-declaration]

Quoted 8 lines
Quoted 4 lines

1170 | SYSTEM_SLEEP_PM_OPS(spmmc_pm_suspend,
spmmc_pm_resume)

         |         ^~~~~~~~~~~~~~~~~~~
         |         SET_SYSTEM_SLEEP_PM_OPS

I follow your sugguest in v5.
"It's better to use SYSTEM_SLEEP_PM_OPS/RUNTIME_PM_OPS instead of the SET_ version" But kernel test robot shows error.

Which you need to fix. Kernel test robot gave you tools needed to reproduce all these errors, so go ahead and fix them. :)

Best regards,
Krzysztof