kpss-xcc.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/err.h>
  8. #include <linux/io.h>
  9. #include <linux/of.h>
  10. #include <linux/of_device.h>
  11. #include <linux/clk.h>
  12. #include <linux/clk-provider.h>
  13. static const char *aux_parents[] = {
  14. "pll8_vote",
  15. "pxo",
  16. };
  17. static unsigned int 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. const struct of_device_id *id;
  30. struct clk *clk;
  31. struct resource *res;
  32. void __iomem *base;
  33. const char *name;
  34. id = of_match_device(kpss_xcc_match_table, &pdev->dev);
  35. if (!id)
  36. return -ENODEV;
  37. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  38. base = devm_ioremap_resource(&pdev->dev, res);
  39. if (IS_ERR(base))
  40. return PTR_ERR(base);
  41. if (id->data) {
  42. if (of_property_read_string_index(pdev->dev.of_node,
  43. "clock-output-names",
  44. 0, &name))
  45. return -ENODEV;
  46. base += 0x14;
  47. } else {
  48. name = "acpu_l2_aux";
  49. base += 0x28;
  50. }
  51. clk = clk_register_mux_table(&pdev->dev, name, aux_parents,
  52. ARRAY_SIZE(aux_parents), 0, base, 0, 0x3,
  53. 0, aux_parent_map, NULL);
  54. platform_set_drvdata(pdev, clk);
  55. return PTR_ERR_OR_ZERO(clk);
  56. }
  57. static int kpss_xcc_driver_remove(struct platform_device *pdev)
  58. {
  59. clk_unregister_mux(platform_get_drvdata(pdev));
  60. return 0;
  61. }
  62. static struct platform_driver kpss_xcc_driver = {
  63. .probe = kpss_xcc_driver_probe,
  64. .remove = kpss_xcc_driver_remove,
  65. .driver = {
  66. .name = "kpss-xcc",
  67. .of_match_table = kpss_xcc_match_table,
  68. },
  69. };
  70. module_platform_driver(kpss_xcc_driver);
  71. MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
  72. MODULE_LICENSE("GPL v2");
  73. MODULE_ALIAS("platform:kpss-xcc");