apss-ipq-pll.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2018, The Linux Foundation. All rights reserved.
  3. #include <linux/clk-provider.h>
  4. #include <linux/module.h>
  5. #include <linux/of_device.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/regmap.h>
  8. #include "clk-alpha-pll.h"
  9. static const u8 ipq_pll_offsets[] = {
  10. [PLL_OFF_L_VAL] = 0x08,
  11. [PLL_OFF_ALPHA_VAL] = 0x10,
  12. [PLL_OFF_USER_CTL] = 0x18,
  13. [PLL_OFF_CONFIG_CTL] = 0x20,
  14. [PLL_OFF_CONFIG_CTL_U] = 0x24,
  15. [PLL_OFF_STATUS] = 0x28,
  16. [PLL_OFF_TEST_CTL] = 0x30,
  17. [PLL_OFF_TEST_CTL_U] = 0x34,
  18. };
  19. static struct clk_alpha_pll ipq_pll = {
  20. .offset = 0x0,
  21. .regs = ipq_pll_offsets,
  22. .flags = SUPPORTS_DYNAMIC_UPDATE,
  23. .clkr = {
  24. .enable_reg = 0x0,
  25. .enable_mask = BIT(0),
  26. .hw.init = &(struct clk_init_data){
  27. .name = "a53pll",
  28. .parent_data = &(const struct clk_parent_data) {
  29. .fw_name = "xo",
  30. },
  31. .num_parents = 1,
  32. .ops = &clk_alpha_pll_huayra_ops,
  33. },
  34. },
  35. };
  36. static const struct alpha_pll_config ipq6018_pll_config = {
  37. .l = 0x37,
  38. .config_ctl_val = 0x240d4828,
  39. .config_ctl_hi_val = 0x6,
  40. .early_output_mask = BIT(3),
  41. .aux2_output_mask = BIT(2),
  42. .aux_output_mask = BIT(1),
  43. .main_output_mask = BIT(0),
  44. .test_ctl_val = 0x1c0000C0,
  45. .test_ctl_hi_val = 0x4000,
  46. };
  47. static const struct alpha_pll_config ipq8074_pll_config = {
  48. .l = 0x48,
  49. .config_ctl_val = 0x200d4828,
  50. .config_ctl_hi_val = 0x6,
  51. .early_output_mask = BIT(3),
  52. .aux2_output_mask = BIT(2),
  53. .aux_output_mask = BIT(1),
  54. .main_output_mask = BIT(0),
  55. .test_ctl_val = 0x1c000000,
  56. .test_ctl_hi_val = 0x4000,
  57. };
  58. static const struct regmap_config ipq_pll_regmap_config = {
  59. .reg_bits = 32,
  60. .reg_stride = 4,
  61. .val_bits = 32,
  62. .max_register = 0x40,
  63. .fast_io = true,
  64. };
  65. static int apss_ipq_pll_probe(struct platform_device *pdev)
  66. {
  67. const struct alpha_pll_config *ipq_pll_config;
  68. struct device *dev = &pdev->dev;
  69. struct regmap *regmap;
  70. void __iomem *base;
  71. int ret;
  72. base = devm_platform_ioremap_resource(pdev, 0);
  73. if (IS_ERR(base))
  74. return PTR_ERR(base);
  75. regmap = devm_regmap_init_mmio(dev, base, &ipq_pll_regmap_config);
  76. if (IS_ERR(regmap))
  77. return PTR_ERR(regmap);
  78. ipq_pll_config = of_device_get_match_data(&pdev->dev);
  79. if (!ipq_pll_config)
  80. return -ENODEV;
  81. clk_alpha_pll_configure(&ipq_pll, regmap, ipq_pll_config);
  82. ret = devm_clk_register_regmap(dev, &ipq_pll.clkr);
  83. if (ret)
  84. return ret;
  85. return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
  86. &ipq_pll.clkr.hw);
  87. }
  88. static const struct of_device_id apss_ipq_pll_match_table[] = {
  89. { .compatible = "qcom,ipq6018-a53pll", .data = &ipq6018_pll_config },
  90. { .compatible = "qcom,ipq8074-a53pll", .data = &ipq8074_pll_config },
  91. { }
  92. };
  93. MODULE_DEVICE_TABLE(of, apss_ipq_pll_match_table);
  94. static struct platform_driver apss_ipq_pll_driver = {
  95. .probe = apss_ipq_pll_probe,
  96. .driver = {
  97. .name = "qcom-ipq-apss-pll",
  98. .of_match_table = apss_ipq_pll_match_table,
  99. },
  100. };
  101. module_platform_driver(apss_ipq_pll_driver);
  102. MODULE_DESCRIPTION("Qualcomm technology Inc APSS ALPHA PLL Driver");
  103. MODULE_LICENSE("GPL v2");