usb_hc_ohci.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _USB_OHCI_PRIV_H
  7. #define _USB_OHCI_PRIV_H
  8. #include "usbh_core.h"
  9. #include "usbh_hub.h"
  10. #include "usb_ohci_reg.h"
  11. #define OHCI_HCOR ((struct ohci_hcor *)(uintptr_t)(bus->hcd.reg_base + CONFIG_USB_OHCI_HCOR_OFFSET))
  12. #define OHCI_PTR2ADDR(x) ((uint32_t)(uintptr_t)(x) & ~0x0F)
  13. #define OHCI_ADDR2ED(x) ((struct ohci_ed_hw *)(uintptr_t)((uint32_t)(x) & ~0x0F))
  14. #define OHCI_ADDR2TD(x) ((struct ohci_td_hw *)(uintptr_t)((uint32_t)(x) & ~0x0F))
  15. #ifndef CONFIG_USB_OHCI_ED_NUM
  16. #define CONFIG_USB_OHCI_ED_NUM CONFIG_USBHOST_PIPE_NUM
  17. #endif
  18. #ifndef CONFIG_USB_OHCI_TD_NUM
  19. #define CONFIG_USB_OHCI_TD_NUM 3
  20. #endif
  21. struct ohci_ed_hw;
  22. struct ohci_td_hw {
  23. struct ohci_gtd hw;
  24. struct usbh_urb *urb;
  25. uint32_t buf_start;
  26. uint32_t length;
  27. } __attribute__((aligned(32))); /* min is 16bytes, we use 32 for cacheline */
  28. struct ohci_ed_hw {
  29. struct ohci_ed hw;
  30. struct ohci_td_hw td_pool[CONFIG_USB_OHCI_TD_NUM];
  31. uint32_t td_count;
  32. uint8_t ed_type;
  33. usb_osal_sem_t waitsem;
  34. } __attribute__((aligned(32))); /* min is 16bytes, we use 32 for cacheline */
  35. struct ohci_hcd {
  36. bool ohci_ed_used[CONFIG_USB_OHCI_ED_NUM];
  37. uint8_t n_ports;
  38. };
  39. int ohci_init(struct usbh_bus *bus);
  40. int ohci_deinit(struct usbh_bus *bus);
  41. uint16_t ohci_get_frame_number(struct usbh_bus *bus);
  42. int ohci_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, uint8_t *buf);
  43. int ohci_submit_urb(struct usbh_urb *urb);
  44. int ohci_kill_urb(struct usbh_urb *urb);
  45. void OHCI_IRQHandler(uint8_t busid);
  46. #endif