All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: tony@atomide.com, paul@pwsan.com, linux-omap@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 21/35] ARM: OMAP2+: clock: add low-level support for regmap
Date: Wed, 25 Feb 2015 21:04:31 +0200	[thread overview]
Message-ID: <1424891085-10392-22-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1424891085-10392-1-git-send-email-t-kristo@ti.com>

Some of the TI clock providers will be converted to use syscon, thus
low-level regmap support is needed for the clock drivers also. This
patch adds this support, which can be enabled for individual drivers
in later patches.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/clock.c      |   39 ++++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/clock.h      |    4 +++-
 arch/arm/mach-omap2/cm_common.c  |    2 +-
 arch/arm/mach-omap2/control.c    |    2 +-
 arch/arm/mach-omap2/prm_common.c |    2 +-
 5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 3327128..d9885b8 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -23,6 +23,7 @@
 #include <linux/clk-provider.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/regmap.h>
 #include <linux/of_address.h>
 #include <asm/cpu.h>
 
@@ -73,20 +74,37 @@ struct ti_clk_features ti_clk_features;
 static bool clkdm_control = true;
 
 static LIST_HEAD(clk_hw_omap_clocks);
-static void __iomem *clk_memmaps[CLK_MAX_MEMMAPS];
+
+struct clk_iomap {
+	struct regmap *regmap;
+	void __iomem *mem;
+};
+
+static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
 
 static void clk_memmap_writel(u32 val, void __iomem *reg)
 {
 	struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+	struct clk_iomap *io = clk_memmaps[r->index];
 
-	writel_relaxed(val, clk_memmaps[r->index] + r->offset);
+	if (io->regmap)
+		regmap_write(io->regmap, r->offset, val);
+	else
+		writel_relaxed(val, io->mem + r->offset);
 }
 
 static u32 clk_memmap_readl(void __iomem *reg)
 {
+	u32 val;
 	struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+	struct clk_iomap *io = clk_memmaps[r->index];
+
+	if (io->regmap)
+		regmap_read(io->regmap, r->offset, &val);
+	else
+		val = readl_relaxed(io->mem + r->offset);
 
-	return readl_relaxed(clk_memmaps[r->index] + r->offset);
+	return val;
 }
 
 void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
@@ -119,18 +137,27 @@ static struct ti_clk_ll_ops omap_clk_ll_ops = {
  * @match_table: DT device table to match for devices to init
  * @np: device node pointer for the this clock provider
  * @index: index for the clock provider
- * @mem: iomem pointer for the clock provider memory area
+ + @syscon: syscon regmap pointer
+ * @mem: iomem pointer for the clock provider memory area, only used if
+ *	 syscon is not provided
  *
  * Initializes a clock provider module (CM/PRM etc.), registering
  * the memory mapping at specified index and initializing the
  * low level driver infrastructure. Returns 0 in success.
  */
 int __init omap2_clk_provider_init(struct device_node *np, int index,
-				   void __iomem *mem)
+				   struct regmap *syscon, void __iomem *mem)
 {
+	struct clk_iomap *io;
+
 	ti_clk_ll_ops = &omap_clk_ll_ops;
 
-	clk_memmaps[index] = mem;
+	io = kzalloc(sizeof(*io), GFP_KERNEL);
+
+	io->regmap = syscon;
+	io->mem = mem;
+
+	clk_memmaps[index] = io;
 
 	ti_dt_clk_init_provider(np, index);
 
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index b6433fc..652ed0a 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -274,8 +274,10 @@ extern const struct clksel_rate div31_1to31_rates[];
 extern int omap2_clkops_enable_clkdm(struct clk_hw *hw);
 extern void omap2_clkops_disable_clkdm(struct clk_hw *hw);
 
+struct regmap;
+
 int __init omap2_clk_provider_init(struct device_node *np, int index,
-				   void __iomem *mem);
+				   struct regmap *syscon, void __iomem *mem);
 void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem);
 
 void __init ti_clk_init_features(void);
diff --git a/arch/arm/mach-omap2/cm_common.c b/arch/arm/mach-omap2/cm_common.c
index 0845194..2582651 100644
--- a/arch/arm/mach-omap2/cm_common.c
+++ b/arch/arm/mach-omap2/cm_common.c
@@ -332,7 +332,7 @@ int __init omap_cm_init(void)
 		if (data->flags & CM_NO_CLOCKS)
 			continue;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 074c333..2b54250 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -675,7 +675,7 @@ int __init omap_control_init(void)
 	for_each_matching_node_and_match(np, omap_scrm_dt_match_table, &match) {
 		data = match->data;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 44221fe..eb9e0c2 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -766,7 +766,7 @@ int __init omap_prcm_init(void)
 	for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) {
 		data = match->data;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
-- 
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 21/35] ARM: OMAP2+: clock: add low-level support for regmap
Date: Wed, 25 Feb 2015 21:04:31 +0200	[thread overview]
Message-ID: <1424891085-10392-22-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1424891085-10392-1-git-send-email-t-kristo@ti.com>

