treeboot-walnut.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Old U-boot compatibility for Walnut
  3. *
  4. * Author: Josh Boyer <jwboyer@linux.vnet.ibm.com>
  5. *
  6. * Copyright 2007 IBM Corporation
  7. * Based on cuboot-83xx.c, which is:
  8. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include "ops.h"
  15. #include "stdio.h"
  16. #include "dcr.h"
  17. #include "4xx.h"
  18. #include "io.h"
  19. BSS_STACK(4096);
  20. static void walnut_flashsel_fixup(void)
  21. {
  22. void *devp, *sram;
  23. u32 reg_flash[3] = {0x0, 0x0, 0x80000};
  24. u32 reg_sram[3] = {0x0, 0x0, 0x80000};
  25. u8 *fpga;
  26. u8 fpga_brds1 = 0x0;
  27. devp = finddevice("/plb/ebc/fpga");
  28. if (!devp)
  29. fatal("Couldn't locate FPGA node\n\r");
  30. if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga))
  31. fatal("no virtual-reg property\n\r");
  32. fpga_brds1 = in_8(fpga);
  33. devp = finddevice("/plb/ebc/flash");
  34. if (!devp)
  35. fatal("Couldn't locate flash node\n\r");
  36. if (getprop(devp, "reg", reg_flash, sizeof(reg_flash)) != sizeof(reg_flash))
  37. fatal("flash reg property has unexpected size\n\r");
  38. sram = finddevice("/plb/ebc/sram");
  39. if (!sram)
  40. fatal("Couldn't locate sram node\n\r");
  41. if (getprop(sram, "reg", reg_sram, sizeof(reg_sram)) != sizeof(reg_sram))
  42. fatal("sram reg property has unexpected size\n\r");
  43. if (fpga_brds1 & 0x1) {
  44. reg_flash[1] ^= 0x80000;
  45. reg_sram[1] ^= 0x80000;
  46. }
  47. setprop(devp, "reg", reg_flash, sizeof(reg_flash));
  48. setprop(sram, "reg", reg_sram, sizeof(reg_sram));
  49. }
  50. #define WALNUT_OPENBIOS_MAC_OFF 0xfffffe0b
  51. static void walnut_fixups(void)
  52. {
  53. ibm4xx_sdram_fixup_memsize();
  54. ibm405gp_fixup_clocks(33330000, 0xa8c000);
  55. ibm4xx_quiesce_eth((u32 *)0xef600800, NULL);
  56. ibm4xx_fixup_ebc_ranges("/plb/ebc");
  57. walnut_flashsel_fixup();
  58. dt_fixup_mac_address_by_alias("ethernet0", (u8 *) WALNUT_OPENBIOS_MAC_OFF);
  59. }
  60. void platform_init(void)
  61. {
  62. unsigned long end_of_ram = 0x2000000;
  63. unsigned long avail_ram = end_of_ram - (unsigned long) _end;
  64. simple_alloc_init(_end, avail_ram, 32, 32);
  65. platform_ops.fixups = walnut_fixups;
  66. platform_ops.exit = ibm40x_dbcr_reset;
  67. fdt_init(_dtb_start);
  68. serial_console_init();
  69. }