clk-exynos5440.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (c) 2013 Samsung Electronics Co., Ltd.
  3. * Author: Thomas Abraham <thomas.ab@samsung.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Common Clock Framework support for Exynos5440 SoC.
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/clkdev.h>
  13. #include <linux/clk-provider.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #include <plat/cpu.h>
  17. #include "clk.h"
  18. #include "clk-pll.h"
  19. #define CLKEN_OV_VAL 0xf8
  20. #define CPU_CLK_STATUS 0xfc
  21. #define MISC_DOUT1 0x558
  22. /*
  23. * Let each supported clock get a unique id. This id is used to lookup the clock
  24. * for device tree based platforms.
  25. */
  26. enum exynos5440_clks {
  27. none, xtal, arm_clk,
  28. spi_baud = 16, pb0_250, pr0_250, pr1_250, b_250, b_125, b_200, sata,
  29. usb, gmac0, cs250, pb0_250_o, pr0_250_o, pr1_250_o, b_250_o, b_125_o,
  30. b_200_o, sata_o, usb_o, gmac0_o, cs250_o,
  31. nr_clks,
  32. };
  33. /* parent clock name list */
  34. PNAME(mout_armclk_p) = { "cplla", "cpllb" };
  35. PNAME(mout_spi_p) = { "div125", "div200" };
  36. /* fixed rate clocks generated outside the soc */
  37. struct samsung_fixed_rate_clock exynos5440_fixed_rate_ext_clks[] __initdata = {
  38. FRATE(none, "xtal", NULL, CLK_IS_ROOT, 0),
  39. };
  40. /* fixed rate clocks */
  41. struct samsung_fixed_rate_clock exynos5440_fixed_rate_clks[] __initdata = {
  42. FRATE(none, "ppll", NULL, CLK_IS_ROOT, 1000000000),
  43. FRATE(none, "usb_phy0", NULL, CLK_IS_ROOT, 60000000),
  44. FRATE(none, "usb_phy1", NULL, CLK_IS_ROOT, 60000000),
  45. FRATE(none, "usb_ohci12", NULL, CLK_IS_ROOT, 12000000),
  46. FRATE(none, "usb_ohci48", NULL, CLK_IS_ROOT, 48000000),
  47. };
  48. /* fixed factor clocks */
  49. struct samsung_fixed_factor_clock exynos5440_fixed_factor_clks[] __initdata = {
  50. FFACTOR(none, "div250", "ppll", 1, 4, 0),
  51. FFACTOR(none, "div200", "ppll", 1, 5, 0),
  52. FFACTOR(none, "div125", "div250", 1, 2, 0),
  53. };
  54. /* mux clocks */
  55. struct samsung_mux_clock exynos5440_mux_clks[] __initdata = {
  56. MUX(none, "mout_spi", mout_spi_p, MISC_DOUT1, 5, 1),
  57. MUX_A(arm_clk, "arm_clk", mout_armclk_p,
  58. CPU_CLK_STATUS, 0, 1, "armclk"),
  59. };
  60. /* divider clocks */
  61. struct samsung_div_clock exynos5440_div_clks[] __initdata = {
  62. DIV(spi_baud, "div_spi", "mout_spi", MISC_DOUT1, 3, 2),
  63. };
  64. /* gate clocks */
  65. struct samsung_gate_clock exynos5440_gate_clks[] __initdata = {
  66. GATE(pb0_250, "pb0_250", "div250", CLKEN_OV_VAL, 3, 0, 0),
  67. GATE(pr0_250, "pr0_250", "div250", CLKEN_OV_VAL, 4, 0, 0),
  68. GATE(pr1_250, "pr1_250", "div250", CLKEN_OV_VAL, 5, 0, 0),
  69. GATE(b_250, "b_250", "div250", CLKEN_OV_VAL, 9, 0, 0),
  70. GATE(b_125, "b_125", "div125", CLKEN_OV_VAL, 10, 0, 0),
  71. GATE(b_200, "b_200", "div200", CLKEN_OV_VAL, 11, 0, 0),
  72. GATE(sata, "sata", "div200", CLKEN_OV_VAL, 12, 0, 0),
  73. GATE(usb, "usb", "div200", CLKEN_OV_VAL, 13, 0, 0),
  74. GATE(gmac0, "gmac0", "div200", CLKEN_OV_VAL, 14, 0, 0),
  75. GATE(cs250, "cs250", "div250", CLKEN_OV_VAL, 19, 0, 0),
  76. GATE(pb0_250_o, "pb0_250_o", "pb0_250", CLKEN_OV_VAL, 3, 0, 0),
  77. GATE(pr0_250_o, "pr0_250_o", "pr0_250", CLKEN_OV_VAL, 4, 0, 0),
  78. GATE(pr1_250_o, "pr1_250_o", "pr1_250", CLKEN_OV_VAL, 5, 0, 0),
  79. GATE(b_250_o, "b_250_o", "b_250", CLKEN_OV_VAL, 9, 0, 0),
  80. GATE(b_125_o, "b_125_o", "b_125", CLKEN_OV_VAL, 10, 0, 0),
  81. GATE(b_200_o, "b_200_o", "b_200", CLKEN_OV_VAL, 11, 0, 0),
  82. GATE(sata_o, "sata_o", "sata", CLKEN_OV_VAL, 12, 0, 0),
  83. GATE(usb_o, "usb_o", "usb", CLKEN_OV_VAL, 13, 0, 0),
  84. GATE(gmac0_o, "gmac0_o", "gmac", CLKEN_OV_VAL, 14, 0, 0),
  85. GATE(cs250_o, "cs250_o", "cs250", CLKEN_OV_VAL, 19, 0, 0),
  86. };
  87. static __initdata struct of_device_id ext_clk_match[] = {
  88. { .compatible = "samsung,clock-xtal", .data = (void *)0, },
  89. {},
  90. };
  91. /* register exynos5440 clocks */
  92. void __init exynos5440_clk_init(struct device_node *np)
  93. {
  94. void __iomem *reg_base;
  95. reg_base = of_iomap(np, 0);
  96. if (!reg_base) {
  97. pr_err("%s: failed to map clock controller registers,"
  98. " aborting clock initialization\n", __func__);
  99. return;
  100. }
  101. samsung_clk_init(np, reg_base, nr_clks, NULL, 0, NULL, 0);
  102. samsung_clk_of_register_fixed_ext(exynos5440_fixed_rate_ext_clks,
  103. ARRAY_SIZE(exynos5440_fixed_rate_ext_clks), ext_clk_match);
  104. samsung_clk_register_pll2550x("cplla", "xtal", reg_base + 0x1c, 0x10);
  105. samsung_clk_register_pll2550x("cpllb", "xtal", reg_base + 0x20, 0x10);
  106. samsung_clk_register_fixed_rate(exynos5440_fixed_rate_clks,
  107. ARRAY_SIZE(exynos5440_fixed_rate_clks));
  108. samsung_clk_register_fixed_factor(exynos5440_fixed_factor_clks,
  109. ARRAY_SIZE(exynos5440_fixed_factor_clks));
  110. samsung_clk_register_mux(exynos5440_mux_clks,
  111. ARRAY_SIZE(exynos5440_mux_clks));
  112. samsung_clk_register_div(exynos5440_div_clks,
  113. ARRAY_SIZE(exynos5440_div_clks));
  114. samsung_clk_register_gate(exynos5440_gate_clks,
  115. ARRAY_SIZE(exynos5440_gate_clks));
  116. pr_info("Exynos5440: arm_clk = %ldHz\n", _get_rate("armclk"));
  117. pr_info("exynos5440 clock initialization complete\n");
  118. }
  119. CLK_OF_DECLARE(exynos5440_clk, "samsung,exynos5440-clock", exynos5440_clk_init);