summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorChunfeng Yun <chunfeng.yun@mediatek.com>2020-07-27 15:14:54 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-07-29 16:53:58 +0200
commit1258450ef38af7ea5b27a0a14195bb406f59cda8 (patch)
treedafb7d68ba7887a030f559478e1bb0bbffab808c /drivers/usb
parentb7d5c3cabcec4191e22e962867904e661cb9bc84 (diff)
usb: mtu3: introduce a funtion to check maximum speed
The max_speed got from DTS may be not supported by the hardware, so need check it, and assign a proper default value. And make it clear by introducing a funtion. Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Link: https://lore.kernel.org/r/1595834101-13094-5-git-send-email-chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/mtu3/mtu3_core.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 4958b04545da..c37842dbfb95 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -573,9 +573,6 @@ static void mtu3_set_speed(struct mtu3 *mtu)
{
void __iomem *mbase = mtu->mac_base;
- if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH))
- mtu->max_speed = USB_SPEED_HIGH;
-
if (mtu->max_speed == USB_SPEED_FULL) {
/* disable U3 SS function */
mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN);
@@ -761,6 +758,32 @@ static irqreturn_t mtu3_irq(int irq, void *data)
return IRQ_HANDLED;
}
+static void mtu3_check_params(struct mtu3 *mtu)
+{
+ /* check the max_speed parameter */
+ switch (mtu->max_speed) {
+ case USB_SPEED_FULL:
+ case USB_SPEED_HIGH:
+ case USB_SPEED_SUPER:
+ case USB_SPEED_SUPER_PLUS:
+ break;
+ default:
+ dev_err(mtu->dev, "invalid max_speed: %s\n",
+ usb_speed_string(mtu->max_speed));
+ fallthrough;
+ case USB_SPEED_UNKNOWN:
+ /* default as SSP */
+ mtu->max_speed = USB_SPEED_SUPER_PLUS;
+ break;
+ }
+
+ if (!mtu->is_u3_ip && (mtu->max_speed > USB_SPEED_HIGH))
+ mtu->max_speed = USB_SPEED_HIGH;
+
+ dev_info(mtu->dev, "max_speed: %s\n",
+ usb_speed_string(mtu->max_speed));
+}
+
static int mtu3_hw_init(struct mtu3 *mtu)
{
u32 value;
@@ -776,6 +799,8 @@ static int mtu3_hw_init(struct mtu3 *mtu)
dev_info(mtu->dev, "IP version 0x%x(%s IP)\n", mtu->hw_version,
mtu->is_u3_ip ? "U3" : "U2");
+ mtu3_check_params(mtu);
+
mtu3_device_reset(mtu);
ret = mtu3_device_enable(mtu);
@@ -855,23 +880,6 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
mtu->ssusb = ssusb;
mtu->max_speed = usb_get_maximum_speed(dev);
- /* check the max_speed parameter */
- switch (mtu->max_speed) {
- case USB_SPEED_FULL:
- case USB_SPEED_HIGH:
- case USB_SPEED_SUPER:
- case USB_SPEED_SUPER_PLUS:
- break;
- default:
- dev_err(dev, "invalid max_speed: %s\n",
- usb_speed_string(mtu->max_speed));
- /* fall through */
- case USB_SPEED_UNKNOWN:
- /* default as SSP */
- mtu->max_speed = USB_SPEED_SUPER_PLUS;
- break;
- }
-
dev_dbg(dev, "mac_base=0x%p, ippc_base=0x%p\n",
mtu->mac_base, mtu->ippc_base);