.. | .. |
---|
73 | 73 | struct usb_host_endpoint *completing_ep; |
---|
74 | 74 | }; |
---|
75 | 75 | |
---|
| 76 | +enum usb_dev_authorize_policy { |
---|
| 77 | + USB_DEVICE_AUTHORIZE_NONE = 0, |
---|
| 78 | + USB_DEVICE_AUTHORIZE_ALL = 1, |
---|
| 79 | + USB_DEVICE_AUTHORIZE_INTERNAL = 2, |
---|
| 80 | +}; |
---|
| 81 | + |
---|
76 | 82 | struct usb_hcd { |
---|
77 | 83 | |
---|
78 | 84 | /* |
---|
.. | .. |
---|
93 | 99 | #ifdef CONFIG_PM |
---|
94 | 100 | struct work_struct wakeup_work; /* for remote wakeup */ |
---|
95 | 101 | #endif |
---|
| 102 | + struct work_struct died_work; /* for when the device dies */ |
---|
96 | 103 | |
---|
97 | 104 | /* |
---|
98 | 105 | * hardware info/state |
---|
.. | .. |
---|
118 | 125 | #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */ |
---|
119 | 126 | #define HCD_FLAG_DEAD 6 /* controller has died? */ |
---|
120 | 127 | #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */ |
---|
121 | | -#define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */ |
---|
| 128 | +#define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */ |
---|
122 | 129 | |
---|
123 | 130 | /* The flags can be tested using these macros; they are likely to |
---|
124 | 131 | * be slightly faster than test_bit(). |
---|
.. | .. |
---|
129 | 136 | #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) |
---|
130 | 137 | #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING)) |
---|
131 | 138 | #define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD)) |
---|
| 139 | +#define HCD_DEFER_RH_REGISTER(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEFER_RH_REGISTER)) |
---|
132 | 140 | |
---|
133 | 141 | /* |
---|
134 | 142 | * Specifies if interfaces are authorized by default |
---|
.. | .. |
---|
143 | 151 | * or they require explicit user space authorization; this bit is |
---|
144 | 152 | * settable through /sys/class/usb_host/X/authorized_default |
---|
145 | 153 | */ |
---|
146 | | -#define HCD_DEV_AUTHORIZED(hcd) \ |
---|
147 | | - ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED)) |
---|
| 154 | + enum usb_dev_authorize_policy dev_policy; |
---|
148 | 155 | |
---|
149 | 156 | /* Flags that get set only during HCD registration or removal. */ |
---|
150 | 157 | unsigned rh_registered:1;/* is root hub registered? */ |
---|
.. | .. |
---|
168 | 175 | unsigned tpl_support:1; /* OTG & EH TPL support */ |
---|
169 | 176 | unsigned cant_recv_wakeups:1; |
---|
170 | 177 | /* wakeup requests from downstream aren't received */ |
---|
171 | | - unsigned rk3288_relinquish_port_quirk:1; |
---|
172 | 178 | |
---|
173 | 179 | unsigned int irq; /* irq allocated */ |
---|
174 | 180 | void __iomem *regs; /* device memory/io */ |
---|
.. | .. |
---|
213 | 219 | #define HC_IS_RUNNING(state) ((state) & __ACTIVE) |
---|
214 | 220 | #define HC_IS_SUSPENDED(state) ((state) & __SUSPEND) |
---|
215 | 221 | |
---|
| 222 | + /* memory pool for HCs having local memory, or %NULL */ |
---|
| 223 | + struct gen_pool *localmem_pool; |
---|
| 224 | + |
---|
216 | 225 | /* more shared queuing code would be good; it should support |
---|
217 | 226 | * smarter scheduling, handle transaction translators, etc; |
---|
218 | 227 | * input size of periodic table to an interrupt scheduler. |
---|
.. | .. |
---|
227 | 236 | /* The HC driver's private data is stored at the end of |
---|
228 | 237 | * this structure. |
---|
229 | 238 | */ |
---|
230 | | - unsigned long hcd_priv[0] |
---|
| 239 | + unsigned long hcd_priv[] |
---|
231 | 240 | __attribute__ ((aligned(sizeof(s64)))); |
---|
232 | 241 | }; |
---|
233 | 242 | |
---|
.. | .. |
---|
242 | 251 | return container_of(bus, struct usb_hcd, self); |
---|
243 | 252 | } |
---|
244 | 253 | |
---|
245 | | -struct hcd_timeout { /* timeouts we allocate */ |
---|
246 | | - struct list_head timeout_list; |
---|
247 | | - struct timer_list timer; |
---|
248 | | -}; |
---|
249 | | - |
---|
250 | 254 | /*-------------------------------------------------------------------------*/ |
---|
251 | 255 | |
---|
252 | 256 | |
---|
.. | .. |
---|
260 | 264 | |
---|
261 | 265 | int flags; |
---|
262 | 266 | #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ |
---|
263 | | -#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ |
---|
| 267 | +#define HCD_DMA 0x0002 /* HC uses DMA */ |
---|
264 | 268 | #define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */ |
---|
265 | 269 | #define HCD_USB11 0x0010 /* USB 1.1 */ |
---|
266 | 270 | #define HCD_USB2 0x0020 /* USB 2.0 */ |
---|
.. | .. |
---|
414 | 418 | /* Call for power on/off the port if necessary */ |
---|
415 | 419 | int (*port_power)(struct usb_hcd *hcd, int portnum, bool enable); |
---|
416 | 420 | |
---|
417 | | - int (*sec_event_ring_setup)(struct usb_hcd *hcd, unsigned int intr_num); |
---|
418 | | - int (*sec_event_ring_cleanup)(struct usb_hcd *hcd, |
---|
419 | | - unsigned int intr_num); |
---|
420 | | - phys_addr_t (*get_sec_event_ring_phys_addr)(struct usb_hcd *hcd, |
---|
421 | | - unsigned int intr_num, dma_addr_t *dma); |
---|
422 | | - phys_addr_t (*get_xfer_ring_phys_addr)(struct usb_hcd *hcd, |
---|
423 | | - struct usb_device *udev, struct usb_host_endpoint *ep, |
---|
424 | | - dma_addr_t *dma); |
---|
425 | | - int (*get_core_id)(struct usb_hcd *hcd); |
---|
426 | | - int (*stop_endpoint)(struct usb_hcd *hcd, struct usb_device *udev, |
---|
427 | | - struct usb_host_endpoint *ep); |
---|
428 | | - |
---|
429 | 421 | ANDROID_KABI_RESERVE(1); |
---|
430 | 422 | ANDROID_KABI_RESERVE(2); |
---|
431 | 423 | ANDROID_KABI_RESERVE(3); |
---|
.. | .. |
---|
441 | 433 | struct usb_host_endpoint *ep) |
---|
442 | 434 | { |
---|
443 | 435 | return hcd->high_prio_bh.completing_ep == ep; |
---|
| 436 | +} |
---|
| 437 | + |
---|
| 438 | +static inline bool hcd_uses_dma(struct usb_hcd *hcd) |
---|
| 439 | +{ |
---|
| 440 | + return IS_ENABLED(CONFIG_HAS_DMA) && (hcd->driver->flags & HCD_DMA); |
---|
444 | 441 | } |
---|
445 | 442 | |
---|
446 | 443 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); |
---|
.. | .. |
---|
468 | 465 | struct usb_host_interface *old_alt, |
---|
469 | 466 | struct usb_host_interface *new_alt); |
---|
470 | 467 | extern int usb_hcd_get_frame_number(struct usb_device *udev); |
---|
471 | | -extern int usb_hcd_sec_event_ring_setup(struct usb_device *udev, |
---|
472 | | - unsigned int intr_num); |
---|
473 | | -extern int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev, |
---|
474 | | - unsigned int intr_num); |
---|
475 | | -extern phys_addr_t usb_hcd_get_sec_event_ring_phys_addr( |
---|
476 | | - struct usb_device *udev, unsigned int intr_num, dma_addr_t *dma); |
---|
477 | | -extern phys_addr_t usb_hcd_get_xfer_ring_phys_addr( |
---|
478 | | - struct usb_device *udev, struct usb_host_endpoint *ep, dma_addr_t *dma); |
---|
479 | | -extern int usb_hcd_get_controller_id(struct usb_device *udev); |
---|
480 | | -extern int usb_hcd_stop_endpoint(struct usb_device *udev, |
---|
481 | | - struct usb_host_endpoint *ep); |
---|
482 | 468 | |
---|
483 | 469 | struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver, |
---|
484 | 470 | struct device *sysdev, struct device *dev, const char *bus_name, |
---|
.. | .. |
---|
495 | 481 | unsigned int irqnum, unsigned long irqflags); |
---|
496 | 482 | extern void usb_remove_hcd(struct usb_hcd *hcd); |
---|
497 | 483 | extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); |
---|
| 484 | +int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr, |
---|
| 485 | + dma_addr_t dma, size_t size); |
---|
498 | 486 | |
---|
499 | 487 | struct platform_device; |
---|
500 | 488 | extern void usb_hcd_platform_shutdown(struct platform_device *dev); |
---|
.. | .. |
---|
503 | 491 | struct pci_dev; |
---|
504 | 492 | struct pci_device_id; |
---|
505 | 493 | extern int usb_hcd_pci_probe(struct pci_dev *dev, |
---|
506 | | - const struct pci_device_id *id); |
---|
| 494 | + const struct pci_device_id *id, |
---|
| 495 | + const struct hc_driver *driver); |
---|
507 | 496 | extern void usb_hcd_pci_remove(struct pci_dev *dev); |
---|
508 | 497 | extern void usb_hcd_pci_shutdown(struct pci_dev *dev); |
---|
509 | 498 | |
---|
.. | .. |
---|
523 | 512 | gfp_t mem_flags, dma_addr_t *dma); |
---|
524 | 513 | void hcd_buffer_free(struct usb_bus *bus, size_t size, |
---|
525 | 514 | void *addr, dma_addr_t dma); |
---|
| 515 | + |
---|
| 516 | +void *hcd_buffer_alloc_pages(struct usb_hcd *hcd, |
---|
| 517 | + size_t size, gfp_t mem_flags, dma_addr_t *dma); |
---|
| 518 | +void hcd_buffer_free_pages(struct usb_hcd *hcd, |
---|
| 519 | + size_t size, void *addr, dma_addr_t dma); |
---|
526 | 520 | |
---|
527 | 521 | /* generic bus glue, needed for host controllers that don't use PCI */ |
---|
528 | 522 | extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); |
---|
.. | .. |
---|
626 | 620 | #define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS) |
---|
627 | 621 | #define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE) |
---|
628 | 622 | #define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE) |
---|
| 623 | +#define ClearTTBuffer HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_CLEAR_TT_BUFFER) |
---|
| 624 | +#define ResetTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_RESET_TT) |
---|
| 625 | +#define GetTTState HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_TT_STATE) |
---|
| 626 | +#define StopTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_STOP_TT) |
---|
629 | 627 | |
---|
630 | 628 | |
---|
631 | 629 | /*-------------------------------------------------------------------------*/ |
---|
.. | .. |
---|
692 | 690 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) |
---|
693 | 691 | |
---|
694 | 692 | #ifdef CONFIG_PM |
---|
| 693 | +extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev); |
---|
695 | 694 | extern void usb_root_hub_lost_power(struct usb_device *rhdev); |
---|
696 | 695 | extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); |
---|
697 | 696 | extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); |
---|
698 | 697 | extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); |
---|
699 | 698 | #else |
---|
| 699 | +static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev) |
---|
| 700 | +{ |
---|
| 701 | + return 0; |
---|
| 702 | +} |
---|
700 | 703 | static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) |
---|
701 | 704 | { |
---|
702 | 705 | return; |
---|