Lines Matching full:host
36 #include <linux/mmc/host.h>
53 static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host, in tmio_mmc_start_dma() argument
56 if (host->dma_ops) in tmio_mmc_start_dma()
57 host->dma_ops->start(host, data); in tmio_mmc_start_dma()
60 static inline void tmio_mmc_end_dma(struct tmio_mmc_host *host) in tmio_mmc_end_dma() argument
62 if (host->dma_ops && host->dma_ops->end) in tmio_mmc_end_dma()
63 host->dma_ops->end(host); in tmio_mmc_end_dma()
66 static inline void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable) in tmio_mmc_enable_dma() argument
68 if (host->dma_ops) in tmio_mmc_enable_dma()
69 host->dma_ops->enable(host, enable); in tmio_mmc_enable_dma()
72 static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host, in tmio_mmc_request_dma() argument
75 if (host->dma_ops) { in tmio_mmc_request_dma()
76 host->dma_ops->request(host, pdata); in tmio_mmc_request_dma()
78 host->chan_tx = NULL; in tmio_mmc_request_dma()
79 host->chan_rx = NULL; in tmio_mmc_request_dma()
83 static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host) in tmio_mmc_release_dma() argument
85 if (host->dma_ops) in tmio_mmc_release_dma()
86 host->dma_ops->release(host); in tmio_mmc_release_dma()
89 static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host) in tmio_mmc_abort_dma() argument
91 if (host->dma_ops) in tmio_mmc_abort_dma()
92 host->dma_ops->abort(host); in tmio_mmc_abort_dma()
95 static inline void tmio_mmc_dataend_dma(struct tmio_mmc_host *host) in tmio_mmc_dataend_dma() argument
97 if (host->dma_ops) in tmio_mmc_dataend_dma()
98 host->dma_ops->dataend(host); in tmio_mmc_dataend_dma()
101 void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i) in tmio_mmc_enable_mmc_irqs() argument
103 host->sdcard_irq_mask &= ~(i & TMIO_MASK_IRQ); in tmio_mmc_enable_mmc_irqs()
104 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask); in tmio_mmc_enable_mmc_irqs()
108 void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i) in tmio_mmc_disable_mmc_irqs() argument
110 host->sdcard_irq_mask |= (i & TMIO_MASK_IRQ); in tmio_mmc_disable_mmc_irqs()
111 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask); in tmio_mmc_disable_mmc_irqs()
115 static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i) in tmio_mmc_ack_mmc_irqs() argument
117 sd_ctrl_write32_as_16_and_16(host, CTL_STATUS, ~i); in tmio_mmc_ack_mmc_irqs()
120 static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data) in tmio_mmc_init_sg() argument
122 host->sg_len = data->sg_len; in tmio_mmc_init_sg()
123 host->sg_ptr = data->sg; in tmio_mmc_init_sg()
124 host->sg_orig = data->sg; in tmio_mmc_init_sg()
125 host->sg_off = 0; in tmio_mmc_init_sg()
128 static int tmio_mmc_next_sg(struct tmio_mmc_host *host) in tmio_mmc_next_sg() argument
130 host->sg_ptr = sg_next(host->sg_ptr); in tmio_mmc_next_sg()
131 host->sg_off = 0; in tmio_mmc_next_sg()
132 return --host->sg_len; in tmio_mmc_next_sg()
139 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_enable_sdio_irq() local
141 if (enable && !host->sdio_irq_enabled) { in tmio_mmc_enable_sdio_irq()
147 host->sdio_irq_enabled = true; in tmio_mmc_enable_sdio_irq()
148 host->sdio_irq_mask = TMIO_SDIO_MASK_ALL & ~TMIO_SDIO_STAT_IOIRQ; in tmio_mmc_enable_sdio_irq()
151 sdio_status = sd_ctrl_read16(host, CTL_SDIO_STATUS) & ~TMIO_SDIO_MASK_ALL; in tmio_mmc_enable_sdio_irq()
152 if (host->pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS) in tmio_mmc_enable_sdio_irq()
154 sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status); in tmio_mmc_enable_sdio_irq()
156 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); in tmio_mmc_enable_sdio_irq()
157 } else if (!enable && host->sdio_irq_enabled) { in tmio_mmc_enable_sdio_irq()
158 host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; in tmio_mmc_enable_sdio_irq()
159 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); in tmio_mmc_enable_sdio_irq()
161 host->sdio_irq_enabled = false; in tmio_mmc_enable_sdio_irq()
167 static void tmio_mmc_reset(struct tmio_mmc_host *host) in tmio_mmc_reset() argument
170 sd_ctrl_write16(host, CTL_RESET_SD, 0x0000); in tmio_mmc_reset()
172 sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); in tmio_mmc_reset()
175 if (host->reset) in tmio_mmc_reset()
176 host->reset(host); in tmio_mmc_reset()
178 tmio_mmc_abort_dma(host); in tmio_mmc_reset()
180 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { in tmio_mmc_reset()
181 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); in tmio_mmc_reset()
182 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); in tmio_mmc_reset()
188 struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host, in tmio_mmc_reset_work() local
193 spin_lock_irqsave(&host->lock, flags); in tmio_mmc_reset_work()
194 mrq = host->mrq; in tmio_mmc_reset_work()
199 * us, so, have to check for IS_ERR(host->mrq) in tmio_mmc_reset_work()
202 time_is_after_jiffies(host->last_req_ts + in tmio_mmc_reset_work()
204 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_reset_work()
208 dev_warn(&host->pdev->dev, in tmio_mmc_reset_work()
212 if (host->data) in tmio_mmc_reset_work()
213 host->data->error = -ETIMEDOUT; in tmio_mmc_reset_work()
214 else if (host->cmd) in tmio_mmc_reset_work()
215 host->cmd->error = -ETIMEDOUT; in tmio_mmc_reset_work()
219 host->cmd = NULL; in tmio_mmc_reset_work()
220 host->data = NULL; in tmio_mmc_reset_work()
222 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_reset_work()
224 tmio_mmc_reset(host); in tmio_mmc_reset_work()
227 host->mrq = NULL; in tmio_mmc_reset_work()
228 mmc_request_done(host->mmc, mrq); in tmio_mmc_reset_work()
245 static int tmio_mmc_start_command(struct tmio_mmc_host *host, in tmio_mmc_start_command() argument
248 struct mmc_data *data = host->data; in tmio_mmc_start_command()
264 host->cmd = cmd; in tmio_mmc_start_command()
274 sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, TMIO_STOP_SEC); in tmio_mmc_start_command()
281 if ((host->pdata->flags & TMIO_MMC_HAVE_CMD12_CTRL) && in tmio_mmc_start_command()
282 (cmd->opcode == SD_IO_RW_EXTENDED || host->mrq->sbc)) in tmio_mmc_start_command()
289 tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_CMD); in tmio_mmc_start_command()
292 sd_ctrl_write32_as_16_and_16(host, CTL_ARG_REG, cmd->arg); in tmio_mmc_start_command()
293 sd_ctrl_write16(host, CTL_SD_CMD, c); in tmio_mmc_start_command()
298 static void tmio_mmc_transfer_data(struct tmio_mmc_host *host, in tmio_mmc_transfer_data() argument
302 int is_read = host->data->flags & MMC_DATA_READ; in tmio_mmc_transfer_data()
308 if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) { in tmio_mmc_transfer_data()
313 sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, buf32, in tmio_mmc_transfer_data()
316 sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, buf32, in tmio_mmc_transfer_data()
327 sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1); in tmio_mmc_transfer_data()
331 sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1); in tmio_mmc_transfer_data()
338 sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); in tmio_mmc_transfer_data()
340 sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); in tmio_mmc_transfer_data()
356 *buf8 = sd_ctrl_read16(host, CTL_SD_DATA_PORT) & 0xff; in tmio_mmc_transfer_data()
358 sd_ctrl_write16(host, CTL_SD_DATA_PORT, *buf8); in tmio_mmc_transfer_data()
366 static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) in tmio_mmc_pio_irq() argument
368 struct mmc_data *data = host->data; in tmio_mmc_pio_irq()
374 if (host->dma_on) { in tmio_mmc_pio_irq()
382 sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags); in tmio_mmc_pio_irq()
383 buf = (unsigned short *)(sg_virt + host->sg_off); in tmio_mmc_pio_irq()
385 count = host->sg_ptr->length - host->sg_off; in tmio_mmc_pio_irq()
390 count, host->sg_off, data->flags); in tmio_mmc_pio_irq()
393 tmio_mmc_transfer_data(host, buf, count); in tmio_mmc_pio_irq()
395 host->sg_off += count; in tmio_mmc_pio_irq()
397 tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt); in tmio_mmc_pio_irq()
399 if (host->sg_off == host->sg_ptr->length) in tmio_mmc_pio_irq()
400 tmio_mmc_next_sg(host); in tmio_mmc_pio_irq()
403 static void tmio_mmc_check_bounce_buffer(struct tmio_mmc_host *host) in tmio_mmc_check_bounce_buffer() argument
405 if (host->sg_ptr == &host->bounce_sg) { in tmio_mmc_check_bounce_buffer()
407 void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig, &flags); in tmio_mmc_check_bounce_buffer()
409 memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length); in tmio_mmc_check_bounce_buffer()
410 tmio_mmc_kunmap_atomic(host->sg_orig, &flags, sg_vaddr); in tmio_mmc_check_bounce_buffer()
414 /* needs to be called with host->lock held */
415 void tmio_mmc_do_data_irq(struct tmio_mmc_host *host) in tmio_mmc_do_data_irq() argument
417 struct mmc_data *data = host->data; in tmio_mmc_do_data_irq()
420 host->data = NULL; in tmio_mmc_do_data_irq()
423 dev_warn(&host->pdev->dev, "Spurious data end IRQ\n"); in tmio_mmc_do_data_irq()
446 if (host->dma_on) in tmio_mmc_do_data_irq()
447 tmio_mmc_check_bounce_buffer(host); in tmio_mmc_do_data_irq()
448 dev_dbg(&host->pdev->dev, "Complete Rx request %p\n", in tmio_mmc_do_data_irq()
449 host->mrq); in tmio_mmc_do_data_irq()
451 dev_dbg(&host->pdev->dev, "Complete Tx request %p\n", in tmio_mmc_do_data_irq()
452 host->mrq); in tmio_mmc_do_data_irq()
455 if (stop && !host->mrq->sbc) { in tmio_mmc_do_data_irq()
457 dev_err(&host->pdev->dev, "unsupported stop: CMD%u,0x%x. We did CMD12,0\n", in tmio_mmc_do_data_irq()
461 stop->resp[0] = sd_ctrl_read16_and_16_as_32(host, CTL_RESPONSE); in tmio_mmc_do_data_irq()
463 sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0); in tmio_mmc_do_data_irq()
466 schedule_work(&host->done); in tmio_mmc_do_data_irq()
470 static void tmio_mmc_data_irq(struct tmio_mmc_host *host, unsigned int stat) in tmio_mmc_data_irq() argument
474 spin_lock(&host->lock); in tmio_mmc_data_irq()
475 data = host->data; in tmio_mmc_data_irq()
483 if (host->dma_on && (data->flags & MMC_DATA_WRITE)) { in tmio_mmc_data_irq()
484 u32 status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS); in tmio_mmc_data_irq()
495 if (host->pdata->flags & TMIO_MMC_HAS_IDLE_WAIT) { in tmio_mmc_data_irq()
504 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND); in tmio_mmc_data_irq()
505 tmio_mmc_dataend_dma(host); in tmio_mmc_data_irq()
507 } else if (host->dma_on && (data->flags & MMC_DATA_READ)) { in tmio_mmc_data_irq()
508 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND); in tmio_mmc_data_irq()
509 tmio_mmc_dataend_dma(host); in tmio_mmc_data_irq()
511 tmio_mmc_do_data_irq(host); in tmio_mmc_data_irq()
512 tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_READOP | TMIO_MASK_WRITEOP); in tmio_mmc_data_irq()
515 spin_unlock(&host->lock); in tmio_mmc_data_irq()
518 static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host, unsigned int stat) in tmio_mmc_cmd_irq() argument
520 struct mmc_command *cmd = host->cmd; in tmio_mmc_cmd_irq()
523 spin_lock(&host->lock); in tmio_mmc_cmd_irq()
525 if (!host->cmd) { in tmio_mmc_cmd_irq()
536 cmd->resp[i] = sd_ctrl_read16_and_16_as_32(host, addr); in tmio_mmc_cmd_irq()
558 if (host->data && (!cmd->error || cmd->error == -EILSEQ)) { in tmio_mmc_cmd_irq()
559 if (host->data->flags & MMC_DATA_READ) { in tmio_mmc_cmd_irq()
560 if (!host->dma_on) { in tmio_mmc_cmd_irq()
561 tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_READOP); in tmio_mmc_cmd_irq()
563 tmio_mmc_disable_mmc_irqs(host, in tmio_mmc_cmd_irq()
565 tasklet_schedule(&host->dma_issue); in tmio_mmc_cmd_irq()
568 if (!host->dma_on) { in tmio_mmc_cmd_irq()
569 tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_WRITEOP); in tmio_mmc_cmd_irq()
571 tmio_mmc_disable_mmc_irqs(host, in tmio_mmc_cmd_irq()
573 tasklet_schedule(&host->dma_issue); in tmio_mmc_cmd_irq()
577 schedule_work(&host->done); in tmio_mmc_cmd_irq()
581 spin_unlock(&host->lock); in tmio_mmc_cmd_irq()
584 static bool __tmio_mmc_card_detect_irq(struct tmio_mmc_host *host, in __tmio_mmc_card_detect_irq() argument
587 struct mmc_host *mmc = host->mmc; in __tmio_mmc_card_detect_irq()
591 tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_CARD_INSERT | in __tmio_mmc_card_detect_irq()
596 mmc_detect_change(host->mmc, msecs_to_jiffies(100)); in __tmio_mmc_card_detect_irq()
603 static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host, int ireg, in __tmio_mmc_sdcard_irq() argument
608 tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_CMDRESPEND | in __tmio_mmc_sdcard_irq()
610 tmio_mmc_cmd_irq(host, status); in __tmio_mmc_sdcard_irq()
616 tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_RXRDY | TMIO_STAT_TXRQ); in __tmio_mmc_sdcard_irq()
617 tmio_mmc_pio_irq(host); in __tmio_mmc_sdcard_irq()
623 tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_DATAEND); in __tmio_mmc_sdcard_irq()
624 tmio_mmc_data_irq(host, status); in __tmio_mmc_sdcard_irq()
631 static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host) in __tmio_mmc_sdio_irq() argument
633 struct mmc_host *mmc = host->mmc; in __tmio_mmc_sdio_irq()
634 struct tmio_mmc_data *pdata = host->pdata; in __tmio_mmc_sdio_irq()
641 status = sd_ctrl_read16(host, CTL_SDIO_STATUS); in __tmio_mmc_sdio_irq()
642 ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask; in __tmio_mmc_sdio_irq()
648 sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status); in __tmio_mmc_sdio_irq()
658 struct tmio_mmc_host *host = devid; in tmio_mmc_irq() local
661 status = sd_ctrl_read16_and_16_as_32(host, CTL_STATUS); in tmio_mmc_irq()
662 ireg = status & TMIO_MASK_IRQ & ~host->sdcard_irq_mask; in tmio_mmc_irq()
665 sd_ctrl_write32_as_16_and_16(host, CTL_STATUS, TMIO_MASK_IRQ); in tmio_mmc_irq()
667 if (__tmio_mmc_card_detect_irq(host, ireg, status)) in tmio_mmc_irq()
669 if (__tmio_mmc_sdcard_irq(host, ireg, status)) in tmio_mmc_irq()
672 if (__tmio_mmc_sdio_irq(host)) in tmio_mmc_irq()
679 static int tmio_mmc_start_data(struct tmio_mmc_host *host, in tmio_mmc_start_data() argument
682 struct tmio_mmc_data *pdata = host->pdata; in tmio_mmc_start_data()
688 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4 || in tmio_mmc_start_data()
689 host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) { in tmio_mmc_start_data()
694 mmc_hostname(host->mmc), data->blksz); in tmio_mmc_start_data()
699 tmio_mmc_init_sg(host, data); in tmio_mmc_start_data()
700 host->data = data; in tmio_mmc_start_data()
701 host->dma_on = false; in tmio_mmc_start_data()
704 sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz); in tmio_mmc_start_data()
705 if (host->mmc->max_blk_count >= SZ_64K) in tmio_mmc_start_data()
706 sd_ctrl_write32(host, CTL_XFER_BLK_COUNT, data->blocks); in tmio_mmc_start_data()
708 sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks); in tmio_mmc_start_data()
710 tmio_mmc_start_dma(host, data); in tmio_mmc_start_data()
715 static void tmio_process_mrq(struct tmio_mmc_host *host, in tmio_process_mrq() argument
721 if (mrq->sbc && host->cmd != mrq->sbc) { in tmio_process_mrq()
726 ret = tmio_mmc_start_data(host, mrq->data); in tmio_process_mrq()
732 ret = tmio_mmc_start_command(host, cmd); in tmio_process_mrq()
736 schedule_delayed_work(&host->delayed_reset_work, in tmio_process_mrq()
741 host->mrq = NULL; in tmio_process_mrq()
743 mmc_request_done(host->mmc, mrq); in tmio_process_mrq()
749 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_request() local
752 spin_lock_irqsave(&host->lock, flags); in tmio_mmc_request()
754 if (host->mrq) { in tmio_mmc_request()
756 if (IS_ERR(host->mrq)) { in tmio_mmc_request()
757 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_request()
764 host->last_req_ts = jiffies; in tmio_mmc_request()
766 host->mrq = mrq; in tmio_mmc_request()
768 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_request()
770 tmio_process_mrq(host, mrq); in tmio_mmc_request()
773 static void tmio_mmc_finish_request(struct tmio_mmc_host *host) in tmio_mmc_finish_request() argument
778 spin_lock_irqsave(&host->lock, flags); in tmio_mmc_finish_request()
780 tmio_mmc_end_dma(host); in tmio_mmc_finish_request()
782 mrq = host->mrq; in tmio_mmc_finish_request()
784 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_finish_request()
789 if (host->cmd != mrq->sbc) { in tmio_mmc_finish_request()
790 host->cmd = NULL; in tmio_mmc_finish_request()
791 host->data = NULL; in tmio_mmc_finish_request()
792 host->mrq = NULL; in tmio_mmc_finish_request()
795 cancel_delayed_work(&host->delayed_reset_work); in tmio_mmc_finish_request()
797 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_finish_request()
800 tmio_mmc_abort_dma(host); in tmio_mmc_finish_request()
803 if (host->check_retune && host->check_retune(host)) in tmio_mmc_finish_request()
804 mmc_retune_needed(host->mmc); in tmio_mmc_finish_request()
807 if (host->mrq && !mrq->cmd->error) { in tmio_mmc_finish_request()
808 tmio_process_mrq(host, mrq); in tmio_mmc_finish_request()
812 if (host->fixup_request) in tmio_mmc_finish_request()
813 host->fixup_request(host, mrq); in tmio_mmc_finish_request()
815 mmc_request_done(host->mmc, mrq); in tmio_mmc_finish_request()
820 struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host, in tmio_mmc_done_work() local
822 tmio_mmc_finish_request(host); in tmio_mmc_done_work()
825 static void tmio_mmc_power_on(struct tmio_mmc_host *host, unsigned short vdd) in tmio_mmc_power_on() argument
827 struct mmc_host *mmc = host->mmc; in tmio_mmc_power_on()
832 if (host->set_pwr) in tmio_mmc_power_on()
833 host->set_pwr(host->pdev, 1); in tmio_mmc_power_on()
855 dev_dbg(&host->pdev->dev, "Regulators failed to power up: %d\n", in tmio_mmc_power_on()
859 static void tmio_mmc_power_off(struct tmio_mmc_host *host) in tmio_mmc_power_off() argument
861 struct mmc_host *mmc = host->mmc; in tmio_mmc_power_off()
869 if (host->set_pwr) in tmio_mmc_power_off()
870 host->set_pwr(host->pdev, 0); in tmio_mmc_power_off()
873 static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host, in tmio_mmc_set_bus_width() argument
876 u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT) in tmio_mmc_set_bus_width()
885 sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg); in tmio_mmc_set_bus_width()
896 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_set_ios() local
897 struct device *dev = &host->pdev->dev; in tmio_mmc_set_ios()
900 mutex_lock(&host->ios_lock); in tmio_mmc_set_ios()
902 spin_lock_irqsave(&host->lock, flags); in tmio_mmc_set_ios()
903 if (host->mrq) { in tmio_mmc_set_ios()
904 if (IS_ERR(host->mrq)) { in tmio_mmc_set_ios()
909 host->mrq = ERR_PTR(-EINTR); in tmio_mmc_set_ios()
914 host->mrq->cmd->opcode, host->last_req_ts, in tmio_mmc_set_ios()
917 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_set_ios()
919 mutex_unlock(&host->ios_lock); in tmio_mmc_set_ios()
923 host->mrq = ERR_PTR(-EBUSY); in tmio_mmc_set_ios()
925 spin_unlock_irqrestore(&host->lock, flags); in tmio_mmc_set_ios()
929 tmio_mmc_power_off(host); in tmio_mmc_set_ios()
931 if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) in tmio_mmc_set_ios()
932 host->reset(host); in tmio_mmc_set_ios()
933 host->set_clock(host, 0); in tmio_mmc_set_ios()
936 tmio_mmc_power_on(host, ios->vdd); in tmio_mmc_set_ios()
937 host->set_clock(host, ios->clock); in tmio_mmc_set_ios()
938 tmio_mmc_set_bus_width(host, ios->bus_width); in tmio_mmc_set_ios()
941 host->set_clock(host, ios->clock); in tmio_mmc_set_ios()
942 tmio_mmc_set_bus_width(host, ios->bus_width); in tmio_mmc_set_ios()
948 if (PTR_ERR(host->mrq) == -EINTR) in tmio_mmc_set_ios()
949 dev_dbg(&host->pdev->dev, in tmio_mmc_set_ios()
953 host->mrq = NULL; in tmio_mmc_set_ios()
955 host->clk_cache = ios->clock; in tmio_mmc_set_ios()
957 mutex_unlock(&host->ios_lock); in tmio_mmc_set_ios()
962 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_get_ro() local
964 return !(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & in tmio_mmc_get_ro()
970 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_get_cd() local
972 return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & in tmio_mmc_get_cd()
979 struct tmio_mmc_host *host = mmc_priv(card->host); in tmio_multi_io_quirk() local
981 if (host->multi_io_quirk) in tmio_multi_io_quirk()
982 return host->multi_io_quirk(card, direction, blk_size); in tmio_multi_io_quirk()
996 static int tmio_mmc_init_ocr(struct tmio_mmc_host *host) in tmio_mmc_init_ocr() argument
998 struct tmio_mmc_data *pdata = host->pdata; in tmio_mmc_init_ocr()
999 struct mmc_host *mmc = host->mmc; in tmio_mmc_init_ocr()
1040 struct tmio_mmc_host *host; in tmio_mmc_host_alloc() local
1053 host = mmc_priv(mmc); in tmio_mmc_host_alloc()
1054 host->ctl = ctl; in tmio_mmc_host_alloc()
1055 host->mmc = mmc; in tmio_mmc_host_alloc()
1056 host->pdev = pdev; in tmio_mmc_host_alloc()
1057 host->pdata = pdata; in tmio_mmc_host_alloc()
1058 host->ops = tmio_mmc_ops; in tmio_mmc_host_alloc()
1059 mmc->ops = &host->ops; in tmio_mmc_host_alloc()
1061 ret = mmc_of_parse(host->mmc); in tmio_mmc_host_alloc()
1063 host = ERR_PTR(ret); in tmio_mmc_host_alloc()
1069 platform_set_drvdata(pdev, host); in tmio_mmc_host_alloc()
1071 return host; in tmio_mmc_host_alloc()
1075 return host; in tmio_mmc_host_alloc()
1079 void tmio_mmc_host_free(struct tmio_mmc_host *host) in tmio_mmc_host_free() argument
1081 mmc_free_host(host->mmc); in tmio_mmc_host_free()
1093 * Check the sanity of mmc->f_min to prevent host->set_clock() from in tmio_mmc_host_probe()
1199 void tmio_mmc_host_remove(struct tmio_mmc_host *host) in tmio_mmc_host_remove() argument
1201 struct platform_device *pdev = host->pdev; in tmio_mmc_host_remove()
1202 struct mmc_host *mmc = host->mmc; in tmio_mmc_host_remove()
1206 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) in tmio_mmc_host_remove()
1207 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); in tmio_mmc_host_remove()
1212 cancel_work_sync(&host->done); in tmio_mmc_host_remove()
1213 cancel_delayed_work_sync(&host->delayed_reset_work); in tmio_mmc_host_remove()
1214 tmio_mmc_release_dma(host); in tmio_mmc_host_remove()
1215 tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); in tmio_mmc_host_remove()
1217 if (host->native_hotplug) in tmio_mmc_host_remove()
1227 static int tmio_mmc_clk_enable(struct tmio_mmc_host *host) in tmio_mmc_clk_enable() argument
1229 if (!host->clk_enable) in tmio_mmc_clk_enable()
1232 return host->clk_enable(host); in tmio_mmc_clk_enable()
1235 static void tmio_mmc_clk_disable(struct tmio_mmc_host *host) in tmio_mmc_clk_disable() argument
1237 if (host->clk_disable) in tmio_mmc_clk_disable()
1238 host->clk_disable(host); in tmio_mmc_clk_disable()
1243 struct tmio_mmc_host *host = dev_get_drvdata(dev); in tmio_mmc_host_runtime_suspend() local
1245 tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); in tmio_mmc_host_runtime_suspend()
1247 if (host->clk_cache) in tmio_mmc_host_runtime_suspend()
1248 host->set_clock(host, 0); in tmio_mmc_host_runtime_suspend()
1250 tmio_mmc_clk_disable(host); in tmio_mmc_host_runtime_suspend()
1258 struct tmio_mmc_host *host = dev_get_drvdata(dev); in tmio_mmc_host_runtime_resume() local
1260 tmio_mmc_clk_enable(host); in tmio_mmc_host_runtime_resume()
1261 tmio_mmc_reset(host); in tmio_mmc_host_runtime_resume()
1263 if (host->clk_cache) in tmio_mmc_host_runtime_resume()
1264 host->set_clock(host, host->clk_cache); in tmio_mmc_host_runtime_resume()
1266 if (host->native_hotplug) in tmio_mmc_host_runtime_resume()
1267 tmio_mmc_enable_mmc_irqs(host, in tmio_mmc_host_runtime_resume()
1270 tmio_mmc_enable_dma(host, true); in tmio_mmc_host_runtime_resume()
1272 mmc_retune_needed(host->mmc); in tmio_mmc_host_runtime_resume()