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,7 +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? */
128
+#define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */
122129
123130 /* The flags can be tested using these macros; they are likely to
124131 * be slightly faster than test_bit().
....@@ -129,6 +136,7 @@
129136 #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
130137 #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
131138 #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))
132140
133141 /*
134142 * Specifies if interfaces are authorized by default
....@@ -143,8 +151,7 @@
143151 * or they require explicit user space authorization; this bit is
144152 * settable through /sys/class/usb_host/X/authorized_default
145153 */
146
-#define HCD_DEV_AUTHORIZED(hcd) \
147
- ((hcd)->flags & (1U << HCD_FLAG_DEV_AUTHORIZED))
154
+ enum usb_dev_authorize_policy dev_policy;
148155
149156 /* Flags that get set only during HCD registration or removal. */
150157 unsigned rh_registered:1;/* is root hub registered? */
....@@ -168,7 +175,6 @@
168175 unsigned tpl_support:1; /* OTG & EH TPL support */
169176 unsigned cant_recv_wakeups:1;
170177 /* wakeup requests from downstream aren't received */
171
- unsigned rk3288_relinquish_port_quirk:1;
172178
173179 unsigned int irq; /* irq allocated */
174180 void __iomem *regs; /* device memory/io */
....@@ -213,6 +219,9 @@
213219 #define HC_IS_RUNNING(state) ((state) & __ACTIVE)
214220 #define HC_IS_SUSPENDED(state) ((state) & __SUSPEND)
215221
222
+ /* memory pool for HCs having local memory, or %NULL */
223
+ struct gen_pool *localmem_pool;
224
+
216225 /* more shared queuing code would be good; it should support
217226 * smarter scheduling, handle transaction translators, etc;
218227 * input size of periodic table to an interrupt scheduler.
....@@ -227,7 +236,7 @@
227236 /* The HC driver's private data is stored at the end of
228237 * this structure.
229238 */
230
- unsigned long hcd_priv[0]
239
+ unsigned long hcd_priv[]
231240 __attribute__ ((aligned(sizeof(s64))));
232241 };
233242
....@@ -242,11 +251,6 @@
242251 return container_of(bus, struct usb_hcd, self);
243252 }
244253
245
-struct hcd_timeout { /* timeouts we allocate */
246
- struct list_head timeout_list;
247
- struct timer_list timer;
248
-};
249
-
250254 /*-------------------------------------------------------------------------*/
251255
252256
....@@ -260,7 +264,7 @@
260264
261265 int flags;
262266 #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 */
264268 #define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */
265269 #define HCD_USB11 0x0010 /* USB 1.1 */
266270 #define HCD_USB2 0x0020 /* USB 2.0 */
....@@ -414,18 +418,6 @@
414418 /* Call for power on/off the port if necessary */
415419 int (*port_power)(struct usb_hcd *hcd, int portnum, bool enable);
416420
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
-
429421 ANDROID_KABI_RESERVE(1);
430422 ANDROID_KABI_RESERVE(2);
431423 ANDROID_KABI_RESERVE(3);
....@@ -441,6 +433,11 @@
441433 struct usb_host_endpoint *ep)
442434 {
443435 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);
444441 }
445442
446443 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
....@@ -468,17 +465,6 @@
468465 struct usb_host_interface *old_alt,
469466 struct usb_host_interface *new_alt);
470467 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);
482468
483469 struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
484470 struct device *sysdev, struct device *dev, const char *bus_name,
....@@ -495,6 +481,8 @@
495481 unsigned int irqnum, unsigned long irqflags);
496482 extern void usb_remove_hcd(struct usb_hcd *hcd);
497483 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);
498486
499487 struct platform_device;
500488 extern void usb_hcd_platform_shutdown(struct platform_device *dev);
....@@ -503,7 +491,8 @@
503491 struct pci_dev;
504492 struct pci_device_id;
505493 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);
507496 extern void usb_hcd_pci_remove(struct pci_dev *dev);
508497 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
509498
....@@ -523,6 +512,11 @@
523512 gfp_t mem_flags, dma_addr_t *dma);
524513 void hcd_buffer_free(struct usb_bus *bus, size_t size,
525514 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);
526520
527521 /* generic bus glue, needed for host controllers that don't use PCI */
528522 extern irqreturn_t usb_hcd_irq(int irq, void *__hcd);
....@@ -626,6 +620,10 @@
626620 #define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
627621 #define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
628622 #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)
629627
630628
631629 /*-------------------------------------------------------------------------*/
....@@ -692,11 +690,16 @@
692690 #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
693691
694692 #ifdef CONFIG_PM
693
+extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev);
695694 extern void usb_root_hub_lost_power(struct usb_device *rhdev);
696695 extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
697696 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
698697 extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
699698 #else
699
+static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev)
700
+{
701
+ return 0;
702
+}
700703 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
701704 {
702705 return;