forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/usb/host/xhci-mtk.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * Copyright (c) 2015 MediaTek Inc.
44 * Author:
....@@ -18,6 +18,15 @@
1818 * bandwidth to it.
1919 */
2020 #define XHCI_MTK_MAX_ESIT 64
21
+
22
+/**
23
+ * @fs_bus_bw: array to keep track of bandwidth already used for FS
24
+ * @ep_list: Endpoints using this TT
25
+ */
26
+struct mu3h_sch_tt {
27
+ u32 fs_bus_bw[XHCI_MTK_MAX_ESIT];
28
+ struct list_head ep_list;
29
+};
2130
2231 /**
2332 * struct mu3h_sch_bw_info: schedule information for bandwidth domain
....@@ -41,7 +50,12 @@
4150 * (@repeat==1) scheduled within the interval
4251 * @bw_cost_per_microframe: bandwidth cost per microframe
4352 * @endpoint: linked into bandwidth domain which it belongs to
53
+ * @tt_endpoint: linked into mu3h_sch_tt's list which it belongs to
54
+ * @sch_tt: mu3h_sch_tt linked into
55
+ * @ep_type: endpoint type
56
+ * @maxpkt: max packet size of endpoint
4457 * @ep: address of usb_host_endpoint struct
58
+ * @allocated: the bandwidth is aready allocated from bus_bw
4559 * @offset: which uframe of the interval that transfer should be
4660 * scheduled first time within the interval
4761 * @repeat: the time gap between two uframes that transfers are
....@@ -57,13 +71,20 @@
5771 * times; 1: distribute the (bMaxBurst+1)*(Mult+1) packets
5872 * according to @pkts and @repeat. normal mode is used by
5973 * default
74
+ * @bw_budget_table: table to record bandwidth budget per microframe
6075 */
6176 struct mu3h_sch_ep_info {
6277 u32 esit;
6378 u32 num_budget_microframes;
6479 u32 bw_cost_per_microframe;
6580 struct list_head endpoint;
66
- void *ep;
81
+ struct list_head tt_endpoint;
82
+ struct mu3h_sch_tt *sch_tt;
83
+ u32 ep_type;
84
+ u32 maxpkt;
85
+ struct usb_host_endpoint *ep;
86
+ enum usb_device_speed speed;
87
+ bool allocated;
6788 /*
6889 * mtk xHCI scheduling information put into reserved DWs
6990 * in ep context
....@@ -73,6 +94,7 @@
7394 u32 pkts;
7495 u32 cs_count;
7596 u32 burst_mode;
97
+ u32 bw_budget_table[];
7698 };
7799
78100 #define MU3C_U3_PORT_MAX 4
....@@ -108,6 +130,7 @@
108130 struct device *dev;
109131 struct usb_hcd *hcd;
110132 struct mu3h_sch_bw_info *sch_array;
133
+ struct list_head bw_ep_chk_list;
111134 struct mu3c_ippc_regs __iomem *ippc_regs;
112135 bool has_ippc;
113136 int num_u2_ports;
....@@ -116,6 +139,7 @@
116139 struct regulator *vusb33;
117140 struct regulator *vbus;
118141 struct clk *sys_clk; /* sys and mac clock */
142
+ struct clk *xhci_clk;
119143 struct clk *ref_clk;
120144 struct clk *mcu_clk;
121145 struct clk *dma_clk;
....@@ -136,26 +160,13 @@
136160 return dev_get_drvdata(hcd->self.controller);
137161 }
138162
139
-#if IS_ENABLED(CONFIG_USB_XHCI_MTK)
140163 int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk);
141164 void xhci_mtk_sch_exit(struct xhci_hcd_mtk *mtk);
142
-int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
143
- struct usb_host_endpoint *ep);
144
-void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
145
- struct usb_host_endpoint *ep);
146
-
147
-#else
148
-static inline int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd,
149
- struct usb_device *udev, struct usb_host_endpoint *ep)
150
-{
151
- return 0;
152
-}
153
-
154
-static inline void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd,
155
- struct usb_device *udev, struct usb_host_endpoint *ep)
156
-{
157
-}
158
-
159
-#endif
165
+int xhci_mtk_add_ep(struct usb_hcd *hcd, struct usb_device *udev,
166
+ struct usb_host_endpoint *ep);
167
+int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
168
+ struct usb_host_endpoint *ep);
169
+int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
170
+void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
160171
161172 #endif /* _XHCI_MTK_H_ */