Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
SDHC interface. More...
Data Structures | |
struct | sdhc_command |
SD host controller command structure. More... | |
struct | sdhc_data |
SD host controller data structure. More... | |
struct | sdhc_host_caps |
SD host controller capabilities. More... | |
struct | sdhc_io |
SD host controller I/O control structure. More... | |
struct | sdhc_host_props |
SD host controller properties. More... | |
struct | sdhc_driver_api |
Macros | |
#define | SDHC_NATIVE_RESPONSE_MASK 0xF |
#define | SDHC_SPI_RESPONSE_TYPE_MASK 0xF0 |
Typedefs | |
typedef void(* | sdhc_interrupt_cb_t) (const struct device *dev, int reason, const void *user_data) |
SDHC card interrupt callback prototype. | |
Enumerations | |
enum | sdhc_bus_mode { SDHC_BUSMODE_OPENDRAIN = 1 , SDHC_BUSMODE_PUSHPULL = 2 } |
SD bus mode. More... | |
enum | sdhc_power { SDHC_POWER_OFF = 1 , SDHC_POWER_ON = 2 } |
SD host controller power. More... | |
enum | sdhc_bus_width { SDHC_BUS_WIDTH1BIT = 1U , SDHC_BUS_WIDTH4BIT = 4U , SDHC_BUS_WIDTH8BIT = 8U } |
SD host controller bus width. More... | |
enum | sdhc_timing_mode { SDHC_TIMING_LEGACY = 1U , SDHC_TIMING_HS = 2U , SDHC_TIMING_SDR12 = 3U , SDHC_TIMING_SDR25 = 4U , SDHC_TIMING_SDR50 = 5U , SDHC_TIMING_SDR104 = 6U , SDHC_TIMING_DDR50 = 7U , SDHC_TIMING_DDR52 = 8U , SDHC_TIMING_HS200 = 9U , SDHC_TIMING_HS400 = 10U } |
SD host controller timing mode. More... | |
enum | sd_voltage { SD_VOL_3_3_V = 1U , SD_VOL_3_0_V = 2U , SD_VOL_1_8_V = 3U , SD_VOL_1_2_V = 4U } |
SD voltage. More... | |
enum | sdhc_interrupt_source { SDHC_INT_SDIO = BIT(0) , SDHC_INT_INSERTED = BIT(1) , SDHC_INT_REMOVED = BIT(2) } |
SD host controller interrupt sources. More... | |
Functions | |
int | sdhc_hw_reset (const struct device *dev) |
reset SDHC controller state | |
int | sdhc_request (const struct device *dev, struct sdhc_command *cmd, struct sdhc_data *data) |
Send command to SDHC. | |
int | sdhc_set_io (const struct device *dev, struct sdhc_io *io) |
set I/O properties of SDHC | |
int | sdhc_card_present (const struct device *dev) |
check for SDHC card presence | |
int | sdhc_execute_tuning (const struct device *dev) |
run SDHC tuning | |
int | sdhc_card_busy (const struct device *dev) |
check if SD card is busy | |
int | sdhc_get_host_props (const struct device *dev, struct sdhc_host_props *props) |
Get SD host controller properties. | |
int | sdhc_enable_interrupt (const struct device *dev, sdhc_interrupt_cb_t callback, int sources, void *user_data) |
Enable SDHC interrupt sources. | |
int | sdhc_disable_interrupt (const struct device *dev, int sources) |
Disable SDHC interrupt sources. | |
SD command timeouts | |
#define | SDHC_TIMEOUT_FOREVER (-1) |
SDHC interface.
#define SDHC_NATIVE_RESPONSE_MASK 0xF |
#include <zephyr/drivers/sdhc.h>
#define SDHC_SPI_RESPONSE_TYPE_MASK 0xF0 |
#include <zephyr/drivers/sdhc.h>
#define SDHC_TIMEOUT_FOREVER (-1) |
#include <zephyr/drivers/sdhc.h>
sdhc_interrupt_cb_t |
#include <zephyr/drivers/sdhc.h>
SDHC card interrupt callback prototype.
Function prototype for SDHC card interrupt callback.
dev | SDHC device that produced interrupt |
reason | one of sdhc_interrupt_source values. |
user_data | User data, set via sdhc_enable_interrupt |
enum sd_voltage |
#include <zephyr/drivers/sdhc.h>
SD voltage.
UHS cards can run with 1.8V signalling for improved power consumption. Legacy cards may support 3.0V signalling, and all cards start at 3.3V. Only relevant for SD controllers, not SPI ones.
enum sdhc_bus_mode |
#include <zephyr/drivers/sdhc.h>
SD bus mode.
Most controllers will use push/pull, including spi, but SDHC controllers that implement SD host specification can support open drain mode
Enumerator | |
---|---|
SDHC_BUSMODE_OPENDRAIN | |
SDHC_BUSMODE_PUSHPULL |
enum sdhc_bus_width |
#include <zephyr/drivers/sdhc.h>
SD host controller bus width.
Only relevant in SD mode, SPI does not support bus width. UHS cards will use 4 bit data bus, all cards start in 1 bit mode
Enumerator | |
---|---|
SDHC_BUS_WIDTH1BIT | |
SDHC_BUS_WIDTH4BIT | |
SDHC_BUS_WIDTH8BIT |
#include <zephyr/drivers/sdhc.h>
SD host controller interrupt sources.
Interrupt sources for SD host controller.
Enumerator | |
---|---|
SDHC_INT_SDIO | Card interrupt, used by SDIO cards. |
SDHC_INT_INSERTED | Card was inserted into slot. |
SDHC_INT_REMOVED | Card was removed from slot. |
enum sdhc_power |
#include <zephyr/drivers/sdhc.h>
SD host controller power.
Many host controllers can control power to attached SD cards. This enum allows applications to request the host controller power off the SD card.
Enumerator | |
---|---|
SDHC_POWER_OFF | |
SDHC_POWER_ON |
enum sdhc_timing_mode |
#include <zephyr/drivers/sdhc.h>
SD host controller timing mode.
Used by SD host controller to determine the timing of the cards attached to the bus. Cards start with legacy timing, but UHS-II cards can go up to SDR104.
int sdhc_card_busy | ( | const struct device * | dev | ) |
#include <zephyr/drivers/sdhc.h>
check if SD card is busy
This check should generally be implemented as checking the line level of the DAT[0:3] lines of the SD bus. No SD commands need to be sent, the controller simply needs to report the status of the SD bus.
dev | SDHC device |
0 | card is not busy |
1 | card is busy |
-EIO | I/O error |
int sdhc_card_present | ( | const struct device * | dev | ) |
#include <zephyr/drivers/sdhc.h>
check for SDHC card presence
Checks if card is present on the SD bus. Note that if a controller requires cards be powered up to detect presence, it should do so in this function.
dev | SDHC device |
1 | card is present |
0 | card is not present |
-EIO | I/O error |
int sdhc_disable_interrupt | ( | const struct device * | dev, |
int | sources | ||
) |
#include <zephyr/drivers/sdhc.h>
Disable SDHC interrupt sources.
Disables SDHC interrupt sources. If multiple sources are enabled, only the ones specified in "sources" will be masked.
dev | SDHC device |
sources | bitmask of sdhc_interrupt_source values indicating which interrupts should be disabled. |
0 | interrupts were disabled |
-ENOTSUP | controller does not support this function |
-EIO | I/O error |
int sdhc_enable_interrupt | ( | const struct device * | dev, |
sdhc_interrupt_cb_t | callback, | ||
int | sources, | ||
void * | user_data | ||
) |
#include <zephyr/drivers/sdhc.h>
Enable SDHC interrupt sources.
Enables SDHC interrupt sources. Each subsequent call of this function should replace the previous callback set, and leave only the interrupts specified in the "sources" argument enabled.
dev | SDHC device |
callback | Callback called when interrupt occurs |
sources | bitmask of sdhc_interrupt_source values indicating which interrupts should produce a callback |
user_data | parameter that will be passed to callback function |
0 | interrupts were enabled, and callback was installed |
-ENOTSUP | controller does not support this function |
-EIO | I/O error |
int sdhc_execute_tuning | ( | const struct device * | dev | ) |
#include <zephyr/drivers/sdhc.h>
run SDHC tuning
SD cards require signal tuning for UHS modes SDR104 and SDR50. This function allows an application to request the SD host controller to tune the card.
dev | SDHC device |
0 | tuning succeeded, card is ready for commands |
-ETIMEDOUT | tuning failed after timeout |
-ENOTSUP | controller does not support tuning |
-EIO | I/O error while tuning |
int sdhc_get_host_props | ( | const struct device * | dev, |
struct sdhc_host_props * | props | ||
) |
#include <zephyr/drivers/sdhc.h>
Get SD host controller properties.
Gets host properties from the host controller. Host controller should initialize all values in the sdhc_host_props structure provided.
dev | SDHC device |
props | property structure to be filled by sdhc driver |
0 | function succeeded. |
-ENOTSUP | host controller does not support this call |
int sdhc_hw_reset | ( | const struct device * | dev | ) |
#include <zephyr/drivers/sdhc.h>
reset SDHC controller state
Used when the SDHC has encountered an error. Resetting the SDHC controller should clear all errors on the SDHC, but does not necessarily reset I/O settings to boot (this can be done with sdhc_set_io)
dev | SD host controller device |
0 | reset succeeded |
-ETIMEDOUT | controller reset timed out |
-EIO | reset failed |
int sdhc_request | ( | const struct device * | dev, |
struct sdhc_command * | cmd, | ||
struct sdhc_data * | data | ||
) |
#include <zephyr/drivers/sdhc.h>
Send command to SDHC.
Sends a command to the SD host controller, which will send this command to attached SD cards.
dev | SDHC device |
cmd | SDHC command |
data | SDHC data. Leave NULL to send SD command without data. |
0 | command was sent successfully |
-ETIMEDOUT | command timed out while sending |
-ENOTSUP | host controller does not support command |
-EIO | I/O error |
#include <zephyr/drivers/sdhc.h>
set I/O properties of SDHC
I/O properties should be reconfigured when the card has been sent a command to change its own SD settings. This function can also be used to toggle power to the SD card.
dev | SDHC device |
io | I/O properties |