| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * Copyright (c) 2015 MediaTek Inc. |
|---|
| 4 | 4 | * Author: |
|---|
| .. | .. |
|---|
| 18 | 18 | * bandwidth to it. |
|---|
| 19 | 19 | */ |
|---|
| 20 | 20 | #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 | +}; |
|---|
| 21 | 30 | |
|---|
| 22 | 31 | /** |
|---|
| 23 | 32 | * struct mu3h_sch_bw_info: schedule information for bandwidth domain |
|---|
| .. | .. |
|---|
| 41 | 50 | * (@repeat==1) scheduled within the interval |
|---|
| 42 | 51 | * @bw_cost_per_microframe: bandwidth cost per microframe |
|---|
| 43 | 52 | * @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 |
|---|
| 44 | 57 | * @ep: address of usb_host_endpoint struct |
|---|
| 58 | + * @allocated: the bandwidth is aready allocated from bus_bw |
|---|
| 45 | 59 | * @offset: which uframe of the interval that transfer should be |
|---|
| 46 | 60 | * scheduled first time within the interval |
|---|
| 47 | 61 | * @repeat: the time gap between two uframes that transfers are |
|---|
| .. | .. |
|---|
| 57 | 71 | * times; 1: distribute the (bMaxBurst+1)*(Mult+1) packets |
|---|
| 58 | 72 | * according to @pkts and @repeat. normal mode is used by |
|---|
| 59 | 73 | * default |
|---|
| 74 | + * @bw_budget_table: table to record bandwidth budget per microframe |
|---|
| 60 | 75 | */ |
|---|
| 61 | 76 | struct mu3h_sch_ep_info { |
|---|
| 62 | 77 | u32 esit; |
|---|
| 63 | 78 | u32 num_budget_microframes; |
|---|
| 64 | 79 | u32 bw_cost_per_microframe; |
|---|
| 65 | 80 | 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; |
|---|
| 67 | 88 | /* |
|---|
| 68 | 89 | * mtk xHCI scheduling information put into reserved DWs |
|---|
| 69 | 90 | * in ep context |
|---|
| .. | .. |
|---|
| 73 | 94 | u32 pkts; |
|---|
| 74 | 95 | u32 cs_count; |
|---|
| 75 | 96 | u32 burst_mode; |
|---|
| 97 | + u32 bw_budget_table[]; |
|---|
| 76 | 98 | }; |
|---|
| 77 | 99 | |
|---|
| 78 | 100 | #define MU3C_U3_PORT_MAX 4 |
|---|
| .. | .. |
|---|
| 108 | 130 | struct device *dev; |
|---|
| 109 | 131 | struct usb_hcd *hcd; |
|---|
| 110 | 132 | struct mu3h_sch_bw_info *sch_array; |
|---|
| 133 | + struct list_head bw_ep_chk_list; |
|---|
| 111 | 134 | struct mu3c_ippc_regs __iomem *ippc_regs; |
|---|
| 112 | 135 | bool has_ippc; |
|---|
| 113 | 136 | int num_u2_ports; |
|---|
| .. | .. |
|---|
| 116 | 139 | struct regulator *vusb33; |
|---|
| 117 | 140 | struct regulator *vbus; |
|---|
| 118 | 141 | struct clk *sys_clk; /* sys and mac clock */ |
|---|
| 142 | + struct clk *xhci_clk; |
|---|
| 119 | 143 | struct clk *ref_clk; |
|---|
| 120 | 144 | struct clk *mcu_clk; |
|---|
| 121 | 145 | struct clk *dma_clk; |
|---|
| .. | .. |
|---|
| 136 | 160 | return dev_get_drvdata(hcd->self.controller); |
|---|
| 137 | 161 | } |
|---|
| 138 | 162 | |
|---|
| 139 | | -#if IS_ENABLED(CONFIG_USB_XHCI_MTK) |
|---|
| 140 | 163 | int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk); |
|---|
| 141 | 164 | 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); |
|---|
| 160 | 171 | |
|---|
| 161 | 172 | #endif /* _XHCI_MTK_H_ */ |
|---|