Lines Matching refs:host

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