[PATCH v2 4/6] soc: samsung: exynos-pmu: Register exynos-pmu driver as a mfd driver

From: Amit Daniel Kachhap
Date: Sat Nov 08 2014 - 08:23:30 EST


This can be used later to probe and configure PMU client drivers
like pm domain, pm sleep etc. A global structure pmu_dev_client_data is
created to pass exynos-pmu platform data to all the clients. Currently
the data passed is register base addresses.
Although the exynos-pmu driver also provides the sysreg interfaces to
provide register base addresses but this is costlier than readl/writel,
so both the interfaces are provided to mfd based exynos-pmu client
drivers.

Reviewed-by: Pankaj Dubey <pankaj.dubey@xxxxxxxxxxx>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@xxxxxxxxxxx>
---
drivers/soc/samsung/exynos-pmu.c | 24 ++++++++++++++++++++++++
include/linux/soc/samsung/exynos-pmu.h | 5 +++++
2 files changed, 29 insertions(+)

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index 3832cda..4a5eb50 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -12,11 +12,17 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/mfd/core.h>
#include <linux/soc/samsung/exynos-regs-pmu.h>
#include <linux/soc/samsung/exynos-pmu.h>

#define PMU_TABLE_END (-1U)

+enum pmu_mfd_list {
+ MFD_POWER_DOMAIN,
+ MFD_MAX,
+};
+
struct exynos_pmu_conf {
unsigned int offset;
unsigned int val[NUM_SYS_POWERDOWN];
@@ -33,6 +39,8 @@ struct exynos_pmu_data {
struct exynos_pmu_context {
struct device *dev;
const struct exynos_pmu_data *pmu_data;
+ struct mfd_cell cells[MFD_MAX];
+ struct pmu_dev_client_data mfd_data;
};

static void __iomem *pmu_base_addr;
@@ -482,6 +490,8 @@ static int exynos_pmu_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct device *dev = &pdev->dev;
struct resource *res;
+ struct mfd_cell *cell;
+ int ret;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pmu_base_addr = devm_ioremap_resource(dev, res);
@@ -506,6 +516,20 @@ static int exynos_pmu_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, pmu_context);

+ /* Initialize and invoke mfd clients */
+ cell = &pmu_context->cells[MFD_POWER_DOMAIN];
+ cell->name = "exynos-pmu-sleep";
+ pmu_context->mfd_data.mem_base_addr = pmu_base_addr;
+ pmu_context->mfd_data.mem_size = resource_size(res);
+ cell->platform_data = &pmu_context->mfd_data;
+ cell->pdata_size = sizeof(pmu_context->mfd_data);
+ ret = mfd_add_devices(&pdev->dev, pdev->id, pmu_context->cells, MFD_MAX,
+ NULL, 0, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "fail to register client devices\n");
+ return ret;
+ }
+
dev_dbg(dev, "Exynos PMU Driver probe done\n");
return 0;
}
diff --git a/include/linux/soc/samsung/exynos-pmu.h b/include/linux/soc/samsung/exynos-pmu.h
index a2ab0d5..d2f4083 100644
--- a/include/linux/soc/samsung/exynos-pmu.h
+++ b/include/linux/soc/samsung/exynos-pmu.h
@@ -19,6 +19,11 @@ enum sys_powerdown {
NUM_SYS_POWERDOWN,
};

+struct pmu_dev_client_data {
+ void __iomem *mem_base_addr;
+ unsigned int mem_size;
+};
+
extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);

#endif /* __EXYNOS_PMU_H */
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/