mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 13:08:42 +00:00
DM USB: xHCI: add microframe index(MFINDEX) register emulation support
Add microframe index register support, which is an important timing component for isochronous transport. Change-Id: I615664275b539cfb713d7795edd3f213b0302b92 Tracked-On: Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Reviewed-by: Liang Yang <liang3.yang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
a49d483cd0
commit
b9597d4fa8
@ -374,6 +374,7 @@ struct pci_xhci_vdev {
|
|||||||
int usb2_port_start;
|
int usb2_port_start;
|
||||||
int usb3_port_start;
|
int usb3_port_start;
|
||||||
uint8_t *native_assign_ports[USB_NATIVE_NUM_BUS];
|
uint8_t *native_assign_ports[USB_NATIVE_NUM_BUS];
|
||||||
|
struct timespec mf_prev_time; /* previous time of accessing MFINDEX */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* portregs and devices arrays are set up to start from idx=1 */
|
/* portregs and devices arrays are set up to start from idx=1 */
|
||||||
@ -3056,12 +3057,21 @@ static uint64_t
|
|||||||
pci_xhci_rtsregs_read(struct pci_xhci_vdev *xdev, uint64_t offset)
|
pci_xhci_rtsregs_read(struct pci_xhci_vdev *xdev, uint64_t offset)
|
||||||
{
|
{
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
struct timespec t;
|
||||||
|
uint64_t time_diff;
|
||||||
|
|
||||||
offset -= xdev->rtsoff;
|
offset -= xdev->rtsoff;
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
if (offset == XHCI_MFINDEX) {
|
if (offset == XHCI_MFINDEX) {
|
||||||
value = xdev->rtsregs.mfindex;
|
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||||
|
time_diff = (t.tv_sec - xdev->mf_prev_time.tv_sec) * 1000000
|
||||||
|
+ (t.tv_nsec - xdev->mf_prev_time.tv_nsec) / 1000;
|
||||||
|
xdev->mf_prev_time = t;
|
||||||
|
value = time_diff / 125;
|
||||||
|
|
||||||
|
if (value >= 1)
|
||||||
|
xdev->rtsregs.mfindex += value;
|
||||||
} else if (offset >= 0x20) {
|
} else if (offset >= 0x20) {
|
||||||
int item;
|
int item;
|
||||||
uint32_t *p;
|
uint32_t *p;
|
||||||
@ -3622,6 +3632,9 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
xdev->vid = XHCI_PCI_DEVICE_ID_DFLT;
|
xdev->vid = XHCI_PCI_DEVICE_ID_DFLT;
|
||||||
xdev->pid = XHCI_PCI_VENDOR_ID_DFLT;
|
xdev->pid = XHCI_PCI_VENDOR_ID_DFLT;
|
||||||
|
|
||||||
|
xdev->rtsregs.mfindex = 0;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &xdev->mf_prev_time);
|
||||||
|
|
||||||
/* discover devices */
|
/* discover devices */
|
||||||
error = pci_xhci_parse_opts(xdev, opts);
|
error = pci_xhci_parse_opts(xdev, opts);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user