summaryrefslogtreecommitdiff
path: root/arch/arm/mach-omap2/cm_common.c
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2014-11-11 16:51:52 +0200
committerTero Kristo <t-kristo@ti.com>2015-03-27 10:55:57 +0200
commit5970ca2db960b2c14e077d27950e402e063298e6 (patch)
treef4f649b625842bcbbfdce431afd16a3a654dc023 /arch/arm/mach-omap2/cm_common.c
parentfe87414f71d0035756cf91a80ac256557d16b488 (diff)
ARM: OMAP2+: CM: determine CM base address from device tree
There is no need to provide the CM base address through a low-level API from the low-level IO init, as this information is available through DT. Re-routed the parsing function to be called from the CM drivers also to simplify the implementation under io.c. Signed-off-by: Tero Kristo <t-kristo@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/cm_common.c')
-rw-r--r--arch/arm/mach-omap2/cm_common.c73
1 files changed, 67 insertions, 6 deletions
diff --git a/arch/arm/mach-omap2/cm_common.c b/arch/arm/mach-omap2/cm_common.c
index f3d578be3272..32af8fc749f0 100644
--- a/arch/arm/mach-omap2/cm_common.c
+++ b/arch/arm/mach-omap2/cm_common.c
@@ -36,6 +36,8 @@ void __iomem *cm_base;
/* cm2_base: base virtual address of the CM2 IP block (OMAP44xx only) */
void __iomem *cm2_base;
+#define CM_NO_CLOCKS 0x1
+
/**
* omap2_set_globals_cm - set the CM/CM2 base addresses (for early use)
* @cm: CM base virtual address
@@ -224,18 +226,79 @@ static struct omap_prcm_init_data cm2_data = {
.index = TI_CLKM_CM2,
};
+static struct omap_prcm_init_data omap2_prcm_data = {
+ .index = TI_CLKM_CM,
+ .flags = CM_NO_CLOCKS,
+};
+
+static struct omap_prcm_init_data omap3_cm_data = {
+ .index = TI_CLKM_CM,
+
+ /*
+ * IVA2 offset is a negative value, must offset the cm_base address
+ * by this to get it to positive side on the iomap
+ */
+ .offset = -OMAP3430_IVA2_MOD,
+};
+
+static struct omap_prcm_init_data am3_prcm_data = {
+ .index = TI_CLKM_CM,
+ .flags = CM_NO_CLOCKS,
+};
+
+static struct omap_prcm_init_data am4_prcm_data = {
+ .index = TI_CLKM_CM,
+ .flags = CM_NO_CLOCKS,
+};
+
static const struct of_device_id omap_cm_dt_match_table[] = {
- { .compatible = "ti,omap3-cm", .data = &cm_data },
+ { .compatible = "ti,omap2-prcm", .data = &omap2_prcm_data },
+ { .compatible = "ti,omap3-cm", .data = &omap3_cm_data },
{ .compatible = "ti,omap4-cm1", .data = &cm_data },
{ .compatible = "ti,omap4-cm2", .data = &cm2_data },
{ .compatible = "ti,omap5-cm-core-aon", .data = &cm_data },
{ .compatible = "ti,omap5-cm-core", .data = &cm2_data },
{ .compatible = "ti,dra7-cm-core-aon", .data = &cm_data },
{ .compatible = "ti,dra7-cm-core", .data = &cm2_data },
+ { .compatible = "ti,am3-prcm", .data = &am3_prcm_data },
+ { .compatible = "ti,am4-prcm", .data = &am4_prcm_data },
{ }
};
/**
+ * omap2_cm_base_init - initialize iomappings for the CM drivers
+ *
+ * Detects and initializes the iomappings for the CM driver, based
+ * on the DT data. Returns 0 in success, negative error value
+ * otherwise.
+ */
+int __init omap2_cm_base_init(void)
+{
+ struct device_node *np;
+ const struct of_device_id *match;
+ struct omap_prcm_init_data *data;
+ void __iomem *mem;
+
+ for_each_matching_node_and_match(np, omap_cm_dt_match_table, &match) {
+ data = (struct omap_prcm_init_data *)match->data;
+
+ mem = of_iomap(np, 0);
+ if (!mem)
+ return -ENOMEM;
+
+ if (data->index == TI_CLKM_CM)
+ cm_base = mem + data->offset;
+
+ if (data->index == TI_CLKM_CM2)
+ cm2_base = mem + data->offset;
+
+ data->mem = mem;
+ }
+
+ return 0;
+}
+
+/**
* omap_cm_init - low level init for the CM drivers
*
* Initializes the low level clock infrastructure for CM drivers.
@@ -244,7 +307,6 @@ static const struct of_device_id omap_cm_dt_match_table[] = {
int __init omap_cm_init(void)
{
struct device_node *np;
- void __iomem *mem;
const struct of_device_id *match;
const struct omap_prcm_init_data *data;
int ret;
@@ -252,11 +314,10 @@ int __init omap_cm_init(void)
for_each_matching_node_and_match(np, omap_cm_dt_match_table, &match) {
data = match->data;
- mem = of_iomap(np, 0);
- if (!mem)
- return -ENOMEM;
+ if (data->flags & CM_NO_CLOCKS)
+ continue;
- ret = omap2_clk_provider_init(np, data->index, mem);
+ ret = omap2_clk_provider_init(np, data->index, data->mem);
if (ret)
return ret;
}