kpss-xcc.c 1.8 KB

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