From: Niklas Neronin <niklas.neronin@linux.intel.com>
To: mathias.nyman@linux.intel.com
Cc: linux-usb@vger.kernel.org,
Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH v3 10/12] usb: xhci: rework USB2 PORTHLPMC macros
Date: Thu, 3 Dec 2026 15:42:42 +0100 [thread overview]
Message-ID: <20261203144244.1680587-11-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20261203144244.1680587-1-niklas.neronin@linux.intel.com>
Replace the PORT_HIRDM(), PORT_L1_TIMEOUT() and PORT_BESLD() helpers
with GENMASK() based field masks, and use FIELD_PREP() to build the
PORTHLPMC value in xhci_calculate_usb2_hw_lpm_params().
While at it, document the PORTHLPMC register layout as described in
xHCI 5.4.11.2.
No functional change.
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
drivers/usb/host/xhci-port.h | 19 +++++++++++++------
drivers/usb/host/xhci.c | 3 ++-
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/xhci-port.h b/drivers/usb/host/xhci-port.h
index 664aa19f00b3..c0a23caad40e 100644
--- a/drivers/usb/host/xhci-port.h
+++ b/drivers/usb/host/xhci-port.h
@@ -173,13 +173,20 @@
/* bits 15:0 - Link Soft Error Count, if LSECC=1 else RsvdP */
/* bits 31:16 - RsvdP */
-/* USB2 Protocol PORTHLPMC */
-#define PORT_HIRDM(p)((p) & 3)
-#define PORT_L1_TIMEOUT(p)(((p) & 0xff) << 2)
-#define PORT_BESLD(p)(((p) & 0xf) << 10)
-
+/* USB2 Port Hardware LPM Control Register (PORTHLPMC), xHCI 5.4.11.2 */
+/* bits 1:0 - Host Initiated Resume Duration Mode (HIRDM) */
+#define PORT_HIRDM_MASK GENMASK(1, 0)
+/*
+ * bits 9:2 - L1 Timeout, L1 inactivity timer value.
+ * 0x00: 128 us (default).
+ * 0x01-0xff: 256 us to 65280 us, in 256 us increments.
+ */
+#define PORT_L1_TIMEOUT_MASK GENMASK(9, 2)
/* use 512 microseconds as USB2 LPM L1 default timeout. */
-#define XHCI_L1_TIMEOUT 512
+#define XHCI_L1_TIMEOUT 512
+/* bits 13:10 - Best Effort Service Latency Deep (BESLD) */
+#define PORT_BESLD_MASK GENMASK(13, 10)
+/* bits 31:14 - RsvdP */
/* Set default HIRD/BESL value to 4 (350/400us) for USB2 L1 LPM resume latency.
* Safe to use with mixed HIRD and BESL systems (host and device) and is used
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 7a42361608f6..c9a68c42d769 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4665,7 +4665,8 @@ static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
hirdm = 1;
}
- return PORT_BESLD(besld) | PORT_L1_TIMEOUT(l1) | PORT_HIRDM(hirdm);
+ return FIELD_PREP(PORT_BESLD_MASK, besld) | FIELD_PREP(PORT_L1_TIMEOUT_MASK, l1) |
+ FIELD_PREP(PORT_HIRDM_MASK, hirdm);
}
static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
--
2.50.1
next prev parent reply other threads:[~2026-12-03 14:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:42 [PATCH v3 00/12] usb: xhci: rework xHCI Port macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 01/12] usb: xhci: use BIT() for single bit port register flags Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 02/12] usb: xhci: rework Port Speed macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 03/12] usb: xhci: rework Port Link State macros Niklas Neronin
2026-12-03 14:59 ` sashiko-bot
2026-12-03 14:42 ` [PATCH v3 04/12] usb: xhci: rework Port Indicator Control macro Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 05/12] usb: xhci: rework USB3 PORTPMSC macros Niklas Neronin
2026-12-03 14:50 ` sashiko-bot
2026-12-03 14:42 ` [PATCH v3 06/12] usb: xhci: rework USB2 " Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 07/12] usb: xhci: rework USB3 PORTLI macros Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 08/12] usb: xhci: rework USB2 " Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 09/12] usb: xhci: document USB3 PORTHLPMC register layout Niklas Neronin
2026-12-03 14:42 ` Niklas Neronin [this message]
2026-12-03 14:42 ` [PATCH v3 11/12] usb: xhci: update port register bitfield comments for consistency Niklas Neronin
2026-12-03 14:42 ` [PATCH v3 12/12] usb: xhci: rename PORTSC field macros to xHCI spec abbreviations Niklas Neronin
2026-12-03 14:54 ` sashiko-bot
2026-12-03 14:59 ` [PATCH v3 00/12] usb: xhci: rework xHCI Port macros sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203144244.1680587-11-niklas.neronin@linux.intel.com \
--to=niklas.neronin@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.