ARM: OMAP2+: control: determine control module base address from DT
authorTero Kristo <t-kristo@ti.com>
Thu, 13 Nov 2014 17:17:34 +0000 (19:17 +0200)
committerTero Kristo <t-kristo@ti.com>
Fri, 27 Mar 2015 08:56:00 +0000 (10:56 +0200)
There is no need to provide the control module base address through a
low-level API from the low-level IO init, as this information is
available through DT. This patch adds a new API to initialize the
control module though, but mostly makes the old API obsolete. The
old API can be completely removed once OMAP3 is made DT only.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
arch/arm/mach-omap2/control.c
arch/arm/mach-omap2/control.h
arch/arm/mach-omap2/io.c
arch/arm/mach-omap2/prm.h
arch/arm/mach-omap2/prm_common.c

index e8818242f968bd969b137d8db1e7d9fc11497520..21ff32c6001a4c5e67c385246acd03499a7a0ef4 100644 (file)
@@ -616,6 +616,7 @@ void __init omap3_ctrl_init(void)
 
 struct control_init_data {
        int index;
+       void __iomem *mem;
 };
 
 static struct control_init_data ctrl_data = {
@@ -627,9 +628,38 @@ static const struct of_device_id omap_scrm_dt_match_table[] = {
        { .compatible = "ti,am4-scrm", .data = &ctrl_data },
        { .compatible = "ti,omap2-scrm", .data = &ctrl_data },
        { .compatible = "ti,omap3-scrm", .data = &ctrl_data },
+       { .compatible = "ti,dm816-scrm", .data = &ctrl_data },
        { }
 };
 
+/**
+ * omap2_control_base_init - initialize iomappings for the control driver
+ *
+ * Detects and initializes the iomappings for the control driver, based
+ * on the DT data. Returns 0 in success, negative error value
+ * otherwise.
+ */
+int __init omap2_control_base_init(void)
+{
+       struct device_node *np;
+       const struct of_device_id *match;
+       struct control_init_data *data;
+       void __iomem *mem;
+
+       for_each_matching_node_and_match(np, omap_scrm_dt_match_table, &match) {
+               data = (struct control_init_data *)match->data;
+
+               mem = of_iomap(np, 0);
+               if (!mem)
+                       return -ENOMEM;
+
+               omap2_ctrl_base = mem;
+               data->mem = mem;
+       }
+
+       return 0;
+}
+
 /**
  * omap_control_init - low level init for the control driver
  *
@@ -639,7 +669,6 @@ static const struct of_device_id omap_scrm_dt_match_table[] = {
 int __init omap_control_init(void)
 {
        struct device_node *np;
-       void __iomem *mem;
        const struct of_device_id *match;
        const struct omap_prcm_init_data *data;
        int ret;
@@ -647,14 +676,22 @@ int __init omap_control_init(void)
        for_each_matching_node_and_match(np, omap_scrm_dt_match_table, &match) {
                data = match->data;
 
-               mem = of_iomap(np, 0);
-               if (!mem)
-                       return -ENOMEM;
-
-               ret = omap2_clk_provider_init(np, data->index, mem);
+               ret = omap2_clk_provider_init(np, data->index, data->mem);
                if (ret)
                        return ret;
        }
 
        return 0;
 }
+
+/**
+ * omap3_control_legacy_iomap_init - legacy iomap init for clock providers
+ *
+ * Legacy iomap init for clock provider. Needed only by legacy boot mode,
+ * where the base addresses are not parsed from DT, but still required
+ * by the clock driver to be setup properly.
+ */
+void __init omap3_control_legacy_iomap_init(void)
+{
+       omap2_clk_legacy_provider_init(TI_CLKM_SCRM, omap2_ctrl_base);
+}
index baf5783cb05d0eecc0650bf83b033494e4c2d24f..c1057eb9d4e4b0abe5330f9c30a69fde4982f001 100644 (file)
@@ -464,9 +464,11 @@ extern void omap_ctrl_write_dsp_boot_mode(u8 bootmode);
 extern void omap3630_ctrl_disable_rta(void);
 extern int omap3_ctrl_save_padconf(void);
 void omap3_ctrl_init(void);
+int omap2_control_base_init(void);
 int omap_control_init(void);
 extern void omap2_set_globals_control(void __iomem *ctrl,
                                      void __iomem *ctrl_pad);
+void __init omap3_control_legacy_iomap_init(void);
 #else
 #define omap_ctrl_base_get()           0
 #define omap_ctrl_readb(x)             0
index 712dd42bb5c2bc1f65bbcd6078527ecad6442e07..622ee3bddd3252b7ae4014294fd8c50ebcdd6440 100644 (file)
@@ -384,8 +384,7 @@ void __init omap2420_init_early(void)
        omap2_set_globals_tap(OMAP242X_CLASS, OMAP2_L4_IO_ADDRESS(0x48014000));
        omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE),
                               OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE));
