kernel: bump 5.4 to 5.4.99
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0530-clk-bcm-rpi-Add-DT-provider-for-the-clocks.patch
1 From 19f7515528fbd1dc0d45e4b5ce6531c1406fc8d8 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 7 Feb 2020 17:03:46 +0100
4 Subject: [PATCH] clk: bcm: rpi: Add DT provider for the clocks
5
6 For the upcoming registration of the clocks provided by the firmware, make
7 sure it's exposed to the device tree providers.
8
9 Cc: Michael Turquette <mturquette@baylibre.com>
10 Cc: linux-clk@vger.kernel.org
11 Reviewed-by: Stephen Boyd <sboyd@kernel.org>
12 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
13 ---
14 drivers/clk/bcm/clk-raspberrypi.c | 16 ++++++++++++++++
15 1 file changed, 16 insertions(+)
16
17 --- a/drivers/clk/bcm/clk-raspberrypi.c
18 +++ b/drivers/clk/bcm/clk-raspberrypi.c
19 @@ -31,6 +31,8 @@
20
21 #define A2W_PLL_FRAC_BITS 20
22
23 +#define NUM_FW_CLKS 16
24 +
25 struct raspberrypi_clk {
26 struct device *dev;
27 struct rpi_firmware *firmware;
28 @@ -285,11 +287,13 @@ static struct clk_hw *raspberrypi_regist
29
30 static int raspberrypi_clk_probe(struct platform_device *pdev)
31 {
32 + struct clk_hw_onecell_data *clk_data;
33 struct device_node *firmware_node;
34 struct device *dev = &pdev->dev;
35 struct rpi_firmware *firmware;
36 struct raspberrypi_clk *rpi;
37 struct clk_hw *hw;
38 + int ret;
39
40 firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware", 0);
41 if (!firmware_node) {
42 @@ -309,6 +313,11 @@ static int raspberrypi_clk_probe(struct
43 rpi->firmware = firmware;
44 platform_set_drvdata(pdev, rpi);
45
46 + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, NUM_FW_CLKS),
47 + GFP_KERNEL);
48 + if (!clk_data)
49 + return -ENOMEM;
50 +
51 hw = raspberrypi_register_pllb(rpi);
52 if (IS_ERR(hw)) {
53 dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
54 @@ -318,6 +327,13 @@ static int raspberrypi_clk_probe(struct
55 hw = raspberrypi_register_pllb_arm(rpi);
56 if (IS_ERR(hw))
57 return PTR_ERR(hw);
58 + clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID] = hw;
59 + clk_data->num = RPI_FIRMWARE_ARM_CLK_ID + 1;
60 +
61 + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
62 + clk_data);
63 + if (ret)
64 + return ret;
65
66 rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
67 -1, NULL, 0);