kpss-xcc.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2018, The Linux Foundation. All rights reserved.
  3. #include <linux/kernel.h>
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/property.h>
  8. #include <linux/err.h>
  9. #include <linux/io.h>
  10. #include <linux/of.h>
  11. #include <linux/clk.h>
  12. #include <linux/clk-provider.h>
  13. static const struct clk_parent_data aux_parents[] = {
  14. { .fw_name = "pll8_vote", .name = "pll8_vote" },
  15. { .fw_name = "pxo", .name = "pxo_board" },
  16. };
  17. static const u32 aux_parent_map[] = {
  18. 3,
  19. 0,
  20. };
  21. static const struct of_device_id kpss_xcc_match_table[] = {
  22. { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
  23. { .compatible = "qcom,kpss-gcc" },
  24. {}
  25. };
  26. MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
  27. static int kpss_xcc_driver_probe(struct platform_device *pdev)
  28. {
  29. struct device *dev = &pdev->dev;
  30. void __iomem *base;
  31. struct clk_hw *hw;
  32. const char *name;
  33. base = devm_platform_ioremap_resource(pdev, 0);
  34. if (IS_ERR(base))
  35. return PTR_ERR(base);
  36. if (device_get_match_data(&pdev->dev)) {
  37. if (of_property_read_string_index(dev->of_node,
  38. "clock-output-names",
  39. 0, &name))
  40. return -ENODEV;
  41. base += 0x14;
  42. } else {
  43. name = "acpu_l2_aux";
  44. base += 0x28;
  45. }
  46. hw = devm_clk_hw_register_mux_parent_data_table(dev, name, aux_parents,
  47. ARRAY_SIZE(aux_parents), 0,
  48. base, 0, 0x3,
  49. 0, aux_parent_map, NULL);
  50. if (IS_ERR(hw))
  51. return PTR_ERR(hw);
  52. return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, hw);
  53. }
  54. static struct platform_driver kpss_xcc_driver = {
  55. .probe = kpss_xcc_driver_probe,
  56. .driver = {
  57. .name = "kpss-xcc",
  58. .of_match_table = kpss_xcc_match_table,
  59. },
  60. };
  61. module_platform_driver(kpss_xcc_driver);
  62. MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
  63. MODULE_LICENSE("GPL v2");
  64. MODULE_ALIAS("platform:kpss-xcc");