Lines Matching refs:host

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