Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sd.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_SD_SD_H_
13#define ZEPHYR_INCLUDE_SD_SD_H_
14
15#include <zephyr/device.h>
16#include <zephyr/drivers/sdhc.h>
17#include <zephyr/kernel.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
31
41
54
55
63struct sd_card {
64 const struct device *sdhc;
65 struct sdhc_io bus_io;
67 struct k_mutex lock;
71 unsigned int num_io: 3;
84 /* NOTE: The buffer is accessed as a uint32_t* by the SD subsystem, so must be
85 * aligned to 4 bytes for platforms that don't support unaligned access...
86 * Systems where the buffer is accessed by DMA may require wider alignment, in
87 * which case, use CONFIG_SDHC_BUFFER_ALIGNMENT.
88 */
89 uint8_t card_buffer[CONFIG_SD_BUFFER_SIZE]
90 __aligned(MAX(4, CONFIG_SDHC_BUFFER_ALIGNMENT)); /* Card internal buffer */
91};
92
105int sd_init(const struct device *sdhc_dev, struct sd_card *card);
106
114bool sd_is_card_present(const struct device *sdhc_dev);
115
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif /* ZEPHYR_INCLUDE_SD_SD_H_ */
sd_voltage
SD voltage.
Definition sdhc.h:146
#define MAX(a, b)
Obtain the maximum of two values.
Definition util.h:385
Public kernel APIs.
card_status
card status.
Definition sd.h:26
@ CARD_ERROR
card state is error
Definition sd.h:28
@ CARD_INITIALIZED
card is in valid state
Definition sd.h:29
@ CARD_UNINITIALIZED
card has not been initialized
Definition sd.h:27
int sd_init(const struct device *sdhc_dev, struct sd_card *card)
Initialize an SD device.
bool sd_is_card_present(const struct device *sdhc_dev)
checks to see if card is present in the SD slot
card_type
card type.
Definition sd.h:35
@ CARD_SDIO
SD I/O card.
Definition sd.h:37
@ CARD_MMC
MMC memory card.
Definition sd.h:39
@ CARD_SDMMC
SD memory card.
Definition sd.h:36
@ CARD_COMBO
SD memory and I/O card.
Definition sd.h:38
sdio_func_num
SDIO function number.
Definition sd_spec.h:784
SD Host Controller public API header file.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
Mutex Structure.
Definition kernel.h:2994
SD card structure.
Definition sd.h:63
enum card_status status
Card status.
Definition sd.h:77
struct sd_switch_caps switch_caps
SD switch capabilities.
Definition sd.h:70
unsigned int num_io
I/O function count.
Definition sd.h:71
uint16_t relative_addr
Card relative address.
Definition sd.h:72
uint8_t bus_width
Desired bus width.
Definition sd.h:80
uint16_t block_size
SD block size.
Definition sd.h:74
uint8_t sd_version
SD specification version.
Definition sd.h:75
enum card_type type
Card type.
Definition sd.h:78
uint8_t card_buffer[CONFIG_SD_BUFFER_SIZE]
Definition sd.h:90
uint32_t ocr
Raw card OCR content.
Definition sd.h:69
struct sdhc_io bus_io
Current bus I/O props for SDHC.
Definition sd.h:65
uint8_t card_speed
Card timing mode.
Definition sd.h:76
struct sdio_func func0
Function 0 common card data.
Definition sd.h:82
struct sdhc_host_props host_props
SDHC host properties.
Definition sd.h:68
uint32_t cccr_flags
SDIO CCCR data.
Definition sd.h:81
struct k_mutex lock
card mutex
Definition sd.h:67
uint32_t block_count
Number of blocks in SD card.
Definition sd.h:73
uint16_t flags
Card flags.
Definition sd.h:79
enum sd_voltage card_voltage
Card signal voltage.
Definition sd.h:66
const struct device * sdhc
SD host controller for card.
Definition sd.h:64
SD switch capabilities.
Definition sd_spec.h:505
SD host controller properties.
Definition sdhc.h:225
SD host controller I/O control structure.
Definition sdhc.h:210
SDIO common CIS tuple properties.
Definition sd_spec.h:918
SDIO function definition.
Definition sd.h:48
enum sdio_func_num num
Function number.
Definition sd.h:49
struct sd_card * card
Card this function is present on.
Definition sd.h:50
uint16_t block_size
Current block size for this function.
Definition sd.h:52
struct sdio_cis cis
CIS tuple data for this function.
Definition sd.h:51