Changeset c3d926f in mainline for uspace/drv/bus/usb/xhci/hc.c
- Timestamp:
- 2017-10-25T08:03:13Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a5b3de6
- Parents:
- 0206d35
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
r0206d35 rc3d926f 600 600 int err; 601 601 xhci_cmd_t cmd; 602 xhci_cmd_init(&cmd); 603 604 if ((err = xhci_send_enable_slot_command(hc, &cmd)) != EOK) 605 return err; 606 607 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT)) != EOK) 608 return err; 609 610 if (slot_id) 602 xhci_cmd_init(&cmd, XHCI_CMD_ENABLE_SLOT); 603 604 if ((err = xhci_cmd_sync(hc, &cmd))) { 605 goto end; 606 } 607 608 if (slot_id) { 611 609 *slot_id = cmd.slot_id; 612 610 } 611 612 end: 613 613 xhci_cmd_fini(&cmd); 614 return EOK;614 return err; 615 615 } 616 616 … … 620 620 621 621 int err; 622 xhci_cmd_t cmd; 623 xhci_cmd_init(&cmd); 624 625 cmd.slot_id = slot_id; 626 627 if ((err = xhci_send_disable_slot_command(hc, &cmd)) != EOK) 628 return err; 629 630 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT)) != EOK) 631 return err; 632 633 xhci_cmd_fini(&cmd); 622 if ((err = xhci_cmd_sync_inline(hc, DISABLE_SLOT, .slot_id = slot_id))) { 623 return err; 624 } 625 634 626 return EOK; 635 627 } … … 688 680 xhci_setup_endpoint_context(ep0, &ictx->endpoint_ctx[0]); 689 681 690 xhci_cmd_t cmd; 691 xhci_cmd_init(&cmd); 692 693 cmd.slot_id = dev->slot_id; 694 695 if ((err = xhci_send_address_device_command(hc, &cmd, ictx)) != EOK) 696 goto err_cmd; 697 698 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT)) != EOK) 699 goto err_cmd; 682 /* Issue Address Device command. */ 683 if ((err = xhci_cmd_sync_inline(hc, ADDRESS_DEVICE, .slot_id = dev->slot_id, .input_ctx = ictx))) { 684 goto err_dev_ctx; 685 } 700 686 701 687 dev->base.address = XHCI_SLOT_DEVICE_ADDRESS(dev->dev_ctx->slot_ctx); … … 707 693 fibril_mutex_unlock(&dev->base.guard); 708 694 709 xhci_cmd_fini(&cmd); 710 free32(ictx); 711 return EOK; 712 713 err_cmd: 714 xhci_cmd_fini(&cmd); 715 free32(ictx); 695 return EOK; 696 716 697 err_dev_ctx: 717 698 free32(dev->dev_ctx); … … 728 709 xhci_input_ctx_t *ictx; 729 710 if ((err = create_valid_input_ctx(&ictx))) { 730 goto err; 731 } 732 711 return err; 712 } 733 713 // TODO: Set slot context and other flags. (probably forgot a lot of 'em) 734 714 735 xhci_cmd_t cmd; 736 xhci_cmd_init(&cmd); 737 738 cmd.slot_id = slot_id; 739 740 if ((err = xhci_send_configure_endpoint_command(hc, &cmd, ictx))) { 741 goto err_cmd; 742 } 743 744 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT))) { 745 goto err_cmd; 746 } 747 748 xhci_cmd_fini(&cmd); 749 750 free32(ictx); 751 return EOK; 752 753 err_cmd: 754 free32(ictx); 755 err: 756 return err; 715 if ((err = xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = slot_id, .input_ctx = ictx))) { 716 return err; 717 } 718 719 return EOK; 757 720 } 758 721 … … 762 725 763 726 /* Issue configure endpoint command (sec 4.3.5) with the DC flag. */ 764 xhci_cmd_t cmd; 765 xhci_cmd_init(&cmd); 766 767 cmd.slot_id = slot_id; 768 cmd.deconfigure = true; 769 770 if ((err = xhci_send_configure_endpoint_command(hc, &cmd, NULL))) { 771 return err; 772 } 773 774 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT))) { 775 return err; 776 } 777 778 xhci_cmd_fini(&cmd); 727 if ((err = xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = slot_id, .deconfigure = true))) { 728 return err; 729 } 779 730 780 731 return EOK; … … 788 739 xhci_input_ctx_t *ictx; 789 740 if ((err = create_valid_input_ctx(&ictx))) { 790 gotoerr;741 return err; 791 742 } 792 743 793 744 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */ 794 745 memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t)); 795 796 746 // TODO: Set slot context and other flags. (probably forgot a lot of 'em) 797 747 798 xhci_cmd_t cmd; 799 xhci_cmd_init(&cmd); 800 801 cmd.slot_id = slot_id; 802 803 if ((err = xhci_send_configure_endpoint_command(hc, &cmd, ictx))) { 804 goto err_cmd; 805 } 806 807 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT))) { 808 goto err_cmd; 809 } 810 811 xhci_cmd_fini(&cmd); 812 813 free32(ictx); 814 return EOK; 815 816 err_cmd: 817 free32(ictx); 818 err: 819 return err; 748 if ((err = xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = slot_id, .input_ctx = ictx))) { 749 return err; 750 } 751 752 return EOK; 820 753 } 821 754 … … 827 760 xhci_input_ctx_t *ictx; 828 761 if ((err = create_valid_input_ctx(&ictx))) { 829 gotoerr;762 return err; 830 763 } 831 764 832 765 XHCI_INPUT_CTRL_CTX_DROP_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */ 833 834 766 // TODO: Set slot context and other flags. (probably forgot a lot of 'em) 835 767 836 xhci_cmd_t cmd; 837 xhci_cmd_init(&cmd); 838 839 cmd.slot_id = slot_id; 840 841 if ((err = xhci_send_configure_endpoint_command(hc, &cmd, ictx))) { 842 goto err_cmd; 843 } 844 845 if ((err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT))) { 846 goto err_cmd; 847 } 848 849 xhci_cmd_fini(&cmd); 850 851 free32(ictx); 852 return EOK; 853 854 err_cmd: 855 free32(ictx); 856 err: 857 return err; 768 if ((err = xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = slot_id, .input_ctx = ictx))) { 769 return err; 770 } 771 772 return EOK; 858 773 } 859 774
Note:
See TracChangeset
for help on using the changeset viewer.