aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2014-10-22 08:15:36 -0400
committerTero Kristo <t-kristo@ti.com>2015-03-27 04:53:30 -0400
commit9f029b1579b2dfe291006e5bfe8e7d0c4ef20828 (patch)
treeba0f8c8e987ebf637a8f87df83c38606e018365f
parent3a3e1c88362429ca3a6ef84d232e56b197294ce0 (diff)
ARM: OMAP2+: clock: move clock provider infrastructure to clock driver
Splits the clock provider init out of the PRM driver and moves it to clock driver. This is needed so that once the PRCM drivers are separated, they can logically just access the clock driver not needing to go through common PRM code. This would be wrong in the case of control module for example. Signed-off-by: Tero Kristo <t-kristo@ti.com>
-rw-r--r--arch/arm/mach-omap2/clock.c77
-rw-r--r--arch/arm/mach-omap2/clock.h6
-rw-r--r--arch/arm/mach-omap2/prm_common.c36
3 files changed, 75 insertions, 44 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 6124db5c37ae..94080fba02f6 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -23,6 +23,7 @@
23#include <linux/clk-provider.h> 23#include <linux/clk-provider.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/bitops.h> 25#include <linux/bitops.h>
26#include <linux/of_address.h>
26#include <asm/cpu.h> 27#include <asm/cpu.h>
27 28
28#include <trace/events/power.h> 29#include <trace/events/power.h>
@@ -72,30 +73,78 @@ struct ti_clk_features ti_clk_features;
72static bool clkdm_control = true; 73static bool clkdm_control = true;
73 74
74static LIST_HEAD(clk_hw_omap_clocks); 75static LIST_HEAD(clk_hw_omap_clocks);
75void __iomem *clk_memmaps[CLK_MAX_MEMMAPS]; 76static void __iomem *clk_memmaps[CLK_MAX_MEMMAPS];
77
78static void clk_memmap_writel(u32 val, void __iomem *reg)
79{
80 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
81
82 writel_relaxed(val, clk_memmaps[r->index] + r->offset);
83}
84
85static u32 clk_memmap_readl(void __iomem *reg)
86{
87 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
88
89 return readl_relaxed(clk_memmaps[r->index] + r->offset);
90}
76 91
77void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg) 92void omap2_clk_writel(u32 val, struct clk_hw_omap *clk, void __iomem *reg)
78{ 93{
79 if (clk->flags & MEMMAP_ADDRESSING) { 94 if (WARN_ON_ONCE(!(clk->flags & MEMMAP_ADDRESSING)))
80 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
81 writel_relaxed(val, clk_memmaps[r->index] + r->offset);
82 } else {
83 writel_relaxed(val, reg); 95 writel_relaxed(val, reg);
84 } 96 else
97 clk_memmap_writel(val, reg);
85} 98}
86 99
87u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg) 100u32 omap2_clk_readl(struct clk_hw_omap *clk, void __iomem *reg)
88{ 101{
89 u32 val; 102 if (WARN_ON_ONCE(!(clk->flags & MEMMAP_ADDRESSING)))
103 return readl_relaxed(reg);
104 else
105 return clk_memmap_readl(reg);
106}
90 107
91 if (clk->flags & MEMMAP_ADDRESSING) { 108static struct ti_clk_ll_ops omap_clk_ll_ops = {
92 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg; 109 .clk_readl = clk_memmap_readl,
93 val = readl_relaxed(clk_memmaps[r->index] + r->offset); 110 .clk_writel = clk_memmap_writel,
94 } else { 111};
95 val = readl_relaxed(reg); 112
96 } 113/**
114 * omap2_clk_provider_init - initialize a clock provider
115 * @match_table: DT device table to match for devices to init
116 * @np: device node pointer for the this clock provider
117 * @index: index for the clock provider
118 * @mem: iomem pointer for the clock provider memory area
119 *
120 * Initializes a clock provider module (CM/PRM etc.), registering
121 * the memory mapping at specified index and initializing the
122 * low level driver infrastructure. Returns 0 in success.
123 */
124int __init omap2_clk_provider_init(struct device_node *np, int index,
125 void __iomem *mem)
126{
127 ti_clk_ll_ops = &omap_clk_ll_ops;
128
129 clk_memmaps[index] = mem;
130
131 ti_dt_clk_init_provider(np, index);
132
133 return 0;
134}
135
136/**
137 * omap2_clk_legacy_provider_init - initialize a legacy clock provider
138 * @index: index for the clock provider
139 * @mem: iomem pointer for the clock provider memory area
140 *
141 * Initializes a legacy clock provider memory mapping.
142 */
143void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)
144{
145 ti_clk_ll_ops = &omap_clk_ll_ops;
97 146
98 return val; 147 clk_memmaps[index] = mem;
99} 148}
100 149
101/* 150/*
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index a56742f96000..b6433fc284ce 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -271,10 +271,12 @@ extern const struct clksel_rate div_1_3_rates[];
271extern const struct clksel_rate div_1_4_rates[]; 271extern const struct clksel_rate div_1_4_rates[];
272extern const struct clksel_rate div31_1to31_rates[]; 272extern const struct clksel_rate div31_1to31_rates[];
273 273
274extern void __iomem *clk_memmaps[];
275
276extern int omap2_clkops_enable_clkdm(struct clk_hw *hw); 274extern int omap2_clkops_enable_clkdm(struct clk_hw *hw);
277extern void omap2_clkops_disable_clkdm(struct clk_hw *hw); 275extern void omap2_clkops_disable_clkdm(struct clk_hw *hw);
278 276
277int __init omap2_clk_provider_init(struct device_node *np, int index,
278 void __iomem *mem);
279void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem);
280
279void __init ti_clk_init_features(void); 281void __init ti_clk_init_features(void);
280#endif 282#endif
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 8ec52012f85d..1bfd00e10f76 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -677,25 +677,6 @@ static const struct of_device_id omap_prcm_dt_match_table[] = {
677 { } 677 { }
678}; 678};
679 679
680static struct clk_hw_omap memmap_dummy_ck = {
681 .flags = MEMMAP_ADDRESSING,
682};
683
684static u32 prm_clk_readl(void __iomem *reg)
685{
686 return omap2_clk_readl(&memmap_dummy_ck, reg);
687}
688
689static void prm_clk_writel(u32 val, void __iomem *reg)
690{
691 omap2_clk_writel(val, &memmap_dummy_ck, reg);
692}
693
694static struct ti_clk_ll_ops omap_clk_ll_ops = {
695 .clk_readl = prm_clk_readl,
696 .clk_writel = prm_clk_writel,
697};
698
699/** 680/**
700 * omap_prcm_init - low level init for the PRCM drivers 681 * omap_prcm_init - low level init for the PRCM drivers
701 * 682 *
@@ -708,8 +689,7 @@ int __init omap_prcm_init(void)
708 void __iomem *mem; 689 void __iomem *mem;
709 const struct of_device_id *match; 690 const struct of_device_id *match;
710 const struct omap_prcm_init_data *data; 691 const struct omap_prcm_init_data *data;
711 692 int ret;
712 ti_clk_ll_ops = &omap_clk_ll_ops;
713 693
714 for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) { 694 for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) {
715 data = match->data; 695 data = match->data;
@@ -718,8 +698,9 @@ int __init omap_prcm_init(void)
718 if (!mem) 698 if (!mem)
719 return -ENOMEM; 699 return -ENOMEM;
720 700
721 clk_memmaps[data->index] = mem; 701 ret = omap2_clk_provider_init(np, data->index, mem);
722 ti_dt_clk_init_provider(np, data->index); 702 if (ret)
703 return ret;
723 } 704 }
724 705
725 return 0; 706 return 0;
@@ -727,11 +708,10 @@ int __init omap_prcm_init(void)
727 708
728void __init omap3_prcm_legacy_iomaps_init(void) 709void __init omap3_prcm_legacy_iomaps_init(void)
729{ 710{
730 ti_clk_ll_ops = &omap_clk_ll_ops; 711 omap2_clk_legacy_provider_init(TI_CLKM_CM, cm_base + OMAP3430_IVA2_MOD);
731 712 omap2_clk_legacy_provider_init(TI_CLKM_PRM,
732 clk_memmaps[TI_CLKM_CM] = cm_base + OMAP3430_IVA2_MOD; 713 prm_base + OMAP3430_IVA2_MOD);
733 clk_memmaps[TI_CLKM_PRM] = prm_base + OMAP3430_IVA2_MOD; 714 omap2_clk_legacy_provider_init(TI_CLKM_SCRM, omap_ctrl_base_get());
734 clk_memmaps[TI_CLKM_SCRM] = omap_ctrl_base_get();
735} 715}
736 716
737static int __init prm_late_init(void) 717static int __init prm_late_init(void)