Some of the TI clock providers will be converted to use syscon, thus
low-level regmap support is needed for the clock drivers also. This
patch adds this support, which can be enabled for individual drivers
in later patches.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/clock.c      |   39 ++++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/clock.h      |    4 +++-
 arch/arm/mach-omap2/cm_common.c  |    2 +-
 arch/arm/mach-omap2/control.c    |    2 +-
 arch/arm/mach-omap2/prm_common.c |    2 +-
 5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 3327128..d9885b8 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -23,6 +23,7 @@
 #include <linux/clk-provider.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/regmap.h>
 #include <linux/of_address.h>
 #include <asm/cpu.h>
 
@@ -73,20 +74,37 @@ struct ti_clk_features ti_clk_features;
 static bool clkdm_control = true;
 
 static LIST_HEAD(clk_hw_omap_clocks);
-static void __iomem *clk_memmaps[CLK_MAX_MEMMAPS];
+
+struct clk_iomap {
+	struct regmap *regmap;
+	void __iomem *mem;
+};
+
+static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
 
 static void clk_memmap_writel(u32 val, void __iomem *reg)
 {
 	struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+	struct clk_iomap *io = clk_memmaps[r->index];
 
-	writel_relaxed(val, clk_memmaps[r->index] + r->offset);
+	if (io->regmap)
+		regmap_write(io->regmap, r->offset, val);
+	else
+		writel_relaxed(val, io->mem + r->offset);
 }
 
 static u32 clk_memmap_readl(void __iomem *reg)
 {
+	u32 val;
 	struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+	struct clk_iomap *io = clk_memmaps[r->index];
+
+	if (io->regmap)
+		regmap_read(io->regmap, r->offset, &val);
+	else
+		val = readl_relaxed(io->mem + r->offset);
 
-	return readl_relaxed(clk_memmaps[r->index] + r->offset);
+	return val;
 }
 
 void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
@@ -119,18 +137,27 @@ static struct ti_clk_ll_ops omap_clk_ll_ops = {
  * @match_table: DT device table to match for devices to init
  * @np: device node pointer for the this clock provider
  * @index: index for the clock provider
- * @mem: iomem pointer for the clock provider memory area
+ + @syscon: syscon regmap pointer
+ * @mem: iomem pointer for the clock provider memory area, only used if
+ *	 syscon is not provided
  *
  * Initializes a clock provider module (CM/PRM etc.), registering
  * the memory mapping at specified index and initializing the
  * low level driver infrastructure. Returns 0 in success.
  */
 int __init omap2_clk_provider_init(struct device_node *np, int index,
-				   void __iomem *mem)
+				   struct regmap *syscon, void __iomem *mem)
 {
+	struct clk_iomap *io;
+
 	ti_clk_ll_ops = &omap_clk_ll_ops;
 
-	clk_memmaps[index] = mem;
+	io = kzalloc(sizeof(*io), GFP_KERNEL);
+
+	io->regmap = syscon;
+	io->mem = mem;
+
+	clk_memmaps[index] = io;
 
 	ti_dt_clk_init_provider(np, index);
 
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index b6433fc..652ed0a 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -274,8 +274,10 @@ extern const struct clksel_rate div31_1to31_rates[];
 extern int omap2_clkops_enable_clkdm(struct clk_hw *hw);
 extern void omap2_clkops_disable_clkdm(struct clk_hw *hw);
 
+struct regmap;
+
 int __init omap2_clk_provider_init(struct device_node *np, int index,
-				   void __iomem *mem);
+				   struct regmap *syscon, void __iomem *mem);
 void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem);
 
 void __init ti_clk_init_features(void);
diff --git a/arch/arm/mach-omap2/cm_common.c b/arch/arm/mach-omap2/cm_common.c
index 0845194..2582651 100644
--- a/arch/arm/mach-omap2/cm_common.c
+++ b/arch/arm/mach-omap2/cm_common.c
@@ -332,7 +332,7 @@ int __init omap_cm_init(void)
 		if (data->flags & CM_NO_CLOCKS)
 			continue;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 074c333..2b54250 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -675,7 +675,7 @@ int __init omap_control_init(void)
 	for_each_matching_node_and_match(np, omap_scrm_dt_match_table, &match) {
 		data = match->data;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 44221fe..eb9e0c2 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -766,7 +766,7 @@ int __init omap_prcm_init(void)
 	for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) {
 		data = match->data;
 
-		ret = omap2_clk_provider_init(np, data->index, data->mem);
+		ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
 		if (ret)
 			return ret;
 	}
