Changeset 6832245 in mainline for uspace/drv/bus/usb/ehci
- Timestamp:
- 2017-12-14T23:01:57Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 837d53d
- Parents:
- bd05140
- git-author:
- Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:54)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:57)
- Location:
- uspace/drv/bus/usb/ehci
- Files:
- 
      - 5 edited
 
 - 
          
  ehci_bus.c (modified) (6 diffs)
- 
          
  ehci_bus.h (modified) (1 diff)
- 
          
  hc.c (modified) (2 diffs)
- 
          
  hc.h (modified) (1 diff)
- 
          
  main.c (modified) (1 diff)
 
Legend:
- Unmodified
- Added
- Removed
- 
      uspace/drv/bus/usb/ehci/ehci_bus.crbd05140 r6832245 79 79 /** Creates new hcd endpoint representation. 80 80 */ 81 static endpoint_t *ehci_endpoint_create( bus_t *bus)81 static endpoint_t *ehci_endpoint_create(device_t *dev, const usb_endpoint_desc_t *desc) 82 82 { 83 assert( bus);83 assert(dev); 84 84 85 85 ehci_endpoint_t *ehci_ep = malloc(sizeof(ehci_endpoint_t)); … … 87 87 return NULL; 88 88 89 endpoint_init(&ehci_ep->base, bus); 89 endpoint_init(&ehci_ep->base, dev, desc); 90 91 // TODO: extract USB2 information from desc 90 92 91 93 ehci_ep->qh = malloc32(sizeof(qh_t)); … … 114 116 115 117 116 static int ehci_register_ep( bus_t *bus_base, device_t *dev, endpoint_t *ep, const usb_endpoint_desc_t *desc)118 static int ehci_register_ep(endpoint_t *ep) 117 119 { 120 bus_t *bus_base = endpoint_get_bus(ep); 118 121 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 119 122 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 123 assert(fibril_mutex_is_locked(&bus_base->guard)); 120 124 121 // TODO utilize desc->usb2 122 123 const int err = bus->parent_ops.register_endpoint(bus_base, dev, ep, desc); 125 const int err = usb2_bus_ops.endpoint_register(ep); 124 126 if (err) 125 127 return err; … … 131 133 } 132 134 133 static int ehci_unregister_ep( bus_t *bus_base,endpoint_t *ep)135 static int ehci_unregister_ep(endpoint_t *ep) 134 136 { 137 bus_t *bus_base = endpoint_get_bus(ep); 135 138 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 136 139 assert(bus); 137 140 assert(ep); 138 141 139 const int err = bus->parent_ops.unregister_endpoint(bus_base,ep);142 const int err = usb2_bus_ops.endpoint_unregister(ep); 140 143 if (err) 141 144 return err; … … 145 148 } 146 149 147 static usb_transfer_batch_t *ehci_ bus_create_batch(bus_t *bus,endpoint_t *ep)150 static usb_transfer_batch_t *ehci_create_batch(endpoint_t *ep) 148 151 { 149 152 ehci_transfer_batch_t *batch = ehci_transfer_batch_create(ep); … … 151 154 } 152 155 153 static void ehci_ bus_destroy_batch(usb_transfer_batch_t *batch)156 static void ehci_destroy_batch(usb_transfer_batch_t *batch) 154 157 { 155 158 ehci_transfer_batch_destroy(ehci_transfer_batch_get(batch)); 156 159 } 157 160 158 int ehci_bus_init(ehci_bus_t *bus, hc_t *hc) 161 static const bus_ops_t ehci_bus_ops = { 162 .parent = &usb2_bus_ops, 163 164 .endpoint_destroy = ehci_endpoint_destroy, 165 .endpoint_create = ehci_endpoint_create, 166 .endpoint_register = ehci_register_ep, 167 .endpoint_unregister = ehci_unregister_ep, 168 .endpoint_set_toggle = ehci_ep_toggle_set, 169 .endpoint_get_toggle = ehci_ep_toggle_get, 170 .endpoint_count_bw = bandwidth_count_usb11, 171 .batch_create = ehci_create_batch, 172 .batch_destroy = ehci_destroy_batch, 173 }; 174 175 int ehci_bus_init(ehci_bus_t *bus, hcd_t *hcd, hc_t *hc) 159 176 { 160 177 assert(hc); 161 178 assert(bus); 162 179 163 // FIXME: Implement the USB2 bw counting.164 usb2_bus_init(&bus->base, BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);180 usb2_bus_t *usb2_bus = (usb2_bus_t *) bus; 181 bus_t *bus_base = (bus_t *) bus; 165 182 166 bus_ops_t *ops = &bus->base.base.ops; 167 bus->parent_ops = *ops; 168 ops->create_endpoint = ehci_endpoint_create; 169 ops->destroy_endpoint = ehci_endpoint_destroy; 170 ops->endpoint_set_toggle = ehci_ep_toggle_set; 171 ops->endpoint_get_toggle = ehci_ep_toggle_get; 172 173 ops->register_endpoint = ehci_register_ep; 174 ops->unregister_endpoint = ehci_unregister_ep; 175 176 ops->create_batch = ehci_bus_create_batch; 177 ops->destroy_batch = ehci_bus_destroy_batch; 183 usb2_bus_init(usb2_bus, hcd, BANDWIDTH_AVAILABLE_USB11); 184 bus_base->ops = &ehci_bus_ops; 178 185 179 186 bus->hc = hc; 
- 
      uspace/drv/bus/usb/ehci/ehci_bus.hrbd05140 r6832245 59 59 usb2_bus_t base; 60 60 hc_t *hc; 61 62 /* Stored original ops from base, they are called in our handlers */63 bus_ops_t parent_ops;64 61 } ehci_bus_t; 65 62 66 int ehci_bus_init(ehci_bus_t *, hc_t *); 63 void ehci_bus_prepare_ops(void); 64 65 int ehci_bus_init(ehci_bus_t *, hcd_t *, hc_t *); 67 66 68 67 /** Get and convert assigned ehci_endpoint_t structure 
- 
      uspace/drv/bus/usb/ehci/hc.crbd05140 r6832245 149 149 * @return Error code 150 150 */ 151 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res)151 int hc_init(hc_t *instance, hcd_t *hcd, const hw_res_list_parsed_t *hw_res) 152 152 { 153 153 assert(instance); … … 190 190 &instance->rh, instance->caps, instance->registers, "ehci rh"); 191 191 192 ehci_bus_init(&instance->bus, instance);192 ehci_bus_init(&instance->bus, hcd, instance); 193 193 return EOK; 194 194 } 
- 
      uspace/drv/bus/usb/ehci/hc.hrbd05140 r6832245 85 85 } hc_t; 86 86 87 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res);87 int hc_init(hc_t *instance, hcd_t *hcd, const hw_res_list_parsed_t *hw_res); 88 88 int hc_start(hc_t *instance, bool interrupts); 89 89 void hc_fini(hc_t *instance); 
- 
      uspace/drv/bus/usb/ehci/main.crbd05140 r6832245 81 81 return ENOMEM; 82 82 83 const int ret = hc_init(instance, res);83 const int ret = hc_init(instance, hcd, res); 84 84 if (ret == EOK) { 85 85 hcd_set_implementation(hcd, instance, &ehci_hc_driver.ops, &instance->bus.base.base); 
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  
