1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2015 MediaTek Inc.
5 * Zhigang.Wei <zhigang.wei@mediatek.com>
6 * Chunfeng.Yun <chunfeng.yun@mediatek.com>
15 * To simplify scheduler algorithm, set a upper limit for ESIT,
16 * if a synchromous ep's ESIT is larger than @XHCI_MTK_MAX_ESIT,
17 * round down to the limit value, that means allocating more
20 #define XHCI_MTK_MAX_ESIT 64
23 * @split_bit_map: used to avoid split microframes overlay
24 * @ep_list: Endpoints using this TT
25 * @usb_tt: usb TT related
26 * @tt_port: TT port number
29 DECLARE_BITMAP(split_bit_map
, XHCI_MTK_MAX_ESIT
);
30 struct list_head ep_list
;
31 struct usb_tt
*usb_tt
;
36 * struct mu3h_sch_bw_info: schedule information for bandwidth domain
38 * @bus_bw: array to keep track of bandwidth already used at each uframes
39 * @bw_ep_list: eps in the bandwidth domain
41 * treat a HS root port as a bandwidth domain, but treat a SS root port as
42 * two bandwidth domains, one for IN eps and another for OUT eps.
44 struct mu3h_sch_bw_info
{
45 u32 bus_bw
[XHCI_MTK_MAX_ESIT
];
46 struct list_head bw_ep_list
;
50 * struct mu3h_sch_ep_info: schedule information for endpoint
52 * @esit: unit is 125us, equal to 2 << Interval field in ep-context
53 * @num_budget_microframes: number of continuous uframes
54 * (@repeat==1) scheduled within the interval
55 * @bw_cost_per_microframe: bandwidth cost per microframe
56 * @endpoint: linked into bandwidth domain which it belongs to
57 * @tt_endpoint: linked into mu3h_sch_tt's list which it belongs to
58 * @sch_tt: mu3h_sch_tt linked into
59 * @ep_type: endpoint type
60 * @maxpkt: max packet size of endpoint
61 * @ep: address of usb_host_endpoint struct
62 * @offset: which uframe of the interval that transfer should be
63 * scheduled first time within the interval
64 * @repeat: the time gap between two uframes that transfers are
65 * scheduled within a interval. in the simple algorithm, only
66 * assign 0 or 1 to it; 0 means using only one uframe in a
67 * interval, and 1 means using @num_budget_microframes
69 * @pkts: number of packets to be transferred in the scheduled uframes
70 * @cs_count: number of CS that host will trigger
71 * @burst_mode: burst mode for scheduling. 0: normal burst mode,
72 * distribute the bMaxBurst+1 packets for a single burst
73 * according to @pkts and @repeat, repeate the burst multiple
74 * times; 1: distribute the (bMaxBurst+1)*(Mult+1) packets
75 * according to @pkts and @repeat. normal mode is used by
77 * @bw_budget_table: table to record bandwidth budget per microframe
79 struct mu3h_sch_ep_info
{
81 u32 num_budget_microframes
;
82 u32 bw_cost_per_microframe
;
83 struct list_head endpoint
;
84 struct list_head tt_endpoint
;
85 struct mu3h_sch_tt
*sch_tt
;
90 * mtk xHCI scheduling information put into reserved DWs
98 u32 bw_budget_table
[];
101 #define MU3C_U3_PORT_MAX 4
102 #define MU3C_U2_PORT_MAX 5
105 * struct mu3c_ippc_regs: MTK ssusb ip port control registers
106 * @ip_pw_ctr0~3: ip power and clock control registers
107 * @ip_pw_sts1~2: ip power and clock status registers
108 * @ip_xhci_cap: ip xHCI capability register
109 * @u3_ctrl_p[x]: ip usb3 port x control register, only low 4bytes are used
110 * @u2_ctrl_p[x]: ip usb2 port x control register, only low 4bytes are used
111 * @u2_phy_pll: usb2 phy pll control register
113 struct mu3c_ippc_regs
{
123 __le64 u3_ctrl_p
[MU3C_U3_PORT_MAX
];
124 __le64 u2_ctrl_p
[MU3C_U2_PORT_MAX
];
127 __le32 reserved3
[33]; /* 0x80 ~ 0xff */
130 struct xhci_hcd_mtk
{
133 struct mu3h_sch_bw_info
*sch_array
;
134 struct mu3c_ippc_regs __iomem
*ippc_regs
;
139 struct regulator
*vusb33
;
140 struct regulator
*vbus
;
141 struct clk
*sys_clk
; /* sys and mac clock */
142 struct clk
*xhci_clk
;
146 struct regmap
*pericfg
;
150 /* usb remote wakeup */
157 static inline struct xhci_hcd_mtk
*hcd_to_mtk(struct usb_hcd
*hcd
)
159 return dev_get_drvdata(hcd
->self
.controller
);
162 #if IS_ENABLED(CONFIG_USB_XHCI_MTK)
163 int xhci_mtk_sch_init(struct xhci_hcd_mtk
*mtk
);
164 void xhci_mtk_sch_exit(struct xhci_hcd_mtk
*mtk
);
165 int xhci_mtk_add_ep_quirk(struct usb_hcd
*hcd
, struct usb_device
*udev
,
166 struct usb_host_endpoint
*ep
);
167 void xhci_mtk_drop_ep_quirk(struct usb_hcd
*hcd
, struct usb_device
*udev
,
168 struct usb_host_endpoint
*ep
);
171 static inline int xhci_mtk_add_ep_quirk(struct usb_hcd
*hcd
,
172 struct usb_device
*udev
, struct usb_host_endpoint
*ep
)
177 static inline void xhci_mtk_drop_ep_quirk(struct usb_hcd
*hcd
,
178 struct usb_device
*udev
, struct usb_host_endpoint
*ep
)
184 #endif /* _XHCI_MTK_H_ */