+ nios2_callr(gd->arch.reset_addr);
+ return 0;
+}
+
+/*
+ * COPY EXCEPTION TRAMPOLINE -- copy the tramp to the
+ * exception address. Define CONFIG_ROM_STUBS to prevent
+ * the copy (e.g. exception in flash or in other
+ * softare/firmware component).
+ */
+#ifndef CONFIG_ROM_STUBS
+static void copy_exception_trampoline(void)
+{
+ extern int _except_start, _except_end;
+ void *except_target = (void *)gd->arch.exception_addr;
+
+ if (&_except_start != except_target) {
+ memcpy(except_target, &_except_start,
+ &_except_end - &_except_start);
+ flush_cache(gd->arch.exception_addr,
+ &_except_end - &_except_start);
+ }
+}
+#endif
+
+static int nios_cpu_setup(void *ctx, struct event *event)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_first_device_err(UCLASS_CPU, &dev);
+ if (ret)
+ return ret;
+
+ gd->ram_size = CFG_SYS_SDRAM_SIZE;
+#ifndef CONFIG_ROM_STUBS
+ copy_exception_trampoline();
+#endif
+
+ return 0;
+}
+EVENT_SPY(EVT_DM_POST_INIT, nios_cpu_setup);
+
+static int altera_nios2_get_desc(const struct udevice *dev, char *buf,
+ int size)
+{
+ const char *cpu_name = "Nios-II";
+
+ if (size < strlen(cpu_name))
+ return -ENOSPC;
+ strcpy(buf, cpu_name);
+
+ return 0;
+}
+
+static int altera_nios2_get_info(const struct udevice *dev,
+ struct cpu_info *info)
+{
+ info->cpu_freq = gd->cpu_clk;
+ info->features = (1 << CPU_FEAT_L1_CACHE) |
+ (gd->arch.has_mmu ? (1 << CPU_FEAT_MMU) : 0);
+