]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
usb: host: tegra: Boost CPU for high-speed devices
authorRohith Seelaboyina <rseelaboyina@nvidia.com>
Thu, 16 Jan 2014 06:13:27 +0000 (11:43 +0530)
committerRohith Seelaboyina <rseelaboyina@nvidia.com>
Mon, 20 Jan 2014 06:26:39 +0000 (22:26 -0800)
Boost CPU freq only for High-Speed devices as
low-speed deivces do not need to run the CPU at
High freq.

Bug 1431729

Change-Id: I57e3a43459ae950d88c06fcff9577510669cb8c7
Signed-off-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Reviewed-on: http://git-master/r/356462
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Suresh Mangipudi <smangipudi@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/usb/host/ehci-tegra.c

index f7268bf41fe0924363e0a720600b671d569e7be8..54013f7052498b5b1f39745fa283a32b8a208dcb 100644 (file)
@@ -83,6 +83,27 @@ static struct usb_phy *get_usb_phy(struct tegra_usb_phy *x)
        return (struct usb_phy *)x;
 }
 
+static int tegra_ehci_port_speed(struct ehci_hcd *ehci)
+{
+       u32 hostpc = ehci_readl(ehci, &ehci->regs->hostpc);
+       enum usb_device_speed port_speed;
+
+       switch ((hostpc >> (ehci->has_hostpc ? 25 : 26)) & 3) {
+       case 0:
+               port_speed = USB_SPEED_LOW;
+               break;
+       case 1:
+               port_speed = USB_SPEED_FULL;
+               break;
+       case 2:
+               port_speed = USB_SPEED_HIGH;
+               break;
+       default:
+               port_speed = USB_SPEED_UNKNOWN;
+       }
+       return port_speed;
+}
+
 static void tegra_ehci_notify_event(struct tegra_ehci_hcd *tegra, int event)
 {
        tegra->transceiver->last_event = event;
@@ -183,9 +204,9 @@ static void tegra_ehci_boost_cpu_frequency_work(struct work_struct *work)
                struct tegra_ehci_hcd, boost_cpu_freq_work.work);
        if (tegra->cpu_boost_in_work) {
                tegra->boost_requested = true;
-               if (tegra->boost_enable)
-                       pm_qos_update_request(
-                               &tegra->boost_cpu_freq_req,
+               if (tegra->boost_enable && (tegra_ehci_port_speed(tegra->ehci)
+                                       == USB_SPEED_HIGH))
+                       pm_qos_update_request(&tegra->boost_cpu_freq_req,
                                (s32)CONFIG_TEGRA_EHCI_BOOST_CPU_FREQ * 1000);
        }
 }
@@ -420,10 +441,10 @@ static int tegra_ehci_bus_resume(struct usb_hcd *hcd)
 #ifdef CONFIG_TEGRA_EHCI_BOOST_CPU_FREQ
        tegra->boost_requested = true;
        if (pm_qos_request_active(&tegra->boost_cpu_freq_req)
-           && tegra->boost_enable)
-               pm_qos_update_request(&tegra->boost_cpu_freq_req,
-                       (s32)CONFIG_TEGRA_EHCI_BOOST_CPU_FREQ * 1000);
-       tegra->cpu_boost_in_work = false;
+               && tegra->boost_enable) {
+               schedule_delayed_work(&tegra->boost_cpu_freq_work, 4000);
+               tegra->cpu_boost_in_work = true;
+       }
 
 #endif