]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
drivers: usb: Add bus scaling suppport
authorRajendra Nayak <rnayak@codeaurora.org>
Tue, 13 Oct 2015 12:08:52 +0000 (17:38 +0530)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Fri, 13 Apr 2018 14:00:32 +0000 (16:00 +0200)
Add msm bus scaling support and hack to request
max bandwith at probe

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
drivers/usb/phy/phy-msm-usb.c
include/linux/usb/msm_hsusb.h

index 370648b18417ca53b4fb190df74f2a7ef57a2029..2bffa849336c3e730ff9aba16ff952ee8538becd 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/usb/msm_hsusb.h>
 #include <linux/usb/msm_hsusb_hw.h>
 #include <linux/regulator/consumer.h>
+#include <linux/msm-bus.h>
 
 #define MSM_USB_BASE   (motg->regs)
 #define DRIVER_NAME    "msm_otg"
@@ -1650,6 +1651,19 @@ static int msm_otg_reboot_notify(struct notifier_block *this,
        return NOTIFY_DONE;
 }
 
+static void msm_otg_bus_vote(struct msm_otg *motg, enum usb_bus_vote vote)
+{
+       int ret;
+
+       if (motg->bus_perf_client) {
+               ret = msm_bus_scale_client_update_request(
+                               motg->bus_perf_client, vote);
+               if (ret)
+                       dev_err(motg->phy.dev, "%s: Failed to vote (%d)\n"
+                                       "for bus bw %d\n", __func__, vote, ret);
+       }
+}
+
 static int msm_otg_probe(struct platform_device *pdev)
 {
        struct regulator_bulk_data regs[2];
@@ -1811,6 +1825,19 @@ static int msm_otg_probe(struct platform_device *pdev)
                goto disable_ldo;
        }
 
+       motg->pdata->bus_scale_table = msm_bus_cl_get_pdata(pdev);
+       if (!motg->pdata->bus_scale_table)
+               dev_dbg(&pdev->dev, "bus scaling is disabled\n");
+       else {
+               motg->bus_perf_client =
+                       msm_bus_scale_register_client(motg->pdata->bus_scale_table);
+               if (!motg->bus_perf_client)
+                       dev_err(motg->phy.dev, "%s: Failed to register BUS\n"
+                                       "scaling client!!\n", __func__);
+       }
+       /* Hack to max out usb performace */
+       msm_otg_bus_vote(motg, USB_MAX_PERF_VOTE);
+
        platform_set_drvdata(pdev, motg);
        device_init_wakeup(&pdev->dev, 1);
 
@@ -1885,6 +1912,7 @@ static int msm_otg_remove(struct platform_device *pdev)
 
        usb_remove_phy(phy);
        disable_irq(motg->irq);
+       msm_bus_scale_unregister_client(motg->bus_perf_client);
 
        /*
         * Put PHY in low power mode.
index 8c8f6854c993b056ae6246ca58091fa9904602b2..e1cee47b8c04868b10baad49948699c171d67e57 100644 (file)
@@ -98,6 +98,20 @@ enum usb_chg_type {
        USB_CDP_CHARGER,
 };
 
+/**
+ * Requested USB votes for BUS bandwidth
+ *
+ * USB_NO_PERF_VOTE     BUS Vote for inactive USB session or disconnect
+ * USB_MAX_PERF_VOTE    Maximum BUS bandwidth vote
+ * USB_MIN_PERF_VOTE    Minimum BUS bandwidth vote (for some hw same as NO_PERF)
+ *
+ */
+enum usb_bus_vote {
+       USB_NO_PERF_VOTE = 0,
+       USB_MAX_PERF_VOTE,
+       USB_MIN_PERF_VOTE,
+};
+
 /**
  * struct msm_otg_platform_data - platform device data
  *              for msm_otg driver.
@@ -114,6 +128,7 @@ struct msm_otg_platform_data {
        int phy_init_sz;
        void (*vbus_power)(bool on);
        unsigned power_budget;
+       struct msm_bus_scale_pdata *bus_scale_table;
        enum usb_dr_mode mode;
        enum otg_control_type otg_control;
        enum msm_usb_phy_type phy_type;
@@ -195,6 +210,7 @@ struct msm_otg {
 
        struct gpio_desc *switch_gpio;
        struct notifier_block reboot;
+       uint32_t bus_perf_client;
 };
 
 #endif