Lines Matching refs:cfg

152 	const struct usdhc_config *cfg = dev->config;  in card_detect_gpio_cb()  local
155 if (gpio_pin_get_dt(&cfg->detect_gpio)) { in card_detect_gpio_cb()
172 static int imx_usdhc_dat3_pull(const struct usdhc_config *cfg, bool pullup) in imx_usdhc_dat3_pull() argument
176 ret = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_NOPULL); in imx_usdhc_dat3_pull()
184 if (cfg->pwr_gpio.port) { in imx_usdhc_dat3_pull()
185 ret = gpio_pin_set_dt(&cfg->pwr_gpio, 0); in imx_usdhc_dat3_pull()
191 ret = gpio_pin_set_dt(&cfg->pwr_gpio, 1); in imx_usdhc_dat3_pull()
208 const struct usdhc_config *cfg = dev->config; in imx_usdhc_error_recovery() local
209 uint32_t status = USDHC_GetPresentStatusFlags(cfg->base); in imx_usdhc_error_recovery()
213 USDHC_Reset(cfg->base, kUSDHC_ResetCommand, 100U); in imx_usdhc_error_recovery()
216 (USDHC_GetAdmaErrorStatusFlags(cfg->base) != 0U)) { in imx_usdhc_error_recovery()
218 USDHC_Reset(cfg->base, kUSDHC_DataInhibitFlag, 100U); in imx_usdhc_error_recovery()
227 const struct usdhc_config *cfg = dev->config; in imx_usdhc_init_host_props() local
233 props->f_max = cfg->max_bus_freq; in imx_usdhc_init_host_props()
234 props->f_min = cfg->min_bus_freq; in imx_usdhc_init_host_props()
235 props->max_current_330 = cfg->max_current_330; in imx_usdhc_init_host_props()
236 props->max_current_180 = cfg->max_current_180; in imx_usdhc_init_host_props()
237 props->power_delay = cfg->power_delay_ms; in imx_usdhc_init_host_props()
239 USDHC_GetCapability(cfg->base, &caps); in imx_usdhc_init_host_props()
240 if (cfg->no_180_vol) { in imx_usdhc_init_host_props()
257 props->host_caps.hs200_support = (bool)(cfg->mmc_hs200_1_8v); in imx_usdhc_init_host_props()
258 props->host_caps.hs400_support = (bool)(cfg->mmc_hs400_1_8v); in imx_usdhc_init_host_props()
266 const struct usdhc_config *cfg = dev->config; in imx_usdhc_reset() local
268 imx_usdhc_select_1_8v(cfg->base, false); in imx_usdhc_reset()
269 USDHC_EnableDDRMode(cfg->base, false, 0U); in imx_usdhc_reset()
271 USDHC_EnableStandardTuning(cfg->base, 0, 0, false); in imx_usdhc_reset()
272 USDHC_EnableAutoTuning(cfg->base, false); in imx_usdhc_reset()
277 USDHC_EnableHS400Mode(cfg->base, false); in imx_usdhc_reset()
279 USDHC_EnableStrobeDLL(cfg->base, false); in imx_usdhc_reset()
283 return USDHC_Reset(cfg->base, kUSDHC_ResetAll, 1000U) == true ? 0 : -ETIMEDOUT; in imx_usdhc_reset()
291 const struct usdhc_config *cfg = dev->config; in imx_usdhc_set_io() local
303 if (clock_control_get_rate(cfg->clock_dev, in imx_usdhc_set_io()
304 cfg->clock_subsys, in imx_usdhc_set_io()
317 bus_clk = USDHC_SetSdClock(cfg->base, src_clk_hz, ios->clock); in imx_usdhc_set_io()
331 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth1Bit); in imx_usdhc_set_io()
334 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth4Bit); in imx_usdhc_set_io()
337 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth8Bit); in imx_usdhc_set_io()
350 imx_usdhc_select_1_8v(cfg->base, false); in imx_usdhc_set_io()
364 imx_usdhc_select_1_8v(cfg->base, true); in imx_usdhc_set_io()
368 USDHC_ForceClockOn(cfg->base, true); in imx_usdhc_set_io()
372 USDHC_ForceClockOn(cfg->base, false); in imx_usdhc_set_io()
382 if ((host_io->power_mode != ios->power_mode) && (cfg->pwr_gpio.port)) { in imx_usdhc_set_io()
384 gpio_pin_set_dt(&cfg->pwr_gpio, 0); in imx_usdhc_set_io()
386 gpio_pin_set_dt(&cfg->pwr_gpio, 1); in imx_usdhc_set_io()
400 USDHC_EnableDDRMode(cfg->base, true, 0); in imx_usdhc_set_io()
404 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_SLOW); in imx_usdhc_set_io()
407 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_MED); in imx_usdhc_set_io()
411 USDHC_EnableHS400Mode(cfg->base, true); in imx_usdhc_set_io()
412 USDHC_EnableDDRMode(cfg->base, true, 0U); in imx_usdhc_set_io()
413 USDHC_ConfigStrobeDLL(cfg->base, 7U, 4U); in imx_usdhc_set_io()
414 USDHC_EnableStrobeDLL(cfg->base, true); in imx_usdhc_set_io()
421 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_FAST); in imx_usdhc_set_io()
438 const struct usdhc_config *cfg = dev->config; in imx_usdhc_transfer() local
458 error = USDHC_TransferNonBlocking(cfg->base, &dev_data->transfer_handle, in imx_usdhc_transfer()
461 error = USDHC_TransferNonBlocking(cfg->base, &dev_data->transfer_handle, in imx_usdhc_transfer()
519 const struct usdhc_config *cfg = dev->config; in imx_usdhc_card_busy() local
521 return (USDHC_GetPresentStatusFlags(cfg->base) in imx_usdhc_card_busy()
534 const struct usdhc_config *cfg = dev->config; in imx_usdhc_execute_tuning() local
566 USDHC_Reset(cfg->base, kUSDHC_ResetTuning, 100U); in imx_usdhc_execute_tuning()
568 USDHC_EnableStandardTuning(cfg->base, IMX_USDHC_STANDARD_TUNING_START, in imx_usdhc_execute_tuning()
570 USDHC_ForceClockOn(cfg->base, true); in imx_usdhc_execute_tuning()
576 USDHC_SetStandardTuningCounter(cfg->base, IMX_USDHC_STANDARD_TUNING_COUNTER); in imx_usdhc_execute_tuning()
578 USDHC_EnableStandardTuning(cfg->base, IMX_USDHC_STANDARD_TUNING_START, in imx_usdhc_execute_tuning()
594 if (USDHC_GetExecuteStdTuningStatus(cfg->base) != 0) { in imx_usdhc_execute_tuning()
598 if ((USDHC_CheckTuningError(cfg->base) != 0U) && retry_tuning) { in imx_usdhc_execute_tuning()
601 USDHC_EnableStandardTuning(cfg->base, in imx_usdhc_execute_tuning()
604 USDHC_SetTuningDelay(cfg->base, in imx_usdhc_execute_tuning()
612 if (USDHC_CheckStdTuningResult(cfg->base) == 0) { in imx_usdhc_execute_tuning()
615 USDHC_ForceClockOn(cfg->base, false); in imx_usdhc_execute_tuning()
618 USDHC_EnableAutoTuning(cfg->base, true); in imx_usdhc_execute_tuning()
628 const struct usdhc_config *cfg = dev->config; in imx_usdhc_request() local
639 USDHC_SetCardActive(cfg->base, 0xFFFF); in imx_usdhc_request()
733 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CommandFlag | in imx_usdhc_request()
735 USDHC_ClearInterruptStatusFlags(cfg->base, kUSDHC_CommandFlag | in imx_usdhc_request()
794 const struct usdhc_config *cfg = dev->config; in imx_usdhc_get_card_present() local
797 if (cfg->detect_dat3) { in imx_usdhc_get_card_present()
804 imx_usdhc_dat3_pull(cfg, false); in imx_usdhc_get_card_present()
805 USDHC_CardDetectByData3(cfg->base, true); in imx_usdhc_get_card_present()
808 data->card_present = USDHC_DetectCardInsert(cfg->base); in imx_usdhc_get_card_present()
810 imx_usdhc_dat3_pull(cfg, true); in imx_usdhc_get_card_present()
811 USDHC_CardDetectByData3(cfg->base, false); in imx_usdhc_get_card_present()
813 } else if (cfg->detect_cd) { in imx_usdhc_get_card_present()
818 data->card_present = USDHC_DetectCardInsert(cfg->base); in imx_usdhc_get_card_present()
819 } else if (cfg->detect_gpio.port) { in imx_usdhc_get_card_present()
820 data->card_present = gpio_pin_get_dt(&cfg->detect_gpio) > 0; in imx_usdhc_get_card_present()
848 const struct usdhc_config *cfg = dev->config; in imx_usdhc_enable_interrupt() local
857 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
858 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
859 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
860 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
866 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInsertionFlag); in imx_usdhc_enable_interrupt()
867 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInsertionFlag); in imx_usdhc_enable_interrupt()
868 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardRemovalFlag); in imx_usdhc_enable_interrupt()
869 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardRemovalFlag); in imx_usdhc_enable_interrupt()
874 USDHC_EnableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
875 USDHC_EnableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
878 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
880 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
887 USDHC_EnableInterruptStatus(cfg->base, in imx_usdhc_enable_interrupt()
889 USDHC_EnableInterruptSignal(cfg->base, in imx_usdhc_enable_interrupt()
894 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
896 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
903 USDHC_EnableInterruptStatus(cfg->base, in imx_usdhc_enable_interrupt()
905 USDHC_EnableInterruptSignal(cfg->base, in imx_usdhc_enable_interrupt()
915 const struct usdhc_config *cfg = dev->config; in imx_usdhc_disable_interrupt() local
922 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_disable_interrupt()
923 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_disable_interrupt()
926 if (cfg->detect_gpio.port) { in imx_usdhc_disable_interrupt()
927 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_disable_interrupt()
934 USDHC_DisableInterruptStatus(cfg->base, in imx_usdhc_disable_interrupt()
936 USDHC_DisableInterruptSignal(cfg->base, in imx_usdhc_disable_interrupt()
941 if (cfg->detect_gpio.port) { in imx_usdhc_disable_interrupt()
942 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_disable_interrupt()
949 USDHC_DisableInterruptStatus(cfg->base, in imx_usdhc_disable_interrupt()
951 USDHC_DisableInterruptSignal(cfg->base, in imx_usdhc_disable_interrupt()
957 if ((USDHC_GetEnabledInterruptStatusFlags(cfg->base) & in imx_usdhc_disable_interrupt()
969 const struct usdhc_config *cfg = dev->config; in imx_usdhc_isr() local
972 USDHC_TransferHandleIRQ(cfg->base, &data->transfer_handle); in imx_usdhc_isr()
981 const struct usdhc_config *cfg = dev->config; in imx_usdhc_init() local
992 if (!device_is_ready(cfg->clock_dev)) { in imx_usdhc_init()
997 ret = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT); in imx_usdhc_init()
1001 USDHC_TransferCreateHandle(cfg->base, &data->transfer_handle, in imx_usdhc_init()
1003 cfg->irq_config_func(dev); in imx_usdhc_init()
1006 host_config.dataTimeout = cfg->data_timeout; in imx_usdhc_init()
1008 host_config.readWatermarkLevel = cfg->read_watermark; in imx_usdhc_init()
1009 host_config.writeWatermarkLevel = cfg->write_watermark; in imx_usdhc_init()
1010 USDHC_Init(cfg->base, &host_config); in imx_usdhc_init()
1014 if (cfg->pwr_gpio.port) { in imx_usdhc_init()
1015 ret = gpio_pin_configure_dt(&cfg->pwr_gpio, GPIO_OUTPUT_INACTIVE); in imx_usdhc_init()
1023 if (cfg->detect_gpio.port) { in imx_usdhc_init()
1024 ret = gpio_pin_configure_dt(&cfg->detect_gpio, GPIO_INPUT); in imx_usdhc_init()
1029 BIT(cfg->detect_gpio.pin)); in imx_usdhc_init()
1030 ret = gpio_add_callback_dt(&cfg->detect_gpio, &data->cd_callback); in imx_usdhc_init()