From 07a8e3253a2d8a2076c9c83c4ed4158fa3fbb2a2 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Thu, 31 Oct 2024 21:03:44 +0000 Subject: [PATCH] drivers: disk: mmc_subsys: remove CONFIG_MMC_VOLUME_NAME Remove CONFIG_MMC_VOLUME_NAME, and set the disk name based on the ``disk-name`` property. This aligns with other disk drivers, and allows for multiple instances of the mmc_subsys disk driver to be registered. Add disk-name properties for all in tree definitions for the mmc-subsys disk driver, and change all in tree usage of the disk name Fixes #75004 Signed-off-by: Daniel DeGrasse --- .../mimxrt595_evk_mimxrt595s_cm33.dts | 1 + .../rcar_h3ulcb/rcar_h3ulcb_r8a77951_a57.dts | 1 + .../rcar_salvator_xs/rcar_salvator_xs.dts | 1 + .../rcar_spider_s4_r8a779f0_a55.dts | 1 + doc/connectivity/usb/device/usb_device.rst | 5 ++--- drivers/disk/Kconfig.mmc | 7 ------- drivers/disk/mmc_subsys.c | 18 +++++++++--------- dts/bindings/sd/zephyr,mmc-disk.yaml | 6 ++++++ dts/x86/intel/alder_lake.dtsi | 1 + samples/subsys/fs/fs_sample/src/main.c | 5 +++++ samples/subsys/fs/littlefs/README.rst | 6 +++--- samples/subsys/fs/littlefs/src/main.c | 2 +- subsys/fs/shell.c | 2 +- tests/drivers/build_all/disk/spi.dtsi | 1 + tests/drivers/disk/disk_access/src/main.c | 2 +- tests/drivers/disk/disk_performance/src/main.c | 2 +- tests/lib/gui/lvgl/src/main.c | 2 +- tests/subsys/fs/fat_fs_api/prj_mmc.conf | 1 - tests/subsys/fs/fat_fs_api/src/test_fat.h | 2 +- 19 files changed, 37 insertions(+), 29 deletions(-) diff --git a/boards/nxp/mimxrt595_evk/mimxrt595_evk_mimxrt595s_cm33.dts b/boards/nxp/mimxrt595_evk/mimxrt595_evk_mimxrt595s_cm33.dts index 77c778e7634..efa9d9d244a 100644 --- a/boards/nxp/mimxrt595_evk/mimxrt595_evk_mimxrt595s_cm33.dts +++ b/boards/nxp/mimxrt595_evk/mimxrt595_evk_mimxrt595s_cm33.dts @@ -371,6 +371,7 @@ zephyr_udc0: &usbhs { cd-gpios = <&gpio2 9 GPIO_ACTIVE_LOW>; mmc { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; status = "okay"; }; pinctrl-0 = <&pinmux_usdhc>; diff --git a/boards/renesas/rcar_h3ulcb/rcar_h3ulcb_r8a77951_a57.dts b/boards/renesas/rcar_h3ulcb/rcar_h3ulcb_r8a77951_a57.dts index 8c470e05538..fd814bc977e 100644 --- a/boards/renesas/rcar_h3ulcb/rcar_h3ulcb_r8a77951_a57.dts +++ b/boards/renesas/rcar_h3ulcb/rcar_h3ulcb_r8a77951_a57.dts @@ -94,6 +94,7 @@ pinctrl-names = "default", "uhs"; disk { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; status = "disabled"; }; bus-width = <8>; diff --git a/boards/renesas/rcar_salvator_xs/rcar_salvator_xs.dts b/boards/renesas/rcar_salvator_xs/rcar_salvator_xs.dts index bc926dfddd4..33f836f5924 100644 --- a/boards/renesas/rcar_salvator_xs/rcar_salvator_xs.dts +++ b/boards/renesas/rcar_salvator_xs/rcar_salvator_xs.dts @@ -46,6 +46,7 @@ pinctrl-names = "default", "uhs"; disk { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; status = "disabled"; }; bus-width = <8>; diff --git a/boards/renesas/rcar_spider_s4/rcar_spider_s4_r8a779f0_a55.dts b/boards/renesas/rcar_spider_s4/rcar_spider_s4_r8a779f0_a55.dts index 3a7b5c4eb82..c512a13f04b 100644 --- a/boards/renesas/rcar_spider_s4/rcar_spider_s4_r8a779f0_a55.dts +++ b/boards/renesas/rcar_spider_s4/rcar_spider_s4_r8a779f0_a55.dts @@ -41,6 +41,7 @@ pinctrl-names = "default", "uhs"; disk { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; status = "okay"; }; bus-width = <8>; diff --git a/doc/connectivity/usb/device/usb_device.rst b/doc/connectivity/usb/device/usb_device.rst index f98a5f4c62d..f1230e073d4 100644 --- a/doc/connectivity/usb/device/usb_device.rst +++ b/doc/connectivity/usb/device/usb_device.rst @@ -323,9 +323,8 @@ or SD Card to the host. Only one disk instance can be exported at a time. The disc to be used by the implementation is set by the :kconfig:option:`CONFIG_MASS_STORAGE_DISK_NAME` and should be the same as the name used by the disc access driver that the application wants to expose to the -host. MMC disk drivers use option :kconfig:option:`CONFIG_MMC_VOLUME_NAME`, or -flash, RAM, and SDMMC disk drivers use node property ``disk-name`` to set -the disk name. +host. Flash, RAM, and SDMMC/MMC disk drivers use node property ``disk-name`` to +set the disk name. For the emulated block device on a flash partition, the flash partition and flash disk to be used must be described in the devicetree. If a storage partition diff --git a/drivers/disk/Kconfig.mmc b/drivers/disk/Kconfig.mmc index 72a81b8e60f..3811ee4b60a 100644 --- a/drivers/disk/Kconfig.mmc +++ b/drivers/disk/Kconfig.mmc @@ -16,13 +16,6 @@ config SD_INIT_PRIORITY help MMC controller driver initialization priority. -config MMC_VOLUME_NAME - string "MMC Disk mount point or drive name" - default "SD" if FAT_FILESYSTEM_ELM - default "MMC" - help - Disk name as per file system naming guidelines. - config MMC_SUBSYS bool "MMC access via SD subsystem" select MMC_STACK diff --git a/drivers/disk/mmc_subsys.c b/drivers/disk/mmc_subsys.c index c595c0edb8a..b8e81cd528f 100644 --- a/drivers/disk/mmc_subsys.c +++ b/drivers/disk/mmc_subsys.c @@ -27,7 +27,7 @@ struct mmc_config { struct mmc_data { struct sd_card card; enum sd_status status; - char *name; + struct disk_info *disk_info; }; @@ -107,10 +107,6 @@ static const struct disk_operations mmc_disk_ops = { .ioctl = disk_mmc_access_ioctl, }; -static struct disk_info mmc_disk = { - .ops = &mmc_disk_ops, -}; - static int disk_mmc_init(const struct device *dev) { struct mmc_data *data = dev->data; @@ -118,10 +114,8 @@ static int disk_mmc_init(const struct device *dev) data->status = SD_UNINIT; data->card.bus_width = config->bus_width; - mmc_disk.dev = dev; - mmc_disk.name = data->name; - return disk_access_register(&mmc_disk); + return disk_access_register(data->disk_info); } #define DISK_ACCESS_MMC_INIT(n) \ @@ -130,8 +124,14 @@ static int disk_mmc_init(const struct device *dev) .bus_width = DT_INST_PROP(n, bus_width), \ }; \ \ + static struct disk_info mmc_disk_##n = { \ + .name = DT_INST_PROP(n, disk_name), \ + .ops = &mmc_disk_ops, \ + .dev = DEVICE_DT_INST_GET(n), \ + }; \ + \ static struct mmc_data mmc_data_##n = { \ - .name = CONFIG_MMC_VOLUME_NAME, \ + .disk_info = &mmc_disk_##n, \ }; \ \ DEVICE_DT_INST_DEFINE(n, \ diff --git a/dts/bindings/sd/zephyr,mmc-disk.yaml b/dts/bindings/sd/zephyr,mmc-disk.yaml index f702b341e1a..4246a994e2e 100644 --- a/dts/bindings/sd/zephyr,mmc-disk.yaml +++ b/dts/bindings/sd/zephyr,mmc-disk.yaml @@ -19,3 +19,9 @@ properties: - 1 - 4 - 8 + + disk-name: + type: string + required: true + description: | + Disk name. diff --git a/dts/x86/intel/alder_lake.dtsi b/dts/x86/intel/alder_lake.dtsi index b847278b24f..b205df48589 100644 --- a/dts/x86/intel/alder_lake.dtsi +++ b/dts/x86/intel/alder_lake.dtsi @@ -348,6 +348,7 @@ mmc { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; bus-width = <8>; status = "okay"; }; diff --git a/samples/subsys/fs/fs_sample/src/main.c b/samples/subsys/fs/fs_sample/src/main.c index b21bafe01ce..cb50716c67f 100644 --- a/samples/subsys/fs/fs_sample/src/main.c +++ b/samples/subsys/fs/fs_sample/src/main.c @@ -22,7 +22,12 @@ * Note the fatfs library is able to mount only strings inside _VOLUME_STRS * in ffconf.h */ +#if defined(CONFIG_DISK_DRIVER_MMC) +#define DISK_DRIVE_NAME "SD2" +#else #define DISK_DRIVE_NAME "SD" +#endif + #define DISK_MOUNT_PT "/"DISK_DRIVE_NAME":" static FATFS fat_fs; diff --git a/samples/subsys/fs/littlefs/README.rst b/samples/subsys/fs/littlefs/README.rst index 9aa63b8a174..4c4407cb252 100644 --- a/samples/subsys/fs/littlefs/README.rst +++ b/samples/subsys/fs/littlefs/README.rst @@ -99,9 +99,9 @@ following logic: * if the :kconfig:option:`CONFIG_DISK_DRIVER_SDMMC` configuration is defined, ``"SD"`` will be used as the mount point name; * if the :kconfig:option:`CONFIG_DISK_DRIVER_SDMMC` configuration is not defined, but the - :kconfig:option:`CONFIG_MMC_VOLUME_NAME` configuration is defined, - :kconfig:option:`CONFIG_MMC_VOLUME_NAME` will be used as the mount point name; -* if neither :kconfig:option:`CONFIG_SDMMC_VOLUME_NAME` nor :kconfig:option:`CONFIG_MMC_VOLUME_NAME` + :kconfig:option:`CONFIG_DISK_DRIVER_MMC` configuration is defined, ``"SD2"`` will + be used as the mount point name; +* if neither :kconfig:option:`CONFIG_DISK_DRIVER_SDMMC` nor :kconfig:option:`CONFIG_DISK_DRIVER_MMC` configurations are defined, the mount point name will not be determined, and an appropriate error will appear during the sample build. diff --git a/samples/subsys/fs/littlefs/src/main.c b/samples/subsys/fs/littlefs/src/main.c index 2a47f0e5ca8..e228baad1fa 100644 --- a/samples/subsys/fs/littlefs/src/main.c +++ b/samples/subsys/fs/littlefs/src/main.c @@ -313,7 +313,7 @@ static int littlefs_mount(struct fs_mount_t *mp) #if defined(CONFIG_DISK_DRIVER_SDMMC) #define DISK_NAME "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME CONFIG_MMC_VOLUME_NAME +#define DISK_NAME "SD2" #else #error "No disk device defined, is your board supported?" #endif diff --git a/subsys/fs/shell.c b/subsys/fs/shell.c index b5fd364b396..465e70af4f1 100644 --- a/subsys/fs/shell.c +++ b/subsys/fs/shell.c @@ -42,7 +42,7 @@ static struct fs_mount_t fatfs_mnt = { #if defined(CONFIG_DISK_DRIVER_SDMMC) #define DISK_NAME "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME CONFIG_MMC_VOLUME_NAME +#define DISK_NAME "SD2" #else #error "No disk device defined, is your board supported?" #endif diff --git a/tests/drivers/build_all/disk/spi.dtsi b/tests/drivers/build_all/disk/spi.dtsi index cd36ac36048..389a1a07d21 100644 --- a/tests/drivers/build_all/disk/spi.dtsi +++ b/tests/drivers/build_all/disk/spi.dtsi @@ -17,6 +17,7 @@ sdhc@0 { mmc { compatible = "zephyr,mmc-disk"; + disk-name = "SD2"; status = "okay"; }; }; diff --git a/tests/drivers/disk/disk_access/src/main.c b/tests/drivers/disk/disk_access/src/main.c index 11689006f4d..0c36f1d6121 100644 --- a/tests/drivers/disk/disk_access/src/main.c +++ b/tests/drivers/disk/disk_access/src/main.c @@ -23,7 +23,7 @@ #if defined(CONFIG_DISK_DRIVER_SDMMC) #define DISK_NAME_PHYS "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME_PHYS CONFIG_MMC_VOLUME_NAME +#define DISK_NAME_PHYS "SD2" #elif defined(CONFIG_DISK_DRIVER_FLASH) #define DISK_NAME_PHYS "NAND" #elif defined(CONFIG_NVME) diff --git a/tests/drivers/disk/disk_performance/src/main.c b/tests/drivers/disk/disk_performance/src/main.c index 82bf2008ab2..c1ac10ba684 100644 --- a/tests/drivers/disk/disk_performance/src/main.c +++ b/tests/drivers/disk/disk_performance/src/main.c @@ -15,7 +15,7 @@ #if defined(CONFIG_DISK_DRIVER_SDMMC) #define DISK_NAME "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME CONFIG_MMC_VOLUME_NAME +#define DISK_NAME "SD2" #elif defined(CONFIG_NVME) #define DISK_NAME "nvme0n0" #else diff --git a/tests/lib/gui/lvgl/src/main.c b/tests/lib/gui/lvgl/src/main.c index 91e38e1714c..0f59d01bd02 100644 --- a/tests/lib/gui/lvgl/src/main.c +++ b/tests/lib/gui/lvgl/src/main.c @@ -20,7 +20,7 @@ #ifdef CONFIG_DISK_DRIVER_SDMMC #define DISK_NAME "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME CONFIG_MMC_VOLUME_NAME +#define DISK_NAME "SD2" #else #error "No disk device defined, is your board supported?" #endif /* CONFIG_DISK_DRIVER_SDMMC */ diff --git a/tests/subsys/fs/fat_fs_api/prj_mmc.conf b/tests/subsys/fs/fat_fs_api/prj_mmc.conf index e3e903f5a89..98181cf96a0 100644 --- a/tests/subsys/fs/fat_fs_api/prj_mmc.conf +++ b/tests/subsys/fs/fat_fs_api/prj_mmc.conf @@ -4,5 +4,4 @@ CONFIG_FAT_FILESYSTEM_ELM=y CONFIG_SPI=y CONFIG_GPIO=y CONFIG_ZTEST=y -CONFIG_MMC_VOLUME_NAME="NAND" CONFIG_MAIN_STACK_SIZE=4096 diff --git a/tests/subsys/fs/fat_fs_api/src/test_fat.h b/tests/subsys/fs/fat_fs_api/src/test_fat.h index f6464ddc88e..adbeffe78dc 100644 --- a/tests/subsys/fs/fat_fs_api/src/test_fat.h +++ b/tests/subsys/fs/fat_fs_api/src/test_fat.h @@ -18,7 +18,7 @@ #elif defined(CONFIG_DISK_DRIVER_SDMMC) #define DISK_NAME "SD" #elif defined(CONFIG_DISK_DRIVER_MMC) -#define DISK_NAME CONFIG_MMC_VOLUME_NAME +#define DISK_NAME "SD2" #else #error "Failed to select DISK access type" #endif