Lines Matching refs:cfg

151 	const struct usdhc_config *cfg = dev->config;  in card_detect_gpio_cb()  local
154 if (gpio_pin_get_dt(&cfg->detect_gpio)) { in card_detect_gpio_cb()
163 static int imx_usdhc_dat3_pull(const struct usdhc_config *cfg, bool pullup) in imx_usdhc_dat3_pull() argument
167 ret = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_NOPULL); in imx_usdhc_dat3_pull()
175 if (cfg->pwr_gpio.port) { in imx_usdhc_dat3_pull()
176 ret = gpio_pin_set_dt(&cfg->pwr_gpio, 0); in imx_usdhc_dat3_pull()
182 ret = gpio_pin_set_dt(&cfg->pwr_gpio, 1); in imx_usdhc_dat3_pull()
199 const struct usdhc_config *cfg = dev->config; in imx_usdhc_error_recovery() local
200 uint32_t status = USDHC_GetPresentStatusFlags(cfg->base); in imx_usdhc_error_recovery()
204 USDHC_Reset(cfg->base, kUSDHC_ResetCommand, 100U); in imx_usdhc_error_recovery()
207 (USDHC_GetAdmaErrorStatusFlags(cfg->base) != 0U)) { in imx_usdhc_error_recovery()
209 USDHC_Reset(cfg->base, kUSDHC_DataInhibitFlag, 100U); in imx_usdhc_error_recovery()
218 const struct usdhc_config *cfg = dev->config; in imx_usdhc_init_host_props() local
224 props->f_max = cfg->max_bus_freq; in imx_usdhc_init_host_props()
225 props->f_min = cfg->min_bus_freq; in imx_usdhc_init_host_props()
226 props->max_current_330 = cfg->max_current_330; in imx_usdhc_init_host_props()
227 props->max_current_180 = cfg->max_current_180; in imx_usdhc_init_host_props()
228 props->power_delay = cfg->power_delay_ms; in imx_usdhc_init_host_props()
230 USDHC_GetCapability(cfg->base, &caps); in imx_usdhc_init_host_props()
231 if (cfg->no_180_vol) { in imx_usdhc_init_host_props()
248 props->host_caps.hs200_support = (bool)(cfg->mmc_hs200_1_8v); in imx_usdhc_init_host_props()
249 props->host_caps.hs400_support = (bool)(cfg->mmc_hs400_1_8v); in imx_usdhc_init_host_props()
257 const struct usdhc_config *cfg = dev->config; in imx_usdhc_reset() local
259 UDSHC_SelectVoltage(cfg->base, false); in imx_usdhc_reset()
260 USDHC_EnableDDRMode(cfg->base, false, 0U); in imx_usdhc_reset()
262 USDHC_EnableStandardTuning(cfg->base, 0, 0, false); in imx_usdhc_reset()
263 USDHC_EnableAutoTuning(cfg->base, false); in imx_usdhc_reset()
268 USDHC_EnableHS400Mode(cfg->base, false); in imx_usdhc_reset()
270 USDHC_EnableStrobeDLL(cfg->base, false); in imx_usdhc_reset()
274 return USDHC_Reset(cfg->base, kUSDHC_ResetAll, 100U) == true ? 0 : -ETIMEDOUT; in imx_usdhc_reset()
297 const struct usdhc_config *cfg = dev->config; in imx_usdhc_set_io() local
309 if (clock_control_get_rate(cfg->clock_dev, in imx_usdhc_set_io()
310 cfg->clock_subsys, in imx_usdhc_set_io()
323 bus_clk = USDHC_SetSdClock(cfg->base, src_clk_hz, ios->clock); in imx_usdhc_set_io()
337 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth1Bit); in imx_usdhc_set_io()
340 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth4Bit); in imx_usdhc_set_io()
343 USDHC_SetDataBusWidth(cfg->base, kUSDHC_DataBusWidth8Bit); in imx_usdhc_set_io()
356 UDSHC_SelectVoltage(cfg->base, false); in imx_usdhc_set_io()
370 UDSHC_SelectVoltage(cfg->base, true); in imx_usdhc_set_io()
374 USDHC_ForceClockOn(cfg->base, true); in imx_usdhc_set_io()
378 USDHC_ForceClockOn(cfg->base, false); in imx_usdhc_set_io()
388 if ((host_io->power_mode != ios->power_mode) && (cfg->pwr_gpio.port)) { in imx_usdhc_set_io()
390 gpio_pin_set_dt(&cfg->pwr_gpio, 0); in imx_usdhc_set_io()
392 gpio_pin_set_dt(&cfg->pwr_gpio, 1); in imx_usdhc_set_io()
406 USDHC_EnableDDRMode(cfg->base, true, 0); in imx_usdhc_set_io()
410 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_SLOW); in imx_usdhc_set_io()
413 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_MED); in imx_usdhc_set_io()
417 USDHC_EnableHS400Mode(cfg->base, true); in imx_usdhc_set_io()
418 USDHC_EnableDDRMode(cfg->base, true, 0U); in imx_usdhc_set_io()
419 USDHC_ConfigStrobeDLL(cfg->base, 7U, 4U); in imx_usdhc_set_io()
420 USDHC_EnableStrobeDLL(cfg->base, true); in imx_usdhc_set_io()
427 pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_FAST); in imx_usdhc_set_io()
444 const struct usdhc_config *cfg = dev->config; in imx_usdhc_transfer() local
464 error = USDHC_TransferNonBlocking(cfg->base, &dev_data->transfer_handle, in imx_usdhc_transfer()
467 error = USDHC_TransferNonBlocking(cfg->base, &dev_data->transfer_handle, in imx_usdhc_transfer()
525 const struct usdhc_config *cfg = dev->config; in imx_usdhc_card_busy() local
527 return (USDHC_GetPresentStatusFlags(cfg->base) in imx_usdhc_card_busy()
540 const struct usdhc_config *cfg = dev->config; in imx_usdhc_execute_tuning() local
572 USDHC_Reset(cfg->base, kUSDHC_ResetTuning, 100U); in imx_usdhc_execute_tuning()
574 USDHC_EnableStandardTuning(cfg->base, IMX_USDHC_STANDARD_TUNING_START, in imx_usdhc_execute_tuning()
576 USDHC_ForceClockOn(cfg->base, true); in imx_usdhc_execute_tuning()
582 USDHC_SetStandardTuningCounter(cfg->base, IMX_USDHC_STANDARD_TUNING_COUNTER); in imx_usdhc_execute_tuning()
584 USDHC_EnableStandardTuning(cfg->base, IMX_USDHC_STANDARD_TUNING_START, in imx_usdhc_execute_tuning()
600 if (USDHC_GetExecuteStdTuningStatus(cfg->base) != 0) { in imx_usdhc_execute_tuning()
604 if ((USDHC_CheckTuningError(cfg->base) != 0U) && retry_tuning) { in imx_usdhc_execute_tuning()
607 USDHC_EnableStandardTuning(cfg->base, in imx_usdhc_execute_tuning()
610 USDHC_SetTuningDelay(cfg->base, in imx_usdhc_execute_tuning()
618 if (USDHC_CheckStdTuningResult(cfg->base) == 0) { in imx_usdhc_execute_tuning()
621 USDHC_ForceClockOn(cfg->base, false); in imx_usdhc_execute_tuning()
624 USDHC_EnableAutoTuning(cfg->base, true); in imx_usdhc_execute_tuning()
634 const struct usdhc_config *cfg = dev->config; in imx_usdhc_request() local
645 USDHC_SetCardActive(cfg->base, 0xFFFF); in imx_usdhc_request()
739 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CommandFlag | in imx_usdhc_request()
741 USDHC_ClearInterruptStatusFlags(cfg->base, kUSDHC_CommandFlag | in imx_usdhc_request()
800 const struct usdhc_config *cfg = dev->config; in imx_usdhc_get_card_present() local
803 if (cfg->detect_dat3) { in imx_usdhc_get_card_present()
810 imx_usdhc_dat3_pull(cfg, false); in imx_usdhc_get_card_present()
811 USDHC_CardDetectByData3(cfg->base, true); in imx_usdhc_get_card_present()
814 data->card_present = USDHC_DetectCardInsert(cfg->base); in imx_usdhc_get_card_present()
816 imx_usdhc_dat3_pull(cfg, true); in imx_usdhc_get_card_present()
817 USDHC_CardDetectByData3(cfg->base, false); 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()
822 data->card_present = USDHC_DetectCardInsert(cfg->base); in imx_usdhc_get_card_present()
846 const struct usdhc_config *cfg = dev->config; in imx_usdhc_enable_interrupt() local
855 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
856 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
857 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
858 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
864 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInsertionFlag); in imx_usdhc_enable_interrupt()
865 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInsertionFlag); in imx_usdhc_enable_interrupt()
866 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardRemovalFlag); in imx_usdhc_enable_interrupt()
867 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardRemovalFlag); in imx_usdhc_enable_interrupt()
872 USDHC_EnableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
873 USDHC_EnableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_enable_interrupt()
876 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
878 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
885 USDHC_EnableInterruptStatus(cfg->base, in imx_usdhc_enable_interrupt()
887 USDHC_EnableInterruptSignal(cfg->base, in imx_usdhc_enable_interrupt()
892 if (cfg->detect_gpio.port) { in imx_usdhc_enable_interrupt()
894 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_enable_interrupt()
901 USDHC_EnableInterruptStatus(cfg->base, in imx_usdhc_enable_interrupt()
903 USDHC_EnableInterruptSignal(cfg->base, in imx_usdhc_enable_interrupt()
913 const struct usdhc_config *cfg = dev->config; in imx_usdhc_disable_interrupt() local
920 USDHC_DisableInterruptStatus(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_disable_interrupt()
921 USDHC_DisableInterruptSignal(cfg->base, kUSDHC_CardInterruptFlag); in imx_usdhc_disable_interrupt()
924 if (cfg->detect_gpio.port) { in imx_usdhc_disable_interrupt()
925 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_disable_interrupt()
932 USDHC_DisableInterruptStatus(cfg->base, in imx_usdhc_disable_interrupt()
934 USDHC_DisableInterruptSignal(cfg->base, in imx_usdhc_disable_interrupt()
939 if (cfg->detect_gpio.port) { in imx_usdhc_disable_interrupt()
940 ret = gpio_pin_interrupt_configure_dt(&cfg->detect_gpio, in imx_usdhc_disable_interrupt()
947 USDHC_DisableInterruptStatus(cfg->base, in imx_usdhc_disable_interrupt()
949 USDHC_DisableInterruptSignal(cfg->base, in imx_usdhc_disable_interrupt()
955 if ((USDHC_GetEnabledInterruptStatusFlags(cfg->base) & in imx_usdhc_disable_interrupt()
967 const struct usdhc_config *cfg = dev->config; in imx_usdhc_isr() local
970 USDHC_TransferHandleIRQ(cfg->base, &data->transfer_handle); in imx_usdhc_isr()
979 const struct usdhc_config *cfg = dev->config; in imx_usdhc_init() local
990 if (!device_is_ready(cfg->clock_dev)) { in imx_usdhc_init()
995 ret = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT); in imx_usdhc_init()
999 USDHC_TransferCreateHandle(cfg->base, &data->transfer_handle, in imx_usdhc_init()
1001 cfg->irq_config_func(dev); in imx_usdhc_init()
1004 host_config.dataTimeout = cfg->data_timeout; in imx_usdhc_init()
1006 host_config.readWatermarkLevel = cfg->read_watermark; in imx_usdhc_init()
1007 host_config.writeWatermarkLevel = cfg->write_watermark; in imx_usdhc_init()
1008 USDHC_Init(cfg->base, &host_config); in imx_usdhc_init()
1012 if (cfg->pwr_gpio.port) { in imx_usdhc_init()
1013 ret = gpio_pin_configure_dt(&cfg->pwr_gpio, GPIO_OUTPUT_INACTIVE); in imx_usdhc_init()
1021 if (cfg->detect_gpio.port) { in imx_usdhc_init()
1022 ret = gpio_pin_configure_dt(&cfg->detect_gpio, GPIO_INPUT); in imx_usdhc_init()
1027 BIT(cfg->detect_gpio.pin)); in imx_usdhc_init()
1028 ret = gpio_add_callback_dt(&cfg->detect_gpio, &data->cd_callback); in imx_usdhc_init()