Merge branches 'pm-devfreq' and 'pm-tools'
[linux-2.6-microblaze.git] / drivers / devfreq / exynos-bus.c
index 1e684a4..e689101 100644 (file)
@@ -24,6 +24,7 @@
 
 struct exynos_bus {
        struct device *dev;
+       struct platform_device *icc_pdev;
 
        struct devfreq *devfreq;
        struct devfreq_event_dev **edev;
@@ -156,18 +157,20 @@ static void exynos_bus_exit(struct device *dev)
        if (ret < 0)
                dev_warn(dev, "failed to disable the devfreq-event devices\n");
 
+       platform_device_unregister(bus->icc_pdev);
+
        dev_pm_opp_of_remove_table(dev);
        clk_disable_unprepare(bus->clk);
-       if (bus->opp_table) {
-               dev_pm_opp_put_regulators(bus->opp_table);
-               bus->opp_table = NULL;
-       }
+       dev_pm_opp_put_regulators(bus->opp_table);
+       bus->opp_table = NULL;
 }
 
 static void exynos_bus_passive_exit(struct device *dev)
 {
        struct exynos_bus *bus = dev_get_drvdata(dev);
 
+       platform_device_unregister(bus->icc_pdev);
+
        dev_pm_opp_of_remove_table(dev);
        clk_disable_unprepare(bus->clk);
 }
@@ -432,6 +435,18 @@ static int exynos_bus_probe(struct platform_device *pdev)
        if (ret < 0)
                goto err;
 
+       /* Create child platform device for the interconnect provider */
+       if (of_get_property(dev->of_node, "#interconnect-cells", NULL)) {
+               bus->icc_pdev = platform_device_register_data(
+                                               dev, "exynos-generic-icc",
+                                               PLATFORM_DEVID_AUTO, NULL, 0);
+
+               if (IS_ERR(bus->icc_pdev)) {
+                       ret = PTR_ERR(bus->icc_pdev);
+                       goto err;
+               }
+       }
+
        max_state = bus->devfreq->profile->max_state;
        min_freq = (bus->devfreq->profile->freq_table[0] / 1000);
        max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000);
@@ -444,10 +459,8 @@ err:
        dev_pm_opp_of_remove_table(dev);
        clk_disable_unprepare(bus->clk);
 err_reg:
-       if (!passive) {
-               dev_pm_opp_put_regulators(bus->opp_table);
-               bus->opp_table = NULL;
-       }
+       dev_pm_opp_put_regulators(bus->opp_table);
+       bus->opp_table = NULL;
 
        return ret;
 }