aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/driver.c19
-rw-r--r--drivers/usb/core/hub.c54
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/core/sec-dock.h133
4 files changed, 204 insertions, 6 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 75b4bc0..e1f547e 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1181,6 +1181,19 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
udev->state == USB_STATE_SUSPENDED)
goto done;
+#ifdef CONFIG_MDM_HSIC_PM
+ /* when additional device attached at ehci hub, interface driver will
+ * goes to suspend , but hub will not goes to suspend.
+ * in hsic case, device modem cannot notice this change on host, so
+ * it does not try to send packet to host
+ *
+ * prevent suspend_both when it's parent has more child
+ */
+ if (udev->dev.parent) {
+ if (atomic_read(&udev->dev.parent->power.child_count) != 1)
+ return -EBUSY;
+ }
+#endif
/* Suspend all the interfaces and then udev itself */
if (udev->actconfig) {
n = udev->actconfig->desc.bNumInterfaces;
@@ -1332,6 +1345,9 @@ int usb_resume(struct device *dev, pm_message_t msg)
* Unbind the interfaces that will need rebinding later.
*/
} else {
+ #ifdef CONFIG_MDM_HSIC_PM
+ pm_runtime_get_sync(dev->parent);
+ #endif
status = usb_resume_both(udev, msg);
if (status == 0) {
pm_runtime_disable(dev);
@@ -1339,6 +1355,9 @@ int usb_resume(struct device *dev, pm_message_t msg)
pm_runtime_enable(dev);
do_unbind_rebind(udev, DO_REBIND);
}
+ #ifdef CONFIG_MDM_HSIC_PM
+ pm_runtime_put_sync(dev->parent);
+ #endif
}
/* Avoid PM error messages for devices disconnected while suspended
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 069739b..93aa0e7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -29,6 +29,9 @@
#include <asm/byteorder.h>
#include "usb.h"
+#ifdef CONFIG_SAMSUNG_SMARTDOCK
+#include "sec-dock.h"
+#endif
/* if we are in debug mode, always announce new devices */
#ifdef DEBUG
@@ -766,7 +769,16 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
"under this hub\n.");
}
}
+ #ifdef CONFIG_MDM_HSIC_PM
+ /* MDM9x15, HSIC device do not need power on delay */
+ if (dev_name(hub->intfdev) &&
+ !strcmp(dev_name(hub->intfdev), "1-0:1.0"))
+ hub_power_on(hub, false);
+ else
+ hub_power_on(hub, true);
+ #else
hub_power_on(hub, true);
+ #endif
} else {
hub_power_on(hub, true);
}
@@ -879,7 +891,8 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
* If any port-status changes do occur during this delay, khubd
* will see them later and handle them normally.
*/
-#if defined(CONFIG_LINK_DEVICE_HSIC) || defined(CONFIG_LINK_DEVICE_USB)
+#if defined(CONFIG_LINK_DEVICE_HSIC) || defined(CONFIG_LINK_DEVICE_USB) \
+ || defined(CONFIG_MDM_HSIC_PM)
if (need_debounce_delay && type != HUB_RESET_RESUME) {
#else
if (need_debounce_delay) {
@@ -1662,6 +1675,10 @@ void usb_disconnect(struct usb_device **pdev)
dev_info(&udev->dev, "USB disconnect, device number %d by %pF\n",
udev->devnum, __builtin_return_address(0));
+#ifdef CONFIG_SAMSUNG_SMARTDOCK
+ call_battery_notify(udev, 0);
+#endif
+
usb_lock_device(udev);
/* Free up all the children before we remove this device */
@@ -1905,7 +1922,12 @@ int usb_new_device(struct usb_device *udev)
/* Tell the world! */
announce_device(udev);
-
+#ifdef CONFIG_SAMSUNG_SMARTDOCK
+#if defined(CONFIG_MUIC_MAX77693_SUPPORT_OTG_AUDIO_DOCK)
+ call_audiodock_notify(udev);
+#endif
+ call_battery_notify(udev, 1);
+#endif
device_enable_async_suspend(&udev->dev);
/* Register the device. The device driver is responsible
* for configuring the device and invoking the add-device
@@ -2130,7 +2152,13 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
switch (status) {
case 0:
/* TRSTRCY = 10 ms; plus some extra */
+ #ifdef CONFIG_MDM_HSIC_PM
+ /* MDM9x15, HSIC deivce do not need this delay */
+ if (!(udev->quirks & USB_QUIRK_HSIC_TUNE))
+ msleep(10 + 40);
+ #else
msleep(10 + 40);
+ #endif
update_devnum(udev, 0);
if (hcd->driver->reset_device) {
status = hcd->driver->reset_device(hcd, udev);
@@ -2276,6 +2304,11 @@ static int check_port_resume_type(struct usb_device *udev,
if (portchange & USB_PORT_STAT_C_ENABLE)
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_ENABLE);
+ #ifdef CONFIG_MDM_HSIC_PM
+ /* MDM9x15, HSIC deivce do need this delay at LPA wake */
+ if (udev->quirks & USB_QUIRK_HSIC_TUNE)
+ msleep(30);
+ #endif
}
return status;
@@ -2566,8 +2599,9 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
}
SuspendCleared:
-#if defined(CONFIG_LINK_DEVICE_HSIC) || defined(CONFIG_LINK_DEVICE_USB)
- pr_debug("mif: %s: %d, %d\n", __func__, portstatus, portchange);
+#if defined(CONFIG_LINK_DEVICE_HSIC) || defined(CONFIG_LINK_DEVICE_USB) \
+ || defined(CONFIG_MDM_HSIC_PM)
+ pr_info("mif: %s: %d, %d\n", __func__, portstatus, portchange);
#endif
if (status == 0) {
if (hub_is_superspeed(hub->hdev)) {
@@ -2591,6 +2625,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
dev_dbg(&udev->dev, "can't resume, status %d\n", status);
hub_port_logical_disconnect(hub, port1);
}
+
return status;
}
@@ -3517,7 +3552,7 @@ static void hub_events(void)
* EM interference sometimes causes badly
* shielded USB devices to be shutdown by
* the hub, this hack enables them again.
- * Works at least with mouse driver.
+ * Works at least with mouse driver.
*/
if (!(portstatus & USB_PORT_STAT_ENABLE)
&& !connect_change
@@ -3539,7 +3574,14 @@ static void hub_events(void)
udev = hdev->children[i-1];
if (udev) {
/* TRSMRCY = 10 msec */
+ #ifdef CONFIG_MDM_HSIC_PM
+ /* MDM9x15, HSIC deivce */
+ if (udev->quirks & USB_QUIRK_HSIC_TUNE)
+ msleep(10 + 10);
+ else
+ #else
msleep(10);
+ #endif
usb_lock_device(udev);
ret = usb_remote_wakeup(hdev->
@@ -3555,7 +3597,7 @@ static void hub_events(void)
"resume on port %d, status %d\n",
i, ret);
}
-
+
if (portchange & USB_PORT_STAT_C_OVERCURRENT) {
u16 status = 0;
u16 unused;
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 5b9755d..f826b52 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -165,6 +165,10 @@ static const struct usb_device_id usb_quirk_list[] = {
/* STE_MAIN - M7400 */
{ USB_DEVICE(0x04cc, 0x2333), .driver_info = USB_QUIRK_HSIC_TUNE },
+ /* Qualcomm MDM9x15 */
+ { USB_DEVICE(0x05c6, 0x9048), .driver_info = USB_QUIRK_HSIC_TUNE },
+
+ { USB_DEVICE(0x05c6, 0x904C), .driver_info = USB_QUIRK_HSIC_TUNE },
{ } /* terminating entry must be last */
};
diff --git a/drivers/usb/core/sec-dock.h b/drivers/usb/core/sec-dock.h
new file mode 100644
index 0000000..1521b67
--- /dev/null
+++ b/drivers/usb/core/sec-dock.h
@@ -0,0 +1,133 @@
+/*
+ * drivers/usb/core/sec-dock.h
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * Author: Woo-kwang Lee <wookwang.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#if defined(CONFIG_MUIC_MAX77693_SUPPORT_OTG_AUDIO_DOCK)
+#include <linux/mfd/max77693.h>
+#endif /* CONFIG_MUIC_MAX77693_SUPPORT_OTG_AUDIO_DOCK */
+#include <linux/power_supply.h>
+
+#define PSY_CHG_NAME "max77693-charger"
+
+int usb_open_count;
+bool is_smartdock;
+
+static struct usb_device_id battery_notify_exception_table[] = {
+/* add exception table list */
+{ USB_DEVICE(0x1d6b, 0x0001), }, /* OHCI Host Controller */
+{ USB_DEVICE(0x1d6b, 0x0002), }, /* EHCI Host Controller */
+{ USB_DEVICE(0x1519, 0x0020), }, /* HSIC Device */
+{ USB_DEVICE(0x05c6, 0x904c), }, /* Qualcomm modem */
+{ USB_DEVICE(0x05c6, 0x9008), }, /* Qualcomm modem */
+{ USB_DEVICE(0x08bb, 0x27c4), }, /* TI USB Audio DAC */
+{ } /* Terminating entry */
+};
+
+#if defined(CONFIG_MUIC_MAX77693_SUPPORT_OTG_AUDIO_DOCK)
+static struct usb_device_id audio_dock_table[] = {
+/* add exception table list */
+{ USB_DEVICE(0x04e8, 0x1220), }, /* Samsung Audio Dock */
+{ USB_DEVICE(0x08bb, 0x27c4), }, /* TI USB Audio DAC */
+{ } /* Terminating entry */
+};
+
+static void call_audiodock_notify(struct usb_device *dev)
+{
+ struct usb_device_id *id = audio_dock_table;
+ /* check VID, PID */
+ for (id = audio_dock_table; id->match_flags; id++) {
+ if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
+ (id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
+ id->idVendor == le16_to_cpu(dev->descriptor.idVendor) &&
+ id->idProduct == le16_to_cpu(dev->descriptor.idProduct)) {
+ dev_info(&dev->dev, "Audio Dock is connected!\n");
+ max77693_muic_attach_audio_dock();
+ return;
+ }
+ }
+}
+#endif /* CONFIG_MUIC_MAX77693_SUPPORT_OTG_AUDIO_DOCK */
+
+/* real battery driver notification function */
+static void set_online(int host_state)
+{
+ struct power_supply *psy = power_supply_get_by_name(PSY_CHG_NAME);
+ union power_supply_propval value;
+ int sub_type;
+
+ if (!psy) {
+ pr_err("%s: fail to get %s psy\n", __func__, PSY_CHG_NAME);
+ return;
+ }
+ if (host_state)
+ sub_type = ONLINE_SUB_TYPE_SMART_OTG;
+ else
+ sub_type = ONLINE_SUB_TYPE_SMART_NOTG;
+
+ value.intval = 0;
+ value.intval = (sub_type << 8);
+ psy->set_property(psy, POWER_SUPPLY_PROP_ONLINE, &value);
+ return;
+}
+
+static int call_battery_notify(struct usb_device *dev, bool bOnOff)
+{
+ struct usb_device_id *id = battery_notify_exception_table;
+
+ /* Smart Dock hub must be skipped */
+ if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a40 &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x0101)) {
+ if (bOnOff)
+ is_smartdock = 1;
+ else
+ is_smartdock = 0;
+ return 0;
+ }
+
+ /* check VID, PID */
+ for (id = battery_notify_exception_table; id->match_flags; id++) {
+ if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
+ (id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
+ id->idVendor == le16_to_cpu(dev->descriptor.idVendor) &&
+ id->idProduct == le16_to_cpu(dev->descriptor.idProduct)) {
+ pr_info("%s : VID : 0x%x, PID : 0x%x skipped.\n",
+ __func__, id->idVendor, id->idProduct);
+ return 0;
+ }
+ }
+ if (bOnOff)
+ usb_open_count++;
+ else
+ usb_open_count--;
+
+ /* battery driver notification */
+ if (usb_open_count == 1 && bOnOff && is_smartdock) {
+ pr_info("%s : VID : 0x%x, PID : 0x%x set 1000mA.\n",
+ __func__,
+ le16_to_cpu(dev->descriptor.idVendor),
+ le16_to_cpu(dev->descriptor.idProduct));
+ set_online(1);
+ } else if (usb_open_count == 0 && !bOnOff) {
+ pr_info("%s : VID : 0x%x, PID : 0x%x set 1700mA.\n",
+ __func__,
+ le16_to_cpu(dev->descriptor.idVendor),
+ le16_to_cpu(dev->descriptor.idProduct));
+ set_online(0);
+ } else {
+ pr_info("%s : VID : 0x%x, PID : 0x%x no action.\n",
+ __func__,
+ le16_to_cpu(dev->descriptor.idVendor),
+ le16_to_cpu(dev->descriptor.idProduct));
+ /* Nothing to do */
+ }
+
+ return 1;
+}
+