Lines Matching refs:vub300

374 	struct vub300_mmc_host *vub300 = kref_to_vub300_mmc_host(kref);  in vub300_delete()  local
375 struct mmc_host *mmc = vub300->mmc; in vub300_delete()
376 usb_free_urb(vub300->command_out_urb); in vub300_delete()
377 vub300->command_out_urb = NULL; in vub300_delete()
378 usb_free_urb(vub300->command_res_urb); in vub300_delete()
379 vub300->command_res_urb = NULL; in vub300_delete()
380 usb_put_dev(vub300->udev); in vub300_delete()
388 static void vub300_queue_cmnd_work(struct vub300_mmc_host *vub300) in vub300_queue_cmnd_work() argument
390 kref_get(&vub300->kref); in vub300_queue_cmnd_work()
391 if (queue_work(cmndworkqueue, &vub300->cmndwork)) { in vub300_queue_cmnd_work()
404 kref_put(&vub300->kref, vub300_delete); in vub300_queue_cmnd_work()
408 static void vub300_queue_poll_work(struct vub300_mmc_host *vub300, int delay) in vub300_queue_poll_work() argument
410 kref_get(&vub300->kref); in vub300_queue_poll_work()
411 if (queue_delayed_work(pollworkqueue, &vub300->pollwork, delay)) { in vub300_queue_poll_work()
424 kref_put(&vub300->kref, vub300_delete); in vub300_queue_poll_work()
428 static void vub300_queue_dead_work(struct vub300_mmc_host *vub300) in vub300_queue_dead_work() argument
430 kref_get(&vub300->kref); in vub300_queue_dead_work()
431 if (queue_work(deadworkqueue, &vub300->deadwork)) { in vub300_queue_dead_work()
444 kref_put(&vub300->kref, vub300_delete); in vub300_queue_dead_work()
450 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in irqpoll_res_completed() local
452 vub300->usb_transport_fail = urb->status; in irqpoll_res_completed()
453 complete(&vub300->irqpoll_complete); in irqpoll_res_completed()
458 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in irqpoll_out_completed() local
460 vub300->usb_transport_fail = urb->status; in irqpoll_out_completed()
461 complete(&vub300->irqpoll_complete); in irqpoll_out_completed()
466 usb_rcvbulkpipe(vub300->udev, vub300->cmnd_res_ep); in irqpoll_out_completed()
467 usb_fill_bulk_urb(vub300->command_res_urb, vub300->udev, pipe, in irqpoll_out_completed()
468 &vub300->resp, sizeof(vub300->resp), in irqpoll_out_completed()
469 irqpoll_res_completed, vub300); in irqpoll_out_completed()
470 vub300->command_res_urb->actual_length = 0; in irqpoll_out_completed()
471 ret = usb_submit_urb(vub300->command_res_urb, GFP_ATOMIC); in irqpoll_out_completed()
473 vub300->usb_transport_fail = ret; in irqpoll_out_completed()
474 complete(&vub300->irqpoll_complete); in irqpoll_out_completed()
480 static void send_irqpoll(struct vub300_mmc_host *vub300) in send_irqpoll() argument
485 vub300->cmnd.poll.header_size = 22; in send_irqpoll()
486 vub300->cmnd.poll.header_type = 1; in send_irqpoll()
487 vub300->cmnd.poll.port_number = 0; in send_irqpoll()
488 vub300->cmnd.poll.command_type = 2; in send_irqpoll()
489 vub300->cmnd.poll.poll_timeout_lsb = 0xFF & (unsigned)timeout; in send_irqpoll()
490 vub300->cmnd.poll.poll_timeout_msb = 0xFF & (unsigned)(timeout >> 8); in send_irqpoll()
491 usb_fill_bulk_urb(vub300->command_out_urb, vub300->udev, in send_irqpoll()
492 usb_sndbulkpipe(vub300->udev, vub300->cmnd_out_ep) in send_irqpoll()
493 , &vub300->cmnd, sizeof(vub300->cmnd) in send_irqpoll()
494 , irqpoll_out_completed, vub300); in send_irqpoll()
495 retval = usb_submit_urb(vub300->command_out_urb, GFP_KERNEL); in send_irqpoll()
497 vub300->usb_transport_fail = retval; in send_irqpoll()
498 vub300_queue_poll_work(vub300, 1); in send_irqpoll()
499 complete(&vub300->irqpoll_complete); in send_irqpoll()
506 static void new_system_port_status(struct vub300_mmc_host *vub300) in new_system_port_status() argument
508 int old_card_present = vub300->card_present; in new_system_port_status()
510 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0; in new_system_port_status()
511 vub300->read_only = in new_system_port_status()
512 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0; in new_system_port_status()
514 dev_info(&vub300->udev->dev, "card just inserted\n"); in new_system_port_status()
515 vub300->card_present = 1; in new_system_port_status()
516 vub300->bus_width = 0; in new_system_port_status()
518 strncpy(vub300->vub_name, "EMPTY Processing Disabled", in new_system_port_status()
519 sizeof(vub300->vub_name)); in new_system_port_status()
521 vub300->vub_name[0] = 0; in new_system_port_status()
522 mmc_detect_change(vub300->mmc, 1); in new_system_port_status()
524 dev_info(&vub300->udev->dev, "card just ejected\n"); in new_system_port_status()
525 vub300->card_present = 0; in new_system_port_status()
526 mmc_detect_change(vub300->mmc, 0); in new_system_port_status()
532 static void __add_offloaded_reg_to_fifo(struct vub300_mmc_host *vub300, in __add_offloaded_reg_to_fifo() argument
536 u8 r = vub300->fn[func].offload_point + vub300->fn[func].offload_count; in __add_offloaded_reg_to_fifo()
537 memcpy(&vub300->fn[func].reg[MAXREGMASK & r], register_access, in __add_offloaded_reg_to_fifo()
539 vub300->fn[func].offload_count += 1; in __add_offloaded_reg_to_fifo()
540 vub300->total_offload_count += 1; in __add_offloaded_reg_to_fifo()
543 static void add_offloaded_reg(struct vub300_mmc_host *vub300, in add_offloaded_reg() argument
550 u8 regs = vub300->dynamic_register_count; in add_offloaded_reg()
552 while (0 < regs-- && 1 == vub300->sdio_register[i].activate) { in add_offloaded_reg()
553 if (vub300->sdio_register[i].func_num == func && in add_offloaded_reg()
554 vub300->sdio_register[i].sdio_reg == Register) { in add_offloaded_reg()
555 if (vub300->sdio_register[i].prepared == 0) in add_offloaded_reg()
556 vub300->sdio_register[i].prepared = 1; in add_offloaded_reg()
557 vub300->sdio_register[i].response = in add_offloaded_reg()
559 vub300->sdio_register[i].regvalue = in add_offloaded_reg()
567 __add_offloaded_reg_to_fifo(vub300, register_access, func); in add_offloaded_reg()
570 static void check_vub300_port_status(struct vub300_mmc_host *vub300) in check_vub300_port_status() argument
578 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in check_vub300_port_status()
581 0x0000, 0x0000, &vub300->system_port_status, in check_vub300_port_status()
582 sizeof(vub300->system_port_status), HZ); in check_vub300_port_status()
583 if (sizeof(vub300->system_port_status) == retval) in check_vub300_port_status()
584 new_system_port_status(vub300); in check_vub300_port_status()
587 static void __vub300_irqpoll_response(struct vub300_mmc_host *vub300) in __vub300_irqpoll_response() argument
590 if (vub300->command_res_urb->actual_length == 0) in __vub300_irqpoll_response()
593 switch (vub300->resp.common.header_type) { in __vub300_irqpoll_response()
595 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
596 if (vub300->irq_enabled) in __vub300_irqpoll_response()
597 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
599 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
600 vub300->irq_disabled = 1; in __vub300_irqpoll_response()
601 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
604 if (vub300->resp.error.error_code == SD_ERROR_NO_DEVICE) in __vub300_irqpoll_response()
605 check_vub300_port_status(vub300); in __vub300_irqpoll_response()
608 vub300->system_port_status = vub300->resp.status; in __vub300_irqpoll_response()
609 new_system_port_status(vub300); in __vub300_irqpoll_response()
610 if (!vub300->card_present) in __vub300_irqpoll_response()
611 vub300_queue_poll_work(vub300, HZ / 5); in __vub300_irqpoll_response()
615 int offloaded_data_length = vub300->resp.common.header_size - 3; in __vub300_irqpoll_response()
619 add_offloaded_reg(vub300, &vub300->resp.irq.reg[ri]); in __vub300_irqpoll_response()
622 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
623 if (vub300->irq_enabled) in __vub300_irqpoll_response()
624 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
626 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
627 vub300->irq_disabled = 1; in __vub300_irqpoll_response()
628 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
633 int offloaded_data_length = vub300->resp.common.header_size - 3; in __vub300_irqpoll_response()
637 add_offloaded_reg(vub300, &vub300->resp.irq.reg[ri]); in __vub300_irqpoll_response()
640 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
641 if (vub300->irq_enabled) in __vub300_irqpoll_response()
642 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
643 else if (vub300->irqs_queued) in __vub300_irqpoll_response()
644 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
646 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
647 vub300->irq_disabled = 0; in __vub300_irqpoll_response()
648 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
652 vub300_queue_poll_work(vub300, 1); in __vub300_irqpoll_response()
659 static void __do_poll(struct vub300_mmc_host *vub300) in __do_poll() argument
663 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in __do_poll()
664 init_completion(&vub300->irqpoll_complete); in __do_poll()
665 send_irqpoll(vub300); in __do_poll()
666 commretval = wait_for_completion_timeout(&vub300->irqpoll_complete, in __do_poll()
668 if (vub300->usb_transport_fail) { in __do_poll()
671 vub300->usb_timed_out = 1; in __do_poll()
672 usb_kill_urb(vub300->command_out_urb); in __do_poll()
673 usb_kill_urb(vub300->command_res_urb); in __do_poll()
675 __vub300_irqpoll_response(vub300); in __do_poll()
684 struct vub300_mmc_host *vub300 = container_of(work, in vub300_pollwork_thread() local
686 if (!vub300->interface) { in vub300_pollwork_thread()
687 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
690 mutex_lock(&vub300->cmd_mutex); in vub300_pollwork_thread()
691 if (vub300->cmd) { in vub300_pollwork_thread()
692 vub300_queue_poll_work(vub300, 1); in vub300_pollwork_thread()
693 } else if (!vub300->card_present) { in vub300_pollwork_thread()
696 mutex_lock(&vub300->irq_mutex); in vub300_pollwork_thread()
697 if (!vub300->irq_enabled) { in vub300_pollwork_thread()
698 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
699 } else if (vub300->irqs_queued) { in vub300_pollwork_thread()
700 vub300->irqs_queued -= 1; in vub300_pollwork_thread()
701 mmc_signal_sdio_irq(vub300->mmc); in vub300_pollwork_thread()
702 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_pollwork_thread()
703 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
705 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
706 __do_poll(vub300); in vub300_pollwork_thread()
709 mutex_unlock(&vub300->cmd_mutex); in vub300_pollwork_thread()
710 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
715 struct vub300_mmc_host *vub300 = in vub300_deadwork_thread() local
717 if (!vub300->interface) { in vub300_deadwork_thread()
718 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
721 mutex_lock(&vub300->cmd_mutex); in vub300_deadwork_thread()
722 if (vub300->cmd) { in vub300_deadwork_thread()
729 } else if (vub300->card_present) { in vub300_deadwork_thread()
730 check_vub300_port_status(vub300); in vub300_deadwork_thread()
731 } else if (vub300->mmc && vub300->mmc->card && in vub300_deadwork_thread()
732 mmc_card_present(vub300->mmc->card)) { in vub300_deadwork_thread()
740 check_vub300_port_status(vub300); in vub300_deadwork_thread()
742 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_deadwork_thread()
743 mutex_unlock(&vub300->cmd_mutex); in vub300_deadwork_thread()
744 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
749 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)data; in vub300_inactivity_timer_expired() local
750 if (!vub300->interface) { in vub300_inactivity_timer_expired()
751 kref_put(&vub300->kref, vub300_delete); in vub300_inactivity_timer_expired()
752 } else if (vub300->cmd) { in vub300_inactivity_timer_expired()
753 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
755 vub300_queue_dead_work(vub300); in vub300_inactivity_timer_expired()
756 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
798 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_res_completed() local
801 } else if (vub300->command_res_urb->actual_length == 0) { in command_res_completed()
806 } else if (!vub300->data) { in command_res_completed()
808 } else if (vub300->resp.common.header_type != 0x02) { in command_res_completed()
813 } else if (vub300->urb) { in command_res_completed()
814 vub300->cmd->error = in command_res_completed()
815 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
816 usb_unlink_urb(vub300->urb); in command_res_completed()
818 vub300->cmd->error = in command_res_completed()
819 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
820 usb_sg_cancel(&vub300->sg_request); in command_res_completed()
822 complete(&vub300->command_complete); /* got_response_in */ in command_res_completed()
827 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_out_completed() local
829 complete(&vub300->command_complete); in command_out_completed()
833 usb_rcvbulkpipe(vub300->udev, vub300->cmnd_res_ep); in command_out_completed()
834 usb_fill_bulk_urb(vub300->command_res_urb, vub300->udev, pipe, in command_out_completed()
835 &vub300->resp, sizeof(vub300->resp), in command_out_completed()
836 command_res_completed, vub300); in command_out_completed()
837 vub300->command_res_urb->actual_length = 0; in command_out_completed()
838 ret = usb_submit_urb(vub300->command_res_urb, GFP_ATOMIC); in command_out_completed()
849 complete(&vub300->command_complete); in command_out_completed()
857 static void snoop_block_size_and_bus_width(struct vub300_mmc_host *vub300, in snoop_block_size_and_bus_width() argument
861 vub300->fbs[1] = (cmd_arg << 8) | (0x00FF & vub300->fbs[1]); in snoop_block_size_and_bus_width()
863 vub300->fbs[1] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[1]); in snoop_block_size_and_bus_width()
865 vub300->fbs[2] = (cmd_arg << 8) | (0x00FF & vub300->fbs[2]); in snoop_block_size_and_bus_width()
867 vub300->fbs[2] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[2]); in snoop_block_size_and_bus_width()
869 vub300->fbs[3] = (cmd_arg << 8) | (0x00FF & vub300->fbs[3]); in snoop_block_size_and_bus_width()
871 vub300->fbs[3] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[3]); in snoop_block_size_and_bus_width()
873 vub300->fbs[4] = (cmd_arg << 8) | (0x00FF & vub300->fbs[4]); in snoop_block_size_and_bus_width()
875 vub300->fbs[4] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[4]); in snoop_block_size_and_bus_width()
877 vub300->fbs[5] = (cmd_arg << 8) | (0x00FF & vub300->fbs[5]); in snoop_block_size_and_bus_width()
879 vub300->fbs[5] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[5]); in snoop_block_size_and_bus_width()
881 vub300->fbs[6] = (cmd_arg << 8) | (0x00FF & vub300->fbs[6]); in snoop_block_size_and_bus_width()
883 vub300->fbs[6] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[6]); in snoop_block_size_and_bus_width()
885 vub300->fbs[7] = (cmd_arg << 8) | (0x00FF & vub300->fbs[7]); in snoop_block_size_and_bus_width()
887 vub300->fbs[7] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[7]); in snoop_block_size_and_bus_width()
889 vub300->bus_width = 1; in snoop_block_size_and_bus_width()
891 vub300->bus_width = 4; in snoop_block_size_and_bus_width()
894 static void send_command(struct vub300_mmc_host *vub300) in send_command() argument
897 struct mmc_command *cmd = vub300->cmd; in send_command()
898 struct mmc_data *data = vub300->data; in send_command()
902 if (vub300->app_spec) { in send_command()
906 vub300->resp_len = 6; in send_command()
908 vub300->bus_width = 1; in send_command()
910 vub300->bus_width = 4; in send_command()
912 dev_err(&vub300->udev->dev, in send_command()
918 vub300->resp_len = 6; in send_command()
922 vub300->resp_len = 6; in send_command()
926 vub300->resp_len = 6; in send_command()
930 vub300->resp_len = 6; in send_command()
934 vub300->resp_len = 6; in send_command()
938 vub300->resp_len = 6; in send_command()
942 vub300->resp_len = 6; in send_command()
945 vub300->resp_len = 0; in send_command()
947 complete(&vub300->command_complete); in send_command()
950 vub300->app_spec = 0; in send_command()
955 vub300->resp_len = 0; in send_command()
959 vub300->resp_len = 6; in send_command()
963 vub300->resp_len = 17; in send_command()
967 vub300->resp_len = 6; in send_command()
971 vub300->resp_len = 0; in send_command()
975 vub300->resp_len = 6; in send_command()
979 vub300->resp_len = 6; in send_command()
983 vub300->resp_len = 6; in send_command()
987 vub300->resp_len = 6; in send_command()
991 vub300->resp_len = 17; in send_command()
995 vub300->resp_len = 17; in send_command()
999 vub300->resp_len = 6; in send_command()
1003 vub300->resp_len = 6; in send_command()
1007 vub300->resp_len = 0; in send_command()
1010 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in send_command()
1011 vub300->fbs[i] = 0xFFFF & cmd->arg; in send_command()
1013 vub300->resp_len = 6; in send_command()
1021 vub300->resp_len = 6; in send_command()
1026 vub300->resp_len = 6; in send_command()
1032 vub300->resp_len = 6; in send_command()
1036 vub300->resp_len = 6; in send_command()
1040 vub300->resp_len = 6; in send_command()
1044 vub300->resp_len = 6; in send_command()
1045 snoop_block_size_and_bus_width(vub300, cmd->arg); in send_command()
1049 vub300->resp_len = 6; in send_command()
1053 vub300->resp_len = 6; in send_command()
1054 vub300->app_spec = 1; in send_command()
1058 vub300->resp_len = 6; in send_command()
1061 vub300->resp_len = 0; in send_command()
1063 complete(&vub300->command_complete); in send_command()
1071 vub300->cmnd.head.header_size = 20; in send_command()
1072 vub300->cmnd.head.header_type = 0x00; in send_command()
1073 vub300->cmnd.head.port_number = 0; /* "0" means port 1 */ in send_command()
1074 vub300->cmnd.head.command_type = 0x00; /* standard read command */ in send_command()
1075 vub300->cmnd.head.response_type = response_type; in send_command()
1076 vub300->cmnd.head.command_index = cmd->opcode; in send_command()
1077 vub300->cmnd.head.arguments[0] = cmd->arg >> 24; in send_command()
1078 vub300->cmnd.head.arguments[1] = cmd->arg >> 16; in send_command()
1079 vub300->cmnd.head.arguments[2] = cmd->arg >> 8; in send_command()
1080 vub300->cmnd.head.arguments[3] = cmd->arg >> 0; in send_command()
1083 vub300->cmnd.head.block_count[0] = 0; in send_command()
1084 vub300->cmnd.head.block_count[1] = 0; in send_command()
1085 vub300->cmnd.head.block_size[0] = (vub300->fbs[fn] >> 8) & 0xFF; in send_command()
1086 vub300->cmnd.head.block_size[1] = (vub300->fbs[fn] >> 0) & 0xFF; in send_command()
1087 vub300->cmnd.head.command_type = 0x00; in send_command()
1088 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1089 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1090 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1091 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1093 vub300->cmnd.head.block_count[0] = 0; in send_command()
1094 vub300->cmnd.head.block_count[1] = 0; in send_command()
1095 vub300->cmnd.head.block_size[0] = (vub300->fbs[0] >> 8) & 0xFF; in send_command()
1096 vub300->cmnd.head.block_size[1] = (vub300->fbs[0] >> 0) & 0xFF; in send_command()
1097 vub300->cmnd.head.command_type = 0x00; in send_command()
1098 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1099 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1100 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1101 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1104 if (0x08 & vub300->cmnd.head.arguments[0]) { /* BLOCK MODE */ in send_command()
1105 vub300->cmnd.head.block_count[0] = in send_command()
1107 vub300->cmnd.head.block_count[1] = in send_command()
1109 vub300->cmnd.head.block_size[0] = in send_command()
1111 vub300->cmnd.head.block_size[1] = in send_command()
1114 vub300->cmnd.head.block_count[0] = 0; in send_command()
1115 vub300->cmnd.head.block_count[1] = 0; in send_command()
1116 vub300->cmnd.head.block_size[0] = in send_command()
1117 (vub300->datasize >> 8) & 0xFF; in send_command()
1118 vub300->cmnd.head.block_size[1] = in send_command()
1119 (vub300->datasize >> 0) & 0xFF; in send_command()
1121 vub300->cmnd.head.command_type = in send_command()
1123 vub300->cmnd.head.transfer_size[0] = in send_command()
1124 (vub300->datasize >> 24) & 0xFF; in send_command()
1125 vub300->cmnd.head.transfer_size[1] = in send_command()
1126 (vub300->datasize >> 16) & 0xFF; in send_command()
1127 vub300->cmnd.head.transfer_size[2] = in send_command()
1128 (vub300->datasize >> 8) & 0xFF; in send_command()
1129 vub300->cmnd.head.transfer_size[3] = in send_command()
1130 (vub300->datasize >> 0) & 0xFF; in send_command()
1131 if (vub300->datasize < vub300->fbs[fn]) { in send_command()
1132 vub300->cmnd.head.block_count[0] = 0; in send_command()
1133 vub300->cmnd.head.block_count[1] = 0; in send_command()
1136 vub300->cmnd.head.block_count[0] = (data->blocks >> 8) & 0xFF; in send_command()
1137 vub300->cmnd.head.block_count[1] = (data->blocks >> 0) & 0xFF; in send_command()
1138 vub300->cmnd.head.block_size[0] = (data->blksz >> 8) & 0xFF; in send_command()
1139 vub300->cmnd.head.block_size[1] = (data->blksz >> 0) & 0xFF; in send_command()
1140 vub300->cmnd.head.command_type = in send_command()
1142 vub300->cmnd.head.transfer_size[0] = in send_command()
1143 (vub300->datasize >> 24) & 0xFF; in send_command()
1144 vub300->cmnd.head.transfer_size[1] = in send_command()
1145 (vub300->datasize >> 16) & 0xFF; in send_command()
1146 vub300->cmnd.head.transfer_size[2] = in send_command()
1147 (vub300->datasize >> 8) & 0xFF; in send_command()
1148 vub300->cmnd.head.transfer_size[3] = in send_command()
1149 (vub300->datasize >> 0) & 0xFF; in send_command()
1150 if (vub300->datasize < vub300->fbs[0]) { in send_command()
1151 vub300->cmnd.head.block_count[0] = 0; in send_command()
1152 vub300->cmnd.head.block_count[1] = 0; in send_command()
1155 if (vub300->cmnd.head.block_size[0] || vub300->cmnd.head.block_size[1]) { in send_command()
1156 u16 block_size = vub300->cmnd.head.block_size[1] | in send_command()
1157 (vub300->cmnd.head.block_size[0] << 8); in send_command()
1160 vub300->cmnd.head.block_boundary[0] = in send_command()
1162 vub300->cmnd.head.block_boundary[1] = in send_command()
1165 vub300->cmnd.head.block_boundary[0] = 0; in send_command()
1166 vub300->cmnd.head.block_boundary[1] = 0; in send_command()
1168 usb_fill_bulk_urb(vub300->command_out_urb, vub300->udev, in send_command()
1169 usb_sndbulkpipe(vub300->udev, vub300->cmnd_out_ep), in send_command()
1170 &vub300->cmnd, sizeof(vub300->cmnd), in send_command()
1171 command_out_completed, vub300); in send_command()
1172 retval = usb_submit_urb(vub300->command_out_urb, GFP_KERNEL); in send_command()
1175 complete(&vub300->command_complete); in send_command()
1188 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)data; in vub300_sg_timed_out() local
1189 vub300->usb_timed_out = 1; in vub300_sg_timed_out()
1190 usb_sg_cancel(&vub300->sg_request); in vub300_sg_timed_out()
1191 usb_unlink_urb(vub300->command_out_urb); in vub300_sg_timed_out()
1192 usb_unlink_urb(vub300->command_res_urb); in vub300_sg_timed_out()
1203 static void __download_offload_pseudocode(struct vub300_mmc_host *vub300, in __download_offload_pseudocode() argument
1212 dev_info(&vub300->udev->dev, "using %s for SDIO offload processing\n", in __download_offload_pseudocode()
1213 vub300->vub_name); in __download_offload_pseudocode()
1217 dev_info(&vub300->udev->dev, "using offload firmware %s %s\n", fw->data, in __download_offload_pseudocode()
1218 vub300->vub_name); in __download_offload_pseudocode()
1220 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1222 vub300->vub_name); in __download_offload_pseudocode()
1223 strncpy(vub300->vub_name, "corrupt offload pseudocode", in __download_offload_pseudocode()
1224 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1243 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1244 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1251 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1253 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1257 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1260 vub300->vub_name); in __download_offload_pseudocode()
1261 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1263 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1267 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1269 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1270 strncpy(vub300->vub_name, "corrupt interrupt pseudocode", in __download_offload_pseudocode()
1271 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1290 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1291 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1298 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1300 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1304 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1307 vub300->vub_name); in __download_offload_pseudocode()
1308 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1310 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1314 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1316 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1317 strncpy(vub300->vub_name, "corrupt transfer pseudocode", in __download_offload_pseudocode()
1318 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1324 int I = vub300->dynamic_register_count = register_count; in __download_offload_pseudocode()
1328 vub300->sdio_register[i].func_num = *data++; in __download_offload_pseudocode()
1338 vub300->sdio_register[i].sdio_reg = func_num; in __download_offload_pseudocode()
1339 vub300->sdio_register[i].activate = 1; in __download_offload_pseudocode()
1340 vub300->sdio_register[i].prepared = 0; in __download_offload_pseudocode()
1343 dev_info(&vub300->udev->dev, in __download_offload_pseudocode()
1345 vub300->dynamic_register_count); in __download_offload_pseudocode()
1348 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1350 vub300->vub_name); in __download_offload_pseudocode()
1351 strncpy(vub300->vub_name, "corrupt dynamic registers", in __download_offload_pseudocode()
1352 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1361 static void download_offload_pseudocode(struct vub300_mmc_host *vub300) in download_offload_pseudocode() argument
1363 struct mmc_card *card = vub300->mmc->card; in download_offload_pseudocode()
1366 int l = snprintf(vub300->vub_name, sizeof(vub300->vub_name), in download_offload_pseudocode()
1372 l += snprintf(vub300->vub_name + l, in download_offload_pseudocode()
1373 sizeof(vub300->vub_name) - l, "_%04X%04X", in download_offload_pseudocode()
1376 snprintf(vub300->vub_name + l, sizeof(vub300->vub_name) - l, ".bin"); in download_offload_pseudocode()
1377 dev_info(&vub300->udev->dev, "requesting offload firmware %s\n", in download_offload_pseudocode()
1378 vub300->vub_name); in download_offload_pseudocode()
1379 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1381 strncpy(vub300->vub_name, "vub_default.bin", in download_offload_pseudocode()
1382 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1383 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1385 strncpy(vub300->vub_name, in download_offload_pseudocode()
1387 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1389 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1393 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1403 static int vub300_usb_bulk_msg(struct vub300_mmc_host *vub300, in vub300_usb_bulk_msg() argument
1408 struct usb_device *usb_dev = vub300->udev; in vub300_usb_bulk_msg()
1411 vub300->urb = usb_alloc_urb(0, GFP_KERNEL); in vub300_usb_bulk_msg()
1412 if (!vub300->urb) in vub300_usb_bulk_msg()
1414 usb_fill_bulk_urb(vub300->urb, usb_dev, pipe, data, len, in vub300_usb_bulk_msg()
1417 vub300->urb->context = &done; in vub300_usb_bulk_msg()
1418 vub300->urb->actual_length = 0; in vub300_usb_bulk_msg()
1419 retval = usb_submit_urb(vub300->urb, GFP_KERNEL); in vub300_usb_bulk_msg()
1425 usb_kill_urb(vub300->urb); in vub300_usb_bulk_msg()
1427 retval = vub300->urb->status; in vub300_usb_bulk_msg()
1430 *actual_length = vub300->urb->actual_length; in vub300_usb_bulk_msg()
1431 usb_free_urb(vub300->urb); in vub300_usb_bulk_msg()
1432 vub300->urb = NULL; in vub300_usb_bulk_msg()
1436 static int __command_read_data(struct vub300_mmc_host *vub300, in __command_read_data() argument
1440 int linear_length = vub300->datasize; in __command_read_data()
1441 int padded_length = vub300->large_usb_packets ? in __command_read_data()
1447 pipe = usb_rcvbulkpipe(vub300->udev, vub300->data_inp_ep); in __command_read_data()
1448 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_read_data()
1452 usb_unlink_urb(vub300->command_out_urb); in __command_read_data()
1453 usb_unlink_urb(vub300->command_res_urb); in __command_read_data()
1458 vub300->sg_transfer_timer.expires = in __command_read_data()
1461 add_timer(&vub300->sg_transfer_timer); in __command_read_data()
1462 usb_sg_wait(&vub300->sg_request); in __command_read_data()
1463 del_timer(&vub300->sg_transfer_timer); in __command_read_data()
1464 if (vub300->sg_request.status < 0) { in __command_read_data()
1465 cmd->error = vub300->sg_request.status; in __command_read_data()
1469 data->bytes_xfered = vub300->datasize; in __command_read_data()
1477 unsigned pipe = usb_rcvbulkpipe(vub300->udev, in __command_read_data()
1478 vub300->data_inp_ep); in __command_read_data()
1480 result = vub300_usb_bulk_msg(vub300, pipe, buf, in __command_read_data()
1497 data->bytes_xfered = vub300->datasize; in __command_read_data()
1508 static int __command_write_data(struct vub300_mmc_host *vub300, in __command_write_data() argument
1512 unsigned pipe = usb_sndbulkpipe(vub300->udev, vub300->data_out_ep); in __command_write_data()
1513 int linear_length = vub300->datasize; in __command_write_data()
1520 vub300->padded_buffer, in __command_write_data()
1521 sizeof(vub300->padded_buffer)); in __command_write_data()
1522 memset(vub300->padded_buffer + linear_length, 0, in __command_write_data()
1523 sizeof(vub300->padded_buffer) - linear_length); in __command_write_data()
1524 result = vub300_usb_bulk_msg(vub300, pipe, vub300->padded_buffer, in __command_write_data()
1525 sizeof(vub300->padded_buffer), in __command_write_data()
1527 (sizeof(vub300->padded_buffer) / in __command_write_data()
1533 data->bytes_xfered = vub300->datasize; in __command_write_data()
1535 } else if ((!vub300->large_usb_packets && (0 < modulo_64_length)) || in __command_write_data()
1536 (vub300->large_usb_packets && (64 > modulo_512_length)) in __command_write_data()
1548 vub300_usb_bulk_msg(vub300, pipe, buf, in __command_write_data()
1556 data->bytes_xfered = vub300->datasize; in __command_write_data()
1566 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_write_data()
1570 usb_unlink_urb(vub300->command_out_urb); in __command_write_data()
1571 usb_unlink_urb(vub300->command_res_urb); in __command_write_data()
1575 vub300->sg_transfer_timer.expires = in __command_write_data()
1578 add_timer(&vub300->sg_transfer_timer); in __command_write_data()
1579 usb_sg_wait(&vub300->sg_request); in __command_write_data()
1583 del_timer(&vub300->sg_transfer_timer); in __command_write_data()
1584 if (vub300->sg_request.status < 0) { in __command_write_data()
1585 cmd->error = vub300->sg_request.status; in __command_write_data()
1588 data->bytes_xfered = vub300->datasize; in __command_write_data()
1596 static void __vub300_command_response(struct vub300_mmc_host *vub300, in __vub300_command_response() argument
1604 wait_for_completion_timeout(&vub300->command_complete, in __vub300_command_response()
1609 vub300->usb_timed_out = 1; in __vub300_command_response()
1610 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1611 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1613 result = usb_lock_device_for_reset(vub300->udev, in __vub300_command_response()
1614 vub300->interface); in __vub300_command_response()
1616 result = usb_reset_device(vub300->udev); in __vub300_command_response()
1617 usb_unlock_device(vub300->udev); in __vub300_command_response()
1621 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1622 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1629 } else if (vub300->command_out_urb->status) { in __vub300_command_response()
1630 vub300->usb_transport_fail = vub300->command_out_urb->status; in __vub300_command_response()
1631 cmd->error = -EPROTO == vub300->command_out_urb->status ? in __vub300_command_response()
1632 -ESHUTDOWN : vub300->command_out_urb->status; in __vub300_command_response()
1633 } else if (vub300->command_res_urb->status) { in __vub300_command_response()
1634 vub300->usb_transport_fail = vub300->command_res_urb->status; in __vub300_command_response()
1635 cmd->error = -EPROTO == vub300->command_res_urb->status ? in __vub300_command_response()
1636 -ESHUTDOWN : vub300->command_res_urb->status; in __vub300_command_response()
1637 } else if (vub300->resp.common.header_type == 0x00) { in __vub300_command_response()
1642 } else if (vub300->resp.common.header_type == RESPONSE_ERROR) { in __vub300_command_response()
1644 vub300_response_error(vub300->resp.error.error_code); in __vub300_command_response()
1645 if (vub300->data) in __vub300_command_response()
1646 usb_sg_cancel(&vub300->sg_request); in __vub300_command_response()
1647 } else if (vub300->resp.common.header_type == RESPONSE_PIGGYBACKED) { in __vub300_command_response()
1649 vub300->resp.common.header_size - in __vub300_command_response()
1654 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1657 vub300->resp.common.header_size = in __vub300_command_response()
1659 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1661 } else if (vub300->resp.common.header_type == RESPONSE_PIG_DISABLED) { in __vub300_command_response()
1663 vub300->resp.common.header_size - in __vub300_command_response()
1668 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1671 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1672 if (vub300->irqs_queued) { in __vub300_command_response()
1673 vub300->irqs_queued += 1; in __vub300_command_response()
1674 } else if (vub300->irq_enabled) { in __vub300_command_response()
1675 vub300->irqs_queued += 1; in __vub300_command_response()
1676 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1678 vub300->irqs_queued += 1; in __vub300_command_response()
1680 vub300->irq_disabled = 1; in __vub300_command_response()
1681 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1682 vub300->resp.common.header_size = in __vub300_command_response()
1684 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1686 } else if (vub300->resp.common.header_type == RESPONSE_PIG_ENABLED) { in __vub300_command_response()
1688 vub300->resp.common.header_size - in __vub300_command_response()
1693 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1696 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1697 if (vub300->irqs_queued) { in __vub300_command_response()
1698 vub300->irqs_queued += 1; in __vub300_command_response()
1699 } else if (vub300->irq_enabled) { in __vub300_command_response()
1700 vub300->irqs_queued += 1; in __vub300_command_response()
1701 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1703 vub300->irqs_queued += 1; in __vub300_command_response()
1705 vub300->irq_disabled = 0; in __vub300_command_response()
1706 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1707 vub300->resp.common.header_size = in __vub300_command_response()
1709 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1716 static void construct_request_response(struct vub300_mmc_host *vub300, in construct_request_response() argument
1719 int resp_len = vub300->resp_len; in construct_request_response()
1723 u8 *r = vub300->resp.response.command_response; in construct_request_response()
1747 struct vub300_mmc_host *vub300 = in vub300_cmndwork_thread() local
1749 if (!vub300->interface) { in vub300_cmndwork_thread()
1750 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1753 struct mmc_request *req = vub300->req; in vub300_cmndwork_thread()
1754 struct mmc_command *cmd = vub300->cmd; in vub300_cmndwork_thread()
1755 struct mmc_data *data = vub300->data; in vub300_cmndwork_thread()
1757 mutex_lock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1758 init_completion(&vub300->command_complete); in vub300_cmndwork_thread()
1759 if (likely(vub300->vub_name[0]) || !vub300->mmc->card || in vub300_cmndwork_thread()
1760 !mmc_card_present(vub300->mmc->card)) { in vub300_cmndwork_thread()
1766 } else if (0 == vub300->mmc->card->sdio_funcs) { in vub300_cmndwork_thread()
1767 strncpy(vub300->vub_name, "SD memory device", in vub300_cmndwork_thread()
1768 sizeof(vub300->vub_name)); in vub300_cmndwork_thread()
1770 download_offload_pseudocode(vub300); in vub300_cmndwork_thread()
1772 send_command(vub300); in vub300_cmndwork_thread()
1776 data_length = __command_read_data(vub300, cmd, data); in vub300_cmndwork_thread()
1778 data_length = __command_write_data(vub300, cmd, data); in vub300_cmndwork_thread()
1779 __vub300_command_response(vub300, cmd, data, data_length); in vub300_cmndwork_thread()
1780 vub300->req = NULL; in vub300_cmndwork_thread()
1781 vub300->cmd = NULL; in vub300_cmndwork_thread()
1782 vub300->data = NULL; in vub300_cmndwork_thread()
1785 check_vub300_port_status(vub300); in vub300_cmndwork_thread()
1786 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1787 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1788 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1791 construct_request_response(vub300, cmd); in vub300_cmndwork_thread()
1792 vub300->resp_len = 0; in vub300_cmndwork_thread()
1793 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1794 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1795 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1801 static int examine_cyclic_buffer(struct vub300_mmc_host *vub300, in examine_cyclic_buffer() argument
1809 int first = MAXREGMASK & vub300->fn[Function].offload_point; in examine_cyclic_buffer()
1810 struct offload_registers_access *rf = &vub300->fn[Function].reg[first]; in examine_cyclic_buffer()
1821 vub300->fn[Function].offload_point += 1; in examine_cyclic_buffer()
1822 vub300->fn[Function].offload_count -= 1; in examine_cyclic_buffer()
1823 vub300->total_offload_count -= 1; in examine_cyclic_buffer()
1827 u8 register_count = vub300->fn[Function].offload_count - 1; in examine_cyclic_buffer()
1828 u32 register_point = vub300->fn[Function].offload_point + 1; in examine_cyclic_buffer()
1832 &vub300->fn[Function].reg[point]; in examine_cyclic_buffer()
1843 vub300->fn[Function].offload_point += delta; in examine_cyclic_buffer()
1844 vub300->fn[Function].offload_count -= delta; in examine_cyclic_buffer()
1845 vub300->total_offload_count -= delta; in examine_cyclic_buffer()
1858 static int satisfy_request_from_offloaded_data(struct vub300_mmc_host *vub300, in satisfy_request_from_offloaded_data() argument
1862 u8 regs = vub300->dynamic_register_count; in satisfy_request_from_offloaded_data()
1867 if ((vub300->sdio_register[i].func_num == func) && in satisfy_request_from_offloaded_data()
1868 (vub300->sdio_register[i].sdio_reg == reg)) { in satisfy_request_from_offloaded_data()
1869 if (!vub300->sdio_register[i].prepared) { in satisfy_request_from_offloaded_data()
1876 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1882 u8 rsp2 = vub300->sdio_register[i].response; in satisfy_request_from_offloaded_data()
1883 u8 rsp3 = vub300->sdio_register[i].regvalue; in satisfy_request_from_offloaded_data()
1884 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1897 if (vub300->total_offload_count == 0) in satisfy_request_from_offloaded_data()
1899 else if (vub300->fn[func].offload_count == 0) in satisfy_request_from_offloaded_data()
1902 return examine_cyclic_buffer(vub300, cmd, func); in satisfy_request_from_offloaded_data()
1908 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_request() local
1909 if (!vub300->interface) { in vub300_mmc_request()
1915 if (!vub300->card_powered) { in vub300_mmc_request()
1920 if (!vub300->card_present) { in vub300_mmc_request()
1925 if (vub300->usb_transport_fail) { in vub300_mmc_request()
1926 cmd->error = vub300->usb_transport_fail; in vub300_mmc_request()
1930 if (!vub300->interface) { in vub300_mmc_request()
1935 kref_get(&vub300->kref); in vub300_mmc_request()
1936 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_request()
1937 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_mmc_request()
1943 satisfy_request_from_offloaded_data(vub300, cmd)) { in vub300_mmc_request()
1945 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1946 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1950 vub300->cmd = cmd; in vub300_mmc_request()
1951 vub300->req = req; in vub300_mmc_request()
1952 vub300->data = data; in vub300_mmc_request()
1954 vub300->datasize = data->blksz * data->blocks; in vub300_mmc_request()
1956 vub300->datasize = 0; in vub300_mmc_request()
1957 vub300_queue_cmnd_work(vub300); in vub300_mmc_request()
1958 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1959 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1971 static void __set_clock_speed(struct vub300_mmc_host *vub300, u8 buf[8], in __set_clock_speed() argument
1998 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in __set_clock_speed()
2003 dev_err(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2006 dev_dbg(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2013 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_set_ios() local
2014 if (!vub300->interface) in vub300_mmc_set_ios()
2016 kref_get(&vub300->kref); in vub300_mmc_set_ios()
2017 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2018 if ((ios->power_mode == MMC_POWER_OFF) && vub300->card_powered) { in vub300_mmc_set_ios()
2019 vub300->card_powered = 0; in vub300_mmc_set_ios()
2020 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2026 } else if ((ios->power_mode == MMC_POWER_UP) && !vub300->card_powered) { in vub300_mmc_set_ios()
2027 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2032 vub300->card_powered = 1; in vub300_mmc_set_ios()
2036 __set_clock_speed(vub300, buf, ios); in vub300_mmc_set_ios()
2042 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2043 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_set_ios()
2048 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_get_ro() local
2049 return vub300->read_only; in vub300_mmc_get_ro()
2054 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_enable_sdio_irq() local
2055 if (!vub300->interface) in vub300_enable_sdio_irq()
2057 kref_get(&vub300->kref); in vub300_enable_sdio_irq()
2059 mutex_lock(&vub300->irq_mutex); in vub300_enable_sdio_irq()
2060 if (vub300->irqs_queued) { in vub300_enable_sdio_irq()
2061 vub300->irqs_queued -= 1; in vub300_enable_sdio_irq()
2062 mmc_signal_sdio_irq(vub300->mmc); in vub300_enable_sdio_irq()
2063 } else if (vub300->irq_disabled) { in vub300_enable_sdio_irq()
2064 vub300->irq_disabled = 0; in vub300_enable_sdio_irq()
2065 vub300->irq_enabled = 1; in vub300_enable_sdio_irq()
2066 vub300_queue_poll_work(vub300, 0); in vub300_enable_sdio_irq()
2067 } else if (vub300->irq_enabled) { in vub300_enable_sdio_irq()
2070 vub300->irq_enabled = 1; in vub300_enable_sdio_irq()
2071 vub300_queue_poll_work(vub300, 0); in vub300_enable_sdio_irq()
2073 mutex_unlock(&vub300->irq_mutex); in vub300_enable_sdio_irq()
2075 vub300->irq_enabled = 0; in vub300_enable_sdio_irq()
2077 kref_put(&vub300->kref, vub300_delete); in vub300_enable_sdio_irq()
2082 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_init_card() local
2083 dev_info(&vub300->udev->dev, "NO host QUIRKS for this card\n"); in vub300_init_card()
2097 struct vub300_mmc_host *vub300; in vub300_probe() local
2185 vub300 = mmc_priv(mmc); in vub300_probe()
2186 vub300->mmc = mmc; in vub300_probe()
2187 vub300->card_powered = 0; in vub300_probe()
2188 vub300->bus_width = 0; in vub300_probe()
2189 vub300->cmnd.head.block_size[0] = 0x00; in vub300_probe()
2190 vub300->cmnd.head.block_size[1] = 0x00; in vub300_probe()
2191 vub300->app_spec = 0; in vub300_probe()
2192 mutex_init(&vub300->cmd_mutex); in vub300_probe()
2193 mutex_init(&vub300->irq_mutex); in vub300_probe()
2194 vub300->command_out_urb = command_out_urb; in vub300_probe()
2195 vub300->command_res_urb = command_res_urb; in vub300_probe()
2196 vub300->usb_timed_out = 0; in vub300_probe()
2197 vub300->dynamic_register_count = 0; in vub300_probe()
2199 for (i = 0; i < ARRAY_SIZE(vub300->fn); i++) { in vub300_probe()
2200 vub300->fn[i].offload_point = 0; in vub300_probe()
2201 vub300->fn[i].offload_count = 0; in vub300_probe()
2204 vub300->total_offload_count = 0; in vub300_probe()
2205 vub300->irq_enabled = 0; in vub300_probe()
2206 vub300->irq_disabled = 0; in vub300_probe()
2207 vub300->irqs_queued = 0; in vub300_probe()
2209 for (i = 0; i < ARRAY_SIZE(vub300->sdio_register); i++) in vub300_probe()
2210 vub300->sdio_register[i++].activate = 0; in vub300_probe()
2212 vub300->udev = udev; in vub300_probe()
2213 vub300->interface = interface; in vub300_probe()
2214 vub300->cmnd_res_ep = 0; in vub300_probe()
2215 vub300->cmnd_out_ep = 0; in vub300_probe()
2216 vub300->data_inp_ep = 0; in vub300_probe()
2217 vub300->data_out_ep = 0; in vub300_probe()
2219 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in vub300_probe()
2220 vub300->fbs[i] = 512; in vub300_probe()
2231 vub300->large_usb_packets = 0; in vub300_probe()
2236 dev_info(&vub300->udev->dev, in vub300_probe()
2242 vub300->large_usb_packets = 1; in vub300_probe()
2244 if (!vub300->cmnd_res_ep) { in vub300_probe()
2245 vub300->cmnd_res_ep = in vub300_probe()
2247 } else if (!vub300->data_inp_ep) { in vub300_probe()
2248 vub300->data_inp_ep = in vub300_probe()
2251 dev_warn(&vub300->udev->dev, in vub300_probe()
2256 if (!vub300->cmnd_out_ep) { in vub300_probe()
2257 vub300->cmnd_out_ep = in vub300_probe()
2259 } else if (!vub300->data_out_ep) { in vub300_probe()
2260 vub300->data_out_ep = in vub300_probe()
2263 dev_warn(&vub300->udev->dev, in vub300_probe()
2268 dev_warn(&vub300->udev->dev, in vub300_probe()
2273 if (vub300->cmnd_res_ep && vub300->cmnd_out_ep && in vub300_probe()
2274 vub300->data_inp_ep && vub300->data_out_ep) { in vub300_probe()
2275 dev_info(&vub300->udev->dev, in vub300_probe()
2278 vub300->large_usb_packets ? "LARGE" : "SMALL", in vub300_probe()
2279 vub300->cmnd_out_ep, vub300->cmnd_res_ep, in vub300_probe()
2280 vub300->data_out_ep, vub300->data_inp_ep); in vub300_probe()
2283 dev_err(&vub300->udev->dev, in vub300_probe()
2289 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2292 0x0000, 0x0000, &vub300->hc_info, in vub300_probe()
2293 sizeof(vub300->hc_info), HZ); in vub300_probe()
2297 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2303 dev_info(&vub300->udev->dev, in vub300_probe()
2309 vub300->large_usb_packets ? 512 : 64); in vub300_probe()
2311 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2314 0x0000, 0x0000, &vub300->system_port_status, in vub300_probe()
2315 sizeof(vub300->system_port_status), HZ); in vub300_probe()
2318 } else if (sizeof(vub300->system_port_status) == retval) { in vub300_probe()
2319 vub300->card_present = in vub300_probe()
2320 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2321 vub300->read_only = in vub300_probe()
2322 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2326 usb_set_intfdata(interface, vub300); in vub300_probe()
2327 INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread); in vub300_probe()
2328 INIT_WORK(&vub300->cmndwork, vub300_cmndwork_thread); in vub300_probe()
2329 INIT_WORK(&vub300->deadwork, vub300_deadwork_thread); in vub300_probe()
2330 kref_init(&vub300->kref); in vub300_probe()
2331 init_timer(&vub300->sg_transfer_timer); in vub300_probe()
2332 vub300->sg_transfer_timer.data = (unsigned long)vub300; in vub300_probe()
2333 vub300->sg_transfer_timer.function = vub300_sg_timed_out; in vub300_probe()
2334 kref_get(&vub300->kref); in vub300_probe()
2335 init_timer(&vub300->inactivity_timer); in vub300_probe()
2336 vub300->inactivity_timer.data = (unsigned long)vub300; in vub300_probe()
2337 vub300->inactivity_timer.function = vub300_inactivity_timer_expired; in vub300_probe()
2338 vub300->inactivity_timer.expires = jiffies + HZ; in vub300_probe()
2339 add_timer(&vub300->inactivity_timer); in vub300_probe()
2340 if (vub300->card_present) in vub300_probe()
2341 dev_info(&vub300->udev->dev, in vub300_probe()
2346 dev_info(&vub300->udev->dev, in vub300_probe()
2369 struct vub300_mmc_host *vub300 = usb_get_intfdata(interface); in vub300_disconnect() local
2370 if (!vub300 || !vub300->mmc) { in vub300_disconnect()
2373 struct mmc_host *mmc = vub300->mmc; in vub300_disconnect()
2374 if (!vub300->mmc) { in vub300_disconnect()
2380 vub300->interface = NULL; in vub300_disconnect()
2381 kref_put(&vub300->kref, vub300_delete); in vub300_disconnect()
2406 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_pre_reset() local
2407 mutex_lock(&vub300->cmd_mutex); in vub300_pre_reset()
2413 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_post_reset() local
2415 vub300->errors = -EPIPE; in vub300_post_reset()
2416 mutex_unlock(&vub300->cmd_mutex); in vub300_post_reset()