hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/usb/hcd.h
....@@ -73,6 +73,12 @@
7373 struct usb_host_endpoint *completing_ep;
7474 };
7575
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
+
7682 struct usb_hcd {
7783
7884 /*
....@@ -93,6 +99,7 @@
9399 #ifdef CONFIG_PM
94100 struct work_struct wakeup_work; /* for remote wakeup */
95101 #endif
102
+ struct work_struct died_work; /* for when the device dies */
96103
97104 /*
98105 * hardware info/state
....@@ -118,8 +125,7 @@
118125 #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
119126 #define HCD_FLAG_DEAD 6 /* controller has died? */
120127 #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */
121
-#define HCD_FLAG_DEV_AUTHORIZED 8 /* authorize devices? */
122
-#define HCD_FLAG_POWER_ON 9 /* power on */
128
+#define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */
123129
124130 /* The flags can be tested using these macros; they are likely to
125131 * be slightly faster than test_bit().
....@@ -130,6 +136,7 @@
130136 #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
131137 #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
132138 #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))
133140
134141 /*
135142 * Specifies if interfaces are authorized by default
....@@ -144,10 +151,7 @@
144151 * or they require explicit user space authorization; this bit is
145152 * settable through /sys/class/usb_host/X/authorized_default
146153 */
147
-#define HCD_DEV_AUTHORIZED(hcd) \
148
- ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED))
149
-
150
-#define HCD_POWER_ON(hcd) ((hcd)->flags & (1U << HCD_FLAG_POWER_ON))
154
+ enum usb_dev_authorize_policy dev_policy;
151155
152156 /* Flags that get set only during HCD registration or removal. */
153157 unsigned rh_registered:1;/* is root hub registered? */
....@@ -171,7 +175,6 @@
171175 unsigned tpl_support:1; /* OTG & EH TPL support */
172176 unsigned cant_recv_wakeups:1;
173177 /* wakeup requests from downstream aren't received */
174
- unsigned rk3288_relinquish_port_quirk:1;
175178
176179 unsigned int irq; /* irq allocated */
177180 void __iomem *regs; /* device memory/io */
....@@ -216,6 +219,9 @@
216219 #define HC_IS_RUNNING(state) ((state) & __ACTIVE)
217220 #define HC_IS_SUSPENDED(state) ((state) & __SUSPEND)
218221
222
+ /* memory pool for HCs having local memory, or %NULL */
223
+ struct gen_pool *localmem_pool;
224
+
219225 /* more shared queuing code would be good; it should support
220226 * smarter scheduling, handle transaction translators, etc;
221227 * input size of periodic table to an interrupt scheduler.
....@@ -230,7 +236,7 @@
230236 /* The HC driver's private data is stored at the end of
231237 * this structure.
232238 */
233
- unsigned long hcd_priv[0]
239
+ unsigned long hcd_priv[]
234240 __attribute__ ((aligned(sizeof(s64))));
235241 };
236242
....@@ -245,11 +251,6 @@
245251 return container_of(bus, struct usb_hcd, self);
246252 }
247253
248
-struct hcd_timeout { /* timeouts we allocate */
249
- struct list_head timeout_list;
250
- struct timer_list timer;
251
-};
252
-
253254 /*-------------------------------------------------------------------------*/
254255
255256
....@@ -263,7 +264,7 @@
263264
264265 int flags;
265266 #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
266
-#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */
267
+#define HCD_DMA 0x0002 /* HC uses DMA */
267268 #define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */
268269 #define HCD_USB11 0x0010 /* USB 1.1 */
269270 #define HCD_USB2 0x0020 /* USB 2.0 */
....@@ -417,18 +418,6 @@
417418 /* Call for power on/off the port if necessary */
418419 int (*port_power)(struct usb_hcd *hcd, int portnum, bool enable);
419420
420
- int (*sec_event_ring_setup)(struct usb_hcd *hcd, unsigned int intr_num);
421
- int (*sec_event_ring_cleanup)(struct usb_hcd *hcd,
422
- unsigned int intr_num);
423
- phys_addr_t (*get_sec_event_ring_phys_addr)(struct usb_hcd *hcd,
424
- unsigned int intr_num, dma_addr_t *dma);
425
- phys_addr_t (*get_xfer_ring_phys_addr)(struct usb_hcd *hcd,
426
- struct usb_device *udev, struct usb_host_endpoint *ep,
427
- dma_addr_t *dma);
428
- int (*get_core_id)(struct usb_hcd *hcd);
429
- int (*stop_endpoint)(struct usb_hcd *hcd, struct usb_device *udev,
430
- struct usb_host_endpoint *ep);
431
-
432421 ANDROID_KABI_RESERVE(1);
433422 ANDROID_KABI_RESERVE(2);
434423 ANDROID_KABI_RESERVE(3);
....@@ -444,6 +433,11 @@
444433 struct usb_host_endpoint *ep)
445434 {
446435 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);
447441 }
448442
449443 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
....@@ -471,17 +465,6 @@
471465 struct usb_host_interface *old_alt,
472466 struct usb_host_interface *new_alt);
473467 extern int usb_hcd_get_frame_number(struct usb_device *udev);
474
-extern int usb_hcd_sec_event_ring_setup(struct usb_device *udev,
475
- unsigned int intr_num);
476
-extern int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev,
477
- unsigned int intr_num);
478
-extern phys_addr_t usb_hcd_get_sec_event_ring_phys_addr(
479
- struct usb_device *udev, unsigned int intr_num, dma_addr_t *dma);
480
-extern phys_addr_t usb_hcd_get_xfer_ring_phys_addr(
481
- struct usb_device *udev, struct usb_host_endpoint *ep, dma_addr_t *dma);
482
-extern int usb_hcd_get_controller_id(struct usb_device *udev);
483
-extern int usb_hcd_stop_endpoint(struct usb_device *udev,
484
- struct usb_host_endpoint *ep);
485468
486469 struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
487470 struct device *sysdev, struct device *dev, const char *bus_name,
....@@ -498,6 +481,8 @@
498481 unsigned int irqnum, unsigned long irqflags);
499482 extern void usb_remove_hcd(struct usb_hcd *hcd);
500483 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);
501486
502487 struct platform_device;
503488 extern void usb_hcd_platform_shutdown(struct platform_device *dev);
....@@ -506,7 +491,8 @@
506491 struct pci_dev;
507492 struct pci_device_id;
508493 extern int usb_hcd_pci_probe(struct pci_dev *dev,
509
- const struct pci_device_id *id);
494
+ const struct pci_device_id *id,
495
+ const struct hc_driver *driver);
510496 extern void usb_hcd_pci_remove(struct pci_dev *dev);
511497 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
512498
....@@ -526,6 +512,11 @@
526512 gfp_t mem_flags, dma_addr_t *dma);
527513 void hcd_buffer_free(struct usb_bus *bus, size_t size,
528514 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);
529520
530521 /* generic bus glue, needed for host controllers that don't use PCI */
531522 extern irqreturn_t usb_hcd_irq(int irq, void *__hcd);
....@@ -629,6 +620,10 @@
629620 #define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
630621 #define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
631622 #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)
632627
633628
634629 /*-------------------------------------------------------------------------*/
....@@ -695,11 +690,16 @@
695690 #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
696691
697692 #ifdef CONFIG_PM
693
+extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev);
698694 extern void usb_root_hub_lost_power(struct usb_device *rhdev);
699695 extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
700696 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
701697 extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
702698 #else
699
+static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev)
700
+{
701
+ return 0;
702
+}
703703 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
704704 {
705705 return;