950-0850-clk-Introduce-clk_hw_init_rate_request.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From 7023dd1743aa6bb305fdce96e6e80eecc6e01f16 Mon Sep 17 00:00:00 2001
  2. From: Maxime Ripard <[email protected]>
  3. Date: Sat, 2 Apr 2022 14:49:56 +0200
  4. Subject: [PATCH] clk: Introduce clk_hw_init_rate_request()
  5. Some drivers (at91, imx, qcom) use __clk_determine_rate directly, and
  6. thus will need to initialise a clk_rate_request structure.
  7. However, drivers don't have access to the function that the core uses to
  8. initialize that structure which could prove to be useful.
  9. Let's create a function for clock providers that will initialize a
  10. clk_rate_request for a given clk_hw pointer and a rate.
  11. Tested-by: Alexander Stein <[email protected]> # imx8mp
  12. Tested-by: Marek Szyprowski <[email protected]> # exynos4210, meson g12b
  13. Signed-off-by: Maxime Ripard <[email protected]>
  14. ---
  15. drivers/clk/clk.c | 20 ++++++++++++++++++++
  16. include/linux/clk-provider.h | 6 ++++++
  17. 2 files changed, 26 insertions(+)
  18. --- a/drivers/clk/clk.c
  19. +++ b/drivers/clk/clk.c
  20. @@ -1394,6 +1394,26 @@ static void clk_core_init_rate_req(struc
  21. }
  22. }
  23. +/**
  24. + * clk_hw_init_rate_request - Initializes a clk_rate_request
  25. + * @hw: the clk for which we want to submit a rate request
  26. + * @req: the clk_rate_request structure we want to initialise
  27. + * @rate: the rate which is to be requested
  28. + *
  29. + * Initializes and fills a clk_rate_request structure to submit to
  30. + * __clk_determine_rate or similar functions.
  31. + */
  32. +void clk_hw_init_rate_request(struct clk_hw * const hw,
  33. + struct clk_rate_request *req,
  34. + unsigned long rate)
  35. +{
  36. + if (WARN_ON(!hw || !req))
  37. + return;
  38. +
  39. + clk_core_init_rate_req(hw->core, req, rate);
  40. +}
  41. +EXPORT_SYMBOL_GPL(clk_hw_init_rate_request);
  42. +
  43. static bool clk_core_can_round(struct clk_core * const core)
  44. {
  45. return core->ops->determine_rate || core->ops->round_rate;
  46. --- a/include/linux/clk-provider.h
  47. +++ b/include/linux/clk-provider.h
  48. @@ -42,6 +42,8 @@ struct dentry;
  49. * struct clk_rate_request - Structure encoding the clk constraints that
  50. * a clock user might require.
  51. *
  52. + * Should be initialized by calling clk_hw_init_rate_request().
  53. + *
  54. * @rate: Requested clock rate. This field will be adjusted by
  55. * clock drivers according to hardware capabilities.
  56. * @min_rate: Minimum rate imposed by clk users.
  57. @@ -60,6 +62,10 @@ struct clk_rate_request {
  58. struct clk_hw *best_parent_hw;
  59. };
  60. +void clk_hw_init_rate_request(struct clk_hw * const hw,
  61. + struct clk_rate_request *req,
  62. + unsigned long rate);
  63. +
  64. /**
  65. * struct clk_duty - Struture encoding the duty cycle ratio of a clock
  66. *