]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
platform: tegra: move pm_domain to drivers
authorPrashant Gaikwad <pgaikwad@nvidia.com>
Fri, 11 Apr 2014 09:12:29 +0000 (14:42 +0530)
committerBharat Nihalani <bnihalani@nvidia.com>
Mon, 14 Apr 2014 03:09:36 +0000 (20:09 -0700)
Change-Id: I30baee4084399b8078232f31296c4d891a903d47
Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-on: http://git-master/r/395123
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
31 files changed:
arch/arm/mach-tegra/Kconfig
arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/pm.c
arch/arm/mach-tegra/pm_domains.c [deleted file]
arch/arm/mach-tegra/tegra_bb.c
arch/arm64/mach-tegra/pm.c
drivers/crypto/tegra-se.c
drivers/dma/tegra20-apb-dma.c
drivers/gpu/nvgpu/gk20a/gk20a.c
drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c
drivers/media/platform/soc_camera/tegra_camera/common.c
drivers/media/platform/tegra/nvavp/nvavp_dev.c
drivers/mmc/host/sdhci-tegra.c
drivers/pci/host/pci-tegra.c
drivers/platform/Kconfig
drivers/platform/tegra/Kconfig [new file with mode: 0644]
drivers/platform/tegra/Makefile
drivers/platform/tegra/pm_domains.c
drivers/usb/host/ehci-tegra.c
drivers/usb/host/xhci-tegra.c
drivers/usb/phy/tegra-otg.c
drivers/video/tegra/dc/dc.c
drivers/video/tegra/host/host1x/host1x.c
drivers/video/tegra/host/isp/isp.c
drivers/video/tegra/host/msenc/msenc.c
drivers/video/tegra/host/nvhost_acm.c
drivers/video/tegra/host/tsec/tsec.c
drivers/video/tegra/host/vi/vi.c
drivers/video/tegra/host/vic03/vic03.c
include/linux/tegra_pm_domains.h [moved from arch/arm/mach-tegra/include/mach/pm_domains.h with 90% similarity]
sound/pci/hda/hda_intel.c

index c452aca1c34c8d333c30125a50ec869d46a6376e..c201be875218aba93bb861efef44950eab51d850 100644 (file)
@@ -971,13 +971,6 @@ config ARCH_TEGRA_VIC
          Say Y here if the SOC supports the Tegra Video Image Compositor.
          Note that this not the same as the ARM Vectored Interrupt Controller.
 
-config TEGRA_MC_DOMAINS
-       bool "Enable MC domains"
-       depends on PM_GENERIC_DOMAINS
-       default n
-       help
-         When enabled, clock gates MC when it's not needed.
-
 config TEGRA_USE_NCT
        bool "Enable NCT partition access"
        help
index d918c2f7a9f874d4e8b8176aee22c7b81a96b310..285c89d79cea4e066eaa0718d2bce536a62fb9fa 100644 (file)
@@ -75,7 +75,6 @@ obj-$(CONFIG_ARCH_TEGRA_12x_SOC)        += powergate-t12x.o
 
 obj-y                                   += apbio.o
 obj-$(CONFIG_TEGRA_ARB_SEMAPHORE)       += arb_sema.o
-obj-$(CONFIG_PM_GENERIC_DOMAINS)        += pm_domains.o
 obj-y                                   += dvfs.o
 obj-$(CONFIG_ARCH_TEGRA_11x_SOC)        += tegra11_dvfs.o
 ifeq ($(CONFIG_ARCH_TEGRA_13x_SOC),y)
index 44a30247386c72c59f6bd884b1380d13f4c9eb61..16e9b2cf55a9eb3d4dc4898b416ae5f8d70ec624 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/irqchip/tegra.h>
 #include <linux/tegra-pm.h>
 #include <linux/tegra-pmc.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <trace/events/power.h>
 #include <trace/events/nvsecurity.h>
@@ -71,7 +72,6 @@
 
 #include <mach/irqs.h>
 #include <mach/tegra_smmu.h>
-#include <mach/pm_domains.h>
 
 #include "board.h"
 #include "clock.h"
