Lines Matching refs:host
72 #define mmc_omap7xx() (host->features & MMC_OMAP7XX)
73 #define mmc_omap15xx() (host->features & MMC_OMAP15XX)
74 #define mmc_omap16xx() (host->features & MMC_OMAP16XX)
76 #define mmc_omap1() (host->features & MMC_OMAP1_MASK)
79 #define OMAP_MMC_REG(host, reg) (OMAP_MMC_REG_##reg << (host)->reg_shift) argument
80 #define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg)) argument
81 #define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, r… argument
112 struct mmc_omap_host *host; member
176 if (slot != NULL && slot->host->fclk_enabled && slot->fclk_freq > 0) { in mmc_omap_fclk_offdelay()
182 static void mmc_omap_fclk_enable(struct mmc_omap_host *host, unsigned int enable) in mmc_omap_fclk_enable() argument
186 spin_lock_irqsave(&host->clk_lock, flags); in mmc_omap_fclk_enable()
187 if (host->fclk_enabled != enable) { in mmc_omap_fclk_enable()
188 host->fclk_enabled = enable; in mmc_omap_fclk_enable()
190 clk_enable(host->fclk); in mmc_omap_fclk_enable()
192 clk_disable(host->fclk); in mmc_omap_fclk_enable()
194 spin_unlock_irqrestore(&host->clk_lock, flags); in mmc_omap_fclk_enable()
199 struct mmc_omap_host *host = slot->host; in mmc_omap_select_slot() local
204 spin_lock_irqsave(&host->slot_lock, flags); in mmc_omap_select_slot()
205 while (host->mmc != NULL) { in mmc_omap_select_slot()
206 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_select_slot()
207 wait_event(host->slot_wq, host->mmc == NULL); in mmc_omap_select_slot()
208 spin_lock_irqsave(&host->slot_lock, flags); in mmc_omap_select_slot()
210 host->mmc = slot->mmc; in mmc_omap_select_slot()
211 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_select_slot()
213 del_timer(&host->clk_timer); in mmc_omap_select_slot()
214 if (host->current_slot != slot || !claimed) in mmc_omap_select_slot()
215 mmc_omap_fclk_offdelay(host->current_slot); in mmc_omap_select_slot()
217 if (host->current_slot != slot) { in mmc_omap_select_slot()
218 OMAP_MMC_WRITE(host, CON, slot->saved_con & 0xFC00); in mmc_omap_select_slot()
219 if (host->pdata->switch_slot != NULL) in mmc_omap_select_slot()
220 host->pdata->switch_slot(mmc_dev(slot->mmc), slot->id); in mmc_omap_select_slot()
221 host->current_slot = slot; in mmc_omap_select_slot()
225 mmc_omap_fclk_enable(host, 1); in mmc_omap_select_slot()
230 OMAP_MMC_READ(host, CON); in mmc_omap_select_slot()
232 OMAP_MMC_WRITE(host, CON, slot->saved_con); in mmc_omap_select_slot()
234 mmc_omap_fclk_enable(host, 0); in mmc_omap_select_slot()
237 static void mmc_omap_start_request(struct mmc_omap_host *host,
242 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host, in mmc_omap_slot_release_work() local
244 struct mmc_omap_slot *next_slot = host->next_slot; in mmc_omap_slot_release_work()
247 host->next_slot = NULL; in mmc_omap_slot_release_work()
252 mmc_omap_start_request(host, rq); in mmc_omap_slot_release_work()
257 struct mmc_omap_host *host = slot->host; in mmc_omap_release_slot() local
261 BUG_ON(slot == NULL || host->mmc == NULL); in mmc_omap_release_slot()
265 mod_timer(&host->clk_timer, jiffies + HZ/10); in mmc_omap_release_slot()
267 del_timer(&host->clk_timer); in mmc_omap_release_slot()
269 mmc_omap_fclk_enable(host, 0); in mmc_omap_release_slot()
272 spin_lock_irqsave(&host->slot_lock, flags); in mmc_omap_release_slot()
274 for (i = 0; i < host->nr_slots; i++) { in mmc_omap_release_slot()
277 if (host->slots[i] == NULL || host->slots[i]->mrq == NULL) in mmc_omap_release_slot()
280 BUG_ON(host->next_slot != NULL); in mmc_omap_release_slot()
281 new_slot = host->slots[i]; in mmc_omap_release_slot()
283 BUG_ON(new_slot == host->current_slot); in mmc_omap_release_slot()
285 host->next_slot = new_slot; in mmc_omap_release_slot()
286 host->mmc = new_slot->mmc; in mmc_omap_release_slot()
287 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_release_slot()
288 queue_work(host->mmc_omap_wq, &host->slot_release_work); in mmc_omap_release_slot()
292 host->mmc = NULL; in mmc_omap_release_slot()
293 wake_up(&host->slot_wq); in mmc_omap_release_slot()
294 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_release_slot()
332 mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd) in mmc_omap_start_command() argument
339 host->cmd = cmd; in mmc_omap_start_command()
360 dev_err(mmc_dev(host->mmc), "Invalid response type: %04x\n", mmc_resp_type(cmd)); in mmc_omap_start_command()
376 if (host->current_slot->bus_mode == MMC_BUSMODE_OPENDRAIN) in mmc_omap_start_command()
382 if (host->data && !(host->data->flags & MMC_DATA_WRITE)) in mmc_omap_start_command()
385 mod_timer(&host->cmd_abort_timer, jiffies + HZ/2); in mmc_omap_start_command()
387 OMAP_MMC_WRITE(host, CTO, 200); in mmc_omap_start_command()
388 OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff); in mmc_omap_start_command()
389 OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16); in mmc_omap_start_command()
397 OMAP_MMC_WRITE(host, IE, irq_mask); in mmc_omap_start_command()
398 OMAP_MMC_WRITE(host, CMD, cmdreg); in mmc_omap_start_command()
402 mmc_omap_release_dma(struct mmc_omap_host *host, struct mmc_data *data, in mmc_omap_release_dma() argument
406 struct device *dev = mmc_dev(host->mmc); in mmc_omap_release_dma()
411 c = host->dma_tx; in mmc_omap_release_dma()
414 c = host->dma_rx; in mmc_omap_release_dma()
424 dma_unmap_sg(dev, data->sg, host->sg_len, dma_data_dir); in mmc_omap_release_dma()
429 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host, in mmc_omap_send_stop_work() local
431 struct mmc_omap_slot *slot = host->current_slot; in mmc_omap_send_stop_work()
432 struct mmc_data *data = host->stop_data; in mmc_omap_send_stop_work()
438 mmc_omap_start_command(host, data->stop); in mmc_omap_send_stop_work()
442 mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data) in mmc_omap_xfer_done() argument
444 if (host->dma_in_use) in mmc_omap_xfer_done()
445 mmc_omap_release_dma(host, data, data->error); in mmc_omap_xfer_done()
447 host->data = NULL; in mmc_omap_xfer_done()
448 host->sg_len = 0; in mmc_omap_xfer_done()
458 host->mrq = NULL; in mmc_omap_xfer_done()
459 mmc = host->mmc; in mmc_omap_xfer_done()
460 mmc_omap_release_slot(host->current_slot, 1); in mmc_omap_xfer_done()
465 host->stop_data = data; in mmc_omap_xfer_done()
466 queue_work(host->mmc_omap_wq, &host->send_stop_work); in mmc_omap_xfer_done()
470 mmc_omap_send_abort(struct mmc_omap_host *host, int maxloops) in mmc_omap_send_abort() argument
472 struct mmc_omap_slot *slot = host->current_slot; in mmc_omap_send_abort()
480 OMAP_MMC_WRITE(host, STAT, 0xFFFF); in mmc_omap_send_abort()
481 OMAP_MMC_WRITE(host, CMD, (3 << 12) | (1 << 7)); in mmc_omap_send_abort()
485 stat = OMAP_MMC_READ(host, STAT); in mmc_omap_send_abort()
495 OMAP_MMC_WRITE(host, STAT, stat); in mmc_omap_send_abort()
499 mmc_omap_abort_xfer(struct mmc_omap_host *host, struct mmc_data *data) in mmc_omap_abort_xfer() argument
501 if (host->dma_in_use) in mmc_omap_abort_xfer()
502 mmc_omap_release_dma(host, data, 1); in mmc_omap_abort_xfer()
504 host->data = NULL; in mmc_omap_abort_xfer()
505 host->sg_len = 0; in mmc_omap_abort_xfer()
507 mmc_omap_send_abort(host, 10000); in mmc_omap_abort_xfer()
511 mmc_omap_end_of_data(struct mmc_omap_host *host, struct mmc_data *data) in mmc_omap_end_of_data() argument
516 if (!host->dma_in_use) { in mmc_omap_end_of_data()
517 mmc_omap_xfer_done(host, data); in mmc_omap_end_of_data()
521 spin_lock_irqsave(&host->dma_lock, flags); in mmc_omap_end_of_data()
522 if (host->dma_done) in mmc_omap_end_of_data()
525 host->brs_received = 1; in mmc_omap_end_of_data()
526 spin_unlock_irqrestore(&host->dma_lock, flags); in mmc_omap_end_of_data()
528 mmc_omap_xfer_done(host, data); in mmc_omap_end_of_data()
532 mmc_omap_dma_done(struct mmc_omap_host *host, struct mmc_data *data) in mmc_omap_dma_done() argument
538 spin_lock_irqsave(&host->dma_lock, flags); in mmc_omap_dma_done()
539 if (host->brs_received) in mmc_omap_dma_done()
542 host->dma_done = 1; in mmc_omap_dma_done()
543 spin_unlock_irqrestore(&host->dma_lock, flags); in mmc_omap_dma_done()
545 mmc_omap_xfer_done(host, data); in mmc_omap_dma_done()
549 mmc_omap_cmd_done(struct mmc_omap_host *host, struct mmc_command *cmd) in mmc_omap_cmd_done() argument
551 host->cmd = NULL; in mmc_omap_cmd_done()
553 del_timer(&host->cmd_abort_timer); in mmc_omap_cmd_done()
559 OMAP_MMC_READ(host, RSP0) | in mmc_omap_cmd_done()
560 (OMAP_MMC_READ(host, RSP1) << 16); in mmc_omap_cmd_done()
562 OMAP_MMC_READ(host, RSP2) | in mmc_omap_cmd_done()
563 (OMAP_MMC_READ(host, RSP3) << 16); in mmc_omap_cmd_done()
565 OMAP_MMC_READ(host, RSP4) | in mmc_omap_cmd_done()
566 (OMAP_MMC_READ(host, RSP5) << 16); in mmc_omap_cmd_done()
568 OMAP_MMC_READ(host, RSP6) | in mmc_omap_cmd_done()
569 (OMAP_MMC_READ(host, RSP7) << 16); in mmc_omap_cmd_done()
573 OMAP_MMC_READ(host, RSP6) | in mmc_omap_cmd_done()
574 (OMAP_MMC_READ(host, RSP7) << 16); in mmc_omap_cmd_done()
578 if (host->data == NULL || cmd->error) { in mmc_omap_cmd_done()
581 if (host->data != NULL) in mmc_omap_cmd_done()
582 mmc_omap_abort_xfer(host, host->data); in mmc_omap_cmd_done()
583 host->mrq = NULL; in mmc_omap_cmd_done()
584 mmc = host->mmc; in mmc_omap_cmd_done()
585 mmc_omap_release_slot(host->current_slot, 1); in mmc_omap_cmd_done()
596 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host, in mmc_omap_abort_command() local
598 BUG_ON(!host->cmd); in mmc_omap_abort_command()
600 dev_dbg(mmc_dev(host->mmc), "Aborting stuck command CMD%d\n", in mmc_omap_abort_command()
601 host->cmd->opcode); in mmc_omap_abort_command()
603 if (host->cmd->error == 0) in mmc_omap_abort_command()
604 host->cmd->error = -ETIMEDOUT; in mmc_omap_abort_command()
606 if (host->data == NULL) { in mmc_omap_abort_command()
610 cmd = host->cmd; in mmc_omap_abort_command()
611 host->cmd = NULL; in mmc_omap_abort_command()
612 mmc_omap_send_abort(host, 10000); in mmc_omap_abort_command()
614 host->mrq = NULL; in mmc_omap_abort_command()
615 mmc = host->mmc; in mmc_omap_abort_command()
616 mmc_omap_release_slot(host->current_slot, 1); in mmc_omap_abort_command()
619 mmc_omap_cmd_done(host, host->cmd); in mmc_omap_abort_command()
621 host->abort = 0; in mmc_omap_abort_command()
622 enable_irq(host->irq); in mmc_omap_abort_command()
628 struct mmc_omap_host *host = from_timer(host, t, cmd_abort_timer); in mmc_omap_cmd_timer() local
631 spin_lock_irqsave(&host->slot_lock, flags); in mmc_omap_cmd_timer()
632 if (host->cmd != NULL && !host->abort) { in mmc_omap_cmd_timer()
633 OMAP_MMC_WRITE(host, IE, 0); in mmc_omap_cmd_timer()
634 disable_irq(host->irq); in mmc_omap_cmd_timer()
635 host->abort = 1; in mmc_omap_cmd_timer()
636 queue_work(host->mmc_omap_wq, &host->cmd_abort_work); in mmc_omap_cmd_timer()
638 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_cmd_timer()
643 mmc_omap_sg_to_buf(struct mmc_omap_host *host) in mmc_omap_sg_to_buf() argument
647 sg = host->data->sg + host->sg_idx; in mmc_omap_sg_to_buf()
648 host->buffer_bytes_left = sg->length; in mmc_omap_sg_to_buf()
649 host->buffer = sg_virt(sg); in mmc_omap_sg_to_buf()
650 if (host->buffer_bytes_left > host->total_bytes_left) in mmc_omap_sg_to_buf()
651 host->buffer_bytes_left = host->total_bytes_left; in mmc_omap_sg_to_buf()
657 struct mmc_omap_host *host = from_timer(host, t, clk_timer); in mmc_omap_clk_timer() local
659 mmc_omap_fclk_enable(host, 0); in mmc_omap_clk_timer()
664 mmc_omap_xfer_data(struct mmc_omap_host *host, int write) in mmc_omap_xfer_data() argument
668 if (host->buffer_bytes_left == 0) { in mmc_omap_xfer_data()
669 host->sg_idx++; in mmc_omap_xfer_data()
670 BUG_ON(host->sg_idx == host->sg_len); in mmc_omap_xfer_data()
671 mmc_omap_sg_to_buf(host); in mmc_omap_xfer_data()
674 if (n > host->buffer_bytes_left) in mmc_omap_xfer_data()
675 n = host->buffer_bytes_left; in mmc_omap_xfer_data()
680 host->buffer_bytes_left -= n; in mmc_omap_xfer_data()
681 host->total_bytes_left -= n; in mmc_omap_xfer_data()
682 host->data->bytes_xfered += n; in mmc_omap_xfer_data()
685 __raw_writesw(host->virt_base + OMAP_MMC_REG(host, DATA), in mmc_omap_xfer_data()
686 host->buffer, nwords); in mmc_omap_xfer_data()
688 __raw_readsw(host->virt_base + OMAP_MMC_REG(host, DATA), in mmc_omap_xfer_data()
689 host->buffer, nwords); in mmc_omap_xfer_data()
692 host->buffer += nwords; in mmc_omap_xfer_data()
696 static void mmc_omap_report_irq(struct mmc_omap_host *host, u16 status) in mmc_omap_report_irq() argument
710 dev_vdbg(mmc_dev(host->mmc), "%s\n", res); in mmc_omap_report_irq()
713 static void mmc_omap_report_irq(struct mmc_omap_host *host, u16 status) in mmc_omap_report_irq() argument
721 struct mmc_omap_host * host = (struct mmc_omap_host *)dev_id; in mmc_omap_irq() local
727 if (host->cmd == NULL && host->data == NULL) { in mmc_omap_irq()
728 status = OMAP_MMC_READ(host, STAT); in mmc_omap_irq()
729 dev_info(mmc_dev(host->slots[0]->mmc), in mmc_omap_irq()
732 OMAP_MMC_WRITE(host, STAT, status); in mmc_omap_irq()
733 OMAP_MMC_WRITE(host, IE, 0); in mmc_omap_irq()
743 while ((status = OMAP_MMC_READ(host, STAT)) != 0) { in mmc_omap_irq()
746 OMAP_MMC_WRITE(host, STAT, status); in mmc_omap_irq()
747 if (host->cmd != NULL) in mmc_omap_irq()
748 cmd = host->cmd->opcode; in mmc_omap_irq()
751 dev_dbg(mmc_dev(host->mmc), "MMC IRQ %04x (CMD %d): ", in mmc_omap_irq()
753 mmc_omap_report_irq(host, status); in mmc_omap_irq()
755 if (host->total_bytes_left) { in mmc_omap_irq()
758 mmc_omap_xfer_data(host, 0); in mmc_omap_irq()
760 mmc_omap_xfer_data(host, 1); in mmc_omap_irq()
767 dev_dbg(mmc_dev(host->mmc), "data timeout (CMD%d)\n", in mmc_omap_irq()
769 if (host->data) { in mmc_omap_irq()
770 host->data->error = -ETIMEDOUT; in mmc_omap_irq()
776 if (host->data) { in mmc_omap_irq()
777 host->data->error = -EILSEQ; in mmc_omap_irq()
778 dev_dbg(mmc_dev(host->mmc), in mmc_omap_irq()
780 host->total_bytes_left); in mmc_omap_irq()
783 dev_dbg(mmc_dev(host->mmc), "data CRC error\n"); in mmc_omap_irq()
789 if (host->cmd) { in mmc_omap_irq()
791 host->current_slot; in mmc_omap_irq()
794 dev_err(mmc_dev(host->mmc), in mmc_omap_irq()
797 host->cmd->error = -ETIMEDOUT; in mmc_omap_irq()
804 if (host->cmd) { in mmc_omap_irq()
805 dev_err(mmc_dev(host->mmc), in mmc_omap_irq()
807 cmd, host->cmd->arg); in mmc_omap_irq()
808 host->cmd->error = -EILSEQ; in mmc_omap_irq()
812 dev_err(mmc_dev(host->mmc), in mmc_omap_irq()
817 dev_dbg(mmc_dev(host->mmc), in mmc_omap_irq()
833 if (cmd_error && host->data) { in mmc_omap_irq()
834 del_timer(&host->cmd_abort_timer); in mmc_omap_irq()
835 host->abort = 1; in mmc_omap_irq()
836 OMAP_MMC_WRITE(host, IE, 0); in mmc_omap_irq()
837 disable_irq_nosync(host->irq); in mmc_omap_irq()
838 queue_work(host->mmc_omap_wq, &host->cmd_abort_work); in mmc_omap_irq()
842 if (end_command && host->cmd) in mmc_omap_irq()
843 mmc_omap_cmd_done(host, host->cmd); in mmc_omap_irq()
844 if (host->data != NULL) { in mmc_omap_irq()
846 mmc_omap_xfer_done(host, host->data); in mmc_omap_irq()
848 mmc_omap_end_of_data(host, host->data); in mmc_omap_irq()
857 struct mmc_omap_host *host = dev_get_drvdata(dev); in omap_mmc_notify_cover_event() local
858 struct mmc_omap_slot *slot = host->slots[num]; in omap_mmc_notify_cover_event()
860 BUG_ON(num >= host->nr_slots); in omap_mmc_notify_cover_event()
863 if (host->nr_slots == 0 || !host->slots[num]) in omap_mmc_notify_cover_event()
903 struct mmc_omap_host *host = priv; in mmc_omap_dma_callback() local
904 struct mmc_data *data = host->data; in mmc_omap_dma_callback()
909 mmc_omap_dma_done(host, data); in mmc_omap_dma_callback()
912 static inline void set_cmd_timeout(struct mmc_omap_host *host, struct mmc_request *req) in set_cmd_timeout() argument
916 reg = OMAP_MMC_READ(host, SDIO); in set_cmd_timeout()
918 OMAP_MMC_WRITE(host, SDIO, reg); in set_cmd_timeout()
920 OMAP_MMC_WRITE(host, CTO, 0xfd); in set_cmd_timeout()
923 static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req) in set_data_timeout() argument
928 cycle_ns = 1000000000 / host->current_slot->fclk_freq; in set_data_timeout()
933 reg = OMAP_MMC_READ(host, SDIO); in set_data_timeout()
939 OMAP_MMC_WRITE(host, SDIO, reg); in set_data_timeout()
940 OMAP_MMC_WRITE(host, DTO, timeout); in set_data_timeout()
944 mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req) in mmc_omap_prepare_data() argument
951 host->data = data; in mmc_omap_prepare_data()
953 OMAP_MMC_WRITE(host, BLEN, 0); in mmc_omap_prepare_data()
954 OMAP_MMC_WRITE(host, NBLK, 0); in mmc_omap_prepare_data()
955 OMAP_MMC_WRITE(host, BUF, 0); in mmc_omap_prepare_data()
956 host->dma_in_use = 0; in mmc_omap_prepare_data()
957 set_cmd_timeout(host, req); in mmc_omap_prepare_data()
963 OMAP_MMC_WRITE(host, NBLK, data->blocks - 1); in mmc_omap_prepare_data()
964 OMAP_MMC_WRITE(host, BLEN, block_size - 1); in mmc_omap_prepare_data()
965 set_data_timeout(host, req); in mmc_omap_prepare_data()
980 host->sg_idx = 0; in mmc_omap_prepare_data()
1001 c = host->dma_tx; in mmc_omap_prepare_data()
1002 bp = &host->dma_tx_burst; in mmc_omap_prepare_data()
1006 c = host->dma_rx; in mmc_omap_prepare_data()
1007 bp = &host->dma_rx_burst; in mmc_omap_prepare_data()
1018 .src_addr = host->phys_base + in mmc_omap_prepare_data()
1019 OMAP_MMC_REG(host, DATA), in mmc_omap_prepare_data()
1020 .dst_addr = host->phys_base + in mmc_omap_prepare_data()
1021 OMAP_MMC_REG(host, DATA), in mmc_omap_prepare_data()
1034 host->sg_len = dma_map_sg(c->device->dev, data->sg, sg_len, in mmc_omap_prepare_data()
1036 if (host->sg_len == 0) in mmc_omap_prepare_data()
1039 tx = dmaengine_prep_slave_sg(c, data->sg, host->sg_len, in mmc_omap_prepare_data()
1045 OMAP_MMC_WRITE(host, BUF, buf); in mmc_omap_prepare_data()
1048 tx->callback_param = host; in mmc_omap_prepare_data()
1050 host->brs_received = 0; in mmc_omap_prepare_data()
1051 host->dma_done = 0; in mmc_omap_prepare_data()
1052 host->dma_in_use = 1; in mmc_omap_prepare_data()
1058 OMAP_MMC_WRITE(host, BUF, 0x1f1f); in mmc_omap_prepare_data()
1059 host->total_bytes_left = data->blocks * block_size; in mmc_omap_prepare_data()
1060 host->sg_len = sg_len; in mmc_omap_prepare_data()
1061 mmc_omap_sg_to_buf(host); in mmc_omap_prepare_data()
1062 host->dma_in_use = 0; in mmc_omap_prepare_data()
1065 static void mmc_omap_start_request(struct mmc_omap_host *host, in mmc_omap_start_request() argument
1068 BUG_ON(host->mrq != NULL); in mmc_omap_start_request()
1070 host->mrq = req; in mmc_omap_start_request()
1073 mmc_omap_prepare_data(host, req); in mmc_omap_start_request()
1074 mmc_omap_start_command(host, req->cmd); in mmc_omap_start_request()
1075 if (host->dma_in_use) { in mmc_omap_start_request()
1076 struct dma_chan *c = host->data->flags & MMC_DATA_WRITE ? in mmc_omap_start_request()
1077 host->dma_tx : host->dma_rx; in mmc_omap_start_request()
1086 struct mmc_omap_host *host = slot->host; in mmc_omap_request() local
1089 spin_lock_irqsave(&host->slot_lock, flags); in mmc_omap_request()
1090 if (host->mmc != NULL) { in mmc_omap_request()
1093 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_request()
1096 host->mmc = mmc; in mmc_omap_request()
1097 spin_unlock_irqrestore(&host->slot_lock, flags); in mmc_omap_request()
1099 mmc_omap_start_request(host, req); in mmc_omap_request()
1105 struct mmc_omap_host *host; in mmc_omap_set_power() local
1107 host = slot->host; in mmc_omap_set_power()
1116 w = OMAP_MMC_READ(host, CON); in mmc_omap_set_power()
1117 OMAP_MMC_WRITE(host, CON, w | (1 << 11)); in mmc_omap_set_power()
1119 w = OMAP_MMC_READ(host, CON); in mmc_omap_set_power()
1120 OMAP_MMC_WRITE(host, CON, w & ~(1 << 11)); in mmc_omap_set_power()
1128 struct mmc_omap_host *host = slot->host; in mmc_omap_calc_divisor() local
1129 int func_clk_rate = clk_get_rate(host->fclk); in mmc_omap_calc_divisor()
1156 struct mmc_omap_host *host = slot->host; in mmc_omap_set_ios() local
1179 mmc_omap_fclk_enable(host, 1); in mmc_omap_set_ios()
1200 OMAP_MMC_WRITE(host, CON, dsor); in mmc_omap_set_ios()
1207 OMAP_MMC_WRITE(host, IE, 0); in mmc_omap_set_ios()
1208 OMAP_MMC_WRITE(host, STAT, 0xffff); in mmc_omap_set_ios()
1209 OMAP_MMC_WRITE(host, CMD, 1 << 7); in mmc_omap_set_ios()
1210 while (usecs > 0 && (OMAP_MMC_READ(host, STAT) & 1) == 0) { in mmc_omap_set_ios()
1214 OMAP_MMC_WRITE(host, STAT, 1); in mmc_omap_set_ios()
1226 static int mmc_omap_new_slot(struct mmc_omap_host *host, int id) in mmc_omap_new_slot() argument
1232 mmc = mmc_alloc_host(sizeof(struct mmc_omap_slot), host->dev); in mmc_omap_new_slot()
1237 slot->host = host; in mmc_omap_new_slot()
1241 slot->pdata = &host->pdata->slots[id]; in mmc_omap_new_slot()
1243 host->slots[id] = slot; in mmc_omap_new_slot()
1246 if (host->pdata->slots[id].wires >= 4) in mmc_omap_new_slot()
1256 if (host->pdata->max_freq) in mmc_omap_new_slot()
1257 mmc->f_max = min(host->pdata->max_freq, mmc->f_max); in mmc_omap_new_slot()
1317 flush_workqueue(slot->host->mmc_omap_wq); in mmc_omap_remove_slot()
1326 struct mmc_omap_host *host = NULL; in mmc_omap_probe() local
1340 host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host), in mmc_omap_probe()
1342 if (host == NULL) in mmc_omap_probe()
1350 host->virt_base = devm_ioremap_resource(&pdev->dev, res); in mmc_omap_probe()
1351 if (IS_ERR(host->virt_base)) in mmc_omap_probe()
1352 return PTR_ERR(host->virt_base); in mmc_omap_probe()
1354 INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work); in mmc_omap_probe()
1355 INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work); in mmc_omap_probe()
1357 INIT_WORK(&host->cmd_abort_work, mmc_omap_abort_command); in mmc_omap_probe()
1358 timer_setup(&host->cmd_abort_timer, mmc_omap_cmd_timer, 0); in mmc_omap_probe()
1360 spin_lock_init(&host->clk_lock); in mmc_omap_probe()
1361 timer_setup(&host->clk_timer, mmc_omap_clk_timer, 0); in mmc_omap_probe()
1363 spin_lock_init(&host->dma_lock); in mmc_omap_probe()
1364 spin_lock_init(&host->slot_lock); in mmc_omap_probe()
1365 init_waitqueue_head(&host->slot_wq); in mmc_omap_probe()
1367 host->pdata = pdata; in mmc_omap_probe()
1368 host->features = host->pdata->slots[0].features; in mmc_omap_probe()
1369 host->dev = &pdev->dev; in mmc_omap_probe()
1370 platform_set_drvdata(pdev, host); in mmc_omap_probe()
1372 host->id = pdev->id; in mmc_omap_probe()
1373 host->irq = irq; in mmc_omap_probe()
1374 host->phys_base = res->start; in mmc_omap_probe()
1375 host->iclk = clk_get(&pdev->dev, "ick"); in mmc_omap_probe()
1376 if (IS_ERR(host->iclk)) in mmc_omap_probe()
1377 return PTR_ERR(host->iclk); in mmc_omap_probe()
1378 clk_enable(host->iclk); in mmc_omap_probe()
1380 host->fclk = clk_get(&pdev->dev, "fck"); in mmc_omap_probe()
1381 if (IS_ERR(host->fclk)) { in mmc_omap_probe()
1382 ret = PTR_ERR(host->fclk); in mmc_omap_probe()
1386 host->dma_tx_burst = -1; in mmc_omap_probe()
1387 host->dma_rx_burst = -1; in mmc_omap_probe()
1389 host->dma_tx = dma_request_chan(&pdev->dev, "tx"); in mmc_omap_probe()
1390 if (IS_ERR(host->dma_tx)) { in mmc_omap_probe()
1391 ret = PTR_ERR(host->dma_tx); in mmc_omap_probe()
1393 clk_put(host->fclk); in mmc_omap_probe()
1397 host->dma_tx = NULL; in mmc_omap_probe()
1398 dev_warn(host->dev, "TX DMA channel request failed\n"); in mmc_omap_probe()
1401 host->dma_rx = dma_request_chan(&pdev->dev, "rx"); in mmc_omap_probe()
1402 if (IS_ERR(host->dma_rx)) { in mmc_omap_probe()
1403 ret = PTR_ERR(host->dma_rx); in mmc_omap_probe()
1405 if (host->dma_tx) in mmc_omap_probe()
1406 dma_release_channel(host->dma_tx); in mmc_omap_probe()
1407 clk_put(host->fclk); in mmc_omap_probe()
1411 host->dma_rx = NULL; in mmc_omap_probe()
1412 dev_warn(host->dev, "RX DMA channel request failed\n"); in mmc_omap_probe()
1415 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host); in mmc_omap_probe()
1425 host->nr_slots = pdata->nr_slots; in mmc_omap_probe()
1426 host->reg_shift = (mmc_omap7xx() ? 1 : 2); in mmc_omap_probe()
1428 host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0); in mmc_omap_probe()
1429 if (!host->mmc_omap_wq) { in mmc_omap_probe()
1435 ret = mmc_omap_new_slot(host, i); in mmc_omap_probe()
1438 mmc_omap_remove_slot(host->slots[i]); in mmc_omap_probe()
1447 destroy_workqueue(host->mmc_omap_wq); in mmc_omap_probe()
1452 free_irq(host->irq, host); in mmc_omap_probe()
1454 if (host->dma_tx) in mmc_omap_probe()
1455 dma_release_channel(host->dma_tx); in mmc_omap_probe()
1456 if (host->dma_rx) in mmc_omap_probe()
1457 dma_release_channel(host->dma_rx); in mmc_omap_probe()
1458 clk_put(host->fclk); in mmc_omap_probe()
1460 clk_disable(host->iclk); in mmc_omap_probe()
1461 clk_put(host->iclk); in mmc_omap_probe()
1467 struct mmc_omap_host *host = platform_get_drvdata(pdev); in mmc_omap_remove() local
1470 BUG_ON(host == NULL); in mmc_omap_remove()
1472 for (i = 0; i < host->nr_slots; i++) in mmc_omap_remove()
1473 mmc_omap_remove_slot(host->slots[i]); in mmc_omap_remove()
1475 if (host->pdata->cleanup) in mmc_omap_remove()
1476 host->pdata->cleanup(&pdev->dev); in mmc_omap_remove()
1478 mmc_omap_fclk_enable(host, 0); in mmc_omap_remove()
1479 free_irq(host->irq, host); in mmc_omap_remove()
1480 clk_put(host->fclk); in mmc_omap_remove()
1481 clk_disable(host->iclk); in mmc_omap_remove()
1482 clk_put(host->iclk); in mmc_omap_remove()
1484 if (host->dma_tx) in mmc_omap_remove()
1485 dma_release_channel(host->dma_tx); in mmc_omap_remove()
1486 if (host->dma_rx) in mmc_omap_remove()
1487 dma_release_channel(host->dma_rx); in mmc_omap_remove()
1489 destroy_workqueue(host->mmc_omap_wq); in mmc_omap_remove()