dpll-pro4.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_pro4_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. /*
  35. * Set Moduration rate
  36. * Set 0x0(1%)/0x1(2%) to SSC_RATE(DPLLCTRL.bit[15])
  37. */
  38. #if defined(DPLL_SSC_RATE_1PER)
  39. tmp &= ~0x00008000;
  40. #else
  41. tmp |= 0x00008000;
  42. #endif
  43. writel(tmp, SC_DPLLCTRL);
  44. tmp = readl(SC_DPLLCTRL2);
  45. tmp |= SC_DPLLCTRL2_NRSTDS;
  46. writel(tmp, SC_DPLLCTRL2);
  47. /* Wait until dpll gets stable */
  48. udelay(500);
  49. return 0;
  50. }