Changeset b5111c46 in mainline
- Timestamp:
- 2014-07-23T21:38:25Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ffa96c2
- Parents:
- 87a3df7f
- Location:
- uspace/drv/bus/usb
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
r87a3df7f rb5111c46 193 193 instance->rh.address = 1; 194 194 rc = usb_device_manager_request_address( 195 &instance->generic .dev_manager, &instance->rh.address, false,195 &instance->generic->dev_manager, &instance->rh.address, false, 196 196 USB_SPEED_FULL); 197 197 if (rc != EOK) { … … 204 204 205 205 rc = usb_endpoint_manager_add_ep( 206 &instance->generic .ep_manager, instance->rh.address, 0,206 &instance->generic->ep_manager, instance->rh.address, 0, 207 207 USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 208 208 0, NULL, NULL); … … 231 231 fun_bound = true; 232 232 233 rc = usb_device_manager_bind_address(&instance->generic .dev_manager,233 rc = usb_device_manager_bind_address(&instance->generic->dev_manager, 234 234 instance->rh.address, ddf_fun_get_handle(hub_fun)); 235 235 if (rc != EOK) { … … 244 244 if (ep_added) { 245 245 usb_endpoint_manager_remove_ep( 246 &instance->generic .ep_manager, instance->rh.address, 0,246 &instance->generic->ep_manager, instance->rh.address, 0, 247 247 USB_DIRECTION_BOTH, NULL, NULL); 248 248 } 249 249 if (addr_reqd) { 250 250 usb_device_manager_release_address( 251 &instance->generic .dev_manager, instance->rh.address);251 &instance->generic->dev_manager, instance->rh.address); 252 252 } 253 253 return rc; … … 257 257 * 258 258 * @param[in] instance Memory place for the structure. 259 * @param[in] HC function node 259 260 * @param[in] regs Device's I/O registers range. 260 261 * @param[in] interrupts True if w interrupts should be used 261 262 * @return Error code 262 263 */ 263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)264 int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts) 264 265 { 265 266 assert(instance); … … 274 275 list_initialize(&instance->pending_batches); 275 276 276 hcd_init(&instance->generic, USB_SPEED_FULL, 277 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 278 if (instance->generic == NULL) { 279 usb_log_error("Out of memory.\n"); 280 return ENOMEM; 281 } 282 283 hcd_init(instance->generic, USB_SPEED_FULL, 277 284 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 278 instance->generic .private_data = instance;279 instance->generic .schedule = hc_schedule;280 instance->generic .ep_add_hook = ohci_endpoint_init;281 instance->generic .ep_remove_hook = ohci_endpoint_fini;285 instance->generic->private_data = instance; 286 instance->generic->schedule = hc_schedule; 287 instance->generic->ep_add_hook = ohci_endpoint_init; 288 instance->generic->ep_remove_hook = ohci_endpoint_fini; 282 289 283 290 rc = hc_init_memory(instance); -
uspace/drv/bus/usb/ohci/hc.h
r87a3df7f rb5111c46 35 35 #define DRV_OHCI_HC_H 36 36 37 #include <ddf/driver.h> 37 38 #include <ddf/interrupt.h> 38 39 #include <fibril.h> … … 53 54 typedef struct hc { 54 55 /** Generic USB hc driver */ 55 hcd_t generic;56 hcd_t *generic; 56 57 57 58 /** Memory mapped I/O registers area */ … … 79 80 int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int, 80 81 interrupt_handler_t); 81 int hc_register_hub(hc_t * instance, ddf_fun_t *hub_fun);82 int hc_init(hc_t * instance, addr_range_t *regs, bool interrupts);82 int hc_register_hub(hc_t *, ddf_fun_t *); 83 int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool); 83 84 84 85 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/ohci/ohci.c
r87a3df7f rb5111c46 34 34 */ 35 35 36 /* XXX Fix this */37 #define _DDF_DATA_IMPLANT38 39 36 #include <errno.h> 40 37 #include <str_error.h> … … 165 162 166 163 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 167 ddf_fun_data_implant(instance->hc_fun, &instance->hc);168 164 169 165 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh"); … … 214 210 } 215 211 216 rc = hc_init(&instance->hc, ®s, interrupts);212 rc = hc_init(&instance->hc, instance->hc_fun, ®s, interrupts); 217 213 if (rc != EOK) { 218 214 usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/uhci/hc.c
r87a3df7f rb5111c46 230 230 * 231 231 * @param[in] instance Memory place to initialize. 232 * @param[in] HC function node 232 233 * @param[in] regs Range of device's I/O control registers. 233 234 * @param[in] interrupts True if hw interrupts should be used. … … 238 239 * interrupt fibrils. 239 240 */ 240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)241 int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts) 241 242 { 242 243 assert(regs->size >= sizeof(uhci_regs_t)); … … 266 267 } 267 268 268 hcd_init(&instance->generic, USB_SPEED_FULL, 269 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 270 if (instance->generic == NULL) { 271 usb_log_error("Out of memory.\n"); 272 return ENOMEM; 273 } 274 275 hcd_init(instance->generic, USB_SPEED_FULL, 269 276 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 270 277 271 instance->generic .private_data = instance;272 instance->generic .schedule = hc_schedule;273 instance->generic .ep_add_hook = NULL;278 instance->generic->private_data = instance; 279 instance->generic->schedule = hc_schedule; 280 instance->generic->ep_add_hook = NULL; 274 281 275 282 hc_init_hw(instance); -
uspace/drv/bus/usb/uhci/hc.h
r87a3df7f rb5111c46 36 36 #define DRV_UHCI_HC_H 37 37 38 #include <ddf/driver.h> 38 39 #include <ddf/interrupt.h> 39 40 #include <device/hw_res_parsed.h> … … 93 94 typedef struct hc { 94 95 /** Generic HCD driver structure */ 95 hcd_t generic;96 hcd_t *generic; 96 97 97 98 /** Addresses of I/O registers */ … … 126 127 addr_range_t *); 127 128 void hc_interrupt(hc_t *instance, uint16_t status); 128 int hc_init(hc_t * instance, addr_range_t *regs, bool interupts);129 int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool); 129 130 130 131 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/uhci/uhci.c
r87a3df7f rb5111c46 34 34 */ 35 35 36 /* XXX Fix this */37 #define _DDF_DATA_IMPLANT38 39 36 #include <errno.h> 40 37 #include <stdbool.h> … … 62 59 hc_t hc; 63 60 /** Internal driver's representation of UHCI root hub */ 64 rh_t rh;61 rh_t *rh; 65 62 } uhci_t; 66 63 … … 186 183 187 184 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 188 ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);189 185 190 186 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); … … 196 192 197 193 ddf_fun_set_ops(instance->rh_fun, &rh_ops); 198 ddf_fun_data_implant(instance->rh_fun, &instance->rh);194 instance->rh = ddf_fun_data_alloc(instance->rh_fun, sizeof(rh_t)); 199 195 200 196 addr_range_t regs; … … 236 232 } 237 233 238 rc = hc_init(&instance->hc, ®s, interrupts);234 rc = hc_init(&instance->hc, instance->hc_fun, ®s, interrupts); 239 235 if (rc != EOK) { 240 236 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc)); … … 260 256 } 261 257 262 rc = rh_init( &instance->rh, instance->rh_fun, ®s, 0x10, 4);258 rc = rh_init(instance->rh, instance->rh_fun, ®s, 0x10, 4); 263 259 if (rc != EOK) { 264 260 usb_log_error("Failed to setup UHCI root hub: %s.\n",
Note:
See TracChangeset
for help on using the changeset viewer.