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