Lines Matching refs:omap_host

137 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host);
138 static void sdhci_omap_stop_clock(struct sdhci_omap_host *omap_host);
152 static int sdhci_omap_set_pbias(struct sdhci_omap_host *omap_host, in sdhci_omap_set_pbias() argument
156 struct device *dev = omap_host->dev; in sdhci_omap_set_pbias()
158 if (IS_ERR(omap_host->pbias)) in sdhci_omap_set_pbias()
162 ret = regulator_set_voltage(omap_host->pbias, iov, iov); in sdhci_omap_set_pbias()
168 if (omap_host->pbias_enabled) in sdhci_omap_set_pbias()
171 ret = regulator_enable(omap_host->pbias); in sdhci_omap_set_pbias()
177 omap_host->pbias_enabled = true; in sdhci_omap_set_pbias()
179 if (!omap_host->pbias_enabled) in sdhci_omap_set_pbias()
182 ret = regulator_disable(omap_host->pbias); in sdhci_omap_set_pbias()
187 omap_host->pbias_enabled = false; in sdhci_omap_set_pbias()
193 static int sdhci_omap_enable_iov(struct sdhci_omap_host *omap_host, in sdhci_omap_enable_iov() argument
197 struct sdhci_host *host = omap_host->host; in sdhci_omap_enable_iov()
200 ret = sdhci_omap_set_pbias(omap_host, false, 0); in sdhci_omap_enable_iov()
213 ret = sdhci_omap_set_pbias(omap_host, true, iov_pbias); in sdhci_omap_enable_iov()
220 static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host, in sdhci_omap_conf_bus_power() argument
226 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL); in sdhci_omap_conf_bus_power()
231 capa = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_conf_bus_power()
237 dev_warn(omap_host->dev, "misconfigured CAPA: %08x\n", in sdhci_omap_conf_bus_power()
246 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, reg); in sdhci_omap_conf_bus_power()
249 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, reg); in sdhci_omap_conf_bus_power()
256 if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP) in sdhci_omap_conf_bus_power()
268 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_enable_sdio_irq() local
271 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_enable_sdio_irq()
276 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_enable_sdio_irq()
281 static inline void sdhci_omap_set_dll(struct sdhci_omap_host *omap_host, in sdhci_omap_set_dll() argument
287 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_set_dll()
291 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
294 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
296 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_set_dll()
301 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_set_dll()
304 static void sdhci_omap_disable_tuning(struct sdhci_omap_host *omap_host) in sdhci_omap_disable_tuning() argument
308 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_disable_tuning()
310 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_disable_tuning()
312 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_disable_tuning()
314 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_disable_tuning()
321 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_execute_tuning() local
323 struct device *dev = omap_host->dev; in sdhci_omap_execute_tuning()
340 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA2); in sdhci_omap_execute_tuning()
354 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); in sdhci_omap_execute_tuning()
356 sdhci_omap_writel(omap_host, SDHCI_OMAP_DLL, reg); in sdhci_omap_execute_tuning()
369 omap_host->is_tuning = true; in sdhci_omap_execute_tuning()
377 sdhci_omap_set_dll(omap_host, phase_delay); in sdhci_omap_execute_tuning()
437 sdhci_omap_set_dll(omap_host, phase_delay + i); in sdhci_omap_execute_tuning()
454 sdhci_omap_set_dll(omap_host, phase_delay + i); in sdhci_omap_execute_tuning()
473 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_execute_tuning()
479 sdhci_omap_set_dll(omap_host, phase_delay); in sdhci_omap_execute_tuning()
481 omap_host->is_tuning = false; in sdhci_omap_execute_tuning()
486 omap_host->is_tuning = false; in sdhci_omap_execute_tuning()
488 sdhci_omap_disable_tuning(omap_host); in sdhci_omap_execute_tuning()
506 struct sdhci_omap_host *omap_host; in sdhci_omap_card_busy() local
510 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_card_busy()
512 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_card_busy()
513 ac12 = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_card_busy()
518 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_card_busy()
530 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_PSTATE); in sdhci_omap_card_busy()
534 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_card_busy()
536 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_card_busy()
553 struct sdhci_omap_host *omap_host; in sdhci_omap_start_signal_voltage_switch() local
557 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_start_signal_voltage_switch()
558 dev = omap_host->dev; in sdhci_omap_start_signal_voltage_switch()
561 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_start_signal_voltage_switch()
570 sdhci_omap_conf_bus_power(omap_host, ios->signal_voltage); in sdhci_omap_start_signal_voltage_switch()
572 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_start_signal_voltage_switch()
574 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_start_signal_voltage_switch()
577 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_start_signal_voltage_switch()
583 sdhci_omap_conf_bus_power(omap_host, ios->signal_voltage); in sdhci_omap_start_signal_voltage_switch()
585 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); in sdhci_omap_start_signal_voltage_switch()
587 sdhci_omap_writel(omap_host, SDHCI_OMAP_AC12, reg); in sdhci_omap_start_signal_voltage_switch()
592 ret = sdhci_omap_enable_iov(omap_host, iov); in sdhci_omap_start_signal_voltage_switch()
602 static void sdhci_omap_set_timing(struct sdhci_omap_host *omap_host, u8 timing) in sdhci_omap_set_timing() argument
606 struct device *dev = omap_host->dev; in sdhci_omap_set_timing()
608 if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) in sdhci_omap_set_timing()
611 if (omap_host->timing == timing) in sdhci_omap_set_timing()
614 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_timing()
616 pinctrl_state = omap_host->pinctrl_state[timing]; in sdhci_omap_set_timing()
617 ret = pinctrl_select_state(omap_host->pinctrl, pinctrl_state); in sdhci_omap_set_timing()
623 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_timing()
624 omap_host->timing = timing; in sdhci_omap_set_timing()
627 static void sdhci_omap_set_power_mode(struct sdhci_omap_host *omap_host, in sdhci_omap_set_power_mode() argument
630 if (omap_host->bus_mode == MMC_POWER_OFF) in sdhci_omap_set_power_mode()
631 sdhci_omap_disable_tuning(omap_host); in sdhci_omap_set_power_mode()
632 omap_host->power_mode = power_mode; in sdhci_omap_set_power_mode()
635 static void sdhci_omap_set_bus_mode(struct sdhci_omap_host *omap_host, in sdhci_omap_set_bus_mode() argument
640 if (omap_host->bus_mode == mode) in sdhci_omap_set_bus_mode()
643 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_bus_mode()
648 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_bus_mode()
650 omap_host->bus_mode = mode; in sdhci_omap_set_bus_mode()
657 struct sdhci_omap_host *omap_host; in sdhci_omap_set_ios() local
660 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_ios()
662 sdhci_omap_set_bus_mode(omap_host, ios->bus_mode); in sdhci_omap_set_ios()
663 sdhci_omap_set_timing(omap_host, ios->timing); in sdhci_omap_set_ios()
665 sdhci_omap_set_power_mode(omap_host, ios->power_mode); in sdhci_omap_set_ios()
680 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host) in sdhci_omap_start_clock() argument
684 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_start_clock()
686 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, reg); in sdhci_omap_start_clock()
689 static void sdhci_omap_stop_clock(struct sdhci_omap_host *omap_host) in sdhci_omap_stop_clock() argument
693 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_stop_clock()
695 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, reg); in sdhci_omap_stop_clock()
701 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_clock() local
704 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_clock()
713 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_clock()
732 static bool sdhci_omap_has_adma(struct sdhci_omap_host *omap_host, int offset) in sdhci_omap_has_adma() argument
738 return readl(omap_host->base + 4) & 1; in sdhci_omap_has_adma()
745 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_enable_dma() local
747 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_enable_dma()
753 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_enable_dma()
768 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_bus_width() local
771 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_bus_width()
776 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_bus_width()
786 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_init_74_clocks() local
788 if (omap_host->power_mode == power_mode) in sdhci_omap_init_74_clocks()
796 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_init_74_clocks()
798 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_init_74_clocks()
799 sdhci_omap_writel(omap_host, SDHCI_OMAP_CMD, 0x0); in sdhci_omap_init_74_clocks()
806 if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN) in sdhci_omap_init_74_clocks()
813 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_init_74_clocks()
815 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_init_74_clocks()
816 sdhci_omap_writel(omap_host, SDHCI_OMAP_STAT, INT_CC_EN); in sdhci_omap_init_74_clocks()
826 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_uhs_signaling() local
828 sdhci_omap_stop_clock(omap_host); in sdhci_omap_set_uhs_signaling()
830 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_set_uhs_signaling()
835 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg); in sdhci_omap_set_uhs_signaling()
838 sdhci_omap_start_clock(omap_host); in sdhci_omap_set_uhs_signaling()
845 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_reset() local
852 sysc = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCONFIG); in sdhci_omap_reset()
855 if (omap_host->is_tuning) in sdhci_omap_reset()
858 if (omap_host->flags & SDHCI_OMAP_SPECIAL_RESET) { in sdhci_omap_reset()
880 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCONFIG, sysc); in sdhci_omap_reset()
890 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_irq() local
892 if (omap_host->is_tuning && host->cmd && !host->data_early && in sdhci_omap_irq()
968 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_set_capabilities() local
969 struct device *dev = omap_host->dev; in sdhci_omap_set_capabilities()
992 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_set_capabilities()
1004 sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, reg); in sdhci_omap_set_capabilities()
1084 *sdhci_omap_iodelay_pinctrl_state(struct sdhci_omap_host *omap_host, char *mode, in sdhci_omap_iodelay_pinctrl_state() argument
1087 struct device *dev = omap_host->dev; in sdhci_omap_iodelay_pinctrl_state()
1088 char *version = omap_host->version; in sdhci_omap_iodelay_pinctrl_state()
1097 pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, str); in sdhci_omap_iodelay_pinctrl_state()
1101 pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode); in sdhci_omap_iodelay_pinctrl_state()
1113 *omap_host) in sdhci_omap_config_iodelay_pinctrl_state()
1115 struct device *dev = omap_host->dev; in sdhci_omap_config_iodelay_pinctrl_state()
1116 struct sdhci_host *host = omap_host->host; in sdhci_omap_config_iodelay_pinctrl_state()
1123 if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) in sdhci_omap_config_iodelay_pinctrl_state()
1133 omap_host->pinctrl = devm_pinctrl_get(omap_host->dev); in sdhci_omap_config_iodelay_pinctrl_state()
1134 if (IS_ERR(omap_host->pinctrl)) { in sdhci_omap_config_iodelay_pinctrl_state()
1136 return PTR_ERR(omap_host->pinctrl); in sdhci_omap_config_iodelay_pinctrl_state()
1139 state = pinctrl_lookup_state(omap_host->pinctrl, "default"); in sdhci_omap_config_iodelay_pinctrl_state()
1146 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr104", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1151 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr50", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1156 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr50", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1161 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr25", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1166 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "sdr12", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1171 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_1_8v", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1176 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_3_3v", in sdhci_omap_config_iodelay_pinctrl_state()
1183 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1188 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps, in sdhci_omap_config_iodelay_pinctrl_state()
1193 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs200_1_8v", caps2, in sdhci_omap_config_iodelay_pinctrl_state()
1198 omap_host->pinctrl_state = pinctrl_state; in sdhci_omap_config_iodelay_pinctrl_state()
1220 struct sdhci_omap_host *omap_host; in sdhci_omap_probe() local
1238 sizeof(*omap_host)); in sdhci_omap_probe()
1245 omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_probe()
1246 omap_host->host = host; in sdhci_omap_probe()
1247 omap_host->base = host->ioaddr; in sdhci_omap_probe()
1248 omap_host->dev = dev; in sdhci_omap_probe()
1249 omap_host->power_mode = MMC_POWER_UNDEFINED; in sdhci_omap_probe()
1250 omap_host->timing = MMC_TIMING_LEGACY; in sdhci_omap_probe()
1251 omap_host->flags = data->flags; in sdhci_omap_probe()
1252 omap_host->omap_offset = data->omap_offset; in sdhci_omap_probe()
1253 omap_host->con = -EINVAL; /* Prevent invalid restore on first resume */ in sdhci_omap_probe()
1265 omap_host->version = "rev11"; in sdhci_omap_probe()
1289 omap_host->pbias = devm_regulator_get_optional(dev, "pbias"); in sdhci_omap_probe()
1290 if (IS_ERR(omap_host->pbias)) { in sdhci_omap_probe()
1291 ret = PTR_ERR(omap_host->pbias); in sdhci_omap_probe()
1296 omap_host->pbias_enabled = false; in sdhci_omap_probe()
1332 !sdhci_omap_has_adma(omap_host, offset)) in sdhci_omap_probe()
1350 ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host); in sdhci_omap_probe()
1362 omap_host->wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); in sdhci_omap_probe()
1363 if (omap_host->wakeirq == -EPROBE_DEFER) { in sdhci_omap_probe()
1367 if (omap_host->wakeirq > 0) { in sdhci_omap_probe()
1369 ret = dev_pm_set_dedicated_wake_irq(dev, omap_host->wakeirq); in sdhci_omap_probe()
1416 static void __maybe_unused sdhci_omap_context_save(struct sdhci_omap_host *omap_host) in sdhci_omap_context_save() argument
1418 omap_host->con = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); in sdhci_omap_context_save()
1419 omap_host->hctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL); in sdhci_omap_context_save()
1420 omap_host->sysctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_SYSCTL); in sdhci_omap_context_save()
1421 omap_host->capa = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA); in sdhci_omap_context_save()
1422 omap_host->ie = sdhci_omap_readl(omap_host, SDHCI_OMAP_IE); in sdhci_omap_context_save()
1423 omap_host->ise = sdhci_omap_readl(omap_host, SDHCI_OMAP_ISE); in sdhci_omap_context_save()
1427 static void __maybe_unused sdhci_omap_context_restore(struct sdhci_omap_host *omap_host) in sdhci_omap_context_restore() argument
1429 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl); in sdhci_omap_context_restore()
1430 sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, omap_host->capa); in sdhci_omap_context_restore()
1431 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl); in sdhci_omap_context_restore()
1433 sdhci_omap_writel(omap_host, SDHCI_OMAP_SYSCTL, omap_host->sysctl); in sdhci_omap_context_restore()
1434 sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, omap_host->con); in sdhci_omap_context_restore()
1435 sdhci_omap_writel(omap_host, SDHCI_OMAP_IE, omap_host->ie); in sdhci_omap_context_restore()
1436 sdhci_omap_writel(omap_host, SDHCI_OMAP_ISE, omap_host->ise); in sdhci_omap_context_restore()
1443 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_runtime_suspend() local
1445 if (omap_host->con != -EINVAL) in sdhci_omap_runtime_suspend()
1448 sdhci_omap_context_save(omap_host); in sdhci_omap_runtime_suspend()
1459 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); in sdhci_omap_runtime_resume() local
1463 if (omap_host->con != -EINVAL) { in sdhci_omap_runtime_resume()
1464 sdhci_omap_context_restore(omap_host); in sdhci_omap_runtime_resume()