Lines Matching refs:priv

97 	struct sdhc_ra_priv *priv = dev->data;  in sdhc_ra_get_card_present()  local
103 fsp_err = R_SDHI_StatusGet(&priv->sdmmc_ctrl, &status); in sdhc_ra_get_card_present()
114 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_card_busy() local
119 fsp_err = R_SDHI_StatusGet(&priv->sdmmc_ctrl, &status); in sdhc_ra_card_busy()
141 static int sdhc_ra_send_cmd(struct sdhc_ra_priv *priv, struct sdmmc_ra_command *ra_cmd, int retries) in sdhc_ra_send_cmd() argument
146 fsp_err = sdhi_command_send_wait(&priv->sdmmc_ctrl, ra_cmd->opcode, ra_cmd->arg, in sdhc_ra_send_cmd()
163 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_request() local
191 k_sem_reset(&priv->sdmmc_event.transfer_sem); in sdhc_ra_request()
192 k_sem_take(&priv->thread_lock, K_FOREVER); in sdhc_ra_request()
214 ret = sdhc_ra_send_cmd(priv, &ra_cmd, retries); in sdhc_ra_request()
221 ret = sdhc_ra_send_cmd(priv, &ra_cmd, retries); in sdhc_ra_request()
226 p_csd_reg.reg.sdrsp10 = priv->sdmmc_ctrl.p_reg->SD_RSP10; in sdhc_ra_request()
227 p_csd_reg.reg.sdrsp32 = priv->sdmmc_ctrl.p_reg->SD_RSP32; in sdhc_ra_request()
228 p_csd_reg.reg.sdrsp54 = priv->sdmmc_ctrl.p_reg->SD_RSP54; in sdhc_ra_request()
229 p_csd_reg.reg.sdrsp76 = priv->sdmmc_ctrl.p_reg->SD_RSP76; in sdhc_ra_request()
236 (SDMMC_CARD_TYPE_MMC == priv->sdmmc_ctrl.device.card_type)) { in sdhc_ra_request()
238 priv->sdmmc_ctrl.device.sector_count = in sdhc_ra_request()
244 priv->sdmmc_ctrl.device.sector_count = in sdhc_ra_request()
245 priv->sdmmc_ctrl.device.sector_count * in sdhc_ra_request()
248 if (SDMMC_CARD_TYPE_MMC == priv->sdmmc_ctrl.device.card_type) { in sdhc_ra_request()
255 priv->sdmmc_ctrl.device.sector_count = 0U; in sdhc_ra_request()
262 priv->sdmmc_ctrl.device.sector_count = in sdhc_ra_request()
270 priv->sdmmc_ctrl.device.erase_sector_count = in sdhc_ra_request()
279 priv->sdmmc_ctrl.device.erase_sector_count = 1U; in sdhc_ra_request()
284 ret = sdhc_ra_send_cmd(priv, &ra_cmd, retries); in sdhc_ra_request()
290 response.status = priv->sdmmc_ctrl.p_reg->SD_RSP10; in sdhc_ra_request()
295 priv->sdmmc_ctrl.sector_addressing = in sdhc_ra_request()
297 priv->sdmmc_ctrl.device.card_type = SDMMC_CARD_TYPE_SD; in sdhc_ra_request()
299 priv->sdmmc_ctrl.initialized = true; in sdhc_ra_request()
303 if (priv->app_cmd && cmd->opcode == SD_APP_SET_BUS_WIDTH) { in sdhc_ra_request()
306 ret = sdhc_ra_send_cmd(priv, &ra_cmd, retries); in sdhc_ra_request()
312 fsp_err = r_sdhi_read_and_block(&priv->sdmmc_ctrl, ra_cmd.opcode, in sdhc_ra_request()
318 memcpy(ra_cmd.data, priv->sdmmc_ctrl.aligned_buff, 8); in sdhc_ra_request()
319 priv->sdmmc_event.transfer_completed = false; in sdhc_ra_request()
327 fsp_err = r_sdhi_read_and_block(&priv->sdmmc_ctrl, ra_cmd.opcode, ra_cmd.arg, in sdhc_ra_request()
334 memcpy(ra_cmd.data, priv->sdmmc_ctrl.aligned_buff, 8); in sdhc_ra_request()
335 priv->sdmmc_event.transfer_completed = false; in sdhc_ra_request()
340 fsp_err = r_sdhi_transfer_read(&priv->sdmmc_ctrl, ra_cmd.sector_count, in sdhc_ra_request()
347 r_sdhi_read_write_common(&priv->sdmmc_ctrl, ra_cmd.sector_count, ra_cmd.sector_size, in sdhc_ra_request()
351 ret = k_sem_take(&priv->sdmmc_event.transfer_sem, K_MSEC(ra_cmd.timeout_ms)); in sdhc_ra_request()
357 if (!priv->sdmmc_event.transfer_completed) { in sdhc_ra_request()
362 priv->sdmmc_event.transfer_completed = false; in sdhc_ra_request()
368 fsp_err = r_sdhi_transfer_write(&priv->sdmmc_ctrl, ra_cmd.sector_count, in sdhc_ra_request()
375 r_sdhi_read_write_common(&priv->sdmmc_ctrl, ra_cmd.sector_count, ra_cmd.sector_size, in sdhc_ra_request()
379 ret = k_sem_take(&priv->sdmmc_event.transfer_sem, K_MSEC(ra_cmd.timeout_ms)); in sdhc_ra_request()
385 if (!priv->sdmmc_event.transfer_completed) { in sdhc_ra_request()
390 priv->sdmmc_event.transfer_completed = false; in sdhc_ra_request()
400 p_csd_reg.reg.sdrsp10 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP10 << 8; in sdhc_ra_request()
401 p_csd_reg.reg.sdrsp32 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP32 << 8; in sdhc_ra_request()
402 p_csd_reg.reg.sdrsp54 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP54 << 8; in sdhc_ra_request()
403 p_csd_reg.reg.sdrsp76 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP76 << 8; in sdhc_ra_request()
408 p_csd_reg.reg.sdrsp10 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP10; in sdhc_ra_request()
409 p_csd_reg.reg.sdrsp32 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP32; in sdhc_ra_request()
410 p_csd_reg.reg.sdrsp54 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP54; in sdhc_ra_request()
411 p_csd_reg.reg.sdrsp76 = (uint32_t)priv->sdmmc_ctrl.p_reg->SD_RSP76; in sdhc_ra_request()
417 priv->app_cmd = true; in sdhc_ra_request()
419 priv->app_cmd = false; in sdhc_ra_request()
422 k_sem_give(&priv->thread_lock); in sdhc_ra_request()
429 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_reset() local
432 k_sem_take(&priv->thread_lock, K_USEC(50)); in sdhc_ra_reset()
438 k_sem_give(&priv->thread_lock); in sdhc_ra_reset()
448 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_set_io() local
450 struct st_sdmmc_instance_ctrl *p_ctrl = &priv->sdmmc_ctrl; in sdhc_ra_set_io()
473 if (priv->bus_width != bus_width) { in sdhc_ra_set_io()
478 priv->bus_width = bus_width; in sdhc_ra_set_io()
483 if (ios->clock > priv->props.f_max || ios->clock < priv->props.f_min) { in sdhc_ra_set_io()
488 if (priv->bus_clock != (uint32_t)ios->clock) { in sdhc_ra_set_io()
494 priv->bus_clock = ios->clock; in sdhc_ra_set_io()
500 if (priv->timing != ios->timing) { in sdhc_ra_set_io()
513 priv->timing = ios->timing; in sdhc_ra_set_io()
526 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_get_host_props() local
528 memcpy(props, &priv->props, sizeof(struct sdhc_host_props)); in sdhc_ra_get_host_props()
535 struct sdhc_ra_priv *priv = dev->data; in sdhc_ra_init() local
540 priv->sdmmc_event.transfer_completed = false; in sdhc_ra_init()
541 k_sem_init(&priv->sdmmc_event.transfer_sem, 1, 1); in sdhc_ra_init()
548 if (priv->sdhi_en.port != NULL) { in sdhc_ra_init()
549 int err = gpio_pin_configure_dt(&priv->sdhi_en, GPIO_OUTPUT_HIGH); in sdhc_ra_init()
557 k_sem_init(&priv->thread_lock, 1, 1); in sdhc_ra_init()
558 fsp_err = R_SDHI_Open(&priv->sdmmc_ctrl, &priv->fsp_config); in sdhc_ra_init()
568 k_sem_take(&priv->thread_lock, K_USEC(timeout)); in sdhc_ra_init()
570 fsp_err = r_sdhi_hw_cfg(&priv->sdmmc_ctrl); in sdhc_ra_init()
576 priv->bus_width = SDMMC_BUS_WIDTH_1_BIT; in sdhc_ra_init()
577 priv->timing = SDHC_TIMING_LEGACY; in sdhc_ra_init()
578 priv->bus_clock = SDMMC_CLOCK_400KHZ; in sdhc_ra_init()
581 k_sem_give(&priv->thread_lock); in sdhc_ra_init()
671 struct sdhc_ra_priv *priv = dev->data; \
673 priv->sdmmc_event.transfer_completed = true; \
674 k_sem_give(&priv->sdmmc_event.transfer_sem); \
676 priv->sdmmc_event.transfer_completed = false; \
677 k_sem_give(&priv->sdmmc_event.transfer_sem); \