kpss-xcc.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 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. const struct of_device_id *id;
  30. void __iomem *base;
  31. struct clk_hw *hw;
  32. const char *name;
  33. id = of_match_device(kpss_xcc_match_table, &pdev->dev);
  34. if (!id)
  35. return -ENODEV;
  36. base = devm_platform_ioremap_resource(pdev, 0);
  37. if (IS_ERR(base))
  38. return PTR_ERR(base);
  39. if (id->data) {
  40. if (of_property_read_string_index(pdev->dev.of_node,
  41. "clock-output-names",
  42. 0, &name))
  43. return -ENODEV;
  44. base += 0x14;
  45. } else {
  46. name = "acpu_l2_aux";
  47. base += 0x28;
  48. }
  49. hw = devm_clk_hw_register_mux_parent_data_table(&pdev->dev, name, aux_parents,
  50. ARRAY_SIZE(aux_parents), 0,
  51. base, 0, 0x3,
  52. 0, aux_parent_map, NULL);
  53. return PTR_ERR_OR_ZERO(hw);
  54. }
  55. static struct platform_driver kpss_xcc_driver = {
  56. .probe = kpss_xcc_driver_probe,
  57. .driver = {
  58. .name = "kpss-xcc",
  59. .of_match_table = kpss_xcc_match_table,
  60. },
  61. };
  62. module_platform_driver(kpss_xcc_driver);
  63. MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
  64. MODULE_LICENSE("GPL v2");
  65. MODULE_ALIAS("platform:kpss-xcc");