44x.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2007 David Gibson, IBM Corporation.
  3. *
  4. * Based on earlier code:
  5. * Matt Porter <mporter@kernel.crashing.org>
  6. * Copyright 2002-2005 MontaVista Software Inc.
  7. *
  8. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  9. * Copyright (c) 2003, 2004 Zultys Technologies
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. #include <stddef.h>
  17. #include "types.h"
  18. #include "string.h"
  19. #include "stdio.h"
  20. #include "ops.h"
  21. #include "reg.h"
  22. #include "dcr.h"
  23. /* Read the 44x memory controller to get size of system memory. */
  24. void ibm44x_fixup_memsize(void)
  25. {
  26. int i;
  27. unsigned long memsize, bank_config;
  28. memsize = 0;
  29. for (i = 0; i < ARRAY_SIZE(sdram_bxcr); i++) {
  30. mtdcr(DCRN_SDRAM0_CFGADDR, sdram_bxcr[i]);
  31. bank_config = mfdcr(DCRN_SDRAM0_CFGDATA);
  32. if (bank_config & SDRAM_CONFIG_BANK_ENABLE)
  33. memsize += SDRAM_CONFIG_BANK_SIZE(bank_config);
  34. }
  35. dt_fixup_memory(0, memsize);
  36. }
  37. #define SPRN_DBCR0 0x134
  38. #define DBCR0_RST_SYSTEM 0x30000000
  39. void ibm44x_dbcr_reset(void)
  40. {
  41. unsigned long tmp;
  42. asm volatile (
  43. "mfspr %0,%1\n"
  44. "oris %0,%0,%2@h\n"
  45. "mtspr %1,%0"
  46. : "=&r"(tmp) : "i"(SPRN_DBCR0), "i"(DBCR0_RST_SYSTEM)
  47. );
  48. }
  49. /* Read 4xx EBC bus bridge registers to get mappings of the peripheral
  50. * banks into the OPB address space */
  51. void ibm4xx_fixup_ebc_ranges(const char *ebc)
  52. {
  53. void *devp;
  54. u32 bxcr;
  55. u32 ranges[EBC_NUM_BANKS*4];
  56. u32 *p = ranges;
  57. int i;
  58. for (i = 0; i < EBC_NUM_BANKS; i++) {
  59. mtdcr(DCRN_EBC0_CFGADDR, EBC_BXCR(i));
  60. bxcr = mfdcr(DCRN_EBC0_CFGDATA);
  61. if ((bxcr & EBC_BXCR_BU) != EBC_BXCR_BU_OFF) {
  62. *p++ = i;
  63. *p++ = 0;
  64. *p++ = bxcr & EBC_BXCR_BAS;
  65. *p++ = EBC_BXCR_BANK_SIZE(bxcr);
  66. }
  67. }
  68. devp = finddevice(ebc);
  69. if (! devp)
  70. fatal("Couldn't locate EBC node %s\n\r", ebc);
  71. setprop(devp, "ranges", ranges, (p - ranges) * sizeof(u32));
  72. }