Lines Matching refs:omap_host

136 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host);
137 static void sdhci_omap_stop_clock(struct sdhci_omap_host *omap_host);
151 static int sdhci_omap_set_pbias(struct sdhci_omap_host *omap_host, in sdhci_omap_set_pbias() argument
155 struct device *dev = omap_host->dev; in sdhci_omap_set_pbias()
157 if (IS_ERR(omap_host->pbias)) in sdhci_omap_set_pbias()
161 ret = regulator_set_voltage(omap_host->pbias, iov, iov); in sdhci_omap_set_pbias()
167 if (omap_host->pbias_enabled) in sdhci_omap_set_pbias()
170 ret = regulator_enable(omap_host->pbias); in sdhci_omap_set_pbias()
176 omap_host->pbias_enabled = true; in sdhci_omap_set_pbias()
178 if (!omap_host->pbias_enabled) in sdhci_omap_set_pbias()
181 ret = regulator_disable(omap_host->pbias); in sdhci_omap_set_pbias()
186 omap_host->pbias_enabled = false; in sdhci_omap_set_pbias()
192 static int sdhci_omap_enable_iov(struct sdhci_omap_host *omap_host, in sdhci_omap_enable_iov() argument
196 struct sdhci_host *host = omap_host->host; in sdhci_omap_enable_iov()
199 ret = sdhci_omap_set_pbias(omap_host, false, 0); in sdhci_omap_enable_iov()
212 ret = sdhci_omap_set_pbias(omap_host, true, iov_pbias); in sdhci_omap_enable_iov()
219 static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host, in sdhci_omap_conf_bus_power() argument
225 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL); in sdhci_omap_conf_bus_power()
230 capa = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_conf_bus_power()
236 dev_warn(omap_host->dev, "misconfigured CAPA: %08x\n", in sdhci_omap_conf_bus_power()
245 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, reg); in sdhci_omap_conf_bus_power()
248 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, reg); in sdhci_omap_conf_bus_power()
255 if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP) in sdhci_omap_conf_bus_power()
267 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_enable_sdio_irq() local
270 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_enable_sdio_irq()
275 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_enable_sdio_irq()
280 static inline void sdhci_omap_set_dll(struct sdhci_omap_host *omap_host, in sdhci_omap_set_dll() argument
286 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_set_dll()
290 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
293 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
295 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_set_dll()
300 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
303 static void sdhci_omap_disable_tuning(struct sdhci_omap_host *omap_host) in sdhci_omap_disable_tuning() argument
307 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_disable_tuning()
309 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_disable_tuning()
311 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_disable_tuning()
313 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_disable_tuning()
320 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_execute_tuning() local
322 struct device *dev = omap_host->dev; in sdhci_omap_execute_tuning()
339 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA2); in sdhci_omap_execute_tuning()
353 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_execute_tuning()
355 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_execute_tuning()
368 omap_host->is_tuning = true; in sdhci_omap_execute_tuning()
376 sdhci_omap_set_dll(omap_host, phase_delay); in sdhci_omap_execute_tuning()
436 sdhci_omap_set_dll(omap_host, phase_delay + i); in sdhci_omap_execute_tuning()
453 sdhci_omap_set_dll(omap_host, phase_delay + i); in sdhci_omap_execute_tuning()
472 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_execute_tuning()
478 sdhci_omap_set_dll(omap_host, phase_delay); in sdhci_omap_execute_tuning()
480 omap_host->is_tuning = false; in sdhci_omap_execute_tuning()
485 omap_host->is_tuning = false; in sdhci_omap_execute_tuning()
487 sdhci_omap_disable_tuning(omap_host); in sdhci_omap_execute_tuning()
505 struct sdhci_omap_host *omap_host; in sdhci_omap_card_busy() local
509 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_card_busy()
511 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_card_busy()
512 ac12 = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_card_busy()
517 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_card_busy()
529 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_PSTATE); in sdhci_omap_card_busy()
533 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_card_busy()
535 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_card_busy()
552 struct sdhci_omap_host *omap_host; in sdhci_omap_start_signal_voltage_switch() local
556 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_start_signal_voltage_switch()
557 dev = omap_host->dev; in sdhci_omap_start_signal_voltage_switch()
560 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_start_signal_voltage_switch()
569 sdhci_omap_conf_bus_power(omap_host, ios->signal_voltage); in sdhci_omap_start_signal_voltage_switch()
571 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_start_signal_voltage_switch()
573 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_start_signal_voltage_switch()
576 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_start_signal_voltage_switch()
582 sdhci_omap_conf_bus_power(omap_host, ios->signal_voltage); in sdhci_omap_start_signal_voltage_switch()
584 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_start_signal_voltage_switch()
586 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_start_signal_voltage_switch()
591 ret = sdhci_omap_enable_iov(omap_host, iov); in sdhci_omap_start_signal_voltage_switch()
601 static void sdhci_omap_set_timing(struct sdhci_omap_host *omap_host, u8 timing) in sdhci_omap_set_timing() argument
605 struct device *dev = omap_host->dev; in sdhci_omap_set_timing()
607 if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) in sdhci_omap_set_timing()
610 if (omap_host->timing == timing) in sdhci_omap_set_timing()
613 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_timing()
615 pinctrl_state = omap_host->pinctrl_state[timing]; in sdhci_omap_set_timing()
616 ret = pinctrl_select_state(omap_host->pinctrl, pinctrl_state); in sdhci_omap_set_timing()
622 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_timing()
623 omap_host->timing = timing; in sdhci_omap_set_timing()
626 static void sdhci_omap_set_power_mode(struct sdhci_omap_host *omap_host, in sdhci_omap_set_power_mode() argument
629 if (omap_host->bus_mode == MMC_POWER_OFF) in sdhci_omap_set_power_mode()
630 sdhci_omap_disable_tuning(omap_host); in sdhci_omap_set_power_mode()
631 omap_host->power_mode = power_mode; in sdhci_omap_set_power_mode()
634 static void sdhci_omap_set_bus_mode(struct sdhci_omap_host *omap_host, in sdhci_omap_set_bus_mode() argument
639 if (omap_host->bus_mode == mode) in sdhci_omap_set_bus_mode()
642 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_bus_mode()
647 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_bus_mode()
649 omap_host->bus_mode = mode; in sdhci_omap_set_bus_mode()
656 struct sdhci_omap_host *omap_host; in sdhci_omap_set_ios() local
659 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_ios()
661 sdhci_omap_set_bus_mode(omap_host, ios->bus_mode); in sdhci_omap_set_ios()
662 sdhci_omap_set_timing(omap_host, ios->timing); in sdhci_omap_set_ios()
664 sdhci_omap_set_power_mode(omap_host, ios->power_mode); in sdhci_omap_set_ios()
679 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host) in sdhci_omap_start_clock() argument
683 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_start_clock()
685 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, reg); in sdhci_omap_start_clock()
688 static void sdhci_omap_stop_clock(struct sdhci_omap_host *omap_host) in sdhci_omap_stop_clock() argument
692 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_stop_clock()
694 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, reg); in sdhci_omap_stop_clock()
700 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_clock() local
703 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_clock()
712 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_clock()
731 static bool sdhci_omap_has_adma(struct sdhci_omap_host *omap_host, int offset) in sdhci_omap_has_adma() argument
737 return readl(omap_host->base + 4) & 1; in sdhci_omap_has_adma()
744 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_enable_dma() local
746 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_enable_dma()
752 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_enable_dma()
767 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_bus_width() local
770 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_bus_width()
775 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_bus_width()
785 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_init_74_clocks() local
787 if (omap_host->power_mode == power_mode) in sdhci_omap_init_74_clocks()
795 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_init_74_clocks()
797 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_init_74_clocks()
798 sdhci_omap_writel(omap_host, SDHCI_OMAP_CMD, 0x0); in sdhci_omap_init_74_clocks()
805 if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN) in sdhci_omap_init_74_clocks()
812 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_init_74_clocks()
814 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_init_74_clocks()
815 sdhci_omap_writel(omap_host, SDHCI_OMAP_STAT, INT_CC_EN); in sdhci_omap_init_74_clocks()
825 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_uhs_signaling() local
827 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_uhs_signaling()
829 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_uhs_signaling()
834 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_uhs_signaling()
837 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_uhs_signaling()
844 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_reset() local
851 sysc = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCONFIG); in sdhci_omap_reset()
854 if (omap_host->is_tuning) in sdhci_omap_reset()
857 if (omap_host->flags & SDHCI_OMAP_SPECIAL_RESET) { in sdhci_omap_reset()
879 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCONFIG, sysc); in sdhci_omap_reset()
889 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_irq() local
891 if (omap_host->is_tuning && host->cmd && !host->data_early && in sdhci_omap_irq()
967 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_capabilities() local
968 struct device *dev = omap_host->dev; in sdhci_omap_set_capabilities()
991 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_set_capabilities()
1003 sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, reg); in sdhci_omap_set_capabilities()
1083 *sdhci_omap_iodelay_pinctrl_state(struct sdhci_omap_host *omap_host, char *mode, in sdhci_omap_iodelay_pinctrl_state() argument
1086 struct device *dev = omap_host->dev; in sdhci_omap_iodelay_pinctrl_state()
1087 char *version = omap_host->version; in sdhci_omap_iodelay_pinctrl_state()
1096 pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, str); in sdhci_omap_iodelay_pinctrl_state()
1100 pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode); in sdhci_omap_iodelay_pinctrl_state()
1112 *omap_host) in sdhci_omap_config_iodelay_pinctrl_state()
1114 struct device *dev = omap_host->dev; in sdhci_omap_config_iodelay_pinctrl_state()
1115 struct sdhci_host *host = omap_host->host; in sdhci_omap_config_iodelay_pinctrl_state()
1122 if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) in sdhci_omap_config_iodelay_pinctrl_state()
1132 omap_host->pinctrl = devm_pinctrl_get(omap_host->dev); in sdhci_omap_config_iodelay_pinctrl_state()
1133 if (IS_ERR(omap_host->pinctrl)) { in sdhci_omap_config_iodelay_pinctrl_state()
1135 return PTR_ERR(omap_host->pinctrl); in sdhci_omap_config_iodelay_pinctrl_state()
1138 state = pinctrl_lookup_state(omap_host->pinctrl, "default"); in sdhci_omap_config_iodelay_pinctrl_state()
1145 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr104", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1150 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr50", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1155 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr50", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1160 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr25", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1165 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr12", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1170 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_1_8v", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1175 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_3_3v", in sdhci_omap_config_iodelay_pinctrl_state()
1182 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1187 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1192 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs200_1_8v", caps2, in sdhci_omap_config_iodelay_pinctrl_state()
1197 omap_host->pinctrl_state = pinctrl_state; in sdhci_omap_config_iodelay_pinctrl_state()
1219 struct sdhci_omap_host *omap_host; in sdhci_omap_probe() local
1237 sizeof(*omap_host)); in sdhci_omap_probe()
1244 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_probe()
1245 omap_host->host = host; in sdhci_omap_probe()
1246 omap_host->base = host->ioaddr; in sdhci_omap_probe()
1247 omap_host->dev = dev; in sdhci_omap_probe()
1248 omap_host->power_mode = MMC_POWER_UNDEFINED; in sdhci_omap_probe()
1249 omap_host->timing = MMC_TIMING_LEGACY; in sdhci_omap_probe()
1250 omap_host->flags = data->flags; in sdhci_omap_probe()
1251 omap_host->omap_offset = data->omap_offset; in sdhci_omap_probe()
1252 omap_host->con = -EINVAL; /* Prevent invalid restore on first resume */ in sdhci_omap_probe()
1264 omap_host->version = "rev11"; in sdhci_omap_probe()
1288 omap_host->pbias = devm_regulator_get_optional(dev, "pbias"); in sdhci_omap_probe()
1289 if (IS_ERR(omap_host->pbias)) { in sdhci_omap_probe()
1290 ret = PTR_ERR(omap_host->pbias); in sdhci_omap_probe()
1295 omap_host->pbias_enabled = false; in sdhci_omap_probe()
1331 !sdhci_omap_has_adma(omap_host, offset)) in sdhci_omap_probe()
1349 ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host); in sdhci_omap_probe()
1361 omap_host->wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); in sdhci_omap_probe()
1362 if (omap_host->wakeirq == -EPROBE_DEFER) { in sdhci_omap_probe()
1366 if (omap_host->wakeirq > 0) { in sdhci_omap_probe()
1368 ret = dev_pm_set_dedicated_wake_irq(dev, omap_host->wakeirq); in sdhci_omap_probe()
1413 static void __maybe_unused sdhci_omap_context_save(struct sdhci_omap_host *omap_host) in sdhci_omap_context_save() argument
1415 omap_host->con = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_context_save()
1416 omap_host->hctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL); in sdhci_omap_context_save()
1417 omap_host->sysctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_context_save()
1418 omap_host->capa = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_context_save()
1419 omap_host->ie = sdhci_omap_readl(omap_host, SDHCI_OMAP_IE); in sdhci_omap_context_save()
1420 omap_host->ise = sdhci_omap_readl(omap_host, SDHCI_OMAP_ISE); in sdhci_omap_context_save()
1424 static void __maybe_unused sdhci_omap_context_restore(struct sdhci_omap_host *omap_host) in sdhci_omap_context_restore() argument
1426 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl); in sdhci_omap_context_restore()
1427 sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, omap_host->capa); in sdhci_omap_context_restore()
1428 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl); in sdhci_omap_context_restore()
1430 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, omap_host->sysctl); in sdhci_omap_context_restore()
1431 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, omap_host->con); in sdhci_omap_context_restore()
1432 sdhci_omap_writel(omap_host, SDHCI_OMAP_IE, omap_host->ie); in sdhci_omap_context_restore()
1433 sdhci_omap_writel(omap_host, SDHCI_OMAP_ISE, omap_host->ise); in sdhci_omap_context_restore()
1440 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_runtime_suspend() local
1442 if (omap_host->con != -EINVAL) in sdhci_omap_runtime_suspend()
1445 sdhci_omap_context_save(omap_host); in sdhci_omap_runtime_suspend()
1456 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_runtime_resume() local
1460 if (omap_host->con != -EINVAL) { in sdhci_omap_runtime_resume()
1461 sdhci_omap_context_restore(omap_host); in sdhci_omap_runtime_resume()