linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Daniel Kachhap <amit.daniel@samsung.com>
To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org
Cc: kgene.kim@samsung.com, linux-kernel@vger.kernel.org,
	s.nawrocki@samsung.com, lee.jones@linaro.org,
	Amit Daniel Kachhap <amit.daniel@samsung.com>
Subject: [PATCH v2 4/6] soc: samsung: exynos-pmu: Register exynos-pmu driver as a mfd driver
Date: Sat, 08 Nov 2014 18:46:39 +0530	[thread overview]
Message-ID: <1415452601-13078-5-git-send-email-amit.daniel@samsung.com> (raw)
In-Reply-To: <1415452601-13078-1-git-send-email-amit.daniel@samsung.com>

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@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
 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


  parent reply	other threads:[~2014-11-08 13:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-08 13:16 [PATCH v2 0/6] exynos: Move pmu driver to driver/soc folder and add exynos7 support Amit Daniel Kachhap
2014-11-08 13:16 ` [PATCH v2 1/6] ARM: EXYNOS: Move pmu specific header files under "linux/soc/samsung" Amit Daniel Kachhap
2014-11-08 13:16 ` [PATCH v2 2/6] drivers: soc: Add support for Exynos PMU driver Amit Daniel Kachhap
2014-11-08 17:15   ` Pankaj Dubey
2014-11-10  5:07     ` amit daniel kachhap
2014-11-08 13:16 ` [PATCH v2 3/6] drivers: soc: samsung: Fix a spelling mistake Amit Daniel Kachhap
2014-11-08 15:56   ` Pankaj Dubey
2014-11-10  4:59     ` amit daniel kachhap
2014-11-08 13:16 ` Amit Daniel Kachhap [this message]
2014-11-08 13:16 ` [PATCH v2 5/6] driver: soc: exynos-pmu: Add an API to be called after wakeup Amit Daniel Kachhap
2014-11-08 13:16 ` [PATCH v2 6/6] drivers: soc: samsung: Add support for Exynos7 pmu Amit Daniel Kachhap
2014-11-08 17:35   ` Pankaj Dubey
2014-11-10  5:10     ` amit daniel kachhap
2014-11-13  8:56 ` [PATCH v2 0/6] exynos: Move pmu driver to driver/soc folder and add exynos7 support amit daniel kachhap
2014-11-19  8:04   ` Kukjin Kim
2014-11-20  5:59     ` amit daniel kachhap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415452601-13078-5-git-send-email-amit.daniel@samsung.com \
    --to=amit.daniel@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=s.nawrocki@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).