Lines Matching refs:host

160 #define mmc_pdata(host)		host->pdata  argument
232 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
236 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_card_detect() local
238 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_card_detect()
243 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_get_cover_state() local
245 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_get_cover_state()
251 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_supply() local
261 if (mmc->supply.vqmmc && !host->vqmmc_enabled) { in omap_hsmmc_enable_supply()
267 host->vqmmc_enabled = 1; in omap_hsmmc_enable_supply()
283 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_disable_supply() local
285 if (mmc->supply.vqmmc && host->vqmmc_enabled) { in omap_hsmmc_disable_supply()
291 host->vqmmc_enabled = 0; in omap_hsmmc_disable_supply()
312 static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, in omap_hsmmc_set_pbias() argument
317 if (!host->pbias) in omap_hsmmc_set_pbias()
322 ret = regulator_set_voltage(host->pbias, VDD_1V8, in omap_hsmmc_set_pbias()
325 ret = regulator_set_voltage(host->pbias, VDD_3V0, in omap_hsmmc_set_pbias()
328 dev_err(host->dev, "pbias set voltage fail\n"); in omap_hsmmc_set_pbias()
332 if (host->pbias_enabled == 0) { in omap_hsmmc_set_pbias()
333 ret = regulator_enable(host->pbias); in omap_hsmmc_set_pbias()
335 dev_err(host->dev, "pbias reg enable fail\n"); in omap_hsmmc_set_pbias()
338 host->pbias_enabled = 1; in omap_hsmmc_set_pbias()
341 if (host->pbias_enabled == 1) { in omap_hsmmc_set_pbias()
342 ret = regulator_disable(host->pbias); in omap_hsmmc_set_pbias()
344 dev_err(host->dev, "pbias reg disable fail\n"); in omap_hsmmc_set_pbias()
347 host->pbias_enabled = 0; in omap_hsmmc_set_pbias()
356 struct omap_hsmmc_host *host = in omap_hsmmc_set_power() local
358 struct mmc_host *mmc = host->mmc; in omap_hsmmc_set_power()
361 if (mmc_pdata(host)->set_power) in omap_hsmmc_set_power()
362 return mmc_pdata(host)->set_power(dev, power_on, vdd); in omap_hsmmc_set_power()
371 if (mmc_pdata(host)->before_set_reg) in omap_hsmmc_set_power()
372 mmc_pdata(host)->before_set_reg(dev, power_on, vdd); in omap_hsmmc_set_power()
374 ret = omap_hsmmc_set_pbias(host, false, 0); in omap_hsmmc_set_power()
396 ret = omap_hsmmc_set_pbias(host, true, vdd); in omap_hsmmc_set_power()
405 if (mmc_pdata(host)->after_set_reg) in omap_hsmmc_set_power()
406 mmc_pdata(host)->after_set_reg(dev, power_on, vdd); in omap_hsmmc_set_power()
436 static int omap_hsmmc_disable_boot_regulators(struct omap_hsmmc_host *host) in omap_hsmmc_disable_boot_regulators() argument
438 struct mmc_host *mmc = host->mmc; in omap_hsmmc_disable_boot_regulators()
448 dev_err(host->dev, "fail to disable boot enabled vmmc reg\n"); in omap_hsmmc_disable_boot_regulators()
454 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
459 ret = omap_hsmmc_disable_boot_regulator(host->pbias); in omap_hsmmc_disable_boot_regulators()
461 dev_err(host->dev, in omap_hsmmc_disable_boot_regulators()
469 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) in omap_hsmmc_reg_get() argument
473 struct mmc_host *mmc = host->mmc; in omap_hsmmc_reg_get()
475 if (mmc_pdata(host)->set_power) in omap_hsmmc_reg_get()
478 mmc->supply.vmmc = devm_regulator_get_optional(host->dev, "vmmc"); in omap_hsmmc_reg_get()
481 if ((ret != -ENODEV) && host->dev->of_node) in omap_hsmmc_reg_get()
483 dev_dbg(host->dev, "unable to get vmmc regulator %ld\n", in omap_hsmmc_reg_get()
489 mmc_pdata(host)->ocr_mask = ocr_value; in omap_hsmmc_reg_get()
493 mmc->supply.vqmmc = devm_regulator_get_optional(host->dev, "vmmc_aux"); in omap_hsmmc_reg_get()
496 if ((ret != -ENODEV) && host->dev->of_node) in omap_hsmmc_reg_get()
498 dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n", in omap_hsmmc_reg_get()
503 host->pbias = devm_regulator_get_optional(host->dev, "pbias"); in omap_hsmmc_reg_get()
504 if (IS_ERR(host->pbias)) { in omap_hsmmc_reg_get()
505 ret = PTR_ERR(host->pbias); in omap_hsmmc_reg_get()
506 if ((ret != -ENODEV) && host->dev->of_node) in omap_hsmmc_reg_get()
508 dev_dbg(host->dev, "unable to get pbias regulator %ld\n", in omap_hsmmc_reg_get()
509 PTR_ERR(host->pbias)); in omap_hsmmc_reg_get()
510 host->pbias = NULL; in omap_hsmmc_reg_get()
514 if (mmc_pdata(host)->no_regulator_off_init) in omap_hsmmc_reg_get()
517 ret = omap_hsmmc_disable_boot_regulators(host); in omap_hsmmc_reg_get()
527 struct omap_hsmmc_host *host, in omap_hsmmc_gpio_init() argument
537 host->get_cover_state = omap_hsmmc_get_cover_state; in omap_hsmmc_gpio_init()
544 host->card_detect = omap_hsmmc_card_detect; in omap_hsmmc_gpio_init()
559 static void omap_hsmmc_start_clock(struct omap_hsmmc_host *host) in omap_hsmmc_start_clock() argument
561 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_start_clock()
562 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN); in omap_hsmmc_start_clock()
568 static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host) in omap_hsmmc_stop_clock() argument
570 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_stop_clock()
571 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN); in omap_hsmmc_stop_clock()
572 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0) in omap_hsmmc_stop_clock()
573 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n"); in omap_hsmmc_stop_clock()
576 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, in omap_hsmmc_enable_irq() argument
582 if (host->use_dma) in omap_hsmmc_enable_irq()
589 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
590 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_enable_irq()
591 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_irq()
594 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_enable_irq()
596 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_irq()
597 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
600 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host) in omap_hsmmc_disable_irq() argument
605 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
607 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_disable_irq()
609 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_disable_irq()
610 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_disable_irq()
611 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_disable_irq()
612 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
616 static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios) in calc_divisor() argument
621 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock); in calc_divisor()
629 static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) in omap_hsmmc_set_clock() argument
631 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_clock()
636 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); in omap_hsmmc_set_clock()
638 omap_hsmmc_stop_clock(host); in omap_hsmmc_set_clock()
640 regval = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_set_clock()
642 clkdiv = calc_divisor(host, ios); in omap_hsmmc_set_clock()
644 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); in omap_hsmmc_set_clock()
645 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_set_clock()
646 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); in omap_hsmmc_set_clock()
650 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS in omap_hsmmc_set_clock()
663 if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) && in omap_hsmmc_set_clock()
666 ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) { in omap_hsmmc_set_clock()
667 regval = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_set_clock()
668 if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000) in omap_hsmmc_set_clock()
673 OMAP_HSMMC_WRITE(host->base, HCTL, regval); in omap_hsmmc_set_clock()
676 omap_hsmmc_start_clock(host); in omap_hsmmc_set_clock()
679 static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_width() argument
681 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_width()
684 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_width()
692 OMAP_HSMMC_WRITE(host->base, CON, con | DW8); in omap_hsmmc_set_bus_width()
695 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
696 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
697 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT); in omap_hsmmc_set_bus_width()
700 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
701 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
702 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT); in omap_hsmmc_set_bus_width()
707 static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_mode() argument
709 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_mode()
712 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_mode()
714 OMAP_HSMMC_WRITE(host->base, CON, con | OD); in omap_hsmmc_set_bus_mode()
716 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD); in omap_hsmmc_set_bus_mode()
725 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
727 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_context_restore()
731 if (host->con == OMAP_HSMMC_READ(host->base, CON) && in omap_hsmmc_context_restore()
732 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) && in omap_hsmmc_context_restore()
733 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) && in omap_hsmmc_context_restore()
734 host->capa == OMAP_HSMMC_READ(host->base, CAPA)) in omap_hsmmc_context_restore()
737 host->context_loss++; in omap_hsmmc_context_restore()
739 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_context_restore()
740 if (host->power_mode != MMC_POWER_OFF && in omap_hsmmc_context_restore()
751 if (host->mmc->caps & MMC_CAP_SDIO_IRQ) in omap_hsmmc_context_restore()
754 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
755 OMAP_HSMMC_READ(host->base, HCTL) | hctl); in omap_hsmmc_context_restore()
757 OMAP_HSMMC_WRITE(host->base, CAPA, in omap_hsmmc_context_restore()
758 OMAP_HSMMC_READ(host->base, CAPA) | capa); in omap_hsmmc_context_restore()
760 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
761 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in omap_hsmmc_context_restore()
764 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP in omap_hsmmc_context_restore()
768 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_context_restore()
769 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_context_restore()
770 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_context_restore()
773 if (host->power_mode == MMC_POWER_OFF) in omap_hsmmc_context_restore()
776 omap_hsmmc_set_bus_width(host); in omap_hsmmc_context_restore()
778 omap_hsmmc_set_clock(host); in omap_hsmmc_context_restore()
780 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_context_restore()
783 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n", in omap_hsmmc_context_restore()
784 host->context_loss); in omap_hsmmc_context_restore()
791 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
793 host->con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_context_save()
794 host->hctl = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_context_save()
795 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_context_save()
796 host->capa = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_context_save()
801 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
806 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
816 static void send_init_stream(struct omap_hsmmc_host *host) in send_init_stream() argument
821 if (host->protect_card) in send_init_stream()
824 disable_irq(host->irq); in send_init_stream()
826 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK); in send_init_stream()
827 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
828 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM); in send_init_stream()
829 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); in send_init_stream()
833 reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN; in send_init_stream()
835 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
836 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); in send_init_stream()
838 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in send_init_stream()
839 OMAP_HSMMC_READ(host->base, STAT); in send_init_stream()
841 enable_irq(host->irq); in send_init_stream()
845 int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host) in omap_hsmmc_cover_is_closed() argument
849 if (host->get_cover_state) in omap_hsmmc_cover_is_closed()
850 r = host->get_cover_state(host->dev); in omap_hsmmc_cover_is_closed()
859 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_cover_switch() local
862 omap_hsmmc_cover_is_closed(host) ? "closed" : "open"); in omap_hsmmc_show_cover_switch()
872 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_slot_name() local
874 return sprintf(buf, "%s\n", mmc_pdata(host)->name); in omap_hsmmc_show_slot_name()
883 omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, in omap_hsmmc_start_command() argument
888 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n", in omap_hsmmc_start_command()
889 mmc_hostname(host->mmc), cmd->opcode, cmd->arg); in omap_hsmmc_start_command()
890 host->cmd = cmd; in omap_hsmmc_start_command()
892 omap_hsmmc_enable_irq(host, cmd); in omap_hsmmc_start_command()
894 host->response_busy = 0; in omap_hsmmc_start_command()
900 host->response_busy = 1; in omap_hsmmc_start_command()
910 if (cmd == host->mrq->stop) in omap_hsmmc_start_command()
915 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) && in omap_hsmmc_start_command()
916 host->mrq->sbc) { in omap_hsmmc_start_command()
918 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg); in omap_hsmmc_start_command()
928 if (host->use_dma) in omap_hsmmc_start_command()
931 host->req_in_progress = 1; in omap_hsmmc_start_command()
933 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg); in omap_hsmmc_start_command()
934 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg); in omap_hsmmc_start_command()
938 omap_hsmmc_get_dma_dir(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_get_dma_dir() argument
946 static struct dma_chan *omap_hsmmc_get_dma_chan(struct omap_hsmmc_host *host, in omap_hsmmc_get_dma_chan() argument
949 return data->flags & MMC_DATA_WRITE ? host->tx_chan : host->rx_chan; in omap_hsmmc_get_dma_chan()
952 static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq) in omap_hsmmc_request_done() argument
957 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_request_done()
958 host->req_in_progress = 0; in omap_hsmmc_request_done()
959 dma_ch = host->dma_ch; in omap_hsmmc_request_done()
960 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_request_done()
962 omap_hsmmc_disable_irq(host); in omap_hsmmc_request_done()
964 if (mrq->data && host->use_dma && dma_ch != -1) in omap_hsmmc_request_done()
966 host->mrq = NULL; in omap_hsmmc_request_done()
967 mmc_request_done(host->mmc, mrq); in omap_hsmmc_request_done()
968 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request_done()
969 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request_done()
976 omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_xfer_done() argument
979 struct mmc_request *mrq = host->mrq; in omap_hsmmc_xfer_done()
982 if (host->cmd && host->cmd->opcode == 6 && in omap_hsmmc_xfer_done()
983 host->response_busy) { in omap_hsmmc_xfer_done()
984 host->response_busy = 0; in omap_hsmmc_xfer_done()
988 omap_hsmmc_request_done(host, mrq); in omap_hsmmc_xfer_done()
992 host->data = NULL; in omap_hsmmc_xfer_done()
999 if (data->stop && (data->error || !host->mrq->sbc)) in omap_hsmmc_xfer_done()
1000 omap_hsmmc_start_command(host, data->stop, NULL); in omap_hsmmc_xfer_done()
1002 omap_hsmmc_request_done(host, data->mrq); in omap_hsmmc_xfer_done()
1009 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) in omap_hsmmc_cmd_done() argument
1011 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) && in omap_hsmmc_cmd_done()
1012 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_cmd_done()
1013 host->cmd = NULL; in omap_hsmmc_cmd_done()
1014 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_cmd_done()
1015 omap_hsmmc_start_command(host, host->mrq->cmd, in omap_hsmmc_cmd_done()
1016 host->mrq->data); in omap_hsmmc_cmd_done()
1020 host->cmd = NULL; in omap_hsmmc_cmd_done()
1025 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
1026 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32); in omap_hsmmc_cmd_done()
1027 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54); in omap_hsmmc_cmd_done()
1028 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76); in omap_hsmmc_cmd_done()
1031 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
1034 if ((host->data == NULL && !host->response_busy) || cmd->error) in omap_hsmmc_cmd_done()
1035 omap_hsmmc_request_done(host, host->mrq); in omap_hsmmc_cmd_done()
1041 static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) in omap_hsmmc_dma_cleanup() argument
1046 host->data->error = errno; in omap_hsmmc_dma_cleanup()
1048 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
1049 dma_ch = host->dma_ch; in omap_hsmmc_dma_cleanup()
1050 host->dma_ch = -1; in omap_hsmmc_dma_cleanup()
1051 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
1053 if (host->use_dma && dma_ch != -1) { in omap_hsmmc_dma_cleanup()
1054 struct dma_chan *chan = omap_hsmmc_get_dma_chan(host, host->data); in omap_hsmmc_dma_cleanup()
1058 host->data->sg, host->data->sg_len, in omap_hsmmc_dma_cleanup()
1059 omap_hsmmc_get_dma_dir(host, host->data)); in omap_hsmmc_dma_cleanup()
1061 host->data->host_cookie = 0; in omap_hsmmc_dma_cleanup()
1063 host->data = NULL; in omap_hsmmc_dma_cleanup()
1070 static void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, u32 status) in omap_hsmmc_dbg_report_irq() argument
1092 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in omap_hsmmc_dbg_report_irq()
1095 static inline void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, in omap_hsmmc_dbg_report_irq() argument
1108 static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, in omap_hsmmc_reset_controller_fsm() argument
1114 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_reset_controller_fsm()
1115 OMAP_HSMMC_READ(host->base, SYSCTL) | bit); in omap_hsmmc_reset_controller_fsm()
1121 if (mmc_pdata(host)->features & HSMMC_HAS_UPDATED_RESET) { in omap_hsmmc_reset_controller_fsm()
1122 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit)) in omap_hsmmc_reset_controller_fsm()
1128 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) && in omap_hsmmc_reset_controller_fsm()
1132 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit) in omap_hsmmc_reset_controller_fsm()
1133 dev_err(mmc_dev(host->mmc), in omap_hsmmc_reset_controller_fsm()
1138 static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, in hsmmc_command_incomplete() argument
1142 omap_hsmmc_reset_controller_fsm(host, SRC); in hsmmc_command_incomplete()
1143 if (host->cmd) in hsmmc_command_incomplete()
1144 host->cmd->error = err; in hsmmc_command_incomplete()
1147 if (host->data) { in hsmmc_command_incomplete()
1148 omap_hsmmc_reset_controller_fsm(host, SRD); in hsmmc_command_incomplete()
1149 omap_hsmmc_dma_cleanup(host, err); in hsmmc_command_incomplete()
1150 } else if (host->mrq && host->mrq->cmd) in hsmmc_command_incomplete()
1151 host->mrq->cmd->error = err; in hsmmc_command_incomplete()
1154 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) in omap_hsmmc_do_irq() argument
1160 data = host->data; in omap_hsmmc_do_irq()
1161 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); in omap_hsmmc_do_irq()
1164 omap_hsmmc_dbg_report_irq(host, status); in omap_hsmmc_do_irq()
1168 if (host->data || host->response_busy) { in omap_hsmmc_do_irq()
1170 host->response_busy = 0; in omap_hsmmc_do_irq()
1173 hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); in omap_hsmmc_do_irq()
1176 hsmmc_command_incomplete(host, -EILSEQ, end_cmd); in omap_hsmmc_do_irq()
1180 ac12 = OMAP_HSMMC_READ(host->base, AC12); in omap_hsmmc_do_irq()
1181 if (!(ac12 & ACNE) && host->mrq->sbc) { in omap_hsmmc_do_irq()
1187 host->mrq->sbc->error = error; in omap_hsmmc_do_irq()
1188 hsmmc_command_incomplete(host, error, end_cmd); in omap_hsmmc_do_irq()
1190 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12); in omap_hsmmc_do_irq()
1194 OMAP_HSMMC_WRITE(host->base, STAT, status); in omap_hsmmc_do_irq()
1195 if (end_cmd || ((status & CC_EN) && host->cmd)) in omap_hsmmc_do_irq()
1196 omap_hsmmc_cmd_done(host, host->cmd); in omap_hsmmc_do_irq()
1197 if ((end_trans || (status & TC_EN)) && host->mrq) in omap_hsmmc_do_irq()
1198 omap_hsmmc_xfer_done(host, data); in omap_hsmmc_do_irq()
1206 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_irq() local
1209 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1211 if (host->req_in_progress) in omap_hsmmc_irq()
1212 omap_hsmmc_do_irq(host, status); in omap_hsmmc_irq()
1215 mmc_signal_sdio_irq(host->mmc); in omap_hsmmc_irq()
1218 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1224 static void set_sd_bus_power(struct omap_hsmmc_host *host) in set_sd_bus_power() argument
1228 OMAP_HSMMC_WRITE(host->base, HCTL, in set_sd_bus_power()
1229 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in set_sd_bus_power()
1231 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP) in set_sd_bus_power()
1244 static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) in omap_hsmmc_switch_opcond() argument
1250 pm_runtime_put_sync(host->dev); in omap_hsmmc_switch_opcond()
1251 if (host->dbclk) in omap_hsmmc_switch_opcond()
1252 clk_disable_unprepare(host->dbclk); in omap_hsmmc_switch_opcond()
1255 ret = omap_hsmmc_set_power(host->dev, 0, 0); in omap_hsmmc_switch_opcond()
1259 ret = omap_hsmmc_set_power(host->dev, 1, vdd); in omap_hsmmc_switch_opcond()
1260 pm_runtime_get_sync(host->dev); in omap_hsmmc_switch_opcond()
1261 if (host->dbclk) in omap_hsmmc_switch_opcond()
1262 clk_prepare_enable(host->dbclk); in omap_hsmmc_switch_opcond()
1267 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_switch_opcond()
1268 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR); in omap_hsmmc_switch_opcond()
1269 reg_val = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_switch_opcond()
1291 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val); in omap_hsmmc_switch_opcond()
1292 set_sd_bus_power(host); in omap_hsmmc_switch_opcond()
1296 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); in omap_hsmmc_switch_opcond()
1301 static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) in omap_hsmmc_protect_card() argument
1303 if (!host->get_cover_state) in omap_hsmmc_protect_card()
1306 host->reqs_blocked = 0; in omap_hsmmc_protect_card()
1307 if (host->get_cover_state(host->dev)) { in omap_hsmmc_protect_card()
1308 if (host->protect_card) { in omap_hsmmc_protect_card()
1309 dev_info(host->dev, "%s: cover is closed, " in omap_hsmmc_protect_card()
1311 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1312 host->protect_card = 0; in omap_hsmmc_protect_card()
1315 if (!host->protect_card) { in omap_hsmmc_protect_card()
1316 dev_info(host->dev, "%s: cover is open, " in omap_hsmmc_protect_card()
1318 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1319 host->protect_card = 1; in omap_hsmmc_protect_card()
1329 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_cover_irq() local
1331 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); in omap_hsmmc_cover_irq()
1333 omap_hsmmc_protect_card(host); in omap_hsmmc_cover_irq()
1334 mmc_detect_change(host->mmc, (HZ * 200) / 1000); in omap_hsmmc_cover_irq()
1340 struct omap_hsmmc_host *host = param; in omap_hsmmc_dma_callback() local
1345 spin_lock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1346 if (host->dma_ch < 0) { in omap_hsmmc_dma_callback()
1347 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1351 data = host->mrq->data; in omap_hsmmc_dma_callback()
1352 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_dma_callback()
1356 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_dma_callback()
1358 req_in_progress = host->req_in_progress; in omap_hsmmc_dma_callback()
1359 host->dma_ch = -1; in omap_hsmmc_dma_callback()
1360 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1364 struct mmc_request *mrq = host->mrq; in omap_hsmmc_dma_callback()
1366 host->mrq = NULL; in omap_hsmmc_dma_callback()
1367 mmc_request_done(host->mmc, mrq); in omap_hsmmc_dma_callback()
1368 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_dma_callback()
1369 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_dma_callback()
1373 static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_pre_dma_transfer() argument
1381 data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1382 dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" in omap_hsmmc_pre_dma_transfer()
1384 __func__, data->host_cookie, host->next_data.cookie); in omap_hsmmc_pre_dma_transfer()
1389 if (next || data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1391 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_pre_dma_transfer()
1394 dma_len = host->next_data.dma_len; in omap_hsmmc_pre_dma_transfer()
1395 host->next_data.dma_len = 0; in omap_hsmmc_pre_dma_transfer()
1406 host->dma_len = dma_len; in omap_hsmmc_pre_dma_transfer()
1414 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_setup_dma_transfer() argument
1437 BUG_ON(host->dma_ch != -1); in omap_hsmmc_setup_dma_transfer()
1439 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_setup_dma_transfer()
1441 cfg.src_addr = host->mapbase + OMAP_HSMMC_DATA; in omap_hsmmc_setup_dma_transfer()
1442 cfg.dst_addr = host->mapbase + OMAP_HSMMC_DATA; in omap_hsmmc_setup_dma_transfer()
1452 ret = omap_hsmmc_pre_dma_transfer(host, data, NULL, chan); in omap_hsmmc_setup_dma_transfer()
1460 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n"); in omap_hsmmc_setup_dma_transfer()
1466 tx->callback_param = host; in omap_hsmmc_setup_dma_transfer()
1471 host->dma_ch = 1; in omap_hsmmc_setup_dma_transfer()
1476 static void set_data_timeout(struct omap_hsmmc_host *host, in set_data_timeout() argument
1483 reg = OMAP_HSMMC_READ(host->base, SYSCTL); in set_data_timeout()
1488 cycle_ns = 1000000000 / (host->clk_rate / clkd); in set_data_timeout()
1510 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg); in set_data_timeout()
1513 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host) in omap_hsmmc_start_dma_transfer() argument
1515 struct mmc_request *req = host->mrq; in omap_hsmmc_start_dma_transfer()
1520 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz) in omap_hsmmc_start_dma_transfer()
1522 set_data_timeout(host, req->data->timeout_ns, in omap_hsmmc_start_dma_transfer()
1524 chan = omap_hsmmc_get_dma_chan(host, req->data); in omap_hsmmc_start_dma_transfer()
1532 omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) in omap_hsmmc_prepare_data() argument
1535 host->data = req->data; in omap_hsmmc_prepare_data()
1538 OMAP_HSMMC_WRITE(host->base, BLK, 0); in omap_hsmmc_prepare_data()
1544 set_data_timeout(host, 100000000U, 0); in omap_hsmmc_prepare_data()
1548 if (host->use_dma) { in omap_hsmmc_prepare_data()
1549 ret = omap_hsmmc_setup_dma_transfer(host, req); in omap_hsmmc_prepare_data()
1551 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); in omap_hsmmc_prepare_data()
1561 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_post_req() local
1564 if (host->use_dma && data->host_cookie) { in omap_hsmmc_post_req()
1565 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_post_req()
1568 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_post_req()
1576 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_pre_req() local
1583 if (host->use_dma) { in omap_hsmmc_pre_req()
1584 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, mrq->data); in omap_hsmmc_pre_req()
1586 if (omap_hsmmc_pre_dma_transfer(host, mrq->data, in omap_hsmmc_pre_req()
1587 &host->next_data, c)) in omap_hsmmc_pre_req()
1597 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_request() local
1600 BUG_ON(host->req_in_progress); in omap_hsmmc_request()
1601 BUG_ON(host->dma_ch != -1); in omap_hsmmc_request()
1602 pm_runtime_get_sync(host->dev); in omap_hsmmc_request()
1603 if (host->protect_card) { in omap_hsmmc_request()
1604 if (host->reqs_blocked < 3) { in omap_hsmmc_request()
1610 omap_hsmmc_reset_controller_fsm(host, SRD); in omap_hsmmc_request()
1611 omap_hsmmc_reset_controller_fsm(host, SRC); in omap_hsmmc_request()
1612 host->reqs_blocked += 1; in omap_hsmmc_request()
1619 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request()
1620 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request()
1622 } else if (host->reqs_blocked) in omap_hsmmc_request()
1623 host->reqs_blocked = 0; in omap_hsmmc_request()
1624 WARN_ON(host->mrq != NULL); in omap_hsmmc_request()
1625 host->mrq = req; in omap_hsmmc_request()
1626 host->clk_rate = clk_get_rate(host->fclk); in omap_hsmmc_request()
1627 err = omap_hsmmc_prepare_data(host, req); in omap_hsmmc_request()
1632 host->mrq = NULL; in omap_hsmmc_request()
1634 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request()
1635 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request()
1638 if (req->sbc && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_request()
1639 omap_hsmmc_start_command(host, req->sbc, NULL); in omap_hsmmc_request()
1643 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_request()
1644 omap_hsmmc_start_command(host, req->cmd, req->data); in omap_hsmmc_request()
1650 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_set_ios() local
1653 pm_runtime_get_sync(host->dev); in omap_hsmmc_set_ios()
1655 if (ios->power_mode != host->power_mode) { in omap_hsmmc_set_ios()
1658 omap_hsmmc_set_power(host->dev, 0, 0); in omap_hsmmc_set_ios()
1661 omap_hsmmc_set_power(host->dev, 1, ios->vdd); in omap_hsmmc_set_ios()
1667 host->power_mode = ios->power_mode; in omap_hsmmc_set_ios()
1672 omap_hsmmc_set_bus_width(host); in omap_hsmmc_set_ios()
1674 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_set_ios()
1678 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && in omap_hsmmc_set_ios()
1686 if (omap_hsmmc_switch_opcond(host, ios->vdd) != 0) in omap_hsmmc_set_ios()
1687 dev_dbg(mmc_dev(host->mmc), in omap_hsmmc_set_ios()
1692 omap_hsmmc_set_clock(host); in omap_hsmmc_set_ios()
1695 send_init_stream(host); in omap_hsmmc_set_ios()
1697 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_set_ios()
1699 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_set_ios()
1704 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_get_cd() local
1706 if (!host->card_detect) in omap_hsmmc_get_cd()
1708 return host->card_detect(host->dev); in omap_hsmmc_get_cd()
1713 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_init_card() local
1715 if (mmc_pdata(host)->init_card) in omap_hsmmc_init_card()
1716 mmc_pdata(host)->init_card(card); in omap_hsmmc_init_card()
1721 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_sdio_irq() local
1725 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1727 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_enable_sdio_irq()
1728 irq_mask = OMAP_HSMMC_READ(host->base, ISE); in omap_hsmmc_enable_sdio_irq()
1730 host->flags |= HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1734 host->flags &= ~HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1738 OMAP_HSMMC_WRITE(host->base, CON, con); in omap_hsmmc_enable_sdio_irq()
1739 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1745 if (!host->req_in_progress || !enable) in omap_hsmmc_enable_sdio_irq()
1746 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1749 OMAP_HSMMC_READ(host->base, IE); in omap_hsmmc_enable_sdio_irq()
1751 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1754 static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host) in omap_hsmmc_configure_wake_irq() argument
1764 if (!host->dev->of_node || !host->wake_irq) in omap_hsmmc_configure_wake_irq()
1767 ret = dev_pm_set_dedicated_wake_irq(host->dev, host->wake_irq); in omap_hsmmc_configure_wake_irq()
1769 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); in omap_hsmmc_configure_wake_irq()
1777 if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) { in omap_hsmmc_configure_wake_irq()
1778 struct pinctrl *p = devm_pinctrl_get(host->dev); in omap_hsmmc_configure_wake_irq()
1784 dev_info(host->dev, "missing default pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1791 dev_info(host->dev, "missing idle pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1799 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_configure_wake_irq()
1800 OMAP_HSMMC_READ(host->base, HCTL) | IWE); in omap_hsmmc_configure_wake_irq()
1804 dev_pm_clear_wake_irq(host->dev); in omap_hsmmc_configure_wake_irq()
1806 dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n"); in omap_hsmmc_configure_wake_irq()
1807 host->wake_irq = 0; in omap_hsmmc_configure_wake_irq()
1811 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host) in omap_hsmmc_conf_bus_power() argument
1816 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_conf_bus_power()
1824 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK; in omap_hsmmc_conf_bus_power()
1825 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl); in omap_hsmmc_conf_bus_power()
1827 value = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_conf_bus_power()
1828 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa); in omap_hsmmc_conf_bus_power()
1831 set_sd_bus_power(host); in omap_hsmmc_conf_bus_power()
1860 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_regs_show() local
1868 (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled" in omap_hsmmc_regs_show()
1871 seq_printf(s, "ctx_loss:\t%d\n", host->context_loss); in omap_hsmmc_regs_show()
1873 pm_runtime_get_sync(host->dev); in omap_hsmmc_regs_show()
1876 OMAP_HSMMC_READ(host->base, CON)); in omap_hsmmc_regs_show()
1878 OMAP_HSMMC_READ(host->base, PSTATE)); in omap_hsmmc_regs_show()
1880 OMAP_HSMMC_READ(host->base, HCTL)); in omap_hsmmc_regs_show()
1882 OMAP_HSMMC_READ(host->base, SYSCTL)); in omap_hsmmc_regs_show()
1884 OMAP_HSMMC_READ(host->base, IE)); in omap_hsmmc_regs_show()
1886 OMAP_HSMMC_READ(host->base, ISE)); in omap_hsmmc_regs_show()
1888 OMAP_HSMMC_READ(host->base, CAPA)); in omap_hsmmc_regs_show()
1890 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_regs_show()
1891 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_regs_show()
2001 struct omap_hsmmc_host *host = NULL; in omap_hsmmc_probe() local
2048 host = mmc_priv(mmc); in omap_hsmmc_probe()
2049 host->mmc = mmc; in omap_hsmmc_probe()
2050 host->pdata = pdata; in omap_hsmmc_probe()
2051 host->dev = &pdev->dev; in omap_hsmmc_probe()
2052 host->use_dma = 1; in omap_hsmmc_probe()
2053 host->dma_ch = -1; in omap_hsmmc_probe()
2054 host->irq = irq; in omap_hsmmc_probe()
2055 host->mapbase = res->start + pdata->reg_offset; in omap_hsmmc_probe()
2056 host->base = base + pdata->reg_offset; in omap_hsmmc_probe()
2057 host->power_mode = MMC_POWER_OFF; in omap_hsmmc_probe()
2058 host->next_data.cookie = 1; in omap_hsmmc_probe()
2059 host->pbias_enabled = 0; in omap_hsmmc_probe()
2060 host->vqmmc_enabled = 0; in omap_hsmmc_probe()
2062 ret = omap_hsmmc_gpio_init(mmc, host, pdata); in omap_hsmmc_probe()
2066 platform_set_drvdata(pdev, host); in omap_hsmmc_probe()
2069 host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); in omap_hsmmc_probe()
2080 spin_lock_init(&host->irq_lock); in omap_hsmmc_probe()
2082 host->fclk = devm_clk_get(&pdev->dev, "fck"); in omap_hsmmc_probe()
2083 if (IS_ERR(host->fclk)) { in omap_hsmmc_probe()
2084 ret = PTR_ERR(host->fclk); in omap_hsmmc_probe()
2085 host->fclk = NULL; in omap_hsmmc_probe()
2089 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { in omap_hsmmc_probe()
2095 pm_runtime_enable(host->dev); in omap_hsmmc_probe()
2096 pm_runtime_get_sync(host->dev); in omap_hsmmc_probe()
2097 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); in omap_hsmmc_probe()
2098 pm_runtime_use_autosuspend(host->dev); in omap_hsmmc_probe()
2100 omap_hsmmc_context_save(host); in omap_hsmmc_probe()
2102 host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck"); in omap_hsmmc_probe()
2106 if (IS_ERR(host->dbclk)) { in omap_hsmmc_probe()
2107 host->dbclk = NULL; in omap_hsmmc_probe()
2108 } else if (clk_prepare_enable(host->dbclk) != 0) { in omap_hsmmc_probe()
2109 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); in omap_hsmmc_probe()
2110 host->dbclk = NULL; in omap_hsmmc_probe()
2125 mmc->caps |= mmc_pdata(host)->caps; in omap_hsmmc_probe()
2129 if (mmc_pdata(host)->nonremovable) in omap_hsmmc_probe()
2132 mmc->pm_caps |= mmc_pdata(host)->pm_caps; in omap_hsmmc_probe()
2134 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_probe()
2139 dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); in omap_hsmmc_probe()
2147 dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); in omap_hsmmc_probe()
2157 host->rx_chan = in omap_hsmmc_probe()
2161 if (!host->rx_chan) { in omap_hsmmc_probe()
2162 dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); in omap_hsmmc_probe()
2167 host->tx_chan = in omap_hsmmc_probe()
2171 if (!host->tx_chan) { in omap_hsmmc_probe()
2172 dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); in omap_hsmmc_probe()
2178 ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0, in omap_hsmmc_probe()
2179 mmc_hostname(mmc), host); in omap_hsmmc_probe()
2181 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); in omap_hsmmc_probe()
2185 ret = omap_hsmmc_reg_get(host); in omap_hsmmc_probe()
2189 mmc->ocr_avail = mmc_pdata(host)->ocr_mask; in omap_hsmmc_probe()
2191 omap_hsmmc_disable_irq(host); in omap_hsmmc_probe()
2201 ret = omap_hsmmc_configure_wake_irq(host); in omap_hsmmc_probe()
2205 omap_hsmmc_protect_card(host); in omap_hsmmc_probe()
2209 if (mmc_pdata(host)->name != NULL) { in omap_hsmmc_probe()
2214 if (host->get_cover_state) { in omap_hsmmc_probe()
2222 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_probe()
2223 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_probe()
2231 if (host->tx_chan) in omap_hsmmc_probe()
2232 dma_release_channel(host->tx_chan); in omap_hsmmc_probe()
2233 if (host->rx_chan) in omap_hsmmc_probe()
2234 dma_release_channel(host->rx_chan); in omap_hsmmc_probe()
2235 pm_runtime_put_sync(host->dev); in omap_hsmmc_probe()
2236 pm_runtime_disable(host->dev); in omap_hsmmc_probe()
2237 if (host->dbclk) in omap_hsmmc_probe()
2238 clk_disable_unprepare(host->dbclk); in omap_hsmmc_probe()
2248 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); in omap_hsmmc_remove() local
2250 pm_runtime_get_sync(host->dev); in omap_hsmmc_remove()
2251 mmc_remove_host(host->mmc); in omap_hsmmc_remove()
2253 if (host->tx_chan) in omap_hsmmc_remove()
2254 dma_release_channel(host->tx_chan); in omap_hsmmc_remove()
2255 if (host->rx_chan) in omap_hsmmc_remove()
2256 dma_release_channel(host->rx_chan); in omap_hsmmc_remove()
2258 pm_runtime_put_sync(host->dev); in omap_hsmmc_remove()
2259 pm_runtime_disable(host->dev); in omap_hsmmc_remove()
2261 if (host->dbclk) in omap_hsmmc_remove()
2262 clk_disable_unprepare(host->dbclk); in omap_hsmmc_remove()
2264 mmc_free_host(host->mmc); in omap_hsmmc_remove()
2272 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_suspend() local
2274 if (!host) in omap_hsmmc_suspend()
2277 pm_runtime_get_sync(host->dev); in omap_hsmmc_suspend()
2279 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { in omap_hsmmc_suspend()
2280 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_suspend()
2281 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_suspend()
2282 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_suspend()
2283 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_suspend()
2284 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); in omap_hsmmc_suspend()
2287 if (host->dbclk) in omap_hsmmc_suspend()
2288 clk_disable_unprepare(host->dbclk); in omap_hsmmc_suspend()
2290 pm_runtime_put_sync(host->dev); in omap_hsmmc_suspend()
2297 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_resume() local
2299 if (!host) in omap_hsmmc_resume()
2302 pm_runtime_get_sync(host->dev); in omap_hsmmc_resume()
2304 if (host->dbclk) in omap_hsmmc_resume()
2305 clk_prepare_enable(host->dbclk); in omap_hsmmc_resume()
2307 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) in omap_hsmmc_resume()
2308 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_resume()
2310 omap_hsmmc_protect_card(host); in omap_hsmmc_resume()
2311 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_resume()
2312 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_resume()
2319 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_suspend() local
2323 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_suspend()
2324 omap_hsmmc_context_save(host); in omap_hsmmc_runtime_suspend()
2327 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2328 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_suspend()
2329 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_suspend()
2331 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_runtime_suspend()
2332 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_runtime_suspend()
2334 if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) { in omap_hsmmc_runtime_suspend()
2341 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_suspend()
2342 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2343 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2355 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2361 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_resume() local
2364 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_resume()
2365 omap_hsmmc_context_restore(host); in omap_hsmmc_runtime_resume()
2368 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()
2369 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_resume()
2370 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_resume()
2372 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2375 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_resume()
2376 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2377 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2379 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2381 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()