30 #include <linux/slab.h>
31 #include <linux/export.h>
33 #include <asm/unaligned.h>
43 #define OZ_IN_BUFFERING_UNITS 50
46 #define OZ_PLAT_DEV_NAME "ozwpan"
49 #define OZ_MAX_LINK_POOL_SIZE 16
52 #define ep_from_link(__e) container_of((__e), struct oz_endpoint, link)
87 #define OZ_F_EP_BUFFERING 0x1
88 #define OZ_F_EP_HAVE_STREAM 0x2
99 #define OZ_NB_ENDPOINTS 16
116 #define OZ_PORT_F_PRESENT 0x1
117 #define OZ_PORT_F_CHANGED 0x2
118 #define OZ_PORT_F_DYING 0x4
122 #define OZ_NB_PORTS 8
135 #define OZ_HDC_F_SUSPENDED 0x1
140 static int oz_hcd_start(
struct usb_hcd *hcd);
141 static void oz_hcd_stop(
struct usb_hcd *hcd);
142 static void oz_hcd_shutdown(
struct usb_hcd *hcd);
143 static int oz_hcd_urb_enqueue(
struct usb_hcd *hcd,
struct urb *
urb,
145 static int oz_hcd_urb_dequeue(
struct usb_hcd *hcd,
struct urb *
urb,
int status);
146 static void oz_hcd_endpoint_disable(
struct usb_hcd *hcd,
147 struct usb_host_endpoint *ep);
148 static void oz_hcd_endpoint_reset(
struct usb_hcd *hcd,
149 struct usb_host_endpoint *ep);
150 static int oz_hcd_get_frame_number(
struct usb_hcd *hcd);
151 static int oz_hcd_hub_status_data(
struct usb_hcd *hcd,
char *
buf);
152 static int oz_hcd_hub_control(
struct usb_hcd *hcd,
u16 req_type,
u16 wvalue,
154 static int oz_hcd_bus_suspend(
struct usb_hcd *hcd);
155 static int oz_hcd_bus_resume(
struct usb_hcd *hcd);
161 static void oz_urb_process_tasklet(
unsigned long unused);
162 static int oz_build_endpoints_for_config(
struct usb_hcd *hcd,
165 static void oz_clean_endpoints_for_config(
struct usb_hcd *hcd,
167 static int oz_build_endpoints_for_interface(
struct usb_hcd *hcd,
169 struct usb_host_interface *
intf,
gfp_t mem_flags);
170 static void oz_clean_endpoints_for_interface(
struct usb_hcd *hcd,
172 static void oz_process_ep0_urb(
struct oz_hcd *ozhcd,
struct urb *
urb,
176 static void oz_hcd_clear_orphanage(
struct oz_hcd *ozhcd,
int status);
181 static struct oz_hcd *g_ozhcd;
183 static const char g_hcd_name[] =
"Ozmo WPAN";
185 static int g_link_pool_size;
191 static const struct hc_driver g_oz_hc_drv = {
192 .description = g_hcd_name,
193 .product_desc =
"Ozmo Devices WPAN",
194 .hcd_priv_size =
sizeof(
struct oz_hcd),
196 .start = oz_hcd_start,
198 .shutdown = oz_hcd_shutdown,
199 .urb_enqueue = oz_hcd_urb_enqueue,
200 .urb_dequeue = oz_hcd_urb_dequeue,
201 .endpoint_disable = oz_hcd_endpoint_disable,
202 .endpoint_reset = oz_hcd_endpoint_reset,
203 .get_frame_number = oz_hcd_get_frame_number,
204 .hub_status_data = oz_hcd_hub_status_data,
205 .hub_control = oz_hcd_hub_control,
206 .bus_suspend = oz_hcd_bus_suspend,
207 .bus_resume = oz_hcd_bus_resume,
211 .probe = oz_plat_probe,
212 .remove = oz_plat_remove,
213 .shutdown = oz_plat_shutdown,
214 .suspend = oz_plat_suspend,
215 .resume = oz_plat_resume,
226 static inline struct oz_hcd *oz_hcd_private(
struct usb_hcd *
hcd)
228 return (
struct oz_hcd *)hcd->hcd_priv;
236 static int oz_get_port_from_addr(
struct oz_hcd *ozhcd,
u8 bus_addr)
240 if (ozhcd->
ports[i].bus_addr == bus_addr)
256 g_link_pool = urbl->
link.next;
259 spin_unlock_irqrestore(&g_link_lock, irq_state);
269 static void oz_free_urb_link(
struct oz_urb_link *urbl)
275 urbl->
link.next = g_link_pool;
276 g_link_pool = &urbl->
link;
280 spin_unlock_irqrestore(&g_link_lock, irq_state);
289 static void oz_empty_link_pool(
void)
296 g_link_pool_size = 0;
297 spin_unlock_irqrestore(&g_link_lock, irq_state);
313 kzalloc(
sizeof(
struct oz_endpoint)+buffer_size, mem_flags);
316 INIT_LIST_HEAD(&ep->
link);
336 if (urb == urbl->
urb) {
348 static void oz_complete_urb(
struct usb_hcd *hcd,
struct urb *
urb,
349 int status,
unsigned long submit_jiffies)
351 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
373 spin_unlock(&g_tasklet_lock);
375 oz_trace(
"OZWPAN: ERROR Unknown URB %p\n", urb);
380 "%lu: giveback_urb(%p,%x) %lu %lu pending:%d\n",
381 jiffies, urb, status, jiffies-submit_jiffies,
387 spin_lock(&g_tasklet_lock);
388 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
390 oz_free_urb_link(cancel_urbl);
403 INIT_LIST_HEAD(&
list);
414 oz_trace(
"Freeing endpoint memory\n");
426 if (data_len <= urb->transfer_buffer_length)
429 available_space = urb->transfer_buffer_length;
434 if (copy_len >= available_space)
435 copy_len = available_space;
438 if (copy_len < available_space) {
440 (available_space - copy_len));
441 ep->
out_ix = available_space - copy_len;
445 urb->actual_length = available_space;
450 oz_trace(
"Trying to give back buffered frame of size=%d\n",
452 oz_complete_urb(port->
ozhcd->hcd, urb, 0, 0);
458 static int oz_enqueue_ep_urb(
struct oz_port *port,
u8 ep_addr,
int in_dir,
465 oz_trace(
"Invalid endpoint number in oz_enqueue_ep_urb().\n");
468 urbl = oz_alloc_urb_link();
478 spin_lock_bh(&port->
ozhcd->hcd_lock);
483 spin_unlock_bh(&port->
ozhcd->hcd_lock);
484 oz_trace(
"urb %p unlinked so complete immediately\n", urb);
485 oz_complete_urb(port->
ozhcd->hcd, urb, 0, 0);
486 oz_free_urb_link(urbl);
490 ep = port->
in_ep[ep_addr];
492 ep = port->
out_ep[ep_addr];
499 oz_free_urb_link(urbl);
500 spin_unlock_bh(&port->
ozhcd->hcd_lock);
505 if (ep && port->
hpd) {
507 if (!in_dir && ep_addr && (ep->
credit < 0)) {
516 spin_unlock_bh(&port->
ozhcd->hcd_lock);
518 oz_free_urb_link(urbl);
526 static int oz_dequeue_ep_urb(
struct oz_port *port,
u8 ep_addr,
int in_dir,
531 spin_lock_bh(&port->
ozhcd->hcd_lock);
533 ep = port->
in_ep[ep_addr];
535 ep = port->
out_ep[ep_addr];
540 if (urbl->
urb == urb) {
547 spin_unlock_bh(&port->
ozhcd->hcd_lock);
549 oz_free_urb_link(urbl);
550 return urbl ? 0 : -
EIDRM;
556 static struct urb *oz_find_urb_by_id(
struct oz_port *port,
int ep_ix,
570 if (urbl->
req_id == req_id) {
581 oz_free_urb_link(urbl);
588 static void oz_acquire_port(
struct oz_port *port,
void *hpd)
601 static struct oz_hcd *oz_hcd_claim(
void)
604 spin_lock_bh(&g_hcdlock);
608 spin_unlock_bh(&g_hcdlock);
614 static inline void oz_hcd_put(
struct oz_hcd *ozhcd)
638 ozhcd = oz_hcd_claim();
655 oz_acquire_port(port, hpd);
661 if (i < OZ_NB_PORTS) {
662 oz_trace(
"Setting conn_port = %d\n", i);
666 ozhcd->
ports[
i].out_ep[0] = ep;
672 usb_hcd_resume_root_hub(ozhcd->
hcd);
699 oz_trace(
"oz_hcd_pd_departed() port = 0\n");
718 oz_clean_endpoints_for_config(ozhcd->
hcd, port);
736 oz_ep_free(port, ep);
755 oz_clean_endpoints_for_config(ozhcd->
hcd, port);
769 oz_trace(
"oz_hcd_get_desc_cnf length = %d offs = %d tot_size = %d\n",
770 length, offset, total_size);
771 urb = oz_find_urb_by_id(port, 0, req_id);
776 int required_size = urb->transfer_buffer_length;
777 if (required_size > total_size)
779 copy_len = required_size-
offset;
780 if (length <= copy_len)
782 memcpy(urb->transfer_buffer+offset, desc, copy_len);
784 if (offset < required_size) {
788 if (oz_enqueue_ep_urb(port, 0, 0, urb, req_id))
793 required_size-offset)) {
794 oz_dequeue_ep_urb(port, 0, 0, urb);
802 oz_complete_urb(port->
ozhcd->hcd, urb, 0, 0);
812 oz_trace(
"USB_REQ_GET_STATUS - cnf\n");
815 oz_trace(
"USB_REQ_CLEAR_FEATURE - cnf\n");
818 oz_trace(
"USB_REQ_SET_FEATURE - cnf\n");
821 oz_trace(
"USB_REQ_SET_ADDRESS - cnf\n");
824 oz_trace(
"USB_REQ_GET_DESCRIPTOR - cnf\n");
827 oz_trace(
"USB_REQ_SET_DESCRIPTOR - cnf\n");
830 oz_trace(
"USB_REQ_GET_CONFIGURATION - cnf\n");
833 oz_trace(
"USB_REQ_SET_CONFIGURATION - cnf\n");
836 oz_trace(
"USB_REQ_GET_INTERFACE - cnf\n");
839 oz_trace(
"USB_REQ_SET_INTERFACE - cnf\n");
842 oz_trace(
"USB_REQ_SYNCH_FRAME - cnf\n");
847 #define oz_display_conf_type(__x)
852 static void oz_hcd_complete_set_config(
struct oz_port *port,
struct urb *urb,
853 u8 rcode,
u8 config_num)
856 struct usb_hcd *hcd = port->
ozhcd->hcd;
859 oz_clean_endpoints_for_config(hcd, port);
860 if (oz_build_endpoints_for_config(hcd, port,
867 oz_complete_urb(hcd, urb, rc, 0);
872 static void oz_hcd_complete_set_interface(
struct oz_port *port,
struct urb *urb,
873 u8 rcode,
u8 if_num,
u8 alt)
875 struct usb_hcd *hcd = port->
ozhcd->hcd;
878 struct usb_host_config *
config;
879 struct usb_host_interface *
intf;
880 oz_trace(
"Set interface %d alt %d\n", if_num, alt);
881 oz_clean_endpoints_for_interface(hcd, port, if_num);
882 config = &urb->dev->config[port->
config_num-1];
883 intf = &config->intf_cache[if_num]->altsetting[alt];
884 if (oz_build_endpoints_for_interface(hcd, port, intf,
888 port->
iface[if_num].alt = alt;
892 oz_complete_urb(hcd, urb, rc, 0);
903 struct usb_hcd *hcd = port->
ozhcd->hcd;
908 oz_trace(
"oz_hcd_control_cnf rcode=%u len=%d\n", rcode, data_len);
909 urb = oz_find_urb_by_id(port, 0, req_id);
922 oz_hcd_complete_set_config(port, urb, rcode,
926 oz_hcd_complete_set_interface(port, urb, rcode,
927 (
u8)windex, (
u8)wvalue);
930 oz_complete_urb(hcd, urb, 0, 0);
937 if (data_len <= urb->transfer_buffer_length)
940 copy_len = urb->transfer_buffer_length;
941 memcpy(urb->transfer_buffer, data, copy_len);
942 urb->actual_length = copy_len;
944 oz_complete_urb(hcd, urb, 0, 0);
959 if (space < (data_len+1)) {
967 if (copy_len > data_len)
971 if (copy_len < data_len) {
973 ep->
in_ix = data_len-copy_len;
975 ep->
in_ix += copy_len;
1003 list_del_init(&urbl->
link);
1006 oz_free_urb_link(urbl);
1007 if (data_len <= urb->transfer_buffer_length)
1010 copy_len = urb->transfer_buffer_length;
1011 memcpy(urb->transfer_buffer, data, copy_len);
1012 urb->actual_length = copy_len;
1013 oz_complete_urb(port->
ozhcd->hcd, urb, 0, 0);
1016 oz_trace(
"buffering frame as URB is not available\n");
1017 oz_hcd_buffer_data(ep, data, data_len);
1021 oz_hcd_buffer_data(ep, data, data_len);
1030 static inline int oz_usb_get_frame_number(
void)
1049 INIT_LIST_HEAD(&xfr_list);
1066 if ((ep->
credit + 1) < urb->number_of_packets)
1068 ep->
credit -= urb->number_of_packets;
1071 list_move_tail(&urbl->
link, &xfr_list);
1083 urb->error_count = 0;
1084 urb->start_frame = oz_usb_get_frame_number();
1086 oz_free_urb_link(urbl);
1087 oz_complete_urb(port->
ozhcd->hcd, urb, 0, t);
1112 while (!list_empty(&ep->
urb_list)) {
1116 struct urb *urb = urbl->
urb;
1120 if ((ep->
credit + 1) < urb->number_of_packets)
1124 urb->actual_length = 0;
1125 for (i = 0; i < urb->number_of_packets; i++) {
1132 memcpy(urb->transfer_buffer,
1134 if (copy_len < len) {
1135 memcpy(urb->transfer_buffer+copy_len,
1136 ep->
buffer, len-copy_len);
1137 ep->
out_ix = len-copy_len;
1142 urb->iso_frame_desc[
i].offset =
1144 urb->actual_length += len;
1145 urb->iso_frame_desc[
i].actual_length = len;
1146 urb->iso_frame_desc[
i].status = 0;
1149 urb->error_count = 0;
1152 list_move_tail(&urbl->
link, &xfr_list);
1153 ep->
credit -= urb->number_of_packets;
1167 oz_free_urb_link(urbl);
1168 oz_complete_urb(port->
ozhcd->hcd, urb, 0, 0);
1181 oz_trace(
"%ld: Request 0x%p timeout\n",
1184 list_move_tail(e, &xfr_list);
1191 while (e != &xfr_list) {
1194 oz_trace(
"Resending request to PD.\n");
1196 oz_free_urb_link(urbl);
1204 static int oz_build_endpoints_for_interface(
struct usb_hcd *hcd,
1206 struct usb_host_interface *intf,
gfp_t mem_flags)
1210 int if_ix = intf->desc.bInterfaceNumber;
1211 int request_heartbeat = 0;
1212 oz_trace(
"interface[%d] = %p\n", if_ix, intf);
1213 for (i = 0; i < intf->desc.bNumEndpoints; i++) {
1214 struct usb_host_endpoint *
hep = &intf->endpoint[
i];
1215 u8 ep_addr = hep->desc.bEndpointAddress;
1218 int buffer_size = 0;
1220 oz_trace(
"%d bEndpointAddress = %x\n", i, ep_addr);
1222 switch (hep->desc.bmAttributes &
1225 buffer_size = 24*1024;
1233 ep = oz_ep_alloc(mem_flags, buffer_size);
1235 oz_clean_endpoints_for_interface(hcd, port, if_ix);
1238 ep->
attrib = hep->desc.bmAttributes;
1243 hep->desc.wMaxPacketSize);
1245 if (ep_addr & USB_ENDPOINT_DIR_MASK) {
1256 if (ep_addr & USB_ENDPOINT_DIR_MASK) {
1258 port->
iface[if_ix].ep_mask |=
1263 request_heartbeat = 1;
1271 request_heartbeat = 1;
1275 if (request_heartbeat && port->
hpd)
1283 static void oz_clean_endpoints_for_interface(
struct usb_hcd *hcd,
1284 struct oz_port *port,
int if_ix)
1291 oz_trace(
"Deleting endpoints for interface %d\n", if_ix);
1294 INIT_LIST_HEAD(&ep_list);
1296 mask = port->
iface[if_ix].ep_mask;
1297 port->
iface[if_ix].ep_mask = 0;
1302 if ((mask & (1<<i)) && port->
out_ep[i]) {
1307 list_move_tail(e, &ep_list);
1311 if ((mask & (1<<(i+OZ_NB_ENDPOINTS))) && port->
in_ep[i]) {
1312 e = &port->
in_ep[
i]->link;
1314 list_move_tail(e, &ep_list);
1318 while (!list_empty(&ep_list)) {
1321 list_del_init(&ep->
link);
1322 oz_ep_free(port, ep);
1328 static int oz_build_endpoints_for_config(
struct usb_hcd *hcd,
1329 struct oz_port *port,
struct usb_host_config *config,
1334 int num_iface = config->desc.bNumInterfaces;
1343 port->
iface = iface;
1347 for (i = 0; i < num_iface; i++) {
1348 struct usb_host_interface *intf =
1349 &config->intf_cache[
i]->altsetting[0];
1350 if (oz_build_endpoints_for_interface(hcd, port, intf,
1356 oz_clean_endpoints_for_config(hcd, port);
1362 static void oz_clean_endpoints_for_config(
struct usb_hcd *hcd,
1367 oz_trace(
"Deleting endpoints for configuration.\n");
1369 oz_clean_endpoints_for_interface(hcd, port, i);
1372 oz_trace(
"Freeing interfaces object.\n");
1382 static void *oz_claim_hpd(
struct oz_port *port)
1396 static void oz_process_ep0_urb(
struct oz_hcd *ozhcd,
struct urb *urb,
1412 port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum);
1417 port = &ozhcd->
ports[port_ix];
1420 oz_trace(
"Refusing URB port_ix = %d devnum = %d\n",
1421 port_ix, urb->dev->devnum);
1440 hpd = oz_claim_hpd(port);
1452 oz_trace(
"USB_REQ_GET_DESCRIPTOR - req\n");
1457 oz_trace(
"USB_REQ_SET_ADDRESS - req\n");
1471 oz_trace(
"USB_REQ_SET_CONFIGURATION - req\n");
1479 oz_trace(
"USB_REQ_GET_CONFIGURATION - reply now\n");
1480 if (urb->transfer_buffer_length >= 1) {
1481 urb->actual_length = 1;
1482 *((
u8 *)urb->transfer_buffer) =
1495 oz_trace(
"USB_REQ_GET_INTERFACE - reply now\n");
1496 if (urb->transfer_buffer_length >= 1) {
1497 urb->actual_length = 1;
1498 *((
u8 *)urb->transfer_buffer) =
1500 oz_trace(
"interface = %d alt = %d\n",
1501 windex, port->
iface[(
u8)windex].alt);
1508 oz_trace(
"USB_REQ_SET_INTERFACE - req\n");
1512 if (!rc && !complete) {
1518 urb->transfer_buffer, data_len)) {
1532 if (oz_enqueue_ep_urb(port, 0, 0, urb, req_id))
1538 if (rc || complete) {
1539 oz_trace(
"Completing request locally\n");
1540 oz_complete_urb(ozhcd->
hcd, urb, rc, 0);
1548 static int oz_urb_process(
struct oz_hcd *ozhcd,
struct urb *urb)
1551 struct oz_port *port = urb->hcpriv;
1560 if (!urb->transfer_buffer && urb->transfer_buffer_length)
1566 ep_addr = usb_pipeendpoint(urb->pipe);
1570 if (oz_enqueue_ep_urb(port, ep_addr, usb_pipein(urb->pipe),
1581 static void oz_urb_process_tasklet(
unsigned long unused)
1585 struct oz_hcd *ozhcd = oz_hcd_claim();
1598 list_del_init(&urbl->
link);
1599 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1601 oz_free_urb_link(urbl);
1602 rc = oz_urb_process(ozhcd, urb);
1604 oz_complete_urb(ozhcd->
hcd, urb, rc, 0);
1607 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1619 static void oz_urb_cancel(
struct oz_port *port,
u8 ep_num,
struct urb *urb)
1627 oz_trace(
"ERRORERROR: oz_urb_cancel(%p) port is null\n", urb);
1630 ozhcd = port->
ozhcd;
1632 oz_trace(
"ERRORERROR: oz_urb_cancel(%p) ozhcd is null\n", urb);
1641 if (urb == urbl->
urb) {
1643 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1647 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1655 if (urbl->
urb == urb) {
1657 oz_trace(
"Found urb in orphanage\n");
1661 ix = (ep_num & 0xf);
1664 urbl = oz_remove_urb(port->
in_ep[ix], urb);
1666 urbl = oz_remove_urb(port->
out_ep[ix], urb);
1668 spin_unlock_irqrestore(&ozhcd->
hcd_lock, irq_state);
1671 urb->actual_length = 0;
1672 oz_free_urb_link(urbl);
1673 oz_complete_urb(ozhcd->
hcd, urb, -
EPIPE, 0);
1679 static void oz_urb_cancel_tasklet(
unsigned long unused)
1683 struct oz_hcd *ozhcd = oz_hcd_claim();
1691 list_del_init(&urbl->
link);
1692 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1695 oz_urb_cancel(urbl->
port, urbl->
ep_num, urb);
1696 oz_free_urb_link(urbl);
1699 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1705 static void oz_hcd_clear_orphanage(
struct oz_hcd *ozhcd,
int status)
1709 while (!list_empty(&ozhcd->
orphanage)) {
1713 oz_complete_urb(ozhcd->
hcd, urbl->
urb, status, 0);
1714 oz_free_urb_link(urbl);
1721 static int oz_hcd_start(
struct usb_hcd *hcd)
1724 hcd->power_budget = 200;
1725 hcd->state = HC_STATE_RUNNING;
1726 hcd->uses_new_polling = 1;
1732 static void oz_hcd_stop(
struct usb_hcd *hcd)
1739 static void oz_hcd_shutdown(
struct usb_hcd *hcd)
1746 #ifdef WANT_EVENT_TRACE
1747 static u8 oz_get_irq_ctx(
void)
1763 static int oz_hcd_urb_enqueue(
struct usb_hcd *hcd,
struct urb *urb,
1766 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
1775 (
u16)urb->number_of_packets, urb, urb->pipe);
1781 if (
unlikely(hcd->state != HC_STATE_RUNNING)) {
1786 port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum);
1789 port = &ozhcd->
ports[port_ix];
1793 oz_trace(
"Refusing URB port_ix = %d devnum = %d\n",
1794 port_ix, urb->dev->devnum);
1800 urbl = oz_alloc_urb_link();
1807 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1808 oz_free_urb_link(urbl);
1812 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1813 tasklet_schedule(&g_urb_process_tasklet);
1829 if (urbl->
urb == urb) {
1831 if (usb_pipeisoc(urb->pipe)) {
1832 ep->
credit -= urb->number_of_packets;
1836 usb_pipein(urb->pipe) ?
1849 static int oz_hcd_urb_dequeue(
struct usb_hcd *hcd,
struct urb *urb,
int status)
1851 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
1856 urbl = oz_alloc_urb_link();
1870 if ((rc == 0) && urb->hcpriv) {
1873 urbl->
ep_num = usb_pipeendpoint(urb->pipe);
1874 if (usb_pipein(urb->pipe))
1875 urbl->
ep_num |= USB_DIR_IN;
1877 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1878 tasklet_schedule(&g_urb_cancel_tasklet);
1880 spin_unlock_irqrestore(&g_tasklet_lock, irq_state);
1881 oz_free_urb_link(urbl);
1888 static void oz_hcd_endpoint_disable(
struct usb_hcd *hcd,
1889 struct usb_host_endpoint *ep)
1891 oz_trace(
"oz_hcd_endpoint_disable\n");
1896 static void oz_hcd_endpoint_reset(
struct usb_hcd *hcd,
1897 struct usb_host_endpoint *ep)
1899 oz_trace(
"oz_hcd_endpoint_reset\n");
1904 static int oz_hcd_get_frame_number(
struct usb_hcd *hcd)
1906 oz_trace(
"oz_hcd_get_frame_number\n");
1907 return oz_usb_get_frame_number();
1914 static int oz_hcd_hub_status_data(
struct usb_hcd *hcd,
char *
buf)
1916 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
1926 ozhcd->
ports[
i].flags &= ~OZ_PORT_F_CHANGED;
1931 return buf[0] ? 1 : 0;
1936 static void oz_get_hub_descriptor(
struct usb_hcd *hcd,
1940 memset(desc, 0,
sizeof(*desc));
1950 static int oz_set_port_feature(
struct usb_hcd *hcd,
u16 wvalue,
u16 windex)
1955 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
1957 unsigned clear_bits = 0;
1959 if ((port_id < 1) || (port_id > OZ_NB_PORTS))
1961 port = &ozhcd->
ports[port_id-1];
1979 ozhcd->
ports[port_id-1].bus_addr = 0;
2013 if (set_bits || clear_bits) {
2015 port->
status &= ~clear_bits;
2026 static int oz_clear_port_feature(
struct usb_hcd *hcd,
u16 wvalue,
u16 windex)
2030 u8 port_id = (
u8)windex;
2031 struct oz_hcd *ozhcd = oz_hcd_private(hcd);
2032 unsigned clear_bits = 0;
2034 if ((port_id < 1) || (port_id > OZ_NB_PORTS))
2036 port = &ozhcd->
ports[port_id-1];
2091 port->
status &= ~clear_bits;
2095 ozhcd->
ports[port_id-1].status);
2101 static int oz_get_port_status(
struct usb_hcd *hcd,
u16 windex,
char *buf)
2105 if ((windex < 1) || (windex > OZ_NB_PORTS))
2107 ozhcd = oz_hcd_private(hcd);
2109 status = ozhcd->
ports[windex-1].status;
2117 static int oz_hcd_hub_control(
struct usb_hcd *hcd,
u16 req_type,
u16 wvalue,
2118 u16 windex,
char *buf,
u16 wlength)
2123 case ClearHubFeature:
2126 case ClearPortFeature:
2127 err = oz_clear_port_feature(hcd, wvalue, windex);
2129 case GetHubDescriptor:
2138 err = oz_get_port_status(hcd, windex, buf);
2143 case SetPortFeature:
2144 err = oz_set_port_feature(hcd, wvalue, windex);
2155 static int oz_hcd_bus_suspend(
struct usb_hcd *hcd)
2159 ozhcd = oz_hcd_private(hcd);
2161 hcd->state = HC_STATE_SUSPENDED;
2169 static int oz_hcd_bus_resume(
struct usb_hcd *hcd)
2173 ozhcd = oz_hcd_private(hcd);
2176 hcd->state = HC_STATE_RUNNING;
2193 struct usb_hcd *hcd;
2198 oz_trace(
"Failed to created hcd object OK\n");
2201 ozhcd = oz_hcd_private(hcd);
2202 memset(ozhcd, 0,
sizeof(*ozhcd));
2219 oz_trace(
"Failed to add hcd object OK\n");
2223 spin_lock_bh(&g_hcdlock);
2225 spin_unlock_bh(&g_hcdlock);
2233 struct usb_hcd *hcd = platform_get_drvdata(dev);
2238 ozhcd = oz_hcd_private(hcd);
2239 spin_lock_bh(&g_hcdlock);
2240 if (ozhcd == g_ozhcd)
2242 spin_unlock_bh(&g_hcdlock);
2244 oz_hcd_clear_orphanage(ozhcd, -
EPIPE);
2248 oz_empty_link_pool();
2275 tasklet_init(&g_urb_process_tasklet, oz_urb_process_tasklet, 0);
2276 tasklet_init(&g_urb_cancel_tasklet, oz_urb_cancel_tasklet, 0);
2278 oz_trace(
"platform_driver_register() returned %d\n", err);
2282 if (g_plat_dev == 0) {
2286 oz_trace(
"platform_device_alloc() succeeded\n");
2290 oz_trace(
"platform_device_add() succeeded\n");
2297 tasklet_disable(&g_urb_process_tasklet);
2298 tasklet_disable(&g_urb_cancel_tasklet);
2299 oz_trace(
"oz_hcd_init() failed %d\n", err);
2307 tasklet_disable(&g_urb_process_tasklet);
2308 tasklet_disable(&g_urb_cancel_tasklet);