mips-cpc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2013 Imagination Technologies
  3. * Author: Paul Burton <paul.burton@imgtec.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 as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #include <linux/errno.h>
  11. #include <asm/mips-cm.h>
  12. #include <asm/mips-cpc.h>
  13. void __iomem *mips_cpc_base;
  14. phys_t __weak mips_cpc_phys_base(void)
  15. {
  16. u32 cpc_base;
  17. if (!mips_cm_present())
  18. return 0;
  19. if (!(read_gcr_cpc_status() & CM_GCR_CPC_STATUS_EX_MSK))
  20. return 0;
  21. /* If the CPC is already enabled, leave it so */
  22. cpc_base = read_gcr_cpc_base();
  23. if (cpc_base & CM_GCR_CPC_BASE_CPCEN_MSK)
  24. return cpc_base & CM_GCR_CPC_BASE_CPCBASE_MSK;
  25. /* Otherwise, give it the default address & enable it */
  26. cpc_base = mips_cpc_default_phys_base();
  27. write_gcr_cpc_base(cpc_base | CM_GCR_CPC_BASE_CPCEN_MSK);
  28. return cpc_base;
  29. }
  30. int mips_cpc_probe(void)
  31. {
  32. phys_t addr;
  33. addr = mips_cpc_phys_base();
  34. if (!addr)
  35. return -ENODEV;
  36. mips_cpc_base = ioremap_nocache(addr, 0x8000);
  37. if (!mips_cpc_base)
  38. return -ENXIO;
  39. return 0;
  40. }