hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
....@@ -2,6 +2,9 @@
22 #ifndef __ASPEED_VHUB_H
33 #define __ASPEED_VHUB_H
44
5
+#include <linux/usb.h>
6
+#include <linux/usb/ch11.h>
7
+
58 /*****************************
69 * *
710 * VHUB register definitions *
....@@ -48,14 +51,11 @@
4851 #define VHUB_CTRL_UPSTREAM_CONNECT (1 << 0)
4952
5053 /* IER & ISR */
54
+#define VHUB_IRQ_DEV1_BIT 9
5155 #define VHUB_IRQ_USB_CMD_DEADLOCK (1 << 18)
5256 #define VHUB_IRQ_EP_POOL_NAK (1 << 17)
5357 #define VHUB_IRQ_EP_POOL_ACK_STALL (1 << 16)
54
-#define VHUB_IRQ_DEVICE5 (1 << 13)
55
-#define VHUB_IRQ_DEVICE4 (1 << 12)
56
-#define VHUB_IRQ_DEVICE3 (1 << 11)
57
-#define VHUB_IRQ_DEVICE2 (1 << 10)
58
-#define VHUB_IRQ_DEVICE1 (1 << 9)
58
+#define VHUB_IRQ_DEVICE1 (1 << (VHUB_IRQ_DEV1_BIT))
5959 #define VHUB_IRQ_BUS_RESUME (1 << 8)
6060 #define VHUB_IRQ_BUS_SUSPEND (1 << 7)
6161 #define VHUB_IRQ_BUS_RESET (1 << 6)
....@@ -67,6 +67,9 @@
6767 #define VHUB_IRQ_HUB_EP0_SETUP (1 << 0)
6868 #define VHUB_IRQ_ACK_ALL 0x1ff
6969
70
+/* Downstream device IRQ mask. */
71
+#define VHUB_DEV_IRQ(n) (VHUB_IRQ_DEVICE1 << (n))
72
+
7073 /* SW reset reg */
7174 #define VHUB_SW_RESET_EP_POOL (1 << 9)
7275 #define VHUB_SW_RESET_DMA_CONTROLLER (1 << 8)
....@@ -76,17 +79,9 @@
7679 #define VHUB_SW_RESET_DEVICE2 (1 << 2)
7780 #define VHUB_SW_RESET_DEVICE1 (1 << 1)
7881 #define VHUB_SW_RESET_ROOT_HUB (1 << 0)
79
-#define VHUB_SW_RESET_ALL (VHUB_SW_RESET_EP_POOL | \
80
- VHUB_SW_RESET_DMA_CONTROLLER | \
81
- VHUB_SW_RESET_DEVICE5 | \
82
- VHUB_SW_RESET_DEVICE4 | \
83
- VHUB_SW_RESET_DEVICE3 | \
84
- VHUB_SW_RESET_DEVICE2 | \
85
- VHUB_SW_RESET_DEVICE1 | \
86
- VHUB_SW_RESET_ROOT_HUB)
82
+
8783 /* EP ACK/NACK IRQ masks */
8884 #define VHUB_EP_IRQ(n) (1 << (n))
89
-#define VHUB_EP_IRQ_ALL 0x7fff /* 15 EPs */
9085
9186 /* USB status reg */
9287 #define VHUB_USBSTS_HISPEED (1 << 27)
....@@ -210,6 +205,11 @@
210205 * *
211206 ****************************************/
212207
208
+/*
209
+ * AST_VHUB_NUM_GEN_EPs and AST_VHUB_NUM_PORTS are kept to avoid breaking
210
+ * existing AST2400/AST2500 platforms. AST2600 and future vhub revisions
211
+ * should define number of downstream ports and endpoints in device tree.
212
+ */
213213 #define AST_VHUB_NUM_GEN_EPs 15 /* Generic non-0 EPs */
214214 #define AST_VHUB_NUM_PORTS 5 /* vHub ports */
215215 #define AST_VHUB_EP0_MAX_PACKET 64 /* EP0's max packet size */
....@@ -257,6 +257,7 @@
257257 ep0_state_token,
258258 ep0_state_data,
259259 ep0_state_status,
260
+ ep0_state_stall,
260261 };
261262
262263 /*
....@@ -311,7 +312,7 @@
311312 /* Registers */
312313 void __iomem *regs;
313314
314
- /* Index in global pool (0..14) */
315
+ /* Index in global pool (zero-based) */
315316 unsigned int g_idx;
316317
317318 /* DMA Descriptors */
....@@ -341,7 +342,7 @@
341342 struct ast_vhub *vhub;
342343 void __iomem *regs;
343344
344
- /* Device index (0...4) and name string */
345
+ /* Device index (zero-based) and name string */
345346 unsigned int index;
346347 const char *name;
347348
....@@ -353,12 +354,12 @@
353354 struct usb_gadget_driver *driver;
354355 bool registered : 1;
355356 bool wakeup_en : 1;
356
- bool suspended : 1;
357357 bool enabled : 1;
358358
359359 /* Endpoint structures */
360360 struct ast_vhub_ep ep0;
361
- struct ast_vhub_ep *epns[AST_VHUB_NUM_GEN_EPs];
361
+ struct ast_vhub_ep **epns;
362
+ u32 max_epns;
362363
363364 };
364365 #define to_ast_dev(__g) container_of(__g, struct ast_vhub_dev, gadget)
....@@ -372,6 +373,12 @@
372373 /* Associated device slot */
373374 struct ast_vhub_dev dev;
374375 };
376
+
377
+struct ast_vhub_full_cdesc {
378
+ struct usb_config_descriptor cfg;
379
+ struct usb_interface_descriptor intf;
380
+ struct usb_endpoint_descriptor ep;
381
+} __packed;
375382
376383 /* Global vhub structure */
377384 struct ast_vhub {
....@@ -393,10 +400,13 @@
393400 bool ep1_stalled : 1;
394401
395402 /* Per-port info */
396
- struct ast_vhub_port ports[AST_VHUB_NUM_PORTS];
403
+ struct ast_vhub_port *ports;
404
+ u32 max_ports;
405
+ u32 port_irq_mask;
397406
398407 /* Generic EP data structures */
399
- struct ast_vhub_ep epns[AST_VHUB_NUM_GEN_EPs];
408
+ struct ast_vhub_ep *epns;
409
+ u32 max_epns;
400410
401411 /* Upstream bus is suspended ? */
402412 bool suspended : 1;
....@@ -409,6 +419,12 @@
409419
410420 /* Upstream bus speed captured at bus reset */
411421 unsigned int speed;
422
+
423
+ /* Standard USB Descriptors of the vhub. */
424
+ struct usb_device_descriptor vhub_dev_desc;
425
+ struct ast_vhub_full_cdesc vhub_conf_desc;
426
+ struct usb_hub_descriptor vhub_hub_desc;
427
+ struct list_head vhub_str_desc;
412428 };
413429
414430 /* Standard request handlers result codes */
....@@ -507,6 +523,7 @@
507523 /* ep0.c */
508524 void ast_vhub_ep0_handle_ack(struct ast_vhub_ep *ep, bool in_ack);
509525 void ast_vhub_ep0_handle_setup(struct ast_vhub_ep *ep);
526
+void ast_vhub_reset_ep0(struct ast_vhub_dev *dev);
510527 void ast_vhub_init_ep0(struct ast_vhub *vhub, struct ast_vhub_ep *ep,
511528 struct ast_vhub_dev *dev);
512529 int ast_vhub_reply(struct ast_vhub_ep *ep, char *ptr, int len);
....@@ -517,7 +534,7 @@
517534 __VA_ARGS__)
518535
519536 /* hub.c */
520
-void ast_vhub_init_hub(struct ast_vhub *vhub);
537
+int ast_vhub_init_hub(struct ast_vhub *vhub);
521538 enum std_req_rc ast_vhub_std_hub_request(struct ast_vhub_ep *ep,
522539 struct usb_ctrlrequest *crq);
523540 enum std_req_rc ast_vhub_class_hub_request(struct ast_vhub_ep *ep,