All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Neronin <niklas.neronin@linux.intel.com>
To: mathias.nyman@linux.intel.com
Cc: linux-usb@vger.kernel.org, michal.pecio@gmail.com,
	Niklas Neronin <niklas.neronin@linux.intel.com>
Subject: [PATCH v2 09/13] usb: xhci: simplify Max Scratchpad buffer macros
Date: Thu, 13 Nov 2025 13:56:36 +0100	[thread overview]
Message-ID: <20251113125640.2875608-10-niklas.neronin@linux.intel.com> (raw)
In-Reply-To: <20251113125640.2875608-1-niklas.neronin@linux.intel.com>

Max Scratchpad Buffers consist of two bit-fields:
bits 25:21 - Max Scratchpad Buffers High, 5 Most significant bits
bits 27:31 - Max Scratchpad Buffers Low, 5 Least significant bits
Combined they create the Max Scratchpad Buffers value.

Add two new macros, 'HCS_MAX_SP_HI' and 'HCS_MAX_SP_LO', to separately
extract the high and low parts of the Max Scratchpad Buffers. These are
then combined using 'HCS_MAX_SCRATCHPAD' macro. This change simplifies
the code and makes it similar to other split value register macros in the
xhci driver.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
 drivers/usb/host/xhci-caps.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-caps.h b/drivers/usb/host/xhci-caps.h
index e772d5f30d36..af47aebc5ba8 100644
--- a/drivers/usb/host/xhci-caps.h
+++ b/drivers/usb/host/xhci-caps.h
@@ -37,9 +37,11 @@
 #define HCS_ERST_MAX(p)		(((p) >> 4) & 0xf)
 /* bits 20:8 - Rsvd */
 /* bits 25:21 - Max Scratchpad Buffers (Hi), 5 Most significant bits */
+#define HCS_MAX_SP_HI(p)	(((p) >> 21) & 0x1f)
 /* bit 26 - Scratchpad restore, for save/restore HW state */
 /* bits 31:27 - Max Scratchpad Buffers (Lo), 5 Least significant bits */
-#define HCS_MAX_SCRATCHPAD(p)   ((((p) >> 16) & 0x3e0) | (((p) >> 27) & 0x1f))
+#define HCS_MAX_SP_LO(p)	(((p) >> 27) & 0x1f)
+#define HCS_MAX_SCRATCHPAD(p)	(HCS_MAX_SP_HI(p) << 5 | HCS_MAX_SP_LO(p))
 
 /* HCSPARAMS3 - hcs_params3 - bitmasks */
 /* bits 7:0 - U1 Device Exit Latency, Max U1 to U0 latency for the roothub ports */
-- 
2.50.1


  parent reply	other threads:[~2025-11-13 12:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 12:56 [PATCH v2 00/13] usb: xhci: Host Controller Capability Registers rework Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 01/13] usb: xhci: remove deprecated TODO comment Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 02/13] usb: xhci: remove unused trace operation and argument Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 03/13] usb: xhci: use cached HCSPARAMS1 value Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 04/13] usb: xhci: simplify handling of Structural Parameters 1 values Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 05/13] usb: xhci: limit number of ports to 127 Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 06/13] usb: xhci: limit number of interrupts to 128 Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 07/13] usb: xhci: improve xhci-caps.h comments Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 08/13] usb: xhci: simplify Isochronous Scheduling Threshold handling Niklas Neronin
2025-11-13 12:56 ` Niklas Neronin [this message]
2025-11-13 12:56 ` [PATCH v2 10/13] usb: xhci: drop xhci-caps.h dependence on xhci-ext-caps.h Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 11/13] usb: xhci: standardize single bit-field macros Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 12/13] usb: xhci: standardize multi " Niklas Neronin
2025-11-13 12:56 ` [PATCH v2 13/13] usb: xhci: use 64-bit Addressing Capability macro Niklas Neronin
2025-11-19 14:00 ` [PATCH v2 00/13] usb: xhci: Host Controller Capability Registers rework Mathias Nyman

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=20251113125640.2875608-10-niklas.neronin@linux.intel.com \
    --to=niklas.neronin@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=michal.pecio@gmail.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.