Lines Matching defs:host
12 #include <linux/mmc/host.h>
111 /* for some reason, host won't respond correctly to readw/writew */
112 static void tifm_sd_read_fifo(struct tifm_sd *host, struct page *pg,
115 struct tifm_dev *sock = host->dev;
120 if (host->cmd_flags & DATA_CARRY) {
121 buf[pos++] = host->bounce_buf_data[0];
122 host->cmd_flags &= ~DATA_CARRY;
129 host->bounce_buf_data[0] = (val >> 8) & 0xff;
130 host->cmd_flags |= DATA_CARRY;
138 static void tifm_sd_write_fifo(struct tifm_sd *host, struct page *pg,
141 struct tifm_dev *sock = host->dev;
146 if (host->cmd_flags & DATA_CARRY) {
147 val = host->bounce_buf_data[0] | ((buf[pos++] << 8) & 0xff00);
149 host->cmd_flags &= ~DATA_CARRY;
155 host->bounce_buf_data[0] = val & 0xff;
156 host->cmd_flags |= DATA_CARRY;
165 static void tifm_sd_transfer_data(struct tifm_sd *host)
167 struct mmc_data *r_data = host->req->cmd->data;
173 if (host->sg_pos == host->sg_len)
176 cnt = sg[host->sg_pos].length - host->block_pos;
178 host->block_pos = 0;
179 host->sg_pos++;
180 if (host->sg_pos == host->sg_len) {
182 && (host->cmd_flags & DATA_CARRY))
183 writel(host->bounce_buf_data[0],
184 host->dev->addr
189 cnt = sg[host->sg_pos].length;
191 off = sg[host->sg_pos].offset + host->block_pos;
193 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
200 tifm_sd_read_fifo(host, pg, p_off, p_cnt);
202 tifm_sd_write_fifo(host, pg, p_off, p_cnt);
205 host->block_pos += p_cnt;
222 static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data)
230 dev_dbg(&host->dev->dev, "bouncing block\n");
232 cnt = sg[host->sg_pos].length - host->block_pos;
234 host->block_pos = 0;
235 host->sg_pos++;
236 if (host->sg_pos == host->sg_len)
238 cnt = sg[host->sg_pos].length;
240 off = sg[host->sg_pos].offset + host->block_pos;
242 pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT);
249 tifm_sd_copy_page(sg_page(&host->bounce_buf),
253 tifm_sd_copy_page(pg, p_off, sg_page(&host->bounce_buf),
257 host->block_pos += p_cnt;
261 static int tifm_sd_set_dma_data(struct tifm_sd *host, struct mmc_data *r_data)
263 struct tifm_dev *sock = host->dev;
269 if (host->sg_pos == host->sg_len)
272 if (host->cmd_flags & DATA_CARRY) {
273 host->cmd_flags &= ~DATA_CARRY;
275 tifm_sd_bounce_block(host, r_data);
277 if (host->sg_pos == host->sg_len)
281 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]) - host->block_pos;
283 host->block_pos = 0;
284 host->sg_pos++;
285 if (host->sg_pos == host->sg_len)
287 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]);
292 dma_off = host->block_pos;
293 host->block_pos += dma_blk_cnt * r_data->blksz;
296 dma_off = host->block_pos;
297 host->block_pos += t_size;
301 sg = &r_data->sg[host->sg_pos];
305 tifm_sd_bounce_block(host, r_data);
308 host->cmd_flags |= DATA_CARRY;
310 sg = &host->bounce_buf;
371 static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd)
373 struct tifm_dev *sock = host->dev;
376 if (host->open_drain)
402 static void tifm_sd_check_status(struct tifm_sd *host)
404 struct tifm_dev *sock = host->dev;
405 struct mmc_command *cmd = host->req->cmd;
410 if (!(host->cmd_flags & CMD_READY))
415 if ((host->cmd_flags & SCMD_ACTIVE)
416 && !(host->cmd_flags & SCMD_READY))
422 if (!(host->cmd_flags & BRS_READY))
425 if (!(host->no_dma || (host->cmd_flags & FIFO_READY)))
429 if (host->req->stop) {
430 if (!(host->cmd_flags & SCMD_ACTIVE)) {
431 host->cmd_flags |= SCMD_ACTIVE;
437 tifm_sd_exec(host, host->req->stop);
440 if (!(host->cmd_flags & SCMD_READY)
441 || (host->cmd_flags & CARD_BUSY))
450 if (host->cmd_flags & CARD_BUSY)
458 if (host->req->stop) {
459 if (!(host->cmd_flags & SCMD_ACTIVE)) {
460 host->cmd_flags |= SCMD_ACTIVE;
461 tifm_sd_exec(host, host->req->stop);
464 if (!(host->cmd_flags & SCMD_READY))
471 tasklet_schedule(&host->finish_tasklet);
477 struct tifm_sd *host;
482 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
485 fifo_status, host->cmd_flags);
487 if (host->req) {
488 r_data = host->req->cmd->data;
491 if (tifm_sd_set_dma_data(host, r_data)) {
492 host->cmd_flags |= FIFO_READY;
493 tifm_sd_check_status(host);
505 struct tifm_sd *host;
512 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
514 dev_dbg(&sock->dev, "host event: host_status %x, flags %x\n",
515 host_status, host->cmd_flags);
517 if (host->req) {
518 cmd = host->req->cmd;
539 if (host->req->stop) {
540 if (host->cmd_flags & SCMD_ACTIVE) {
541 host->req->stop->error = cmd_error;
542 host->cmd_flags |= SCMD_READY;
545 host->cmd_flags |= SCMD_ACTIVE;
546 tifm_sd_exec(host, host->req->stop);
553 if (!(host->cmd_flags & CMD_READY)) {
554 host->cmd_flags |= CMD_READY;
556 } else if (host->cmd_flags & SCMD_ACTIVE) {
557 host->cmd_flags |= SCMD_READY;
558 tifm_sd_fetch_resp(host->req->stop,
563 host->cmd_flags |= BRS_READY;
566 if (host->no_dma && cmd->data) {
574 tifm_sd_transfer_data(host);
581 host->cmd_flags &= ~CARD_BUSY;
583 host->cmd_flags |= CARD_BUSY;
585 tifm_sd_check_status(host);
592 static void tifm_sd_set_data_timeout(struct tifm_sd *host,
595 struct tifm_dev *sock = host->dev;
602 ((1000000000UL / host->clk_freq) * host->clk_div);
622 struct tifm_sd *host = mmc_priv(mmc);
623 struct tifm_dev *sock = host->dev;
628 if (host->eject) {
633 if (host->req) {
640 host->cmd_flags = 0;
641 host->block_pos = 0;
642 host->sg_pos = 0;
645 host->no_dma = 1;
647 host->no_dma = no_dma ? 1 : 0;
650 tifm_sd_set_data_timeout(host, r_data);
657 if (host->no_dma) {
665 host->sg_len = r_data->sg_len;
667 sg_init_one(&host->bounce_buf, host->bounce_buf_data,
670 if(1 != tifm_map_sg(sock, &host->bounce_buf, 1,
679 host->sg_len = tifm_map_sg(sock, r_data->sg,
685 if (host->sg_len < 1) {
688 tifm_unmap_sg(sock, &host->bounce_buf, 1,
712 tifm_sd_set_dma_data(host, r_data);
721 host->req = mrq;
722 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
725 tifm_sd_exec(host, mrq->cmd);
736 struct tifm_sd *host = (struct tifm_sd*)data;
737 struct tifm_dev *sock = host->dev;
745 del_timer(&host->timer);
746 mrq = host->req;
747 host->req = NULL;
758 if (host->no_dma) {
763 tifm_unmap_sg(sock, &host->bounce_buf, 1,
787 struct tifm_sd *host = from_timer(host, t, timer);
791 dev_name(&host->dev->dev), host->req->cmd->opcode, host->cmd_flags);
793 tifm_eject(host->dev);
798 struct tifm_sd *host = mmc_priv(mmc);
799 struct tifm_dev *sock = host->dev;
833 host->clk_freq = 20000000;
834 host->clk_div = clk_div1;
839 host->clk_freq = 24000000;
840 host->clk_div = clk_div2;
846 host->clk_div = 0;
848 host->clk_div &= TIFM_MMCSD_CLKMASK;
849 writel(host->clk_div
854 host->open_drain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN);
866 struct tifm_sd *host = mmc_priv(mmc);
867 struct tifm_dev *sock = host->dev;
883 static int tifm_sd_initialize_host(struct tifm_sd *host)
887 struct tifm_dev *sock = host->dev;
890 host->clk_div = 61;
891 host->clk_freq = 20000000;
893 writel(host->clk_div | TIFM_MMCSD_POWER,
912 writel(host->clk_div | TIFM_MMCSD_POWER,
947 struct tifm_sd *host;
961 host = mmc_priv(mmc);
963 host->dev = sock;
964 host->timeout_jiffies = msecs_to_jiffies(TIFM_MMCSD_REQ_TIMEOUT_MS);
971 tasklet_init(&host->finish_tasklet, tifm_sd_end_cmd,
972 (unsigned long)host);
973 timer_setup(&host->timer, tifm_sd_abort, 0);
989 rc = tifm_sd_initialize_host(host);
1003 struct tifm_sd *host = mmc_priv(mmc);
1007 host->eject = 1;
1011 tasklet_kill(&host->finish_tasklet);
1014 if (host->req) {
1018 host->req->cmd->error = -ENOMEDIUM;
1019 if (host->req->stop)
1020 host->req->stop->error = -ENOMEDIUM;
1021 tasklet_schedule(&host->finish_tasklet);
1040 struct tifm_sd *host = mmc_priv(mmc);
1043 rc = tifm_sd_initialize_host(host);
1047 host->eject = 1;