-       omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap2xxx_check_revision();
        omap2xxx_prm_init();
        omap2xxx_cm_init();
@@ -412,8 +411,7 @@ void __init omap2430_init_early(void)
        omap2_set_globals_tap(OMAP243X_CLASS, OMAP2_L4_IO_ADDRESS(0x4900a000));
        omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE),
                               OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE));
-       omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap2xxx_check_revision();
        omap2xxx_prm_init();
        omap2xxx_cm_init();
@@ -444,11 +442,15 @@ void __init omap3_init_early(void)
        omap2_set_globals_tap(OMAP343X_CLASS, OMAP2_L4_IO_ADDRESS(0x4830A000));
        omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE),
                               OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE));
-       omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE),
-                                 NULL);
-       /* XXX: remove these two once OMAP3 is DT only */
-       omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP3430_PRM_BASE));
-       omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE), NULL);
+       /* XXX: remove these once OMAP3 is DT only */
+       if (!of_have_populated_dt()) {
+               omap2_set_globals_control(
+                       OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE), NULL);
+               omap2_set_globals_prm(OMAP2_L4_IO_ADDRESS(OMAP3430_PRM_BASE));
+               omap2_set_globals_cm(OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE),
+                                    NULL);
+       }
+       omap2_control_base_init();
        omap3xxx_check_revision();
        omap3xxx_check_features();
        omap3xxx_prm_init();
@@ -459,7 +461,7 @@ void __init omap3_init_early(void)
        omap3xxx_hwmod_init();
        omap_hwmod_init_postsetup();
        if (!of_have_populated_dt()) {
-               omap3_prcm_legacy_iomaps_init();
+               omap3_control_legacy_iomap_init();
                if (soc_is_am35xx())
                        omap_clk_soc_init = am35xx_clk_legacy_init;
                else if (cpu_is_omap3630())
@@ -546,8 +548,7 @@ void __init ti814x_init_early(void)
 {
        omap2_set_globals_tap(TI814X_CLASS,
                              OMAP2_L4_IO_ADDRESS(TI81XX_TAP_BASE));
-       omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(TI81XX_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap3xxx_check_revision();
        ti81xx_check_features();
        am33xx_prm_init();
@@ -565,8 +566,7 @@ void __init ti816x_init_early(void)
 {
        omap2_set_globals_tap(TI816X_CLASS,
                              OMAP2_L4_IO_ADDRESS(TI81XX_TAP_BASE));
-       omap2_set_globals_control(OMAP2_L4_IO_ADDRESS(TI81XX_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap3xxx_check_revision();
        ti81xx_check_features();
        am33xx_prm_init();
@@ -586,8 +586,7 @@ void __init am33xx_init_early(void)
 {
        omap2_set_globals_tap(AM335X_CLASS,
                              AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE));
-       omap2_set_globals_control(AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap3xxx_check_revision();
        am33xx_check_features();
        am33xx_prm_init();
@@ -610,8 +609,7 @@ void __init am43xx_init_early(void)
 {
        omap2_set_globals_tap(AM335X_CLASS,
                              AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE));
-       omap2_set_globals_control(AM33XX_L4_WK_IO_ADDRESS(AM33XX_CTRL_BASE),
-                                 NULL);
+       omap2_control_base_init();
        omap3xxx_check_revision();
        am33xx_check_features();
        omap44xx_prm_init();
index 6d0a808f33f7aeb011399890e4e46bb256508b77..670733365287231f21ed2151311780d59cb8e059 100644 (file)
@@ -21,7 +21,6 @@ extern u16 prm_features;
 extern void omap2_set_globals_prm(void __iomem *prm);
 int omap_prcm_init(void);
 int omap2_prm_base_init(void);
-void omap3_prcm_legacy_iomaps_init(void);
 # endif
 
 /*
index b23d2327bafe0d9eed15b638c99fb0e4699b4b6d..a943e144753652b1a997345966a03e427cdc4d6c 100644 (file)
@@ -722,11 +722,6 @@ int __init omap_prcm_init(void)
        return 0;
 }
 
-void __init omap3_prcm_legacy_iomaps_init(void)
-{
-       omap2_clk_legacy_provider_init(TI_CLKM_SCRM, omap_ctrl_base_get());
-}
-
 static int __init prm_late_init(void)
 {
        if (prm_ll_data->late_init)