diff mbox series

[v3,01/13] soc: samsung: pmu: Provide global function to get PMU regmap

Message ID 1484833733-16082-2-git-send-email-m.szyprowski@samsung.com
State Accepted
Commit 76640b84bd7a9d68c70d8bc8ecd02cdc4bd8855e
Headers show
Series Move pad retention control to Exynos pin controller driver | expand

Commit Message

Marek Szyprowski Jan. 19, 2017, 1:48 p.m. UTC
PMU is something like a SoC wide service, so add a helper function to get
PMU regmap. This will be used by other Exynos device drivers. This way it
can be avoided to model this dependency in device tree (as phandles to PMU
node) for almost every device in the SoC.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com>

---
 drivers/soc/samsung/exynos-pmu.c       | 11 +++++++++++
 include/linux/soc/samsung/exynos-pmu.h | 10 ++++++++++
 2 files changed, 21 insertions(+)

-- 
1.9.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Comments

Linus Walleij Jan. 26, 2017, 3:54 p.m. UTC | #1
On Thu, Jan 26, 2017 at 11:22 AM, Marek Szyprowski
<m.szyprowski@samsung.com> wrote:

> syscon_regmap_lookup_by_compatible() requires to have a compatible string

> hardcoded in the client driver. This might be used, but will require to have

> (and maintain) a duplicated list of PMU compatibles in pin control driver.

> There is a little problem with exynos4212 and exynos4412, which have same

> pinctrl compatible (samsung,exynos4x12-pinctrl), but separate PMU

> compatibles


I actually used this approach with the ARM reference designs:
drivers/mtd/maps/physmap_of_versatile.c
drivers/video/fbdev/amba-clcd-versatile.c

It made sense to me, because for each compatible I anyways
needed the .data field to distinguish between the different
system controllers, because they are of course all slightly
idiomatic.

I guess in your case you can distinguish how to use the syscon
by the pinctrl compatible instead.

Oh well.

I guess I'm OK with this then. I'll try to pull it in and see what
happens.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff mbox series

Patch

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index 0acdfd82e751..5c269bf23210 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -11,6 +11,7 @@ 
 
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/mfd/syscon.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 
@@ -92,6 +93,16 @@  void exynos_sys_powerdown_conf(enum sys_powerdown mode)
 	{ /*sentinel*/ },
 };
 
+struct regmap *exynos_get_pmu_regmap(void)
+{
+	struct device_node *np = of_find_matching_node(NULL,
+						      exynos_pmu_of_device_ids);
+	if (np)
+		return syscon_node_to_regmap(np);
+	return ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap);
+
 static int exynos_pmu_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
diff --git a/include/linux/soc/samsung/exynos-pmu.h b/include/linux/soc/samsung/exynos-pmu.h
index e2e9de1acc5b..e57eb4b6cc5a 100644
--- a/include/linux/soc/samsung/exynos-pmu.h
+++ b/include/linux/soc/samsung/exynos-pmu.h
@@ -12,6 +12,8 @@ 
 #ifndef __LINUX_SOC_EXYNOS_PMU_H
 #define __LINUX_SOC_EXYNOS_PMU_H
 
+struct regmap;
+
 enum sys_powerdown {
 	SYS_AFTR,
 	SYS_LPA,
@@ -20,5 +22,13 @@  enum sys_powerdown {
 };
 
 extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
+#ifdef CONFIG_EXYNOS_PMU
+extern struct regmap *exynos_get_pmu_regmap(void);
+#else
+static inline struct regmap *exynos_get_pmu_regmap(void)
+{
+	return ERR_PTR(-ENODEV);
+}
+#endif
 
 #endif /* __LINUX_SOC_EXYNOS_PMU_H */