usb_hc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2025, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usbh_core.h"
  7. #include "usbh_hub.h"
  8. int usb_hc_init(struct usbh_bus *bus)
  9. {
  10. return 0;
  11. }
  12. int usb_hc_deinit(struct usbh_bus *bus)
  13. {
  14. return 0;
  15. }
  16. uint16_t usbh_get_frame_number(struct usbh_bus *bus)
  17. {
  18. return 0;
  19. }
  20. int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, uint8_t *buf)
  21. {
  22. uint8_t nports;
  23. uint8_t port;
  24. uint32_t status;
  25. nports = CONFIG_USBHOST_MAX_RHPORTS;
  26. port = setup->wIndex;
  27. if (setup->bmRequestType & USB_REQUEST_RECIPIENT_DEVICE) {
  28. switch (setup->bRequest) {
  29. case HUB_REQUEST_CLEAR_FEATURE:
  30. switch (setup->wValue) {
  31. case HUB_FEATURE_HUB_C_LOCALPOWER:
  32. break;
  33. case HUB_FEATURE_HUB_C_OVERCURRENT:
  34. break;
  35. default:
  36. return -USB_ERR_NOTSUPP;
  37. }
  38. break;
  39. case HUB_REQUEST_SET_FEATURE:
  40. switch (setup->wValue) {
  41. case HUB_FEATURE_HUB_C_LOCALPOWER:
  42. break;
  43. case HUB_FEATURE_HUB_C_OVERCURRENT:
  44. break;
  45. default:
  46. return -USB_ERR_NOTSUPP;
  47. }
  48. break;
  49. case HUB_REQUEST_GET_DESCRIPTOR:
  50. break;
  51. case HUB_REQUEST_GET_STATUS:
  52. memset(buf, 0, 4);
  53. break;
  54. default:
  55. break;
  56. }
  57. } else if (setup->bmRequestType & USB_REQUEST_RECIPIENT_OTHER) {
  58. switch (setup->bRequest) {
  59. case HUB_REQUEST_CLEAR_FEATURE:
  60. if (!port || port > nports) {
  61. return -USB_ERR_INVAL;
  62. }
  63. switch (setup->wValue) {
  64. case HUB_PORT_FEATURE_ENABLE:
  65. break;
  66. case HUB_PORT_FEATURE_SUSPEND:
  67. break;
  68. case HUB_PORT_FEATURE_C_SUSPEND:
  69. break;
  70. case HUB_PORT_FEATURE_POWER:
  71. break;
  72. case HUB_PORT_FEATURE_C_CONNECTION:
  73. break;
  74. case HUB_PORT_FEATURE_C_ENABLE:
  75. break;
  76. case HUB_PORT_FEATURE_C_OVER_CURREN:
  77. break;
  78. case HUB_PORT_FEATURE_C_RESET:
  79. break;
  80. default:
  81. return -USB_ERR_NOTSUPP;
  82. }
  83. break;
  84. case HUB_REQUEST_SET_FEATURE:
  85. if (!port || port > nports) {
  86. return -USB_ERR_INVAL;
  87. }
  88. switch (setup->wValue) {
  89. case HUB_PORT_FEATURE_SUSPEND:
  90. break;
  91. case HUB_PORT_FEATURE_POWER:
  92. break;
  93. case HUB_PORT_FEATURE_RESET:
  94. break;
  95. default:
  96. return -USB_ERR_NOTSUPP;
  97. }
  98. break;
  99. case HUB_REQUEST_GET_STATUS:
  100. if (!port || port > nports) {
  101. return -USB_ERR_INVAL;
  102. }
  103. memcpy(buf, &status, 4);
  104. break;
  105. default:
  106. break;
  107. }
  108. }
  109. return 0;
  110. }
  111. int usbh_submit_urb(struct usbh_urb *urb)
  112. {
  113. return -USB_ERR_NOTSUPP;
  114. }
  115. int usbh_kill_urb(struct usbh_urb *urb)
  116. {
  117. return -USB_ERR_NOTSUPP;
  118. }
  119. void USBH_IRQHandler(uint8_t busid)
  120. {
  121. }