1 /*
2 * Copyright 2022 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7
8 #ifndef ZEPHYR_SUBSYS_SD_SD_OPS_H_
9 #define ZEPHYR_SUBSYS_SD_SD_OPS_H_
10
11 /*
12 * Switches voltage of SD card to 1.8V, as described by
13 * "Signal voltage switch procedure" in section 3.6.1 of SD host controller specification.
14 */
15 int sdmmc_switch_voltage(struct sd_card *card);
16
17 /*
18 * Reads card identification register, and decodes it
19 */
20 int card_read_cid(struct sd_card *card);
21
22 /*
23 * Read card specific data register
24 */
25 int sdmmc_read_csd(struct sd_card *card);
26
27 /*
28 * Requests card to publish a new relative card address, and move from
29 * identification to data mode
30 */
31 int sdmmc_request_rca(struct sd_card *card);
32
33 /*
34 * Selects card, moving it into data transfer mode
35 */
36 int sdmmc_select_card(struct sd_card *card);
37
38 /* Returns 1 if host supports UHS, zero otherwise */
sdmmc_host_uhs(struct sdhc_host_props * props)39 static inline int sdmmc_host_uhs(struct sdhc_host_props *props)
40 {
41 return (props->host_caps.sdr50_support |
42 props->host_caps.uhs_2_support |
43 props->host_caps.sdr104_support |
44 props->host_caps.ddr50_support)
45 & (props->host_caps.vol_180_support);
46 }
47
48 int card_ioctl(struct sd_card *card, uint8_t cmd, void *buf);
49
50 int card_read_blocks(struct sd_card *card, uint8_t *rbuf,
51 uint32_t start_block, uint32_t num_blocks);
52
53 int card_write_blocks(struct sd_card *card, const uint8_t *wbuf,
54 uint32_t start_block, uint32_t num_blocks);
55
56 int card_app_command(struct sd_card *card, int relative_card_address);
57
58 int sdmmc_read_status(struct sd_card *card);
59
60 int sdmmc_wait_ready(struct sd_card *card);
61
62 #endif /* ZEPHYR_SUBSYS_SD_SD_OPS_H_ */
63