Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 2 | * Copyright (c) 2005 DENX Software Engineering |
| 3 | * Stefan Roese <sr@denx.de> |
| 4 | * |
| 5 | * Based on original work by |
| 6 | * 2005 (c) SYSGO AG - g.jaeger@sysgo.com |
| 7 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * This file is licensed under the terms of the GNU General Public |
| 9 | * License version 2. This program is licensed "as is" without |
| 10 | * any warranty of any kind, whether express or implied. |
| 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/string.h> |
| 16 | #include <asm/ppcboot.h> |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 17 | #include <asm/ibm4xx.h> |
| 18 | #include <asm/reg.h> |
| 19 | #ifdef CONFIG_40x |
| 20 | #include <asm/io.h> |
| 21 | #endif |
| 22 | |
| 23 | #if defined(CONFIG_BUBINGA) |
| 24 | #define BOARD_INFO_VECTOR 0xFFF80B50 /* openbios 1.19 moved this vector down - armin */ |
| 25 | #else |
| 26 | #define BOARD_INFO_VECTOR 0xFFFE0B50 |
| 27 | #endif |
| 28 | |
| 29 | #ifdef CONFIG_40x |
| 30 | /* Supply a default Ethernet address for those eval boards that don't |
| 31 | * ship with one. This is an address from the MBX board I have, so |
| 32 | * it is unlikely you will find it on your network. |
| 33 | */ |
| 34 | static ushort def_enet_addr[] = { 0x0800, 0x3e26, 0x1559 }; |
| 35 | |
| 36 | extern unsigned long timebase_period_ns; |
| 37 | #endif /* CONFIG_40x */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | extern unsigned long decompress_kernel(unsigned long load_addr, int num_words, |
| 40 | unsigned long cksum); |
| 41 | |
| 42 | /* We need to make sure that this is before the images to ensure |
| 43 | * that it's in a mapped location. */ |
| 44 | bd_t hold_resid_buf __attribute__ ((__section__ (".data.boot"))); |
| 45 | bd_t *hold_residual = &hold_resid_buf; |
| 46 | |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 47 | typedef struct openbios_board_info { |
| 48 | unsigned char bi_s_version[4]; /* Version of this structure */ |
| 49 | unsigned char bi_r_version[30]; /* Version of the IBM ROM */ |
| 50 | unsigned int bi_memsize; /* DRAM installed, in bytes */ |
| 51 | #ifdef CONFIG_405EP |
| 52 | unsigned char bi_enetaddr[2][6]; /* Local Ethernet MAC address */ |
| 53 | #else /* CONFIG_405EP */ |
| 54 | unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */ |
| 55 | #endif /* CONFIG_405EP */ |
| 56 | unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */ |
| 57 | unsigned int bi_intfreq; /* Processor speed, in Hz */ |
| 58 | unsigned int bi_busfreq; /* PLB Bus speed, in Hz */ |
| 59 | unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */ |
| 60 | #ifdef CONFIG_405EP |
| 61 | unsigned int bi_opb_busfreq; /* OPB Bus speed, in Hz */ |
| 62 | unsigned int bi_pllouta_freq; /* PLL OUTA speed, in Hz */ |
| 63 | #endif /* CONFIG_405EP */ |
| 64 | } openbios_bd_t; |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | void * |
| 67 | load_kernel(unsigned long load_addr, int num_words, unsigned long cksum, |
| 68 | void *ign1, void *ign2) |
| 69 | { |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 70 | #ifdef CONFIG_40x |
| 71 | openbios_bd_t *openbios_bd = NULL; |
| 72 | openbios_bd_t *(*get_board_info)(void) = |
| 73 | (openbios_bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 75 | /* |
| 76 | * On 40x platforms we not only need the MAC-addresses, but also the |
| 77 | * clocks and memsize. Now try to get all values using the OpenBIOS |
| 78 | * "get_board_info()" callback. |
| 79 | */ |
| 80 | if ((openbios_bd = get_board_info()) != NULL) { |
| 81 | /* |
| 82 | * Copy bd_info from OpenBIOS struct into U-Boot struct |
| 83 | * used by kernel |
| 84 | */ |
| 85 | hold_residual->bi_memsize = openbios_bd->bi_memsize; |
| 86 | hold_residual->bi_intfreq = openbios_bd->bi_intfreq; |
| 87 | hold_residual->bi_busfreq = openbios_bd->bi_busfreq; |
| 88 | hold_residual->bi_pci_busfreq = openbios_bd->bi_pci_busfreq; |
| 89 | memcpy(hold_residual->bi_pci_enetaddr, openbios_bd->bi_pci_enetaddr, 6); |
| 90 | #ifdef CONFIG_405EP |
| 91 | memcpy(hold_residual->bi_enetaddr, openbios_bd->bi_enetaddr[0], 6); |
| 92 | memcpy(hold_residual->bi_enet1addr, openbios_bd->bi_enetaddr[1], 6); |
| 93 | hold_residual->bi_opbfreq = openbios_bd->bi_opb_busfreq; |
| 94 | hold_residual->bi_procfreq = openbios_bd->bi_pllouta_freq; |
| 95 | #else /* CONFIG_405EP */ |
| 96 | memcpy(hold_residual->bi_enetaddr, openbios_bd->bi_enetaddr, 6); |
| 97 | #endif /* CONFIG_405EP */ |
| 98 | } else { |
| 99 | /* Hmmm...better try to stuff some defaults. |
| 100 | */ |
| 101 | hold_residual->bi_memsize = 16 * 1024 * 1024; |
| 102 | hold_residual->bi_intfreq = 200000000; |
| 103 | hold_residual->bi_busfreq = 100000000; |
| 104 | hold_residual->bi_pci_busfreq = 66666666; |
| 105 | |
| 106 | /* |
| 107 | * Only supply one mac-address in this fallback |
| 108 | */ |
| 109 | memcpy(hold_residual->bi_enetaddr, (void *)def_enet_addr, 6); |
| 110 | #ifdef CONFIG_405EP |
| 111 | hold_residual->bi_opbfreq = 50000000; |
| 112 | hold_residual->bi_procfreq = 200000000; |
| 113 | #endif /* CONFIG_405EP */ |
| 114 | } |
| 115 | |
| 116 | timebase_period_ns = 1000000000 / hold_residual->bi_intfreq; |
| 117 | #endif /* CONFIG_40x */ |
| 118 | |
| 119 | #ifdef CONFIG_440GP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | /* simply copy the MAC addresses */ |
Matt Porter | 3e9e7c1 | 2005-11-07 00:58:15 -0800 | [diff] [blame] | 121 | memcpy(hold_residual->bi_enetaddr, (char *)OPENBIOS_MAC_BASE, 6); |
| 122 | memcpy(hold_residual->bi_enet1addr, (char *)(OPENBIOS_MAC_BASE+OPENBIOS_MAC_OFFSET), 6); |
| 123 | #endif /* CONFIG_440GP */ |
| 124 | |
| 125 | decompress_kernel(load_addr, num_words, cksum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | return (void *)hold_residual; |
| 128 | } |