Lines Matching refs:host
157 static unsigned int jmb38x_ms_read_data(struct jmb38x_ms_host *host, in jmb38x_ms_read_data() argument
162 while (host->io_pos && length) { in jmb38x_ms_read_data()
163 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_data()
164 host->io_word[0] >>= 8; in jmb38x_ms_read_data()
166 host->io_pos--; in jmb38x_ms_read_data()
172 while (!(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) { in jmb38x_ms_read_data()
175 *(unsigned int *)(buf + off) = __raw_readl(host->addr + DATA); in jmb38x_ms_read_data()
181 && !(STATUS_FIFO_EMPTY & readl(host->addr + STATUS))) { in jmb38x_ms_read_data()
182 host->io_word[0] = readl(host->addr + DATA); in jmb38x_ms_read_data()
183 for (host->io_pos = 4; host->io_pos; --host->io_pos) { in jmb38x_ms_read_data()
184 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_data()
185 host->io_word[0] >>= 8; in jmb38x_ms_read_data()
195 static unsigned int jmb38x_ms_read_reg_data(struct jmb38x_ms_host *host, in jmb38x_ms_read_reg_data() argument
201 while (host->io_pos > 4 && length) { in jmb38x_ms_read_reg_data()
202 buf[off++] = host->io_word[0] & 0xff; in jmb38x_ms_read_reg_data()
203 host->io_word[0] >>= 8; in jmb38x_ms_read_reg_data()
205 host->io_pos--; in jmb38x_ms_read_reg_data()
211 while (host->io_pos && length) { in jmb38x_ms_read_reg_data()
212 buf[off++] = host->io_word[1] & 0xff; in jmb38x_ms_read_reg_data()
213 host->io_word[1] >>= 8; in jmb38x_ms_read_reg_data()
215 host->io_pos--; in jmb38x_ms_read_reg_data()
221 static unsigned int jmb38x_ms_write_data(struct jmb38x_ms_host *host, in jmb38x_ms_write_data() argument
227 if (host->io_pos) { in jmb38x_ms_write_data()
228 while (host->io_pos < 4 && length) { in jmb38x_ms_write_data()
229 host->io_word[0] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_data()
230 host->io_pos++; in jmb38x_ms_write_data()
235 if (host->io_pos == 4 in jmb38x_ms_write_data()
236 && !(STATUS_FIFO_FULL & readl(host->addr + STATUS))) { in jmb38x_ms_write_data()
237 writel(host->io_word[0], host->addr + DATA); in jmb38x_ms_write_data()
238 host->io_pos = 0; in jmb38x_ms_write_data()
239 host->io_word[0] = 0; in jmb38x_ms_write_data()
240 } else if (host->io_pos) { in jmb38x_ms_write_data()
247 while (!(STATUS_FIFO_FULL & readl(host->addr + STATUS))) { in jmb38x_ms_write_data()
252 host->addr + DATA); in jmb38x_ms_write_data()
259 host->io_word[0] |= buf[off + 2] << 16; in jmb38x_ms_write_data()
260 host->io_pos++; in jmb38x_ms_write_data()
262 host->io_word[0] |= buf[off + 1] << 8; in jmb38x_ms_write_data()
263 host->io_pos++; in jmb38x_ms_write_data()
265 host->io_word[0] |= buf[off]; in jmb38x_ms_write_data()
266 host->io_pos++; in jmb38x_ms_write_data()
269 off += host->io_pos; in jmb38x_ms_write_data()
274 static unsigned int jmb38x_ms_write_reg_data(struct jmb38x_ms_host *host, in jmb38x_ms_write_reg_data() argument
280 while (host->io_pos < 4 && length) { in jmb38x_ms_write_reg_data()
281 host->io_word[0] &= ~(0xff << (host->io_pos * 8)); in jmb38x_ms_write_reg_data()
282 host->io_word[0] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_reg_data()
283 host->io_pos++; in jmb38x_ms_write_reg_data()
290 while (host->io_pos < 8 && length) { in jmb38x_ms_write_reg_data()
291 host->io_word[1] &= ~(0xff << (host->io_pos * 8)); in jmb38x_ms_write_reg_data()
292 host->io_word[1] |= buf[off++] << (host->io_pos * 8); in jmb38x_ms_write_reg_data()
293 host->io_pos++; in jmb38x_ms_write_reg_data()
300 static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host) in jmb38x_ms_transfer_data() argument
309 if (host->req->long_data) { in jmb38x_ms_transfer_data()
310 length = host->req->sg.length - host->block_pos; in jmb38x_ms_transfer_data()
311 off = host->req->sg.offset + host->block_pos; in jmb38x_ms_transfer_data()
313 length = host->req->data_len - host->block_pos; in jmb38x_ms_transfer_data()
320 if (host->req->long_data) { in jmb38x_ms_transfer_data()
321 pg = nth_page(sg_page(&host->req->sg), in jmb38x_ms_transfer_data()
330 buf = host->req->data + host->block_pos; in jmb38x_ms_transfer_data()
331 p_cnt = host->req->data_len - host->block_pos; in jmb38x_ms_transfer_data()
334 if (host->req->data_dir == WRITE) in jmb38x_ms_transfer_data()
335 t_size = !(host->cmd_flags & REG_DATA) in jmb38x_ms_transfer_data()
336 ? jmb38x_ms_write_data(host, buf, p_cnt) in jmb38x_ms_transfer_data()
337 : jmb38x_ms_write_reg_data(host, buf, p_cnt); in jmb38x_ms_transfer_data()
339 t_size = !(host->cmd_flags & REG_DATA) in jmb38x_ms_transfer_data()
340 ? jmb38x_ms_read_data(host, buf, p_cnt) in jmb38x_ms_transfer_data()
341 : jmb38x_ms_read_reg_data(host, buf, p_cnt); in jmb38x_ms_transfer_data()
343 if (host->req->long_data) { in jmb38x_ms_transfer_data()
350 host->block_pos += t_size; in jmb38x_ms_transfer_data()
355 if (!length && host->req->data_dir == WRITE) { in jmb38x_ms_transfer_data()
356 if (host->cmd_flags & REG_DATA) { in jmb38x_ms_transfer_data()
357 writel(host->io_word[0], host->addr + TPC_P0); in jmb38x_ms_transfer_data()
358 writel(host->io_word[1], host->addr + TPC_P1); in jmb38x_ms_transfer_data()
359 } else if (host->io_pos) { in jmb38x_ms_transfer_data()
360 writel(host->io_word[0], host->addr + DATA); in jmb38x_ms_transfer_data()
369 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_issue_cmd() local
373 if (!(STATUS_HAS_MEDIA & readl(host->addr + STATUS))) { in jmb38x_ms_issue_cmd()
375 host->req->error = -ETIME; in jmb38x_ms_issue_cmd()
376 return host->req->error; in jmb38x_ms_issue_cmd()
379 dev_dbg(&msh->dev, "control %08x\n", readl(host->addr + HOST_CONTROL)); in jmb38x_ms_issue_cmd()
380 dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); in jmb38x_ms_issue_cmd()
381 dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); in jmb38x_ms_issue_cmd()
383 host->cmd_flags = 0; in jmb38x_ms_issue_cmd()
384 host->block_pos = 0; in jmb38x_ms_issue_cmd()
385 host->io_pos = 0; in jmb38x_ms_issue_cmd()
386 host->io_word[0] = 0; in jmb38x_ms_issue_cmd()
387 host->io_word[1] = 0; in jmb38x_ms_issue_cmd()
389 cmd = host->req->tpc << 16; in jmb38x_ms_issue_cmd()
392 if (host->req->data_dir == READ) in jmb38x_ms_issue_cmd()
395 if (host->req->need_card_int) { in jmb38x_ms_issue_cmd()
396 if (host->ifmode == MEMSTICK_SERIAL) in jmb38x_ms_issue_cmd()
402 data = host->req->data; in jmb38x_ms_issue_cmd()
405 host->cmd_flags |= DMA_DATA; in jmb38x_ms_issue_cmd()
407 if (host->req->long_data) { in jmb38x_ms_issue_cmd()
408 data_len = host->req->sg.length; in jmb38x_ms_issue_cmd()
410 data_len = host->req->data_len; in jmb38x_ms_issue_cmd()
411 host->cmd_flags &= ~DMA_DATA; in jmb38x_ms_issue_cmd()
416 host->cmd_flags |= REG_DATA; in jmb38x_ms_issue_cmd()
418 host->cmd_flags &= ~DMA_DATA; in jmb38x_ms_issue_cmd()
421 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_issue_cmd()
422 if (1 != dma_map_sg(&host->chip->pdev->dev, &host->req->sg, 1, in jmb38x_ms_issue_cmd()
423 host->req->data_dir == READ in jmb38x_ms_issue_cmd()
426 host->req->error = -ENOMEM; in jmb38x_ms_issue_cmd()
427 return host->req->error; in jmb38x_ms_issue_cmd()
429 data_len = sg_dma_len(&host->req->sg); in jmb38x_ms_issue_cmd()
430 writel(sg_dma_address(&host->req->sg), in jmb38x_ms_issue_cmd()
431 host->addr + DMA_ADDRESS); in jmb38x_ms_issue_cmd()
434 host->addr + BLOCK); in jmb38x_ms_issue_cmd()
435 writel(DMA_CONTROL_ENABLE, host->addr + DMA_CONTROL); in jmb38x_ms_issue_cmd()
436 } else if (!(host->cmd_flags & REG_DATA)) { in jmb38x_ms_issue_cmd()
439 host->addr + BLOCK); in jmb38x_ms_issue_cmd()
440 t_val = readl(host->addr + INT_STATUS_ENABLE); in jmb38x_ms_issue_cmd()
441 t_val |= host->req->data_dir == READ in jmb38x_ms_issue_cmd()
445 writel(t_val, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_issue_cmd()
446 writel(t_val, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_issue_cmd()
449 host->cmd_flags |= REG_DATA; in jmb38x_ms_issue_cmd()
452 if (host->req->data_dir == WRITE) { in jmb38x_ms_issue_cmd()
453 jmb38x_ms_transfer_data(host); in jmb38x_ms_issue_cmd()
454 writel(host->io_word[0], host->addr + TPC_P0); in jmb38x_ms_issue_cmd()
455 writel(host->io_word[1], host->addr + TPC_P1); in jmb38x_ms_issue_cmd()
459 mod_timer(&host->timer, jiffies + host->timeout_jiffies); in jmb38x_ms_issue_cmd()
460 writel(HOST_CONTROL_LED | readl(host->addr + HOST_CONTROL), in jmb38x_ms_issue_cmd()
461 host->addr + HOST_CONTROL); in jmb38x_ms_issue_cmd()
462 host->req->error = 0; in jmb38x_ms_issue_cmd()
464 writel(cmd, host->addr + TPC); in jmb38x_ms_issue_cmd()
472 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_complete_cmd() local
476 del_timer(&host->timer); in jmb38x_ms_complete_cmd()
479 readl(host->addr + HOST_CONTROL)); in jmb38x_ms_complete_cmd()
481 readl(host->addr + INT_STATUS)); in jmb38x_ms_complete_cmd()
482 dev_dbg(&msh->dev, "c hstatus %08x\n", readl(host->addr + STATUS)); in jmb38x_ms_complete_cmd()
484 host->req->int_reg = readl(host->addr + STATUS) & 0xff; in jmb38x_ms_complete_cmd()
486 writel(0, host->addr + BLOCK); in jmb38x_ms_complete_cmd()
487 writel(0, host->addr + DMA_CONTROL); in jmb38x_ms_complete_cmd()
489 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_complete_cmd()
490 dma_unmap_sg(&host->chip->pdev->dev, &host->req->sg, 1, in jmb38x_ms_complete_cmd()
491 host->req->data_dir == READ in jmb38x_ms_complete_cmd()
494 t_val = readl(host->addr + INT_STATUS_ENABLE); in jmb38x_ms_complete_cmd()
495 if (host->req->data_dir == READ) in jmb38x_ms_complete_cmd()
500 writel(t_val, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_complete_cmd()
501 writel(t_val, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_complete_cmd()
504 writel((~HOST_CONTROL_LED) & readl(host->addr + HOST_CONTROL), in jmb38x_ms_complete_cmd()
505 host->addr + HOST_CONTROL); in jmb38x_ms_complete_cmd()
509 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_complete_cmd()
513 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_complete_cmd()
515 host->req->error = -ETIME; in jmb38x_ms_complete_cmd()
523 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_isr() local
526 spin_lock(&host->lock); in jmb38x_ms_isr()
527 irq_status = readl(host->addr + INT_STATUS); in jmb38x_ms_isr()
528 dev_dbg(&host->chip->pdev->dev, "irq_status = %08x\n", irq_status); in jmb38x_ms_isr()
530 spin_unlock(&host->lock); in jmb38x_ms_isr()
534 if (host->req) { in jmb38x_ms_isr()
537 host->req->error = -EILSEQ; in jmb38x_ms_isr()
539 dev_dbg(&host->chip->pdev->dev, "TPC_ERR\n"); in jmb38x_ms_isr()
542 host->req->error = -ETIME; in jmb38x_ms_isr()
544 if (host->cmd_flags & DMA_DATA) { in jmb38x_ms_isr()
546 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
550 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
553 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
554 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
559 host->cmd_flags |= CMD_READY; in jmb38x_ms_isr()
560 if (host->cmd_flags & REG_DATA) { in jmb38x_ms_isr()
561 if (host->req->data_dir == READ) { in jmb38x_ms_isr()
562 host->io_word[0] in jmb38x_ms_isr()
563 = readl(host->addr in jmb38x_ms_isr()
565 host->io_word[1] in jmb38x_ms_isr()
566 = readl(host->addr in jmb38x_ms_isr()
568 host->io_pos = 8; in jmb38x_ms_isr()
570 jmb38x_ms_transfer_data(host); in jmb38x_ms_isr()
572 host->cmd_flags |= FIFO_READY; in jmb38x_ms_isr()
579 dev_dbg(&host->chip->pdev->dev, "media changed\n"); in jmb38x_ms_isr()
583 writel(irq_status, host->addr + INT_STATUS); in jmb38x_ms_isr()
585 if (host->req in jmb38x_ms_isr()
586 && (((host->cmd_flags & CMD_READY) in jmb38x_ms_isr()
587 && (host->cmd_flags & FIFO_READY)) in jmb38x_ms_isr()
588 || host->req->error)) in jmb38x_ms_isr()
591 spin_unlock(&host->lock); in jmb38x_ms_isr()
598 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_abort() local
601 dev_dbg(&host->chip->pdev->dev, "abort\n"); in jmb38x_ms_abort()
602 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_abort()
603 if (host->req) { in jmb38x_ms_abort()
604 host->req->error = -ETIME; in jmb38x_ms_abort()
607 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_abort()
613 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_req_tasklet() local
617 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_req_tasklet()
618 if (!host->req) { in jmb38x_ms_req_tasklet()
620 rc = memstick_next_req(msh, &host->req); in jmb38x_ms_req_tasklet()
621 dev_dbg(&host->chip->pdev->dev, "tasklet req %d\n", rc); in jmb38x_ms_req_tasklet()
624 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_req_tasklet()
634 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_submit_req() local
636 tasklet_schedule(&host->notify); in jmb38x_ms_submit_req()
639 static int jmb38x_ms_reset(struct jmb38x_ms_host *host) in jmb38x_ms_reset() argument
644 | readl(host->addr + HOST_CONTROL), in jmb38x_ms_reset()
645 host->addr + HOST_CONTROL); in jmb38x_ms_reset()
650 & readl(host->addr + HOST_CONTROL))) in jmb38x_ms_reset()
655 dev_dbg(&host->chip->pdev->dev, "reset_req timeout\n"); in jmb38x_ms_reset()
659 | readl(host->addr + HOST_CONTROL), in jmb38x_ms_reset()
660 host->addr + HOST_CONTROL); in jmb38x_ms_reset()
665 & readl(host->addr + HOST_CONTROL))) in jmb38x_ms_reset()
670 dev_dbg(&host->chip->pdev->dev, "reset timeout\n"); in jmb38x_ms_reset()
675 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_reset()
676 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_reset()
684 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_set_param() local
685 unsigned int host_ctl = readl(host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
692 rc = jmb38x_ms_reset(host); in jmb38x_ms_set_param()
699 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
701 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 in jmb38x_ms_set_param()
703 host->addr + PAD_PU_PD); in jmb38x_ms_set_param()
706 host->addr + PAD_OUTPUT_ENABLE); in jmb38x_ms_set_param()
709 dev_dbg(&host->chip->pdev->dev, "power on\n"); in jmb38x_ms_set_param()
713 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
714 writel(0, host->addr + PAD_OUTPUT_ENABLE); in jmb38x_ms_set_param()
715 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD); in jmb38x_ms_set_param()
716 dev_dbg(&host->chip->pdev->dev, "power off\n"); in jmb38x_ms_set_param()
721 dev_dbg(&host->chip->pdev->dev, in jmb38x_ms_set_param()
750 writel(host_ctl, host->addr + HOST_CONTROL); in jmb38x_ms_set_param()
751 writel(CLOCK_CONTROL_OFF, host->addr + CLOCK_CONTROL); in jmb38x_ms_set_param()
752 writel(clock_ctl, host->addr + CLOCK_CONTROL); in jmb38x_ms_set_param()
753 pci_write_config_byte(host->chip->pdev, in jmb38x_ms_set_param()
756 host->ifmode = value; in jmb38x_ms_set_param()
873 struct jmb38x_ms_host *host; in jmb38x_ms_alloc_host() local
880 host = memstick_priv(msh); in jmb38x_ms_alloc_host()
881 host->chip = jm; in jmb38x_ms_alloc_host()
882 host->addr = ioremap(pci_resource_start(jm->pdev, cnt), in jmb38x_ms_alloc_host()
884 if (!host->addr) in jmb38x_ms_alloc_host()
887 spin_lock_init(&host->lock); in jmb38x_ms_alloc_host()
888 host->id = cnt; in jmb38x_ms_alloc_host()
889 snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d", in jmb38x_ms_alloc_host()
890 host->id); in jmb38x_ms_alloc_host()
891 host->irq = jm->pdev->irq; in jmb38x_ms_alloc_host()
892 host->timeout_jiffies = msecs_to_jiffies(1000); in jmb38x_ms_alloc_host()
894 tasklet_init(&host->notify, jmb38x_ms_req_tasklet, (unsigned long)msh); in jmb38x_ms_alloc_host()
900 setup_timer(&host->timer, jmb38x_ms_abort, (unsigned long)msh); in jmb38x_ms_alloc_host()
902 if (!request_irq(host->irq, jmb38x_ms_isr, IRQF_SHARED, host->host_id, in jmb38x_ms_alloc_host()
906 iounmap(host->addr); in jmb38x_ms_alloc_host()
914 struct jmb38x_ms_host *host = memstick_priv(msh); in jmb38x_ms_free_host() local
916 free_irq(host->irq, msh); in jmb38x_ms_free_host()
917 iounmap(host->addr); in jmb38x_ms_free_host()
996 struct jmb38x_ms_host *host; in jmb38x_ms_remove() local
1004 host = memstick_priv(jm->hosts[cnt]); in jmb38x_ms_remove()
1007 tasklet_kill(&host->notify); in jmb38x_ms_remove()
1008 writel(0, host->addr + INT_SIGNAL_ENABLE); in jmb38x_ms_remove()
1009 writel(0, host->addr + INT_STATUS_ENABLE); in jmb38x_ms_remove()
1012 spin_lock_irqsave(&host->lock, flags); in jmb38x_ms_remove()
1013 if (host->req) { in jmb38x_ms_remove()
1014 host->req->error = -ETIME; in jmb38x_ms_remove()
1017 spin_unlock_irqrestore(&host->lock, flags); in jmb38x_ms_remove()