source: mainline/uspace/drv/uhci/uhci.c@ 18e35a7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 18e35a7 was 18e35a7, checked in by Jan Vesely <jano.vesely@…>, 15 years ago

root hub detection of devices works

TODO assign correct match ids before reporting
TODO communicate new address to the device

  • Property mode set to 100644
File size: 2.4 KB
Line 
1#include <errno.h>
2#include <usb/debug.h>
3#include <usb/usb.h>
4
5#include "name.h"
6#include "uhci.h"
7
8
9int uhci_init(device_t *device, void *regs)
10{
11 assert( device );
12 usb_dprintf(NAME, 1, "Initializing device at address %p\n", device);
13
14 /* create instance */
15 uhci_t *instance = malloc( sizeof(uhci_t) );
16 if (!instance)
17 { return ENOMEM; }
18 memset( instance, 0, sizeof(uhci_t) );
19
20 /* init address keeper(libusb) */
21 usb_address_keeping_init( &instance->address_manager, USB11_ADDRESS_MAX );
22
23 /* allow access to hc control registers */
24 regs_t *io;
25 int ret = pio_enable( regs, sizeof(regs_t), (void**)&io);
26 if (ret < 0) {
27 free( instance );
28 printf(NAME": Failed to gain access to registers at %p\n", io);
29 return ret;
30 }
31 instance->registers = io;
32
33 /* init root hub */
34 ret = uhci_root_hub_init( &instance->root_hub, device,
35 (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET );
36 if (ret < 0) {
37 free( instance );
38 printf(NAME": Failed to initialize root hub driver.\n");
39 return ret;
40 }
41
42 device->driver_data = instance;
43 return EOK;
44}
45/*----------------------------------------------------------------------------*/
46int uhci_in(
47 device_t *dev,
48 usb_target_t target,
49 usb_transfer_type_t transfer_type,
50 void *buffer, size_t size,
51 usbhc_iface_transfer_in_callback_t callback, void *arg
52 )
53{
54 usb_dprintf(NAME, 1, "transfer IN [%d.%d (%s); %zu]\n",
55 target.address, target.endpoint,
56 usb_str_transfer_type(transfer_type),
57 size);
58
59 return ENOTSUP;
60}
61/*----------------------------------------------------------------------------*/
62int uhci_out(
63 device_t *dev,
64 usb_target_t target,
65 usb_transfer_type_t transfer_type,
66 void *buffer, size_t size,
67 usbhc_iface_transfer_out_callback_t callback, void *arg
68 )
69{
70 usb_dprintf(NAME, 1, "transfer OUT [%d.%d (%s); %zu]\n",
71 target.address, target.endpoint,
72 usb_str_transfer_type(transfer_type),
73 size);
74
75 return ENOTSUP;
76}
77/*----------------------------------------------------------------------------*/
78int uhci_setup(
79 device_t *dev,
80 usb_target_t target,
81 usb_transfer_type_t transfer_type,
82 void *buffer, size_t size,
83 usbhc_iface_transfer_out_callback_t callback, void *arg
84 )
85{
86 usb_dprintf(NAME, 1, "transfer SETUP [%d.%d (%s); %zu]\n",
87 target.address, target.endpoint,
88 usb_str_transfer_type(transfer_type),
89 size);
90
91 return ENOTSUP;
92}
93/*----------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.