]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/usb/phy/phy-msm-usb.c
usb: phy: msm: use devm_ioremap_resource()
[karo-tx-linux.git] / drivers / usb / phy / phy-msm-usb.c
index 370648b18417ca53b4fb190df74f2a7ef57a2029..301ffb1fa0e439e9c7fd55114099deb721d3093d 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"
@@ -764,7 +765,8 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
         * Kick the state machine work, if peripheral is not supported
         * or peripheral is already registered with us.
         */
-       if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
+       if (motg->pdata->mode == USB_DR_MODE_HOST ||
+                       motg->pdata->mode == USB_DR_MODE_OTG || otg->gadget) {
                pm_runtime_get_sync(otg->usb_phy->dev);
                schedule_work(&motg->sm_work);
        }
@@ -834,7 +836,8 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
         * Kick the state machine work, if host is not supported
         * or host is already registered with us.
         */
-       if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
+       if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL ||
+               motg->pdata->mode == USB_DR_MODE_OTG || otg->host) {
                pm_runtime_get_sync(otg->usb_phy->dev);
                schedule_work(&motg->sm_work);
        }
@@ -1650,6 +1653,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];
@@ -1702,11 +1718,9 @@ static int msm_otg_probe(struct platform_device *pdev)
                                      np ? "alt_core" : "usb_hs_core_clk");
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res)
-               return -EINVAL;
-       motg->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-       if (!motg->regs)
-               return -ENOMEM;
+       motg->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(motg->regs))
+               return PTR_ERR(motg->regs);
 
        pdata = dev_get_platdata(&pdev->dev);
        if (!pdata) {
@@ -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.