public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms
@ 2021-04-06 10:10 Stefan Roese
  2021-04-06 10:10 ` [PATCH 2/3] usb: xhci: Add missing xhci_readl() Stefan Roese
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Roese @ 2021-04-06 10:10 UTC (permalink / raw)
  To: u-boot

From: Aaron Williams <awilliams@marvell.com>

Add missing endianness conversions to usb_get_port_status(). This
(amongst others) is necessary to enable the use of USB 3 hubs on
big-endian platforms like MIPS Octeon.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Chandrakala Chavva <cchavva@marvell.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
---
 common/usb_hub.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 3d856e7de792..ba11a188ca64 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -144,7 +144,8 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data)
 
 	if (!usb_hub_is_root_hub(dev->dev) && usb_hub_is_superspeed(dev)) {
 		struct usb_port_status *status = (struct usb_port_status *)data;
-		u16 tmp = (status->wPortStatus) & USB_SS_PORT_STAT_MASK;
+		u16 tmp = le16_to_cpu(status->wPortStatus) &
+			USB_SS_PORT_STAT_MASK;
 
 		if (status->wPortStatus & USB_SS_PORT_STAT_POWER)
 			tmp |= USB_PORT_STAT_POWER;
@@ -152,7 +153,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data)
 		    USB_SS_PORT_STAT_SPEED_5GBPS)
 			tmp |= USB_PORT_STAT_SUPER_SPEED;
 
-		status->wPortStatus = tmp;
+		status->wPortStatus = cpu_to_le16(tmp);
 	}
 #endif
 
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] usb: xhci: Add missing xhci_readl()
  2021-04-06 10:10 [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Stefan Roese
@ 2021-04-06 10:10 ` Stefan Roese
  2021-04-06 10:10 ` [PATCH 3/3] usb: xhci: Make debug output better readable and checkpatch clean Stefan Roese
  2021-04-06 14:41 ` [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Marek Vasut
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2021-04-06 10:10 UTC (permalink / raw)
  To: u-boot

From: Aaron Williams <awilliams@marvell.com>

Accessing the xHCI controller registers should be done via the
xhci_readl/writel functions. This patch adds this to a few missing
places.

Signed-off-by: Aaron Williams <awilliams@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Chandrakala Chavva <cchavva@marvell.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/host/xhci-mem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 83147d51b5c0..1c11c2e7e04d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -434,9 +434,9 @@ static struct xhci_container_ctx
 	BUG_ON((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT));
 	ctx->type = type;
 	ctx->size = (MAX_EP_CTX_NUM + 1) *
-			CTX_SIZE(readl(&ctrl->hccr->cr_hccparams));
+			CTX_SIZE(xhci_readl(&ctrl->hccr->cr_hccparams));
 	if (type == XHCI_CTX_TYPE_INPUT)
-		ctx->size += CTX_SIZE(readl(&ctrl->hccr->cr_hccparams));
+		ctx->size += CTX_SIZE(xhci_readl(&ctrl->hccr->cr_hccparams));
 
 	ctx->bytes = xhci_malloc(ctx->size);
 
@@ -636,7 +636,7 @@ struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_ctrl *ctrl,
 		return (struct xhci_slot_ctx *)ctx->bytes;
 
 	return (struct xhci_slot_ctx *)
-		(ctx->bytes + CTX_SIZE(readl(&ctrl->hccr->cr_hccparams)));
+		(ctx->bytes + CTX_SIZE(xhci_readl(&ctrl->hccr->cr_hccparams)));
 }
 
 /**
@@ -658,7 +658,7 @@ struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_ctrl *ctrl,
 
 	return (struct xhci_ep_ctx *)
 		(ctx->bytes +
-		(ep_index * CTX_SIZE(readl(&ctrl->hccr->cr_hccparams))));
+		(ep_index * CTX_SIZE(xhci_readl(&ctrl->hccr->cr_hccparams))));
 }
 
 /**
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] usb: xhci: Make debug output better readable and checkpatch clean
  2021-04-06 10:10 [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Stefan Roese
  2021-04-06 10:10 ` [PATCH 2/3] usb: xhci: Add missing xhci_readl() Stefan Roese
@ 2021-04-06 10:10 ` Stefan Roese
  2021-04-06 14:41 ` [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Marek Vasut
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2021-04-06 10:10 UTC (permalink / raw)
  To: u-boot

This change makes debugging a bit easier as the output is better
readable with the added space. The explicit le16_to_cpu() is not
needed in the output. Also this patch moves the strings into one line
to make the patch checkpatch clean.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Aaron Williams <awilliams@marvell.com>
Cc: Chandrakala Chavva <cchavva@marvell.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/host/xhci-ring.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 46c137f85781..35bd5cd29e15 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -849,12 +849,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 		}
 	}
 
-	debug("req->requesttype = %d, req->request = %d,"
-		"le16_to_cpu(req->value) = %d,"
-		"le16_to_cpu(req->index) = %d,"
-		"le16_to_cpu(req->length) = %d\n",
-		req->requesttype, req->request, le16_to_cpu(req->value),
-		le16_to_cpu(req->index), le16_to_cpu(req->length));
+	debug("req->requesttype = %d, req->request = %d, req->value = %d, req->index = %d, req->length = %d\n",
+	      req->requesttype, req->request, le16_to_cpu(req->value),
+	      le16_to_cpu(req->index), le16_to_cpu(req->length));
 
 	trb_fields[0] = req->requesttype | req->request << 8 |
 				le16_to_cpu(req->value) << 16;
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms
  2021-04-06 10:10 [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Stefan Roese
  2021-04-06 10:10 ` [PATCH 2/3] usb: xhci: Add missing xhci_readl() Stefan Roese
  2021-04-06 10:10 ` [PATCH 3/3] usb: xhci: Make debug output better readable and checkpatch clean Stefan Roese
@ 2021-04-06 14:41 ` Marek Vasut
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2021-04-06 14:41 UTC (permalink / raw)
  To: u-boot

On 4/6/21 12:10 PM, Stefan Roese wrote:
> From: Aaron Williams <awilliams@marvell.com>
> 
> Add missing endianness conversions to usb_get_port_status(). This
> (amongst others) is necessary to enable the use of USB 3 hubs on
> big-endian platforms like MIPS Octeon.

Applied all, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-06 14:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-06 10:10 [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Stefan Roese
2021-04-06 10:10 ` [PATCH 2/3] usb: xhci: Add missing xhci_readl() Stefan Roese
2021-04-06 10:10 ` [PATCH 3/3] usb: xhci: Make debug output better readable and checkpatch clean Stefan Roese
2021-04-06 14:41 ` [PATCH 1/3] usb: hub: Fix usb_get_port_status() for big-endian platforms Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox