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()
644 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
645 vub300->irq_disabled = 0; in __vub300_irqpoll_response()
646 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
650 vub300_queue_poll_work(vub300, 1); in __vub300_irqpoll_response()
657 static void __do_poll(struct vub300_mmc_host *vub300) in __do_poll() argument
661 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in __do_poll()
662 init_completion(&vub300->irqpoll_complete); in __do_poll()
663 send_irqpoll(vub300); in __do_poll()
664 commretval = wait_for_completion_timeout(&vub300->irqpoll_complete, in __do_poll()
666 if (vub300->usb_transport_fail) { in __do_poll()
669 vub300->usb_timed_out = 1; in __do_poll()
670 usb_kill_urb(vub300->command_out_urb); in __do_poll()
671 usb_kill_urb(vub300->command_res_urb); in __do_poll()
673 __vub300_irqpoll_response(vub300); in __do_poll()
682 struct vub300_mmc_host *vub300 = container_of(work, in vub300_pollwork_thread() local
684 if (!vub300->interface) { in vub300_pollwork_thread()
685 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
688 mutex_lock(&vub300->cmd_mutex); in vub300_pollwork_thread()
689 if (vub300->cmd) { in vub300_pollwork_thread()
690 vub300_queue_poll_work(vub300, 1); in vub300_pollwork_thread()
691 } else if (!vub300->card_present) { in vub300_pollwork_thread()
694 mutex_lock(&vub300->irq_mutex); in vub300_pollwork_thread()
695 if (!vub300->irq_enabled) { in vub300_pollwork_thread()
696 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
697 } else if (vub300->irqs_queued) { in vub300_pollwork_thread()
698 vub300->irqs_queued -= 1; in vub300_pollwork_thread()
699 mmc_signal_sdio_irq(vub300->mmc); in vub300_pollwork_thread()
700 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_pollwork_thread()
701 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
703 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
704 __do_poll(vub300); in vub300_pollwork_thread()
707 mutex_unlock(&vub300->cmd_mutex); in vub300_pollwork_thread()
708 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
713 struct vub300_mmc_host *vub300 = in vub300_deadwork_thread() local
715 if (!vub300->interface) { in vub300_deadwork_thread()
716 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
719 mutex_lock(&vub300->cmd_mutex); in vub300_deadwork_thread()
720 if (vub300->cmd) { in vub300_deadwork_thread()
727 } else if (vub300->card_present) { in vub300_deadwork_thread()
728 check_vub300_port_status(vub300); in vub300_deadwork_thread()
729 } else if (vub300->mmc && vub300->mmc->card) { in vub300_deadwork_thread()
737 check_vub300_port_status(vub300); in vub300_deadwork_thread()
739 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_deadwork_thread()
740 mutex_unlock(&vub300->cmd_mutex); in vub300_deadwork_thread()
741 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
746 struct vub300_mmc_host *vub300 = from_timer(vub300, t, in vub300_inactivity_timer_expired() local
748 if (!vub300->interface) { in vub300_inactivity_timer_expired()
749 kref_put(&vub300->kref, vub300_delete); in vub300_inactivity_timer_expired()
750 } else if (vub300->cmd) { in vub300_inactivity_timer_expired()
751 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
753 vub300_queue_dead_work(vub300); in vub300_inactivity_timer_expired()
754 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
796 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_res_completed() local
799 } else if (vub300->command_res_urb->actual_length == 0) { in command_res_completed()
804 } else if (!vub300->data) { in command_res_completed()
806 } else if (vub300->resp.common.header_type != 0x02) { in command_res_completed()
811 } else if (vub300->urb) { in command_res_completed()
812 vub300->cmd->error = in command_res_completed()
813 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
814 usb_unlink_urb(vub300->urb); in command_res_completed()
816 vub300->cmd->error = in command_res_completed()
817 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
818 usb_sg_cancel(&vub300->sg_request); in command_res_completed()
820 complete(&vub300->command_complete); /* got_response_in */ in command_res_completed()
825 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_out_completed() local
827 complete(&vub300->command_complete); in command_out_completed()
831 usb_rcvbulkpipe(vub300->udev, vub300->cmnd_res_ep); in command_out_completed()
832 usb_fill_bulk_urb(vub300->command_res_urb, vub300->udev, pipe, in command_out_completed()
833 &vub300->resp, sizeof(vub300->resp), in command_out_completed()
834 command_res_completed, vub300); in command_out_completed()
835 vub300->command_res_urb->actual_length = 0; in command_out_completed()
836 ret = usb_submit_urb(vub300->command_res_urb, GFP_ATOMIC); in command_out_completed()
847 complete(&vub300->command_complete); in command_out_completed()
855 static void snoop_block_size_and_bus_width(struct vub300_mmc_host *vub300, in snoop_block_size_and_bus_width() argument
859 vub300->fbs[1] = (cmd_arg << 8) | (0x00FF & vub300->fbs[1]); in snoop_block_size_and_bus_width()
861 vub300->fbs[1] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[1]); in snoop_block_size_and_bus_width()
863 vub300->fbs[2] = (cmd_arg << 8) | (0x00FF & vub300->fbs[2]); in snoop_block_size_and_bus_width()
865 vub300->fbs[2] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[2]); in snoop_block_size_and_bus_width()
867 vub300->fbs[3] = (cmd_arg << 8) | (0x00FF & vub300->fbs[3]); in snoop_block_size_and_bus_width()
869 vub300->fbs[3] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[3]); in snoop_block_size_and_bus_width()
871 vub300->fbs[4] = (cmd_arg << 8) | (0x00FF & vub300->fbs[4]); in snoop_block_size_and_bus_width()
873 vub300->fbs[4] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[4]); in snoop_block_size_and_bus_width()
875 vub300->fbs[5] = (cmd_arg << 8) | (0x00FF & vub300->fbs[5]); in snoop_block_size_and_bus_width()
877 vub300->fbs[5] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[5]); in snoop_block_size_and_bus_width()
879 vub300->fbs[6] = (cmd_arg << 8) | (0x00FF & vub300->fbs[6]); in snoop_block_size_and_bus_width()
881 vub300->fbs[6] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[6]); in snoop_block_size_and_bus_width()
883 vub300->fbs[7] = (cmd_arg << 8) | (0x00FF & vub300->fbs[7]); in snoop_block_size_and_bus_width()
885 vub300->fbs[7] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[7]); in snoop_block_size_and_bus_width()
887 vub300->bus_width = 1; in snoop_block_size_and_bus_width()
889 vub300->bus_width = 4; in snoop_block_size_and_bus_width()
892 static void send_command(struct vub300_mmc_host *vub300) in send_command() argument
895 struct mmc_command *cmd = vub300->cmd; in send_command()
896 struct mmc_data *data = vub300->data; in send_command()
900 if (vub300->app_spec) { in send_command()
904 vub300->resp_len = 6; in send_command()
906 vub300->bus_width = 1; in send_command()
908 vub300->bus_width = 4; in send_command()
910 dev_err(&vub300->udev->dev, in send_command()
916 vub300->resp_len = 6; in send_command()
920 vub300->resp_len = 6; in send_command()
924 vub300->resp_len = 6; in send_command()
928 vub300->resp_len = 6; in send_command()
932 vub300->resp_len = 6; in send_command()
936 vub300->resp_len = 6; in send_command()
940 vub300->resp_len = 6; in send_command()
943 vub300->resp_len = 0; in send_command()
945 complete(&vub300->command_complete); in send_command()
948 vub300->app_spec = 0; in send_command()
953 vub300->resp_len = 0; in send_command()
957 vub300->resp_len = 6; in send_command()
961 vub300->resp_len = 17; in send_command()
965 vub300->resp_len = 6; in send_command()
969 vub300->resp_len = 0; in send_command()
973 vub300->resp_len = 6; in send_command()
977 vub300->resp_len = 6; in send_command()
981 vub300->resp_len = 6; in send_command()
985 vub300->resp_len = 6; in send_command()
989 vub300->resp_len = 17; in send_command()
993 vub300->resp_len = 17; in send_command()
997 vub300->resp_len = 6; in send_command()
1001 vub300->resp_len = 6; in send_command()
1005 vub300->resp_len = 0; in send_command()
1008 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in send_command()
1009 vub300->fbs[i] = 0xFFFF & cmd->arg; in send_command()
1011 vub300->resp_len = 6; in send_command()
1019 vub300->resp_len = 6; in send_command()
1024 vub300->resp_len = 6; in send_command()
1030 vub300->resp_len = 6; in send_command()
1034 vub300->resp_len = 6; in send_command()
1038 vub300->resp_len = 6; in send_command()
1042 vub300->resp_len = 6; in send_command()
1043 snoop_block_size_and_bus_width(vub300, cmd->arg); in send_command()
1047 vub300->resp_len = 6; in send_command()
1051 vub300->resp_len = 6; in send_command()
1052 vub300->app_spec = 1; in send_command()
1056 vub300->resp_len = 6; in send_command()
1059 vub300->resp_len = 0; in send_command()
1061 complete(&vub300->command_complete); in send_command()
1069 vub300->cmnd.head.header_size = 20; in send_command()
1070 vub300->cmnd.head.header_type = 0x00; in send_command()
1071 vub300->cmnd.head.port_number = 0; /* "0" means port 1 */ in send_command()
1072 vub300->cmnd.head.command_type = 0x00; /* standard read command */ in send_command()
1073 vub300->cmnd.head.response_type = response_type; in send_command()
1074 vub300->cmnd.head.command_index = cmd->opcode; in send_command()
1075 vub300->cmnd.head.arguments[0] = cmd->arg >> 24; in send_command()
1076 vub300->cmnd.head.arguments[1] = cmd->arg >> 16; in send_command()
1077 vub300->cmnd.head.arguments[2] = cmd->arg >> 8; in send_command()
1078 vub300->cmnd.head.arguments[3] = cmd->arg >> 0; in send_command()
1081 vub300->cmnd.head.block_count[0] = 0; in send_command()
1082 vub300->cmnd.head.block_count[1] = 0; in send_command()
1083 vub300->cmnd.head.block_size[0] = (vub300->fbs[fn] >> 8) & 0xFF; in send_command()
1084 vub300->cmnd.head.block_size[1] = (vub300->fbs[fn] >> 0) & 0xFF; in send_command()
1085 vub300->cmnd.head.command_type = 0x00; in send_command()
1086 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1087 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1088 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1089 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1091 vub300->cmnd.head.block_count[0] = 0; in send_command()
1092 vub300->cmnd.head.block_count[1] = 0; in send_command()
1093 vub300->cmnd.head.block_size[0] = (vub300->fbs[0] >> 8) & 0xFF; in send_command()
1094 vub300->cmnd.head.block_size[1] = (vub300->fbs[0] >> 0) & 0xFF; in send_command()
1095 vub300->cmnd.head.command_type = 0x00; in send_command()
1096 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1097 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1098 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1099 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1102 if (0x08 & vub300->cmnd.head.arguments[0]) { /* BLOCK MODE */ in send_command()
1103 vub300->cmnd.head.block_count[0] = in send_command()
1105 vub300->cmnd.head.block_count[1] = in send_command()
1107 vub300->cmnd.head.block_size[0] = in send_command()
1109 vub300->cmnd.head.block_size[1] = in send_command()
1112 vub300->cmnd.head.block_count[0] = 0; in send_command()
1113 vub300->cmnd.head.block_count[1] = 0; in send_command()
1114 vub300->cmnd.head.block_size[0] = in send_command()
1115 (vub300->datasize >> 8) & 0xFF; in send_command()
1116 vub300->cmnd.head.block_size[1] = in send_command()
1117 (vub300->datasize >> 0) & 0xFF; in send_command()
1119 vub300->cmnd.head.command_type = in send_command()
1121 vub300->cmnd.head.transfer_size[0] = in send_command()
1122 (vub300->datasize >> 24) & 0xFF; in send_command()
1123 vub300->cmnd.head.transfer_size[1] = in send_command()
1124 (vub300->datasize >> 16) & 0xFF; in send_command()
1125 vub300->cmnd.head.transfer_size[2] = in send_command()
1126 (vub300->datasize >> 8) & 0xFF; in send_command()
1127 vub300->cmnd.head.transfer_size[3] = in send_command()
1128 (vub300->datasize >> 0) & 0xFF; in send_command()
1129 if (vub300->datasize < vub300->fbs[fn]) { in send_command()
1130 vub300->cmnd.head.block_count[0] = 0; in send_command()
1131 vub300->cmnd.head.block_count[1] = 0; in send_command()
1134 vub300->cmnd.head.block_count[0] = (data->blocks >> 8) & 0xFF; in send_command()
1135 vub300->cmnd.head.block_count[1] = (data->blocks >> 0) & 0xFF; in send_command()
1136 vub300->cmnd.head.block_size[0] = (data->blksz >> 8) & 0xFF; in send_command()
1137 vub300->cmnd.head.block_size[1] = (data->blksz >> 0) & 0xFF; in send_command()
1138 vub300->cmnd.head.command_type = in send_command()
1140 vub300->cmnd.head.transfer_size[0] = in send_command()
1141 (vub300->datasize >> 24) & 0xFF; in send_command()
1142 vub300->cmnd.head.transfer_size[1] = in send_command()
1143 (vub300->datasize >> 16) & 0xFF; in send_command()
1144 vub300->cmnd.head.transfer_size[2] = in send_command()
1145 (vub300->datasize >> 8) & 0xFF; in send_command()
1146 vub300->cmnd.head.transfer_size[3] = in send_command()
1147 (vub300->datasize >> 0) & 0xFF; in send_command()
1148 if (vub300->datasize < vub300->fbs[0]) { in send_command()
1149 vub300->cmnd.head.block_count[0] = 0; in send_command()
1150 vub300->cmnd.head.block_count[1] = 0; in send_command()
1153 if (vub300->cmnd.head.block_size[0] || vub300->cmnd.head.block_size[1]) { in send_command()
1154 u16 block_size = vub300->cmnd.head.block_size[1] | in send_command()
1155 (vub300->cmnd.head.block_size[0] << 8); in send_command()
1158 vub300->cmnd.head.block_boundary[0] = in send_command()
1160 vub300->cmnd.head.block_boundary[1] = in send_command()
1163 vub300->cmnd.head.block_boundary[0] = 0; in send_command()
1164 vub300->cmnd.head.block_boundary[1] = 0; in send_command()
1166 usb_fill_bulk_urb(vub300->command_out_urb, vub300->udev, in send_command()
1167 usb_sndbulkpipe(vub300->udev, vub300->cmnd_out_ep), in send_command()
1168 &vub300->cmnd, sizeof(vub300->cmnd), in send_command()
1169 command_out_completed, vub300); in send_command()
1170 retval = usb_submit_urb(vub300->command_out_urb, GFP_KERNEL); in send_command()
1173 complete(&vub300->command_complete); in send_command()
1186 struct vub300_mmc_host *vub300 = from_timer(vub300, t, in vub300_sg_timed_out() local
1188 vub300->usb_timed_out = 1; in vub300_sg_timed_out()
1189 usb_sg_cancel(&vub300->sg_request); in vub300_sg_timed_out()
1190 usb_unlink_urb(vub300->command_out_urb); in vub300_sg_timed_out()
1191 usb_unlink_urb(vub300->command_res_urb); in vub300_sg_timed_out()
1202 static void __download_offload_pseudocode(struct vub300_mmc_host *vub300, in __download_offload_pseudocode() argument
1211 dev_info(&vub300->udev->dev, "using %s for SDIO offload processing\n", in __download_offload_pseudocode()
1212 vub300->vub_name); in __download_offload_pseudocode()
1216 dev_info(&vub300->udev->dev, "using offload firmware %s %s\n", fw->data, in __download_offload_pseudocode()
1217 vub300->vub_name); in __download_offload_pseudocode()
1219 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1221 vub300->vub_name); in __download_offload_pseudocode()
1222 strncpy(vub300->vub_name, "corrupt offload pseudocode", in __download_offload_pseudocode()
1223 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1242 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1243 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1252 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1255 vub300->vub_name); in __download_offload_pseudocode()
1256 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1258 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1262 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1264 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1265 strncpy(vub300->vub_name, "corrupt interrupt pseudocode", in __download_offload_pseudocode()
1266 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1285 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1286 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1295 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1298 vub300->vub_name); in __download_offload_pseudocode()
1299 strncpy(vub300->vub_name, in __download_offload_pseudocode()
1301 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1305 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1307 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1308 strncpy(vub300->vub_name, "corrupt transfer pseudocode", in __download_offload_pseudocode()
1309 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1315 int I = vub300->dynamic_register_count = register_count; in __download_offload_pseudocode()
1319 vub300->sdio_register[i].func_num = *data++; in __download_offload_pseudocode()
1329 vub300->sdio_register[i].sdio_reg = func_num; in __download_offload_pseudocode()
1330 vub300->sdio_register[i].activate = 1; in __download_offload_pseudocode()
1331 vub300->sdio_register[i].prepared = 0; in __download_offload_pseudocode()
1334 dev_info(&vub300->udev->dev, in __download_offload_pseudocode()
1336 vub300->dynamic_register_count); in __download_offload_pseudocode()
1339 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1341 vub300->vub_name); in __download_offload_pseudocode()
1342 strncpy(vub300->vub_name, "corrupt dynamic registers", in __download_offload_pseudocode()
1343 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1350 strncpy(vub300->vub_name, "SDIO pseudocode download failed", in __download_offload_pseudocode()
1351 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1358 static void download_offload_pseudocode(struct vub300_mmc_host *vub300) in download_offload_pseudocode() argument
1360 struct mmc_card *card = vub300->mmc->card; in download_offload_pseudocode()
1363 int l = snprintf(vub300->vub_name, sizeof(vub300->vub_name), in download_offload_pseudocode()
1369 l += snprintf(vub300->vub_name + l, in download_offload_pseudocode()
1370 sizeof(vub300->vub_name) - l, "_%04X%04X", in download_offload_pseudocode()
1373 snprintf(vub300->vub_name + l, sizeof(vub300->vub_name) - l, ".bin"); in download_offload_pseudocode()
1374 dev_info(&vub300->udev->dev, "requesting offload firmware %s\n", in download_offload_pseudocode()
1375 vub300->vub_name); in download_offload_pseudocode()
1376 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1378 strncpy(vub300->vub_name, "vub_default.bin", in download_offload_pseudocode()
1379 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1380 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1382 strncpy(vub300->vub_name, in download_offload_pseudocode()
1384 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1386 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1390 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1400 static int vub300_usb_bulk_msg(struct vub300_mmc_host *vub300, in vub300_usb_bulk_msg() argument
1405 struct usb_device *usb_dev = vub300->udev; in vub300_usb_bulk_msg()
1408 vub300->urb = usb_alloc_urb(0, GFP_KERNEL); in vub300_usb_bulk_msg()
1409 if (!vub300->urb) in vub300_usb_bulk_msg()
1411 usb_fill_bulk_urb(vub300->urb, usb_dev, pipe, data, len, in vub300_usb_bulk_msg()
1414 vub300->urb->context = &done; in vub300_usb_bulk_msg()
1415 vub300->urb->actual_length = 0; in vub300_usb_bulk_msg()
1416 retval = usb_submit_urb(vub300->urb, GFP_KERNEL); in vub300_usb_bulk_msg()
1422 usb_kill_urb(vub300->urb); in vub300_usb_bulk_msg()
1424 retval = vub300->urb->status; in vub300_usb_bulk_msg()
1427 *actual_length = vub300->urb->actual_length; in vub300_usb_bulk_msg()
1428 usb_free_urb(vub300->urb); in vub300_usb_bulk_msg()
1429 vub300->urb = NULL; in vub300_usb_bulk_msg()
1433 static int __command_read_data(struct vub300_mmc_host *vub300, in __command_read_data() argument
1437 int linear_length = vub300->datasize; in __command_read_data()
1438 int padded_length = vub300->large_usb_packets ? in __command_read_data()
1444 pipe = usb_rcvbulkpipe(vub300->udev, vub300->data_inp_ep); in __command_read_data()
1445 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_read_data()
1449 usb_unlink_urb(vub300->command_out_urb); in __command_read_data()
1450 usb_unlink_urb(vub300->command_res_urb); in __command_read_data()
1455 vub300->sg_transfer_timer.expires = in __command_read_data()
1458 add_timer(&vub300->sg_transfer_timer); in __command_read_data()
1459 usb_sg_wait(&vub300->sg_request); in __command_read_data()
1460 del_timer(&vub300->sg_transfer_timer); in __command_read_data()
1461 if (vub300->sg_request.status < 0) { in __command_read_data()
1462 cmd->error = vub300->sg_request.status; in __command_read_data()
1466 data->bytes_xfered = vub300->datasize; in __command_read_data()
1474 unsigned pipe = usb_rcvbulkpipe(vub300->udev, in __command_read_data()
1475 vub300->data_inp_ep); in __command_read_data()
1477 result = vub300_usb_bulk_msg(vub300, pipe, buf, in __command_read_data()
1494 data->bytes_xfered = vub300->datasize; in __command_read_data()
1505 static int __command_write_data(struct vub300_mmc_host *vub300, in __command_write_data() argument
1509 unsigned pipe = usb_sndbulkpipe(vub300->udev, vub300->data_out_ep); in __command_write_data()
1510 int linear_length = vub300->datasize; in __command_write_data()
1517 vub300->padded_buffer, in __command_write_data()
1518 sizeof(vub300->padded_buffer)); in __command_write_data()
1519 memset(vub300->padded_buffer + linear_length, 0, in __command_write_data()
1520 sizeof(vub300->padded_buffer) - linear_length); in __command_write_data()
1521 result = vub300_usb_bulk_msg(vub300, pipe, vub300->padded_buffer, in __command_write_data()
1522 sizeof(vub300->padded_buffer), in __command_write_data()
1524 (sizeof(vub300->padded_buffer) / in __command_write_data()
1530 data->bytes_xfered = vub300->datasize; in __command_write_data()
1532 } else if ((!vub300->large_usb_packets && (0 < modulo_64_length)) || in __command_write_data()
1533 (vub300->large_usb_packets && (64 > modulo_512_length)) in __command_write_data()
1545 vub300_usb_bulk_msg(vub300, pipe, buf, in __command_write_data()
1553 data->bytes_xfered = vub300->datasize; in __command_write_data()
1563 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_write_data()
1567 usb_unlink_urb(vub300->command_out_urb); in __command_write_data()
1568 usb_unlink_urb(vub300->command_res_urb); in __command_write_data()
1572 vub300->sg_transfer_timer.expires = in __command_write_data()
1575 add_timer(&vub300->sg_transfer_timer); in __command_write_data()
1576 usb_sg_wait(&vub300->sg_request); in __command_write_data()
1580 del_timer(&vub300->sg_transfer_timer); in __command_write_data()
1581 if (vub300->sg_request.status < 0) { in __command_write_data()
1582 cmd->error = vub300->sg_request.status; in __command_write_data()
1585 data->bytes_xfered = vub300->datasize; in __command_write_data()
1593 static void __vub300_command_response(struct vub300_mmc_host *vub300, in __vub300_command_response() argument
1601 wait_for_completion_timeout(&vub300->command_complete, in __vub300_command_response()
1606 vub300->usb_timed_out = 1; in __vub300_command_response()
1607 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1608 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1610 result = usb_lock_device_for_reset(vub300->udev, in __vub300_command_response()
1611 vub300->interface); in __vub300_command_response()
1613 result = usb_reset_device(vub300->udev); in __vub300_command_response()
1614 usb_unlock_device(vub300->udev); in __vub300_command_response()
1618 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1619 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1626 } else if (vub300->command_out_urb->status) { in __vub300_command_response()
1627 vub300->usb_transport_fail = vub300->command_out_urb->status; in __vub300_command_response()
1628 cmd->error = -EPROTO == vub300->command_out_urb->status ? in __vub300_command_response()
1629 -ESHUTDOWN : vub300->command_out_urb->status; in __vub300_command_response()
1630 } else if (vub300->command_res_urb->status) { in __vub300_command_response()
1631 vub300->usb_transport_fail = vub300->command_res_urb->status; in __vub300_command_response()
1632 cmd->error = -EPROTO == vub300->command_res_urb->status ? in __vub300_command_response()
1633 -ESHUTDOWN : vub300->command_res_urb->status; in __vub300_command_response()
1634 } else if (vub300->resp.common.header_type == 0x00) { in __vub300_command_response()
1639 } else if (vub300->resp.common.header_type == RESPONSE_ERROR) { in __vub300_command_response()
1641 vub300_response_error(vub300->resp.error.error_code); in __vub300_command_response()
1642 if (vub300->data) in __vub300_command_response()
1643 usb_sg_cancel(&vub300->sg_request); in __vub300_command_response()
1644 } else if (vub300->resp.common.header_type == RESPONSE_PIGGYBACKED) { in __vub300_command_response()
1646 vub300->resp.common.header_size - in __vub300_command_response()
1651 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1654 vub300->resp.common.header_size = in __vub300_command_response()
1656 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1658 } else if (vub300->resp.common.header_type == RESPONSE_PIG_DISABLED) { in __vub300_command_response()
1660 vub300->resp.common.header_size - in __vub300_command_response()
1665 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1668 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1669 if (vub300->irqs_queued) { in __vub300_command_response()
1670 vub300->irqs_queued += 1; in __vub300_command_response()
1671 } else if (vub300->irq_enabled) { in __vub300_command_response()
1672 vub300->irqs_queued += 1; in __vub300_command_response()
1673 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1675 vub300->irqs_queued += 1; in __vub300_command_response()
1677 vub300->irq_disabled = 1; in __vub300_command_response()
1678 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1679 vub300->resp.common.header_size = in __vub300_command_response()
1681 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1683 } else if (vub300->resp.common.header_type == RESPONSE_PIG_ENABLED) { in __vub300_command_response()
1685 vub300->resp.common.header_size - in __vub300_command_response()
1690 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1693 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1694 if (vub300->irqs_queued) { in __vub300_command_response()
1695 vub300->irqs_queued += 1; in __vub300_command_response()
1696 } else if (vub300->irq_enabled) { in __vub300_command_response()
1697 vub300->irqs_queued += 1; in __vub300_command_response()
1698 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1700 vub300->irqs_queued += 1; in __vub300_command_response()
1702 vub300->irq_disabled = 0; in __vub300_command_response()
1703 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1704 vub300->resp.common.header_size = in __vub300_command_response()
1706 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1713 static void construct_request_response(struct vub300_mmc_host *vub300, in construct_request_response() argument
1716 int resp_len = vub300->resp_len; in construct_request_response()
1720 u8 *r = vub300->resp.response.command_response; in construct_request_response()
1744 struct vub300_mmc_host *vub300 = in vub300_cmndwork_thread() local
1746 if (!vub300->interface) { in vub300_cmndwork_thread()
1747 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1750 struct mmc_request *req = vub300->req; in vub300_cmndwork_thread()
1751 struct mmc_command *cmd = vub300->cmd; in vub300_cmndwork_thread()
1752 struct mmc_data *data = vub300->data; in vub300_cmndwork_thread()
1754 mutex_lock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1755 init_completion(&vub300->command_complete); in vub300_cmndwork_thread()
1756 if (likely(vub300->vub_name[0]) || !vub300->mmc->card) { in vub300_cmndwork_thread()
1762 } else if (0 == vub300->mmc->card->sdio_funcs) { in vub300_cmndwork_thread()
1763 strncpy(vub300->vub_name, "SD memory device", in vub300_cmndwork_thread()
1764 sizeof(vub300->vub_name)); in vub300_cmndwork_thread()
1766 download_offload_pseudocode(vub300); in vub300_cmndwork_thread()
1768 send_command(vub300); in vub300_cmndwork_thread()
1772 data_length = __command_read_data(vub300, cmd, data); in vub300_cmndwork_thread()
1774 data_length = __command_write_data(vub300, cmd, data); in vub300_cmndwork_thread()
1775 __vub300_command_response(vub300, cmd, data, data_length); in vub300_cmndwork_thread()
1776 vub300->req = NULL; in vub300_cmndwork_thread()
1777 vub300->cmd = NULL; in vub300_cmndwork_thread()
1778 vub300->data = NULL; in vub300_cmndwork_thread()
1781 check_vub300_port_status(vub300); in vub300_cmndwork_thread()
1782 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1783 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1784 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1787 construct_request_response(vub300, cmd); in vub300_cmndwork_thread()
1788 vub300->resp_len = 0; in vub300_cmndwork_thread()
1789 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1790 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1791 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1797 static int examine_cyclic_buffer(struct vub300_mmc_host *vub300, in examine_cyclic_buffer() argument
1805 int first = MAXREGMASK & vub300->fn[Function].offload_point; in examine_cyclic_buffer()
1806 struct offload_registers_access *rf = &vub300->fn[Function].reg[first]; in examine_cyclic_buffer()
1817 vub300->fn[Function].offload_point += 1; in examine_cyclic_buffer()
1818 vub300->fn[Function].offload_count -= 1; in examine_cyclic_buffer()
1819 vub300->total_offload_count -= 1; in examine_cyclic_buffer()
1823 u8 register_count = vub300->fn[Function].offload_count - 1; in examine_cyclic_buffer()
1824 u32 register_point = vub300->fn[Function].offload_point + 1; in examine_cyclic_buffer()
1828 &vub300->fn[Function].reg[point]; in examine_cyclic_buffer()
1839 vub300->fn[Function].offload_point += delta; in examine_cyclic_buffer()
1840 vub300->fn[Function].offload_count -= delta; in examine_cyclic_buffer()
1841 vub300->total_offload_count -= delta; in examine_cyclic_buffer()
1854 static int satisfy_request_from_offloaded_data(struct vub300_mmc_host *vub300, in satisfy_request_from_offloaded_data() argument
1858 u8 regs = vub300->dynamic_register_count; in satisfy_request_from_offloaded_data()
1863 if ((vub300->sdio_register[i].func_num == func) && in satisfy_request_from_offloaded_data()
1864 (vub300->sdio_register[i].sdio_reg == reg)) { in satisfy_request_from_offloaded_data()
1865 if (!vub300->sdio_register[i].prepared) { in satisfy_request_from_offloaded_data()
1872 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1878 u8 rsp2 = vub300->sdio_register[i].response; in satisfy_request_from_offloaded_data()
1879 u8 rsp3 = vub300->sdio_register[i].regvalue; in satisfy_request_from_offloaded_data()
1880 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1893 if (vub300->total_offload_count == 0) in satisfy_request_from_offloaded_data()
1895 else if (vub300->fn[func].offload_count == 0) in satisfy_request_from_offloaded_data()
1898 return examine_cyclic_buffer(vub300, cmd, func); in satisfy_request_from_offloaded_data()
1904 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_request() local
1905 if (!vub300->interface) { in vub300_mmc_request()
1911 if (!vub300->card_powered) { in vub300_mmc_request()
1916 if (!vub300->card_present) { in vub300_mmc_request()
1921 if (vub300->usb_transport_fail) { in vub300_mmc_request()
1922 cmd->error = vub300->usb_transport_fail; in vub300_mmc_request()
1926 if (!vub300->interface) { in vub300_mmc_request()
1931 kref_get(&vub300->kref); in vub300_mmc_request()
1932 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_request()
1933 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_mmc_request()
1939 satisfy_request_from_offloaded_data(vub300, cmd)) { in vub300_mmc_request()
1941 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1942 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1946 vub300->cmd = cmd; in vub300_mmc_request()
1947 vub300->req = req; in vub300_mmc_request()
1948 vub300->data = data; in vub300_mmc_request()
1950 vub300->datasize = data->blksz * data->blocks; in vub300_mmc_request()
1952 vub300->datasize = 0; in vub300_mmc_request()
1953 vub300_queue_cmnd_work(vub300); in vub300_mmc_request()
1954 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1955 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1967 static void __set_clock_speed(struct vub300_mmc_host *vub300, u8 buf[8], in __set_clock_speed() argument
1994 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in __set_clock_speed()
1999 dev_err(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2002 dev_dbg(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2009 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_set_ios() local
2010 if (!vub300->interface) in vub300_mmc_set_ios()
2012 kref_get(&vub300->kref); in vub300_mmc_set_ios()
2013 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2014 if ((ios->power_mode == MMC_POWER_OFF) && vub300->card_powered) { in vub300_mmc_set_ios()
2015 vub300->card_powered = 0; in vub300_mmc_set_ios()
2016 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2022 } else if ((ios->power_mode == MMC_POWER_UP) && !vub300->card_powered) { in vub300_mmc_set_ios()
2023 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2028 vub300->card_powered = 1; in vub300_mmc_set_ios()
2032 __set_clock_speed(vub300, buf, ios); in vub300_mmc_set_ios()
2038 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2039 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_set_ios()
2044 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_get_ro() local
2045 return vub300->read_only; in vub300_mmc_get_ro()
2050 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_enable_sdio_irq() local
2051 if (!vub300->interface) in vub300_enable_sdio_irq()
2053 kref_get(&vub300->kref); in vub300_enable_sdio_irq()
2055 mutex_lock(&vub300->irq_mutex); in vub300_enable_sdio_irq()
2056 if (vub300->irqs_queued) { in vub300_enable_sdio_irq()
2057 vub300->irqs_queued -= 1; in vub300_enable_sdio_irq()
2058 mmc_signal_sdio_irq(vub300->mmc); in vub300_enable_sdio_irq()
2059 } else if (vub300->irq_disabled) { in vub300_enable_sdio_irq()
2060 vub300->irq_disabled = 0; in vub300_enable_sdio_irq()
2061 vub300->irq_enabled = 1; in vub300_enable_sdio_irq()
2062 vub300_queue_poll_work(vub300, 0); in vub300_enable_sdio_irq()
2063 } else if (vub300->irq_enabled) { in vub300_enable_sdio_irq()
2066 vub300->irq_enabled = 1; in vub300_enable_sdio_irq()
2067 vub300_queue_poll_work(vub300, 0); in vub300_enable_sdio_irq()
2069 mutex_unlock(&vub300->irq_mutex); in vub300_enable_sdio_irq()
2071 vub300->irq_enabled = 0; in vub300_enable_sdio_irq()
2073 kref_put(&vub300->kref, vub300_delete); in vub300_enable_sdio_irq()
2078 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_init_card() local
2079 dev_info(&vub300->udev->dev, "NO host QUIRKS for this card\n"); in vub300_init_card()
2093 struct vub300_mmc_host *vub300; in vub300_probe() local
2180 vub300 = mmc_priv(mmc); in vub300_probe()
2181 vub300->mmc = mmc; in vub300_probe()
2182 vub300->card_powered = 0; in vub300_probe()
2183 vub300->bus_width = 0; in vub300_probe()
2184 vub300->cmnd.head.block_size[0] = 0x00; in vub300_probe()
2185 vub300->cmnd.head.block_size[1] = 0x00; in vub300_probe()
2186 vub300->app_spec = 0; in vub300_probe()
2187 mutex_init(&vub300->cmd_mutex); in vub300_probe()
2188 mutex_init(&vub300->irq_mutex); in vub300_probe()
2189 vub300->command_out_urb = command_out_urb; in vub300_probe()
2190 vub300->command_res_urb = command_res_urb; in vub300_probe()
2191 vub300->usb_timed_out = 0; in vub300_probe()
2192 vub300->dynamic_register_count = 0; in vub300_probe()
2194 for (i = 0; i < ARRAY_SIZE(vub300->fn); i++) { in vub300_probe()
2195 vub300->fn[i].offload_point = 0; in vub300_probe()
2196 vub300->fn[i].offload_count = 0; in vub300_probe()
2199 vub300->total_offload_count = 0; in vub300_probe()
2200 vub300->irq_enabled = 0; in vub300_probe()
2201 vub300->irq_disabled = 0; in vub300_probe()
2202 vub300->irqs_queued = 0; in vub300_probe()
2204 for (i = 0; i < ARRAY_SIZE(vub300->sdio_register); i++) in vub300_probe()
2205 vub300->sdio_register[i++].activate = 0; in vub300_probe()
2207 vub300->udev = udev; in vub300_probe()
2208 vub300->interface = interface; in vub300_probe()
2209 vub300->cmnd_res_ep = 0; in vub300_probe()
2210 vub300->cmnd_out_ep = 0; in vub300_probe()
2211 vub300->data_inp_ep = 0; in vub300_probe()
2212 vub300->data_out_ep = 0; in vub300_probe()
2214 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in vub300_probe()
2215 vub300->fbs[i] = 512; in vub300_probe()
2226 vub300->large_usb_packets = 0; in vub300_probe()
2231 dev_info(&vub300->udev->dev, in vub300_probe()
2237 vub300->large_usb_packets = 1; in vub300_probe()
2239 if (!vub300->cmnd_res_ep) { in vub300_probe()
2240 vub300->cmnd_res_ep = in vub300_probe()
2242 } else if (!vub300->data_inp_ep) { in vub300_probe()
2243 vub300->data_inp_ep = in vub300_probe()
2246 dev_warn(&vub300->udev->dev, in vub300_probe()
2251 if (!vub300->cmnd_out_ep) { in vub300_probe()
2252 vub300->cmnd_out_ep = in vub300_probe()
2254 } else if (!vub300->data_out_ep) { in vub300_probe()
2255 vub300->data_out_ep = in vub300_probe()
2258 dev_warn(&vub300->udev->dev, in vub300_probe()
2263 dev_warn(&vub300->udev->dev, in vub300_probe()
2268 if (vub300->cmnd_res_ep && vub300->cmnd_out_ep && in vub300_probe()
2269 vub300->data_inp_ep && vub300->data_out_ep) { in vub300_probe()
2270 dev_info(&vub300->udev->dev, in vub300_probe()
2273 vub300->large_usb_packets ? "LARGE" : "SMALL", in vub300_probe()
2274 vub300->cmnd_out_ep, vub300->cmnd_res_ep, in vub300_probe()
2275 vub300->data_out_ep, vub300->data_inp_ep); in vub300_probe()
2278 dev_err(&vub300->udev->dev, in vub300_probe()
2284 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2287 0x0000, 0x0000, &vub300->hc_info, in vub300_probe()
2288 sizeof(vub300->hc_info), HZ); in vub300_probe()
2292 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2298 dev_info(&vub300->udev->dev, in vub300_probe()
2304 vub300->large_usb_packets ? 512 : 64); in vub300_probe()
2306 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2309 0x0000, 0x0000, &vub300->system_port_status, in vub300_probe()
2310 sizeof(vub300->system_port_status), HZ); in vub300_probe()
2313 } else if (sizeof(vub300->system_port_status) == retval) { in vub300_probe()
2314 vub300->card_present = in vub300_probe()
2315 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2316 vub300->read_only = in vub300_probe()
2317 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2321 usb_set_intfdata(interface, vub300); in vub300_probe()
2322 INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread); in vub300_probe()
2323 INIT_WORK(&vub300->cmndwork, vub300_cmndwork_thread); in vub300_probe()
2324 INIT_WORK(&vub300->deadwork, vub300_deadwork_thread); in vub300_probe()
2325 kref_init(&vub300->kref); in vub300_probe()
2326 timer_setup(&vub300->sg_transfer_timer, vub300_sg_timed_out, 0); in vub300_probe()
2327 kref_get(&vub300->kref); in vub300_probe()
2328 timer_setup(&vub300->inactivity_timer, in vub300_probe()
2330 vub300->inactivity_timer.expires = jiffies + HZ; in vub300_probe()
2331 add_timer(&vub300->inactivity_timer); in vub300_probe()
2332 if (vub300->card_present) in vub300_probe()
2333 dev_info(&vub300->udev->dev, in vub300_probe()
2338 dev_info(&vub300->udev->dev, in vub300_probe()
2361 struct vub300_mmc_host *vub300 = usb_get_intfdata(interface); in vub300_disconnect() local
2362 if (!vub300 || !vub300->mmc) { in vub300_disconnect()
2365 struct mmc_host *mmc = vub300->mmc; in vub300_disconnect()
2366 if (!vub300->mmc) { in vub300_disconnect()
2372 vub300->interface = NULL; in vub300_disconnect()
2373 kref_put(&vub300->kref, vub300_delete); in vub300_disconnect()
2398 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_pre_reset() local
2399 mutex_lock(&vub300->cmd_mutex); in vub300_pre_reset()
2405 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_post_reset() local
2407 vub300->errors = -EPIPE; in vub300_post_reset()
2408 mutex_unlock(&vub300->cmd_mutex); in vub300_post_reset()