linux/drivers/usb/host/xhci-mtk-sch.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2015 MediaTek Inc.
 * Author:
 *  Zhigang.Wei <[email protected]>
 *  Chunfeng.Yun <[email protected]>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>

#include "xhci.h"
#include "xhci-mtk.h"

#define SSP_BW_BOUNDARY
#define SS_BW_BOUNDARY
/* table 5-5. High-speed Isoc Transaction Limits in usb_20 spec */
#define HS_BW_BOUNDARY
/* usb2 spec section11.18.1: at most 188 FS bytes per microframe */
#define FS_PAYLOAD_MAX
#define LS_PAYLOAD_MAX
/* section 11.18.1, per fs frame */
#define FS_BW_BOUNDARY
#define LS_BW_BOUNDARY

/*
 * max number of microframes for split transfer, assume extra-cs budget is 0
 * for fs isoc in : 1 ss + 1 idle + 6 cs (roundup(1023/188))
 */
#define TT_MICROFRAMES_MAX
/* offset from SS for fs/ls isoc/intr ep (ss + idle) */
#define CS_OFFSET

#define DBG_BUF_EN

/* schedule error type */
#define ESCH_SS_Y6
#define ESCH_SS_OVERLAP
#define ESCH_CS_OVERFLOW
#define ESCH_BW_OVERFLOW
#define ESCH_FIXME

/* mtk scheduler bitmasks */
#define EP_BPKTS(p)
#define EP_BCSCOUNT(p)
#define EP_BBM(p)
#define EP_BOFFSET(p)
#define EP_BREPEAT(p)

static char *sch_error_string(int err_num)
{}

static int is_fs_or_ls(enum usb_device_speed speed)
{}

static const char *
decode_ep(struct usb_host_endpoint *ep, enum usb_device_speed speed)
{}

static u32 get_bw_boundary(enum usb_device_speed speed)
{}

/*
* get the bandwidth domain which @ep belongs to.
*
* the bandwidth domain array is saved to @sch_array of struct xhci_hcd_mtk,
* each HS root port is treated as a single bandwidth domain,
* but each SS root port is treated as two bandwidth domains, one for IN eps,
* one for OUT eps.
*/
static struct mu3h_sch_bw_info *
get_bw_info(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
	    struct usb_host_endpoint *ep)
{}

static u32 get_esit(struct xhci_ep_ctx *ep_ctx)
{}

static struct mu3h_sch_tt *find_tt(struct usb_device *udev)
{}

/* Release the TT above udev, if it's not in use */
static void drop_tt(struct usb_device *udev)
{}

static struct mu3h_sch_ep_info *
create_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
	      struct usb_host_endpoint *ep, struct xhci_ep_ctx *ep_ctx)
{}

static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
			   struct mu3h_sch_ep_info *sch_ep)
{}

/* Get maximum bandwidth when we schedule at offset slot. */
static u32 get_max_bw(struct mu3h_sch_bw_info *sch_bw,
	struct mu3h_sch_ep_info *sch_ep, u32 offset)
{}

/*
 * for OUT: get first SS consumed bw;
 * for IN: get first CS consumed bw;
 */
static u16 get_fs_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
{}

static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
	struct mu3h_sch_ep_info *sch_ep, bool used)
{}

static int check_ls_budget_microframes(struct mu3h_sch_ep_info *sch_ep, int offset)
{}

static int check_fs_budget_microframes(struct mu3h_sch_ep_info *sch_ep, int offset)
{}

static int check_fs_budget_frames(struct mu3h_sch_ep_info *sch_ep, int offset)
{}

static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
{}

static int check_ss_and_cs(struct mu3h_sch_ep_info *sch_ep, u32 offset)
{}

/*
 * when isoc-out transfers 188 bytes in a uframe, and send isoc/intr's
 * ss token in the uframe, may cause 'bit stuff error' in downstream
 * port;
 * when isoc-out transfer less than 188 bytes in a uframe, shall send
 * isoc-in's ss after isoc-out's ss (but hw can't ensure the sequence,
 * so just avoid overlap).
 */
static int check_isoc_ss_overlap(struct mu3h_sch_ep_info *sch_ep, u32 offset)
{}

static int check_sch_tt_budget(struct mu3h_sch_ep_info *sch_ep, u32 offset)
{}

/* allocate microframes in the ls/fs frame */
static int alloc_sch_portion_of_frame(struct mu3h_sch_ep_info *sch_ep)
{}

static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
{}

static int load_ep_bw(struct mu3h_sch_bw_info *sch_bw,
		      struct mu3h_sch_ep_info *sch_ep, bool loaded)
{}

/* allocate microframes for hs/ss/ssp */
static int alloc_sch_microframes(struct mu3h_sch_ep_info *sch_ep)
{}

static int check_sch_bw(struct mu3h_sch_ep_info *sch_ep)
{}

static void destroy_sch_ep(struct xhci_hcd_mtk *mtk, struct usb_device *udev,
			   struct mu3h_sch_ep_info *sch_ep)
{}

static bool need_bw_sch(struct usb_device *udev,
			struct usb_host_endpoint *ep)
{}

int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk)
{}

void xhci_mtk_sch_exit(struct xhci_hcd_mtk *mtk)
{}

static int add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
			struct usb_host_endpoint *ep)
{}

static void drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
			  struct usb_host_endpoint *ep)
{}

int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
{}

void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
{}

int xhci_mtk_add_ep(struct usb_hcd *hcd, struct usb_device *udev,
		    struct usb_host_endpoint *ep)
{}

int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device *udev,
		     struct usb_host_endpoint *ep)
{}