Lines Matching refs:host
155 #define mmc_pdata(host) host->pdata argument
227 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
231 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_card_detect() local
233 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_card_detect()
238 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_get_cover_state() local
240 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_get_cover_state()
246 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_supply() local
256 if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { in omap_hsmmc_enable_supply()
262 host->vqmmc_enabled = 1; in omap_hsmmc_enable_supply()
278 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_disable_supply() local
280 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { in omap_hsmmc_disable_supply()
286 host->vqmmc_enabled = 0; in omap_hsmmc_disable_supply()
307 static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on) in omap_hsmmc_set_pbias() argument
311 if (IS_ERR(host->pbias)) in omap_hsmmc_set_pbias()
315 if (host->pbias_enabled == 0) { in omap_hsmmc_set_pbias()
316 ret = regulator_enable(host->pbias); in omap_hsmmc_set_pbias()
318 dev_err(host->dev, "pbias reg enable fail\n"); in omap_hsmmc_set_pbias()
321 host->pbias_enabled = 1; in omap_hsmmc_set_pbias()
324 if (host->pbias_enabled == 1) { in omap_hsmmc_set_pbias()
325 ret = regulator_disable(host->pbias); in omap_hsmmc_set_pbias()
327 dev_err(host->dev, "pbias reg disable fail\n"); in omap_hsmmc_set_pbias()
330 host->pbias_enabled = 0; in omap_hsmmc_set_pbias()
337 static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on) in omap_hsmmc_set_power() argument
339 struct mmc_host *mmc = host->mmc; in omap_hsmmc_set_power()
349 ret = omap_hsmmc_set_pbias(host, false); in omap_hsmmc_set_power()
371 ret = omap_hsmmc_set_pbias(host, true); in omap_hsmmc_set_power()
408 static int omap_hsmmc_disable_boot_regulators(struct omap_hsmmc_host *host) in omap_hsmmc_disable_boot_regulators() argument
410 struct mmc_host *mmc = host->mmc; in omap_hsmmc_disable_boot_regulators()
420 dev_err(host->dev, "fail to disable boot enabled vmmc reg\n"); in omap_hsmmc_disable_boot_regulators()
426 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
431 ret = omap_hsmmc_disable_boot_regulator(host->pbias); in omap_hsmmc_disable_boot_regulators()
433 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
441 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) in omap_hsmmc_reg_get() argument
444 struct mmc_host *mmc = host->mmc; in omap_hsmmc_reg_get()
453 mmc->supply.vqmmc = devm_regulator_get_optional(host->dev, in omap_hsmmc_reg_get()
457 if ((ret != -ENODEV) && host->dev->of_node) in omap_hsmmc_reg_get()
459 dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n", in omap_hsmmc_reg_get()
464 host->pbias = devm_regulator_get_optional(host->dev, "pbias"); in omap_hsmmc_reg_get()
465 if (IS_ERR(host->pbias)) { in omap_hsmmc_reg_get()
466 ret = PTR_ERR(host->pbias); in omap_hsmmc_reg_get()
467 if ((ret != -ENODEV) && host->dev->of_node) { in omap_hsmmc_reg_get()
468 dev_err(host->dev, in omap_hsmmc_reg_get()
472 dev_dbg(host->dev, "unable to get pbias regulator %ld\n", in omap_hsmmc_reg_get()
473 PTR_ERR(host->pbias)); in omap_hsmmc_reg_get()
477 if (mmc_pdata(host)->no_regulator_off_init) in omap_hsmmc_reg_get()
480 ret = omap_hsmmc_disable_boot_regulators(host); in omap_hsmmc_reg_get()
490 struct omap_hsmmc_host *host, in omap_hsmmc_gpio_init() argument
500 host->get_cover_state = omap_hsmmc_get_cover_state; in omap_hsmmc_gpio_init()
507 host->card_detect = omap_hsmmc_card_detect; in omap_hsmmc_gpio_init()
522 static void omap_hsmmc_start_clock(struct omap_hsmmc_host *host) in omap_hsmmc_start_clock() argument
524 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_start_clock()
525 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN); in omap_hsmmc_start_clock()
531 static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host) in omap_hsmmc_stop_clock() argument
533 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_stop_clock()
534 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN); in omap_hsmmc_stop_clock()
535 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0) in omap_hsmmc_stop_clock()
536 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n"); in omap_hsmmc_stop_clock()
539 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, in omap_hsmmc_enable_irq() argument
545 if (host->use_dma) in omap_hsmmc_enable_irq()
552 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
553 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_enable_irq()
554 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_irq()
557 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_enable_irq()
559 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_irq()
560 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
563 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host) in omap_hsmmc_disable_irq() argument
568 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
570 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_disable_irq()
572 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_disable_irq()
573 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_disable_irq()
574 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_disable_irq()
575 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
579 static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios) in calc_divisor() argument
584 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock); in calc_divisor()
592 static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) in omap_hsmmc_set_clock() argument
594 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_clock()
599 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); in omap_hsmmc_set_clock()
601 omap_hsmmc_stop_clock(host); in omap_hsmmc_set_clock()
603 regval = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_set_clock()
605 clkdiv = calc_divisor(host, ios); in omap_hsmmc_set_clock()
607 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); in omap_hsmmc_set_clock()
608 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_set_clock()
609 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); in omap_hsmmc_set_clock()
613 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS in omap_hsmmc_set_clock()
626 if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) && in omap_hsmmc_set_clock()
629 ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) { in omap_hsmmc_set_clock()
630 regval = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_set_clock()
631 if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000) in omap_hsmmc_set_clock()
636 OMAP_HSMMC_WRITE(host->base, HCTL, regval); in omap_hsmmc_set_clock()
639 omap_hsmmc_start_clock(host); in omap_hsmmc_set_clock()
642 static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_width() argument
644 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_width()
647 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_width()
655 OMAP_HSMMC_WRITE(host->base, CON, con | DW8); in omap_hsmmc_set_bus_width()
658 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
659 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
660 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT); in omap_hsmmc_set_bus_width()
663 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
664 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
665 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT); in omap_hsmmc_set_bus_width()
670 static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_mode() argument
672 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_mode()
675 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_mode()
677 OMAP_HSMMC_WRITE(host->base, CON, con | OD); in omap_hsmmc_set_bus_mode()
679 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD); in omap_hsmmc_set_bus_mode()
688 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
690 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_context_restore()
694 if (host->con == OMAP_HSMMC_READ(host->base, CON) && in omap_hsmmc_context_restore()
695 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) && in omap_hsmmc_context_restore()
696 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) && in omap_hsmmc_context_restore()
697 host->capa == OMAP_HSMMC_READ(host->base, CAPA)) in omap_hsmmc_context_restore()
700 host->context_loss++; in omap_hsmmc_context_restore()
702 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_context_restore()
703 if (host->power_mode != MMC_POWER_OFF && in omap_hsmmc_context_restore()
714 if (host->mmc->caps & MMC_CAP_SDIO_IRQ) in omap_hsmmc_context_restore()
717 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
718 OMAP_HSMMC_READ(host->base, HCTL) | hctl); in omap_hsmmc_context_restore()
720 OMAP_HSMMC_WRITE(host->base, CAPA, in omap_hsmmc_context_restore()
721 OMAP_HSMMC_READ(host->base, CAPA) | capa); in omap_hsmmc_context_restore()
723 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
724 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in omap_hsmmc_context_restore()
727 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP in omap_hsmmc_context_restore()
731 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_context_restore()
732 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_context_restore()
733 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_context_restore()
736 if (host->power_mode == MMC_POWER_OFF) in omap_hsmmc_context_restore()
739 omap_hsmmc_set_bus_width(host); in omap_hsmmc_context_restore()
741 omap_hsmmc_set_clock(host); in omap_hsmmc_context_restore()
743 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_context_restore()
746 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n", in omap_hsmmc_context_restore()
747 host->context_loss); in omap_hsmmc_context_restore()
754 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
756 host->con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_context_save()
757 host->hctl = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_context_save()
758 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_context_save()
759 host->capa = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_context_save()
764 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
769 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
779 static void send_init_stream(struct omap_hsmmc_host *host) in send_init_stream() argument
784 if (host->protect_card) in send_init_stream()
787 disable_irq(host->irq); in send_init_stream()
789 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK); in send_init_stream()
790 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
791 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM); in send_init_stream()
792 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); in send_init_stream()
796 reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN; in send_init_stream()
798 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
799 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); in send_init_stream()
801 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in send_init_stream()
802 OMAP_HSMMC_READ(host->base, STAT); in send_init_stream()
804 enable_irq(host->irq); in send_init_stream()
808 int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host) in omap_hsmmc_cover_is_closed() argument
812 if (host->get_cover_state) in omap_hsmmc_cover_is_closed()
813 r = host->get_cover_state(host->dev); in omap_hsmmc_cover_is_closed()
822 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_cover_switch() local
825 omap_hsmmc_cover_is_closed(host) ? "closed" : "open"); in omap_hsmmc_show_cover_switch()
835 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_slot_name() local
837 return sprintf(buf, "%s\n", mmc_pdata(host)->name); in omap_hsmmc_show_slot_name()
846 omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, in omap_hsmmc_start_command() argument
851 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n", in omap_hsmmc_start_command()
852 mmc_hostname(host->mmc), cmd->opcode, cmd->arg); in omap_hsmmc_start_command()
853 host->cmd = cmd; in omap_hsmmc_start_command()
855 omap_hsmmc_enable_irq(host, cmd); in omap_hsmmc_start_command()
857 host->response_busy = 0; in omap_hsmmc_start_command()
863 host->response_busy = 1; in omap_hsmmc_start_command()
873 if (cmd == host->mrq->stop) in omap_hsmmc_start_command()
878 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) && in omap_hsmmc_start_command()
879 host->mrq->sbc) { in omap_hsmmc_start_command()
881 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg); in omap_hsmmc_start_command()
891 if (host->use_dma) in omap_hsmmc_start_command()
894 host->req_in_progress = 1; in omap_hsmmc_start_command()
896 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg); in omap_hsmmc_start_command()
897 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg); in omap_hsmmc_start_command()
900 static struct dma_chan *omap_hsmmc_get_dma_chan(struct omap_hsmmc_host *host, in omap_hsmmc_get_dma_chan() argument
903 return data->flags & MMC_DATA_WRITE ? host->tx_chan : host->rx_chan; in omap_hsmmc_get_dma_chan()
906 static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq) in omap_hsmmc_request_done() argument
911 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_request_done()
912 host->req_in_progress = 0; in omap_hsmmc_request_done()
913 dma_ch = host->dma_ch; in omap_hsmmc_request_done()
914 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_request_done()
916 omap_hsmmc_disable_irq(host); in omap_hsmmc_request_done()
918 if (mrq->data && host->use_dma && dma_ch != -1) in omap_hsmmc_request_done()
920 host->mrq = NULL; in omap_hsmmc_request_done()
921 mmc_request_done(host->mmc, mrq); in omap_hsmmc_request_done()
928 omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_xfer_done() argument
931 struct mmc_request *mrq = host->mrq; in omap_hsmmc_xfer_done()
934 if (host->cmd && host->cmd->opcode == 6 && in omap_hsmmc_xfer_done()
935 host->response_busy) { in omap_hsmmc_xfer_done()
936 host->response_busy = 0; in omap_hsmmc_xfer_done()
940 omap_hsmmc_request_done(host, mrq); in omap_hsmmc_xfer_done()
944 host->data = NULL; in omap_hsmmc_xfer_done()
951 if (data->stop && (data->error || !host->mrq->sbc)) in omap_hsmmc_xfer_done()
952 omap_hsmmc_start_command(host, data->stop, NULL); in omap_hsmmc_xfer_done()
954 omap_hsmmc_request_done(host, data->mrq); in omap_hsmmc_xfer_done()
961 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) in omap_hsmmc_cmd_done() argument
963 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) && in omap_hsmmc_cmd_done()
964 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_cmd_done()
965 host->cmd = NULL; in omap_hsmmc_cmd_done()
966 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_cmd_done()
967 omap_hsmmc_start_command(host, host->mrq->cmd, in omap_hsmmc_cmd_done()
968 host->mrq->data); in omap_hsmmc_cmd_done()
972 host->cmd = NULL; in omap_hsmmc_cmd_done()
977 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
978 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32); in omap_hsmmc_cmd_done()
979 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54); in omap_hsmmc_cmd_done()
980 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76); in omap_hsmmc_cmd_done()
983 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
986 if ((host->data == NULL && !host->response_busy) || cmd->error) in omap_hsmmc_cmd_done()
987 omap_hsmmc_request_done(host, host->mrq); in omap_hsmmc_cmd_done()
993 static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) in omap_hsmmc_dma_cleanup() argument
998 host->data->error = errno; in omap_hsmmc_dma_cleanup()
1000 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
1001 dma_ch = host->dma_ch; in omap_hsmmc_dma_cleanup()
1002 host->dma_ch = -1; in omap_hsmmc_dma_cleanup()
1003 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
1005 if (host->use_dma && dma_ch != -1) { in omap_hsmmc_dma_cleanup()
1006 struct dma_chan *chan = omap_hsmmc_get_dma_chan(host, host->data); in omap_hsmmc_dma_cleanup()
1010 host->data->sg, host->data->sg_len, in omap_hsmmc_dma_cleanup()
1011 mmc_get_dma_dir(host->data)); in omap_hsmmc_dma_cleanup()
1013 host->data->host_cookie = 0; in omap_hsmmc_dma_cleanup()
1015 host->data = NULL; in omap_hsmmc_dma_cleanup()
1022 static void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, u32 status) in omap_hsmmc_dbg_report_irq() argument
1044 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in omap_hsmmc_dbg_report_irq()
1047 static inline void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, in omap_hsmmc_dbg_report_irq() argument
1060 static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, in omap_hsmmc_reset_controller_fsm() argument
1066 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_reset_controller_fsm()
1067 OMAP_HSMMC_READ(host->base, SYSCTL) | bit); in omap_hsmmc_reset_controller_fsm()
1073 if (mmc_pdata(host)->features & HSMMC_HAS_UPDATED_RESET) { in omap_hsmmc_reset_controller_fsm()
1074 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit)) in omap_hsmmc_reset_controller_fsm()
1080 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) && in omap_hsmmc_reset_controller_fsm()
1084 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit) in omap_hsmmc_reset_controller_fsm()
1085 dev_err(mmc_dev(host->mmc), in omap_hsmmc_reset_controller_fsm()
1090 static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, in hsmmc_command_incomplete() argument
1094 omap_hsmmc_reset_controller_fsm(host, SRC); in hsmmc_command_incomplete()
1095 if (host->cmd) in hsmmc_command_incomplete()
1096 host->cmd->error = err; in hsmmc_command_incomplete()
1099 if (host->data) { in hsmmc_command_incomplete()
1100 omap_hsmmc_reset_controller_fsm(host, SRD); in hsmmc_command_incomplete()
1101 omap_hsmmc_dma_cleanup(host, err); in hsmmc_command_incomplete()
1102 } else if (host->mrq && host->mrq->cmd) in hsmmc_command_incomplete()
1103 host->mrq->cmd->error = err; in hsmmc_command_incomplete()
1106 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) in omap_hsmmc_do_irq() argument
1112 data = host->data; in omap_hsmmc_do_irq()
1113 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); in omap_hsmmc_do_irq()
1116 omap_hsmmc_dbg_report_irq(host, status); in omap_hsmmc_do_irq()
1120 if (host->data || host->response_busy) { in omap_hsmmc_do_irq()
1122 host->response_busy = 0; in omap_hsmmc_do_irq()
1125 hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); in omap_hsmmc_do_irq()
1128 hsmmc_command_incomplete(host, -EILSEQ, end_cmd); in omap_hsmmc_do_irq()
1132 ac12 = OMAP_HSMMC_READ(host->base, AC12); in omap_hsmmc_do_irq()
1133 if (!(ac12 & ACNE) && host->mrq->sbc) { in omap_hsmmc_do_irq()
1139 host->mrq->sbc->error = error; in omap_hsmmc_do_irq()
1140 hsmmc_command_incomplete(host, error, end_cmd); in omap_hsmmc_do_irq()
1142 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12); in omap_hsmmc_do_irq()
1146 OMAP_HSMMC_WRITE(host->base, STAT, status); in omap_hsmmc_do_irq()
1147 if (end_cmd || ((status & CC_EN) && host->cmd)) in omap_hsmmc_do_irq()
1148 omap_hsmmc_cmd_done(host, host->cmd); in omap_hsmmc_do_irq()
1149 if ((end_trans || (status & TC_EN)) && host->mrq) in omap_hsmmc_do_irq()
1150 omap_hsmmc_xfer_done(host, data); in omap_hsmmc_do_irq()
1158 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_irq() local
1161 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1163 if (host->req_in_progress) in omap_hsmmc_irq()
1164 omap_hsmmc_do_irq(host, status); in omap_hsmmc_irq()
1167 mmc_signal_sdio_irq(host->mmc); in omap_hsmmc_irq()
1170 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1176 static void set_sd_bus_power(struct omap_hsmmc_host *host) in set_sd_bus_power() argument
1180 OMAP_HSMMC_WRITE(host->base, HCTL, in set_sd_bus_power()
1181 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in set_sd_bus_power()
1183 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP) in set_sd_bus_power()
1196 static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) in omap_hsmmc_switch_opcond() argument
1202 if (host->dbclk) in omap_hsmmc_switch_opcond()
1203 clk_disable_unprepare(host->dbclk); in omap_hsmmc_switch_opcond()
1206 ret = omap_hsmmc_set_power(host, 0); in omap_hsmmc_switch_opcond()
1210 ret = omap_hsmmc_set_power(host, 1); in omap_hsmmc_switch_opcond()
1211 if (host->dbclk) in omap_hsmmc_switch_opcond()
1212 clk_prepare_enable(host->dbclk); in omap_hsmmc_switch_opcond()
1217 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_switch_opcond()
1218 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR); in omap_hsmmc_switch_opcond()
1219 reg_val = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_switch_opcond()
1241 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val); in omap_hsmmc_switch_opcond()
1242 set_sd_bus_power(host); in omap_hsmmc_switch_opcond()
1246 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); in omap_hsmmc_switch_opcond()
1251 static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) in omap_hsmmc_protect_card() argument
1253 if (!host->get_cover_state) in omap_hsmmc_protect_card()
1256 host->reqs_blocked = 0; in omap_hsmmc_protect_card()
1257 if (host->get_cover_state(host->dev)) { in omap_hsmmc_protect_card()
1258 if (host->protect_card) { in omap_hsmmc_protect_card()
1259 dev_info(host->dev, "%s: cover is closed, " in omap_hsmmc_protect_card()
1261 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1262 host->protect_card = 0; in omap_hsmmc_protect_card()
1265 if (!host->protect_card) { in omap_hsmmc_protect_card()
1266 dev_info(host->dev, "%s: cover is open, " in omap_hsmmc_protect_card()
1268 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1269 host->protect_card = 1; in omap_hsmmc_protect_card()
1279 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_cover_irq() local
1281 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); in omap_hsmmc_cover_irq()
1283 omap_hsmmc_protect_card(host); in omap_hsmmc_cover_irq()
1284 mmc_detect_change(host->mmc, (HZ * 200) / 1000); in omap_hsmmc_cover_irq()
1290 struct omap_hsmmc_host *host = param; in omap_hsmmc_dma_callback() local
1295 spin_lock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1296 if (host->dma_ch < 0) { in omap_hsmmc_dma_callback()
1297 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1301 data = host->mrq->data; in omap_hsmmc_dma_callback()
1302 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_dma_callback()
1308 req_in_progress = host->req_in_progress; in omap_hsmmc_dma_callback()
1309 host->dma_ch = -1; in omap_hsmmc_dma_callback()
1310 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1314 struct mmc_request *mrq = host->mrq; in omap_hsmmc_dma_callback()
1316 host->mrq = NULL; in omap_hsmmc_dma_callback()
1317 mmc_request_done(host->mmc, mrq); in omap_hsmmc_dma_callback()
1321 static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_pre_dma_transfer() argument
1329 data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1330 dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" in omap_hsmmc_pre_dma_transfer()
1332 __func__, data->host_cookie, host->next_data.cookie); in omap_hsmmc_pre_dma_transfer()
1337 if (next || data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1342 dma_len = host->next_data.dma_len; in omap_hsmmc_pre_dma_transfer()
1343 host->next_data.dma_len = 0; in omap_hsmmc_pre_dma_transfer()
1354 host->dma_len = dma_len; in omap_hsmmc_pre_dma_transfer()
1362 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_setup_dma_transfer() argument
1370 .src_addr = host->mapbase + OMAP_HSMMC_DATA, in omap_hsmmc_setup_dma_transfer()
1371 .dst_addr = host->mapbase + OMAP_HSMMC_DATA, in omap_hsmmc_setup_dma_transfer()
1392 BUG_ON(host->dma_ch != -1); in omap_hsmmc_setup_dma_transfer()
1394 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_setup_dma_transfer()
1400 ret = omap_hsmmc_pre_dma_transfer(host, data, NULL, chan); in omap_hsmmc_setup_dma_transfer()
1408 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n"); in omap_hsmmc_setup_dma_transfer()
1414 tx->callback_param = host; in omap_hsmmc_setup_dma_transfer()
1419 host->dma_ch = 1; in omap_hsmmc_setup_dma_transfer()
1424 static void set_data_timeout(struct omap_hsmmc_host *host, in set_data_timeout() argument
1432 reg = OMAP_HSMMC_READ(host->base, SYSCTL); in set_data_timeout()
1437 cycle_ns = 1000000000 / (host->clk_rate / clkd); in set_data_timeout()
1459 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg); in set_data_timeout()
1462 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host) in omap_hsmmc_start_dma_transfer() argument
1464 struct mmc_request *req = host->mrq; in omap_hsmmc_start_dma_transfer()
1469 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz) in omap_hsmmc_start_dma_transfer()
1471 set_data_timeout(host, req->data->timeout_ns, in omap_hsmmc_start_dma_transfer()
1473 chan = omap_hsmmc_get_dma_chan(host, req->data); in omap_hsmmc_start_dma_transfer()
1481 omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) in omap_hsmmc_prepare_data() argument
1486 host->data = req->data; in omap_hsmmc_prepare_data()
1489 OMAP_HSMMC_WRITE(host->base, BLK, 0); in omap_hsmmc_prepare_data()
1500 set_data_timeout(host, timeout, 0); in omap_hsmmc_prepare_data()
1505 if (host->use_dma) { in omap_hsmmc_prepare_data()
1506 ret = omap_hsmmc_setup_dma_transfer(host, req); in omap_hsmmc_prepare_data()
1508 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); in omap_hsmmc_prepare_data()
1518 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_post_req() local
1521 if (host->use_dma && data->host_cookie) { in omap_hsmmc_post_req()
1522 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_post_req()
1532 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_pre_req() local
1539 if (host->use_dma) { in omap_hsmmc_pre_req()
1540 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, mrq->data); in omap_hsmmc_pre_req()
1542 if (omap_hsmmc_pre_dma_transfer(host, mrq->data, in omap_hsmmc_pre_req()
1543 &host->next_data, c)) in omap_hsmmc_pre_req()
1553 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_request() local
1556 BUG_ON(host->req_in_progress); in omap_hsmmc_request()
1557 BUG_ON(host->dma_ch != -1); in omap_hsmmc_request()
1558 if (host->protect_card) { in omap_hsmmc_request()
1559 if (host->reqs_blocked < 3) { in omap_hsmmc_request()
1565 omap_hsmmc_reset_controller_fsm(host, SRD); in omap_hsmmc_request()
1566 omap_hsmmc_reset_controller_fsm(host, SRC); in omap_hsmmc_request()
1567 host->reqs_blocked += 1; in omap_hsmmc_request()
1575 } else if (host->reqs_blocked) in omap_hsmmc_request()
1576 host->reqs_blocked = 0; in omap_hsmmc_request()
1577 WARN_ON(host->mrq != NULL); in omap_hsmmc_request()
1578 host->mrq = req; in omap_hsmmc_request()
1579 host->clk_rate = clk_get_rate(host->fclk); in omap_hsmmc_request()
1580 err = omap_hsmmc_prepare_data(host, req); in omap_hsmmc_request()
1585 host->mrq = NULL; in omap_hsmmc_request()
1589 if (req->sbc && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_request()
1590 omap_hsmmc_start_command(host, req->sbc, NULL); in omap_hsmmc_request()
1594 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_request()
1595 omap_hsmmc_start_command(host, req->cmd, req->data); in omap_hsmmc_request()
1601 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_set_ios() local
1604 if (ios->power_mode != host->power_mode) { in omap_hsmmc_set_ios()
1607 omap_hsmmc_set_power(host, 0); in omap_hsmmc_set_ios()
1610 omap_hsmmc_set_power(host, 1); in omap_hsmmc_set_ios()
1616 host->power_mode = ios->power_mode; in omap_hsmmc_set_ios()
1621 omap_hsmmc_set_bus_width(host); in omap_hsmmc_set_ios()
1623 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_set_ios()
1627 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && in omap_hsmmc_set_ios()
1635 if (omap_hsmmc_switch_opcond(host, ios->vdd) != 0) in omap_hsmmc_set_ios()
1636 dev_dbg(mmc_dev(host->mmc), in omap_hsmmc_set_ios()
1641 omap_hsmmc_set_clock(host); in omap_hsmmc_set_ios()
1644 send_init_stream(host); in omap_hsmmc_set_ios()
1646 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_set_ios()
1651 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_get_cd() local
1653 if (!host->card_detect) in omap_hsmmc_get_cd()
1655 return host->card_detect(host->dev); in omap_hsmmc_get_cd()
1660 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_init_card() local
1662 if (mmc_pdata(host)->init_card) in omap_hsmmc_init_card()
1663 mmc_pdata(host)->init_card(card); in omap_hsmmc_init_card()
1668 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_sdio_irq() local
1672 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1674 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_enable_sdio_irq()
1675 irq_mask = OMAP_HSMMC_READ(host->base, ISE); in omap_hsmmc_enable_sdio_irq()
1677 host->flags |= HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1681 host->flags &= ~HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1685 OMAP_HSMMC_WRITE(host->base, CON, con); in omap_hsmmc_enable_sdio_irq()
1686 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1692 if (!host->req_in_progress || !enable) in omap_hsmmc_enable_sdio_irq()
1693 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1696 OMAP_HSMMC_READ(host->base, IE); in omap_hsmmc_enable_sdio_irq()
1698 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1701 static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host) in omap_hsmmc_configure_wake_irq() argument
1711 if (!host->dev->of_node || !host->wake_irq) in omap_hsmmc_configure_wake_irq()
1714 ret = dev_pm_set_dedicated_wake_irq(host->dev, host->wake_irq); in omap_hsmmc_configure_wake_irq()
1716 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); in omap_hsmmc_configure_wake_irq()
1724 if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) { in omap_hsmmc_configure_wake_irq()
1725 struct pinctrl *p = devm_pinctrl_get(host->dev); in omap_hsmmc_configure_wake_irq()
1731 dev_info(host->dev, "missing default pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1738 dev_info(host->dev, "missing idle pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1746 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_configure_wake_irq()
1747 OMAP_HSMMC_READ(host->base, HCTL) | IWE); in omap_hsmmc_configure_wake_irq()
1751 dev_pm_clear_wake_irq(host->dev); in omap_hsmmc_configure_wake_irq()
1753 dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n"); in omap_hsmmc_configure_wake_irq()
1754 host->wake_irq = 0; in omap_hsmmc_configure_wake_irq()
1758 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host) in omap_hsmmc_conf_bus_power() argument
1763 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_conf_bus_power()
1771 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK; in omap_hsmmc_conf_bus_power()
1772 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl); in omap_hsmmc_conf_bus_power()
1774 value = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_conf_bus_power()
1775 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa); in omap_hsmmc_conf_bus_power()
1778 set_sd_bus_power(host); in omap_hsmmc_conf_bus_power()
1807 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_regs_show() local
1815 (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled" in omap_hsmmc_regs_show()
1818 seq_printf(s, "ctx_loss:\t%d\n", host->context_loss); in omap_hsmmc_regs_show()
1820 pm_runtime_get_sync(host->dev); in omap_hsmmc_regs_show()
1823 OMAP_HSMMC_READ(host->base, CON)); in omap_hsmmc_regs_show()
1825 OMAP_HSMMC_READ(host->base, PSTATE)); in omap_hsmmc_regs_show()
1827 OMAP_HSMMC_READ(host->base, HCTL)); in omap_hsmmc_regs_show()
1829 OMAP_HSMMC_READ(host->base, SYSCTL)); in omap_hsmmc_regs_show()
1831 OMAP_HSMMC_READ(host->base, IE)); in omap_hsmmc_regs_show()
1833 OMAP_HSMMC_READ(host->base, ISE)); in omap_hsmmc_regs_show()
1835 OMAP_HSMMC_READ(host->base, CAPA)); in omap_hsmmc_regs_show()
1837 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_regs_show()
1838 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_regs_show()
1952 struct omap_hsmmc_host *host = NULL; in omap_hsmmc_probe() local
1997 host = mmc_priv(mmc); in omap_hsmmc_probe()
1998 host->mmc = mmc; in omap_hsmmc_probe()
1999 host->pdata = pdata; in omap_hsmmc_probe()
2000 host->dev = &pdev->dev; in omap_hsmmc_probe()
2001 host->use_dma = 1; in omap_hsmmc_probe()
2002 host->dma_ch = -1; in omap_hsmmc_probe()
2003 host->irq = irq; in omap_hsmmc_probe()
2004 host->mapbase = res->start + pdata->reg_offset; in omap_hsmmc_probe()
2005 host->base = base + pdata->reg_offset; in omap_hsmmc_probe()
2006 host->power_mode = MMC_POWER_OFF; in omap_hsmmc_probe()
2007 host->next_data.cookie = 1; in omap_hsmmc_probe()
2008 host->pbias_enabled = 0; in omap_hsmmc_probe()
2009 host->vqmmc_enabled = 0; in omap_hsmmc_probe()
2011 ret = omap_hsmmc_gpio_init(mmc, host, pdata); in omap_hsmmc_probe()
2015 platform_set_drvdata(pdev, host); in omap_hsmmc_probe()
2018 host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); in omap_hsmmc_probe()
2029 spin_lock_init(&host->irq_lock); in omap_hsmmc_probe()
2031 host->fclk = devm_clk_get(&pdev->dev, "fck"); in omap_hsmmc_probe()
2032 if (IS_ERR(host->fclk)) { in omap_hsmmc_probe()
2033 ret = PTR_ERR(host->fclk); in omap_hsmmc_probe()
2034 host->fclk = NULL; in omap_hsmmc_probe()
2038 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { in omap_hsmmc_probe()
2044 pm_runtime_enable(host->dev); in omap_hsmmc_probe()
2045 pm_runtime_get_sync(host->dev); in omap_hsmmc_probe()
2046 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); in omap_hsmmc_probe()
2047 pm_runtime_use_autosuspend(host->dev); in omap_hsmmc_probe()
2049 omap_hsmmc_context_save(host); in omap_hsmmc_probe()
2051 host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck"); in omap_hsmmc_probe()
2055 if (IS_ERR(host->dbclk)) { in omap_hsmmc_probe()
2056 host->dbclk = NULL; in omap_hsmmc_probe()
2057 } else if (clk_prepare_enable(host->dbclk) != 0) { in omap_hsmmc_probe()
2058 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); in omap_hsmmc_probe()
2059 host->dbclk = NULL; in omap_hsmmc_probe()
2074 mmc->caps |= mmc_pdata(host)->caps; in omap_hsmmc_probe()
2078 if (mmc_pdata(host)->nonremovable) in omap_hsmmc_probe()
2081 mmc->pm_caps |= mmc_pdata(host)->pm_caps; in omap_hsmmc_probe()
2083 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_probe()
2085 host->rx_chan = dma_request_chan(&pdev->dev, "rx"); in omap_hsmmc_probe()
2086 if (IS_ERR(host->rx_chan)) { in omap_hsmmc_probe()
2087 dev_err(mmc_dev(host->mmc), "RX DMA channel request failed\n"); in omap_hsmmc_probe()
2088 ret = PTR_ERR(host->rx_chan); in omap_hsmmc_probe()
2092 host->tx_chan = dma_request_chan(&pdev->dev, "tx"); in omap_hsmmc_probe()
2093 if (IS_ERR(host->tx_chan)) { in omap_hsmmc_probe()
2094 dev_err(mmc_dev(host->mmc), "TX DMA channel request failed\n"); in omap_hsmmc_probe()
2095 ret = PTR_ERR(host->tx_chan); in omap_hsmmc_probe()
2100 ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0, in omap_hsmmc_probe()
2101 mmc_hostname(mmc), host); in omap_hsmmc_probe()
2103 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); in omap_hsmmc_probe()
2107 ret = omap_hsmmc_reg_get(host); in omap_hsmmc_probe()
2112 mmc->ocr_avail = mmc_pdata(host)->ocr_mask; in omap_hsmmc_probe()
2114 omap_hsmmc_disable_irq(host); in omap_hsmmc_probe()
2124 ret = omap_hsmmc_configure_wake_irq(host); in omap_hsmmc_probe()
2128 omap_hsmmc_protect_card(host); in omap_hsmmc_probe()
2132 if (mmc_pdata(host)->name != NULL) { in omap_hsmmc_probe()
2137 if (host->get_cover_state) { in omap_hsmmc_probe()
2145 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_probe()
2146 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_probe()
2154 if (!IS_ERR_OR_NULL(host->tx_chan)) in omap_hsmmc_probe()
2155 dma_release_channel(host->tx_chan); in omap_hsmmc_probe()
2156 if (!IS_ERR_OR_NULL(host->rx_chan)) in omap_hsmmc_probe()
2157 dma_release_channel(host->rx_chan); in omap_hsmmc_probe()
2158 pm_runtime_dont_use_autosuspend(host->dev); in omap_hsmmc_probe()
2159 pm_runtime_put_sync(host->dev); in omap_hsmmc_probe()
2160 pm_runtime_disable(host->dev); in omap_hsmmc_probe()
2161 if (host->dbclk) in omap_hsmmc_probe()
2162 clk_disable_unprepare(host->dbclk); in omap_hsmmc_probe()
2172 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); in omap_hsmmc_remove() local
2174 pm_runtime_get_sync(host->dev); in omap_hsmmc_remove()
2175 mmc_remove_host(host->mmc); in omap_hsmmc_remove()
2177 dma_release_channel(host->tx_chan); in omap_hsmmc_remove()
2178 dma_release_channel(host->rx_chan); in omap_hsmmc_remove()
2180 dev_pm_clear_wake_irq(host->dev); in omap_hsmmc_remove()
2181 pm_runtime_dont_use_autosuspend(host->dev); in omap_hsmmc_remove()
2182 pm_runtime_put_sync(host->dev); in omap_hsmmc_remove()
2183 pm_runtime_disable(host->dev); in omap_hsmmc_remove()
2185 if (host->dbclk) in omap_hsmmc_remove()
2186 clk_disable_unprepare(host->dbclk); in omap_hsmmc_remove()
2188 mmc_free_host(host->mmc); in omap_hsmmc_remove()
2196 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_suspend() local
2198 if (!host) in omap_hsmmc_suspend()
2201 pm_runtime_get_sync(host->dev); in omap_hsmmc_suspend()
2203 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { in omap_hsmmc_suspend()
2204 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_suspend()
2205 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_suspend()
2206 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_suspend()
2207 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_suspend()
2208 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); in omap_hsmmc_suspend()
2211 if (host->dbclk) in omap_hsmmc_suspend()
2212 clk_disable_unprepare(host->dbclk); in omap_hsmmc_suspend()
2214 pm_runtime_put_sync(host->dev); in omap_hsmmc_suspend()
2221 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_resume() local
2223 if (!host) in omap_hsmmc_resume()
2226 pm_runtime_get_sync(host->dev); in omap_hsmmc_resume()
2228 if (host->dbclk) in omap_hsmmc_resume()
2229 clk_prepare_enable(host->dbclk); in omap_hsmmc_resume()
2231 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) in omap_hsmmc_resume()
2232 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_resume()
2234 omap_hsmmc_protect_card(host); in omap_hsmmc_resume()
2235 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_resume()
2236 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_resume()
2243 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_suspend() local
2247 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_suspend()
2248 omap_hsmmc_context_save(host); in omap_hsmmc_runtime_suspend()
2251 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2252 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_suspend()
2253 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_suspend()
2255 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_runtime_suspend()
2256 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_runtime_suspend()
2258 if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) { in omap_hsmmc_runtime_suspend()
2265 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_suspend()
2266 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2267 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2279 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2285 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_resume() local
2288 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_resume()
2289 omap_hsmmc_context_restore(host); in omap_hsmmc_runtime_resume()
2292 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()
2293 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_resume()
2294 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_resume()
2296 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2299 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_resume()
2300 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2301 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2303 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2305 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()