: "=r" (reg));
 }
 
+static void __iomem *imx3_ioremap(unsigned long phys_addr, size_t size,
+                                 unsigned int mtype)
+{
+       if (mtype == MT_DEVICE) {
+               /*
+                * Access all peripherals below 0x80000000 as nonshared device
+                * on mx3, but leave l2cc alone.  Otherwise cache corruptions
+                * can occur.
+                */
+               if (phys_addr < 0x80000000 &&
+                               !addr_in_module(phys_addr, MX3x_L2CC))
+                       mtype = MT_DEVICE_NONSHARED;
+       }
+
+       return __arm_ioremap(phys_addr, size, mtype);
+}
+
 void imx3_init_l2x0(void)
 {
        void __iomem *l2x0_base;
        mxc_set_cpu_type(MXC_CPU_MX31);
        mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
        imx_idle = imx3_idle;
+       imx_ioremap = imx3_ioremap;
 }
 
 void __init imx35_init_early(void)
        mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR));
        mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR));
        imx_idle = imx3_idle;
+       imx_ioremap = imx3_ioremap;
 }
 
 void __init mx31_init_irq(void)
 
 /* Allow IO space to be anywhere in the memory */
 #define IO_SPACE_LIMIT 0xffffffff
 
-#if defined(CONFIG_SOC_IMX31) || defined(CONFIG_SOC_IMX35)
-#include <mach/hardware.h>
-
 #define __arch_ioremap __imx_ioremap
 #define __arch_iounmap __iounmap
 
 #define addr_in_module(addr, mod) \
        ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE)
 
+extern void __iomem *(*imx_ioremap)(unsigned long, size_t, unsigned int);
+
 static inline void __iomem *
 __imx_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
 {
-       if (mtype == MT_DEVICE && (cpu_is_mx31() || cpu_is_mx35())) {
-               /*
-                * Access all peripherals below 0x80000000 as nonshared device
-                * on mx3, but leave l2cc alone.  Otherwise cache corruptions
-                * can occur.
-                */
-               if (phys_addr < 0x80000000 &&
-                               !addr_in_module(phys_addr, MX3x_L2CC))
-                       mtype = MT_DEVICE_NONSHARED;
-       }
-
-       return __arm_ioremap(phys_addr, size, mtype);
+       if (imx_ioremap != NULL)
+               return imx_ioremap(phys_addr, size, mtype);
+       else
+               return __arm_ioremap(phys_addr, size, mtype);
 }
-#endif
 
 /* io address mapping macro */
 #define __io(a)                __typesafe_io(a)