Lines Matching refs:host

154 static unsigned int jmb38x_ms_read_data(struct jmb38x_ms_host *host,  in jmb38x_ms_read_data()  argument
159 while (host->io_pos && length) { in jmb38x_ms_read_data()
160 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_data()
161 host->io_word[0] >>= 8; in jmb38x_ms_read_data()
163 host->io_pos--; in jmb38x_ms_read_data()
169 while (!(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) { in jmb38x_ms_read_data()
172 *(unsigned int *)(buf + off) = __raw_readl(host->addr + DATA); in jmb38x_ms_read_data()
178 && !(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) { in jmb38x_ms_read_data()
179 host->io_word[0] = readl(host->addr + DATA); in jmb38x_ms_read_data()
180 for (host->io_pos = 4; host->io_pos; --host->io_pos) { in jmb38x_ms_read_data()
181 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_data()
182 host->io_word[0] >>= 8; in jmb38x_ms_read_data()
192 static unsigned int jmb38x_ms_read_reg_data(struct jmb38x_ms_host *host, in jmb38x_ms_read_reg_data() argument
198 while (host->io_pos > 4 && length) { in jmb38x_ms_read_reg_data()
199 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_reg_data()
200 host->io_word[0] >>= 8; in jmb38x_ms_read_reg_data()
202 host->io_pos--; in jmb38x_ms_read_reg_data()
208 while (host->io_pos && length) { in jmb38x_ms_read_reg_data()
209 buf[off++] = host->io_word[1] & 0xff; in jmb38x_ms_read_reg_data()
210 host->io_word[1] >>= 8; in jmb38x_ms_read_reg_data()
212 host->io_pos--; in jmb38x_ms_read_reg_data()
218 static unsigned int jmb38x_ms_write_data(struct jmb38x_ms_host *host, in jmb38x_ms_write_data() argument
224 if (host->io_pos) { in jmb38x_ms_write_data()
225 while (host->io_pos < 4 && length) { in jmb38x_ms_write_data()
226 host->io_word[0] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_data()
227 host->io_pos++; in jmb38x_ms_write_data()
232 if (host->io_pos == 4 in jmb38x_ms_write_data()
233 && !(STATUS_FIFO_FULL & readl(host->addr + STATUS))) { in jmb38x_ms_write_data()
234 writel(host->io_word[0], host->addr + DATA); in jmb38x_ms_write_data()
235 host->io_pos = 0; in jmb38x_ms_write_data()
236 host->io_word[0] = 0; in jmb38x_ms_write_data()
237 } else if (host->io_pos) { in jmb38x_ms_write_data()
244 while (!(STATUS_FIFO_FULL & readl(host->addr + STATUS))) { in jmb38x_ms_write_data()
249 host->addr + DATA); in jmb38x_ms_write_data()
256 host->io_word[0] |= buf[off + 2] << 16; in jmb38x_ms_write_data()
257 host->io_pos++; in jmb38x_ms_write_data()
260 host->io_word[0] |= buf[off + 1] << 8; in jmb38x_ms_write_data()
261 host->io_pos++; in jmb38x_ms_write_data()
264 host->io_word[0] |= buf[off]; in jmb38x_ms_write_data()
265 host->io_pos++; in jmb38x_ms_write_data()
268 off += host->io_pos; in jmb38x_ms_write_data()
273 static unsigned int jmb38x_ms_write_reg_data(struct jmb38x_ms_host *host, in jmb38x_ms_write_reg_data() argument
279 while (host->io_pos < 4 && length) { in jmb38x_ms_write_reg_data()
280 host->io_word[0] &= ~(0xff << (host->io_pos * 8)); in jmb38x_ms_write_reg_data()
281 host->io_word[0] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_reg_data()
282 host->io_pos++; in jmb38x_ms_write_reg_data()
289 while (host->io_pos < 8 && length) { in jmb38x_ms_write_reg_data()
290 host->io_word[1] &= ~(0xff << (host->io_pos * 8)); in jmb38x_ms_write_reg_data()
291 host->io_word[1] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_reg_data()
292 host->io_pos++; in jmb38x_ms_write_reg_data()
299 static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host) in jmb38x_ms_transfer_data() argument
308 if (host->req->long_data) { in jmb38x_ms_transfer_data()
309 length = host->req->sg.length - host->block_pos; in jmb38x_ms_transfer_data()
310 off = host->req->sg.offset + host->block_pos; in jmb38x_ms_transfer_data()
312 length = host->req->data_len - host->block_pos; in jmb38x_ms_transfer_data()
319 if (host->req->long_data) { in jmb38x_ms_transfer_data()
320 pg = nth_page(sg_page(&host->req->sg), in jmb38x_ms_transfer_data()
329 buf = host->req->data + host->block_pos; in jmb38x_ms_transfer_data()
330 p_cnt = host->req->data_len - host->block_pos; in jmb38x_ms_transfer_data()
333 if (host->req->data_dir == WRITE) in jmb38x_ms_transfer_data()
334 t_size = !(host->cmd_flags & REG_DATA) in jmb38x_ms_transfer_data()
335 ? jmb38x_ms_write_data(host, buf, p_cnt) in jmb38x_ms_transfer_data()
336 : jmb38x_ms_write_reg_data(host, buf, p_cnt); in jmb38x_ms_transfer_data()
338 t_size = !(host->cmd_flags & REG_DATA) in jmb38x_ms_transfer_data()
339 ? jmb38x_ms_read_data(host, buf, p_cnt) in jmb38x_ms_transfer_data()
340 : jmb38x_ms_read_reg_data(host, buf, p_cnt); in jmb38x_ms_transfer_data()
342 if (host->req->long_data) { in jmb38x_ms_transfer_data()
349 host->block_pos += t_size; in jmb38x_ms_transfer_data()
354 if (!length && host->req->data_dir == WRITE) { in jmb38x_ms_transfer_data()
355 if (host->cmd_flags & REG_DATA) { in jmb38x_ms_transfer_data()
356 writel(host->io_word[0], host->addr + TPC_P0); in jmb38x_ms_transfer_data()
357 writel(host->io_word[1], host->addr + TPC_P1); in jmb38x_ms_transfer_data()
358 } else if (host->io_pos) { in jmb38x_ms_transfer_data()
359 writel(host->io_word[0], host->addr + DATA); in jmb38x_ms_transfer_data()
368 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_issue_cmd() local
371 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { in jmb38x_ms_issue_cmd()
373 host->req->error = -ETIME; in jmb38x_ms_issue_cmd()
374 return host->req->error; in jmb38x_ms_issue_cmd()
377 dev_dbg(&msh->dev, "control %08x\n", readl(host->addr + HOST_CONTROL)); in jmb38x_ms_issue_cmd()
378 dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); in jmb38x_ms_issue_cmd()
379 dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); in jmb38x_ms_issue_cmd()
381 host->cmd_flags = 0; in jmb38x_ms_issue_cmd()
382 host->block_pos = 0; in jmb38x_ms_issue_cmd()
383 host->io_pos = 0; in jmb38x_ms_issue_cmd()
384 host->io_word[0] = 0; in jmb38x_ms_issue_cmd()
385 host->io_word[1] = 0; in jmb38x_ms_issue_cmd()
387 cmd = host->req->tpc << 16; in jmb38x_ms_issue_cmd()
390 if (host->req->data_dir == READ) in jmb38x_ms_issue_cmd()
393 if (host->req->need_card_int) { in jmb38x_ms_issue_cmd()
394 if (host->ifmode == MEMSTICK_SERIAL) in jmb38x_ms_issue_cmd()
401 host->cmd_flags |= DMA_DATA; in jmb38x_ms_issue_cmd()
403 if (host->req->long_data) { in jmb38x_ms_issue_cmd()
404 data_len = host->req->sg.length; in jmb38x_ms_issue_cmd()
406 data_len = host->req->data_len; in jmb38x_ms_issue_cmd()
407 host->cmd_flags &= ~DMA_DATA; in jmb38x_ms_issue_cmd()
412 host->cmd_flags |= REG_DATA; in jmb38x_ms_issue_cmd()
414 host->cmd_flags &= ~DMA_DATA; in jmb38x_ms_issue_cmd()
417 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_issue_cmd()
418 if (1 != dma_map_sg(&host->chip->pdev->dev, &host->req->sg, 1, in jmb38x_ms_issue_cmd()
419 host->req->data_dir == READ in jmb38x_ms_issue_cmd()
422 host->req->error = -ENOMEM; in jmb38x_ms_issue_cmd()
423 return host->req->error; in jmb38x_ms_issue_cmd()
425 data_len = sg_dma_len(&host->req->sg); in jmb38x_ms_issue_cmd()
426 writel(sg_dma_address(&host->req->sg), in jmb38x_ms_issue_cmd()
427 host->addr + DMA_ADDRESS); in jmb38x_ms_issue_cmd()
430 host->addr + BLOCK); in jmb38x_ms_issue_cmd()
431 writel(DMA_CONTROL_ENABLE, host->addr + DMA_CONTROL); in jmb38x_ms_issue_cmd()
432 } else if (!(host->cmd_flags & REG_DATA)) { in jmb38x_ms_issue_cmd()
435 host->addr + BLOCK); in jmb38x_ms_issue_cmd()
436 t_val = readl(host->addr + INT_STATUS_ENABLE); in jmb38x_ms_issue_cmd()
437 t_val |= host->req->data_dir == READ in jmb38x_ms_issue_cmd()
441 writel(t_val, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_issue_cmd()
442 writel(t_val, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_issue_cmd()
445 host->cmd_flags |= REG_DATA; in jmb38x_ms_issue_cmd()
448 if (host->req->data_dir == WRITE) { in jmb38x_ms_issue_cmd()
449 jmb38x_ms_transfer_data(host); in jmb38x_ms_issue_cmd()
450 writel(host->io_word[0], host->addr + TPC_P0); in jmb38x_ms_issue_cmd()
451 writel(host->io_word[1], host->addr + TPC_P1); in jmb38x_ms_issue_cmd()
455 mod_timer(&host->timer, jiffies + host->timeout_jiffies); in jmb38x_ms_issue_cmd()
456 writel(HOST_CONTROL_LED | readl(host->addr + HOST_CONTROL), in jmb38x_ms_issue_cmd()
457 host->addr + HOST_CONTROL); in jmb38x_ms_issue_cmd()
458 host->req->error = 0; in jmb38x_ms_issue_cmd()
460 writel(cmd, host->addr + TPC); in jmb38x_ms_issue_cmd()
468 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_complete_cmd() local
472 del_timer(&host->timer); in jmb38x_ms_complete_cmd()
475 readl(host->addr + HOST_CONTROL)); in jmb38x_ms_complete_cmd()
477 readl(host->addr + INT_STATUS)); in jmb38x_ms_complete_cmd()
478 dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS)); in jmb38x_ms_complete_cmd()
480 host->req->int_reg = readl(host->addr + STATUS) & 0xff; in jmb38x_ms_complete_cmd()
482 writel(0, host->addr + BLOCK); in jmb38x_ms_complete_cmd()
483 writel(0, host->addr + DMA_CONTROL); in jmb38x_ms_complete_cmd()
485 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_complete_cmd()
486 dma_unmap_sg(&host->chip->pdev->dev, &host->req->sg, 1, in jmb38x_ms_complete_cmd()
487 host->req->data_dir == READ in jmb38x_ms_complete_cmd()
490 t_val = readl(host->addr + INT_STATUS_ENABLE); in jmb38x_ms_complete_cmd()
491 if (host->req->data_dir == READ) in jmb38x_ms_complete_cmd()
496 writel(t_val, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_complete_cmd()
497 writel(t_val, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_complete_cmd()
500 writel((~HOST_CONTROL_LED) & readl(host->addr + HOST_CONTROL), in jmb38x_ms_complete_cmd()
501 host->addr + HOST_CONTROL); in jmb38x_ms_complete_cmd()
505 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_complete_cmd()
509 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_complete_cmd()
511 host->req->error = -ETIME; in jmb38x_ms_complete_cmd()
519 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_isr() local
522 spin_lock(&host->lock); in jmb38x_ms_isr()
523 irq_status = readl(host->addr + INT_STATUS); in jmb38x_ms_isr()
524 dev_dbg(&host->chip->pdev->dev, "irq_status = %08x\n", irq_status); in jmb38x_ms_isr()
526 spin_unlock(&host->lock); in jmb38x_ms_isr()
530 if (host->req) { in jmb38x_ms_isr()
533 host->req->error = -EILSEQ; in jmb38x_ms_isr()
535 dev_dbg(&host->chip->pdev->dev, "TPC_ERR\n"); in jmb38x_ms_isr()
538 host->req->error = -ETIME; in jmb38x_ms_isr()
540 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_isr()
542 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
546 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
549 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
550 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
555 host->cmd_flags |= CMD_READY; in jmb38x_ms_isr()
556 if (host->cmd_flags & REG_DATA) { in jmb38x_ms_isr()
557 if (host->req->data_dir == READ) { in jmb38x_ms_isr()
558 host->io_word[0] in jmb38x_ms_isr()
559 = readl(host->addr in jmb38x_ms_isr()
561 host->io_word[1] in jmb38x_ms_isr()
562 = readl(host->addr in jmb38x_ms_isr()
564 host->io_pos = 8; in jmb38x_ms_isr()
566 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
568 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
575 dev_dbg(&host->chip->pdev->dev, "media changed\n"); in jmb38x_ms_isr()
579 writel(irq_status, host->addr + INT_STATUS); in jmb38x_ms_isr()
581 if (host->req in jmb38x_ms_isr()
582 && (((host->cmd_flags & CMD_READY) in jmb38x_ms_isr()
583 && (host->cmd_flags & FIFO_READY)) in jmb38x_ms_isr()
584 || host->req->error)) in jmb38x_ms_isr()
587 spin_unlock(&host->lock); in jmb38x_ms_isr()
593 struct jmb38x_ms_host *host = from_timer(host, t, timer); in jmb38x_ms_abort() local
594 struct memstick_host *msh = host->msh; in jmb38x_ms_abort()
597 dev_dbg(&host->chip->pdev->dev, "abort\n"); in jmb38x_ms_abort()
598 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_abort()
599 if (host->req) { in jmb38x_ms_abort()
600 host->req->error = -ETIME; in jmb38x_ms_abort()
603 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_abort()
609 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_req_tasklet() local
613 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_req_tasklet()
614 if (!host->req) { in jmb38x_ms_req_tasklet()
616 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_req_tasklet()
617 dev_dbg(&host->chip->pdev->dev, "tasklet req %d\n", rc); in jmb38x_ms_req_tasklet()
620 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_req_tasklet()
630 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_submit_req() local
632 tasklet_schedule(&host->notify); in jmb38x_ms_submit_req()
635 static int jmb38x_ms_reset(struct jmb38x_ms_host *host) in jmb38x_ms_reset() argument
640 | readl(host->addr + HOST_CONTROL), in jmb38x_ms_reset()
641 host->addr + HOST_CONTROL); in jmb38x_ms_reset()
645 & readl(host->addr + HOST_CONTROL))) in jmb38x_ms_reset()
650 dev_dbg(&host->chip->pdev->dev, "reset_req timeout\n"); in jmb38x_ms_reset()
654 | readl(host->addr + HOST_CONTROL), in jmb38x_ms_reset()
655 host->addr + HOST_CONTROL); in jmb38x_ms_reset()
659 & readl(host->addr + HOST_CONTROL))) in jmb38x_ms_reset()
664 dev_dbg(&host->chip->pdev->dev, "reset timeout\n"); in jmb38x_ms_reset()
668 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_reset()
669 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_reset()
677 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_set_param() local
678 unsigned int host_ctl = readl(host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
685 rc = jmb38x_ms_reset(host); in jmb38x_ms_set_param()
692 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
694 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 in jmb38x_ms_set_param()
696 host->addr + PAD_PU_PD); in jmb38x_ms_set_param()
699 host->addr + PAD_OUTPUT_ENABLE); in jmb38x_ms_set_param()
702 dev_dbg(&host->chip->pdev->dev, "power on\n"); in jmb38x_ms_set_param()
706 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
707 writel(0, host->addr + PAD_OUTPUT_ENABLE); in jmb38x_ms_set_param()
708 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD); in jmb38x_ms_set_param()
709 dev_dbg(&host->chip->pdev->dev, "power off\n"); in jmb38x_ms_set_param()
714 dev_dbg(&host->chip->pdev->dev, in jmb38x_ms_set_param()
743 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
744 writel(CLOCK_CONTROL_OFF, host->addr + CLOCK_CONTROL); in jmb38x_ms_set_param()
745 writel(clock_ctl, host->addr + CLOCK_CONTROL); in jmb38x_ms_set_param()
746 pci_write_config_byte(host->chip->pdev, in jmb38x_ms_set_param()
749 host->ifmode = value; in jmb38x_ms_set_param()
849 struct jmb38x_ms_host *host; in jmb38x_ms_alloc_host() local
856 host = memstick_priv(msh); in jmb38x_ms_alloc_host()
857 host->msh = msh; in jmb38x_ms_alloc_host()
858 host->chip = jm; in jmb38x_ms_alloc_host()
859 host->addr = ioremap(pci_resource_start(jm->pdev, cnt), in jmb38x_ms_alloc_host()
861 if (!host->addr) in jmb38x_ms_alloc_host()
864 spin_lock_init(&host->lock); in jmb38x_ms_alloc_host()
865 host->id = cnt; in jmb38x_ms_alloc_host()
866 snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d", in jmb38x_ms_alloc_host()
867 host->id); in jmb38x_ms_alloc_host()
868 host->irq = jm->pdev->irq; in jmb38x_ms_alloc_host()
869 host->timeout_jiffies = msecs_to_jiffies(1000); in jmb38x_ms_alloc_host()
871 tasklet_init(&host->notify, jmb38x_ms_req_tasklet, (unsigned long)msh); in jmb38x_ms_alloc_host()
877 timer_setup(&host->timer, jmb38x_ms_abort, 0); in jmb38x_ms_alloc_host()
879 if (!request_irq(host->irq, jmb38x_ms_isr, IRQF_SHARED, host->host_id, in jmb38x_ms_alloc_host()
883 iounmap(host->addr); in jmb38x_ms_alloc_host()
891 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_free_host() local
893 free_irq(host->irq, msh); in jmb38x_ms_free_host()
894 iounmap(host->addr); in jmb38x_ms_free_host()
972 struct jmb38x_ms_host *host; in jmb38x_ms_remove() local
980 host = memstick_priv(jm->hosts[cnt]); in jmb38x_ms_remove()
983 tasklet_kill(&host->notify); in jmb38x_ms_remove()
984 writel(0, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_remove()
985 writel(0, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_remove()
987 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_remove()
988 if (host->req) { in jmb38x_ms_remove()
989 host->req->error = -ETIME; in jmb38x_ms_remove()
992 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_remove()