Commit aa9c2219 authored by Neal Liu's avatar Neal Liu Committed by Greg Kroah-Hartman
Browse files

usb: aspeed-vhub: support test mode feature

parent d693bbd4
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -110,17 +110,28 @@ static int ast_vhub_dev_feature(struct ast_vhub_dev *d,
				u16 wIndex, u16 wValue,
				bool is_set)
{
	u32 val;

	DDBG(d, "%s_FEATURE(dev val=%02x)\n",
	     is_set ? "SET" : "CLEAR", wValue);

	if (wValue != USB_DEVICE_REMOTE_WAKEUP)
		return std_req_driver;

	if (wValue == USB_DEVICE_REMOTE_WAKEUP) {
		d->wakeup_en = is_set;
		return std_req_complete;
	}

	if (wValue == USB_DEVICE_TEST_MODE) {
		val = readl(d->vhub->regs + AST_VHUB_CTRL);
		val &= ~GENMASK(10, 8);
		val |= VHUB_CTRL_SET_TEST_MODE((wIndex >> 8) & 0x7);
		writel(val, d->vhub->regs + AST_VHUB_CTRL);

		return std_req_complete;
	}

	return std_req_driver;
}

static int ast_vhub_ep_feature(struct ast_vhub_dev *d,
			       u16 wIndex, u16 wValue, bool is_set)
{
+17 −6
Original line number Diff line number Diff line
@@ -212,19 +212,30 @@ static int ast_vhub_hub_dev_feature(struct ast_vhub_ep *ep,
				    u16 wIndex, u16 wValue,
				    bool is_set)
{
	u32 val;

	EPDBG(ep, "%s_FEATURE(dev val=%02x)\n",
	      is_set ? "SET" : "CLEAR", wValue);

	if (wValue != USB_DEVICE_REMOTE_WAKEUP)
		return std_req_stall;

	if (wValue == USB_DEVICE_REMOTE_WAKEUP) {
		ep->vhub->wakeup_en = is_set;
		EPDBG(ep, "Hub remote wakeup %s\n",
		      is_set ? "enabled" : "disabled");
		return std_req_complete;
	}

	if (wValue == USB_DEVICE_TEST_MODE) {
		val = readl(ep->vhub->regs + AST_VHUB_CTRL);
		val &= ~GENMASK(10, 8);
		val |= VHUB_CTRL_SET_TEST_MODE((wIndex >> 8) & 0x7);
		writel(val, ep->vhub->regs + AST_VHUB_CTRL);

		return std_req_complete;
	}

	return std_req_stall;
}

static int ast_vhub_hub_ep_feature(struct ast_vhub_ep *ep,
				   u16 wIndex, u16 wValue,
				   bool is_set)