usb_glue_sunxi.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usb_config.h"
  7. #include "stdint.h"
  8. #include "usb_musb_reg.h"
  9. #ifndef CONFIG_USB_MUSB_SUNXI
  10. #error must define CONFIG_USB_MUSB_SUNXI when use sunxi chips
  11. #endif
  12. #if CONFIG_USBDEV_EP_NUM != 4
  13. #error sunxi chips only support 4 endpoints
  14. #endif
  15. #if CONFIG_USBHOST_PIPE_NUM != 4
  16. #error sunxi chips only support 4 pipes
  17. #endif
  18. // clang-format off
  19. static struct musb_fifo_cfg musb_device_table[] = {
  20. { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
  21. { .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
  22. { .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
  23. { .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
  24. { .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
  25. { .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
  26. { .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
  27. };
  28. static struct musb_fifo_cfg musb_host_table[] = {
  29. { .ep_num = 0, .style = FIFO_TXRX, .maxpacket = 64, },
  30. { .ep_num = 1, .style = FIFO_TX, .maxpacket = 1024, },
  31. { .ep_num = 1, .style = FIFO_RX, .maxpacket = 1024, },
  32. { .ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
  33. { .ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
  34. { .ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
  35. { .ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
  36. };
  37. // clang-format on
  38. uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
  39. {
  40. *cfg = musb_device_table;
  41. return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
  42. }
  43. uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
  44. {
  45. *cfg = musb_host_table;
  46. return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
  47. }
  48. uint32_t usb_get_musb_ram_size(void)
  49. {
  50. return 8192;
  51. }
  52. void usbd_musb_delay_ms(uint8_t ms)
  53. {
  54. /* implement later */
  55. }