DM USB: xHCI: support xHCI parameter option for extended capabilities.

This patch implements scalable xHCI parameter for extended capabilities.
For future supported platform, user can be easy to specify their
platform to emulate corresponding xHCI capabilities.

The new usage:
-s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]:[cap=x]
The old usage:
-s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]

Change-Id: Ie8ba056d57cac9446bcf3f39b342c7ac22245c61
Signed-off-by: Liang Yang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
Liang Yang 2018-05-30 13:37:31 +08:00 committed by lijinxia
parent 0679a81972
commit 72104468f2
1 changed files with 37 additions and 4 deletions

View File

@ -456,10 +456,12 @@ static int pci_xhci_xfer_complete(struct pci_xhci_vdev *xdev,
static inline int pci_xhci_is_valid_portnum(int n);
static int pci_xhci_parse_tablet(struct pci_xhci_vdev *xdev, char *opts);
static int pci_xhci_parse_log_level(struct pci_xhci_vdev *xdev, char *opts);
static int pci_xhci_parse_extcap(struct pci_xhci_vdev *xdev, char *opts);
static struct pci_xhci_option_elem xhci_option_table[] = {
{"tablet", pci_xhci_parse_tablet},
{"log", pci_xhci_parse_log_level}
{"log", pci_xhci_parse_log_level},
{"cap", pci_xhci_parse_extcap}
};
static int
@ -3265,10 +3267,11 @@ static void
pci_xhci_device_usage(char *opt)
{
static const char *usage_str = "usage:\r\n"
" -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]\r\n"
" -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]:[cap=x]\r\n"
" eg: -s 8,xhci,1-2,2-2\r\n"
" eg: -s 7,xhci,tablet:log=D\r\n"
" eg: -s 7,xhci,1-2,2-2:tablet\r\n"
" eg: -s 7,xhci,1-2,2-2:tablet:log=D:cap=apl\r\n"
" Note: please follow the board hardware design, assign the "
" ports according to the receptacle connection\r\n";
@ -3428,6 +3431,37 @@ errout:
return rc;
}
static int
pci_xhci_parse_extcap(struct pci_xhci_vdev *xdev, char *opts)
{
char *cap;
char *s, *o;
int rc = 0;
assert(opts);
cap = o = s = strdup(opts);
s = strchr(opts, '=');
if (!s) {
rc = -1;
goto errout;
}
cap = s + 1;
if (!strncmp(cap, "apl", 3)) {
xdev->excap_write = pci_xhci_apl_drdregs_write;
xdev->excap_ptr = excap_group_apl;
} else
rc = -2;
errout:
if (rc)
printf("USB: fail to set vendor capability, rc=%d\r\n", rc);
free(o);
return rc;
}
static int
pci_xhci_parse_opts(struct pci_xhci_vdev *xdev, char *opts)
{
@ -3541,8 +3575,7 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
xdev->usb2_port_start = (XHCI_MAX_DEVS/2) + 1;
xdev->usb3_port_start = 1;
xdev->excap_ptr = excap_group_apl;
xdev->excap_write = pci_xhci_apl_drdregs_write;
xdev->excap_ptr = excap_group_dft;
/* discover devices */
error = pci_xhci_parse_opts(xdev, opts);