misc-mv64x60.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * arch/ppc/boot/simple/misc-mv64x60.c
  3. *
  4. * Relocate bridge's register base and call board specific routine.
  5. *
  6. * Author: Mark A. Greer <source@mvista.com>
  7. *
  8. * 2005 (c) MontaVista Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/types.h>
  15. #include <asm/io.h>
  16. #include <asm/mv64x60_defs.h>
  17. extern struct bi_record *decompress_kernel(unsigned long load_addr,
  18. int num_words, unsigned long cksum);
  19. u32 size_reg[MV64x60_CPU2MEM_WINDOWS] = {
  20. MV64x60_CPU2MEM_0_SIZE, MV64x60_CPU2MEM_1_SIZE,
  21. MV64x60_CPU2MEM_2_SIZE, MV64x60_CPU2MEM_3_SIZE
  22. };
  23. /* Read mem ctlr to get the amount of mem in system */
  24. unsigned long
  25. mv64360_get_mem_size(void)
  26. {
  27. u32 enables, i, v;
  28. u32 mem = 0;
  29. enables = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE +
  30. MV64360_CPU_BAR_ENABLE) & 0xf;
  31. for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++)
  32. if (!(enables & (1<<i))) {
  33. v = in_le32((void __iomem *)CONFIG_MV64X60_NEW_BASE
  34. + size_reg[i]) & 0xffff;
  35. v = (v + 1) << 16;
  36. mem += v;
  37. }
  38. return mem;
  39. }
  40. void
  41. mv64x60_move_base(void __iomem *old_base, void __iomem *new_base)
  42. {
  43. u32 bits, mask, b;
  44. if (old_base != new_base) {
  45. #ifdef CONFIG_GT64260
  46. bits = 12;
  47. mask = 0x07000000;
  48. #else /* Must be mv64[34]60 */
  49. bits = 16;
  50. mask = 0x03000000;
  51. #endif
  52. b = in_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE);
  53. b &= mask;
  54. b |= ((u32)new_base >> (32 - bits));
  55. out_le32(old_base + MV64x60_INTERNAL_SPACE_DECODE, b);
  56. __asm__ __volatile__("sync");
  57. /* Wait for change to happen (in accordance with the manual) */
  58. while (in_le32(new_base + MV64x60_INTERNAL_SPACE_DECODE) != b);
  59. }
  60. }
  61. void __attribute__ ((weak))
  62. mv64x60_board_init(void __iomem *old_base, void __iomem *new_base)
  63. {
  64. }
  65. void *
  66. load_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
  67. void *ign1, void *ign2)
  68. {
  69. mv64x60_move_base((void __iomem *)CONFIG_MV64X60_BASE,
  70. (void __iomem *)CONFIG_MV64X60_NEW_BASE);
  71. mv64x60_board_init((void __iomem *)CONFIG_MV64X60_BASE,
  72. (void __iomem *)CONFIG_MV64X60_NEW_BASE);
  73. return decompress_kernel(load_addr, num_words, cksum);
  74. }