Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 PIKA Technologies |
| 3 | * Sean MacLennan <smaclennan@pikatech.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published |
| 7 | * by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include "ops.h" |
| 11 | #include "4xx.h" |
| 12 | #include "cuboot.h" |
Sean MacLennan | 4ebef31 | 2008-05-20 08:28:52 -0500 | [diff] [blame^] | 13 | #include "stdio.h" |
Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 14 | |
Josh Boyer | fe57e8b | 2008-02-28 08:16:27 -0600 | [diff] [blame] | 15 | #define TARGET_4xx |
Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 16 | #define TARGET_44x |
| 17 | #include "ppcboot.h" |
| 18 | |
| 19 | static bd_t bd; |
| 20 | |
Sean MacLennan | 4ebef31 | 2008-05-20 08:28:52 -0500 | [diff] [blame^] | 21 | static void warp_fixup_one_nor(u32 from, u32 to) |
| 22 | { |
| 23 | void *devp; |
| 24 | char name[50]; |
| 25 | u32 v[2]; |
| 26 | |
| 27 | sprintf(name, "/plb/opb/ebc/nor_flash@0,0/partition@%x", from); |
| 28 | |
| 29 | devp = finddevice(name); |
| 30 | if (!devp) |
| 31 | return; |
| 32 | |
| 33 | if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) { |
| 34 | v[0] = to; |
| 35 | setprop(devp, "reg", v, sizeof(v)); |
| 36 | |
| 37 | printf("NOR 64M fixup %x -> %x\r\n", from, to); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | |
Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 42 | static void warp_fixups(void) |
| 43 | { |
Sean MacLennan | 4ebef31 | 2008-05-20 08:28:52 -0500 | [diff] [blame^] | 44 | ibm440ep_fixup_clocks(66000000, 11059200, 50000000); |
Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 45 | ibm4xx_sdram_fixup_memsize(); |
| 46 | ibm4xx_fixup_ebc_ranges("/plb/opb/ebc"); |
David Gibson | ecc6cd7 | 2008-02-26 11:43:20 +1100 | [diff] [blame] | 47 | dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr); |
Sean MacLennan | 4ebef31 | 2008-05-20 08:28:52 -0500 | [diff] [blame^] | 48 | |
| 49 | /* Fixup for 64M flash on Rev A boards. */ |
| 50 | if (bd.bi_flashsize == 0x4000000) { |
| 51 | void *devp; |
| 52 | u32 v[3]; |
| 53 | |
| 54 | devp = finddevice("/plb/opb/ebc/nor_flash@0,0"); |
| 55 | if (!devp) |
| 56 | return; |
| 57 | |
| 58 | /* Fixup the size */ |
| 59 | if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) { |
| 60 | v[2] = bd.bi_flashsize; |
| 61 | setprop(devp, "reg", v, sizeof(v)); |
| 62 | } |
| 63 | |
| 64 | /* Fixup parition offsets */ |
| 65 | warp_fixup_one_nor(0x300000, 0x3f00000); |
| 66 | warp_fixup_one_nor(0x340000, 0x3f40000); |
| 67 | warp_fixup_one_nor(0x380000, 0x3f80000); |
| 68 | } |
Sean MacLennan | 1e12f3c | 2008-01-11 17:17:51 +1100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | |
| 72 | void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, |
| 73 | unsigned long r6, unsigned long r7) |
| 74 | { |
| 75 | CUBOOT_INIT(); |
| 76 | |
| 77 | platform_ops.fixups = warp_fixups; |
| 78 | platform_ops.exit = ibm44x_dbcr_reset; |
| 79 | fdt_init(_dtb_start); |
| 80 | serial_console_init(); |
| 81 | } |