Lines Matching refs:vub300
371 struct vub300_mmc_host *vub300 = kref_to_vub300_mmc_host(kref); in vub300_delete() local
372 struct mmc_host *mmc = vub300->mmc; in vub300_delete()
373 usb_free_urb(vub300->command_out_urb); in vub300_delete()
374 vub300->command_out_urb = NULL; in vub300_delete()
375 usb_free_urb(vub300->command_res_urb); in vub300_delete()
376 vub300->command_res_urb = NULL; in vub300_delete()
377 usb_put_dev(vub300->udev); in vub300_delete()
385 static void vub300_queue_cmnd_work(struct vub300_mmc_host *vub300) in vub300_queue_cmnd_work() argument
387 kref_get(&vub300->kref); in vub300_queue_cmnd_work()
388 if (queue_work(cmndworkqueue, &vub300->cmndwork)) { in vub300_queue_cmnd_work()
401 kref_put(&vub300->kref, vub300_delete); in vub300_queue_cmnd_work()
405 static void vub300_queue_poll_work(struct vub300_mmc_host *vub300, int delay) in vub300_queue_poll_work() argument
407 kref_get(&vub300->kref); in vub300_queue_poll_work()
408 if (queue_delayed_work(pollworkqueue, &vub300->pollwork, delay)) { in vub300_queue_poll_work()
421 kref_put(&vub300->kref, vub300_delete); in vub300_queue_poll_work()
425 static void vub300_queue_dead_work(struct vub300_mmc_host *vub300) in vub300_queue_dead_work() argument
427 kref_get(&vub300->kref); in vub300_queue_dead_work()
428 if (queue_work(deadworkqueue, &vub300->deadwork)) { in vub300_queue_dead_work()
441 kref_put(&vub300->kref, vub300_delete); in vub300_queue_dead_work()
447 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in irqpoll_res_completed() local
449 vub300->usb_transport_fail = urb->status; in irqpoll_res_completed()
450 complete(&vub300->irqpoll_complete); in irqpoll_res_completed()
455 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in irqpoll_out_completed() local
457 vub300->usb_transport_fail = urb->status; in irqpoll_out_completed()
458 complete(&vub300->irqpoll_complete); in irqpoll_out_completed()
463 usb_rcvbulkpipe(vub300->udev, vub300->cmnd_res_ep); in irqpoll_out_completed()
464 usb_fill_bulk_urb(vub300->command_res_urb, vub300->udev, pipe, in irqpoll_out_completed()
465 &vub300->resp, sizeof(vub300->resp), in irqpoll_out_completed()
466 irqpoll_res_completed, vub300); in irqpoll_out_completed()
467 vub300->command_res_urb->actual_length = 0; in irqpoll_out_completed()
468 ret = usb_submit_urb(vub300->command_res_urb, GFP_ATOMIC); in irqpoll_out_completed()
470 vub300->usb_transport_fail = ret; in irqpoll_out_completed()
471 complete(&vub300->irqpoll_complete); in irqpoll_out_completed()
477 static void send_irqpoll(struct vub300_mmc_host *vub300) in send_irqpoll() argument
482 vub300->cmnd.poll.header_size = 22; in send_irqpoll()
483 vub300->cmnd.poll.header_type = 1; in send_irqpoll()
484 vub300->cmnd.poll.port_number = 0; in send_irqpoll()
485 vub300->cmnd.poll.command_type = 2; in send_irqpoll()
486 vub300->cmnd.poll.poll_timeout_lsb = 0xFF & (unsigned)timeout; in send_irqpoll()
487 vub300->cmnd.poll.poll_timeout_msb = 0xFF & (unsigned)(timeout >> 8); in send_irqpoll()
488 usb_fill_bulk_urb(vub300->command_out_urb, vub300->udev, in send_irqpoll()
489 usb_sndbulkpipe(vub300->udev, vub300->cmnd_out_ep) in send_irqpoll()
490 , &vub300->cmnd, sizeof(vub300->cmnd) in send_irqpoll()
491 , irqpoll_out_completed, vub300); in send_irqpoll()
492 retval = usb_submit_urb(vub300->command_out_urb, GFP_KERNEL); in send_irqpoll()
494 vub300->usb_transport_fail = retval; in send_irqpoll()
495 vub300_queue_poll_work(vub300, 1); in send_irqpoll()
496 complete(&vub300->irqpoll_complete); in send_irqpoll()
503 static void new_system_port_status(struct vub300_mmc_host *vub300) in new_system_port_status() argument
505 int old_card_present = vub300->card_present; in new_system_port_status()
507 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0; in new_system_port_status()
508 vub300->read_only = in new_system_port_status()
509 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0; in new_system_port_status()
511 dev_info(&vub300->udev->dev, "card just inserted\n"); in new_system_port_status()
512 vub300->card_present = 1; in new_system_port_status()
513 vub300->bus_width = 0; in new_system_port_status()
515 strscpy(vub300->vub_name, "EMPTY Processing Disabled", in new_system_port_status()
516 sizeof(vub300->vub_name)); in new_system_port_status()
518 vub300->vub_name[0] = 0; in new_system_port_status()
519 mmc_detect_change(vub300->mmc, 1); in new_system_port_status()
521 dev_info(&vub300->udev->dev, "card just ejected\n"); in new_system_port_status()
522 vub300->card_present = 0; in new_system_port_status()
523 mmc_detect_change(vub300->mmc, 0); in new_system_port_status()
529 static void __add_offloaded_reg_to_fifo(struct vub300_mmc_host *vub300, in __add_offloaded_reg_to_fifo() argument
533 u8 r = vub300->fn[func].offload_point + vub300->fn[func].offload_count; in __add_offloaded_reg_to_fifo()
534 memcpy(&vub300->fn[func].reg[MAXREGMASK & r], register_access, in __add_offloaded_reg_to_fifo()
536 vub300->fn[func].offload_count += 1; in __add_offloaded_reg_to_fifo()
537 vub300->total_offload_count += 1; in __add_offloaded_reg_to_fifo()
540 static void add_offloaded_reg(struct vub300_mmc_host *vub300, in add_offloaded_reg() argument
547 u8 regs = vub300->dynamic_register_count; in add_offloaded_reg()
549 while (0 < regs-- && 1 == vub300->sdio_register[i].activate) { in add_offloaded_reg()
550 if (vub300->sdio_register[i].func_num == func && in add_offloaded_reg()
551 vub300->sdio_register[i].sdio_reg == Register) { in add_offloaded_reg()
552 if (vub300->sdio_register[i].prepared == 0) in add_offloaded_reg()
553 vub300->sdio_register[i].prepared = 1; in add_offloaded_reg()
554 vub300->sdio_register[i].response = in add_offloaded_reg()
556 vub300->sdio_register[i].regvalue = in add_offloaded_reg()
564 __add_offloaded_reg_to_fifo(vub300, register_access, func); in add_offloaded_reg()
567 static void check_vub300_port_status(struct vub300_mmc_host *vub300) in check_vub300_port_status() argument
575 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in check_vub300_port_status()
578 0x0000, 0x0000, &vub300->system_port_status, in check_vub300_port_status()
579 sizeof(vub300->system_port_status), 1000); in check_vub300_port_status()
580 if (sizeof(vub300->system_port_status) == retval) in check_vub300_port_status()
581 new_system_port_status(vub300); in check_vub300_port_status()
584 static void __vub300_irqpoll_response(struct vub300_mmc_host *vub300) in __vub300_irqpoll_response() argument
587 if (vub300->command_res_urb->actual_length == 0) in __vub300_irqpoll_response()
590 switch (vub300->resp.common.header_type) { in __vub300_irqpoll_response()
592 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
593 if (vub300->irq_enabled) in __vub300_irqpoll_response()
594 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
596 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
597 vub300->irq_disabled = 1; in __vub300_irqpoll_response()
598 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
601 if (vub300->resp.error.error_code == SD_ERROR_NO_DEVICE) in __vub300_irqpoll_response()
602 check_vub300_port_status(vub300); in __vub300_irqpoll_response()
605 vub300->system_port_status = vub300->resp.status; in __vub300_irqpoll_response()
606 new_system_port_status(vub300); in __vub300_irqpoll_response()
607 if (!vub300->card_present) in __vub300_irqpoll_response()
608 vub300_queue_poll_work(vub300, HZ / 5); in __vub300_irqpoll_response()
612 int offloaded_data_length = vub300->resp.common.header_size - 3; in __vub300_irqpoll_response()
616 add_offloaded_reg(vub300, &vub300->resp.irq.reg[ri]); in __vub300_irqpoll_response()
619 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
620 if (vub300->irq_enabled) in __vub300_irqpoll_response()
621 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
623 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
624 vub300->irq_disabled = 1; in __vub300_irqpoll_response()
625 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
630 int offloaded_data_length = vub300->resp.common.header_size - 3; in __vub300_irqpoll_response()
634 add_offloaded_reg(vub300, &vub300->resp.irq.reg[ri]); in __vub300_irqpoll_response()
637 mutex_lock(&vub300->irq_mutex); in __vub300_irqpoll_response()
638 if (vub300->irq_enabled) in __vub300_irqpoll_response()
639 mmc_signal_sdio_irq(vub300->mmc); in __vub300_irqpoll_response()
641 vub300->irqs_queued += 1; in __vub300_irqpoll_response()
642 vub300->irq_disabled = 0; in __vub300_irqpoll_response()
643 mutex_unlock(&vub300->irq_mutex); in __vub300_irqpoll_response()
647 vub300_queue_poll_work(vub300, 1); in __vub300_irqpoll_response()
654 static void __do_poll(struct vub300_mmc_host *vub300) in __do_poll() argument
658 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in __do_poll()
659 init_completion(&vub300->irqpoll_complete); in __do_poll()
660 send_irqpoll(vub300); in __do_poll()
661 commretval = wait_for_completion_timeout(&vub300->irqpoll_complete, in __do_poll()
663 if (vub300->usb_transport_fail) { in __do_poll()
666 vub300->usb_timed_out = 1; in __do_poll()
667 usb_kill_urb(vub300->command_out_urb); in __do_poll()
668 usb_kill_urb(vub300->command_res_urb); in __do_poll()
670 __vub300_irqpoll_response(vub300); in __do_poll()
679 struct vub300_mmc_host *vub300 = container_of(work, in vub300_pollwork_thread() local
681 if (!vub300->interface) { in vub300_pollwork_thread()
682 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
685 mutex_lock(&vub300->cmd_mutex); in vub300_pollwork_thread()
686 if (vub300->cmd) { in vub300_pollwork_thread()
687 vub300_queue_poll_work(vub300, 1); in vub300_pollwork_thread()
688 } else if (!vub300->card_present) { in vub300_pollwork_thread()
691 mutex_lock(&vub300->irq_mutex); in vub300_pollwork_thread()
692 if (!vub300->irq_enabled) { in vub300_pollwork_thread()
693 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
694 } else if (vub300->irqs_queued) { in vub300_pollwork_thread()
695 vub300->irqs_queued -= 1; in vub300_pollwork_thread()
696 mmc_signal_sdio_irq(vub300->mmc); in vub300_pollwork_thread()
697 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_pollwork_thread()
698 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
700 mutex_unlock(&vub300->irq_mutex); in vub300_pollwork_thread()
701 __do_poll(vub300); in vub300_pollwork_thread()
704 mutex_unlock(&vub300->cmd_mutex); in vub300_pollwork_thread()
705 kref_put(&vub300->kref, vub300_delete); in vub300_pollwork_thread()
710 struct vub300_mmc_host *vub300 = in vub300_deadwork_thread() local
712 if (!vub300->interface) { in vub300_deadwork_thread()
713 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
716 mutex_lock(&vub300->cmd_mutex); in vub300_deadwork_thread()
717 if (vub300->cmd) { in vub300_deadwork_thread()
724 } else if (vub300->card_present) { in vub300_deadwork_thread()
725 check_vub300_port_status(vub300); in vub300_deadwork_thread()
726 } else if (vub300->mmc && vub300->mmc->card) { in vub300_deadwork_thread()
734 check_vub300_port_status(vub300); in vub300_deadwork_thread()
736 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_deadwork_thread()
737 mutex_unlock(&vub300->cmd_mutex); in vub300_deadwork_thread()
738 kref_put(&vub300->kref, vub300_delete); in vub300_deadwork_thread()
743 struct vub300_mmc_host *vub300 = from_timer(vub300, t, in vub300_inactivity_timer_expired() local
745 if (!vub300->interface) { in vub300_inactivity_timer_expired()
746 kref_put(&vub300->kref, vub300_delete); in vub300_inactivity_timer_expired()
747 } else if (vub300->cmd) { in vub300_inactivity_timer_expired()
748 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
750 vub300_queue_dead_work(vub300); in vub300_inactivity_timer_expired()
751 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_inactivity_timer_expired()
793 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_res_completed() local
796 } else if (vub300->command_res_urb->actual_length == 0) { in command_res_completed()
801 } else if (!vub300->data) { in command_res_completed()
803 } else if (vub300->resp.common.header_type != 0x02) { in command_res_completed()
808 } else if (vub300->urb) { in command_res_completed()
809 vub300->cmd->error = in command_res_completed()
810 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
811 usb_unlink_urb(vub300->urb); in command_res_completed()
813 vub300->cmd->error = in command_res_completed()
814 vub300_response_error(vub300->resp.error.error_code); in command_res_completed()
815 usb_sg_cancel(&vub300->sg_request); in command_res_completed()
817 complete(&vub300->command_complete); /* got_response_in */ in command_res_completed()
822 struct vub300_mmc_host *vub300 = (struct vub300_mmc_host *)urb->context; in command_out_completed() local
824 complete(&vub300->command_complete); in command_out_completed()
828 usb_rcvbulkpipe(vub300->udev, vub300->cmnd_res_ep); in command_out_completed()
829 usb_fill_bulk_urb(vub300->command_res_urb, vub300->udev, pipe, in command_out_completed()
830 &vub300->resp, sizeof(vub300->resp), in command_out_completed()
831 command_res_completed, vub300); in command_out_completed()
832 vub300->command_res_urb->actual_length = 0; in command_out_completed()
833 ret = usb_submit_urb(vub300->command_res_urb, GFP_ATOMIC); in command_out_completed()
844 complete(&vub300->command_complete); in command_out_completed()
852 static void snoop_block_size_and_bus_width(struct vub300_mmc_host *vub300, in snoop_block_size_and_bus_width() argument
856 vub300->fbs[1] = (cmd_arg << 8) | (0x00FF & vub300->fbs[1]); in snoop_block_size_and_bus_width()
858 vub300->fbs[1] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[1]); in snoop_block_size_and_bus_width()
860 vub300->fbs[2] = (cmd_arg << 8) | (0x00FF & vub300->fbs[2]); in snoop_block_size_and_bus_width()
862 vub300->fbs[2] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[2]); in snoop_block_size_and_bus_width()
864 vub300->fbs[3] = (cmd_arg << 8) | (0x00FF & vub300->fbs[3]); in snoop_block_size_and_bus_width()
866 vub300->fbs[3] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[3]); in snoop_block_size_and_bus_width()
868 vub300->fbs[4] = (cmd_arg << 8) | (0x00FF & vub300->fbs[4]); in snoop_block_size_and_bus_width()
870 vub300->fbs[4] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[4]); in snoop_block_size_and_bus_width()
872 vub300->fbs[5] = (cmd_arg << 8) | (0x00FF & vub300->fbs[5]); in snoop_block_size_and_bus_width()
874 vub300->fbs[5] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[5]); in snoop_block_size_and_bus_width()
876 vub300->fbs[6] = (cmd_arg << 8) | (0x00FF & vub300->fbs[6]); in snoop_block_size_and_bus_width()
878 vub300->fbs[6] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[6]); in snoop_block_size_and_bus_width()
880 vub300->fbs[7] = (cmd_arg << 8) | (0x00FF & vub300->fbs[7]); in snoop_block_size_and_bus_width()
882 vub300->fbs[7] = (0xFF & cmd_arg) | (0xFF00 & vub300->fbs[7]); in snoop_block_size_and_bus_width()
884 vub300->bus_width = 1; in snoop_block_size_and_bus_width()
886 vub300->bus_width = 4; in snoop_block_size_and_bus_width()
889 static void send_command(struct vub300_mmc_host *vub300) in send_command() argument
892 struct mmc_command *cmd = vub300->cmd; in send_command()
893 struct mmc_data *data = vub300->data; in send_command()
897 if (vub300->app_spec) { in send_command()
901 vub300->resp_len = 6; in send_command()
903 vub300->bus_width = 1; in send_command()
905 vub300->bus_width = 4; in send_command()
907 dev_err(&vub300->udev->dev, in send_command()
913 vub300->resp_len = 6; in send_command()
917 vub300->resp_len = 6; in send_command()
921 vub300->resp_len = 6; in send_command()
925 vub300->resp_len = 6; in send_command()
929 vub300->resp_len = 6; in send_command()
933 vub300->resp_len = 6; in send_command()
937 vub300->resp_len = 6; in send_command()
940 vub300->resp_len = 0; in send_command()
942 complete(&vub300->command_complete); in send_command()
945 vub300->app_spec = 0; in send_command()
950 vub300->resp_len = 0; in send_command()
954 vub300->resp_len = 6; in send_command()
958 vub300->resp_len = 17; in send_command()
962 vub300->resp_len = 6; in send_command()
966 vub300->resp_len = 0; in send_command()
970 vub300->resp_len = 6; in send_command()
974 vub300->resp_len = 6; in send_command()
978 vub300->resp_len = 6; in send_command()
982 vub300->resp_len = 6; in send_command()
986 vub300->resp_len = 17; in send_command()
990 vub300->resp_len = 17; in send_command()
994 vub300->resp_len = 6; in send_command()
998 vub300->resp_len = 6; in send_command()
1002 vub300->resp_len = 0; in send_command()
1005 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in send_command()
1006 vub300->fbs[i] = 0xFFFF & cmd->arg; in send_command()
1008 vub300->resp_len = 6; in send_command()
1016 vub300->resp_len = 6; in send_command()
1021 vub300->resp_len = 6; in send_command()
1027 vub300->resp_len = 6; in send_command()
1031 vub300->resp_len = 6; in send_command()
1035 vub300->resp_len = 6; in send_command()
1039 vub300->resp_len = 6; in send_command()
1040 snoop_block_size_and_bus_width(vub300, cmd->arg); in send_command()
1044 vub300->resp_len = 6; in send_command()
1048 vub300->resp_len = 6; in send_command()
1049 vub300->app_spec = 1; in send_command()
1053 vub300->resp_len = 6; in send_command()
1056 vub300->resp_len = 0; in send_command()
1058 complete(&vub300->command_complete); in send_command()
1066 vub300->cmnd.head.header_size = 20; in send_command()
1067 vub300->cmnd.head.header_type = 0x00; in send_command()
1068 vub300->cmnd.head.port_number = 0; /* "0" means port 1 */ in send_command()
1069 vub300->cmnd.head.command_type = 0x00; /* standard read command */ in send_command()
1070 vub300->cmnd.head.response_type = response_type; in send_command()
1071 vub300->cmnd.head.command_index = cmd->opcode; in send_command()
1072 vub300->cmnd.head.arguments[0] = cmd->arg >> 24; in send_command()
1073 vub300->cmnd.head.arguments[1] = cmd->arg >> 16; in send_command()
1074 vub300->cmnd.head.arguments[2] = cmd->arg >> 8; in send_command()
1075 vub300->cmnd.head.arguments[3] = cmd->arg >> 0; in send_command()
1078 vub300->cmnd.head.block_count[0] = 0; in send_command()
1079 vub300->cmnd.head.block_count[1] = 0; in send_command()
1080 vub300->cmnd.head.block_size[0] = (vub300->fbs[fn] >> 8) & 0xFF; in send_command()
1081 vub300->cmnd.head.block_size[1] = (vub300->fbs[fn] >> 0) & 0xFF; in send_command()
1082 vub300->cmnd.head.command_type = 0x00; in send_command()
1083 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1084 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1085 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1086 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1088 vub300->cmnd.head.block_count[0] = 0; in send_command()
1089 vub300->cmnd.head.block_count[1] = 0; in send_command()
1090 vub300->cmnd.head.block_size[0] = (vub300->fbs[0] >> 8) & 0xFF; in send_command()
1091 vub300->cmnd.head.block_size[1] = (vub300->fbs[0] >> 0) & 0xFF; in send_command()
1092 vub300->cmnd.head.command_type = 0x00; in send_command()
1093 vub300->cmnd.head.transfer_size[0] = 0; in send_command()
1094 vub300->cmnd.head.transfer_size[1] = 0; in send_command()
1095 vub300->cmnd.head.transfer_size[2] = 0; in send_command()
1096 vub300->cmnd.head.transfer_size[3] = 0; in send_command()
1099 if (0x08 & vub300->cmnd.head.arguments[0]) { /* BLOCK MODE */ in send_command()
1100 vub300->cmnd.head.block_count[0] = in send_command()
1102 vub300->cmnd.head.block_count[1] = in send_command()
1104 vub300->cmnd.head.block_size[0] = in send_command()
1106 vub300->cmnd.head.block_size[1] = in send_command()
1109 vub300->cmnd.head.block_count[0] = 0; in send_command()
1110 vub300->cmnd.head.block_count[1] = 0; in send_command()
1111 vub300->cmnd.head.block_size[0] = in send_command()
1112 (vub300->datasize >> 8) & 0xFF; in send_command()
1113 vub300->cmnd.head.block_size[1] = in send_command()
1114 (vub300->datasize >> 0) & 0xFF; in send_command()
1116 vub300->cmnd.head.command_type = in send_command()
1118 vub300->cmnd.head.transfer_size[0] = in send_command()
1119 (vub300->datasize >> 24) & 0xFF; in send_command()
1120 vub300->cmnd.head.transfer_size[1] = in send_command()
1121 (vub300->datasize >> 16) & 0xFF; in send_command()
1122 vub300->cmnd.head.transfer_size[2] = in send_command()
1123 (vub300->datasize >> 8) & 0xFF; in send_command()
1124 vub300->cmnd.head.transfer_size[3] = in send_command()
1125 (vub300->datasize >> 0) & 0xFF; in send_command()
1126 if (vub300->datasize < vub300->fbs[fn]) { in send_command()
1127 vub300->cmnd.head.block_count[0] = 0; in send_command()
1128 vub300->cmnd.head.block_count[1] = 0; in send_command()
1131 vub300->cmnd.head.block_count[0] = (data->blocks >> 8) & 0xFF; in send_command()
1132 vub300->cmnd.head.block_count[1] = (data->blocks >> 0) & 0xFF; in send_command()
1133 vub300->cmnd.head.block_size[0] = (data->blksz >> 8) & 0xFF; in send_command()
1134 vub300->cmnd.head.block_size[1] = (data->blksz >> 0) & 0xFF; in send_command()
1135 vub300->cmnd.head.command_type = in send_command()
1137 vub300->cmnd.head.transfer_size[0] = in send_command()
1138 (vub300->datasize >> 24) & 0xFF; in send_command()
1139 vub300->cmnd.head.transfer_size[1] = in send_command()
1140 (vub300->datasize >> 16) & 0xFF; in send_command()
1141 vub300->cmnd.head.transfer_size[2] = in send_command()
1142 (vub300->datasize >> 8) & 0xFF; in send_command()
1143 vub300->cmnd.head.transfer_size[3] = in send_command()
1144 (vub300->datasize >> 0) & 0xFF; in send_command()
1145 if (vub300->datasize < vub300->fbs[0]) { in send_command()
1146 vub300->cmnd.head.block_count[0] = 0; in send_command()
1147 vub300->cmnd.head.block_count[1] = 0; in send_command()
1150 if (vub300->cmnd.head.block_size[0] || vub300->cmnd.head.block_size[1]) { in send_command()
1151 u16 block_size = vub300->cmnd.head.block_size[1] | in send_command()
1152 (vub300->cmnd.head.block_size[0] << 8); in send_command()
1155 vub300->cmnd.head.block_boundary[0] = in send_command()
1157 vub300->cmnd.head.block_boundary[1] = in send_command()
1160 vub300->cmnd.head.block_boundary[0] = 0; in send_command()
1161 vub300->cmnd.head.block_boundary[1] = 0; in send_command()
1163 usb_fill_bulk_urb(vub300->command_out_urb, vub300->udev, in send_command()
1164 usb_sndbulkpipe(vub300->udev, vub300->cmnd_out_ep), in send_command()
1165 &vub300->cmnd, sizeof(vub300->cmnd), in send_command()
1166 command_out_completed, vub300); in send_command()
1167 retval = usb_submit_urb(vub300->command_out_urb, GFP_KERNEL); in send_command()
1170 complete(&vub300->command_complete); in send_command()
1183 struct vub300_mmc_host *vub300 = from_timer(vub300, t, in vub300_sg_timed_out() local
1185 vub300->usb_timed_out = 1; in vub300_sg_timed_out()
1186 usb_sg_cancel(&vub300->sg_request); in vub300_sg_timed_out()
1187 usb_unlink_urb(vub300->command_out_urb); in vub300_sg_timed_out()
1188 usb_unlink_urb(vub300->command_res_urb); in vub300_sg_timed_out()
1199 static void __download_offload_pseudocode(struct vub300_mmc_host *vub300, in __download_offload_pseudocode() argument
1208 dev_info(&vub300->udev->dev, "using %s for SDIO offload processing\n", in __download_offload_pseudocode()
1209 vub300->vub_name); in __download_offload_pseudocode()
1213 dev_info(&vub300->udev->dev, "using offload firmware %s %s\n", fw->data, in __download_offload_pseudocode()
1214 vub300->vub_name); in __download_offload_pseudocode()
1216 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1218 vub300->vub_name); in __download_offload_pseudocode()
1219 strscpy(vub300->vub_name, "corrupt offload pseudocode", in __download_offload_pseudocode()
1220 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1239 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1240 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1249 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1252 vub300->vub_name); in __download_offload_pseudocode()
1253 strscpy(vub300->vub_name, in __download_offload_pseudocode()
1255 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1259 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1261 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1262 strscpy(vub300->vub_name, "corrupt interrupt pseudocode", in __download_offload_pseudocode()
1263 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1282 usb_control_msg(vub300->udev, in __download_offload_pseudocode()
1283 usb_sndctrlpipe(vub300->udev, 0), in __download_offload_pseudocode()
1292 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1295 vub300->vub_name); in __download_offload_pseudocode()
1296 strscpy(vub300->vub_name, in __download_offload_pseudocode()
1298 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1302 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1304 fw->data, vub300->vub_name); in __download_offload_pseudocode()
1305 strscpy(vub300->vub_name, "corrupt transfer pseudocode", in __download_offload_pseudocode()
1306 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1312 int I = vub300->dynamic_register_count = register_count; in __download_offload_pseudocode()
1316 vub300->sdio_register[i].func_num = *data++; in __download_offload_pseudocode()
1326 vub300->sdio_register[i].sdio_reg = func_num; in __download_offload_pseudocode()
1327 vub300->sdio_register[i].activate = 1; in __download_offload_pseudocode()
1328 vub300->sdio_register[i].prepared = 0; in __download_offload_pseudocode()
1331 dev_info(&vub300->udev->dev, in __download_offload_pseudocode()
1333 vub300->dynamic_register_count); in __download_offload_pseudocode()
1336 dev_err(&vub300->udev->dev, in __download_offload_pseudocode()
1338 vub300->vub_name); in __download_offload_pseudocode()
1339 strscpy(vub300->vub_name, "corrupt dynamic registers", in __download_offload_pseudocode()
1340 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1345 strscpy(vub300->vub_name, "SDIO pseudocode download failed", in __download_offload_pseudocode()
1346 sizeof(vub300->vub_name)); in __download_offload_pseudocode()
1353 static void download_offload_pseudocode(struct vub300_mmc_host *vub300) in download_offload_pseudocode() argument
1355 struct mmc_card *card = vub300->mmc->card; in download_offload_pseudocode()
1358 int l = snprintf(vub300->vub_name, sizeof(vub300->vub_name), in download_offload_pseudocode()
1364 l += scnprintf(vub300->vub_name + l, in download_offload_pseudocode()
1365 sizeof(vub300->vub_name) - l, "_%04X%04X", in download_offload_pseudocode()
1368 snprintf(vub300->vub_name + l, sizeof(vub300->vub_name) - l, ".bin"); in download_offload_pseudocode()
1369 dev_info(&vub300->udev->dev, "requesting offload firmware %s\n", in download_offload_pseudocode()
1370 vub300->vub_name); in download_offload_pseudocode()
1371 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1373 strscpy(vub300->vub_name, "vub_default.bin", in download_offload_pseudocode()
1374 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1375 retval = request_firmware(&fw, vub300->vub_name, &card->dev); in download_offload_pseudocode()
1377 strscpy(vub300->vub_name, in download_offload_pseudocode()
1379 sizeof(vub300->vub_name)); in download_offload_pseudocode()
1381 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1385 __download_offload_pseudocode(vub300, fw); in download_offload_pseudocode()
1395 static int vub300_usb_bulk_msg(struct vub300_mmc_host *vub300, in vub300_usb_bulk_msg() argument
1400 struct usb_device *usb_dev = vub300->udev; in vub300_usb_bulk_msg()
1403 vub300->urb = usb_alloc_urb(0, GFP_KERNEL); in vub300_usb_bulk_msg()
1404 if (!vub300->urb) in vub300_usb_bulk_msg()
1406 usb_fill_bulk_urb(vub300->urb, usb_dev, pipe, data, len, in vub300_usb_bulk_msg()
1409 vub300->urb->context = &done; in vub300_usb_bulk_msg()
1410 vub300->urb->actual_length = 0; in vub300_usb_bulk_msg()
1411 retval = usb_submit_urb(vub300->urb, GFP_KERNEL); in vub300_usb_bulk_msg()
1417 usb_kill_urb(vub300->urb); in vub300_usb_bulk_msg()
1419 retval = vub300->urb->status; in vub300_usb_bulk_msg()
1422 *actual_length = vub300->urb->actual_length; in vub300_usb_bulk_msg()
1423 usb_free_urb(vub300->urb); in vub300_usb_bulk_msg()
1424 vub300->urb = NULL; in vub300_usb_bulk_msg()
1428 static int __command_read_data(struct vub300_mmc_host *vub300, in __command_read_data() argument
1432 int linear_length = vub300->datasize; in __command_read_data()
1433 int padded_length = vub300->large_usb_packets ? in __command_read_data()
1439 pipe = usb_rcvbulkpipe(vub300->udev, vub300->data_inp_ep); in __command_read_data()
1440 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_read_data()
1444 usb_unlink_urb(vub300->command_out_urb); in __command_read_data()
1445 usb_unlink_urb(vub300->command_res_urb); in __command_read_data()
1450 vub300->sg_transfer_timer.expires = in __command_read_data()
1453 add_timer(&vub300->sg_transfer_timer); in __command_read_data()
1454 usb_sg_wait(&vub300->sg_request); in __command_read_data()
1455 del_timer(&vub300->sg_transfer_timer); in __command_read_data()
1456 if (vub300->sg_request.status < 0) { in __command_read_data()
1457 cmd->error = vub300->sg_request.status; in __command_read_data()
1461 data->bytes_xfered = vub300->datasize; in __command_read_data()
1469 unsigned pipe = usb_rcvbulkpipe(vub300->udev, in __command_read_data()
1470 vub300->data_inp_ep); in __command_read_data()
1472 result = vub300_usb_bulk_msg(vub300, pipe, buf, in __command_read_data()
1489 data->bytes_xfered = vub300->datasize; in __command_read_data()
1500 static int __command_write_data(struct vub300_mmc_host *vub300, in __command_write_data() argument
1504 unsigned pipe = usb_sndbulkpipe(vub300->udev, vub300->data_out_ep); in __command_write_data()
1505 int linear_length = vub300->datasize; in __command_write_data()
1512 vub300->padded_buffer, in __command_write_data()
1513 sizeof(vub300->padded_buffer)); in __command_write_data()
1514 memset(vub300->padded_buffer + linear_length, 0, in __command_write_data()
1515 sizeof(vub300->padded_buffer) - linear_length); in __command_write_data()
1516 result = vub300_usb_bulk_msg(vub300, pipe, vub300->padded_buffer, in __command_write_data()
1517 sizeof(vub300->padded_buffer), in __command_write_data()
1519 (sizeof(vub300->padded_buffer) / in __command_write_data()
1525 data->bytes_xfered = vub300->datasize; in __command_write_data()
1527 } else if ((!vub300->large_usb_packets && (0 < modulo_64_length)) || in __command_write_data()
1528 (vub300->large_usb_packets && (64 > modulo_512_length)) in __command_write_data()
1540 vub300_usb_bulk_msg(vub300, pipe, buf, in __command_write_data()
1548 data->bytes_xfered = vub300->datasize; in __command_write_data()
1558 result = usb_sg_init(&vub300->sg_request, vub300->udev, in __command_write_data()
1562 usb_unlink_urb(vub300->command_out_urb); in __command_write_data()
1563 usb_unlink_urb(vub300->command_res_urb); in __command_write_data()
1567 vub300->sg_transfer_timer.expires = in __command_write_data()
1570 add_timer(&vub300->sg_transfer_timer); in __command_write_data()
1571 usb_sg_wait(&vub300->sg_request); in __command_write_data()
1575 del_timer(&vub300->sg_transfer_timer); in __command_write_data()
1576 if (vub300->sg_request.status < 0) { in __command_write_data()
1577 cmd->error = vub300->sg_request.status; in __command_write_data()
1580 data->bytes_xfered = vub300->datasize; in __command_write_data()
1588 static void __vub300_command_response(struct vub300_mmc_host *vub300, in __vub300_command_response() argument
1596 wait_for_completion_timeout(&vub300->command_complete, in __vub300_command_response()
1601 vub300->usb_timed_out = 1; in __vub300_command_response()
1602 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1603 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1605 result = usb_lock_device_for_reset(vub300->udev, in __vub300_command_response()
1606 vub300->interface); in __vub300_command_response()
1608 result = usb_reset_device(vub300->udev); in __vub300_command_response()
1609 usb_unlock_device(vub300->udev); in __vub300_command_response()
1613 usb_kill_urb(vub300->command_out_urb); in __vub300_command_response()
1614 usb_kill_urb(vub300->command_res_urb); in __vub300_command_response()
1621 } else if (vub300->command_out_urb->status) { in __vub300_command_response()
1622 vub300->usb_transport_fail = vub300->command_out_urb->status; in __vub300_command_response()
1623 cmd->error = -EPROTO == vub300->command_out_urb->status ? in __vub300_command_response()
1624 -ESHUTDOWN : vub300->command_out_urb->status; in __vub300_command_response()
1625 } else if (vub300->command_res_urb->status) { in __vub300_command_response()
1626 vub300->usb_transport_fail = vub300->command_res_urb->status; in __vub300_command_response()
1627 cmd->error = -EPROTO == vub300->command_res_urb->status ? in __vub300_command_response()
1628 -ESHUTDOWN : vub300->command_res_urb->status; in __vub300_command_response()
1629 } else if (vub300->resp.common.header_type == 0x00) { in __vub300_command_response()
1634 } else if (vub300->resp.common.header_type == RESPONSE_ERROR) { in __vub300_command_response()
1636 vub300_response_error(vub300->resp.error.error_code); in __vub300_command_response()
1637 if (vub300->data) in __vub300_command_response()
1638 usb_sg_cancel(&vub300->sg_request); in __vub300_command_response()
1639 } else if (vub300->resp.common.header_type == RESPONSE_PIGGYBACKED) { in __vub300_command_response()
1641 vub300->resp.common.header_size - in __vub300_command_response()
1646 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1649 vub300->resp.common.header_size = in __vub300_command_response()
1651 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1653 } else if (vub300->resp.common.header_type == RESPONSE_PIG_DISABLED) { in __vub300_command_response()
1655 vub300->resp.common.header_size - in __vub300_command_response()
1660 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1663 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1664 if (vub300->irqs_queued) { in __vub300_command_response()
1665 vub300->irqs_queued += 1; in __vub300_command_response()
1666 } else if (vub300->irq_enabled) { in __vub300_command_response()
1667 vub300->irqs_queued += 1; in __vub300_command_response()
1668 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1670 vub300->irqs_queued += 1; in __vub300_command_response()
1672 vub300->irq_disabled = 1; in __vub300_command_response()
1673 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1674 vub300->resp.common.header_size = in __vub300_command_response()
1676 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1678 } else if (vub300->resp.common.header_type == RESPONSE_PIG_ENABLED) { in __vub300_command_response()
1680 vub300->resp.common.header_size - in __vub300_command_response()
1685 add_offloaded_reg(vub300, &vub300->resp.pig.reg[ri]); in __vub300_command_response()
1688 mutex_lock(&vub300->irq_mutex); in __vub300_command_response()
1689 if (vub300->irqs_queued) { in __vub300_command_response()
1690 vub300->irqs_queued += 1; in __vub300_command_response()
1691 } else if (vub300->irq_enabled) { in __vub300_command_response()
1692 vub300->irqs_queued += 1; in __vub300_command_response()
1693 vub300_queue_poll_work(vub300, 0); in __vub300_command_response()
1695 vub300->irqs_queued += 1; in __vub300_command_response()
1697 vub300->irq_disabled = 0; in __vub300_command_response()
1698 mutex_unlock(&vub300->irq_mutex); in __vub300_command_response()
1699 vub300->resp.common.header_size = in __vub300_command_response()
1701 vub300->resp.common.header_type = 0x00; in __vub300_command_response()
1708 static void construct_request_response(struct vub300_mmc_host *vub300, in construct_request_response() argument
1711 int resp_len = vub300->resp_len; in construct_request_response()
1715 u8 *r = vub300->resp.response.command_response; in construct_request_response()
1742 struct vub300_mmc_host *vub300 = in vub300_cmndwork_thread() local
1744 if (!vub300->interface) { in vub300_cmndwork_thread()
1745 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1748 struct mmc_request *req = vub300->req; in vub300_cmndwork_thread()
1749 struct mmc_command *cmd = vub300->cmd; in vub300_cmndwork_thread()
1750 struct mmc_data *data = vub300->data; in vub300_cmndwork_thread()
1752 mutex_lock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1753 init_completion(&vub300->command_complete); in vub300_cmndwork_thread()
1754 if (likely(vub300->vub_name[0]) || !vub300->mmc->card) { in vub300_cmndwork_thread()
1760 } else if (0 == vub300->mmc->card->sdio_funcs) { in vub300_cmndwork_thread()
1761 strscpy(vub300->vub_name, "SD memory device", in vub300_cmndwork_thread()
1762 sizeof(vub300->vub_name)); in vub300_cmndwork_thread()
1764 download_offload_pseudocode(vub300); in vub300_cmndwork_thread()
1766 send_command(vub300); in vub300_cmndwork_thread()
1770 data_length = __command_read_data(vub300, cmd, data); in vub300_cmndwork_thread()
1772 data_length = __command_write_data(vub300, cmd, data); in vub300_cmndwork_thread()
1773 __vub300_command_response(vub300, cmd, data, data_length); in vub300_cmndwork_thread()
1774 vub300->req = NULL; in vub300_cmndwork_thread()
1775 vub300->cmd = NULL; in vub300_cmndwork_thread()
1776 vub300->data = NULL; in vub300_cmndwork_thread()
1779 check_vub300_port_status(vub300); in vub300_cmndwork_thread()
1780 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1781 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1782 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1785 construct_request_response(vub300, cmd); in vub300_cmndwork_thread()
1786 vub300->resp_len = 0; in vub300_cmndwork_thread()
1787 mutex_unlock(&vub300->cmd_mutex); in vub300_cmndwork_thread()
1788 kref_put(&vub300->kref, vub300_delete); in vub300_cmndwork_thread()
1789 mmc_request_done(vub300->mmc, req); in vub300_cmndwork_thread()
1795 static int examine_cyclic_buffer(struct vub300_mmc_host *vub300, in examine_cyclic_buffer() argument
1803 int first = MAXREGMASK & vub300->fn[Function].offload_point; in examine_cyclic_buffer()
1804 struct offload_registers_access *rf = &vub300->fn[Function].reg[first]; in examine_cyclic_buffer()
1815 vub300->fn[Function].offload_point += 1; in examine_cyclic_buffer()
1816 vub300->fn[Function].offload_count -= 1; in examine_cyclic_buffer()
1817 vub300->total_offload_count -= 1; in examine_cyclic_buffer()
1821 u8 register_count = vub300->fn[Function].offload_count - 1; in examine_cyclic_buffer()
1822 u32 register_point = vub300->fn[Function].offload_point + 1; in examine_cyclic_buffer()
1826 &vub300->fn[Function].reg[point]; in examine_cyclic_buffer()
1837 vub300->fn[Function].offload_point += delta; in examine_cyclic_buffer()
1838 vub300->fn[Function].offload_count -= delta; in examine_cyclic_buffer()
1839 vub300->total_offload_count -= delta; in examine_cyclic_buffer()
1852 static int satisfy_request_from_offloaded_data(struct vub300_mmc_host *vub300, in satisfy_request_from_offloaded_data() argument
1856 u8 regs = vub300->dynamic_register_count; in satisfy_request_from_offloaded_data()
1861 if ((vub300->sdio_register[i].func_num == func) && in satisfy_request_from_offloaded_data()
1862 (vub300->sdio_register[i].sdio_reg == reg)) { in satisfy_request_from_offloaded_data()
1863 if (!vub300->sdio_register[i].prepared) { in satisfy_request_from_offloaded_data()
1870 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1876 u8 rsp2 = vub300->sdio_register[i].response; in satisfy_request_from_offloaded_data()
1877 u8 rsp3 = vub300->sdio_register[i].regvalue; in satisfy_request_from_offloaded_data()
1878 vub300->sdio_register[i].prepared = 0; in satisfy_request_from_offloaded_data()
1891 if (vub300->total_offload_count == 0) in satisfy_request_from_offloaded_data()
1893 else if (vub300->fn[func].offload_count == 0) in satisfy_request_from_offloaded_data()
1896 return examine_cyclic_buffer(vub300, cmd, func); in satisfy_request_from_offloaded_data()
1902 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_request() local
1903 if (!vub300->interface) { in vub300_mmc_request()
1909 if (!vub300->card_powered) { in vub300_mmc_request()
1914 if (!vub300->card_present) { in vub300_mmc_request()
1919 if (vub300->usb_transport_fail) { in vub300_mmc_request()
1920 cmd->error = vub300->usb_transport_fail; in vub300_mmc_request()
1924 if (!vub300->interface) { in vub300_mmc_request()
1929 kref_get(&vub300->kref); in vub300_mmc_request()
1930 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_request()
1931 mod_timer(&vub300->inactivity_timer, jiffies + HZ); in vub300_mmc_request()
1937 satisfy_request_from_offloaded_data(vub300, cmd)) { in vub300_mmc_request()
1939 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1940 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1944 vub300->cmd = cmd; in vub300_mmc_request()
1945 vub300->req = req; in vub300_mmc_request()
1946 vub300->data = data; in vub300_mmc_request()
1948 vub300->datasize = data->blksz * data->blocks; in vub300_mmc_request()
1950 vub300->datasize = 0; in vub300_mmc_request()
1951 vub300_queue_cmnd_work(vub300); in vub300_mmc_request()
1952 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_request()
1953 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_request()
1965 static void __set_clock_speed(struct vub300_mmc_host *vub300, u8 buf[8], in __set_clock_speed() argument
1992 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in __set_clock_speed()
1997 dev_err(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2000 dev_dbg(&vub300->udev->dev, "SET_CLOCK_SPEED" in __set_clock_speed()
2007 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_set_ios() local
2008 if (!vub300->interface) in vub300_mmc_set_ios()
2010 kref_get(&vub300->kref); in vub300_mmc_set_ios()
2011 mutex_lock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2012 if ((ios->power_mode == MMC_POWER_OFF) && vub300->card_powered) { in vub300_mmc_set_ios()
2013 vub300->card_powered = 0; in vub300_mmc_set_ios()
2014 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2020 } else if ((ios->power_mode == MMC_POWER_UP) && !vub300->card_powered) { in vub300_mmc_set_ios()
2021 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_mmc_set_ios()
2026 vub300->card_powered = 1; in vub300_mmc_set_ios()
2030 __set_clock_speed(vub300, buf, ios); in vub300_mmc_set_ios()
2036 mutex_unlock(&vub300->cmd_mutex); in vub300_mmc_set_ios()
2037 kref_put(&vub300->kref, vub300_delete); in vub300_mmc_set_ios()
2042 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_mmc_get_ro() local
2043 return vub300->read_only; in vub300_mmc_get_ro()
2048 struct vub300_mmc_host *vub300 = mmc_priv(mmc); in vub300_enable_sdio_irq() local
2049 if (!vub300->interface) in vub300_enable_sdio_irq()
2051 kref_get(&vub300->kref); in vub300_enable_sdio_irq()
2054 mutex_lock(&vub300->irq_mutex); in vub300_enable_sdio_irq()
2055 if (vub300->irqs_queued) { in vub300_enable_sdio_irq()
2056 vub300->irqs_queued -= 1; in vub300_enable_sdio_irq()
2057 mmc_signal_sdio_irq(vub300->mmc); in vub300_enable_sdio_irq()
2058 } else if (vub300->irq_disabled) { in vub300_enable_sdio_irq()
2059 vub300->irq_disabled = 0; in vub300_enable_sdio_irq()
2060 vub300->irq_enabled = 1; in vub300_enable_sdio_irq()
2061 vub300_queue_poll_work(vub300, 0); in vub300_enable_sdio_irq()
2062 } else if (vub300->irq_enabled) { 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()
2068 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()
2086 struct vub300_mmc_host *vub300; in vub300_probe() local
2173 vub300 = mmc_priv(mmc); in vub300_probe()
2174 vub300->mmc = mmc; in vub300_probe()
2175 vub300->card_powered = 0; in vub300_probe()
2176 vub300->bus_width = 0; in vub300_probe()
2177 vub300->cmnd.head.block_size[0] = 0x00; in vub300_probe()
2178 vub300->cmnd.head.block_size[1] = 0x00; in vub300_probe()
2179 vub300->app_spec = 0; in vub300_probe()
2180 mutex_init(&vub300->cmd_mutex); in vub300_probe()
2181 mutex_init(&vub300->irq_mutex); in vub300_probe()
2182 vub300->command_out_urb = command_out_urb; in vub300_probe()
2183 vub300->command_res_urb = command_res_urb; in vub300_probe()
2184 vub300->usb_timed_out = 0; in vub300_probe()
2185 vub300->dynamic_register_count = 0; in vub300_probe()
2187 for (i = 0; i < ARRAY_SIZE(vub300->fn); i++) { in vub300_probe()
2188 vub300->fn[i].offload_point = 0; in vub300_probe()
2189 vub300->fn[i].offload_count = 0; in vub300_probe()
2192 vub300->total_offload_count = 0; in vub300_probe()
2193 vub300->irq_enabled = 0; in vub300_probe()
2194 vub300->irq_disabled = 0; in vub300_probe()
2195 vub300->irqs_queued = 0; in vub300_probe()
2197 for (i = 0; i < ARRAY_SIZE(vub300->sdio_register); i++) in vub300_probe()
2198 vub300->sdio_register[i++].activate = 0; in vub300_probe()
2200 vub300->udev = udev; in vub300_probe()
2201 vub300->interface = interface; in vub300_probe()
2202 vub300->cmnd_res_ep = 0; in vub300_probe()
2203 vub300->cmnd_out_ep = 0; in vub300_probe()
2204 vub300->data_inp_ep = 0; in vub300_probe()
2205 vub300->data_out_ep = 0; in vub300_probe()
2207 for (i = 0; i < ARRAY_SIZE(vub300->fbs); i++) in vub300_probe()
2208 vub300->fbs[i] = 512; in vub300_probe()
2219 vub300->large_usb_packets = 0; in vub300_probe()
2224 dev_info(&vub300->udev->dev, in vub300_probe()
2230 vub300->large_usb_packets = 1; in vub300_probe()
2232 if (!vub300->cmnd_res_ep) { in vub300_probe()
2233 vub300->cmnd_res_ep = in vub300_probe()
2235 } else if (!vub300->data_inp_ep) { in vub300_probe()
2236 vub300->data_inp_ep = in vub300_probe()
2239 dev_warn(&vub300->udev->dev, in vub300_probe()
2244 if (!vub300->cmnd_out_ep) { in vub300_probe()
2245 vub300->cmnd_out_ep = in vub300_probe()
2247 } else if (!vub300->data_out_ep) { in vub300_probe()
2248 vub300->data_out_ep = in vub300_probe()
2251 dev_warn(&vub300->udev->dev, in vub300_probe()
2256 dev_warn(&vub300->udev->dev, in vub300_probe()
2261 if (vub300->cmnd_res_ep && vub300->cmnd_out_ep && in vub300_probe()
2262 vub300->data_inp_ep && vub300->data_out_ep) { in vub300_probe()
2263 dev_info(&vub300->udev->dev, in vub300_probe()
2266 vub300->large_usb_packets ? "LARGE" : "SMALL", in vub300_probe()
2267 vub300->cmnd_out_ep, vub300->cmnd_res_ep, in vub300_probe()
2268 vub300->data_out_ep, vub300->data_inp_ep); in vub300_probe()
2271 dev_err(&vub300->udev->dev, in vub300_probe()
2277 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2280 0x0000, 0x0000, &vub300->hc_info, in vub300_probe()
2281 sizeof(vub300->hc_info), 1000); in vub300_probe()
2285 usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0), in vub300_probe()
2291 dev_info(&vub300->udev->dev, in vub300_probe()
2297 vub300->large_usb_packets ? 512 : 64); in vub300_probe()
2299 usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0), in vub300_probe()
2302 0x0000, 0x0000, &vub300->system_port_status, in vub300_probe()
2303 sizeof(vub300->system_port_status), 1000); in vub300_probe()
2306 } else if (sizeof(vub300->system_port_status) == retval) { in vub300_probe()
2307 vub300->card_present = in vub300_probe()
2308 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2309 vub300->read_only = in vub300_probe()
2310 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0; in vub300_probe()
2315 usb_set_intfdata(interface, vub300); in vub300_probe()
2316 INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread); in vub300_probe()
2317 INIT_WORK(&vub300->cmndwork, vub300_cmndwork_thread); in vub300_probe()
2318 INIT_WORK(&vub300->deadwork, vub300_deadwork_thread); in vub300_probe()
2319 kref_init(&vub300->kref); in vub300_probe()
2320 timer_setup(&vub300->sg_transfer_timer, vub300_sg_timed_out, 0); in vub300_probe()
2321 kref_get(&vub300->kref); in vub300_probe()
2322 timer_setup(&vub300->inactivity_timer, in vub300_probe()
2324 vub300->inactivity_timer.expires = jiffies + HZ; in vub300_probe()
2325 add_timer(&vub300->inactivity_timer); in vub300_probe()
2326 if (vub300->card_present) in vub300_probe()
2327 dev_info(&vub300->udev->dev, in vub300_probe()
2332 dev_info(&vub300->udev->dev, in vub300_probe()
2342 del_timer_sync(&vub300->inactivity_timer); in vub300_probe()
2360 struct vub300_mmc_host *vub300 = usb_get_intfdata(interface); in vub300_disconnect() local
2361 if (!vub300 || !vub300->mmc) { in vub300_disconnect()
2364 struct mmc_host *mmc = vub300->mmc; in vub300_disconnect()
2365 if (!vub300->mmc) { in vub300_disconnect()
2371 vub300->interface = NULL; in vub300_disconnect()
2372 kref_put(&vub300->kref, vub300_delete); in vub300_disconnect()
2397 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_pre_reset() local
2398 mutex_lock(&vub300->cmd_mutex); in vub300_pre_reset()
2404 struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); in vub300_post_reset() local
2406 vub300->errors = -EPIPE; in vub300_post_reset()
2407 mutex_unlock(&vub300->cmd_mutex); in vub300_post_reset()