diff --git a/arch/arm/mach-tegra/pm_domains.c b/arch/arm/mach-tegra/pm_domains.c
deleted file mode 100644 (file)
index 0778648..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * arch/arm/mach-tegra/pm_domains.c
- *
- * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
- *
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/module.h>
-#include <linux/pm.h>
-#include <linux/pm_runtime.h>
-#include <linux/pm_domain.h>
-
-#include <mach/pm_domains.h>
-
-#ifdef CONFIG_TEGRA_MC_DOMAINS
-#define TEGRA_PD_DEV_CALLBACK(callback, dev)                   \
-({                                                             \
-       int (*__routine)(struct device *__d);                   \
-       int __ret = 0;                                          \
-                                                               \
-       if (dev->type && dev->type->pm)                         \
-               __routine = dev->type->pm->callback;            \
-       else if (dev->class && dev->class->pm)                  \
-               __routine = dev->class->pm->callback;           \
-       else if (dev->bus && dev->bus->pm)                      \
-               __routine = dev->bus->pm->callback;             \
-       else                                                    \
-               __routine = NULL;                               \
-                                                               \
-       if (!__routine && dev->driver && dev->driver->pm)       \
-               __routine = dev->driver->pm->callback;          \
-                                                               \
-       if (__routine)                                          \
-               __ret = __routine(dev);                         \
-       __ret;                                                  \
-})
-
-struct domain_client {
-       const char *name;
-       struct generic_pm_domain *domain;
-};
-
-#ifdef CONFIG_PM_SLEEP
-
-static int tegra_pd_suspend_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(suspend, dev);
-}
-
-static int tegra_pd_suspend_late(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(suspend_late, dev);
-}
-
-static int tegra_pd_resume_early(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(resume_early, dev);
-}
-
-static int tegra_pd_resume_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(resume, dev);
-}
-
-static int tegra_pd_freeze_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(freeze, dev);
-}
-
-static int tegra_pd_freeze_late(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(freeze_late, dev);
-}
-
-static int tegra_pd_thaw_early(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(thaw_early, dev);
-}
-
-static int tegra_pd_thaw_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(thaw, dev);
-}
-#else /* !CONFIG_PM_SLEEP */
-
-#define tegra_pd_suspend_dev   NULL
-#define tegra_pd_suspend_late  NULL
-#define tegra_pd_resume_early  NULL
-#define tegra_pd_resume_dev    NULL
-#define tegra_pd_freeze_dev    NULL
-#define tegra_pd_freeze_late   NULL
-#define tegra_pd_thaw_early    NULL
-#define tegra_pd_thaw_dev      NULL
-
-#endif /* !CONFIG_PM_SLEEP */
-
-static bool tegra_pd_active_wakeup(struct device *dev)
-{
-       return device_may_wakeup(dev);
-}
-
-static int tegra_pd_save_dev(struct device *dev)
-{
-       return 0;
-}
-
-static int tegra_pd_restore_dev(struct device *dev)
-{
-       return 0;
-}
-
-static int tegra_pd_stop_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(runtime_suspend, dev);
-}
-
-static int tegra_pd_start_dev(struct device *dev)
-{
-       return TEGRA_PD_DEV_CALLBACK(runtime_resume, dev);
-}
-
-struct gpd_dev_ops tegra_pd_ops = {
-       .active_wakeup = tegra_pd_active_wakeup,
-       .save_state = tegra_pd_save_dev,
-       .restore_state = tegra_pd_restore_dev,
-       .stop = tegra_pd_stop_dev,
-       .start = tegra_pd_start_dev,
-       .suspend = tegra_pd_suspend_dev,
-       .suspend_late = tegra_pd_suspend_late,
-       .resume_early = tegra_pd_resume_early,
-       .resume = tegra_pd_resume_dev,
-       .freeze = tegra_pd_freeze_dev,
-       .freeze_late = tegra_pd_freeze_late,
-       .thaw_early = tegra_pd_thaw_early,
-       .thaw = tegra_pd_thaw_dev,
-};
-
-static int tegra_mc_clk_power_off(struct generic_pm_domain *genpd)
-{
-       struct tegra_pm_domain *pd = to_tegra_pd(genpd);
-
-       if (!pd)
-               return -EINVAL;
-
-       if (IS_ERR_OR_NULL(pd->clk))
-               return 0;
-
-       clk_disable_unprepare(pd->clk);
-
-       return 0;
-}
-
-static int tegra_mc_clk_power_on(struct generic_pm_domain *genpd)
-{
-       struct tegra_pm_domain *pd = to_tegra_pd(genpd);
-
-       if (!pd)
-               return -EINVAL;
-
-       if (IS_ERR_OR_NULL(pd->clk))
-               return 0;
-
-       clk_prepare_enable(pd->clk);
-
-       return 0;
-}
-
-static struct tegra_pm_domain tegra_nvavp = {
-       .gpd.name = "tegra_nvavp",
-};
-
-static struct tegra_pm_domain tegra_mc_clk = {
-       .gpd.name = "tegra_mc_clk",
-       .gpd.power_off = tegra_mc_clk_power_off,
-       .gpd.power_on = tegra_mc_clk_power_on,
-};
-
-static struct domain_client client_list[] = {
-       { .name = "tegradc", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra30-hda", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-apbdma", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-otg", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-ehci", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-xhci", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-host1x", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra_nvavp", .domain = &tegra_mc_clk.gpd },
-       { .name = "nvavp", .domain = &tegra_nvavp.gpd },
-       { .name = "sdhci-tegra", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra11-se", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra12-se", .domain = &tegra_mc_clk.gpd },
-       { .name = "tegra-pcie", .domain = &tegra_mc_clk.gpd },
-       { .name = "gpu", .domain = &tegra_mc_clk.gpd },
-       {},
-};
-
-static int __init tegra_init_pm_domain(void)
-{
-       pm_genpd_init(&tegra_mc_clk.gpd, &simple_qos_governor, false);
-
-       pm_genpd_init(&tegra_nvavp.gpd, &simple_qos_governor, false);
-       tegra_pd_add_sd(&tegra_nvavp.gpd);
-
-       return 0;
-}
-core_initcall(tegra_init_pm_domain);
-
-static struct generic_pm_domain *tegra_pd_get_domain(const char *client)
-{
-       const char *s;
-       struct domain_client *clients = client_list;
-
-       while ((s = clients->name) != NULL) {
-               if (!strncmp(s, client, strlen(s)))
-                       return clients->domain;
-
-               clients++;
-       }
-       return NULL;
-}
-
-void tegra_pd_add_device(struct device *dev)
-{
-       struct generic_pm_domain *master = tegra_pd_get_domain(dev_name(dev));
-
-       if (!master)
-               return;
-
-       device_set_wakeup_capable(dev, 1);
-       pm_genpd_add_device(master, dev);
-       pm_genpd_dev_need_save(dev, false);
-       pm_genpd_add_callbacks(dev, &tegra_pd_ops, NULL);
-}
-EXPORT_SYMBOL(tegra_pd_add_device);
-
-void tegra_pd_remove_device(struct device *dev)
-{
-       struct generic_pm_domain *genpd = dev_to_genpd(dev);
-
-       if (!IS_ERR_OR_NULL(genpd))
-               pm_genpd_remove_device(genpd, dev);
-}
-EXPORT_SYMBOL(tegra_pd_remove_device);
-
-void tegra_pd_add_sd(struct generic_pm_domain *sd)
-{
-       struct generic_pm_domain *master = tegra_pd_get_domain(sd->name);
-
-       if (!master)
-               return;
-
-       pm_genpd_add_subdomain(master, sd);
-}
-EXPORT_SYMBOL(tegra_pd_add_sd);
-#else
-struct tegra_pm_domain tegra_mc_clk;
-EXPORT_SYMBOL(tegra_mc_clk);
-struct tegra_pm_domain tegra_mc_chain_a;
-EXPORT_SYMBOL(tegra_mc_chain_a);
-struct tegra_pm_domain tegra_mc_chain_b;
-EXPORT_SYMBOL(tegra_mc_chain_b);
-#endif
index c9801659847eca60a70c84efc644b9a855c9f97f..314d20308f8e3b45e489752232319a360a4601a8 100644 (file)
 #include <linux/suspend.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/nvshm.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <mach/tegra_bb.h>
 #include <mach/tegra_bbc_proxy.h>
-#include <mach/pm_domains.h>
 #include <mach/tegra_emc.h>
 
 #include "clock.h"
index 38e924bd45b256f3b40c393efc2fda78d9375b1c..58b56ab792a0f65b7054f1d28e1a49b88cb5a67e 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/tegra-cpuidle.h>
 #include <linux/irqchip/tegra.h>
 #include <linux/tegra-pm.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <trace/events/power.h>
 #include <trace/events/nvsecurity.h>
@@ -68,7 +69,6 @@
 
 #include <mach/irqs.h>
 #include <mach/tegra_smmu.h>
-#include <mach/pm_domains.h>
 
 #include "board.h"
 #include "clock.h"
index d6d17445c0c2c01a07bcd464893918d98f761eff..baaf5868070873d1c6af4dfbe4c65e8a89f276c8 100644 (file)
@@ -44,7 +44,7 @@
 #include <crypto/internal/hash.h>
 #include <crypto/sha.h>
 #include <linux/pm_runtime.h>
-#include <mach/pm_domains.h>
+#include <linux/tegra_pm_domains.h>
 
 #include "tegra-se.h"
 
index f3bf037c08dbf5d638126469e1b7e83661ea6460..3efc84eb4b2f57435c48c3f9838e44532c59c26c 100644 (file)
@@ -35,8 +35,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/clk/tegra.h>
+#include <linux/tegra_pm_domains.h>
 
-#include <mach/pm_domains.h>
 #include "dmaengine.h"
 
 #define TEGRA_APBDMA_GENERAL                   0x0
index 7e2b9afb07f10afcf03949abae75c41b10b3d298..f206fd7d50b83a9561727607afba26bfaa8f5453 100644 (file)
 #include <linux/debugfs.h>
 #include <linux/spinlock.h>
 #include <linux/tegra-powergate.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <linux/sched.h>
 #include <linux/input-cfboost.h>
 
-#include <mach/pm_domains.h>
 
 #include "gk20a.h"
 #include "debug_gk20a.h"
index dff98ef3a273a272fc6d1eb1cbb9c6337d45185d..a5d5ad3e35c8e4861d6ac812d09542f815266545 100644 (file)
@@ -21,8 +21,9 @@
 #include <linux/nvhost_ioctl.h>
 #include <linux/dma-buf.h>
 #include <linux/nvmap.h>
+#include <linux/tegra_pm_domains.h>
+
 #include <mach/irqs.h>
-#include <mach/pm_domains.h>
 
 #include "../../../arch/arm/mach-tegra/iomap.h"
 
index f0a250678cca0eb58b7c3383c0c61a657257ede9..0076fbb6a4fc4bce333bd7a6c4cb2beeacc5c576 100644 (file)
@@ -22,9 +22,9 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <mach/powergate.h>
-#include <mach/pm_domains.h>
 
 #include <media/soc_camera.h>
 #include <media/soc_mediabus.h>
index 7a2fe8a0d2a42c430e81a76a499f821a38449fa7..2e51c87377674282a0975232d419d40cabc33d6d 100644 (file)
@@ -44,8 +44,8 @@
 #include <linux/sched.h>
 #include <linux/memblock.h>
 #include <linux/anon_inodes.h>
+#include <linux/tegra_pm_domains.h>
 
-#include <mach/pm_domains.h>
 
 #include <linux/pm_qos.h>
 
index 34a6792af251e24d53b58268f5920f62000c5eb1..545985821d9f8bfb747d62892fa183640977e4c0 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
+#include <linux/tegra_pm_domains.h>
 
 #ifndef CONFIG_ARM64
 #include <asm/gpio.h>
@@ -45,7 +46,6 @@
 
 #include <linux/platform_data/mmc-sdhci-tegra.h>
 #include <mach/pinmux.h>
-#include <mach/pm_domains.h>
 
 #include "sdhci-pltfm.h"
 
index 0806ea73d3b8a3a01b6276a4ff0d7744ece73b35..455ae530a621e94cb9b955445ab2207f6d0dc014 100644 (file)
 #include <linux/pci-tegra.h>
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <asm/sizes.h>
 #include <asm/mach/pci.h>
 #include <asm/io.h>
 
 #include <mach/tegra_usb_pad_ctrl.h>
-#include <mach/pm_domains.h>
 #include <mach/io_dpd.h>
 #include <mach/pinmux.h>
 #include <mach/pinmux-t12.h>
index 69616aeaa966218efa16eb3858324107e816e7bf..6d36c5e4f3efe69af3471bffb134ff13bac44501 100644 (file)
@@ -4,4 +4,6 @@ endif
 if GOLDFISH
 source "drivers/platform/goldfish/Kconfig"
 endif
-
+if ARCH_TEGRA
+source "drivers/platform/tegra/Kconfig"
+endif
diff --git a/drivers/platform/tegra/Kconfig b/drivers/platform/tegra/Kconfig
new file mode 100644 (file)
index 0000000..25916fd
--- /dev/null
@@ -0,0 +1,23 @@
+
+# Copyright (c) 2012-2014, NVIDIA CORPORATION.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms and conditions of the GNU General Public License,
+# version 2, as published by the Free Software Foundation.
+#
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+comment "NVIDIA Tegra options"
+
+config TEGRA_MC_DOMAINS
+       bool "Enable Tegra MC PM domain"
+       depends on PM_GENERIC_DOMAINS
+       default n
+       help
+         When enabled, clock gates MC when it's not needed.
index c82cc3403b4b0fc5b250f88d102e87b4bd018602..918e2af246b6367a61a7c09838f0c5a4912cfd8f 100644 (file)
@@ -16,6 +16,8 @@ obj-y += mc/
 obj-$(CONFIG_PM_SLEEP) += pm-irq.o
 obj-y += pmc.o
 
+obj-$(CONFIG_TEGRA_MC_DOMAINS) += pm_domains.o
+
 ifneq ($(CONFIG_ARM64),)
 
 ccflags-y += -I$(srctree)/arch/arm/mach-tegra/include \
@@ -48,8 +50,6 @@ obj-y += powergate-ops-txx.o
 obj-y += powergate-ops-t1xx.o
 obj-$(CONFIG_ARCH_TEGRA_12x_SOC)        += powergate-t12x.o
 
-obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
-
 obj-y += dvfs.o
 obj-$(CONFIG_ARCH_TEGRA_13x_SOC) += tegra13_dvfs.o
 obj-$(CONFIG_CPU_FREQ)                  += cpu-tegra.o
@@ -77,6 +77,8 @@ obj-y += tegra_emc.o
 obj-$(CONFIG_ARCH_TEGRA_12x_SOC) += tegra12_emc.o
 obj-$(CONFIG_ARCH_TEGRA_12x_SOC) += tegra_emc_dt_parse.o
 
+obj-$(CONFIG_TEGRA_MC_DOMAINS) += pm_domains.o
+
 obj-y += flowctrl.o
 obj-y += reset.o
 obj-$(CONFIG_DEBUG_ICEDCC) += sysfs-dcc.o
index 19d305704a7d593ded059a1d188036e9f98aaf82..d98999562b95f017c562932f19c9d782a14e5628 100644 (file)
@@ -1,2 +1,270 @@
-/* Automatically generated file; DO NOT EDIT. */
-#include "../../../arch/arm/mach-tegra/pm_domains.c"
+/*
+ * drivers/platform/tegra/pm_domains.c
+ *
+ * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/pm_domain.h>
+#include <linux/tegra_pm_domains.h>
+
+#ifdef CONFIG_TEGRA_MC_DOMAINS
+#define TEGRA_PD_DEV_CALLBACK(callback, dev)                   \
+({                                                             \
+       int (*__routine)(struct device *__d);                   \
+       int __ret = 0;                                          \
+                                                               \
+       if (dev->type && dev->type->pm)                         \
+               __routine = dev->type->pm->callback;            \
+       else if (dev->class && dev->class->pm)                  \
+               __routine = dev->class->pm->callback;           \
+       else if (dev->bus && dev->bus->pm)                      \
+               __routine = dev->bus->pm->callback;             \
+       else                                                    \
+               __routine = NULL;                               \
+                                                               \
+       if (!__routine && dev->driver && dev->driver->pm)       \
+               __routine = dev->driver->pm->callback;          \
+                                                               \
+       if (__routine)                                          \
+               __ret = __routine(dev);                         \
+       __ret;                                                  \
+})
+
+struct domain_client {
+       const char *name;
+       struct generic_pm_domain *domain;
+};
+
+#ifdef CONFIG_PM_SLEEP
+
+static int tegra_pd_suspend_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(suspend, dev);
+}
+
+static int tegra_pd_suspend_late(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(suspend_late, dev);
+}
+
+static int tegra_pd_resume_early(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(resume_early, dev);
+}
+
+static int tegra_pd_resume_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(resume, dev);
+}
+
+static int tegra_pd_freeze_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(freeze, dev);
+}
+
+static int tegra_pd_freeze_late(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(freeze_late, dev);
+}
+
+static int tegra_pd_thaw_early(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(thaw_early, dev);
+}
+
+static int tegra_pd_thaw_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(thaw, dev);
+}
+#else /* !CONFIG_PM_SLEEP */
+
+#define tegra_pd_suspend_dev   NULL
+#define tegra_pd_suspend_late  NULL
+#define tegra_pd_resume_early  NULL
+#define tegra_pd_resume_dev    NULL
+#define tegra_pd_freeze_dev    NULL
+#define tegra_pd_freeze_late   NULL
+#define tegra_pd_thaw_early    NULL
+#define tegra_pd_thaw_dev      NULL
+
+#endif /* !CONFIG_PM_SLEEP */
+
+static bool tegra_pd_active_wakeup(struct device *dev)
+{
+       return device_may_wakeup(dev);
+}
+
+static int tegra_pd_save_dev(struct device *dev)
+{
+       return 0;
+}
+
+static int tegra_pd_restore_dev(struct device *dev)
+{
+       return 0;
+}
+
+static int tegra_pd_stop_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(runtime_suspend, dev);
+}
+
+static int tegra_pd_start_dev(struct device *dev)
+{
+       return TEGRA_PD_DEV_CALLBACK(runtime_resume, dev);
+}
+
+struct gpd_dev_ops tegra_pd_ops = {
+       .active_wakeup = tegra_pd_active_wakeup,
+       .save_state = tegra_pd_save_dev,
+       .restore_state = tegra_pd_restore_dev,
+       .stop = tegra_pd_stop_dev,
+       .start = tegra_pd_start_dev,
+       .suspend = tegra_pd_suspend_dev,
+       .suspend_late = tegra_pd_suspend_late,
+       .resume_early = tegra_pd_resume_early,
+       .resume = tegra_pd_resume_dev,
+       .freeze = tegra_pd_freeze_dev,
+       .freeze_late = tegra_pd_freeze_late,
+       .thaw_early = tegra_pd_thaw_early,
+       .thaw = tegra_pd_thaw_dev,
+};
+
+static int tegra_mc_clk_power_off(struct generic_pm_domain *genpd)
+{
+       struct tegra_pm_domain *pd = to_tegra_pd(genpd);
+
+       if (!pd)
+               return -EINVAL;
+
+       if (IS_ERR_OR_NULL(pd->clk))
+               return 0;
+
+       clk_disable_unprepare(pd->clk);
+
+       return 0;
+}
+
+static int tegra_mc_clk_power_on(struct generic_pm_domain *genpd)
+{
+       struct tegra_pm_domain *pd = to_tegra_pd(genpd);
+
+       if (!pd)
+               return -EINVAL;
+
+       if (IS_ERR_OR_NULL(pd->clk))
+               return 0;
+
+       clk_prepare_enable(pd->clk);
+
+       return 0;
+}
+
+static struct tegra_pm_domain tegra_nvavp = {
+       .gpd.name = "tegra_nvavp",
+};
+
+static struct tegra_pm_domain tegra_mc_clk = {
+       .gpd.name = "tegra_mc_clk",
+       .gpd.power_off = tegra_mc_clk_power_off,
+       .gpd.power_on = tegra_mc_clk_power_on,
+};
+
+static struct domain_client client_list[] = {
+       { .name = "tegradc", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra30-hda", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-apbdma", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-otg", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-ehci", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-xhci", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-host1x", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra_nvavp", .domain = &tegra_mc_clk.gpd },
+       { .name = "nvavp", .domain = &tegra_nvavp.gpd },
+       { .name = "sdhci-tegra", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra11-se", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra12-se", .domain = &tegra_mc_clk.gpd },
+       { .name = "tegra-pcie", .domain = &tegra_mc_clk.gpd },
+       { .name = "gpu", .domain = &tegra_mc_clk.gpd },
+       {},
+};
+
+static int __init tegra_init_pm_domain(void)
+{
+       pm_genpd_init(&tegra_mc_clk.gpd, &simple_qos_governor, false);
+
+       pm_genpd_init(&tegra_nvavp.gpd, &simple_qos_governor, false);
+       tegra_pd_add_sd(&tegra_nvavp.gpd);
+
+       return 0;
+}
+core_initcall(tegra_init_pm_domain);
+
+static struct generic_pm_domain *tegra_pd_get_domain(const char *client)
+{
+       const char *s;
+       struct domain_client *clients = client_list;
+
+       while ((s = clients->name) != NULL) {
+               if (!strncmp(s, client, strlen(s)))
+                       return clients->domain;
+
+               clients++;
+       }
+       return NULL;
+}
+
+void tegra_pd_add_device(struct device *dev)
+{
+       struct generic_pm_domain *master = tegra_pd_get_domain(dev_name(dev));
+
+       if (!master)
+               return;
+
+       device_set_wakeup_capable(dev, 1);
+       pm_genpd_add_device(master, dev);
+       pm_genpd_dev_need_save(dev, false);
+       pm_genpd_add_callbacks(dev, &tegra_pd_ops, NULL);
+}
+EXPORT_SYMBOL(tegra_pd_add_device);
+
+void tegra_pd_remove_device(struct device *dev)
+{
+       struct generic_pm_domain *genpd = dev_to_genpd(dev);
+
+       if (!IS_ERR_OR_NULL(genpd))
+               pm_genpd_remove_device(genpd, dev);
+}
+EXPORT_SYMBOL(tegra_pd_remove_device);
+
+void tegra_pd_add_sd(struct generic_pm_domain *sd)
+{
+       struct generic_pm_domain *master = tegra_pd_get_domain(sd->name);
+
+       if (!master)
+               return;
+
+       pm_genpd_add_subdomain(master, sd);
+}
+EXPORT_SYMBOL(tegra_pd_add_sd);
+#else
+struct tegra_pm_domain tegra_mc_clk;
+EXPORT_SYMBOL(tegra_mc_clk);
+struct tegra_pm_domain tegra_mc_chain_a;
+EXPORT_SYMBOL(tegra_mc_chain_a);
+struct tegra_pm_domain tegra_mc_chain_b;
+EXPORT_SYMBOL(tegra_mc_chain_b);
+#endif
index 6fb05ea20e5035ebd897d4fc958f9600800f2a06..56ea68ec4861f073cccfc04bccf634d1a381cc9f 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <linux/usb/tegra_usb_phy.h>
 
-#include <mach/pm_domains.h>
+#include <linux/tegra_pm_domains.h>
 #include <linux/pm_qos.h>
 
 /* HACK! This needs to come from DT */
index ddc1f3b8dde9e73ce62992e4bcc398b021056dc6..559fab9810cb4f0c9112ba6348643e4ae72f981f 100644 (file)
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/tegra-fuse.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <mach/tegra_usb_pad_ctrl.h>
 #include <mach/tegra_usb_pmc.h>
-#include <mach/pm_domains.h>
 #include <mach/mc.h>
 #include <mach/xusb.h>
 
index 0709fe6a282f8ba8d7afabc04200ab52d50c9bdc..7d8d84b34fb638f690e9b3d143cfb8fe0f49dc55 100644 (file)
@@ -36,8 +36,8 @@
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
 #include <linux/usb/hcd.h>
+#include <linux/tegra_pm_domains.h>
 
-#include <mach/pm_domains.h>
 #include <mach/tegra_usb_pad_ctrl.h>
 
 #define USB_PHY_WAKEUP         0x408
index 12252eff9ef7dc1227db3578d9fc591cd6c14258..57f9fa935122c3e1a4df5246d44ccf9cd70a0200 100644 (file)
@@ -45,6 +45,7 @@
 #endif
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
+#include <linux/tegra_pm_domains.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/display.h>
@@ -55,7 +56,6 @@
 #include <linux/nvhost.h>
 #include <linux/nvhost_ioctl.h>
 #include <mach/latency_allowance.h>
-#include <mach/pm_domains.h>
 
 #include "dc_reg.h"
 #include "dc_config.h"
index f13200a06e5b755fa2b44c86e4a004dcf3cd0310..7f34b36e97cfd6ab91a12613d6c26b189dba6ab6 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/tegra-soc.h>
+#include <linux/tegra_pm_domains.h>
 
 #include "dev.h"
 #include <trace/events/nvhost.h>
@@ -38,8 +39,6 @@
 #include <linux/nvhost.h>
 #include <linux/nvhost_ioctl.h>
 
-#include <mach/pm_domains.h>
-
 #include "debug.h"
 #include "bus_client.h"
 #include "nvhost_acm.h"
index f89393dd9149abcb95dc4f556b9e7b71c43ca168..887be6b464131eedfa3d90a5cbd85cea410141c7 100644 (file)
@@ -26,8 +26,7 @@
 #include <linux/of_platform.h>
 #include <linux/irq.h>
 #include <linux/workqueue.h>
-
-#include <mach/pm_domains.h>
+#include <linux/tegra_pm_domains.h>
 
 #include "dev.h"
 #include "bus_client.h"
index fef034bdfdff9383d1a88a44974b9fcf4bde057d..7f566b058ee20d1b8691541f50dccc9b42e9811c 100644 (file)
@@ -29,8 +29,7 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/dma-mapping.h>
-
-#include <mach/pm_domains.h>
+#include <linux/tegra_pm_domains.h>
 
 #include "dev.h"
 #include "msenc.h"
index 616a20daecb2f96955056b891096da499d7a747c..d7ba643277b9f0ec66b6e5f95d8e1d3ad5ee481a 100644 (file)
@@ -34,9 +34,9 @@
 #include <linux/tegra-soc.h>
 #include <trace/events/nvhost.h>
 #include <linux/platform_data/tegra_edp.h>
+#include <linux/tegra_pm_domains.h>
 
 #include <mach/mc.h>
-#include <mach/pm_domains.h>
 
 #include "nvhost_acm.h"
 #include "nvhost_channel.h"
index 6afc058524708ca736f97fa368421169f81cc1d7..3f71b2482c0f86b829501377cdd3a3a5c8496b25 100644 (file)
@@ -29,8 +29,8 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/dma-mapping.h>
+#include <linux/tegra_pm_domains.h>
 
-#include <mach/pm_domains.h>
 #include <mach/hardware.h>
 
 #include "dev.h"
index 901ffad3045721ea3d9e431d328ea1671b5f2a56..94d426363a72704ea2e4ba894ebedec124acf248 100644 (file)
@@ -26,8 +26,8 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/clk/tegra.h>
+#include <linux/tegra_pm_domains.h>
 
-#include <mach/pm_domains.h>
 #include <media/tegra_v4l2_camera.h>
 
 #include "dev.h"
index 2a62262a2df6e871d25f30a23e81b0bb8893683b..3b5726012df0dbf2b9fbe4a9eb3c08dfed7185db 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/tegra-powergate.h>
 #include <linux/tegra-soc.h>
+#include <linux/tegra_pm_domains.h>
 
 #include "dev.h"
 #include "class_ids.h"
@@ -46,7 +47,6 @@
 #include "t124/hardware_t124.h" /* for nvhost opcodes*/
 #include "t124/t124.h"
 
-#include <mach/pm_domains.h>
 
 #include "../../../../../arch/arm/mach-tegra/iomap.h"
 
similarity index 90%
rename from arch/arm/mach-tegra/include/mach/pm_domains.h
rename to include/linux/tegra_pm_domains.h
index 783617cd2ae64a6d6f0b136b688f6f24a63338dd..c381f4c4bba71382cd3c801072d25acca9b39991 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * arch/arm/mach-tegra/include/mach/pm_domains.h
+ * include/linux/tegra_pm_domains.h
  *
  * Copyright (c) 2012-2014, NVIDIA CORPORATION.  All rights reserved.
  *
@@ -17,8 +17,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-#ifndef _MACH_TEGRA_PM_DOMAINS_H_
-#define _MACH_TEGRA_PM_DOMAINS_H_
+#ifndef _INCLUDE_TEGRA_PM_DOMAINS_H_
+#define _INCLUDE_TEGRA_PM_DOMAINS_H_
 
 #include <linux/clk.h>
 #include <linux/pm_domain.h>
@@ -45,4 +45,4 @@ static inline void tegra_pd_remove_device(struct device *dev) { }
 static inline void tegra_pd_add_sd(struct generic_pm_domain *sd) { }
 #endif /* CONFIG_TEGRA_MC_DOMAINS */
 
-#endif /* _MACH_TEGRA_PM_DOMAINS_H_ */
+#endif /* _INCLUDE_TEGRA_PM_DOMAINS_H_ */
index 30e7fd27471e63abf3a7aeed1ac8316b9f2c7f5f..fe10a0dab60414079840f237bb083a1be0a812e5 100644 (file)
@@ -69,7 +69,7 @@
 #endif
 #ifdef CONFIG_SND_HDA_PLATFORM_NVIDIA_TEGRA
 #include <linux/tegra-powergate.h>
-#include <mach/pm_domains.h>
+#include <linux/tegra_pm_domains.h>
 #endif
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;