Lines Matching +full:bus +full:- +full:idle +full:- +full:timeout
4 * SPDX-License-Identifier: Apache-2.0
21 /* Idle all cards on bus. Can be used to clear errors on cards */
32 return sdhc_request(card->sdhc, &cmd, NULL); in sd_idle()
38 * - CMD0 (SD reset)
39 * - CMD8 (SD voltage check)
60 ret = sdhc_request(card->sdhc, &cmd, NULL); in sd_send_interface_condition()
66 if (card->host_props.is_spi) { in sd_send_interface_condition()
78 return -ENOTSUP; in sd_send_interface_condition()
81 card->flags |= SD_SDHC_FLAG; in sd_send_interface_condition()
91 __ASSERT_NO_MSG(card->host_props.is_spi); in sd_enable_crc()
97 return sdhc_request(card->sdhc, &cmd, NULL); in sd_enable_crc()
107 if (ret == -ETIMEDOUT) { in sd_common_init()
114 if (card->host_props.is_spi && in sd_common_init()
124 struct sdhc_io *bus_io = &card->bus_io; in sd_init_io()
125 struct sdhc_host_props *host_props = &card->host_props; in sd_init_io()
129 bus_io->clock = 0; in sd_init_io()
131 bus_io->bus_mode = SDHC_BUSMODE_PUSHPULL; in sd_init_io()
132 bus_io->power_mode = SDHC_POWER_ON; in sd_init_io()
133 bus_io->bus_width = SDHC_BUS_WIDTH1BIT; in sd_init_io()
135 bus_io->timing = SDHC_TIMING_LEGACY; in sd_init_io()
137 if (host_props->host_caps.vol_330_support) { in sd_init_io()
140 } else if (host_props->host_caps.vol_300_support) { in sd_init_io()
149 bus_io->signal_voltage = voltage; in sd_init_io()
153 bus_io->power_mode = SDHC_POWER_OFF; in sd_init_io()
154 ret = sdhc_set_io(card->sdhc, bus_io); in sd_init_io()
159 sd_delay(card->host_props.power_delay); in sd_init_io()
160 bus_io->power_mode = SDHC_POWER_ON; in sd_init_io()
161 ret = sdhc_set_io(card->sdhc, bus_io); in sd_init_io()
167 card->card_voltage = voltage; in sd_init_io()
169 card->flags = 0U; in sd_init_io()
171 sd_delay(card->host_props.power_delay); in sd_init_io()
172 /* Start bus clock */ in sd_init_io()
173 bus_io->clock = SDMMC_CLOCK_400KHZ; in sd_init_io()
174 ret = sdhc_set_io(card->sdhc, bus_io); in sd_init_io()
176 LOG_ERR("Could not start bus clock"); in sd_init_io()
230 return -ENOTSUP; in sd_command_init()
239 return -ENODEV; in sd_init()
241 card->sdhc = sdhc_dev; in sd_init()
242 ret = sdhc_get_host_props(card->sdhc, &card->host_props); in sd_init()
249 ret = k_mutex_init(&card->lock); in sd_init()
254 ret = k_mutex_lock(&card->lock, K_MSEC(CONFIG_SD_INIT_TIMEOUT)); in sd_init()
256 LOG_ERR("Timeout while trying to acquire card mutex"); in sd_init()
263 k_mutex_unlock(&card->lock); in sd_init()
272 * - set card status to error in sd_init()
273 * - re init host I/O (will also toggle power to the SD card) in sd_init()
274 * - retry initialization once more in sd_init()
281 card->status = CARD_ERROR; in sd_init()
286 k_mutex_unlock(&card->lock); in sd_init()
292 k_mutex_unlock(&card->lock); in sd_init()
297 k_mutex_unlock(&card->lock); in sd_init()
298 card->status = CARD_ERROR; in sd_init()
302 card->status = CARD_INITIALIZED; in sd_init()
304 ret = k_mutex_unlock(&card->lock); in sd_init()