Changeset 6cbe7dad in mainline
- Timestamp:
- 2011-02-25T15:58:25Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6495e71
- Parents:
- e9e58ea3
- Location:
- uspace/drv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/uhci-hcd/root_hub.c ¶
re9e58ea3 r6cbe7dad 35 35 #include <errno.h> 36 36 #include <stdio.h> 37 #include <ops/hw_res.h> 38 37 39 #include <usb_iface.h> 38 40 #include <usb/debug.h> … … 41 43 #include "uhci.h" 42 44 45 /*----------------------------------------------------------------------------*/ 43 46 static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun, 44 47 devman_handle_t *handle) … … 51 54 return EOK; 52 55 } 53 56 /*----------------------------------------------------------------------------*/ 54 57 static int usb_iface_get_address_rh_impl(ddf_fun_t *fun, devman_handle_t handle, 55 58 usb_address_t *address) … … 73 76 return EOK; 74 77 } 75 78 /*----------------------------------------------------------------------------*/ 76 79 usb_iface_t usb_iface_root_hub_fun_impl = { 77 80 .get_hc_handle = usb_iface_get_hc_handle_rh_impl, 78 81 .get_address = usb_iface_get_address_rh_impl 79 82 }; 83 /*----------------------------------------------------------------------------*/ 84 static hw_resource_list_t *get_resource_list(ddf_fun_t *dev) 85 { 86 assert(dev); 87 ddf_fun_t *hc_ddf_instance = dev->driver_data; 88 assert(hc_ddf_instance); 89 uhci_t *hc = hc_ddf_instance->driver_data; 90 assert(hc); 80 91 92 //TODO: fix memory leak 93 hw_resource_list_t *resource_list = malloc(sizeof(hw_resource_list_t)); 94 assert(resource_list); 95 resource_list->count = 1; 96 resource_list->resources = malloc(sizeof(hw_resource_t)); 97 assert(resource_list->resources); 98 resource_list->resources[0].type = IO_RANGE; 99 resource_list->resources[0].res.io_range.address = 100 ((uintptr_t)hc->registers) + 0x10; // see UHCI design guide 101 resource_list->resources[0].res.io_range.size = 4; 102 resource_list->resources[0].res.io_range.endianness = LITTLE_ENDIAN; 103 104 return resource_list; 105 } 106 /*----------------------------------------------------------------------------*/ 107 static hw_res_ops_t hw_res_iface = { 108 .get_resource_list = get_resource_list, 109 .enable_interrupt = NULL 110 }; 111 /*----------------------------------------------------------------------------*/ 81 112 static ddf_dev_ops_t root_hub_ops = { 82 .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl 113 .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl, 114 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface 83 115 }; 84 85 116 /*----------------------------------------------------------------------------*/ 86 117 int setup_root_hub(ddf_fun_t **fun, ddf_dev_t *hc) -
TabularUnified uspace/drv/uhci-hcd/uhci.c ¶
re9e58ea3 r6cbe7dad 61 61 }; 62 62 63 63 64 static int usb_iface_get_address(ddf_fun_t *fun, devman_handle_t handle, 64 65 usb_address_t *address) … … 80 81 return EOK; 81 82 } 82 83 83 /*----------------------------------------------------------------------------*/ 84 84 static usb_iface_t hc_usb_iface = { 85 85 .get_hc_handle = usb_iface_get_hc_handle_hc_impl, … … 89 89 static ddf_dev_ops_t uhci_ops = { 90 90 .interfaces[USB_DEV_IFACE] = &hc_usb_iface, 91 .interfaces[USBHC_DEV_IFACE] = &uhci_iface 91 .interfaces[USBHC_DEV_IFACE] = &uhci_iface, 92 92 }; 93 93 -
TabularUnified uspace/drv/uhci-rhd/main.c ¶
re9e58ea3 r6cbe7dad 33 33 */ 34 34 #include <ddf/driver.h> 35 #include <devman.h> 36 #include <device/hw_res.h> 35 37 #include <usb_iface.h> 36 38 #include <usb/ddfiface.h> … … 43 45 44 46 #define NAME "uhci-rhd" 47 static int hc_get_my_registers(ddf_dev_t *dev, 48 uintptr_t *io_reg_address, size_t *io_reg_size); 45 49 46 50 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) … … 80 84 } 81 85 82 /* TODO: get register values from hc */ 83 int ret = uhci_root_hub_init(rh, (void*)0xc030, 4, device); 86 uintptr_t io_regs = 0; 87 size_t io_size = 0; 88 89 int ret = hc_get_my_registers(device, &io_regs, &io_size); 90 assert(ret == EOK); 91 92 /* TODO: verify values from hc */ 93 usb_log_info("I/O regs at 0x%X (size %zu).\n", io_regs, io_size); 94 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 84 95 if (ret != EOK) { 85 96 usb_log_error("Failed(%d) to initialize driver instance.\n", ret); … … 102 113 .driver_ops = &uhci_rh_driver_ops 103 114 }; 104 115 /*----------------------------------------------------------------------------*/ 105 116 int main(int argc, char *argv[]) 106 117 { … … 108 119 return ddf_driver_main(&uhci_rh_driver); 109 120 } 121 /*----------------------------------------------------------------------------*/ 122 int hc_get_my_registers(ddf_dev_t *dev, 123 uintptr_t *io_reg_address, size_t *io_reg_size) 124 { 125 assert(dev != NULL); 126 127 int parent_phone = devman_parent_device_connect(dev->handle, 128 IPC_FLAG_BLOCKING); 129 if (parent_phone < 0) { 130 return parent_phone; 131 } 132 133 int rc; 134 135 hw_resource_list_t hw_resources; 136 rc = hw_res_get_resource_list(parent_phone, &hw_resources); 137 if (rc != EOK) { 138 goto leave; 139 } 140 141 uintptr_t io_address = 0; 142 size_t io_size = 0; 143 bool io_found = false; 144 145 size_t i; 146 for (i = 0; i < hw_resources.count; i++) { 147 hw_resource_t *res = &hw_resources.resources[i]; 148 switch (res->type) { 149 case IO_RANGE: 150 io_address = (uintptr_t) 151 res->res.io_range.address; 152 io_size = res->res.io_range.size; 153 io_found = true; 154 break; 155 default: 156 break; 157 } 158 } 159 160 if (!io_found) { 161 rc = ENOENT; 162 goto leave; 163 } 164 165 if (io_reg_address != NULL) { 166 *io_reg_address = io_address; 167 } 168 if (io_reg_size != NULL) { 169 *io_reg_size = io_size; 170 } 171 rc = EOK; 172 leave: 173 async_hangup(parent_phone); 174 175 return rc; 176 } 110 177 /** 111 178 * @} -
TabularUnified uspace/drv/uhci-rhd/root_hub.c ¶
re9e58ea3 r6cbe7dad 39 39 40 40 #include "root_hub.h" 41 42 41 43 42 int uhci_root_hub_init(
Note:
See TracChangeset
for help on using the changeset viewer.