pll-tmpv770x.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Toshiba Visconti PLL controller
  4. *
  5. * Copyright (c) 2021 TOSHIBA CORPORATION
  6. * Copyright (c) 2021 Toshiba Electronic Devices & Storage Corporation
  7. *
  8. * Nobuhiro Iwamatsu <[email protected]>
  9. */
  10. #include <linux/clk-provider.h>
  11. #include <linux/of_address.h>
  12. #include <linux/slab.h>
  13. #include <dt-bindings/clock/toshiba,tmpv770x.h>
  14. #include "pll.h"
  15. static DEFINE_SPINLOCK(tmpv770x_pll_lock);
  16. static const struct visconti_pll_rate_table pipll0_rates[] __initconst = {
  17. VISCONTI_PLL_RATE(840000000, 0x1, 0x0, 0x1, 0x54, 0x000000, 0x2, 0x1),
  18. VISCONTI_PLL_RATE(780000000, 0x1, 0x0, 0x1, 0x4e, 0x000000, 0x2, 0x1),
  19. VISCONTI_PLL_RATE(600000000, 0x1, 0x0, 0x1, 0x3c, 0x000000, 0x2, 0x1),
  20. { /* sentinel */ },
  21. };
  22. static const struct visconti_pll_rate_table piddrcpll_rates[] __initconst = {
  23. VISCONTI_PLL_RATE(780000000, 0x1, 0x0, 0x1, 0x4e, 0x000000, 0x2, 0x1),
  24. VISCONTI_PLL_RATE(760000000, 0x1, 0x0, 0x1, 0x4c, 0x000000, 0x2, 0x1),
  25. { /* sentinel */ },
  26. };
  27. static const struct visconti_pll_rate_table pivoifpll_rates[] __initconst = {
  28. VISCONTI_PLL_RATE(165000000, 0x1, 0x0, 0x1, 0x42, 0x000000, 0x4, 0x2),
  29. VISCONTI_PLL_RATE(148500000, 0x1, 0x1, 0x1, 0x3b, 0x666666, 0x4, 0x2),
  30. VISCONTI_PLL_RATE(96000000, 0x1, 0x0, 0x1, 0x30, 0x000000, 0x5, 0x2),
  31. VISCONTI_PLL_RATE(74250000, 0x1, 0x1, 0x1, 0x3b, 0x666666, 0x4, 0x4),
  32. VISCONTI_PLL_RATE(54000000, 0x1, 0x0, 0x1, 0x36, 0x000000, 0x5, 0x4),
  33. VISCONTI_PLL_RATE(48000000, 0x1, 0x0, 0x1, 0x30, 0x000000, 0x5, 0x4),
  34. VISCONTI_PLL_RATE(35750000, 0x1, 0x1, 0x1, 0x32, 0x0ccccc, 0x7, 0x4),
  35. { /* sentinel */ },
  36. };
  37. static const struct visconti_pll_rate_table piimgerpll_rates[] __initconst = {
  38. VISCONTI_PLL_RATE(165000000, 0x1, 0x0, 0x1, 0x42, 0x000000, 0x4, 0x2),
  39. VISCONTI_PLL_RATE(96000000, 0x1, 0x0, 0x1, 0x30, 0x000000, 0x5, 0x2),
  40. VISCONTI_PLL_RATE(54000000, 0x1, 0x0, 0x1, 0x36, 0x000000, 0x5, 0x4),
  41. VISCONTI_PLL_RATE(48000000, 0x1, 0x0, 0x1, 0x30, 0x000000, 0x5, 0x4),
  42. { /* sentinel */ },
  43. };
  44. static const struct visconti_pll_info pll_info[] __initconst = {
  45. { TMPV770X_PLL_PIPLL0, "pipll0", "osc2-clk", 0x0, pipll0_rates },
  46. { TMPV770X_PLL_PIDDRCPLL, "piddrcpll", "osc2-clk", 0x500, piddrcpll_rates },
  47. { TMPV770X_PLL_PIVOIFPLL, "pivoifpll", "osc2-clk", 0x600, pivoifpll_rates },
  48. { TMPV770X_PLL_PIIMGERPLL, "piimgerpll", "osc2-clk", 0x700, piimgerpll_rates },
  49. };
  50. static void __init tmpv770x_setup_plls(struct device_node *np)
  51. {
  52. struct visconti_pll_provider *ctx;
  53. void __iomem *reg_base;
  54. reg_base = of_iomap(np, 0);
  55. if (!reg_base)
  56. return;
  57. ctx = visconti_init_pll(np, reg_base, TMPV770X_NR_PLL);
  58. if (IS_ERR(ctx)) {
  59. iounmap(reg_base);
  60. return;
  61. }
  62. ctx->clk_data.hws[TMPV770X_PLL_PIPLL1] =
  63. clk_hw_register_fixed_rate(NULL, "pipll1", NULL, 0, 600000000);
  64. ctx->clk_data.hws[TMPV770X_PLL_PIDNNPLL] =
  65. clk_hw_register_fixed_rate(NULL, "pidnnpll", NULL, 0, 500000000);
  66. ctx->clk_data.hws[TMPV770X_PLL_PIETHERPLL] =
  67. clk_hw_register_fixed_rate(NULL, "pietherpll", NULL, 0, 500000000);
  68. visconti_register_plls(ctx, pll_info, ARRAY_SIZE(pll_info), &tmpv770x_pll_lock);
  69. }
  70. CLK_OF_DECLARE(tmpv770x_plls, "toshiba,tmpv7708-pipllct", tmpv770x_setup_plls);