]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/usb/renesas_usbhs/common.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[mirror_ubuntu-bionic-kernel.git] / drivers / usb / renesas_usbhs / common.c
index 08c679c0dde5ae110a56ec70af33819fdd20cfeb..a165490bae48ae82140dd9a3abf68f66f4f0fb8c 100644 (file)
@@ -95,25 +95,15 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev)
 /*
  *             syscfg functions
  */
-void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable)
+static void usbhs_sys_clock_ctrl(struct usbhs_priv *priv, int enable)
 {
        usbhs_bset(priv, SYSCFG, SCKE, enable ? SCKE : 0);
 }
 
-void usbhs_sys_hispeed_ctrl(struct usbhs_priv *priv, int enable)
-{
-       usbhs_bset(priv, SYSCFG, HSE, enable ? HSE : 0);
-}
-
-void usbhs_sys_usb_ctrl(struct usbhs_priv *priv, int enable)
-{
-       usbhs_bset(priv, SYSCFG, USBE, enable ? USBE : 0);
-}
-
 void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable)
 {
-       u16 mask = DCFM | DRPD | DPRPU;
-       u16 val  = DCFM | DRPD;
+       u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
+       u16 val  = DCFM | DRPD | HSE | USBE;
        int has_otg = usbhs_get_dparam(priv, has_otg);
 
        if (has_otg)
@@ -130,8 +120,8 @@ void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable)
 
 void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable)
 {
-       u16 mask = DCFM | DRPD | DPRPU;
-       u16 val  = DPRPU;
+       u16 mask = DCFM | DRPD | DPRPU | HSE | USBE;
+       u16 val  = DPRPU | HSE | USBE;
 
        /*
         * if enable
@@ -142,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable)
        usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
 }
 
+void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode)
+{
+       usbhs_write(priv, TESTMODE, mode);
+}
+
 /*
  *             frame functions
  */
@@ -229,7 +224,7 @@ static void usbhsc_bus_init(struct usbhs_priv *priv)
 /*
  *             device configuration
  */
-int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum,
+int usbhs_set_device_config(struct usbhs_priv *priv, int devnum,
                           u16 upphub, u16 hubport, u16 speed)
 {
        struct device *dev = usbhs_priv_to_dev(priv);
@@ -301,18 +296,25 @@ static u32 usbhsc_default_pipe_type[] = {
  */
 static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable)
 {
+       struct platform_device *pdev = usbhs_priv_to_pdev(priv);
        struct device *dev = usbhs_priv_to_dev(priv);
 
        if (enable) {
                /* enable PM */
                pm_runtime_get_sync(dev);
 
+               /* enable platform power */
+               usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
+
                /* USB on */
                usbhs_sys_clock_ctrl(priv, enable);
        } else {
                /* USB off */
                usbhs_sys_clock_ctrl(priv, enable);
 
+               /* disable platform power */
+               usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable);
+
                /* disable PM */
                pm_runtime_put_sync(dev);
        }
@@ -388,7 +390,7 @@ static void usbhsc_notify_hotplug(struct work_struct *work)
        usbhsc_hotplug(priv);
 }
 
-int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
+static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
 {
        struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
        int delay = usbhs_get_dparam(priv, detection_delay);
@@ -398,7 +400,8 @@ int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
         * To make sure safety context,
         * use workqueue for usbhs_notify_hotplug
         */
-       schedule_delayed_work(&priv->notify_hotplug_work, delay);
+       schedule_delayed_work(&priv->notify_hotplug_work,
+                             msecs_to_jiffies(delay));
        return 0;
 }
 
@@ -410,8 +413,7 @@ static int usbhs_probe(struct platform_device *pdev)
        struct renesas_usbhs_platform_info *info = pdev->dev.platform_data;
        struct renesas_usbhs_driver_callback *dfunc;
        struct usbhs_priv *priv;
-       struct resource *res;
-       unsigned int irq;
+       struct resource *res, *irq_res;
        int ret;
 
        /* check platform information */
@@ -423,8 +425,8 @@ static int usbhs_probe(struct platform_device *pdev)
 
        /* platform data */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       irq = platform_get_irq(pdev, 0);
-       if (!res || (int)irq <= 0) {
+       irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (!res || !irq_res) {
                dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n");
                return -ENODEV;
        }
@@ -473,7 +475,9 @@ static int usbhs_probe(struct platform_device *pdev)
        /*
         * priv settings
         */
-       priv->irq       = irq;
+       priv->irq       = irq_res->start;
+       if (irq_res->flags & IORESOURCE_IRQ_SHAREABLE)
+               priv->irqflags = IRQF_SHARED;
        priv->pdev      = pdev;
        INIT_DELAYED_WORK(&priv->notify_hotplug_work, usbhsc_notify_hotplug);
        spin_lock_init(usbhs_priv_to_lock(priv));
@@ -637,18 +641,7 @@ static struct platform_driver renesas_usbhs_driver = {
        .remove         = __devexit_p(usbhs_remove),
 };
 
-static int __init usbhs_init(void)
-{
-       return platform_driver_register(&renesas_usbhs_driver);
-}
-
-static void __exit usbhs_exit(void)
-{
-       platform_driver_unregister(&renesas_usbhs_driver);
-}
-
-module_init(usbhs_init);
-module_exit(usbhs_exit);
+module_platform_driver(renesas_usbhs_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Renesas USB driver");