提交 4d79e042 编写于 作者: C Chunfeng Yun 提交者: Felipe Balbi

usb: mtu3: add support for usb3.1 IP

Support SuperSpeedPlus for usb3.1 device IP
Signed-off-by: NChunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
上级 c776f2c3
...@@ -94,6 +94,7 @@ enum mtu3_speed { ...@@ -94,6 +94,7 @@ enum mtu3_speed {
MTU3_SPEED_FULL = 1, MTU3_SPEED_FULL = 1,
MTU3_SPEED_HIGH = 3, MTU3_SPEED_HIGH = 3,
MTU3_SPEED_SUPER = 4, MTU3_SPEED_SUPER = 4,
MTU3_SPEED_SUPER_PLUS = 5,
}; };
/** /**
......
...@@ -237,7 +237,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set) ...@@ -237,7 +237,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set)
void mtu3_dev_on_off(struct mtu3 *mtu, int is_on) void mtu3_dev_on_off(struct mtu3 *mtu, int is_on)
{ {
if (mtu->is_u3_ip && (mtu->max_speed == USB_SPEED_SUPER)) if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER)
mtu3_ss_func_set(mtu, is_on); mtu3_ss_func_set(mtu, is_on);
else else
mtu3_hs_softconn_set(mtu, is_on); mtu3_hs_softconn_set(mtu, is_on);
...@@ -547,6 +547,9 @@ static void mtu3_set_speed(struct mtu3 *mtu) ...@@ -547,6 +547,9 @@ static void mtu3_set_speed(struct mtu3 *mtu)
mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN); mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN);
/* HS/FS detected by HW */ /* HS/FS detected by HW */
mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE); mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE);
} else if (mtu->max_speed == USB_SPEED_SUPER) {
mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0),
SSUSB_U3_PORT_SSP_SPEED);
} }
dev_info(mtu->dev, "max_speed: %s\n", dev_info(mtu->dev, "max_speed: %s\n",
...@@ -624,6 +627,10 @@ static irqreturn_t mtu3_link_isr(struct mtu3 *mtu) ...@@ -624,6 +627,10 @@ static irqreturn_t mtu3_link_isr(struct mtu3 *mtu)
udev_speed = USB_SPEED_SUPER; udev_speed = USB_SPEED_SUPER;
maxpkt = 512; maxpkt = 512;
break; break;
case MTU3_SPEED_SUPER_PLUS:
udev_speed = USB_SPEED_SUPER_PLUS;
maxpkt = 512;
break;
default: default:
udev_speed = USB_SPEED_UNKNOWN; udev_speed = USB_SPEED_UNKNOWN;
break; break;
...@@ -825,14 +832,15 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) ...@@ -825,14 +832,15 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
case USB_SPEED_FULL: case USB_SPEED_FULL:
case USB_SPEED_HIGH: case USB_SPEED_HIGH:
case USB_SPEED_SUPER: case USB_SPEED_SUPER:
case USB_SPEED_SUPER_PLUS:
break; break;
default: default:
dev_err(dev, "invalid max_speed: %s\n", dev_err(dev, "invalid max_speed: %s\n",
usb_speed_string(mtu->max_speed)); usb_speed_string(mtu->max_speed));
/* fall through */ /* fall through */
case USB_SPEED_UNKNOWN: case USB_SPEED_UNKNOWN:
/* default as SS */ /* default as SSP */
mtu->max_speed = USB_SPEED_SUPER; mtu->max_speed = USB_SPEED_SUPER_PLUS;
break; break;
} }
......
...@@ -89,6 +89,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep) ...@@ -89,6 +89,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
switch (mtu->g.speed) { switch (mtu->g.speed) {
case USB_SPEED_SUPER: case USB_SPEED_SUPER:
case USB_SPEED_SUPER_PLUS:
if (usb_endpoint_xfer_int(desc) || if (usb_endpoint_xfer_int(desc) ||
usb_endpoint_xfer_isoc(desc)) { usb_endpoint_xfer_isoc(desc)) {
interval = desc->bInterval; interval = desc->bInterval;
...@@ -456,7 +457,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget) ...@@ -456,7 +457,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget)
return -EOPNOTSUPP; return -EOPNOTSUPP;
spin_lock_irqsave(&mtu->lock, flags); spin_lock_irqsave(&mtu->lock, flags);
if (mtu->g.speed == USB_SPEED_SUPER) { if (mtu->g.speed >= USB_SPEED_SUPER) {
mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT);
} else { } else {
mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
......
...@@ -212,8 +212,8 @@ ep0_get_status(struct mtu3 *mtu, const struct usb_ctrlrequest *setup) ...@@ -212,8 +212,8 @@ ep0_get_status(struct mtu3 *mtu, const struct usb_ctrlrequest *setup)
case USB_RECIP_DEVICE: case USB_RECIP_DEVICE:
result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED; result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED;
result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP;
/* superspeed only */
if (mtu->g.speed == USB_SPEED_SUPER) { if (mtu->g.speed >= USB_SPEED_SUPER) {
result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED; result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED;
result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED; result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED;
} }
...@@ -329,8 +329,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu, ...@@ -329,8 +329,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
handled = handle_test_mode(mtu, setup); handled = handle_test_mode(mtu, setup);
break; break;
case USB_DEVICE_U1_ENABLE: case USB_DEVICE_U1_ENABLE:
if (mtu->g.speed != USB_SPEED_SUPER || if (mtu->g.speed < USB_SPEED_SUPER ||
mtu->g.state != USB_STATE_CONFIGURED) mtu->g.state != USB_STATE_CONFIGURED)
break; break;
lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
...@@ -344,8 +344,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu, ...@@ -344,8 +344,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
handled = 1; handled = 1;
break; break;
case USB_DEVICE_U2_ENABLE: case USB_DEVICE_U2_ENABLE:
if (mtu->g.speed != USB_SPEED_SUPER || if (mtu->g.speed < USB_SPEED_SUPER ||
mtu->g.state != USB_STATE_CONFIGURED) mtu->g.state != USB_STATE_CONFIGURED)
break; break;
lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL); lpc = mtu3_readl(mbase, U3D_LINK_POWER_CONTROL);
...@@ -384,8 +384,8 @@ static int ep0_handle_feature(struct mtu3 *mtu, ...@@ -384,8 +384,8 @@ static int ep0_handle_feature(struct mtu3 *mtu,
break; break;
case USB_RECIP_INTERFACE: case USB_RECIP_INTERFACE:
/* superspeed only */ /* superspeed only */
if ((value == USB_INTRF_FUNC_SUSPEND) if (value == USB_INTRF_FUNC_SUSPEND &&
&& (mtu->g.speed == USB_SPEED_SUPER)) { mtu->g.speed >= USB_SPEED_SUPER) {
/* /*
* forward the request because function drivers * forward the request because function drivers
* should handle it * should handle it
......
...@@ -467,6 +467,7 @@ ...@@ -467,6 +467,7 @@
#define SSUSB_VBUS_CHG_INT_B_EN BIT(6) #define SSUSB_VBUS_CHG_INT_B_EN BIT(6)
/* U3D_SSUSB_U3_CTRL_0P */ /* U3D_SSUSB_U3_CTRL_0P */
#define SSUSB_U3_PORT_SSP_SPEED BIT(9)
#define SSUSB_U3_PORT_HOST_SEL BIT(2) #define SSUSB_U3_PORT_HOST_SEL BIT(2)
#define SSUSB_U3_PORT_PDN BIT(1) #define SSUSB_U3_PORT_PDN BIT(1)
#define SSUSB_U3_PORT_DIS BIT(0) #define SSUSB_U3_PORT_DIS BIT(0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册