dpll-ld4.c 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2013-2014 Panasonic Corporation
  4. * Copyright (C) 2015-2016 Socionext Inc.
  5. */
  6. #include <common.h>
  7. #include <linux/errno.h>
  8. #include <linux/io.h>
  9. #include "../init.h"
  10. #include "../sc-regs.h"
  11. #undef DPLL_SSC_RATE_1PER
  12. int uniphier_ld4_dpll_init(const struct uniphier_board_data *bd)
  13. {
  14. unsigned int dram_freq = bd->dram_freq;
  15. u32 tmp;
  16. /*
  17. * Set Frequency
  18. * Set 0xc(1600MHz)/0xd(1333MHz)/0xe(1066MHz)
  19. * to FOUT (DPLLCTRL.bit[29:20])
  20. */
  21. tmp = readl(SC_DPLLCTRL);
  22. tmp &= ~0x000f0000;
  23. switch (dram_freq) {
  24. case 1333:
  25. tmp |= 0x000d0000;
  26. break;
  27. case 1600:
  28. tmp |= 0x000c0000;
  29. break;
  30. default:
  31. pr_err("Unsupported frequency");
  32. return -EINVAL;
  33. }
  34. #if defined(DPLL_SSC_RATE_1PER)
  35. tmp &= ~SC_DPLLCTRL_SSC_RATE;
  36. #else
  37. tmp |= SC_DPLLCTRL_SSC_RATE;
  38. #endif
  39. writel(tmp, SC_DPLLCTRL);
  40. tmp = readl(SC_DPLLCTRL2);
  41. tmp |= SC_DPLLCTRL2_NRSTDS;
  42. writel(tmp, SC_DPLLCTRL2);
  43. /* Wait 500 usec until dpll gets stable */
  44. udelay(500);
  45. return 0;
  46. }