dpll-ld4.c 1018 B

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