openbios.c 4.5 KB

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