usbh_rtl8152.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef USBH_RTL8152_H
  7. #define USBH_RTL8152_H
  8. struct usbh_rtl8152 {
  9. struct usbh_hubport *hport;
  10. struct usb_endpoint_descriptor *bulkin; /* Bulk IN endpoint */
  11. struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */
  12. struct usb_endpoint_descriptor *intin; /* INTR IN endpoint */
  13. struct usbh_urb bulkout_urb;
  14. struct usbh_urb bulkin_urb;
  15. struct usbh_urb intin_urb;
  16. uint8_t intf;
  17. uint8_t mac[6];
  18. bool connect_status;
  19. uint32_t speed[2];
  20. uint8_t version;
  21. uint8_t eee_adv;
  22. uint8_t eee_en;
  23. uint8_t supports_gmii;
  24. uint16_t min_mtu;
  25. uint16_t max_mtu;
  26. uint16_t ocp_base;
  27. uint32_t saved_wolopts;
  28. uint32_t rx_buf_sz;
  29. struct rtl_ops {
  30. void (*init)(struct usbh_rtl8152 *tp);
  31. int (*enable)(struct usbh_rtl8152 *tp);
  32. void (*disable)(struct usbh_rtl8152 *tp);
  33. void (*up)(struct usbh_rtl8152 *tp);
  34. void (*down)(struct usbh_rtl8152 *tp);
  35. void (*unload)(struct usbh_rtl8152 *tp);
  36. bool (*in_nway)(struct usbh_rtl8152 *tp);
  37. void (*hw_phy_cfg)(struct usbh_rtl8152 *tp);
  38. void (*autosuspend_en)(struct usbh_rtl8152 *tp, bool enable);
  39. void (*change_mtu)(struct usbh_rtl8152 *tp);
  40. } rtl_ops;
  41. void *user_data;
  42. };
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. int usbh_rtl8152_get_connect_status(struct usbh_rtl8152 *rtl8152_class);
  47. void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class);
  48. void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class);
  49. uint8_t *usbh_rtl8152_get_eth_txbuf(void);
  50. int usbh_rtl8152_eth_output(uint32_t buflen);
  51. void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen);
  52. void usbh_rtl8152_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV);
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif /* USBH_RTL8152_H */