ARM: OMAP4+: prminst: provide function to find prm_dev instance offset
authorNishanth Menon <nm@ti.com>
Thu, 22 May 2014 19:53:54 +0000 (14:53 -0500)
committerNishanth Menon <nm@ti.com>
Mon, 8 Sep 2014 15:53:25 +0000 (10:53 -0500)
PRM device instance can vary depending on SoC. We already handle the
same during reset of the device, However, this is also needed
for other logic instances. So, first abstract this out to a generic
function.

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
arch/arm/mach-omap2/prminst44xx.c
arch/arm/mach-omap2/prminst44xx.h

index 69f0dd08629cb1bdbeaeb2d9c3c87e00e0bf8afb..225e0258d76d4e02e49ea6d63f8c1da1e6187479 100644 (file)
@@ -31,6 +31,8 @@
 
 static void __iomem *_prm_bases[OMAP4_MAX_PRCM_PARTITIONS];
 
+static s32 prm_dev_inst = PRM_INSTANCE_UNKNOWN;
+
 /**
  * omap_prm_base_init - Populates the prm partitions
  *
@@ -43,6 +45,24 @@ void omap_prm_base_init(void)
        _prm_bases[OMAP4430_PRCM_MPU_PARTITION] = prcm_mpu_base;
 }
 
+s32 omap4_prmst_get_prm_dev_inst(void)
+{
+       if (prm_dev_inst != PRM_INSTANCE_UNKNOWN)
+               return prm_dev_inst;
+
+       /* This cannot be done way early at boot.. as things are not setup */
+       if (cpu_is_omap44xx())
+               prm_dev_inst = OMAP4430_PRM_DEVICE_INST;
+       else if (soc_is_omap54xx())
+               prm_dev_inst = OMAP54XX_PRM_DEVICE_INST;
+       else if (soc_is_dra7xx())
+               prm_dev_inst = DRA7XX_PRM_DEVICE_INST;
+       else if (soc_is_am43xx())
+               prm_dev_inst = AM43XX_PRM_DEVICE_INST;
+
+       return prm_dev_inst;
+}
+
 /* Read a register in a PRM instance */
 u32 omap4_prminst_read_inst_reg(u8 part, s16 inst, u16 idx)
 {
@@ -169,28 +189,18 @@ int omap4_prminst_deassert_hardreset(u8 shift, u8 part, s16 inst,
 void omap4_prminst_global_warm_sw_reset(void)
 {
        u32 v;
-       s16 dev_inst;
+       s32 inst = omap4_prmst_get_prm_dev_inst();
 
-       if (cpu_is_omap44xx())
-               dev_inst = OMAP4430_PRM_DEVICE_INST;
-       else if (soc_is_omap54xx())
-               dev_inst = OMAP54XX_PRM_DEVICE_INST;
-       else if (soc_is_dra7xx())
-               dev_inst = DRA7XX_PRM_DEVICE_INST;
-       else if (soc_is_am43xx())
-               dev_inst = AM43XX_PRM_DEVICE_INST;
-       else
+       if (inst == PRM_INSTANCE_UNKNOWN)
                return;
 
-       v = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, dev_inst,
+       v = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, inst,
                                        OMAP4_PRM_RSTCTRL_OFFSET);
        v |= OMAP4430_RST_GLOBAL_WARM_SW_MASK;
        omap4_prminst_write_inst_reg(v, OMAP4430_PRM_PARTITION,
-                                dev_inst,
-                                OMAP4_PRM_RSTCTRL_OFFSET);
+                                inst, OMAP4_PRM_RSTCTRL_OFFSET);
 
        /* OCP barrier */
        v = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
-                                   dev_inst,
-                                   OMAP4_PRM_RSTCTRL_OFFSET);
+                                   inst, OMAP4_PRM_RSTCTRL_OFFSET);
 }
index a2ede2d65481580e7399cc36bf964e57eee0fea5..583aa3774571391bda936e075fc9051b209624b4 100644 (file)
@@ -12,6 +12,9 @@
 #ifndef __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H
 #define __ARCH_ASM_MACH_OMAP2_PRMINST44XX_H
 
+#define PRM_INSTANCE_UNKNOWN   -1
+extern s32 omap4_prmst_get_prm_dev_inst(void);
+
 /*
  * In an ideal world, we would not export these low-level functions,
  * but this will probably take some time to fix properly