Lines Matching refs:host
113 static void tifm_sd_read_fifo(struct tifm_sd *host, struct page *pg, in tifm_sd_read_fifo() argument
116 struct tifm_dev *sock = host->dev; in tifm_sd_read_fifo()
121 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_read_fifo()
122 buf[pos++] = host->bounce_buf_data[0]; in tifm_sd_read_fifo()
123 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_read_fifo()
130 host->bounce_buf_data[0] = (val >> 8) & 0xff; in tifm_sd_read_fifo()
131 host->cmd_flags |= DATA_CARRY; in tifm_sd_read_fifo()
139 static void tifm_sd_write_fifo(struct tifm_sd *host, struct page *pg, in tifm_sd_write_fifo() argument
142 struct tifm_dev *sock = host->dev; in tifm_sd_write_fifo()
147 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_write_fifo()
148 val = host->bounce_buf_data[0] | ((buf[pos++] << 8) & 0xff00); in tifm_sd_write_fifo()
150 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_write_fifo()
156 host->bounce_buf_data[0] = val & 0xff; in tifm_sd_write_fifo()
157 host->cmd_flags |= DATA_CARRY; in tifm_sd_write_fifo()
166 static void tifm_sd_transfer_data(struct tifm_sd *host) in tifm_sd_transfer_data() argument
168 struct mmc_data *r_data = host->req->cmd->data; in tifm_sd_transfer_data()
174 if (host->sg_pos == host->sg_len) in tifm_sd_transfer_data()
177 cnt = sg[host->sg_pos].length - host->block_pos; in tifm_sd_transfer_data()
179 host->block_pos = 0; in tifm_sd_transfer_data()
180 host->sg_pos++; in tifm_sd_transfer_data()
181 if (host->sg_pos == host->sg_len) { in tifm_sd_transfer_data()
183 && (host->cmd_flags & DATA_CARRY)) in tifm_sd_transfer_data()
184 writel(host->bounce_buf_data[0], in tifm_sd_transfer_data()
185 host->dev->addr in tifm_sd_transfer_data()
190 cnt = sg[host->sg_pos].length; in tifm_sd_transfer_data()
192 off = sg[host->sg_pos].offset + host->block_pos; in tifm_sd_transfer_data()
194 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); in tifm_sd_transfer_data()
201 tifm_sd_read_fifo(host, pg, p_off, p_cnt); in tifm_sd_transfer_data()
203 tifm_sd_write_fifo(host, pg, p_off, p_cnt); in tifm_sd_transfer_data()
206 host->block_pos += p_cnt; in tifm_sd_transfer_data()
223 static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data) in tifm_sd_bounce_block() argument
231 dev_dbg(&host->dev->dev, "bouncing block\n"); in tifm_sd_bounce_block()
233 cnt = sg[host->sg_pos].length - host->block_pos; in tifm_sd_bounce_block()
235 host->block_pos = 0; in tifm_sd_bounce_block()
236 host->sg_pos++; in tifm_sd_bounce_block()
237 if (host->sg_pos == host->sg_len) in tifm_sd_bounce_block()
239 cnt = sg[host->sg_pos].length; in tifm_sd_bounce_block()
241 off = sg[host->sg_pos].offset + host->block_pos; in tifm_sd_bounce_block()
243 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); in tifm_sd_bounce_block()
250 tifm_sd_copy_page(sg_page(&host->bounce_buf), in tifm_sd_bounce_block()
254 tifm_sd_copy_page(pg, p_off, sg_page(&host->bounce_buf), in tifm_sd_bounce_block()
258 host->block_pos += p_cnt; in tifm_sd_bounce_block()
262 static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data) in tifm_sd_set_dma_data() argument
264 struct tifm_dev *sock = host->dev; in tifm_sd_set_dma_data()
269 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
272 if (host->cmd_flags & DATA_CARRY) { in tifm_sd_set_dma_data()
273 host->cmd_flags &= ~DATA_CARRY; in tifm_sd_set_dma_data()
274 tifm_sd_bounce_block(host, r_data); in tifm_sd_set_dma_data()
275 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
279 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]) - host->block_pos; in tifm_sd_set_dma_data()
281 host->block_pos = 0; in tifm_sd_set_dma_data()
282 host->sg_pos++; in tifm_sd_set_dma_data()
283 if (host->sg_pos == host->sg_len) in tifm_sd_set_dma_data()
285 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]); in tifm_sd_set_dma_data()
290 dma_off = host->block_pos; in tifm_sd_set_dma_data()
291 host->block_pos += dma_blk_cnt * r_data->blksz; in tifm_sd_set_dma_data()
294 dma_off = host->block_pos; in tifm_sd_set_dma_data()
295 host->block_pos += t_size; in tifm_sd_set_dma_data()
299 sg = &r_data->sg[host->sg_pos]; in tifm_sd_set_dma_data()
302 tifm_sd_bounce_block(host, r_data); in tifm_sd_set_dma_data()
304 host->cmd_flags |= DATA_CARRY; in tifm_sd_set_dma_data()
306 sg = &host->bounce_buf; in tifm_sd_set_dma_data()
367 static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd) in tifm_sd_exec() argument
369 struct tifm_dev *sock = host->dev; in tifm_sd_exec()
372 if (host->open_drain) in tifm_sd_exec()
398 static void tifm_sd_check_status(struct tifm_sd *host) in tifm_sd_check_status() argument
400 struct tifm_dev *sock = host->dev; in tifm_sd_check_status()
401 struct mmc_command *cmd = host->req->cmd; in tifm_sd_check_status()
406 if (!(host->cmd_flags & CMD_READY)) in tifm_sd_check_status()
411 if ((host->cmd_flags & SCMD_ACTIVE) in tifm_sd_check_status()
412 && !(host->cmd_flags & SCMD_READY)) in tifm_sd_check_status()
418 if (!(host->cmd_flags & BRS_READY)) in tifm_sd_check_status()
421 if (!(host->no_dma || (host->cmd_flags & FIFO_READY))) in tifm_sd_check_status()
425 if (host->req->stop) { in tifm_sd_check_status()
426 if (!(host->cmd_flags & SCMD_ACTIVE)) { in tifm_sd_check_status()
427 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_check_status()
433 tifm_sd_exec(host, host->req->stop); in tifm_sd_check_status()
436 if (!(host->cmd_flags & SCMD_READY) in tifm_sd_check_status()
437 || (host->cmd_flags & CARD_BUSY)) in tifm_sd_check_status()
446 if (host->cmd_flags & CARD_BUSY) in tifm_sd_check_status()
454 if (host->req->stop) { in tifm_sd_check_status()
455 if (!(host->cmd_flags & SCMD_ACTIVE)) { in tifm_sd_check_status()
456 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_check_status()
457 tifm_sd_exec(host, host->req->stop); in tifm_sd_check_status()
460 if (!(host->cmd_flags & SCMD_READY)) in tifm_sd_check_status()
467 queue_work(system_bh_wq, &host->finish_bh_work); in tifm_sd_check_status()
473 struct tifm_sd *host; in tifm_sd_data_event() local
478 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock)); in tifm_sd_data_event()
481 fifo_status, host->cmd_flags); in tifm_sd_data_event()
483 if (host->req) { in tifm_sd_data_event()
484 r_data = host->req->cmd->data; in tifm_sd_data_event()
487 if (tifm_sd_set_dma_data(host, r_data)) { in tifm_sd_data_event()
488 host->cmd_flags |= FIFO_READY; in tifm_sd_data_event()
489 tifm_sd_check_status(host); in tifm_sd_data_event()
501 struct tifm_sd *host; in tifm_sd_card_event() local
507 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock)); in tifm_sd_card_event()
510 host_status, host->cmd_flags); in tifm_sd_card_event()
512 if (host->req) { in tifm_sd_card_event()
513 cmd = host->req->cmd; in tifm_sd_card_event()
534 if (host->req->stop) { in tifm_sd_card_event()
535 if (host->cmd_flags & SCMD_ACTIVE) { in tifm_sd_card_event()
536 host->req->stop->error = cmd_error; in tifm_sd_card_event()
537 host->cmd_flags |= SCMD_READY; in tifm_sd_card_event()
540 host->cmd_flags |= SCMD_ACTIVE; in tifm_sd_card_event()
541 tifm_sd_exec(host, host->req->stop); in tifm_sd_card_event()
548 if (!(host->cmd_flags & CMD_READY)) { in tifm_sd_card_event()
549 host->cmd_flags |= CMD_READY; in tifm_sd_card_event()
551 } else if (host->cmd_flags & SCMD_ACTIVE) { in tifm_sd_card_event()
552 host->cmd_flags |= SCMD_READY; in tifm_sd_card_event()
553 tifm_sd_fetch_resp(host->req->stop, in tifm_sd_card_event()
558 host->cmd_flags |= BRS_READY; in tifm_sd_card_event()
561 if (host->no_dma && cmd->data) { in tifm_sd_card_event()
568 tifm_sd_transfer_data(host); in tifm_sd_card_event()
574 host->cmd_flags &= ~CARD_BUSY; in tifm_sd_card_event()
576 host->cmd_flags |= CARD_BUSY; in tifm_sd_card_event()
578 tifm_sd_check_status(host); in tifm_sd_card_event()
585 static void tifm_sd_set_data_timeout(struct tifm_sd *host, in tifm_sd_set_data_timeout() argument
588 struct tifm_dev *sock = host->dev; in tifm_sd_set_data_timeout()
595 ((1000000000UL / host->clk_freq) * host->clk_div); in tifm_sd_set_data_timeout()
615 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_request() local
616 struct tifm_dev *sock = host->dev; in tifm_sd_request()
621 if (host->eject) { in tifm_sd_request()
626 if (host->req) { in tifm_sd_request()
633 host->cmd_flags = 0; in tifm_sd_request()
634 host->block_pos = 0; in tifm_sd_request()
635 host->sg_pos = 0; in tifm_sd_request()
638 host->no_dma = 1; in tifm_sd_request()
640 host->no_dma = no_dma ? 1 : 0; in tifm_sd_request()
643 tifm_sd_set_data_timeout(host, r_data); in tifm_sd_request()
650 if (host->no_dma) { in tifm_sd_request()
658 host->sg_len = r_data->sg_len; in tifm_sd_request()
660 sg_init_one(&host->bounce_buf, host->bounce_buf_data, in tifm_sd_request()
663 if(1 != tifm_map_sg(sock, &host->bounce_buf, 1, in tifm_sd_request()
672 host->sg_len = tifm_map_sg(sock, r_data->sg, in tifm_sd_request()
678 if (host->sg_len < 1) { in tifm_sd_request()
681 tifm_unmap_sg(sock, &host->bounce_buf, 1, in tifm_sd_request()
705 tifm_sd_set_dma_data(host, r_data); in tifm_sd_request()
714 host->req = mrq; in tifm_sd_request()
715 mod_timer(&host->timer, jiffies + host->timeout_jiffies); in tifm_sd_request()
718 tifm_sd_exec(host, mrq->cmd); in tifm_sd_request()
729 struct tifm_sd *host = from_work(host, t, finish_bh_work); in tifm_sd_end_cmd() local
730 struct tifm_dev *sock = host->dev; in tifm_sd_end_cmd()
738 del_timer(&host->timer); in tifm_sd_end_cmd()
739 mrq = host->req; in tifm_sd_end_cmd()
740 host->req = NULL; in tifm_sd_end_cmd()
751 if (host->no_dma) { in tifm_sd_end_cmd()
756 tifm_unmap_sg(sock, &host->bounce_buf, 1, in tifm_sd_end_cmd()
780 struct tifm_sd *host = from_timer(host, t, timer); in tifm_sd_abort() local
784 dev_name(&host->dev->dev), host->req->cmd->opcode, host->cmd_flags); in tifm_sd_abort()
786 tifm_eject(host->dev); in tifm_sd_abort()
791 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_ios() local
792 struct tifm_dev *sock = host->dev; in tifm_sd_ios()
826 host->clk_freq = 20000000; in tifm_sd_ios()
827 host->clk_div = clk_div1; in tifm_sd_ios()
832 host->clk_freq = 24000000; in tifm_sd_ios()
833 host->clk_div = clk_div2; in tifm_sd_ios()
839 host->clk_div = 0; in tifm_sd_ios()
841 host->clk_div &= TIFM_MMCSD_CLKMASK; in tifm_sd_ios()
842 writel(host->clk_div in tifm_sd_ios()
847 host->open_drain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN); in tifm_sd_ios()
859 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_ro() local
860 struct tifm_dev *sock = host->dev; in tifm_sd_ro()
876 static int tifm_sd_initialize_host(struct tifm_sd *host) in tifm_sd_initialize_host() argument
880 struct tifm_dev *sock = host->dev; in tifm_sd_initialize_host()
883 host->clk_div = 61; in tifm_sd_initialize_host()
884 host->clk_freq = 20000000; in tifm_sd_initialize_host()
886 writel(host->clk_div | TIFM_MMCSD_POWER, in tifm_sd_initialize_host()
905 writel(host->clk_div | TIFM_MMCSD_POWER, in tifm_sd_initialize_host()
940 struct tifm_sd *host; in tifm_sd_probe() local
954 host = mmc_priv(mmc); in tifm_sd_probe()
956 host->dev = sock; in tifm_sd_probe()
957 host->timeout_jiffies = msecs_to_jiffies(TIFM_MMCSD_REQ_TIMEOUT_MS); in tifm_sd_probe()
964 INIT_WORK(&host->finish_bh_work, tifm_sd_end_cmd); in tifm_sd_probe()
965 timer_setup(&host->timer, tifm_sd_abort, 0); in tifm_sd_probe()
981 rc = tifm_sd_initialize_host(host); in tifm_sd_probe()
995 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_remove() local
999 host->eject = 1; in tifm_sd_remove()
1003 cancel_work_sync(&host->finish_bh_work); in tifm_sd_remove()
1006 if (host->req) { in tifm_sd_remove()
1010 host->req->cmd->error = -ENOMEDIUM; in tifm_sd_remove()
1011 if (host->req->stop) in tifm_sd_remove()
1012 host->req->stop->error = -ENOMEDIUM; in tifm_sd_remove()
1013 queue_work(system_bh_wq, &host->finish_bh_work); in tifm_sd_remove()
1032 struct tifm_sd *host = mmc_priv(mmc); in tifm_sd_resume() local
1035 rc = tifm_sd_initialize_host(host); in tifm_sd_resume()
1039 host->eject = 1; in tifm_sd_resume()