usb_glue_intel.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifdef __rtems__
  2. #include <rtems.h>
  3. #include <rtems/pci.h>
  4. #include <bsp/irq.h>
  5. #include "usbh_core.h"
  6. uint32_t echi_base;
  7. static int ehci_bus;
  8. static int ehci_slot;
  9. static int ehci_function;
  10. static int ehci_vector;
  11. extern void USBH_IRQHandler(uint8_t busid);
  12. void ehci_pci_scan(int bus, int slot, int fun, int vector)
  13. {
  14. ehci_bus = bus;
  15. ehci_slot = slot;
  16. ehci_function = fun;
  17. ehci_vector = vector;
  18. pci_read_config_dword(bus, slot, fun, PCI_BASE_ADDRESS_0, &echi_base);
  19. }
  20. void usb_hc_low_level_init(struct usbh_bus *bus)
  21. {
  22. //set software own ehci
  23. uint32_t legacy_val;
  24. pci_write_config_dword(ehci_bus, ehci_slot, ehci_function, 0x68, 1 << 24);
  25. pci_read_config_dword(ehci_bus, ehci_slot, ehci_function, 0x68, &legacy_val);
  26. if ((legacy_val & 0x01010000) == 0x01000000)
  27. printf("OS owned echi\n");
  28. else
  29. printf("BIOS owned echi\n");
  30. rtems_status_code sc;
  31. sc = rtems_interrupt_handler_install(
  32. ehci_vector,
  33. "USBirq",
  34. RTEMS_INTERRUPT_SHARED,
  35. USBH_IRQHandler,
  36. (void *)0);
  37. if (sc != RTEMS_SUCCESSFUL) {
  38. printf("USB install isr falied,%s\n", rtems_status_text(sc));
  39. return;
  40. }
  41. }
  42. uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
  43. {
  44. printf("USB_SPEED_HIGH present\n");
  45. return USB_SPEED_HIGH;
  46. }
  47. #endif