Lines Matching full:host

82 static unsigned int tifm_ms_read_data(struct tifm_ms *host,  in tifm_ms_read_data()  argument
85 struct tifm_dev *sock = host->dev; in tifm_ms_read_data()
88 while (host->io_pos && length) { in tifm_ms_read_data()
89 buf[off++] = host->io_word & 0xff; in tifm_ms_read_data()
90 host->io_word >>= 8; in tifm_ms_read_data()
92 host->io_pos--; in tifm_ms_read_data()
109 host->io_word = readl(sock->addr + SOCK_MS_DATA); in tifm_ms_read_data()
110 for (host->io_pos = 4; host->io_pos; --host->io_pos) { in tifm_ms_read_data()
111 buf[off++] = host->io_word & 0xff; in tifm_ms_read_data()
112 host->io_word >>= 8; in tifm_ms_read_data()
122 static unsigned int tifm_ms_write_data(struct tifm_ms *host, in tifm_ms_write_data() argument
125 struct tifm_dev *sock = host->dev; in tifm_ms_write_data()
128 if (host->io_pos) { in tifm_ms_write_data()
129 while (host->io_pos < 4 && length) { in tifm_ms_write_data()
130 host->io_word |= buf[off++] << (host->io_pos * 8); in tifm_ms_write_data()
131 host->io_pos++; in tifm_ms_write_data()
136 if (host->io_pos == 4 in tifm_ms_write_data()
140 writel(host->io_word, sock->addr + SOCK_MS_DATA); in tifm_ms_write_data()
141 host->io_pos = 0; in tifm_ms_write_data()
142 host->io_word = 0; in tifm_ms_write_data()
143 } else if (host->io_pos) { in tifm_ms_write_data()
163 host->io_word |= buf[off + 2] << 16; in tifm_ms_write_data()
164 host->io_pos++; in tifm_ms_write_data()
167 host->io_word |= buf[off + 1] << 8; in tifm_ms_write_data()
168 host->io_pos++; in tifm_ms_write_data()
171 host->io_word |= buf[off]; in tifm_ms_write_data()
172 host->io_pos++; in tifm_ms_write_data()
175 off += host->io_pos; in tifm_ms_write_data()
180 static unsigned int tifm_ms_transfer_data(struct tifm_ms *host) in tifm_ms_transfer_data() argument
182 struct tifm_dev *sock = host->dev; in tifm_ms_transfer_data()
190 if (host->req->long_data) { in tifm_ms_transfer_data()
191 length = host->req->sg.length - host->block_pos; in tifm_ms_transfer_data()
192 off = host->req->sg.offset + host->block_pos; in tifm_ms_transfer_data()
194 length = host->req->data_len - host->block_pos; in tifm_ms_transfer_data()
198 host->block_pos); in tifm_ms_transfer_data()
203 if (host->req->long_data) { in tifm_ms_transfer_data()
204 pg = nth_page(sg_page(&host->req->sg), in tifm_ms_transfer_data()
213 buf = host->req->data + host->block_pos; in tifm_ms_transfer_data()
214 p_cnt = host->req->data_len - host->block_pos; in tifm_ms_transfer_data()
217 t_size = host->req->data_dir == WRITE in tifm_ms_transfer_data()
218 ? tifm_ms_write_data(host, buf, p_cnt) in tifm_ms_transfer_data()
219 : tifm_ms_read_data(host, buf, p_cnt); in tifm_ms_transfer_data()
221 if (host->req->long_data) { in tifm_ms_transfer_data()
228 host->block_pos += t_size; in tifm_ms_transfer_data()
234 if (!length && (host->req->data_dir == WRITE)) { in tifm_ms_transfer_data()
235 if (host->io_pos) { in tifm_ms_transfer_data()
239 writel(host->io_word, sock->addr + SOCK_MS_DATA); in tifm_ms_transfer_data()
252 static int tifm_ms_issue_cmd(struct tifm_ms *host) in tifm_ms_issue_cmd() argument
254 struct tifm_dev *sock = host->dev; in tifm_ms_issue_cmd()
257 host->cmd_flags = 0; in tifm_ms_issue_cmd()
258 host->block_pos = 0; in tifm_ms_issue_cmd()
259 host->io_pos = 0; in tifm_ms_issue_cmd()
260 host->io_word = 0; in tifm_ms_issue_cmd()
261 host->cmd_flags = 0; in tifm_ms_issue_cmd()
263 host->use_dma = !no_dma; in tifm_ms_issue_cmd()
265 if (host->req->long_data) { in tifm_ms_issue_cmd()
266 data_len = host->req->sg.length; in tifm_ms_issue_cmd()
268 host->use_dma = 0; in tifm_ms_issue_cmd()
270 data_len = host->req->data_len; in tifm_ms_issue_cmd()
271 host->use_dma = 0; in tifm_ms_issue_cmd()
279 if (host->use_dma) { in tifm_ms_issue_cmd()
280 if (1 != tifm_map_sg(sock, &host->req->sg, 1, in tifm_ms_issue_cmd()
281 host->req->data_dir == READ in tifm_ms_issue_cmd()
284 host->req->error = -ENOMEM; in tifm_ms_issue_cmd()
285 return host->req->error; in tifm_ms_issue_cmd()
287 data_len = sg_dma_len(&host->req->sg); in tifm_ms_issue_cmd()
294 if (host->req->data_dir == WRITE) in tifm_ms_issue_cmd()
300 writel(sg_dma_address(&host->req->sg), in tifm_ms_issue_cmd()
304 writel(host->mode_mask | TIFM_MS_SYS_FIFO, in tifm_ms_issue_cmd()
311 mod_timer(&host->timer, jiffies + host->timeout_jiffies); in tifm_ms_issue_cmd()
314 host->req->error = 0; in tifm_ms_issue_cmd()
319 if (host->use_dma) in tifm_ms_issue_cmd()
326 cmd = (host->req->tpc & 0xf) << 12; in tifm_ms_issue_cmd()
334 static void tifm_ms_complete_cmd(struct tifm_ms *host) in tifm_ms_complete_cmd() argument
336 struct tifm_dev *sock = host->dev; in tifm_ms_complete_cmd()
340 del_timer(&host->timer); in tifm_ms_complete_cmd()
342 host->req->int_reg = readl(sock->addr + SOCK_MS_STATUS) & 0xff; in tifm_ms_complete_cmd()
343 host->req->int_reg = (host->req->int_reg & 1) in tifm_ms_complete_cmd()
344 | ((host->req->int_reg << 4) & 0xe0); in tifm_ms_complete_cmd()
350 if (host->use_dma) { in tifm_ms_complete_cmd()
351 tifm_unmap_sg(sock, &host->req->sg, 1, in tifm_ms_complete_cmd()
352 host->req->data_dir == READ in tifm_ms_complete_cmd()
362 rc = memstick_next_req(msh, &host->req); in tifm_ms_complete_cmd()
363 } while (!rc && tifm_ms_issue_cmd(host)); in tifm_ms_complete_cmd()
366 static int tifm_ms_check_status(struct tifm_ms *host) in tifm_ms_check_status() argument
368 if (!host->req->error) { in tifm_ms_check_status()
369 if (!(host->cmd_flags & CMD_READY)) in tifm_ms_check_status()
371 if (!(host->cmd_flags & FIFO_READY)) in tifm_ms_check_status()
373 if (host->req->need_card_int in tifm_ms_check_status()
374 && !(host->cmd_flags & CARD_INT)) in tifm_ms_check_status()
383 struct tifm_ms *host; in tifm_ms_data_event() local
388 host = memstick_priv((struct memstick_host *)tifm_get_drvdata(sock)); in tifm_ms_data_event()
393 fifo_status, host_status, host->cmd_flags); in tifm_ms_data_event()
395 if (host->req) { in tifm_ms_data_event()
396 if (host->use_dma && (fifo_status & 1)) { in tifm_ms_data_event()
397 host->cmd_flags |= FIFO_READY; in tifm_ms_data_event()
398 rc = tifm_ms_check_status(host); in tifm_ms_data_event()
400 if (!host->use_dma && (fifo_status & TIFM_FIFO_MORE)) { in tifm_ms_data_event()
401 if (!tifm_ms_transfer_data(host)) { in tifm_ms_data_event()
402 host->cmd_flags |= FIFO_READY; in tifm_ms_data_event()
403 rc = tifm_ms_check_status(host); in tifm_ms_data_event()
410 tifm_ms_complete_cmd(host); in tifm_ms_data_event()
419 struct tifm_ms *host; in tifm_ms_card_event() local
424 host = memstick_priv((struct memstick_host *)tifm_get_drvdata(sock)); in tifm_ms_card_event()
426 dev_dbg(&sock->dev, "host event: host_status %x, flags %x\n", in tifm_ms_card_event()
427 host_status, host->cmd_flags); in tifm_ms_card_event()
429 if (host->req) { in tifm_ms_card_event()
431 host->req->error = -ETIME; in tifm_ms_card_event()
433 host->req->error = -EILSEQ; in tifm_ms_card_event()
436 host->cmd_flags |= CMD_READY; in tifm_ms_card_event()
439 host->cmd_flags |= CARD_INT; in tifm_ms_card_event()
441 rc = tifm_ms_check_status(host); in tifm_ms_card_event()
449 tifm_ms_complete_cmd(host); in tifm_ms_card_event()
458 struct tifm_ms *host = memstick_priv(msh); in tifm_ms_req_tasklet() local
459 struct tifm_dev *sock = host->dev; in tifm_ms_req_tasklet()
464 if (!host->req) { in tifm_ms_req_tasklet()
465 if (host->eject) { in tifm_ms_req_tasklet()
467 rc = memstick_next_req(msh, &host->req); in tifm_ms_req_tasklet()
469 host->req->error = -ETIME; in tifm_ms_req_tasklet()
476 rc = memstick_next_req(msh, &host->req); in tifm_ms_req_tasklet()
477 } while (!rc && tifm_ms_issue_cmd(host)); in tifm_ms_req_tasklet()
489 struct tifm_ms *host = memstick_priv(msh); in tifm_ms_submit_req() local
491 tasklet_schedule(&host->notify); in tifm_ms_submit_req()
498 struct tifm_ms *host = memstick_priv(msh); in tifm_ms_set_param() local
499 struct tifm_dev *sock = host->dev; in tifm_ms_set_param()
505 host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI; in tifm_ms_set_param()
519 host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI; in tifm_ms_set_param()
524 host->mode_mask = 0; in tifm_ms_set_param()
538 struct tifm_ms *host = from_timer(host, t, timer); in tifm_ms_abort() local
540 dev_dbg(&host->dev->dev, "status %x\n", in tifm_ms_abort()
541 readl(host->dev->addr + SOCK_MS_STATUS)); in tifm_ms_abort()
545 dev_name(&host->dev->dev), host->req ? host->req->tpc : 0, in tifm_ms_abort()
546 host->cmd_flags); in tifm_ms_abort()
548 tifm_eject(host->dev); in tifm_ms_abort()
554 struct tifm_ms *host; in tifm_ms_probe() local
568 host = memstick_priv(msh); in tifm_ms_probe()
570 host->dev = sock; in tifm_ms_probe()
571 host->timeout_jiffies = msecs_to_jiffies(1000); in tifm_ms_probe()
573 timer_setup(&host->timer, tifm_ms_abort, 0); in tifm_ms_probe()
574 tasklet_init(&host->notify, tifm_ms_req_tasklet, (unsigned long)msh); in tifm_ms_probe()
594 struct tifm_ms *host = memstick_priv(msh); in tifm_ms_remove() local
599 tasklet_kill(&host->notify); in tifm_ms_remove()
601 host->eject = 1; in tifm_ms_remove()
602 if (host->req) { in tifm_ms_remove()
603 del_timer(&host->timer); in tifm_ms_remove()
607 if (host->use_dma) in tifm_ms_remove()
608 tifm_unmap_sg(sock, &host->req->sg, 1, in tifm_ms_remove()
609 host->req->data_dir == READ in tifm_ms_remove()
612 host->req->error = -ETIME; in tifm_ms_remove()
615 rc = memstick_next_req(msh, &host->req); in tifm_ms_remove()
617 host->req->error = -ETIME; in tifm_ms_remove()