fsl-soc.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Freescale SOC support functions
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. *
  6. * Copyright (c) 2007 Freescale Semiconductor, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include "ops.h"
  13. #include "types.h"
  14. #include "fsl-soc.h"
  15. #include "stdio.h"
  16. static u32 prop_buf[MAX_PROP_LEN / 4];
  17. u32 *fsl_get_immr(void)
  18. {
  19. void *soc;
  20. unsigned long ret = 0;
  21. soc = find_node_by_devtype(NULL, "soc");
  22. if (soc) {
  23. int size;
  24. u32 naddr;
  25. size = getprop(soc, "#address-cells", prop_buf, MAX_PROP_LEN);
  26. if (size == 4)
  27. naddr = prop_buf[0];
  28. else
  29. naddr = 2;
  30. if (naddr != 1 && naddr != 2)
  31. goto err;
  32. size = getprop(soc, "ranges", prop_buf, MAX_PROP_LEN);
  33. if (size < 12)
  34. goto err;
  35. if (prop_buf[0] != 0)
  36. goto err;
  37. if (naddr == 2 && prop_buf[1] != 0)
  38. goto err;
  39. if (!dt_xlate_addr(soc, prop_buf + naddr, 8, &ret))
  40. ret = 0;
  41. }
  42. err:
  43. if (!ret)
  44. printf("fsl_get_immr: Failed to find immr base\r\n");
  45. return (u32 *)ret;
  46. }