diff mbox

[PATCHv10,31/41] ARM: OMAP2+: clock: add support for regmap

Message ID 1385453182-24421-32-git-send-email-t-kristo@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tero Kristo Nov. 26, 2013, 8:06 a.m. UTC
Using regmap is required for isolating the actual memory access from
the clock code. Now, the driver providing the support for the clock IP
block can provide a regmap for this purpose.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/clock.c |   27 ++++++++++++++++++++++++++-
 arch/arm/mach-omap2/clock.h |    3 +++
 2 files changed, 29 insertions(+), 1 deletion(-)

Comments

Tony Lindgren Nov. 26, 2013, 5:40 p.m. UTC | #1
* Tero Kristo <t-kristo@ti.com> [131126 00:10]:
> Using regmap is required for isolating the actual memory access from
> the clock code. Now, the driver providing the support for the clock IP
> block can provide a regmap for this purpose.
> 
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/clock.c |   27 ++++++++++++++++++++++++++-
>  arch/arm/mach-omap2/clock.h |    3 +++
>  2 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
> index 238be3f..1ef6df8 100644
> --- a/arch/arm/mach-omap2/clock.c
> +++ b/arch/arm/mach-omap2/clock.c
> @@ -25,7 +25,7 @@
>  #include <linux/bitops.h>
>  #include <linux/clk-private.h>
>  #include <asm/cpu.h>
> -
> +#include <linux/regmap.h>
>  
>  #include <trace/events/power.h>
>  
> @@ -56,6 +56,31 @@ u16 cpu_mask;
>  static bool clkdm_control = true;
>  
>  static LIST_HEAD(clk_hw_omap_clocks);
> +struct regmap *clk_regmaps[CLK_MAX_REGMAPS];
> +
> +void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
> +{
> +	if (clk->flags & REGMAP_ADDRESSING) {
> +		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
> +		regmap_write(clk_regmaps[r->index], r->offset, val);
> +	} else {
> +		__raw_writel(val, reg);
> +	}
> +}
> +
> +u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg)
> +{
> +	u32 val;
> +
> +	if (clk->flags & REGMAP_ADDRESSING) {
> +		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
> +		regmap_read(clk_regmaps[r->index], r->offset, &val);
> +	} else {
> +		val = __raw_readl(reg);
> +	}
> +
> +	return val;
> +}
>  
>  /*
>   * Used for clocks that have the same value as the parent clock,

Maybe use read[lw]_relaxed and write[lw]_relaxed here and elsewhere
instead of __raw_read/write to help cut down the changes needed for
the big endian patch set?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tero Kristo Nov. 27, 2013, 9:08 a.m. UTC | #2
On 11/26/2013 07:40 PM, Tony Lindgren wrote:
> * Tero Kristo <t-kristo@ti.com> [131126 00:10]:
>> Using regmap is required for isolating the actual memory access from
>> the clock code. Now, the driver providing the support for the clock IP
>> block can provide a regmap for this purpose.
>>
>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>> ---
>>   arch/arm/mach-omap2/clock.c |   27 ++++++++++++++++++++++++++-
>>   arch/arm/mach-omap2/clock.h |    3 +++
>>   2 files changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
>> index 238be3f..1ef6df8 100644
>> --- a/arch/arm/mach-omap2/clock.c
>> +++ b/arch/arm/mach-omap2/clock.c
>> @@ -25,7 +25,7 @@
>>   #include <linux/bitops.h>
>>   #include <linux/clk-private.h>
>>   #include <asm/cpu.h>
>> -
>> +#include <linux/regmap.h>
>>
>>   #include <trace/events/power.h>
>>
>> @@ -56,6 +56,31 @@ u16 cpu_mask;
>>   static bool clkdm_control = true;
>>
>>   static LIST_HEAD(clk_hw_omap_clocks);
>> +struct regmap *clk_regmaps[CLK_MAX_REGMAPS];
>> +
>> +void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
>> +{
>> +	if (clk->flags & REGMAP_ADDRESSING) {
>> +		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
>> +		regmap_write(clk_regmaps[r->index], r->offset, val);
>> +	} else {
>> +		__raw_writel(val, reg);
>> +	}
>> +}
>> +
>> +u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg)
>> +{
>> +	u32 val;
>> +
>> +	if (clk->flags & REGMAP_ADDRESSING) {
>> +		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
>> +		regmap_read(clk_regmaps[r->index], r->offset, &val);
>> +	} else {
>> +		val = __raw_readl(reg);
>> +	}
>> +
>> +	return val;
>> +}
>>
>>   /*
>>    * Used for clocks that have the same value as the parent clock,
>
> Maybe use read[lw]_relaxed and write[lw]_relaxed here and elsewhere
> instead of __raw_read/write to help cut down the changes needed for
> the big endian patch set?

Well, this is the only place where we have a call to __raw_readl / 
__raw_writel in this patch set, the next patch actually removes all 
these calls from mach-omap2. But yes, I can change this.

-Tero

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 238be3f..1ef6df8 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -25,7 +25,7 @@ 
 #include <linux/bitops.h>
 #include <linux/clk-private.h>
 #include <asm/cpu.h>
-
+#include <linux/regmap.h>
 
 #include <trace/events/power.h>
 
@@ -56,6 +56,31 @@  u16 cpu_mask;
 static bool clkdm_control = true;
 
 static LIST_HEAD(clk_hw_omap_clocks);
+struct regmap *clk_regmaps[CLK_MAX_REGMAPS];
+
+void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
+{
+	if (clk->flags & REGMAP_ADDRESSING) {
+		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+		regmap_write(clk_regmaps[r->index], r->offset, val);
+	} else {
+		__raw_writel(val, reg);
+	}
+}
+
+u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg)
+{
+	u32 val;
+
+	if (clk->flags & REGMAP_ADDRESSING) {
+		struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
+		regmap_read(clk_regmaps[r->index], r->offset, &val);
+	} else {
+		val = __raw_readl(reg);
+	}
+
+	return val;
+}
 
 /*
  * Used for clocks that have the same value as the parent clock,
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index cbe5ff7..9595d72 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -254,6 +254,9 @@  void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
 			       const char *core_ck_name,
 			       const char *mpu_ck_name);
 
+u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg);
+void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg);
+
 extern u16 cpu_mask;
 
 extern const struct clkops clkops_omap2_dflt_wait;