• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Old U-boot compatibility for Walnut
4  *
5  * Author: Josh Boyer <jwboyer@linux.vnet.ibm.com>
6  *
7  * Copyright 2007 IBM Corporation
8  *   Based on cuboot-83xx.c, which is:
9  * Copyright (c) 2007 Freescale Semiconductor, Inc.
10  */
11 
12 #include "ops.h"
13 #include "stdio.h"
14 #include "dcr.h"
15 #include "4xx.h"
16 #include "io.h"
17 
18 BSS_STACK(4096);
19 
walnut_flashsel_fixup(void)20 static void walnut_flashsel_fixup(void)
21 {
22 	void *devp, *sram;
23 	u32 reg_flash[3] = {0x0, 0x0, 0x80000};
24 	u32 reg_sram[3] = {0x0, 0x0, 0x80000};
25 	u8 *fpga;
26 	u8 fpga_brds1 = 0x0;
27 
28 	devp = finddevice("/plb/ebc/fpga");
29 	if (!devp)
30 		fatal("Couldn't locate FPGA node\n\r");
31 
32 	if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga))
33 		fatal("no virtual-reg property\n\r");
34 
35 	fpga_brds1 = in_8(fpga);
36 
37 	devp = finddevice("/plb/ebc/flash");
38 	if (!devp)
39 		fatal("Couldn't locate flash node\n\r");
40 
41 	if (getprop(devp, "reg", reg_flash, sizeof(reg_flash)) != sizeof(reg_flash))
42 		fatal("flash reg property has unexpected size\n\r");
43 
44 	sram = finddevice("/plb/ebc/sram");
45 	if (!sram)
46 		fatal("Couldn't locate sram node\n\r");
47 
48 	if (getprop(sram, "reg", reg_sram, sizeof(reg_sram)) != sizeof(reg_sram))
49 		fatal("sram reg property has unexpected size\n\r");
50 
51 	if (fpga_brds1 & 0x1) {
52 		reg_flash[1] ^= 0x80000;
53 		reg_sram[1] ^= 0x80000;
54 	}
55 
56 	setprop(devp, "reg", reg_flash, sizeof(reg_flash));
57 	setprop(sram, "reg", reg_sram, sizeof(reg_sram));
58 }
59 
60 #define WALNUT_OPENBIOS_MAC_OFF 0xfffffe0b
walnut_fixups(void)61 static void walnut_fixups(void)
62 {
63 	ibm4xx_sdram_fixup_memsize();
64 	ibm405gp_fixup_clocks(33330000, 0xa8c000);
65 	ibm4xx_quiesce_eth((u32 *)0xef600800, NULL);
66 	ibm4xx_fixup_ebc_ranges("/plb/ebc");
67 	walnut_flashsel_fixup();
68 	dt_fixup_mac_address_by_alias("ethernet0", (u8 *) WALNUT_OPENBIOS_MAC_OFF);
69 }
70 
platform_init(void)71 void platform_init(void)
72 {
73 	unsigned long end_of_ram = 0x2000000;
74 	unsigned long avail_ram = end_of_ram - (unsigned long) _end;
75 
76 	simple_alloc_init(_end, avail_ram, 32, 32);
77 	platform_ops.fixups = walnut_fixups;
78 	platform_ops.exit = ibm40x_dbcr_reset;
79 	fdt_init(_dtb_start);
80 	serial_console_init();
81 }
82