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