mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
xhci: Add ZHAOXIN xHCI host U1/U2 feature support
Add U1/U2 feature support of xHCI for ZHAOXIN. Since both INTEL and ZHAOXIN need to check the tier where the device is located to determine whether to enabled U1/U2, remove the previous INTEL U1/U2 tier policy and add common policy in xhci_check_tier_policy. If vendor has specific U1/U2 enable policy,quirks can be add to declare. Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Message-ID: <20230602144009.1225632-12-mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d9b0328d0b
commit
d5e234ff08
2 changed files with 21 additions and 27 deletions
|
@ -523,6 +523,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
|
||||||
|
|
||||||
if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN) {
|
if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN) {
|
||||||
xhci->quirks |= XHCI_ZHAOXIN_HOST;
|
xhci->quirks |= XHCI_ZHAOXIN_HOST;
|
||||||
|
xhci->quirks |= XHCI_LPM_SUPPORT;
|
||||||
|
|
||||||
if (pdev->device == 0x9202) {
|
if (pdev->device == 0x9202) {
|
||||||
xhci->quirks |= XHCI_RESET_ON_RESUME;
|
xhci->quirks |= XHCI_RESET_ON_RESUME;
|
||||||
|
|
|
@ -4605,7 +4605,7 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xhci->quirks & XHCI_INTEL_HOST)
|
if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST))
|
||||||
timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
|
timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
|
||||||
else
|
else
|
||||||
timeout_ns = udev->u1_params.sel;
|
timeout_ns = udev->u1_params.sel;
|
||||||
|
@ -4669,7 +4669,7 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xhci->quirks & XHCI_INTEL_HOST)
|
if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST))
|
||||||
timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
|
timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
|
||||||
else
|
else
|
||||||
timeout_ns = udev->u2_params.sel;
|
timeout_ns = udev->u2_params.sel;
|
||||||
|
@ -4741,35 +4741,28 @@ static int xhci_update_timeout_for_interface(struct xhci_hcd *xhci,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xhci_check_intel_tier_policy(struct usb_device *udev,
|
|
||||||
enum usb3_link_state state)
|
|
||||||
{
|
|
||||||
struct usb_device *parent;
|
|
||||||
unsigned int num_hubs;
|
|
||||||
|
|
||||||
/* Don't enable U1 if the device is on a 2nd tier hub or lower. */
|
|
||||||
for (parent = udev->parent, num_hubs = 0; parent->parent;
|
|
||||||
parent = parent->parent)
|
|
||||||
num_hubs++;
|
|
||||||
|
|
||||||
if (num_hubs < 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dev_dbg(&udev->dev, "Disabling U1/U2 link state for device"
|
|
||||||
" below second-tier hub.\n");
|
|
||||||
dev_dbg(&udev->dev, "Plug device into first-tier hub "
|
|
||||||
"to decrease power consumption.\n");
|
|
||||||
return -E2BIG;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int xhci_check_tier_policy(struct xhci_hcd *xhci,
|
static int xhci_check_tier_policy(struct xhci_hcd *xhci,
|
||||||
struct usb_device *udev,
|
struct usb_device *udev,
|
||||||
enum usb3_link_state state)
|
enum usb3_link_state state)
|
||||||
{
|
{
|
||||||
if (xhci->quirks & XHCI_INTEL_HOST)
|
struct usb_device *parent = udev->parent;
|
||||||
return xhci_check_intel_tier_policy(udev, state);
|
int tier = 1; /* roothub is tier1 */
|
||||||
else
|
|
||||||
|
while (parent) {
|
||||||
|
parent = parent->parent;
|
||||||
|
tier++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xhci->quirks & XHCI_INTEL_HOST && tier > 3)
|
||||||
|
goto fail;
|
||||||
|
if (xhci->quirks & XHCI_ZHAOXIN_HOST && tier > 2)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
fail:
|
||||||
|
dev_dbg(&udev->dev, "Tier policy prevents U1/U2 LPM states for devices at tier %d\n",
|
||||||
|
tier);
|
||||||
|
return -E2BIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the U1 or U2 timeout that should be enabled.
|
/* Returns the U1 or U2 timeout that should be enabled.
|
||||||
|
|
Loading…
Reference in a new issue