Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Old U-boot compatibility for Walnut |
| 3 | * |
| 4 | * Author: Josh Boyer <jwboyer@linux.vnet.ibm.com> |
| 5 | * |
| 6 | * Copyright 2007 IBM Corporation |
| 7 | * Based on cuboot-83xx.c, which is: |
| 8 | * Copyright (c) 2007 Freescale Semiconductor, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License version 2 as published |
| 12 | * by the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include "ops.h" |
| 16 | #include "stdio.h" |
| 17 | #include "dcr.h" |
| 18 | #include "4xx.h" |
| 19 | #include "io.h" |
| 20 | |
| 21 | BSS_STACK(4096); |
| 22 | |
Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 23 | static void walnut_flashsel_fixup(void) |
| 24 | { |
| 25 | void *devp, *sram; |
| 26 | u32 reg_flash[3] = {0x0, 0x0, 0x80000}; |
| 27 | u32 reg_sram[3] = {0x0, 0x0, 0x80000}; |
| 28 | u8 *fpga; |
| 29 | u8 fpga_brds1 = 0x0; |
| 30 | |
| 31 | devp = finddevice("/plb/ebc/fpga"); |
| 32 | if (!devp) |
| 33 | fatal("Couldn't locate FPGA node\n\r"); |
| 34 | |
| 35 | if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga)) |
| 36 | fatal("no virtual-reg property\n\r"); |
| 37 | |
| 38 | fpga_brds1 = in_8(fpga); |
| 39 | |
| 40 | devp = finddevice("/plb/ebc/flash"); |
| 41 | if (!devp) |
| 42 | fatal("Couldn't locate flash node\n\r"); |
| 43 | |
| 44 | if (getprop(devp, "reg", reg_flash, sizeof(reg_flash)) != sizeof(reg_flash)) |
| 45 | fatal("flash reg property has unexpected size\n\r"); |
| 46 | |
| 47 | sram = finddevice("/plb/ebc/sram"); |
| 48 | if (!sram) |
| 49 | fatal("Couldn't locate sram node\n\r"); |
| 50 | |
| 51 | if (getprop(sram, "reg", reg_sram, sizeof(reg_sram)) != sizeof(reg_sram)) |
| 52 | fatal("sram reg property has unexpected size\n\r"); |
| 53 | |
| 54 | if (fpga_brds1 & 0x1) { |
| 55 | reg_flash[1] ^= 0x80000; |
| 56 | reg_sram[1] ^= 0x80000; |
| 57 | } |
| 58 | |
| 59 | setprop(devp, "reg", reg_flash, sizeof(reg_flash)); |
| 60 | setprop(sram, "reg", reg_sram, sizeof(reg_sram)); |
| 61 | } |
| 62 | |
Josh Boyer | b3af7a5 | 2007-10-20 00:53:11 +1000 | [diff] [blame] | 63 | #define WALNUT_OPENBIOS_MAC_OFF 0xfffffe0b |
Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 64 | static void walnut_fixups(void) |
| 65 | { |
Benjamin Herrenschmidt | d23f509 | 2007-12-21 15:39:31 +1100 | [diff] [blame] | 66 | ibm4xx_sdram_fixup_memsize(); |
Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 67 | ibm405gp_fixup_clocks(33330000, 0xa8c000); |
| 68 | ibm4xx_quiesce_eth((u32 *)0xef600800, NULL); |
| 69 | ibm4xx_fixup_ebc_ranges("/plb/ebc"); |
| 70 | walnut_flashsel_fixup(); |
David Gibson | ecc6cd7 | 2008-02-26 11:43:20 +1100 | [diff] [blame] | 71 | dt_fixup_mac_address_by_alias("ethernet0", (u8 *) WALNUT_OPENBIOS_MAC_OFF); |
Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void platform_init(void) |
| 75 | { |
| 76 | unsigned long end_of_ram = 0x2000000; |
| 77 | unsigned long avail_ram = end_of_ram - (unsigned long) _end; |
| 78 | |
| 79 | simple_alloc_init(_end, avail_ram, 32, 32); |
| 80 | platform_ops.fixups = walnut_fixups; |
| 81 | platform_ops.exit = ibm40x_dbcr_reset; |
David Gibson | 2f0dfea | 2007-12-10 14:28:39 +1100 | [diff] [blame] | 82 | fdt_init(_dtb_start); |
Josh Boyer | 5326152 | 2007-09-07 07:51:44 -0500 | [diff] [blame] | 83 | serial_console_init(); |
| 84 | } |