8236-clk-add-API-of-clks.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From df2373ca941741f3f66750241a048ad4e2ff2c91 Mon Sep 17 00:00:00 2001
  2. From: Zhao Qiang <qiang.zhao@nxp.com>
  3. Date: Thu, 24 Nov 2016 11:47:45 +0800
  4. Subject: [PATCH 236/238] clk: add API of clks
  5. Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
  6. ---
  7. drivers/clk/clk.c | 19 +++++++++++++++++++
  8. include/linux/clk-provider.h | 1 +
  9. include/linux/clk.h | 9 +++++++++
  10. 3 files changed, 29 insertions(+)
  11. --- a/drivers/clk/clk.c
  12. +++ b/drivers/clk/clk.c
  13. @@ -359,6 +359,19 @@ static struct clk_core *clk_core_get_par
  14. return core->parents[index];
  15. }
  16. +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
  17. +{
  18. + struct clk_core *parent;
  19. +
  20. + if (!clk)
  21. + return NULL;
  22. +
  23. + parent = clk_core_get_parent_by_index(clk->core, index);
  24. +
  25. + return !parent ? NULL : parent->hw->clk;
  26. +}
  27. +EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
  28. +
  29. struct clk_hw *
  30. clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
  31. {
  32. @@ -2036,6 +2049,12 @@ static const struct file_operations clk_
  33. .release = single_release,
  34. };
  35. +unsigned int clk_get_num_parents(struct clk *clk)
  36. +{
  37. + return !clk ? 0 : clk->core->num_parents;
  38. +}
  39. +EXPORT_SYMBOL_GPL(clk_get_num_parents);
  40. +
  41. static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
  42. {
  43. if (!c)
  44. --- a/include/linux/clk-provider.h
  45. +++ b/include/linux/clk-provider.h
  46. @@ -656,6 +656,7 @@ unsigned int clk_hw_get_num_parents(cons
  47. struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
  48. struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
  49. unsigned int index);
  50. +struct clk *clk_get_parent_by_index(struct clk *clk, u8 index);
  51. unsigned int __clk_get_enable_count(struct clk *clk);
  52. unsigned long clk_hw_get_rate(const struct clk_hw *hw);
  53. unsigned long __clk_get_flags(struct clk *clk);
  54. --- a/include/linux/clk.h
  55. +++ b/include/linux/clk.h
  56. @@ -392,6 +392,15 @@ int clk_set_parent(struct clk *clk, stru
  57. struct clk *clk_get_parent(struct clk *clk);
  58. /**
  59. + * clk_get_num_parents - get number of possible parents
  60. + * @clk: clock source
  61. + *
  62. + * Returns the number of possible parents of this clock,
  63. + * which can then be enumerated using clk_get_parent_by_index().
  64. + */
  65. +unsigned int clk_get_num_parents(struct clk *clk);
  66. +
  67. +/**
  68. * clk_get_sys - get a clock based upon the device name
  69. * @dev_id: device name
  70. * @con_id: connection ID