ebony.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2007 David Gibson, IBM Corporation.
  3. *
  4. * Based on earlier code:
  5. * Copyright (C) Paul Mackerras 1997.
  6. *
  7. * Matt Porter <mporter@kernel.crashing.org>
  8. * Copyright 2002-2005 MontaVista Software Inc.
  9. *
  10. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  11. * Copyright (c) 2003, 2004 Zultys Technologies
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version
  16. * 2 of the License, or (at your option) any later version.
  17. */
  18. #include <stdarg.h>
  19. #include <stddef.h>
  20. #include "types.h"
  21. #include "elf.h"
  22. #include "string.h"
  23. #include "stdio.h"
  24. #include "page.h"
  25. #include "ops.h"
  26. #include "reg.h"
  27. #include "io.h"
  28. #include "dcr.h"
  29. #include "4xx.h"
  30. #include "44x.h"
  31. static u8 *ebony_mac0, *ebony_mac1;
  32. #define EBONY_FPGA_PATH "/plb/opb/ebc/fpga"
  33. #define EBONY_FPGA_FLASH_SEL 0x01
  34. #define EBONY_SMALL_FLASH_PATH "/plb/opb/ebc/small-flash"
  35. static void ebony_flashsel_fixup(void)
  36. {
  37. void *devp;
  38. u32 reg[3] = {0x0, 0x0, 0x80000};
  39. u8 *fpga;
  40. u8 fpga_reg0 = 0x0;
  41. devp = finddevice(EBONY_FPGA_PATH);
  42. if (!devp)
  43. fatal("Couldn't locate FPGA node %s\n\r", EBONY_FPGA_PATH);
  44. if (getprop(devp, "virtual-reg", &fpga, sizeof(fpga)) != sizeof(fpga))
  45. fatal("%s has missing or invalid virtual-reg property\n\r",
  46. EBONY_FPGA_PATH);
  47. fpga_reg0 = in_8(fpga);
  48. devp = finddevice(EBONY_SMALL_FLASH_PATH);
  49. if (!devp)
  50. fatal("Couldn't locate small flash node %s\n\r",
  51. EBONY_SMALL_FLASH_PATH);
  52. if (getprop(devp, "reg", reg, sizeof(reg)) != sizeof(reg))
  53. fatal("%s has reg property of unexpected size\n\r",
  54. EBONY_SMALL_FLASH_PATH);
  55. /* Invert address bit 14 (IBM-endian) if FLASH_SEL fpga bit is set */
  56. if (fpga_reg0 & EBONY_FPGA_FLASH_SEL)
  57. reg[1] ^= 0x80000;
  58. setprop(devp, "reg", reg, sizeof(reg));
  59. }
  60. static void ebony_fixups(void)
  61. {
  62. // FIXME: sysclk should be derived by reading the FPGA registers
  63. unsigned long sysclk = 33000000;
  64. ibm440gp_fixup_clocks(sysclk, 6 * 1843200);
  65. ibm4xx_sdram_fixup_memsize();
  66. dt_fixup_mac_address_by_alias("ethernet0", ebony_mac0);
  67. dt_fixup_mac_address_by_alias("ethernet1", ebony_mac1);
  68. ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
  69. ebony_flashsel_fixup();
  70. }
  71. void ebony_init(void *mac0, void *mac1)
  72. {
  73. platform_ops.fixups = ebony_fixups;
  74. platform_ops.exit = ibm44x_dbcr_reset;
  75. ebony_mac0 = mac0;
  76. ebony_mac1 = mac1;
  77. fdt_init(_dtb_start);
  78. serial_console_init();
  79. }