-- 
1.7.9.5

  parent reply	other threads:[~2015-02-25 19:05 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 19:04 [PATCHv3 00/35] ARM: OMAP2+: PRCM / SCM cleanups against 4.0-rc1 Tero Kristo
2015-02-25 19:04 ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 01/35] ARM: OMAP2+: PRCM: rename of_prcm_init to omap_prcm_init Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 02/35] ARM: OMAP3: PRM: invert the wkst_mask for the prm_clear_mod_irqs Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 03/35] ARM: OMAP2+: PRM: add generic API for clear_mod_irqs Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:08   ` Felipe Balbi
2015-02-25 19:08     ` Felipe Balbi
2015-02-25 19:04 ` [PATCHv3 04/35] ARM: OMAP3+: PRM: add common APIs for prm_vp_check/clear_txdone Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:09   ` Felipe Balbi
2015-02-25 19:09     ` Felipe Balbi
2015-02-25 19:44     ` Tero Kristo
2015-02-25 19:44       ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 05/35] ARM: OMAP4+: PRM: move omap_prm_base_init under OMAP4 PRM driver Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 06/35] ARM: OMAP4+: CM: move omap_cm_base_init under OMAP4 CM driver Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 07/35] ARM: OMAP4: PRM: move omap4xxx_prm_init earlier in init order Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 08/35] clk: ti: fix ti_clk_get_reg_addr error handling Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-03-06 19:18   ` Mike Turquette
2015-03-06 19:18     ` Mike Turquette
2015-03-17 18:38     ` Tony Lindgren
2015-03-17 18:38       ` Tony Lindgren
2015-03-18  7:06       ` Tero Kristo
2015-03-18  7:06         ` Tero Kristo
2015-03-18 17:02         ` Tony Lindgren
2015-03-18 17:02           ` Tony Lindgren
2015-03-19  7:14           ` Tero Kristo
2015-03-19  7:14             ` Tero Kristo
2015-03-20  7:00     ` Tero Kristo
2015-03-20  7:00       ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 09/35] Documentation: DT: document PRCM compatible strings for dm81x SoCs Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 10/35] ARM: OMAP2+: PRCM: add support for static clock memmap indices Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 11/35] ARM: OMAP2+: clock: move clock provider infrastructure to clock driver Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 12/35] ARM: OMAP2+: PRCM: split PRCM module init to their own driver files Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 13/35] ARM: OMAP2+: CM: determine CM base address from device tree Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 14/35] ARM: OMAP2+: PRM: determine PRM " Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 15/35] ARM: OMAP2+: control: determine control module base address from DT Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 16/35] ARM: OMAP2+: PRM: move SoC specific init calls within a generic API Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 17/35] ARM: OMAP4+: PRM: determine prm_device_inst based on DT compatibility Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 18/35] ARM: OMAP2+: CM: move SoC specific init calls within a generic API Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 19/35] ARM: OMAP4+: PRM: setup prm_features from the PRM init time flags Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 20/35] ARM: OMAP4+: PRM: get rid of cpu_is_omap44xx calls from interrupt init Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` Tero Kristo [this message]
2015-02-25 19:04   ` [PATCHv3 21/35] ARM: OMAP2+: clock: add low-level support for regmap Tero Kristo
2015-02-25 19:04 ` [PATCHv3 22/35] ARM: OMAP2+: control: remove API for getting control module base address Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 23/35] ARM: OMAP2+: id: cache omap_type value Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 24/35] ARM: OMAP2+: control: add syscon support for register accesses Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 25/35] ARM: dts: omap24xx: merge control module features under scrm node Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 26/35] ARM: dts: omap3: " Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 27/35] ARM: dts: am33xx: " Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 28/35] ARM: dts: am43xx-epos-evm: fix pinmux node layout Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 29/35] ARM: dts: am4372: merge control module features under scrm node Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 30/35] ARM: dts: omap4: add system control module node Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 31/35] ARM: OMAP4: display: convert display to use syscon for dsi muxing Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 32/35] ARM: OMAP4+: control: remove support for legacy pad read/write Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 33/35] ARM: dts: omap5: add system control module node Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 34/35] ARM: dts: dra7: " Tero Kristo
2015-02-25 19:04   ` Tero Kristo
2015-03-11 17:17   ` Tony Lindgren
2015-03-11 17:17     ` Tony Lindgren
2015-03-11 19:08     ` Tero Kristo
2015-03-11 19:08       ` Tero Kristo
2015-03-11 19:26       ` Tony Lindgren
2015-03-11 19:26         ` Tony Lindgren
2015-03-11 19:57         ` Tero Kristo
2015-03-11 19:57           ` Tero Kristo
2015-03-11 21:00           ` Tony Lindgren
2015-03-11 21:00             ` Tony Lindgren
2015-02-25 19:04 ` [PATCHv3 35/35] ARM: OMAP4+: control: add support for initializing control module via DT Tero Kristo
2015-02-25 19:04   ` Tero Kristo

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=1424891085-10392-22-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=tony@atomide.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.