| 796 | ****************************************************************************/ |
| 797 | |
| 798 | int sim_usbhost_initialize(void) |
| 799 | { |
| 800 | struct sim_usbhost_s *priv = &g_sim_usbhost; |
| 801 | struct usbhost_hubport_s *hport; |
| 802 | int ret; |
| 803 | |
| 804 | #ifdef CONFIG_USBHOST_CDCACM |
| 805 | ret = usbhost_cdcacm_initialize(); |
| 806 | #endif |
| 807 | |
| 808 | /* Initialize the device operations */ |
| 809 | |
| 810 | priv->drvr.ep0configure = sim_usbhost_ep0configure; |
| 811 | priv->drvr.epalloc = sim_usbhost_epalloc; |
| 812 | priv->drvr.epfree = sim_usbhost_epfree; |
| 813 | priv->drvr.alloc = sim_usbhost_alloc; |
| 814 | priv->drvr.free = sim_usbhost_free; |
| 815 | priv->drvr.ioalloc = sim_usbhost_ioalloc; |
| 816 | priv->drvr.iofree = sim_usbhost_iofree; |
| 817 | priv->drvr.ctrlin = sim_usbhost_ctrlin; |
| 818 | priv->drvr.ctrlout = sim_usbhost_ctrlout; |
| 819 | priv->drvr.transfer = sim_usbhost_transfer; |
| 820 | priv->drvr.cancel = sim_usbhost_cancel; |
| 821 | priv->drvr.disconnect = sim_usbhost_disconnect; |
| 822 | #ifdef CONFIG_USBHOST_ASYNCH |
| 823 | priv->drvr.asynch = sim_usbhost_asynch; |
| 824 | #endif |
| 825 | |
| 826 | /* Initialize the public port representation */ |
| 827 | |
| 828 | hport = &priv->hport.hport; |
| 829 | hport->drvr = &priv->drvr; |
| 830 | hport->ep0 = &priv->ep0; |
| 831 | hport->port = 0; |
| 832 | hport->speed = USB_SPEED_HIGH; |
| 833 | |
| 834 | /* Initialize function address generation logic */ |
| 835 | |
| 836 | usbhost_devaddr_initialize(&priv->devgen); |
| 837 | priv->hport.pdevgen = &priv->devgen; |
| 838 | |
| 839 | /* Initialize host usb controller */ |
| 840 | |
| 841 | host_usbhost_init(); |
| 842 | |
| 843 | /* Initialize the driver state data */ |
| 844 | |
| 845 | priv->state = USB_HOST_DETACHED; |
| 846 | |
| 847 | ret = kthread_create("usbhost monitor", CONFIG_SIM_USB_PRIO, |
| 848 | CONFIG_SIM_USB_STACKSIZE, |
| 849 | sim_usbhost_waittask, NULL); |
| 850 | if (ret < 0) |
| 851 | { |
| 852 | uerr("ERROR: Failed to create sim_usbhost_waittask: %d\n", ret); |
| 853 | return -ENODEV; |
| 854 | } |
| 855 |
no test coverage detected