cuboot-warp.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2008 PIKA Technologies
  3. * Sean MacLennan <smaclennan@pikatech.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published
  7. * by the Free Software Foundation.
  8. */
  9. #include "ops.h"
  10. #include "4xx.h"
  11. #include "cuboot.h"
  12. #include "stdio.h"
  13. #define TARGET_4xx
  14. #define TARGET_44x
  15. #include "ppcboot.h"
  16. static bd_t bd;
  17. static void warp_fixup_one_nor(u32 from, u32 to)
  18. {
  19. void *devp;
  20. char name[50];
  21. u32 v[2];
  22. sprintf(name, "/plb/opb/ebc/nor_flash@0,0/partition@%x", from);
  23. devp = finddevice(name);
  24. if (!devp)
  25. return;
  26. if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) {
  27. v[0] = to;
  28. setprop(devp, "reg", v, sizeof(v));
  29. printf("NOR 64M fixup %x -> %x\r\n", from, to);
  30. }
  31. }
  32. static void warp_fixups(void)
  33. {
  34. ibm440ep_fixup_clocks(66000000, 11059200, 50000000);
  35. ibm4xx_sdram_fixup_memsize();
  36. ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
  37. dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
  38. /* Fixup for 64M flash on Rev A boards. */
  39. if (bd.bi_flashsize == 0x4000000) {
  40. void *devp;
  41. u32 v[3];
  42. devp = finddevice("/plb/opb/ebc/nor_flash@0,0");
  43. if (!devp)
  44. return;
  45. /* Fixup the size */
  46. if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) {
  47. v[2] = bd.bi_flashsize;
  48. setprop(devp, "reg", v, sizeof(v));
  49. }
  50. /* Fixup parition offsets */
  51. warp_fixup_one_nor(0x300000, 0x3f00000);
  52. warp_fixup_one_nor(0x340000, 0x3f40000);
  53. warp_fixup_one_nor(0x380000, 0x3f80000);
  54. }
  55. }
  56. void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  57. unsigned long r6, unsigned long r7)
  58. {
  59. CUBOOT_INIT();
  60. platform_ops.fixups = warp_fixups;
  61. platform_ops.exit = ibm44x_dbcr_reset;
  62. fdt_init(_dtb_start);
  63. serial_console_init();
  64. }