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