Lines Matching refs:host

114 static void tifm_sd_read_fifo(struct tifm_sd *host, struct page *pg,  in tifm_sd_read_fifo()  argument
117 struct tifm_dev *sock = host->dev; in tifm_sd_read_fifo()
122 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_read_fifo()
123 buf[pos++] = host->bounce_buf_data[0]; in tifm_sd_read_fifo()
124 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_read_fifo()
131 host->bounce_buf_data[0] = (val >> 8) & 0xff; in tifm_sd_read_fifo()
132 host->cmd_flags |= DATA_CARRY; in tifm_sd_read_fifo()
140 static void tifm_sd_write_fifo(struct tifm_sd *host, struct page *pg, in tifm_sd_write_fifo() argument
143 struct tifm_dev *sock = host->dev; in tifm_sd_write_fifo()
148 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_write_fifo()
149 val = host->bounce_buf_data[0] | ((buf[pos++] << 8) & 0xff00); in tifm_sd_write_fifo()
151 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_write_fifo()
157 host->bounce_buf_data[0] = val & 0xff; in tifm_sd_write_fifo()
158 host->cmd_flags |= DATA_CARRY; in tifm_sd_write_fifo()
167 static void tifm_sd_transfer_data(struct tifm_sd *host) in tifm_sd_transfer_data() argument
169 struct mmc_data *r_data = host->req->cmd->data; in tifm_sd_transfer_data()
175 if (host->sg_pos == host->sg_len) in tifm_sd_transfer_data()
178 cnt = sg[host->sg_pos].length - host->block_pos; in tifm_sd_transfer_data()
180 host->block_pos = 0; in tifm_sd_transfer_data()
181 host->sg_pos++; in tifm_sd_transfer_data()
182 if (host->sg_pos == host->sg_len) { in tifm_sd_transfer_data()
184 && (host->cmd_flags & DATA_CARRY)) in tifm_sd_transfer_data()
185 writel(host->bounce_buf_data[0], in tifm_sd_transfer_data()
186 host->dev->addr in tifm_sd_transfer_data()
191 cnt = sg[host->sg_pos].length; in tifm_sd_transfer_data()
193 off = sg[host->sg_pos].offset + host->block_pos; in tifm_sd_transfer_data()
195 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); in tifm_sd_transfer_data()
202 tifm_sd_read_fifo(host, pg, p_off, p_cnt); in tifm_sd_transfer_data()
204 tifm_sd_write_fifo(host, pg, p_off, p_cnt); in tifm_sd_transfer_data()
207 host->block_pos += p_cnt; in tifm_sd_transfer_data()
224 static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data) in tifm_sd_bounce_block() argument
232 dev_dbg(&host->dev->dev, "bouncing block\n"); in tifm_sd_bounce_block()
234 cnt = sg[host->sg_pos].length - host->block_pos; in tifm_sd_bounce_block()
236 host->block_pos = 0; in tifm_sd_bounce_block()
237 host->sg_pos++; in tifm_sd_bounce_block()
238 if (host->sg_pos == host->sg_len) in tifm_sd_bounce_block()
240 cnt = sg[host->sg_pos].length; in tifm_sd_bounce_block()
242 off = sg[host->sg_pos].offset + host->block_pos; in tifm_sd_bounce_block()
244 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); in tifm_sd_bounce_block()
251 tifm_sd_copy_page(sg_page(&host->bounce_buf), in tifm_sd_bounce_block()
255 tifm_sd_copy_page(pg, p_off, sg_page(&host->bounce_buf), in tifm_sd_bounce_block()
259 host->block_pos += p_cnt; in tifm_sd_bounce_block()
263 static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data) in tifm_sd_set_dma_data() argument
265 struct tifm_dev *sock = host->dev; in tifm_sd_set_dma_data()
271 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
274 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_set_dma_data()
275 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_set_dma_data()
277 tifm_sd_bounce_block(host, r_data); in tifm_sd_set_dma_data()
279 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
283 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]) - host->block_pos; in tifm_sd_set_dma_data()
285 host->block_pos = 0; in tifm_sd_set_dma_data()
286 host->sg_pos++; in tifm_sd_set_dma_data()
287 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
289 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]); in tifm_sd_set_dma_data()
294 dma_off = host->block_pos; in tifm_sd_set_dma_data()
295 host->block_pos += dma_blk_cnt * r_data->blksz; in tifm_sd_set_dma_data()
298 dma_off = host->block_pos; in tifm_sd_set_dma_data()
299 host->block_pos += t_size; in tifm_sd_set_dma_data()
303 sg = &r_data->sg[host->sg_pos]; in tifm_sd_set_dma_data()
307 tifm_sd_bounce_block(host, r_data); in tifm_sd_set_dma_data()
310 host->cmd_flags |= DATA_CARRY; in tifm_sd_set_dma_data()
312 sg = &host->bounce_buf; in tifm_sd_set_dma_data()
372 static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd) in tifm_sd_exec() argument
374 struct tifm_dev *sock = host->dev; in tifm_sd_exec()
377 if (host->open_drain) in tifm_sd_exec()
403 static void tifm_sd_check_status(struct tifm_sd *host) in tifm_sd_check_status() argument
405 struct tifm_dev *sock = host->dev; in tifm_sd_check_status()
406 struct mmc_command *cmd = host->req->cmd; in tifm_sd_check_status()
411 if (!(host->cmd_flags & CMD_READY)) in tifm_sd_check_status()
416 if ((host->cmd_flags & SCMD_ACTIVE) in tifm_sd_check_status()
417 && !(host->cmd_flags & SCMD_READY)) in tifm_sd_check_status()
423 if (!(host->cmd_flags & BRS_READY)) in tifm_sd_check_status()
426 if (!(host->no_dma || (host->cmd_flags & FIFO_READY))) in tifm_sd_check_status()
430 if (host->req->stop) { in tifm_sd_check_status()
431 if (!(host->cmd_flags & SCMD_ACTIVE)) { in tifm_sd_check_status()
432 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_check_status()
438 tifm_sd_exec(host, host->req->stop); in tifm_sd_check_status()
441 if (!(host->cmd_flags & SCMD_READY) in tifm_sd_check_status()
442 || (host->cmd_flags & CARD_BUSY)) in tifm_sd_check_status()
451 if (host->cmd_flags & CARD_BUSY) in tifm_sd_check_status()
459 if (host->req->stop) { in tifm_sd_check_status()
460 if (!(host->cmd_flags & SCMD_ACTIVE)) { in tifm_sd_check_status()
461 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_check_status()
462 tifm_sd_exec(host, host->req->stop); in tifm_sd_check_status()
465 if (!(host->cmd_flags & SCMD_READY)) in tifm_sd_check_status()
472 tasklet_schedule(&host->finish_tasklet); in tifm_sd_check_status()
478 struct tifm_sd *host; in tifm_sd_data_event() local
483 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock)); in tifm_sd_data_event()
486 fifo_status, host->cmd_flags); in tifm_sd_data_event()
488 if (host->req) { in tifm_sd_data_event()
489 r_data = host->req->cmd->data; in tifm_sd_data_event()
492 if (tifm_sd_set_dma_data(host, r_data)) { in tifm_sd_data_event()
493 host->cmd_flags |= FIFO_READY; in tifm_sd_data_event()
494 tifm_sd_check_status(host); in tifm_sd_data_event()
506 struct tifm_sd *host; in tifm_sd_card_event() local
513 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock)); in tifm_sd_card_event()
516 host_status, host->cmd_flags); in tifm_sd_card_event()
518 if (host->req) { in tifm_sd_card_event()
519 cmd = host->req->cmd; in tifm_sd_card_event()
540 if (host->req->stop) { in tifm_sd_card_event()
541 if (host->cmd_flags & SCMD_ACTIVE) { in tifm_sd_card_event()
542 host->req->stop->error = cmd_error; in tifm_sd_card_event()
543 host->cmd_flags |= SCMD_READY; in tifm_sd_card_event()
546 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_card_event()
547 tifm_sd_exec(host, host->req->stop); in tifm_sd_card_event()
554 if (!(host->cmd_flags & CMD_READY)) { in tifm_sd_card_event()
555 host->cmd_flags |= CMD_READY; in tifm_sd_card_event()
557 } else if (host->cmd_flags & SCMD_ACTIVE) { in tifm_sd_card_event()
558 host->cmd_flags |= SCMD_READY; in tifm_sd_card_event()
559 tifm_sd_fetch_resp(host->req->stop, in tifm_sd_card_event()
564 host->cmd_flags |= BRS_READY; in tifm_sd_card_event()
567 if (host->no_dma && cmd->data) { in tifm_sd_card_event()
575 tifm_sd_transfer_data(host); in tifm_sd_card_event()
582 host->cmd_flags &= ~CARD_BUSY; in tifm_sd_card_event()
584 host->cmd_flags |= CARD_BUSY; in tifm_sd_card_event()
586 tifm_sd_check_status(host); in tifm_sd_card_event()
593 static void tifm_sd_set_data_timeout(struct tifm_sd *host, in tifm_sd_set_data_timeout() argument
596 struct tifm_dev *sock = host->dev; in tifm_sd_set_data_timeout()
603 ((1000000000UL / host->clk_freq) * host->clk_div); in tifm_sd_set_data_timeout()
623 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_request() local
624 struct tifm_dev *sock = host->dev; in tifm_sd_request()
629 if (host->eject) { in tifm_sd_request()
634 if (host->req) { in tifm_sd_request()
641 host->cmd_flags = 0; in tifm_sd_request()
642 host->block_pos = 0; in tifm_sd_request()
643 host->sg_pos = 0; in tifm_sd_request()
646 host->no_dma = 1; in tifm_sd_request()
648 host->no_dma = no_dma ? 1 : 0; in tifm_sd_request()
651 tifm_sd_set_data_timeout(host, r_data); in tifm_sd_request()
658 if (host->no_dma) { in tifm_sd_request()
666 host->sg_len = r_data->sg_len; in tifm_sd_request()
668 sg_init_one(&host->bounce_buf, host->bounce_buf_data, in tifm_sd_request()
671 if(1 != tifm_map_sg(sock, &host->bounce_buf, 1, in tifm_sd_request()
680 host->sg_len = tifm_map_sg(sock, r_data->sg, in tifm_sd_request()
686 if (host->sg_len < 1) { in tifm_sd_request()
689 tifm_unmap_sg(sock, &host->bounce_buf, 1, in tifm_sd_request()
713 tifm_sd_set_dma_data(host, r_data); in tifm_sd_request()
722 host->req = mrq; in tifm_sd_request()
723 mod_timer(&host->timer, jiffies + host->timeout_jiffies); in tifm_sd_request()
726 tifm_sd_exec(host, mrq->cmd); in tifm_sd_request()
737 struct tifm_sd *host = (struct tifm_sd*)data; in tifm_sd_end_cmd() local
738 struct tifm_dev *sock = host->dev; in tifm_sd_end_cmd()
746 del_timer(&host->timer); in tifm_sd_end_cmd()
747 mrq = host->req; in tifm_sd_end_cmd()
748 host->req = NULL; in tifm_sd_end_cmd()
759 if (host->no_dma) { in tifm_sd_end_cmd()
764 tifm_unmap_sg(sock, &host->bounce_buf, 1, in tifm_sd_end_cmd()
788 struct tifm_sd *host = (struct tifm_sd*)data; in tifm_sd_abort() local
792 dev_name(&host->dev->dev), host->req->cmd->opcode, host->cmd_flags); in tifm_sd_abort()
794 tifm_eject(host->dev); in tifm_sd_abort()
799 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_ios() local
800 struct tifm_dev *sock = host->dev; in tifm_sd_ios()
834 host->clk_freq = 20000000; in tifm_sd_ios()
835 host->clk_div = clk_div1; in tifm_sd_ios()
840 host->clk_freq = 24000000; in tifm_sd_ios()
841 host->clk_div = clk_div2; in tifm_sd_ios()
847 host->clk_div = 0; in tifm_sd_ios()
849 host->clk_div &= TIFM_MMCSD_CLKMASK; in tifm_sd_ios()
850 writel(host->clk_div in tifm_sd_ios()
855 host->open_drain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN); in tifm_sd_ios()
867 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_ro() local
868 struct tifm_dev *sock = host->dev; in tifm_sd_ro()
884 static int tifm_sd_initialize_host(struct tifm_sd *host) in tifm_sd_initialize_host() argument
888 struct tifm_dev *sock = host->dev; in tifm_sd_initialize_host()
892 host->clk_div = 61; in tifm_sd_initialize_host()
893 host->clk_freq = 20000000; in tifm_sd_initialize_host()
895 writel(host->clk_div | TIFM_MMCSD_POWER, in tifm_sd_initialize_host()
914 writel(host->clk_div | TIFM_MMCSD_POWER, in tifm_sd_initialize_host()
950 struct tifm_sd *host; in tifm_sd_probe() local
964 host = mmc_priv(mmc); in tifm_sd_probe()
966 host->dev = sock; in tifm_sd_probe()
967 host->timeout_jiffies = msecs_to_jiffies(1000); in tifm_sd_probe()
969 tasklet_init(&host->finish_tasklet, tifm_sd_end_cmd, in tifm_sd_probe()
970 (unsigned long)host); in tifm_sd_probe()
971 setup_timer(&host->timer, tifm_sd_abort, (unsigned long)host); in tifm_sd_probe()
987 rc = tifm_sd_initialize_host(host); in tifm_sd_probe()
1001 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_remove() local
1005 host->eject = 1; in tifm_sd_remove()
1010 tasklet_kill(&host->finish_tasklet); in tifm_sd_remove()
1013 if (host->req) { in tifm_sd_remove()
1017 host->req->cmd->error = -ENOMEDIUM; in tifm_sd_remove()
1018 if (host->req->stop) in tifm_sd_remove()
1019 host->req->stop->error = -ENOMEDIUM; in tifm_sd_remove()
1020 tasklet_schedule(&host->finish_tasklet); in tifm_sd_remove()
1039 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_resume() local
1042 rc = tifm_sd_initialize_host(host); in tifm_sd_resume()
1046 host->eject = 1; in tifm_sd_resume()