Lines Matching refs:host
153 #define mmc_pdata(host) host->pdata argument
214 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
219 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_supply() local
229 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in omap_hsmmc_enable_supply()
235 host->vqmmc_enabled = 1; in omap_hsmmc_enable_supply()
251 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_disable_supply() local
253 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in omap_hsmmc_disable_supply()
259 host->vqmmc_enabled = 0; in omap_hsmmc_disable_supply()
280 static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on) in omap_hsmmc_set_pbias() argument
284 if (IS_ERR(host->pbias)) in omap_hsmmc_set_pbias()
288 if (host->pbias_enabled == 0) { in omap_hsmmc_set_pbias()
289 ret = regulator_enable(host->pbias); in omap_hsmmc_set_pbias()
291 dev_err(host->dev, "pbias reg enable fail\n"); in omap_hsmmc_set_pbias()
294 host->pbias_enabled = 1; in omap_hsmmc_set_pbias()
297 if (host->pbias_enabled == 1) { in omap_hsmmc_set_pbias()
298 ret = regulator_disable(host->pbias); in omap_hsmmc_set_pbias()
300 dev_err(host->dev, "pbias reg disable fail\n"); in omap_hsmmc_set_pbias()
303 host->pbias_enabled = 0; in omap_hsmmc_set_pbias()
310 static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on) in omap_hsmmc_set_power() argument
312 struct mmc_host *mmc = host->mmc; in omap_hsmmc_set_power()
322 ret = omap_hsmmc_set_pbias(host, false); in omap_hsmmc_set_power()
344 ret = omap_hsmmc_set_pbias(host, true); in omap_hsmmc_set_power()
381 static int omap_hsmmc_disable_boot_regulators(struct omap_hsmmc_host *host) in omap_hsmmc_disable_boot_regulators() argument
383 struct mmc_host *mmc = host->mmc; in omap_hsmmc_disable_boot_regulators()
393 dev_err(host->dev, "fail to disable boot enabled vmmc reg\n"); in omap_hsmmc_disable_boot_regulators()
399 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
404 ret = omap_hsmmc_disable_boot_regulator(host->pbias); in omap_hsmmc_disable_boot_regulators()
406 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
414 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) in omap_hsmmc_reg_get() argument
417 struct mmc_host *mmc = host->mmc; in omap_hsmmc_reg_get()
426 mmc->supply.vqmmc = devm_regulator_get_optional(host->dev, in omap_hsmmc_reg_get()
430 if ((ret != -ENODEV) && host->dev->of_node) in omap_hsmmc_reg_get()
432 dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n", in omap_hsmmc_reg_get()
437 host->pbias = devm_regulator_get_optional(host->dev, "pbias"); in omap_hsmmc_reg_get()
438 if (IS_ERR(host->pbias)) { in omap_hsmmc_reg_get()
439 ret = PTR_ERR(host->pbias); in omap_hsmmc_reg_get()
440 if ((ret != -ENODEV) && host->dev->of_node) { in omap_hsmmc_reg_get()
441 dev_err(host->dev, in omap_hsmmc_reg_get()
445 dev_dbg(host->dev, "unable to get pbias regulator %ld\n", in omap_hsmmc_reg_get()
446 PTR_ERR(host->pbias)); in omap_hsmmc_reg_get()
450 if (mmc_pdata(host)->no_regulator_off_init) in omap_hsmmc_reg_get()
453 ret = omap_hsmmc_disable_boot_regulators(host); in omap_hsmmc_reg_get()
463 static void omap_hsmmc_start_clock(struct omap_hsmmc_host *host) in omap_hsmmc_start_clock() argument
465 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_start_clock()
466 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN); in omap_hsmmc_start_clock()
472 static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host) in omap_hsmmc_stop_clock() argument
474 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_stop_clock()
475 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN); in omap_hsmmc_stop_clock()
476 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0) in omap_hsmmc_stop_clock()
477 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n"); in omap_hsmmc_stop_clock()
480 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, in omap_hsmmc_enable_irq() argument
486 if (host->use_dma) in omap_hsmmc_enable_irq()
493 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
494 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_enable_irq()
495 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_irq()
498 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_enable_irq()
500 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_irq()
501 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
504 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host) in omap_hsmmc_disable_irq() argument
509 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
511 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_disable_irq()
513 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_disable_irq()
514 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_disable_irq()
515 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_disable_irq()
516 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
520 static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios) in calc_divisor() argument
525 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock); in calc_divisor()
533 static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) in omap_hsmmc_set_clock() argument
535 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_clock()
540 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); in omap_hsmmc_set_clock()
542 omap_hsmmc_stop_clock(host); in omap_hsmmc_set_clock()
544 regval = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_set_clock()
546 clkdiv = calc_divisor(host, ios); in omap_hsmmc_set_clock()
548 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); in omap_hsmmc_set_clock()
549 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_set_clock()
550 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); in omap_hsmmc_set_clock()
554 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS in omap_hsmmc_set_clock()
567 if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) && in omap_hsmmc_set_clock()
570 ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) { in omap_hsmmc_set_clock()
571 regval = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_set_clock()
572 if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000) in omap_hsmmc_set_clock()
577 OMAP_HSMMC_WRITE(host->base, HCTL, regval); in omap_hsmmc_set_clock()
580 omap_hsmmc_start_clock(host); in omap_hsmmc_set_clock()
583 static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_width() argument
585 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_width()
588 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_width()
596 OMAP_HSMMC_WRITE(host->base, CON, con | DW8); in omap_hsmmc_set_bus_width()
599 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
600 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
601 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT); in omap_hsmmc_set_bus_width()
604 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
605 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
606 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT); in omap_hsmmc_set_bus_width()
611 static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_mode() argument
613 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_mode()
616 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_mode()
618 OMAP_HSMMC_WRITE(host->base, CON, con | OD); in omap_hsmmc_set_bus_mode()
620 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD); in omap_hsmmc_set_bus_mode()
629 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
631 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_context_restore()
635 if (host->con == OMAP_HSMMC_READ(host->base, CON) && in omap_hsmmc_context_restore()
636 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) && in omap_hsmmc_context_restore()
637 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) && in omap_hsmmc_context_restore()
638 host->capa == OMAP_HSMMC_READ(host->base, CAPA)) in omap_hsmmc_context_restore()
641 host->context_loss++; in omap_hsmmc_context_restore()
643 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_context_restore()
644 if (host->power_mode != MMC_POWER_OFF && in omap_hsmmc_context_restore()
655 if (host->mmc->caps & MMC_CAP_SDIO_IRQ) in omap_hsmmc_context_restore()
658 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
659 OMAP_HSMMC_READ(host->base, HCTL) | hctl); in omap_hsmmc_context_restore()
661 OMAP_HSMMC_WRITE(host->base, CAPA, in omap_hsmmc_context_restore()
662 OMAP_HSMMC_READ(host->base, CAPA) | capa); in omap_hsmmc_context_restore()
664 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
665 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in omap_hsmmc_context_restore()
668 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP in omap_hsmmc_context_restore()
672 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_context_restore()
673 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_context_restore()
674 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_context_restore()
677 if (host->power_mode == MMC_POWER_OFF) in omap_hsmmc_context_restore()
680 omap_hsmmc_set_bus_width(host); in omap_hsmmc_context_restore()
682 omap_hsmmc_set_clock(host); in omap_hsmmc_context_restore()
684 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_context_restore()
687 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n", in omap_hsmmc_context_restore()
688 host->context_loss); in omap_hsmmc_context_restore()
695 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
697 host->con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_context_save()
698 host->hctl = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_context_save()
699 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_context_save()
700 host->capa = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_context_save()
705 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
710 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
720 static void send_init_stream(struct omap_hsmmc_host *host) in send_init_stream() argument
725 disable_irq(host->irq); in send_init_stream()
727 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK); in send_init_stream()
728 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
729 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM); in send_init_stream()
730 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); in send_init_stream()
734 reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN; in send_init_stream()
736 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
737 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); in send_init_stream()
739 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in send_init_stream()
740 OMAP_HSMMC_READ(host->base, STAT); in send_init_stream()
742 enable_irq(host->irq); in send_init_stream()
750 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_slot_name() local
752 return sprintf(buf, "%s\n", mmc_pdata(host)->name); in omap_hsmmc_show_slot_name()
761 omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, in omap_hsmmc_start_command() argument
766 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n", in omap_hsmmc_start_command()
767 mmc_hostname(host->mmc), cmd->opcode, cmd->arg); in omap_hsmmc_start_command()
768 host->cmd = cmd; in omap_hsmmc_start_command()
770 omap_hsmmc_enable_irq(host, cmd); in omap_hsmmc_start_command()
772 host->response_busy = 0; in omap_hsmmc_start_command()
778 host->response_busy = 1; in omap_hsmmc_start_command()
788 if (cmd == host->mrq->stop) in omap_hsmmc_start_command()
793 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) && in omap_hsmmc_start_command()
794 host->mrq->sbc) { in omap_hsmmc_start_command()
796 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg); in omap_hsmmc_start_command()
806 if (host->use_dma) in omap_hsmmc_start_command()
809 host->req_in_progress = 1; in omap_hsmmc_start_command()
811 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg); in omap_hsmmc_start_command()
812 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg); in omap_hsmmc_start_command()
815 static struct dma_chan *omap_hsmmc_get_dma_chan(struct omap_hsmmc_host *host, in omap_hsmmc_get_dma_chan() argument
818 return data->flags & MMC_DATA_WRITE ? host->tx_chan : host->rx_chan; in omap_hsmmc_get_dma_chan()
821 static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq) in omap_hsmmc_request_done() argument
826 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_request_done()
827 host->req_in_progress = 0; in omap_hsmmc_request_done()
828 dma_ch = host->dma_ch; in omap_hsmmc_request_done()
829 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_request_done()
831 omap_hsmmc_disable_irq(host); in omap_hsmmc_request_done()
833 if (mrq->data && host->use_dma && dma_ch != -1) in omap_hsmmc_request_done()
835 host->mrq = NULL; in omap_hsmmc_request_done()
836 mmc_request_done(host->mmc, mrq); in omap_hsmmc_request_done()
843 omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_xfer_done() argument
846 struct mmc_request *mrq = host->mrq; in omap_hsmmc_xfer_done()
849 if (host->cmd && host->cmd->opcode == 6 && in omap_hsmmc_xfer_done()
850 host->response_busy) { in omap_hsmmc_xfer_done()
851 host->response_busy = 0; in omap_hsmmc_xfer_done()
855 omap_hsmmc_request_done(host, mrq); in omap_hsmmc_xfer_done()
859 host->data = NULL; in omap_hsmmc_xfer_done()
866 if (data->stop && (data->error || !host->mrq->sbc)) in omap_hsmmc_xfer_done()
867 omap_hsmmc_start_command(host, data->stop, NULL); in omap_hsmmc_xfer_done()
869 omap_hsmmc_request_done(host, data->mrq); in omap_hsmmc_xfer_done()
876 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) in omap_hsmmc_cmd_done() argument
878 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) && in omap_hsmmc_cmd_done()
879 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_cmd_done()
880 host->cmd = NULL; in omap_hsmmc_cmd_done()
881 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_cmd_done()
882 omap_hsmmc_start_command(host, host->mrq->cmd, in omap_hsmmc_cmd_done()
883 host->mrq->data); in omap_hsmmc_cmd_done()
887 host->cmd = NULL; in omap_hsmmc_cmd_done()
892 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
893 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32); in omap_hsmmc_cmd_done()
894 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54); in omap_hsmmc_cmd_done()
895 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76); in omap_hsmmc_cmd_done()
898 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
901 if ((host->data == NULL && !host->response_busy) || cmd->error) in omap_hsmmc_cmd_done()
902 omap_hsmmc_request_done(host, host->mrq); in omap_hsmmc_cmd_done()
908 static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) in omap_hsmmc_dma_cleanup() argument
913 host->data->error = errno; in omap_hsmmc_dma_cleanup()
915 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
916 dma_ch = host->dma_ch; in omap_hsmmc_dma_cleanup()
917 host->dma_ch = -1; in omap_hsmmc_dma_cleanup()
918 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
920 if (host->use_dma && dma_ch != -1) { in omap_hsmmc_dma_cleanup()
921 struct dma_chan *chan = omap_hsmmc_get_dma_chan(host, host->data); in omap_hsmmc_dma_cleanup()
925 host->data->sg, host->data->sg_len, in omap_hsmmc_dma_cleanup()
926 mmc_get_dma_dir(host->data)); in omap_hsmmc_dma_cleanup()
928 host->data->host_cookie = 0; in omap_hsmmc_dma_cleanup()
930 host->data = NULL; in omap_hsmmc_dma_cleanup()
937 static void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, u32 status) in omap_hsmmc_dbg_report_irq() argument
959 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in omap_hsmmc_dbg_report_irq()
962 static inline void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, in omap_hsmmc_dbg_report_irq() argument
975 static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, in omap_hsmmc_reset_controller_fsm() argument
981 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_reset_controller_fsm()
982 OMAP_HSMMC_READ(host->base, SYSCTL) | bit); in omap_hsmmc_reset_controller_fsm()
988 if (mmc_pdata(host)->features & HSMMC_HAS_UPDATED_RESET) { in omap_hsmmc_reset_controller_fsm()
989 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit)) in omap_hsmmc_reset_controller_fsm()
995 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) && in omap_hsmmc_reset_controller_fsm()
999 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit) in omap_hsmmc_reset_controller_fsm()
1000 dev_err(mmc_dev(host->mmc), in omap_hsmmc_reset_controller_fsm()
1005 static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, in hsmmc_command_incomplete() argument
1009 omap_hsmmc_reset_controller_fsm(host, SRC); in hsmmc_command_incomplete()
1010 if (host->cmd) in hsmmc_command_incomplete()
1011 host->cmd->error = err; in hsmmc_command_incomplete()
1014 if (host->data) { in hsmmc_command_incomplete()
1015 omap_hsmmc_reset_controller_fsm(host, SRD); in hsmmc_command_incomplete()
1016 omap_hsmmc_dma_cleanup(host, err); in hsmmc_command_incomplete()
1017 } else if (host->mrq && host->mrq->cmd) in hsmmc_command_incomplete()
1018 host->mrq->cmd->error = err; in hsmmc_command_incomplete()
1021 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) in omap_hsmmc_do_irq() argument
1027 data = host->data; in omap_hsmmc_do_irq()
1028 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); in omap_hsmmc_do_irq()
1031 omap_hsmmc_dbg_report_irq(host, status); in omap_hsmmc_do_irq()
1035 if (host->data || host->response_busy) { in omap_hsmmc_do_irq()
1037 host->response_busy = 0; in omap_hsmmc_do_irq()
1040 hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); in omap_hsmmc_do_irq()
1043 hsmmc_command_incomplete(host, -EILSEQ, end_cmd); in omap_hsmmc_do_irq()
1047 ac12 = OMAP_HSMMC_READ(host->base, AC12); in omap_hsmmc_do_irq()
1048 if (!(ac12 & ACNE) && host->mrq->sbc) { in omap_hsmmc_do_irq()
1054 host->mrq->sbc->error = error; in omap_hsmmc_do_irq()
1055 hsmmc_command_incomplete(host, error, end_cmd); in omap_hsmmc_do_irq()
1057 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12); in omap_hsmmc_do_irq()
1061 OMAP_HSMMC_WRITE(host->base, STAT, status); in omap_hsmmc_do_irq()
1062 if (end_cmd || ((status & CC_EN) && host->cmd)) in omap_hsmmc_do_irq()
1063 omap_hsmmc_cmd_done(host, host->cmd); in omap_hsmmc_do_irq()
1064 if ((end_trans || (status & TC_EN)) && host->mrq) in omap_hsmmc_do_irq()
1065 omap_hsmmc_xfer_done(host, data); in omap_hsmmc_do_irq()
1073 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_irq() local
1076 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1078 if (host->req_in_progress) in omap_hsmmc_irq()
1079 omap_hsmmc_do_irq(host, status); in omap_hsmmc_irq()
1082 mmc_signal_sdio_irq(host->mmc); in omap_hsmmc_irq()
1085 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1091 static void set_sd_bus_power(struct omap_hsmmc_host *host) in set_sd_bus_power() argument
1095 OMAP_HSMMC_WRITE(host->base, HCTL, in set_sd_bus_power()
1096 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in set_sd_bus_power()
1098 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP) in set_sd_bus_power()
1111 static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) in omap_hsmmc_switch_opcond() argument
1117 clk_disable_unprepare(host->dbclk); in omap_hsmmc_switch_opcond()
1120 ret = omap_hsmmc_set_power(host, 0); in omap_hsmmc_switch_opcond()
1124 ret = omap_hsmmc_set_power(host, 1); in omap_hsmmc_switch_opcond()
1125 clk_prepare_enable(host->dbclk); in omap_hsmmc_switch_opcond()
1130 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_switch_opcond()
1131 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR); in omap_hsmmc_switch_opcond()
1132 reg_val = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_switch_opcond()
1154 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val); in omap_hsmmc_switch_opcond()
1155 set_sd_bus_power(host); in omap_hsmmc_switch_opcond()
1159 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); in omap_hsmmc_switch_opcond()
1165 struct omap_hsmmc_host *host = param; in omap_hsmmc_dma_callback() local
1170 spin_lock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1171 if (host->dma_ch < 0) { in omap_hsmmc_dma_callback()
1172 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1176 data = host->mrq->data; in omap_hsmmc_dma_callback()
1177 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_dma_callback()
1183 req_in_progress = host->req_in_progress; in omap_hsmmc_dma_callback()
1184 host->dma_ch = -1; in omap_hsmmc_dma_callback()
1185 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1189 struct mmc_request *mrq = host->mrq; in omap_hsmmc_dma_callback()
1191 host->mrq = NULL; in omap_hsmmc_dma_callback()
1192 mmc_request_done(host->mmc, mrq); in omap_hsmmc_dma_callback()
1196 static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_pre_dma_transfer() argument
1204 data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1205 dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" in omap_hsmmc_pre_dma_transfer()
1207 __func__, data->host_cookie, host->next_data.cookie); in omap_hsmmc_pre_dma_transfer()
1212 if (next || data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1217 dma_len = host->next_data.dma_len; in omap_hsmmc_pre_dma_transfer()
1218 host->next_data.dma_len = 0; in omap_hsmmc_pre_dma_transfer()
1229 host->dma_len = dma_len; in omap_hsmmc_pre_dma_transfer()
1237 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_setup_dma_transfer() argument
1245 .src_addr = host->mapbase + OMAP_HSMMC_DATA, in omap_hsmmc_setup_dma_transfer()
1246 .dst_addr = host->mapbase + OMAP_HSMMC_DATA, in omap_hsmmc_setup_dma_transfer()
1267 BUG_ON(host->dma_ch != -1); in omap_hsmmc_setup_dma_transfer()
1269 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_setup_dma_transfer()
1275 ret = omap_hsmmc_pre_dma_transfer(host, data, NULL, chan); in omap_hsmmc_setup_dma_transfer()
1283 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n"); in omap_hsmmc_setup_dma_transfer()
1289 tx->callback_param = host; in omap_hsmmc_setup_dma_transfer()
1294 host->dma_ch = 1; in omap_hsmmc_setup_dma_transfer()
1299 static void set_data_timeout(struct omap_hsmmc_host *host, in set_data_timeout() argument
1307 reg = OMAP_HSMMC_READ(host->base, SYSCTL); in set_data_timeout()
1312 cycle_ns = 1000000000 / (host->clk_rate / clkd); in set_data_timeout()
1334 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg); in set_data_timeout()
1337 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host) in omap_hsmmc_start_dma_transfer() argument
1339 struct mmc_request *req = host->mrq; in omap_hsmmc_start_dma_transfer()
1344 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz) in omap_hsmmc_start_dma_transfer()
1346 set_data_timeout(host, req->data->timeout_ns, in omap_hsmmc_start_dma_transfer()
1348 chan = omap_hsmmc_get_dma_chan(host, req->data); in omap_hsmmc_start_dma_transfer()
1356 omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) in omap_hsmmc_prepare_data() argument
1361 host->data = req->data; in omap_hsmmc_prepare_data()
1364 OMAP_HSMMC_WRITE(host->base, BLK, 0); in omap_hsmmc_prepare_data()
1375 set_data_timeout(host, timeout, 0); in omap_hsmmc_prepare_data()
1380 if (host->use_dma) { in omap_hsmmc_prepare_data()
1381 ret = omap_hsmmc_setup_dma_transfer(host, req); in omap_hsmmc_prepare_data()
1383 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); in omap_hsmmc_prepare_data()
1393 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_post_req() local
1396 if (host->use_dma && data->host_cookie) { in omap_hsmmc_post_req()
1397 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_post_req()
1407 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_pre_req() local
1414 if (host->use_dma) { in omap_hsmmc_pre_req()
1415 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, mrq->data); in omap_hsmmc_pre_req()
1417 if (omap_hsmmc_pre_dma_transfer(host, mrq->data, in omap_hsmmc_pre_req()
1418 &host->next_data, c)) in omap_hsmmc_pre_req()
1428 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_request() local
1431 BUG_ON(host->req_in_progress); in omap_hsmmc_request()
1432 BUG_ON(host->dma_ch != -1); in omap_hsmmc_request()
1433 if (host->reqs_blocked) in omap_hsmmc_request()
1434 host->reqs_blocked = 0; in omap_hsmmc_request()
1435 WARN_ON(host->mrq != NULL); in omap_hsmmc_request()
1436 host->mrq = req; in omap_hsmmc_request()
1437 host->clk_rate = clk_get_rate(host->fclk); in omap_hsmmc_request()
1438 err = omap_hsmmc_prepare_data(host, req); in omap_hsmmc_request()
1443 host->mrq = NULL; in omap_hsmmc_request()
1447 if (req->sbc && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_request()
1448 omap_hsmmc_start_command(host, req->sbc, NULL); in omap_hsmmc_request()
1452 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_request()
1453 omap_hsmmc_start_command(host, req->cmd, req->data); in omap_hsmmc_request()
1459 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_set_ios() local
1462 if (ios->power_mode != host->power_mode) { in omap_hsmmc_set_ios()
1465 omap_hsmmc_set_power(host, 0); in omap_hsmmc_set_ios()
1468 omap_hsmmc_set_power(host, 1); in omap_hsmmc_set_ios()
1474 host->power_mode = ios->power_mode; in omap_hsmmc_set_ios()
1479 omap_hsmmc_set_bus_width(host); in omap_hsmmc_set_ios()
1481 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_set_ios()
1485 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && in omap_hsmmc_set_ios()
1493 if (omap_hsmmc_switch_opcond(host, ios->vdd) != 0) in omap_hsmmc_set_ios()
1494 dev_dbg(mmc_dev(host->mmc), in omap_hsmmc_set_ios()
1499 omap_hsmmc_set_clock(host); in omap_hsmmc_set_ios()
1502 send_init_stream(host); in omap_hsmmc_set_ios()
1504 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_set_ios()
1509 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_init_card() local
1529 dev_info(host->dev, "found wl1251\n"); in omap_hsmmc_init_card()
1544 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_sdio_irq() local
1548 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1550 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_enable_sdio_irq()
1551 irq_mask = OMAP_HSMMC_READ(host->base, ISE); in omap_hsmmc_enable_sdio_irq()
1553 host->flags |= HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1557 host->flags &= ~HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1561 OMAP_HSMMC_WRITE(host->base, CON, con); in omap_hsmmc_enable_sdio_irq()
1562 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1568 if (!host->req_in_progress || !enable) in omap_hsmmc_enable_sdio_irq()
1569 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1572 OMAP_HSMMC_READ(host->base, IE); in omap_hsmmc_enable_sdio_irq()
1574 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1577 static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host) in omap_hsmmc_configure_wake_irq() argument
1587 if (!host->dev->of_node || !host->wake_irq) in omap_hsmmc_configure_wake_irq()
1590 ret = dev_pm_set_dedicated_wake_irq(host->dev, host->wake_irq); in omap_hsmmc_configure_wake_irq()
1592 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); in omap_hsmmc_configure_wake_irq()
1600 if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) { in omap_hsmmc_configure_wake_irq()
1601 struct pinctrl *p = devm_pinctrl_get(host->dev); in omap_hsmmc_configure_wake_irq()
1608 dev_info(host->dev, "missing idle pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1616 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_configure_wake_irq()
1617 OMAP_HSMMC_READ(host->base, HCTL) | IWE); in omap_hsmmc_configure_wake_irq()
1621 dev_pm_clear_wake_irq(host->dev); in omap_hsmmc_configure_wake_irq()
1623 dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n"); in omap_hsmmc_configure_wake_irq()
1624 host->wake_irq = 0; in omap_hsmmc_configure_wake_irq()
1628 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host) in omap_hsmmc_conf_bus_power() argument
1633 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_conf_bus_power()
1641 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK; in omap_hsmmc_conf_bus_power()
1642 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl); in omap_hsmmc_conf_bus_power()
1644 value = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_conf_bus_power()
1645 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa); in omap_hsmmc_conf_bus_power()
1648 set_sd_bus_power(host); in omap_hsmmc_conf_bus_power()
1677 struct omap_hsmmc_host *host = mmc_priv(mmc); in mmc_regs_show() local
1685 (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled" in mmc_regs_show()
1688 seq_printf(s, "ctx_loss:\t%d\n", host->context_loss); in mmc_regs_show()
1690 pm_runtime_get_sync(host->dev); in mmc_regs_show()
1693 OMAP_HSMMC_READ(host->base, CON)); in mmc_regs_show()
1695 OMAP_HSMMC_READ(host->base, PSTATE)); in mmc_regs_show()
1697 OMAP_HSMMC_READ(host->base, HCTL)); in mmc_regs_show()
1699 OMAP_HSMMC_READ(host->base, SYSCTL)); in mmc_regs_show()
1701 OMAP_HSMMC_READ(host->base, IE)); in mmc_regs_show()
1703 OMAP_HSMMC_READ(host->base, ISE)); in mmc_regs_show()
1705 OMAP_HSMMC_READ(host->base, CAPA)); in mmc_regs_show()
1707 pm_runtime_mark_last_busy(host->dev); in mmc_regs_show()
1708 pm_runtime_put_autosuspend(host->dev); in mmc_regs_show()
1808 struct omap_hsmmc_host *host = NULL; in omap_hsmmc_probe() local
1853 host = mmc_priv(mmc); in omap_hsmmc_probe()
1854 host->mmc = mmc; in omap_hsmmc_probe()
1855 host->pdata = pdata; in omap_hsmmc_probe()
1856 host->dev = &pdev->dev; in omap_hsmmc_probe()
1857 host->use_dma = 1; in omap_hsmmc_probe()
1858 host->dma_ch = -1; in omap_hsmmc_probe()
1859 host->irq = irq; in omap_hsmmc_probe()
1860 host->mapbase = res->start + pdata->reg_offset; in omap_hsmmc_probe()
1861 host->base = base + pdata->reg_offset; in omap_hsmmc_probe()
1862 host->power_mode = MMC_POWER_OFF; in omap_hsmmc_probe()
1863 host->next_data.cookie = 1; in omap_hsmmc_probe()
1864 host->pbias_enabled = 0; in omap_hsmmc_probe()
1865 host->vqmmc_enabled = 0; in omap_hsmmc_probe()
1867 platform_set_drvdata(pdev, host); in omap_hsmmc_probe()
1870 host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); in omap_hsmmc_probe()
1881 spin_lock_init(&host->irq_lock); in omap_hsmmc_probe()
1883 host->fclk = devm_clk_get(&pdev->dev, "fck"); in omap_hsmmc_probe()
1884 if (IS_ERR(host->fclk)) { in omap_hsmmc_probe()
1885 ret = PTR_ERR(host->fclk); in omap_hsmmc_probe()
1886 host->fclk = NULL; in omap_hsmmc_probe()
1890 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { in omap_hsmmc_probe()
1896 pm_runtime_enable(host->dev); in omap_hsmmc_probe()
1897 pm_runtime_get_sync(host->dev); in omap_hsmmc_probe()
1898 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); in omap_hsmmc_probe()
1899 pm_runtime_use_autosuspend(host->dev); in omap_hsmmc_probe()
1901 omap_hsmmc_context_save(host); in omap_hsmmc_probe()
1903 host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck"); in omap_hsmmc_probe()
1907 if (IS_ERR(host->dbclk)) { in omap_hsmmc_probe()
1908 host->dbclk = NULL; in omap_hsmmc_probe()
1909 } else if (clk_prepare_enable(host->dbclk) != 0) { in omap_hsmmc_probe()
1910 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); in omap_hsmmc_probe()
1911 host->dbclk = NULL; in omap_hsmmc_probe()
1925 mmc->caps |= mmc_pdata(host)->caps; in omap_hsmmc_probe()
1929 if (mmc_pdata(host)->nonremovable) in omap_hsmmc_probe()
1932 mmc->pm_caps |= mmc_pdata(host)->pm_caps; in omap_hsmmc_probe()
1934 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_probe()
1936 host->rx_chan = dma_request_chan(&pdev->dev, "rx"); in omap_hsmmc_probe()
1937 if (IS_ERR(host->rx_chan)) { in omap_hsmmc_probe()
1938 dev_err(mmc_dev(host->mmc), "RX DMA channel request failed\n"); in omap_hsmmc_probe()
1939 ret = PTR_ERR(host->rx_chan); in omap_hsmmc_probe()
1943 host->tx_chan = dma_request_chan(&pdev->dev, "tx"); in omap_hsmmc_probe()
1944 if (IS_ERR(host->tx_chan)) { in omap_hsmmc_probe()
1945 dev_err(mmc_dev(host->mmc), "TX DMA channel request failed\n"); in omap_hsmmc_probe()
1946 ret = PTR_ERR(host->tx_chan); in omap_hsmmc_probe()
1958 dma_get_max_seg_size(host->rx_chan->device->dev), in omap_hsmmc_probe()
1959 dma_get_max_seg_size(host->tx_chan->device->dev)); in omap_hsmmc_probe()
1962 ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0, in omap_hsmmc_probe()
1963 mmc_hostname(mmc), host); in omap_hsmmc_probe()
1965 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); in omap_hsmmc_probe()
1969 ret = omap_hsmmc_reg_get(host); in omap_hsmmc_probe()
1974 mmc->ocr_avail = mmc_pdata(host)->ocr_mask; in omap_hsmmc_probe()
1976 omap_hsmmc_disable_irq(host); in omap_hsmmc_probe()
1986 ret = omap_hsmmc_configure_wake_irq(host); in omap_hsmmc_probe()
1994 if (mmc_pdata(host)->name != NULL) { in omap_hsmmc_probe()
2001 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_probe()
2002 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_probe()
2010 if (!IS_ERR_OR_NULL(host->tx_chan)) in omap_hsmmc_probe()
2011 dma_release_channel(host->tx_chan); in omap_hsmmc_probe()
2012 if (!IS_ERR_OR_NULL(host->rx_chan)) in omap_hsmmc_probe()
2013 dma_release_channel(host->rx_chan); in omap_hsmmc_probe()
2014 pm_runtime_dont_use_autosuspend(host->dev); in omap_hsmmc_probe()
2015 pm_runtime_put_sync(host->dev); in omap_hsmmc_probe()
2016 pm_runtime_disable(host->dev); in omap_hsmmc_probe()
2017 clk_disable_unprepare(host->dbclk); in omap_hsmmc_probe()
2026 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); in omap_hsmmc_remove() local
2028 pm_runtime_get_sync(host->dev); in omap_hsmmc_remove()
2029 mmc_remove_host(host->mmc); in omap_hsmmc_remove()
2031 dma_release_channel(host->tx_chan); in omap_hsmmc_remove()
2032 dma_release_channel(host->rx_chan); in omap_hsmmc_remove()
2034 dev_pm_clear_wake_irq(host->dev); in omap_hsmmc_remove()
2035 pm_runtime_dont_use_autosuspend(host->dev); in omap_hsmmc_remove()
2036 pm_runtime_put_sync(host->dev); in omap_hsmmc_remove()
2037 pm_runtime_disable(host->dev); in omap_hsmmc_remove()
2039 clk_disable_unprepare(host->dbclk); in omap_hsmmc_remove()
2041 mmc_free_host(host->mmc); in omap_hsmmc_remove()
2049 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_suspend() local
2051 if (!host) in omap_hsmmc_suspend()
2054 pm_runtime_get_sync(host->dev); in omap_hsmmc_suspend()
2056 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { in omap_hsmmc_suspend()
2057 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_suspend()
2058 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_suspend()
2059 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_suspend()
2060 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_suspend()
2061 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); in omap_hsmmc_suspend()
2064 clk_disable_unprepare(host->dbclk); in omap_hsmmc_suspend()
2066 pm_runtime_put_sync(host->dev); in omap_hsmmc_suspend()
2073 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_resume() local
2075 if (!host) in omap_hsmmc_resume()
2078 pm_runtime_get_sync(host->dev); in omap_hsmmc_resume()
2080 clk_prepare_enable(host->dbclk); in omap_hsmmc_resume()
2082 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) in omap_hsmmc_resume()
2083 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_resume()
2085 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_resume()
2086 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_resume()
2093 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_suspend() local
2097 host = dev_get_drvdata(dev); in omap_hsmmc_runtime_suspend()
2098 omap_hsmmc_context_save(host); in omap_hsmmc_runtime_suspend()
2101 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2102 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_suspend()
2103 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_suspend()
2105 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_runtime_suspend()
2106 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_runtime_suspend()
2108 if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) { in omap_hsmmc_runtime_suspend()
2115 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_suspend()
2116 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2117 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2129 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2135 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_resume() local
2138 host = dev_get_drvdata(dev); in omap_hsmmc_runtime_resume()
2139 omap_hsmmc_context_restore(host); in omap_hsmmc_runtime_resume()
2142 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()
2143 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_resume()
2144 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_resume()
2146 pinctrl_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2149 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_resume()
2150 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2151 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2153 pinctrl_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2155 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()