feat(sd): added power control driver and implementation layer with ldo

This commit is contained in:
Armando
2024-01-21 19:29:42 +08:00
parent 5154be52ac
commit ec44556a07
24 changed files with 414 additions and 46 deletions

View File

@@ -21,3 +21,5 @@ INPUT += \
$(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/gpio_num.h \
$(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/soc_caps.h \
$(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/uart_channel.h \
$(PROJECT_PATH)/components/sdmmc/include/sd_pwr_ctrl.h \
$(PROJECT_PATH)/components/sdmmc/include/sd_pwr_ctrl_by_on_chip_ldo.h \

View File

@@ -67,7 +67,7 @@ Overview
Pins used by Slot 0 (``HS1_*``) are also used to connect the SPI flash chip in ESP32-WROOM and ESP32-WROVER modules. These pins cannot be concurrently shared between an SD card and an SPI flash. If you need to use Slot 0, establish an alternative connection for the SPI flash using different pins and configure the necessary eFuses accordingly.
.. only:: esp32s3
.. only:: SOC_SDMMC_USE_GPIO_MATRIX
Both slots :c:macro:`SDMMC_HOST_SLOT_0` and :c:macro:`SDMMC_HOST_SLOT_1` support 1-, 4- and 8-line SD interfaces. The slots are connected to {IDF_TARGET_NAME} GPIOs using the GPIO matrix. This means that any GPIO may be used for each of the SD card signals.
@@ -76,7 +76,7 @@ Overview
- :c:macro:`SDMMC_HOST_SLOT_1` is routed via GPIO Matrix. This means that any GPIO may be used for each of the SD card signals. It is for non UHS-I usage.
- :c:macro:`SDMMC_HOST_SLOT_0` is dedicated to UHS-I mode, which is not yet supported in the driver.
Currently SDMMC host driver is using the on-chip LDO 4 as the default power supply. SDMMC power control driver is not supported yet. If you buy the ESP32P4 chip itself and plan to use SDMMC peripheral, make sure the VDDPST_5 pin is connected to the on-chip LDO 4 or correct external power supply.
On {IDF_TARGET_NAME}, SDMMC host requires an external power supply for the IO voltage. Please refer to :ref:'pwr-ctrl' for details.
Supported Speed Modes
---------------------
@@ -162,6 +162,21 @@ To configure the bus width, set the ``width`` field of :cpp:class:`sdmmc_slot_co
Once :cpp:class:`sdmmc_slot_config_t` structure is initialized this way, you can use it when calling :cpp:func:`sdmmc_host_init_slot` or one of the higher level functions (such as :cpp:func:`esp_vfs_fat_sdmmc_mount`).
.. only:: SOC_SDMMC_IO_POWER_EXTERNAL
.. _pwr-ctrl:
Configuring Voltage Level
-------------------------
{IDF_TARGET_NAME} SDMMC Host requires the IO voltage to be supplied externally via the VDDPST_5 (SD_VREF) pin. If the design doesn't require the higher speed SD modes, this pin can be simply connected to the 3.3V supply.
If the design does require higher speed SD modes (which only work at 1.8V IO levels), there are two options available:
- Use the on-chip programmable LDO. In this case, connect the desired LDO output channel to VDDPST_5 (SD_VREF) pin. Call :cpp:func:'sd_pwr_ctrl_new_on_chip_ldo' to initialize the SD power control driver, then set :cpp:class:'sdmmc_host_t::pwr_ctrl_handle' to the resulting handle.
- Use an external programmable LDO. Likewise, connect the LDO output to the VDDPST_5 (SD_VREF) pin. Then implement a custom `sd_pwr_ctrl` driver to control your LDO. Finally, assign :cpp:class:'sdmmc_host_t::pwr_ctrl_handle' to the handle of your driver instance.
DDR Mode for eMMC Chips
-----------------------

View File

@@ -71,6 +71,12 @@ SDMMC 主机驱动
卡槽 :c:macro:`SDMMC_HOST_SLOT_0`:c:macro:`SDMMC_HOST_SLOT_1` 都支持 1、4、8 线的 SD 接口,这些卡槽通过 GPIO 交换矩阵连接到 {IDF_TARGET_NAME} 的 GPIO即每个 SD 卡信号都可以使用任意 GPIO 连接。
.. only:: esp32p4
- 卡槽 :c:macro:`SDMMC_HOST_SLOT_1` 通过GPIO矩阵连接。这意味着任何GPIO都可以用于每个SD卡信号。它适用于非UHS-I用途。
- 卡槽 :c:macro:`SDMMC_HOST_SLOT_0` 专用于UHS-I模式驱动程序中尚不支持该模式。
目前SDMMC主机需要为IO电平提供外部电压参考。如果您自行购买ESP32P4芯片并计划使用SDMMC外设请参阅 :ref:'wr-ctrl' 。
支持的速率模式
---------------------
@@ -156,6 +162,18 @@ SDMMC 主机驱动支持以下速率模式:
通过上述方式初始化 :cpp:class:`sdmmc_slot_config_t` 结构体后,即可在调用 :cpp:func:`sdmmc_host_init_slot` 或其他任意高层函数(如 :cpp:func:`esp_vfs_fat_sdmmc_mount`)时使用该结构体。
.. only:: SOC_SDMMC_IO_POWER_EXTERNAL
.. _pwr-ctrl:
配置供电和参考电压
------------------
{IDF_TARGET_NAME} SDMMC主机需要为IO电平提供外部电压参考 ,以支持高速设备, 驱动器将动态配置电压参考。您可以使用片上可编程LDO作为从机电源和电压参考 ,也可以提供正确的外部电源。
- 要使用片上LDO ,请确保 VDDPST_5(sd_vref) 引脚连接到所选的片上LD通道 ,并调用 :cpp:func:'sd_pwr_ctrl_new_on_chip_ldo' 分配所选的LDO通道 ,然后将 'pwr_ctr_handle' 传递给 :cpp:class:'sdmmc_host_t::pwr_ctl_handle' 。
- 要使用外部电源,请确保 VDDPST_5(sd_vref) 引脚已连接,然后按照 :cpp:class:'sd_pwr_ctrl_drv_t' 构造外部电源控制结构体,并将其传递给 :cpp:class:'sdmmc_host_t::pwr_ctr_handle'。
eMMC 芯片的 DDR 模式
-----------------------