-#define MICRO_SUPPORT_CARD_BASE 0x43f00000
-#define SMC911X_BASE ((MICRO_SUPPORT_CARD_BASE) + 0x00000)
-#define LED_BASE ((MICRO_SUPPORT_CARD_BASE) + 0x90000)
-#define NS16550A_BASE ((MICRO_SUPPORT_CARD_BASE) + 0xb0000)
-#define MICRO_SUPPORT_CARD_RESET ((MICRO_SUPPORT_CARD_BASE) + 0xd0034)
-#define MICRO_SUPPORT_CARD_REVISION ((MICRO_SUPPORT_CARD_BASE) + 0xd00E0)
+#define SMC911X_OFFSET 0x00000
+#define LED_OFFSET 0x90000
+#define NS16550A_OFFSET 0xb0000
+#define MICRO_SUPPORT_CARD_RESET 0xd0034
+#define MICRO_SUPPORT_CARD_REVISION 0xd00e0
+
+static bool support_card_found;
+static void __iomem *support_card_base;
+
+static void support_card_detect(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ const void *fdt = gd->fdt_blob;
+ int offset;
+ u64 addr, addr2;
+
+ offset = fdt_node_offset_by_compatible(fdt, 0, "smsc,lan9118");
+ if (offset < 0)
+ return;
+
+ addr = fdt_get_base_address(fdt, offset);
+ if (addr == OF_BAD_ADDR)
+ return;
+ addr -= SMC911X_OFFSET;
+
+ offset = fdt_node_offset_by_compatible(fdt, 0, "ns16550a");
+ if (offset < 0)
+ return;
+
+ addr2 = fdt_get_base_address(fdt, offset);
+ if (addr2 == OF_BAD_ADDR)
+ return;
+ addr2 -= NS16550A_OFFSET;
+
+ /* sanity check */
+ if (addr != addr2)
+ return;
+
+ support_card_base = ioremap(addr, 0x100000);
+
+ support_card_found = true;
+}