Add stubs for USB OHCI support.
[seabios.git] / src / usb-ohci.c
1 // Code for handling OHCI USB controllers.
2 //
3 // Copyright (C) 2009  Kevin O'Connor <kevin@koconnor.net>
4 //
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
6
7 #include "util.h" // dprintf
8 #include "pci.h" // pci_bdf_to_bus
9 #include "config.h" // CONFIG_*
10 #include "ioport.h" // outw
11 #include "usb-ohci.h" // USBLEGSUP
12 #include "pci_regs.h" // PCI_BASE_ADDRESS_4
13 #include "usb.h" // struct usb_s
14 #include "farptr.h" // GET_FLATPTR
15 #include "biosvar.h" // GET_GLOBAL
16
17 static void
18 reset_ohci(struct usb_s *cntl)
19 {
20 }
21
22 static void
23 configure_ohci(struct usb_s *cntl)
24 {
25     // XXX - check for SMM control?
26
27     writel(&cntl->ohci.regs->intrdisable, OHCI_INTR_MIE);
28
29     struct ohci_hcca *hcca = memalign_low(256, sizeof(*hcca));
30     if (!hcca) {
31         dprintf(1, "No ram for ohci init\n");
32         return;
33     }
34
35     
36 }
37
38 static void
39 start_ohci(struct usb_s *cntl)
40 {
41 }
42
43 // Find any devices connected to the root hub.
44 static int
45 check_ohci_ports(struct usb_s *cntl)
46 {
47     return 0;
48 }
49
50 int
51 ohci_init(struct usb_s *cntl)
52 {
53     if (! CONFIG_USB_OHCI)
54         return 0;
55
56     cntl->type = USB_TYPE_OHCI;
57     u32 baseaddr = pci_config_readl(cntl->bdf, PCI_BASE_ADDRESS_0);
58     cntl->ohci.regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
59
60     dprintf(3, "OHCI init on dev %02x:%02x.%x (regs=%p)\n"
61             , pci_bdf_to_bus(cntl->bdf), pci_bdf_to_dev(cntl->bdf)
62             , pci_bdf_to_fn(cntl->bdf), cntl->ohci.regs);
63
64     // Enable bus mastering and memory access.
65     pci_config_maskw(cntl->bdf, PCI_COMMAND
66                      , 0, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY);
67
68     reset_ohci(cntl);
69     configure_ohci(cntl);
70     start_ohci(cntl);
71
72     int count = check_ohci_ports(cntl);
73     if (! count) {
74         // XXX - no devices; free data structures.
75         return 0;
76     }
77
78     return 0;
79 }
80
81 int
82 ohci_control(u32 endp, int dir, const void *cmd, int cmdsize
83              , void *data, int datasize)
84 {
85     if (! CONFIG_USB_OHCI)
86         return 0;
87
88     dprintf(5, "ohci_control %x\n", endp);
89     return 0;
90 }
91
92 struct usb_pipe *
93 ohci_alloc_intr_pipe(u32 endp, int period)
94 {
95     if (! CONFIG_USB_OHCI)
96         return NULL;
97
98     dprintf(7, "ohci_alloc_intr_pipe %x %d\n", endp, period);
99     return NULL;
100 }
101
102 int
103 ohci_poll_intr(void *pipe, void *data)
104 {
105     ASSERT16();
106     if (! CONFIG_USB_OHCI)
107         return -1;
108     return -1;
109 }