soc: dove: add legacy support to PMU driver
authorRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 8 Dec 2015 10:43:28 +0000 (10:43 +0000)
committerGregory CLEMENT <gregory.clement@free-electrons.com>
Tue, 8 Dec 2015 12:19:29 +0000 (13:19 +0100)
Add support for legacy non-DT Dove to the PMU driver, so that we can
transition the legacy support over.

[gregory.clement@free-electrons.com: removed pm_genpd_poweroff_unused]
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
drivers/soc/Makefile
drivers/soc/dove/pmu.c
include/linux/soc/dove/pmu.h

index f2ba2e932ae10c5d2cda1de269b826b9875a4a5c..d52872680f8654caed6793d8d311b8e48977838e 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_SOC_BRCMSTB)      += brcmstb/
+obj-$(CONFIG_ARCH_DOVE)                += dove/
 obj-$(CONFIG_MACH_DOVE)                += dove/
 obj-$(CONFIG_ARCH_MEDIATEK)    += mediatek/
 obj-$(CONFIG_ARCH_QCOM)                += qcom/
index abd087917f807e03a466337a0fcf26cfd3499243..039374e9fdc03038159a685eb7ee49e83d9c2a28 100644 (file)
@@ -305,6 +305,49 @@ static int __init dove_init_pmu_irq(struct pmu_data *pmu, int irq)
        return 0;
 }
 
+int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata)
+{
+       const struct dove_pmu_domain_initdata *domain_initdata;
+       struct pmu_data *pmu;
+       int ret;
+
+       pmu = kzalloc(sizeof(*pmu), GFP_KERNEL);
+       if (!pmu)
+               return -ENOMEM;
+
+       spin_lock_init(&pmu->lock);
+       pmu->pmc_base = initdata->pmc_base;
+       pmu->pmu_base = initdata->pmu_base;
+
+       pmu_reset_init(pmu);
+       for (domain_initdata = initdata->domains; domain_initdata->name;
+            domain_initdata++) {
+               struct pmu_domain *domain;
+
+               domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+               if (domain) {
+                       domain->pmu = pmu;
+                       domain->pwr_mask = domain_initdata->pwr_mask;
+                       domain->rst_mask = domain_initdata->rst_mask;
+                       domain->iso_mask = domain_initdata->iso_mask;
+                       domain->base.name = domain_initdata->name;
+
+                       __pmu_domain_register(domain, NULL);
+               }
+       }
+
+       ret = dove_init_pmu_irq(pmu, initdata->irq);
+       if (ret)
+               pr_err("dove_init_pmu_irq() failed: %d\n", ret);
+
+       if (pmu->irq_domain)
+               irq_domain_associate_many(pmu->irq_domain,
+                                         initdata->irq_domain_start,
+                                         0, NR_PMU_IRQS);
+
+       return 0;
+}
+
 /*
  * pmu: power-manager@d0000 {
  *     compatible = "marvell,dove-pmu";
index 9c99f84bcc0e36baa9c4dbf1041c415b8965b4e6..765386972b55286caab046d401692f63627cc388 100644 (file)
@@ -1,6 +1,25 @@
 #ifndef LINUX_SOC_DOVE_PMU_H
 #define LINUX_SOC_DOVE_PMU_H
 
+#include <linux/types.h>
+
+struct dove_pmu_domain_initdata {
+       u32 pwr_mask;
+       u32 rst_mask;
+       u32 iso_mask;
+       const char *name;
+};
+
+struct dove_pmu_initdata {
+       void __iomem *pmc_base;
+       void __iomem *pmu_base;
+       int irq;
+       int irq_domain_start;
+       const struct dove_pmu_domain_initdata *domains;
+};
+
+int dove_init_pmu_legacy(const struct dove_pmu_initdata *);
+
 int dove_init_pmu(void);
 
 #endif