openbios.c 4.6 KB

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