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;
268 if (host->sg_pos == host->sg_len)
271 if (host->cmd_flags & DATA_CARRY) {
272 host->cmd_flags &= ~DATA_CARRY;
273 tifm_sd_bounce_block(host, r_data);
274 if (host->sg_pos == host->sg_len)
278 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]) - host->block_pos;
280 host->block_pos = 0;
281 host->sg_pos++;
282 if (host->sg_pos == host->sg_len)
284 dma_len = sg_dma_len(&r_data->sg[host->sg_pos]);
289 dma_off = host->block_pos;
290 host->block_pos += dma_blk_cnt * r_data->blksz;
293 dma_off = host->block_pos;
294 host->block_pos += t_size;
298 sg = &r_data->sg[host->sg_pos];
301 tifm_sd_bounce_block(host, r_data);
303 host->cmd_flags |= DATA_CARRY;
305 sg = &host->bounce_buf;
366 static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd)
368 struct tifm_dev *sock = host->dev;
371 if (host->open_drain)
397 static void tifm_sd_check_status(struct tifm_sd *host)
399 struct tifm_dev *sock = host->dev;
400 struct mmc_command *cmd = host->req->cmd;
405 if (!(host->cmd_flags & CMD_READY))
410 if ((host->cmd_flags & SCMD_ACTIVE)
411 && !(host->cmd_flags & SCMD_READY))
417 if (!(host->cmd_flags & BRS_READY))
420 if (!(host->no_dma || (host->cmd_flags & FIFO_READY)))
424 if (host->req->stop) {
425 if (!(host->cmd_flags & SCMD_ACTIVE)) {
426 host->cmd_flags |= SCMD_ACTIVE;
432 tifm_sd_exec(host, host->req->stop);
435 if (!(host->cmd_flags & SCMD_READY)
436 || (host->cmd_flags & CARD_BUSY))
445 if (host->cmd_flags & CARD_BUSY)
453 if (host->req->stop) {
454 if (!(host->cmd_flags & SCMD_ACTIVE)) {
455 host->cmd_flags |= SCMD_ACTIVE;
456 tifm_sd_exec(host, host->req->stop);
459 if (!(host->cmd_flags & SCMD_READY))
466 tasklet_schedule(&host->finish_tasklet);
472 struct tifm_sd *host;
477 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
480 fifo_status, host->cmd_flags);
482 if (host->req) {
483 r_data = host->req->cmd->data;
486 if (tifm_sd_set_dma_data(host, r_data)) {
487 host->cmd_flags |= FIFO_READY;
488 tifm_sd_check_status(host);
500 struct tifm_sd *host;
506 host = mmc_priv((struct mmc_host*)tifm_get_drvdata(sock));
508 dev_dbg(&sock->dev, "host event: host_status %x, flags %x\n",
509 host_status, host->cmd_flags);
511 if (host->req) {
512 cmd = host->req->cmd;
533 if (host->req->stop) {
534 if (host->cmd_flags & SCMD_ACTIVE) {
535 host->req->stop->error = cmd_error;
536 host->cmd_flags |= SCMD_READY;
539 host->cmd_flags |= SCMD_ACTIVE;
540 tifm_sd_exec(host, host->req->stop);
547 if (!(host->cmd_flags & CMD_READY)) {
548 host->cmd_flags |= CMD_READY;
550 } else if (host->cmd_flags & SCMD_ACTIVE) {
551 host->cmd_flags |= SCMD_READY;
552 tifm_sd_fetch_resp(host->req->stop,
557 host->cmd_flags |= BRS_READY;
560 if (host->no_dma && cmd->data) {
567 tifm_sd_transfer_data(host);
573 host->cmd_flags &= ~CARD_BUSY;
575 host->cmd_flags |= CARD_BUSY;
577 tifm_sd_check_status(host);
584 static void tifm_sd_set_data_timeout(struct tifm_sd *host,
587 struct tifm_dev *sock = host->dev;
594 ((1000000000UL / host->clk_freq) * host->clk_div);
614 struct tifm_sd *host = mmc_priv(mmc);
615 struct tifm_dev *sock = host->dev;
620 if (host->eject) {
625 if (host->req) {
632 host->cmd_flags = 0;
633 host->block_pos = 0;
634 host->sg_pos = 0;
637 host->no_dma = 1;
639 host->no_dma = no_dma ? 1 : 0;
642 tifm_sd_set_data_timeout(host, r_data);
649 if (host->no_dma) {
657 host->sg_len = r_data->sg_len;
659 sg_init_one(&host->bounce_buf, host->bounce_buf_data,
662 if(1 != tifm_map_sg(sock, &host->bounce_buf, 1,
671 host->sg_len = tifm_map_sg(sock, r_data->sg,
677 if (host->sg_len < 1) {
680 tifm_unmap_sg(sock, &host->bounce_buf, 1,
704 tifm_sd_set_dma_data(host, r_data);
713 host->req = mrq;
714 mod_timer(&host->timer, jiffies + host->timeout_jiffies);
717 tifm_sd_exec(host, mrq->cmd);
728 struct tifm_sd *host = from_tasklet(host, t, finish_tasklet);
729 struct tifm_dev *sock = host->dev;
737 del_timer(&host->timer);
738 mrq = host->req;
739 host->req = NULL;
750 if (host->no_dma) {
755 tifm_unmap_sg(sock, &host->bounce_buf, 1,
779 struct tifm_sd *host = from_timer(host, t, timer);
783 dev_name(&host->dev->dev), host->req->cmd->opcode, host->cmd_flags);
785 tifm_eject(host->dev);
790 struct tifm_sd *host = mmc_priv(mmc);
791 struct tifm_dev *sock = host->dev;
825 host->clk_freq = 20000000;
826 host->clk_div = clk_div1;
831 host->clk_freq = 24000000;
832 host->clk_div = clk_div2;
838 host->clk_div = 0;
840 host->clk_div &= TIFM_MMCSD_CLKMASK;
841 writel(host->clk_div
846 host->open_drain = (ios->bus_mode == MMC_BUSMODE_OPENDRAIN);
858 struct tifm_sd *host = mmc_priv(mmc);
859 struct tifm_dev *sock = host->dev;
875 static int tifm_sd_initialize_host(struct tifm_sd *host)
879 struct tifm_dev *sock = host->dev;
882 host->clk_div = 61;
883 host->clk_freq = 20000000;
885 writel(host->clk_div | TIFM_MMCSD_POWER,
904 writel(host->clk_div | TIFM_MMCSD_POWER,
939 struct tifm_sd *host;
953 host = mmc_priv(mmc);
955 host->dev = sock;
956 host->timeout_jiffies = msecs_to_jiffies(TIFM_MMCSD_REQ_TIMEOUT_MS);
963 tasklet_setup(&host->finish_tasklet, tifm_sd_end_cmd);
964 timer_setup(&host->timer, tifm_sd_abort, 0);
980 rc = tifm_sd_initialize_host(host);
994 struct tifm_sd *host = mmc_priv(mmc);
998 host->eject = 1;
1002 tasklet_kill(&host->finish_tasklet);
1005 if (host->req) {
1009 host->req->cmd->error = -ENOMEDIUM;
1010 if (host->req->stop)
1011 host->req->stop->error = -ENOMEDIUM;
1012 tasklet_schedule(&host->finish_tasklet);
1031 struct tifm_sd *host = mmc_priv(mmc);
1034 rc = tifm_sd_initialize_host(host);
1038 host->eject = 1;