12#ifndef ZEPHYR_INCLUDE_DRIVERS_SDHC_H_
13#define ZEPHYR_INCLUDE_DRIVERS_SDHC_H_
37#define SDHC_TIMEOUT_FOREVER (-1)
55#define SDHC_NATIVE_RESPONSE_MASK 0xF
56#define SDHC_SPI_RESPONSE_TYPE_MASK 0xF0
165 unsigned int _rsvd_6: 1;
172 unsigned int _rsvd_20: 1;
190 unsigned int _rsvd_39: 1;
195 unsigned int _rsvd_56: 3;
198 unsigned int _rsvd_61: 3;
257 const void *user_data);
272 int sources,
void *user_data);
290static inline int z_impl_sdhc_hw_reset(
const struct device *dev)
298 return api->reset(dev);
318static inline int z_impl_sdhc_request(
const struct device *dev,
328 return api->request(dev,
cmd, data);
345static inline int z_impl_sdhc_set_io(
const struct device *dev,
354 return api->set_io(dev, io);
370static inline int z_impl_sdhc_card_present(
const struct device *dev)
374 if (!api->get_card_present) {
378 return api->get_card_present(dev);
395static inline int z_impl_sdhc_execute_tuning(
const struct device *dev)
399 if (!api->execute_tuning) {
403 return api->execute_tuning(dev);
419static inline int z_impl_sdhc_card_busy(
const struct device *dev)
423 if (!api->card_busy) {
427 return api->card_busy(dev);
444static inline int z_impl_sdhc_get_host_props(
const struct device *dev,
449 if (!api->get_host_props) {
453 return api->get_host_props(dev, props);
473 int sources,
void *user_data);
475static inline int z_impl_sdhc_enable_interrupt(
const struct device *dev,
477 int sources,
void *user_data)
481 if (!api->enable_interrupt) {
485 return api->enable_interrupt(dev, callback, sources, user_data);
502static inline int z_impl_sdhc_disable_interrupt(
const struct device *dev,
507 if (!api->disable_interrupt) {
511 return api->disable_interrupt(dev, sources);
522#include <zephyr/syscalls/sdhc.h>
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition ft8xx_reference_api.h:153
int sdhc_set_io(const struct device *dev, struct sdhc_io *io)
set I/O properties of SDHC
sd_voltage
SD voltage.
Definition sdhc.h:146
void(* sdhc_interrupt_cb_t)(const struct device *dev, int reason, const void *user_data)
SDHC card interrupt callback prototype.
Definition sdhc.h:256
int sdhc_disable_interrupt(const struct device *dev, int sources)
Disable SDHC interrupt sources.
sdhc_timing_mode
SD host controller timing mode.
Definition sdhc.h:116
int sdhc_card_present(const struct device *dev)
check for SDHC card presence
int sdhc_enable_interrupt(const struct device *dev, sdhc_interrupt_cb_t callback, int sources, void *user_data)
Enable SDHC interrupt sources.
int sdhc_card_busy(const struct device *dev)
check if SD card is busy
sdhc_interrupt_source
SD host controller interrupt sources.
Definition sdhc.h:241
int sdhc_get_host_props(const struct device *dev, struct sdhc_host_props *props)
Get SD host controller properties.
int sdhc_execute_tuning(const struct device *dev)
run SDHC tuning
int sdhc_request(const struct device *dev, struct sdhc_command *cmd, struct sdhc_data *data)
Send command to SDHC.
sdhc_power
SD host controller power.
Definition sdhc.h:92
int sdhc_hw_reset(const struct device *dev)
reset SDHC controller state
sdhc_bus_width
SD host controller bus width.
Definition sdhc.h:103
sdhc_bus_mode
SD bus mode.
Definition sdhc.h:80
@ SD_VOL_3_3_V
card operation voltage around 3.3v
Definition sdhc.h:147
@ SD_VOL_1_2_V
card operation voltage around 1.2v
Definition sdhc.h:153
@ SD_VOL_3_0_V
card operation voltage around 3.0v
Definition sdhc.h:149
@ SD_VOL_1_8_V
card operation voltage around 1.8v
Definition sdhc.h:151
@ SDHC_TIMING_HS400
HS400 mode.
Definition sdhc.h:135
@ SDHC_TIMING_DDR52
DDR52 mode.
Definition sdhc.h:131
@ SDHC_TIMING_SDR50
SDR49 mode.
Definition sdhc.h:125
@ SDHC_TIMING_LEGACY
Legacy 3.3V Mode.
Definition sdhc.h:117
@ SDHC_TIMING_SDR25
High speed mode & SDR25.
Definition sdhc.h:123
@ SDHC_TIMING_SDR12
Identification mode & SDR12.
Definition sdhc.h:121
@ SDHC_TIMING_SDR104
SDR104 mode.
Definition sdhc.h:127
@ SDHC_TIMING_HS200
HS200 mode.
Definition sdhc.h:133
@ SDHC_TIMING_HS
Legacy High speed mode (3.3V)
Definition sdhc.h:119
@ SDHC_TIMING_DDR50
DDR50 mode.
Definition sdhc.h:129
@ SDHC_INT_REMOVED
Card was removed from slot.
Definition sdhc.h:244
@ SDHC_INT_INSERTED
Card was inserted into slot.
Definition sdhc.h:243
@ SDHC_INT_SDIO
Card interrupt, used by SDIO cards.
Definition sdhc.h:242
@ SDHC_POWER_OFF
Definition sdhc.h:93
@ SDHC_POWER_ON
Definition sdhc.h:94
@ SDHC_BUS_WIDTH8BIT
Definition sdhc.h:106
@ SDHC_BUS_WIDTH4BIT
Definition sdhc.h:105
@ SDHC_BUS_WIDTH1BIT
Definition sdhc.h:104
@ SDHC_BUSMODE_OPENDRAIN
Definition sdhc.h:81
@ SDHC_BUSMODE_PUSHPULL
Definition sdhc.h:82
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
sd_driver_type
SD driver types.
Definition sd_spec.h:476
sdhc_clock_speed
SD host controller clock speed.
Definition sd_spec.h:430
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
SD host controller command structure.
Definition sdhc.h:46
uint32_t opcode
SD Host specification CMD index.
Definition sdhc.h:47
uint32_t response[4]
SD card response field.
Definition sdhc.h:49
unsigned int retries
Max number of retries.
Definition sdhc.h:51
int timeout_ms
Command timeout in milliseconds.
Definition sdhc.h:52
uint32_t arg
SD host specification argument.
Definition sdhc.h:48
uint32_t response_type
Expected SD response type.
Definition sdhc.h:50
SD host controller data structure.
Definition sdhc.h:64
void * data
Data to transfer or receive.
Definition sdhc.h:69
unsigned int block_size
Block size.
Definition sdhc.h:66
unsigned int blocks
Number of blocks.
Definition sdhc.h:67
unsigned int block_addr
Block to start read from.
Definition sdhc.h:65
unsigned int bytes_xfered
populated with number of bytes sent by SDHC
Definition sdhc.h:68
int timeout_ms
data timeout in milliseconds
Definition sdhc.h:70
int(* get_card_present)(const struct device *dev)
Definition sdhc.h:265
int(* enable_interrupt)(const struct device *dev, sdhc_interrupt_cb_t callback, int sources, void *user_data)
Definition sdhc.h:270
int(* request)(const struct device *dev, struct sdhc_command *cmd, struct sdhc_data *data)
Definition sdhc.h:261
int(* execute_tuning)(const struct device *dev)
Definition sdhc.h:266
int(* disable_interrupt)(const struct device *dev, int sources)
Definition sdhc.h:273
int(* reset)(const struct device *dev)
Definition sdhc.h:260
int(* card_busy)(const struct device *dev)
Definition sdhc.h:267
int(* set_io)(const struct device *dev, struct sdhc_io *ios)
Definition sdhc.h:264
int(* get_host_props)(const struct device *dev, struct sdhc_host_props *props)
Definition sdhc.h:268
SD host controller capabilities.
Definition sdhc.h:163
unsigned int address_64_bit_support_v3
64-bit system address support for V3
Definition sdhc.h:180
unsigned int uhs_2_support
UHS-II support.
Definition sdhc.h:186
unsigned int sd_base_clk
SD base clock frequency.
Definition sdhc.h:167
unsigned int sdma_support
SDMA support.
Definition sdhc.h:174
unsigned int vdd2_180_support
1.8V VDD2 support
Definition sdhc.h:197
unsigned int slot_type
Slot type.
Definition sdhc.h:182
unsigned int timeout_clk_freq
Timeout clock frequency.
Definition sdhc.h:164
unsigned int sdr104_support
SDR104 support.
Definition sdhc.h:184
unsigned int drv_type_a_support
Driver type A support.
Definition sdhc.h:187
unsigned int retuning_mode
Re-tuning mode.
Definition sdhc.h:193
unsigned int sdr50_support
SDR50 support.
Definition sdhc.h:183
unsigned int sdio_async_interrupt_support
Asynchronous interrupt support.
Definition sdhc.h:181
unsigned int bus_4_bit_support
4 bit bus support
Definition sdhc.h:170
unsigned int vol_300_support
Voltage support 3.0V.
Definition sdhc.h:177
unsigned int timeout_clk_unit
Timeout clock unit.
Definition sdhc.h:166
unsigned int adma3_support
ADMA3 support.
Definition sdhc.h:196
unsigned int hs200_support
HS200 support.
Definition sdhc.h:199
unsigned int max_blk_len
Max block length.
Definition sdhc.h:168
unsigned int ddr50_support
DDR50 support.
Definition sdhc.h:185
unsigned int vol_180_support
Voltage support 1.8V.
Definition sdhc.h:178
unsigned int high_spd_support
High speed support.
Definition sdhc.h:173
unsigned int drv_type_c_support
Driver type C support.
Definition sdhc.h:188
unsigned int retune_timer_count
Timer count for re-tuning.
Definition sdhc.h:191
unsigned int sdr50_needs_tuning
Use tuning for SDR50.
Definition sdhc.h:192
unsigned int vol_330_support
Voltage support 3.3V.
Definition sdhc.h:176
unsigned int adma_2_support
ADMA2 support.
Definition sdhc.h:171
unsigned int bus_8_bit_support
8-bit Support for embedded device
Definition sdhc.h:169
unsigned int hs400_support
HS400 support.
Definition sdhc.h:200
unsigned int drv_type_d_support
Driver type D support.
Definition sdhc.h:189
unsigned int address_64_bit_support_v4
64-bit system address support for V4
Definition sdhc.h:179
unsigned int suspend_res_support
Suspend/Resume support.
Definition sdhc.h:175
unsigned int clk_multiplier
Clock multiplier.
Definition sdhc.h:194
SD host controller properties.
Definition sdhc.h:225
unsigned int f_min
Min bus frequency.
Definition sdhc.h:227
uint32_t max_current_180
Max current (in mA) at 1.8V.
Definition sdhc.h:232
unsigned int power_delay
Delay to allow SD to power up or down (in ms)
Definition sdhc.h:228
bool is_spi
Is the host using SPI mode.
Definition sdhc.h:233
uint32_t max_current_300
Max current (in mA) at 3.0V.
Definition sdhc.h:231
struct sdhc_host_caps host_caps
Host capability bitfield.
Definition sdhc.h:229
unsigned int f_max
Max bus frequency.
Definition sdhc.h:226
uint32_t max_current_330
Max current (in mA) at 3.3V.
Definition sdhc.h:230
SD host controller I/O control structure.
Definition sdhc.h:210
enum sd_driver_type driver_type
SD driver type.
Definition sdhc.h:216
enum sdhc_bus_mode bus_mode
command output mode
Definition sdhc.h:212
enum sdhc_timing_mode timing
SD bus timing.
Definition sdhc.h:215
enum sdhc_bus_width bus_width
SD bus width.
Definition sdhc.h:214
enum sdhc_clock_speed clock
Clock rate.
Definition sdhc.h:211
enum sdhc_power power_mode
SD power supply mode.
Definition sdhc.h:213
enum sd_voltage signal_voltage
IO signalling voltage (usually 1.8 or 3.3V)
Definition sdhc.h:217