wrap_pll_config_s10.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
  4. *
  5. */
  6. #include <common.h>
  7. #include <asm/arch/clock_manager.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/handoff_s10.h>
  10. #include <asm/arch/system_manager.h>
  11. static const struct socfpga_system_manager *sysmgr_regs =
  12. (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
  13. const struct cm_config * const cm_get_default_config(void)
  14. {
  15. struct cm_config *cm_handoff_cfg = (struct cm_config *)
  16. (S10_HANDOFF_CLOCK + S10_HANDOFF_OFFSET_DATA);
  17. u32 *conversion = (u32 *)cm_handoff_cfg;
  18. u32 i;
  19. u32 handoff_clk = readl(S10_HANDOFF_CLOCK);
  20. if (swab32(handoff_clk) == S10_HANDOFF_MAGIC_CLOCK) {
  21. writel(swab32(handoff_clk), S10_HANDOFF_CLOCK);
  22. for (i = 0; i < (sizeof(*cm_handoff_cfg) / sizeof(u32)); i++)
  23. conversion[i] = swab32(conversion[i]);
  24. return cm_handoff_cfg;
  25. } else if (handoff_clk == S10_HANDOFF_MAGIC_CLOCK) {
  26. return cm_handoff_cfg;
  27. }
  28. return NULL;
  29. }
  30. const unsigned int cm_get_osc_clk_hz(void)
  31. {
  32. #ifdef CONFIG_SPL_BUILD
  33. u32 clock = readl(S10_HANDOFF_CLOCK_OSC);
  34. writel(clock, &sysmgr_regs->boot_scratch_cold1);
  35. #endif
  36. return readl(&sysmgr_regs->boot_scratch_cold1);
  37. }
  38. const unsigned int cm_get_intosc_clk_hz(void)
  39. {
  40. return CLKMGR_INTOSC_HZ;
  41. }
  42. const unsigned int cm_get_fpga_clk_hz(void)
  43. {
  44. #ifdef CONFIG_SPL_BUILD
  45. u32 clock = readl(S10_HANDOFF_CLOCK_FPGA);
  46. writel(clock, &sysmgr_regs->boot_scratch_cold2);
  47. #endif
  48. return readl(&sysmgr_regs->boot_scratch_cold2);
  49. }