Lines Matching refs:host
159 #define mmc_pdata(host) host->pdata argument
241 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
245 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_card_detect() local
247 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_card_detect()
252 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_get_cover_state() local
254 return mmc_gpio_get_cd(host->mmc); in omap_hsmmc_get_cover_state()
261 struct omap_hsmmc_host *host = in omap_hsmmc_set_power() local
269 if (!host->vcc) in omap_hsmmc_set_power()
272 if (mmc_pdata(host)->before_set_reg) in omap_hsmmc_set_power()
273 mmc_pdata(host)->before_set_reg(dev, power_on, vdd); in omap_hsmmc_set_power()
275 if (host->pbias) { in omap_hsmmc_set_power()
276 if (host->pbias_enabled == 1) { in omap_hsmmc_set_power()
277 ret = regulator_disable(host->pbias); in omap_hsmmc_set_power()
279 host->pbias_enabled = 0; in omap_hsmmc_set_power()
281 regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0); in omap_hsmmc_set_power()
298 if (host->vcc) in omap_hsmmc_set_power()
299 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); in omap_hsmmc_set_power()
301 if (ret == 0 && host->vcc_aux) { in omap_hsmmc_set_power()
302 ret = regulator_enable(host->vcc_aux); in omap_hsmmc_set_power()
303 if (ret < 0 && host->vcc) in omap_hsmmc_set_power()
304 ret = mmc_regulator_set_ocr(host->mmc, in omap_hsmmc_set_power()
305 host->vcc, 0); in omap_hsmmc_set_power()
309 if (host->vcc_aux) in omap_hsmmc_set_power()
310 ret = regulator_disable(host->vcc_aux); in omap_hsmmc_set_power()
311 if (host->vcc) { in omap_hsmmc_set_power()
313 ret = mmc_regulator_set_ocr(host->mmc, in omap_hsmmc_set_power()
314 host->vcc, 0); in omap_hsmmc_set_power()
318 if (host->pbias) { in omap_hsmmc_set_power()
320 ret = regulator_set_voltage(host->pbias, VDD_1V8, in omap_hsmmc_set_power()
323 ret = regulator_set_voltage(host->pbias, VDD_3V0, in omap_hsmmc_set_power()
328 if (host->pbias_enabled == 0) { in omap_hsmmc_set_power()
329 ret = regulator_enable(host->pbias); in omap_hsmmc_set_power()
331 host->pbias_enabled = 1; in omap_hsmmc_set_power()
335 if (mmc_pdata(host)->after_set_reg) in omap_hsmmc_set_power()
336 mmc_pdata(host)->after_set_reg(dev, power_on, vdd); in omap_hsmmc_set_power()
342 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) in omap_hsmmc_reg_get() argument
347 reg = devm_regulator_get(host->dev, "vmmc"); in omap_hsmmc_reg_get()
349 dev_err(host->dev, "unable to get vmmc regulator %ld\n", in omap_hsmmc_reg_get()
353 host->vcc = reg; in omap_hsmmc_reg_get()
355 if (!mmc_pdata(host)->ocr_mask) { in omap_hsmmc_reg_get()
356 mmc_pdata(host)->ocr_mask = ocr_value; in omap_hsmmc_reg_get()
358 if (!(mmc_pdata(host)->ocr_mask & ocr_value)) { in omap_hsmmc_reg_get()
359 dev_err(host->dev, "ocrmask %x is not supported\n", in omap_hsmmc_reg_get()
360 mmc_pdata(host)->ocr_mask); in omap_hsmmc_reg_get()
361 mmc_pdata(host)->ocr_mask = 0; in omap_hsmmc_reg_get()
366 mmc_pdata(host)->set_power = omap_hsmmc_set_power; in omap_hsmmc_reg_get()
369 reg = devm_regulator_get_optional(host->dev, "vmmc_aux"); in omap_hsmmc_reg_get()
370 host->vcc_aux = IS_ERR(reg) ? NULL : reg; in omap_hsmmc_reg_get()
372 reg = devm_regulator_get_optional(host->dev, "pbias"); in omap_hsmmc_reg_get()
373 host->pbias = IS_ERR(reg) ? NULL : reg; in omap_hsmmc_reg_get()
376 if (mmc_pdata(host)->no_regulator_off_init) in omap_hsmmc_reg_get()
382 if ((host->vcc && regulator_is_enabled(host->vcc) > 0) || in omap_hsmmc_reg_get()
383 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) { in omap_hsmmc_reg_get()
384 int vdd = ffs(mmc_pdata(host)->ocr_mask) - 1; in omap_hsmmc_reg_get()
386 mmc_pdata(host)->set_power(host->dev, 1, vdd); in omap_hsmmc_reg_get()
387 mmc_pdata(host)->set_power(host->dev, 0, 0); in omap_hsmmc_reg_get()
393 static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) in omap_hsmmc_reg_put() argument
395 mmc_pdata(host)->set_power = NULL; in omap_hsmmc_reg_put()
405 static inline int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) in omap_hsmmc_reg_get() argument
410 static inline void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) in omap_hsmmc_reg_put() argument
424 struct omap_hsmmc_host *host, in omap_hsmmc_gpio_init() argument
434 host->get_cover_state = omap_hsmmc_get_cover_state; in omap_hsmmc_gpio_init()
441 host->card_detect = omap_hsmmc_card_detect; in omap_hsmmc_gpio_init()
456 static void omap_hsmmc_start_clock(struct omap_hsmmc_host *host) in omap_hsmmc_start_clock() argument
458 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_start_clock()
459 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN); in omap_hsmmc_start_clock()
465 static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host) in omap_hsmmc_stop_clock() argument
467 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_stop_clock()
468 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN); in omap_hsmmc_stop_clock()
469 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0) in omap_hsmmc_stop_clock()
470 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n"); in omap_hsmmc_stop_clock()
473 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, in omap_hsmmc_enable_irq() argument
479 if (host->use_dma) in omap_hsmmc_enable_irq()
486 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
487 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_enable_irq()
488 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_irq()
491 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_enable_irq()
493 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_irq()
494 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_irq()
497 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host) in omap_hsmmc_disable_irq() argument
502 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
504 if (host->flags & HSMMC_SDIO_IRQ_ENABLED) in omap_hsmmc_disable_irq()
506 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_disable_irq()
507 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_disable_irq()
508 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_disable_irq()
509 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_disable_irq()
513 static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios) in calc_divisor() argument
518 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock); in calc_divisor()
526 static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host) in omap_hsmmc_set_clock() argument
528 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_clock()
533 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock); in omap_hsmmc_set_clock()
535 omap_hsmmc_stop_clock(host); in omap_hsmmc_set_clock()
537 regval = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_set_clock()
539 clkdiv = calc_divisor(host, ios); in omap_hsmmc_set_clock()
541 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval); in omap_hsmmc_set_clock()
542 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_set_clock()
543 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE); in omap_hsmmc_set_clock()
547 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS in omap_hsmmc_set_clock()
560 if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) && in omap_hsmmc_set_clock()
563 ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) { in omap_hsmmc_set_clock()
564 regval = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_set_clock()
565 if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000) in omap_hsmmc_set_clock()
570 OMAP_HSMMC_WRITE(host->base, HCTL, regval); in omap_hsmmc_set_clock()
573 omap_hsmmc_start_clock(host); in omap_hsmmc_set_clock()
576 static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_width() argument
578 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_width()
581 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_width()
589 OMAP_HSMMC_WRITE(host->base, CON, con | DW8); in omap_hsmmc_set_bus_width()
592 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
593 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
594 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT); in omap_hsmmc_set_bus_width()
597 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8); in omap_hsmmc_set_bus_width()
598 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_set_bus_width()
599 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT); in omap_hsmmc_set_bus_width()
604 static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host) in omap_hsmmc_set_bus_mode() argument
606 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_set_bus_mode()
609 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_set_bus_mode()
611 OMAP_HSMMC_WRITE(host->base, CON, con | OD); in omap_hsmmc_set_bus_mode()
613 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD); in omap_hsmmc_set_bus_mode()
622 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
624 struct mmc_ios *ios = &host->mmc->ios; in omap_hsmmc_context_restore()
628 if (host->con == OMAP_HSMMC_READ(host->base, CON) && in omap_hsmmc_context_restore()
629 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) && in omap_hsmmc_context_restore()
630 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) && in omap_hsmmc_context_restore()
631 host->capa == OMAP_HSMMC_READ(host->base, CAPA)) in omap_hsmmc_context_restore()
634 host->context_loss++; in omap_hsmmc_context_restore()
636 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_context_restore()
637 if (host->power_mode != MMC_POWER_OFF && in omap_hsmmc_context_restore()
648 if (host->mmc->caps & MMC_CAP_SDIO_IRQ) in omap_hsmmc_context_restore()
651 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
652 OMAP_HSMMC_READ(host->base, HCTL) | hctl); in omap_hsmmc_context_restore()
654 OMAP_HSMMC_WRITE(host->base, CAPA, in omap_hsmmc_context_restore()
655 OMAP_HSMMC_READ(host->base, CAPA) | capa); in omap_hsmmc_context_restore()
657 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_context_restore()
658 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in omap_hsmmc_context_restore()
661 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP in omap_hsmmc_context_restore()
665 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_context_restore()
666 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_context_restore()
667 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_context_restore()
670 if (host->power_mode == MMC_POWER_OFF) in omap_hsmmc_context_restore()
673 omap_hsmmc_set_bus_width(host); in omap_hsmmc_context_restore()
675 omap_hsmmc_set_clock(host); in omap_hsmmc_context_restore()
677 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_context_restore()
680 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n", in omap_hsmmc_context_restore()
681 host->context_loss); in omap_hsmmc_context_restore()
688 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
690 host->con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_context_save()
691 host->hctl = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_context_save()
692 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL); in omap_hsmmc_context_save()
693 host->capa = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_context_save()
698 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) in omap_hsmmc_context_restore() argument
703 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host) in omap_hsmmc_context_save() argument
713 static void send_init_stream(struct omap_hsmmc_host *host) in send_init_stream() argument
718 if (host->protect_card) in send_init_stream()
721 disable_irq(host->irq); in send_init_stream()
723 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK); in send_init_stream()
724 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
725 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM); in send_init_stream()
726 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD); in send_init_stream()
730 reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN; in send_init_stream()
732 OMAP_HSMMC_WRITE(host->base, CON, in send_init_stream()
733 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM); in send_init_stream()
735 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in send_init_stream()
736 OMAP_HSMMC_READ(host->base, STAT); in send_init_stream()
738 enable_irq(host->irq); in send_init_stream()
742 int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host) in omap_hsmmc_cover_is_closed() argument
746 if (host->get_cover_state) in omap_hsmmc_cover_is_closed()
747 r = host->get_cover_state(host->dev); in omap_hsmmc_cover_is_closed()
756 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_cover_switch() local
759 omap_hsmmc_cover_is_closed(host) ? "closed" : "open"); in omap_hsmmc_show_cover_switch()
769 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_show_slot_name() local
771 return sprintf(buf, "%s\n", mmc_pdata(host)->name); in omap_hsmmc_show_slot_name()
780 omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, in omap_hsmmc_start_command() argument
785 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n", in omap_hsmmc_start_command()
786 mmc_hostname(host->mmc), cmd->opcode, cmd->arg); in omap_hsmmc_start_command()
787 host->cmd = cmd; in omap_hsmmc_start_command()
789 omap_hsmmc_enable_irq(host, cmd); in omap_hsmmc_start_command()
791 host->response_busy = 0; in omap_hsmmc_start_command()
797 host->response_busy = 1; in omap_hsmmc_start_command()
807 if (cmd == host->mrq->stop) in omap_hsmmc_start_command()
812 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) && in omap_hsmmc_start_command()
813 host->mrq->sbc) { in omap_hsmmc_start_command()
815 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg); in omap_hsmmc_start_command()
825 if (host->use_dma) in omap_hsmmc_start_command()
828 host->req_in_progress = 1; in omap_hsmmc_start_command()
830 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg); in omap_hsmmc_start_command()
831 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg); in omap_hsmmc_start_command()
835 omap_hsmmc_get_dma_dir(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_get_dma_dir() argument
843 static struct dma_chan *omap_hsmmc_get_dma_chan(struct omap_hsmmc_host *host, in omap_hsmmc_get_dma_chan() argument
846 return data->flags & MMC_DATA_WRITE ? host->tx_chan : host->rx_chan; in omap_hsmmc_get_dma_chan()
849 static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq) in omap_hsmmc_request_done() argument
854 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_request_done()
855 host->req_in_progress = 0; in omap_hsmmc_request_done()
856 dma_ch = host->dma_ch; in omap_hsmmc_request_done()
857 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_request_done()
859 omap_hsmmc_disable_irq(host); in omap_hsmmc_request_done()
861 if (mrq->data && host->use_dma && dma_ch != -1) in omap_hsmmc_request_done()
863 host->mrq = NULL; in omap_hsmmc_request_done()
864 mmc_request_done(host->mmc, mrq); in omap_hsmmc_request_done()
865 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request_done()
866 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request_done()
873 omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data) in omap_hsmmc_xfer_done() argument
876 struct mmc_request *mrq = host->mrq; in omap_hsmmc_xfer_done()
879 if (host->cmd && host->cmd->opcode == 6 && in omap_hsmmc_xfer_done()
880 host->response_busy) { in omap_hsmmc_xfer_done()
881 host->response_busy = 0; in omap_hsmmc_xfer_done()
885 omap_hsmmc_request_done(host, mrq); in omap_hsmmc_xfer_done()
889 host->data = NULL; in omap_hsmmc_xfer_done()
896 if (data->stop && (data->error || !host->mrq->sbc)) in omap_hsmmc_xfer_done()
897 omap_hsmmc_start_command(host, data->stop, NULL); in omap_hsmmc_xfer_done()
899 omap_hsmmc_request_done(host, data->mrq); in omap_hsmmc_xfer_done()
906 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) in omap_hsmmc_cmd_done() argument
908 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) && in omap_hsmmc_cmd_done()
909 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_cmd_done()
910 host->cmd = NULL; in omap_hsmmc_cmd_done()
911 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_cmd_done()
912 omap_hsmmc_start_command(host, host->mrq->cmd, in omap_hsmmc_cmd_done()
913 host->mrq->data); in omap_hsmmc_cmd_done()
917 host->cmd = NULL; in omap_hsmmc_cmd_done()
922 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
923 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32); in omap_hsmmc_cmd_done()
924 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54); in omap_hsmmc_cmd_done()
925 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76); in omap_hsmmc_cmd_done()
928 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10); in omap_hsmmc_cmd_done()
931 if ((host->data == NULL && !host->response_busy) || cmd->error) in omap_hsmmc_cmd_done()
932 omap_hsmmc_request_done(host, host->mrq); in omap_hsmmc_cmd_done()
938 static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) in omap_hsmmc_dma_cleanup() argument
943 host->data->error = errno; in omap_hsmmc_dma_cleanup()
945 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
946 dma_ch = host->dma_ch; in omap_hsmmc_dma_cleanup()
947 host->dma_ch = -1; in omap_hsmmc_dma_cleanup()
948 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_dma_cleanup()
950 if (host->use_dma && dma_ch != -1) { in omap_hsmmc_dma_cleanup()
951 struct dma_chan *chan = omap_hsmmc_get_dma_chan(host, host->data); in omap_hsmmc_dma_cleanup()
955 host->data->sg, host->data->sg_len, in omap_hsmmc_dma_cleanup()
956 omap_hsmmc_get_dma_dir(host, host->data)); in omap_hsmmc_dma_cleanup()
958 host->data->host_cookie = 0; in omap_hsmmc_dma_cleanup()
960 host->data = NULL; in omap_hsmmc_dma_cleanup()
967 static void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, u32 status) in omap_hsmmc_dbg_report_irq() argument
989 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in omap_hsmmc_dbg_report_irq()
992 static inline void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, in omap_hsmmc_dbg_report_irq() argument
1005 static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, in omap_hsmmc_reset_controller_fsm() argument
1011 OMAP_HSMMC_WRITE(host->base, SYSCTL, in omap_hsmmc_reset_controller_fsm()
1012 OMAP_HSMMC_READ(host->base, SYSCTL) | bit); in omap_hsmmc_reset_controller_fsm()
1018 if (mmc_pdata(host)->features & HSMMC_HAS_UPDATED_RESET) { in omap_hsmmc_reset_controller_fsm()
1019 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit)) in omap_hsmmc_reset_controller_fsm()
1025 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) && in omap_hsmmc_reset_controller_fsm()
1029 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit) in omap_hsmmc_reset_controller_fsm()
1030 dev_err(mmc_dev(host->mmc), in omap_hsmmc_reset_controller_fsm()
1035 static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, in hsmmc_command_incomplete() argument
1039 omap_hsmmc_reset_controller_fsm(host, SRC); in hsmmc_command_incomplete()
1040 if (host->cmd) in hsmmc_command_incomplete()
1041 host->cmd->error = err; in hsmmc_command_incomplete()
1044 if (host->data) { in hsmmc_command_incomplete()
1045 omap_hsmmc_reset_controller_fsm(host, SRD); in hsmmc_command_incomplete()
1046 omap_hsmmc_dma_cleanup(host, err); in hsmmc_command_incomplete()
1047 } else if (host->mrq && host->mrq->cmd) in hsmmc_command_incomplete()
1048 host->mrq->cmd->error = err; in hsmmc_command_incomplete()
1051 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) in omap_hsmmc_do_irq() argument
1057 data = host->data; in omap_hsmmc_do_irq()
1058 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); in omap_hsmmc_do_irq()
1061 omap_hsmmc_dbg_report_irq(host, status); in omap_hsmmc_do_irq()
1065 if (host->data || host->response_busy) { in omap_hsmmc_do_irq()
1067 host->response_busy = 0; in omap_hsmmc_do_irq()
1070 hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd); in omap_hsmmc_do_irq()
1072 hsmmc_command_incomplete(host, -EILSEQ, end_cmd); in omap_hsmmc_do_irq()
1076 ac12 = OMAP_HSMMC_READ(host->base, AC12); in omap_hsmmc_do_irq()
1077 if (!(ac12 & ACNE) && host->mrq->sbc) { in omap_hsmmc_do_irq()
1083 host->mrq->sbc->error = error; in omap_hsmmc_do_irq()
1084 hsmmc_command_incomplete(host, error, end_cmd); in omap_hsmmc_do_irq()
1086 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12); in omap_hsmmc_do_irq()
1090 OMAP_HSMMC_WRITE(host->base, STAT, status); in omap_hsmmc_do_irq()
1091 if (end_cmd || ((status & CC_EN) && host->cmd)) in omap_hsmmc_do_irq()
1092 omap_hsmmc_cmd_done(host, host->cmd); in omap_hsmmc_do_irq()
1093 if ((end_trans || (status & TC_EN)) && host->mrq) in omap_hsmmc_do_irq()
1094 omap_hsmmc_xfer_done(host, data); in omap_hsmmc_do_irq()
1102 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_irq() local
1105 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1107 if (host->req_in_progress) in omap_hsmmc_irq()
1108 omap_hsmmc_do_irq(host, status); in omap_hsmmc_irq()
1111 mmc_signal_sdio_irq(host->mmc); in omap_hsmmc_irq()
1114 status = OMAP_HSMMC_READ(host->base, STAT); in omap_hsmmc_irq()
1122 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_wake_irq() local
1125 spin_lock(&host->irq_lock); in omap_hsmmc_wake_irq()
1126 if (host->flags & HSMMC_WAKE_IRQ_ENABLED) { in omap_hsmmc_wake_irq()
1127 disable_irq_nosync(host->wake_irq); in omap_hsmmc_wake_irq()
1128 host->flags &= ~HSMMC_WAKE_IRQ_ENABLED; in omap_hsmmc_wake_irq()
1130 spin_unlock(&host->irq_lock); in omap_hsmmc_wake_irq()
1131 pm_request_resume(host->dev); /* no use counter */ in omap_hsmmc_wake_irq()
1136 static void set_sd_bus_power(struct omap_hsmmc_host *host) in set_sd_bus_power() argument
1140 OMAP_HSMMC_WRITE(host->base, HCTL, in set_sd_bus_power()
1141 OMAP_HSMMC_READ(host->base, HCTL) | SDBP); in set_sd_bus_power()
1143 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP) in set_sd_bus_power()
1156 static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd) in omap_hsmmc_switch_opcond() argument
1162 pm_runtime_put_sync(host->dev); in omap_hsmmc_switch_opcond()
1163 if (host->dbclk) in omap_hsmmc_switch_opcond()
1164 clk_disable_unprepare(host->dbclk); in omap_hsmmc_switch_opcond()
1167 ret = mmc_pdata(host)->set_power(host->dev, 0, 0); in omap_hsmmc_switch_opcond()
1171 ret = mmc_pdata(host)->set_power(host->dev, 1, vdd); in omap_hsmmc_switch_opcond()
1172 pm_runtime_get_sync(host->dev); in omap_hsmmc_switch_opcond()
1173 if (host->dbclk) in omap_hsmmc_switch_opcond()
1174 clk_prepare_enable(host->dbclk); in omap_hsmmc_switch_opcond()
1179 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_switch_opcond()
1180 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR); in omap_hsmmc_switch_opcond()
1181 reg_val = OMAP_HSMMC_READ(host->base, HCTL); in omap_hsmmc_switch_opcond()
1203 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val); in omap_hsmmc_switch_opcond()
1204 set_sd_bus_power(host); in omap_hsmmc_switch_opcond()
1208 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n"); in omap_hsmmc_switch_opcond()
1213 static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) in omap_hsmmc_protect_card() argument
1215 if (!host->get_cover_state) in omap_hsmmc_protect_card()
1218 host->reqs_blocked = 0; in omap_hsmmc_protect_card()
1219 if (host->get_cover_state(host->dev)) { in omap_hsmmc_protect_card()
1220 if (host->protect_card) { in omap_hsmmc_protect_card()
1221 dev_info(host->dev, "%s: cover is closed, " in omap_hsmmc_protect_card()
1223 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1224 host->protect_card = 0; in omap_hsmmc_protect_card()
1227 if (!host->protect_card) { in omap_hsmmc_protect_card()
1228 dev_info(host->dev, "%s: cover is open, " in omap_hsmmc_protect_card()
1230 mmc_hostname(host->mmc)); in omap_hsmmc_protect_card()
1231 host->protect_card = 1; in omap_hsmmc_protect_card()
1241 struct omap_hsmmc_host *host = dev_id; in omap_hsmmc_cover_irq() local
1243 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); in omap_hsmmc_cover_irq()
1245 omap_hsmmc_protect_card(host); in omap_hsmmc_cover_irq()
1246 mmc_detect_change(host->mmc, (HZ * 200) / 1000); in omap_hsmmc_cover_irq()
1252 struct omap_hsmmc_host *host = param; in omap_hsmmc_dma_callback() local
1257 spin_lock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1258 if (host->dma_ch < 0) { in omap_hsmmc_dma_callback()
1259 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1263 data = host->mrq->data; in omap_hsmmc_dma_callback()
1264 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_dma_callback()
1268 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_dma_callback()
1270 req_in_progress = host->req_in_progress; in omap_hsmmc_dma_callback()
1271 host->dma_ch = -1; in omap_hsmmc_dma_callback()
1272 spin_unlock_irq(&host->irq_lock); in omap_hsmmc_dma_callback()
1276 struct mmc_request *mrq = host->mrq; in omap_hsmmc_dma_callback()
1278 host->mrq = NULL; in omap_hsmmc_dma_callback()
1279 mmc_request_done(host->mmc, mrq); in omap_hsmmc_dma_callback()
1280 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_dma_callback()
1281 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_dma_callback()
1285 static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_pre_dma_transfer() argument
1293 data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1294 dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" in omap_hsmmc_pre_dma_transfer()
1296 __func__, data->host_cookie, host->next_data.cookie); in omap_hsmmc_pre_dma_transfer()
1301 if (next || data->host_cookie != host->next_data.cookie) { in omap_hsmmc_pre_dma_transfer()
1303 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_pre_dma_transfer()
1306 dma_len = host->next_data.dma_len; in omap_hsmmc_pre_dma_transfer()
1307 host->next_data.dma_len = 0; in omap_hsmmc_pre_dma_transfer()
1318 host->dma_len = dma_len; in omap_hsmmc_pre_dma_transfer()
1326 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host, in omap_hsmmc_setup_dma_transfer() argument
1349 BUG_ON(host->dma_ch != -1); in omap_hsmmc_setup_dma_transfer()
1351 chan = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_setup_dma_transfer()
1353 cfg.src_addr = host->mapbase + OMAP_HSMMC_DATA; in omap_hsmmc_setup_dma_transfer()
1354 cfg.dst_addr = host->mapbase + OMAP_HSMMC_DATA; in omap_hsmmc_setup_dma_transfer()
1364 ret = omap_hsmmc_pre_dma_transfer(host, data, NULL, chan); in omap_hsmmc_setup_dma_transfer()
1372 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n"); in omap_hsmmc_setup_dma_transfer()
1378 tx->callback_param = host; in omap_hsmmc_setup_dma_transfer()
1383 host->dma_ch = 1; in omap_hsmmc_setup_dma_transfer()
1388 static void set_data_timeout(struct omap_hsmmc_host *host, in set_data_timeout() argument
1395 reg = OMAP_HSMMC_READ(host->base, SYSCTL); in set_data_timeout()
1400 cycle_ns = 1000000000 / (host->clk_rate / clkd); in set_data_timeout()
1422 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg); in set_data_timeout()
1425 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host) in omap_hsmmc_start_dma_transfer() argument
1427 struct mmc_request *req = host->mrq; in omap_hsmmc_start_dma_transfer()
1432 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz) in omap_hsmmc_start_dma_transfer()
1434 set_data_timeout(host, req->data->timeout_ns, in omap_hsmmc_start_dma_transfer()
1436 chan = omap_hsmmc_get_dma_chan(host, req->data); in omap_hsmmc_start_dma_transfer()
1444 omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) in omap_hsmmc_prepare_data() argument
1447 host->data = req->data; in omap_hsmmc_prepare_data()
1450 OMAP_HSMMC_WRITE(host->base, BLK, 0); in omap_hsmmc_prepare_data()
1456 set_data_timeout(host, 100000000U, 0); in omap_hsmmc_prepare_data()
1460 if (host->use_dma) { in omap_hsmmc_prepare_data()
1461 ret = omap_hsmmc_setup_dma_transfer(host, req); in omap_hsmmc_prepare_data()
1463 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); in omap_hsmmc_prepare_data()
1473 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_post_req() local
1476 if (host->use_dma && data->host_cookie) { in omap_hsmmc_post_req()
1477 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, data); in omap_hsmmc_post_req()
1480 omap_hsmmc_get_dma_dir(host, data)); in omap_hsmmc_post_req()
1488 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_pre_req() local
1495 if (host->use_dma) { in omap_hsmmc_pre_req()
1496 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, mrq->data); in omap_hsmmc_pre_req()
1498 if (omap_hsmmc_pre_dma_transfer(host, mrq->data, in omap_hsmmc_pre_req()
1499 &host->next_data, c)) in omap_hsmmc_pre_req()
1509 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_request() local
1512 BUG_ON(host->req_in_progress); in omap_hsmmc_request()
1513 BUG_ON(host->dma_ch != -1); in omap_hsmmc_request()
1514 pm_runtime_get_sync(host->dev); in omap_hsmmc_request()
1515 if (host->protect_card) { in omap_hsmmc_request()
1516 if (host->reqs_blocked < 3) { in omap_hsmmc_request()
1522 omap_hsmmc_reset_controller_fsm(host, SRD); in omap_hsmmc_request()
1523 omap_hsmmc_reset_controller_fsm(host, SRC); in omap_hsmmc_request()
1524 host->reqs_blocked += 1; in omap_hsmmc_request()
1531 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request()
1532 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request()
1534 } else if (host->reqs_blocked) in omap_hsmmc_request()
1535 host->reqs_blocked = 0; in omap_hsmmc_request()
1536 WARN_ON(host->mrq != NULL); in omap_hsmmc_request()
1537 host->mrq = req; in omap_hsmmc_request()
1538 host->clk_rate = clk_get_rate(host->fclk); in omap_hsmmc_request()
1539 err = omap_hsmmc_prepare_data(host, req); in omap_hsmmc_request()
1544 host->mrq = NULL; in omap_hsmmc_request()
1546 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_request()
1547 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_request()
1550 if (req->sbc && !(host->flags & AUTO_CMD23)) { in omap_hsmmc_request()
1551 omap_hsmmc_start_command(host, req->sbc, NULL); in omap_hsmmc_request()
1555 omap_hsmmc_start_dma_transfer(host); in omap_hsmmc_request()
1556 omap_hsmmc_start_command(host, req->cmd, req->data); in omap_hsmmc_request()
1562 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_set_ios() local
1565 pm_runtime_get_sync(host->dev); in omap_hsmmc_set_ios()
1567 if (ios->power_mode != host->power_mode) { in omap_hsmmc_set_ios()
1570 mmc_pdata(host)->set_power(host->dev, 0, 0); in omap_hsmmc_set_ios()
1573 mmc_pdata(host)->set_power(host->dev, 1, ios->vdd); in omap_hsmmc_set_ios()
1579 host->power_mode = ios->power_mode; in omap_hsmmc_set_ios()
1584 omap_hsmmc_set_bus_width(host); in omap_hsmmc_set_ios()
1586 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_set_ios()
1590 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && in omap_hsmmc_set_ios()
1598 if (omap_hsmmc_switch_opcond(host, ios->vdd) != 0) in omap_hsmmc_set_ios()
1599 dev_dbg(mmc_dev(host->mmc), in omap_hsmmc_set_ios()
1604 omap_hsmmc_set_clock(host); in omap_hsmmc_set_ios()
1607 send_init_stream(host); in omap_hsmmc_set_ios()
1609 omap_hsmmc_set_bus_mode(host); in omap_hsmmc_set_ios()
1611 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_set_ios()
1616 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_get_cd() local
1618 if (!host->card_detect) in omap_hsmmc_get_cd()
1620 return host->card_detect(host->dev); in omap_hsmmc_get_cd()
1625 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_init_card() local
1627 if (mmc_pdata(host)->init_card) in omap_hsmmc_init_card()
1628 mmc_pdata(host)->init_card(card); in omap_hsmmc_init_card()
1633 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_enable_sdio_irq() local
1637 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1639 con = OMAP_HSMMC_READ(host->base, CON); in omap_hsmmc_enable_sdio_irq()
1640 irq_mask = OMAP_HSMMC_READ(host->base, ISE); in omap_hsmmc_enable_sdio_irq()
1642 host->flags |= HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1646 host->flags &= ~HSMMC_SDIO_IRQ_ENABLED; in omap_hsmmc_enable_sdio_irq()
1650 OMAP_HSMMC_WRITE(host->base, CON, con); in omap_hsmmc_enable_sdio_irq()
1651 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1657 if (!host->req_in_progress || !enable) in omap_hsmmc_enable_sdio_irq()
1658 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); in omap_hsmmc_enable_sdio_irq()
1661 OMAP_HSMMC_READ(host->base, IE); in omap_hsmmc_enable_sdio_irq()
1663 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_enable_sdio_irq()
1666 static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host) in omap_hsmmc_configure_wake_irq() argument
1668 struct mmc_host *mmc = host->mmc; in omap_hsmmc_configure_wake_irq()
1677 if (!host->dev->of_node || !host->wake_irq) in omap_hsmmc_configure_wake_irq()
1681 irq_set_status_flags(host->wake_irq, IRQ_NOAUTOEN); in omap_hsmmc_configure_wake_irq()
1682 ret = devm_request_irq(host->dev, host->wake_irq, omap_hsmmc_wake_irq, in omap_hsmmc_configure_wake_irq()
1684 mmc_hostname(mmc), host); in omap_hsmmc_configure_wake_irq()
1686 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); in omap_hsmmc_configure_wake_irq()
1694 if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) { in omap_hsmmc_configure_wake_irq()
1695 struct pinctrl *p = devm_pinctrl_get(host->dev); in omap_hsmmc_configure_wake_irq()
1701 dev_info(host->dev, "missing default pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1708 dev_info(host->dev, "missing idle pinctrl state\n"); in omap_hsmmc_configure_wake_irq()
1716 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_configure_wake_irq()
1717 OMAP_HSMMC_READ(host->base, HCTL) | IWE); in omap_hsmmc_configure_wake_irq()
1721 devm_free_irq(host->dev, host->wake_irq, host); in omap_hsmmc_configure_wake_irq()
1723 dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n"); in omap_hsmmc_configure_wake_irq()
1724 host->wake_irq = 0; in omap_hsmmc_configure_wake_irq()
1728 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host) in omap_hsmmc_conf_bus_power() argument
1733 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { in omap_hsmmc_conf_bus_power()
1741 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK; in omap_hsmmc_conf_bus_power()
1742 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl); in omap_hsmmc_conf_bus_power()
1744 value = OMAP_HSMMC_READ(host->base, CAPA); in omap_hsmmc_conf_bus_power()
1745 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa); in omap_hsmmc_conf_bus_power()
1748 set_sd_bus_power(host); in omap_hsmmc_conf_bus_power()
1777 struct omap_hsmmc_host *host = mmc_priv(mmc); in omap_hsmmc_regs_show() local
1785 (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled" in omap_hsmmc_regs_show()
1788 seq_printf(s, "ctx_loss:\t%d\n", host->context_loss); in omap_hsmmc_regs_show()
1790 pm_runtime_get_sync(host->dev); in omap_hsmmc_regs_show()
1793 OMAP_HSMMC_READ(host->base, CON)); in omap_hsmmc_regs_show()
1795 OMAP_HSMMC_READ(host->base, PSTATE)); in omap_hsmmc_regs_show()
1797 OMAP_HSMMC_READ(host->base, HCTL)); in omap_hsmmc_regs_show()
1799 OMAP_HSMMC_READ(host->base, SYSCTL)); in omap_hsmmc_regs_show()
1801 OMAP_HSMMC_READ(host->base, IE)); in omap_hsmmc_regs_show()
1803 OMAP_HSMMC_READ(host->base, ISE)); in omap_hsmmc_regs_show()
1805 OMAP_HSMMC_READ(host->base, CAPA)); in omap_hsmmc_regs_show()
1807 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_regs_show()
1808 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_regs_show()
1918 struct omap_hsmmc_host *host = NULL; in omap_hsmmc_probe() local
1965 host = mmc_priv(mmc); in omap_hsmmc_probe()
1966 host->mmc = mmc; in omap_hsmmc_probe()
1967 host->pdata = pdata; in omap_hsmmc_probe()
1968 host->dev = &pdev->dev; in omap_hsmmc_probe()
1969 host->use_dma = 1; in omap_hsmmc_probe()
1970 host->dma_ch = -1; in omap_hsmmc_probe()
1971 host->irq = irq; in omap_hsmmc_probe()
1972 host->mapbase = res->start + pdata->reg_offset; in omap_hsmmc_probe()
1973 host->base = base + pdata->reg_offset; in omap_hsmmc_probe()
1974 host->power_mode = MMC_POWER_OFF; in omap_hsmmc_probe()
1975 host->next_data.cookie = 1; in omap_hsmmc_probe()
1976 host->pbias_enabled = 0; in omap_hsmmc_probe()
1978 ret = omap_hsmmc_gpio_init(mmc, host, pdata); in omap_hsmmc_probe()
1982 platform_set_drvdata(pdev, host); in omap_hsmmc_probe()
1985 host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); in omap_hsmmc_probe()
1996 spin_lock_init(&host->irq_lock); in omap_hsmmc_probe()
1998 host->fclk = devm_clk_get(&pdev->dev, "fck"); in omap_hsmmc_probe()
1999 if (IS_ERR(host->fclk)) { in omap_hsmmc_probe()
2000 ret = PTR_ERR(host->fclk); in omap_hsmmc_probe()
2001 host->fclk = NULL; in omap_hsmmc_probe()
2005 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { in omap_hsmmc_probe()
2010 pm_runtime_enable(host->dev); in omap_hsmmc_probe()
2011 pm_runtime_get_sync(host->dev); in omap_hsmmc_probe()
2012 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY); in omap_hsmmc_probe()
2013 pm_runtime_use_autosuspend(host->dev); in omap_hsmmc_probe()
2015 omap_hsmmc_context_save(host); in omap_hsmmc_probe()
2017 host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck"); in omap_hsmmc_probe()
2021 if (IS_ERR(host->dbclk)) { in omap_hsmmc_probe()
2022 host->dbclk = NULL; in omap_hsmmc_probe()
2023 } else if (clk_prepare_enable(host->dbclk) != 0) { in omap_hsmmc_probe()
2024 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n"); in omap_hsmmc_probe()
2025 host->dbclk = NULL; in omap_hsmmc_probe()
2040 mmc->caps |= mmc_pdata(host)->caps; in omap_hsmmc_probe()
2044 if (mmc_pdata(host)->nonremovable) in omap_hsmmc_probe()
2047 mmc->pm_caps |= mmc_pdata(host)->pm_caps; in omap_hsmmc_probe()
2049 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_probe()
2054 dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); in omap_hsmmc_probe()
2062 dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); in omap_hsmmc_probe()
2072 host->rx_chan = in omap_hsmmc_probe()
2076 if (!host->rx_chan) { in omap_hsmmc_probe()
2077 dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); in omap_hsmmc_probe()
2082 host->tx_chan = in omap_hsmmc_probe()
2086 if (!host->tx_chan) { in omap_hsmmc_probe()
2087 dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); in omap_hsmmc_probe()
2093 ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0, in omap_hsmmc_probe()
2094 mmc_hostname(mmc), host); in omap_hsmmc_probe()
2096 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n"); in omap_hsmmc_probe()
2100 if (omap_hsmmc_have_reg() && !mmc_pdata(host)->set_power) { in omap_hsmmc_probe()
2101 ret = omap_hsmmc_reg_get(host); in omap_hsmmc_probe()
2104 host->use_reg = 1; in omap_hsmmc_probe()
2107 mmc->ocr_avail = mmc_pdata(host)->ocr_mask; in omap_hsmmc_probe()
2109 omap_hsmmc_disable_irq(host); in omap_hsmmc_probe()
2119 ret = omap_hsmmc_configure_wake_irq(host); in omap_hsmmc_probe()
2123 omap_hsmmc_protect_card(host); in omap_hsmmc_probe()
2127 if (mmc_pdata(host)->name != NULL) { in omap_hsmmc_probe()
2132 if (host->get_cover_state) { in omap_hsmmc_probe()
2140 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_probe()
2141 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_probe()
2147 if (host->use_reg) in omap_hsmmc_probe()
2148 omap_hsmmc_reg_put(host); in omap_hsmmc_probe()
2150 if (host->tx_chan) in omap_hsmmc_probe()
2151 dma_release_channel(host->tx_chan); in omap_hsmmc_probe()
2152 if (host->rx_chan) in omap_hsmmc_probe()
2153 dma_release_channel(host->rx_chan); in omap_hsmmc_probe()
2154 pm_runtime_put_sync(host->dev); in omap_hsmmc_probe()
2155 pm_runtime_disable(host->dev); in omap_hsmmc_probe()
2156 if (host->dbclk) in omap_hsmmc_probe()
2157 clk_disable_unprepare(host->dbclk); in omap_hsmmc_probe()
2167 struct omap_hsmmc_host *host = platform_get_drvdata(pdev); in omap_hsmmc_remove() local
2169 pm_runtime_get_sync(host->dev); in omap_hsmmc_remove()
2170 mmc_remove_host(host->mmc); in omap_hsmmc_remove()
2171 if (host->use_reg) in omap_hsmmc_remove()
2172 omap_hsmmc_reg_put(host); in omap_hsmmc_remove()
2174 if (host->tx_chan) in omap_hsmmc_remove()
2175 dma_release_channel(host->tx_chan); in omap_hsmmc_remove()
2176 if (host->rx_chan) in omap_hsmmc_remove()
2177 dma_release_channel(host->rx_chan); in omap_hsmmc_remove()
2179 pm_runtime_put_sync(host->dev); in omap_hsmmc_remove()
2180 pm_runtime_disable(host->dev); in omap_hsmmc_remove()
2181 if (host->dbclk) in omap_hsmmc_remove()
2182 clk_disable_unprepare(host->dbclk); in omap_hsmmc_remove()
2184 mmc_free_host(host->mmc); in omap_hsmmc_remove()
2192 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_suspend() local
2194 if (!host) in omap_hsmmc_suspend()
2197 pm_runtime_get_sync(host->dev); in omap_hsmmc_suspend()
2199 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { in omap_hsmmc_suspend()
2200 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_suspend()
2201 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_suspend()
2202 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_suspend()
2203 OMAP_HSMMC_WRITE(host->base, HCTL, in omap_hsmmc_suspend()
2204 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); in omap_hsmmc_suspend()
2208 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_suspend()
2209 !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)) in omap_hsmmc_suspend()
2210 disable_irq(host->wake_irq); in omap_hsmmc_suspend()
2212 if (host->dbclk) in omap_hsmmc_suspend()
2213 clk_disable_unprepare(host->dbclk); in omap_hsmmc_suspend()
2215 pm_runtime_put_sync(host->dev); in omap_hsmmc_suspend()
2222 struct omap_hsmmc_host *host = dev_get_drvdata(dev); in omap_hsmmc_resume() local
2224 if (!host) in omap_hsmmc_resume()
2227 pm_runtime_get_sync(host->dev); in omap_hsmmc_resume()
2229 if (host->dbclk) in omap_hsmmc_resume()
2230 clk_prepare_enable(host->dbclk); in omap_hsmmc_resume()
2232 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) in omap_hsmmc_resume()
2233 omap_hsmmc_conf_bus_power(host); in omap_hsmmc_resume()
2235 omap_hsmmc_protect_card(host); in omap_hsmmc_resume()
2237 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_resume()
2238 !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)) in omap_hsmmc_resume()
2239 enable_irq(host->wake_irq); in omap_hsmmc_resume()
2241 pm_runtime_mark_last_busy(host->dev); in omap_hsmmc_resume()
2242 pm_runtime_put_autosuspend(host->dev); in omap_hsmmc_resume()
2249 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_suspend() local
2253 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_suspend()
2254 omap_hsmmc_context_save(host); in omap_hsmmc_runtime_suspend()
2257 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2258 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_suspend()
2259 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_suspend()
2261 OMAP_HSMMC_WRITE(host->base, ISE, 0); in omap_hsmmc_runtime_suspend()
2262 OMAP_HSMMC_WRITE(host->base, IE, 0); in omap_hsmmc_runtime_suspend()
2264 if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) { in omap_hsmmc_runtime_suspend()
2271 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_suspend()
2272 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2273 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_suspend()
2281 WARN_ON(host->flags & HSMMC_WAKE_IRQ_ENABLED); in omap_hsmmc_runtime_suspend()
2282 enable_irq(host->wake_irq); in omap_hsmmc_runtime_suspend()
2283 host->flags |= HSMMC_WAKE_IRQ_ENABLED; in omap_hsmmc_runtime_suspend()
2289 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_suspend()
2295 struct omap_hsmmc_host *host; in omap_hsmmc_runtime_resume() local
2298 host = platform_get_drvdata(to_platform_device(dev)); in omap_hsmmc_runtime_resume()
2299 omap_hsmmc_context_restore(host); in omap_hsmmc_runtime_resume()
2302 spin_lock_irqsave(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()
2303 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && in omap_hsmmc_runtime_resume()
2304 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { in omap_hsmmc_runtime_resume()
2306 if (host->flags & HSMMC_WAKE_IRQ_ENABLED) { in omap_hsmmc_runtime_resume()
2307 disable_irq_nosync(host->wake_irq); in omap_hsmmc_runtime_resume()
2308 host->flags &= ~HSMMC_WAKE_IRQ_ENABLED; in omap_hsmmc_runtime_resume()
2311 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2314 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); in omap_hsmmc_runtime_resume()
2315 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2316 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); in omap_hsmmc_runtime_resume()
2318 pinctrl_pm_select_default_state(host->dev); in omap_hsmmc_runtime_resume()
2320 spin_unlock_irqrestore(&host->irq_lock, flags); in omap_hsmmc_runtime_resume()