bcm27xx: update patches from RPi foundation
[openwrt/staging/luka.git] / target / linux / bcm27xx / patches-5.4 / 950-0518-clk-bcm-rpi-Allow-the-driver-to-be-probed-by-DT.patch
1 From faeea753ba262e2a781570f9db23c5773c5d20e7 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 23 Dec 2019 19:58:08 +0100
4 Subject: [PATCH] clk: bcm: rpi: Allow the driver to be probed by DT
5
6 The current firmware clock driver for the RaspberryPi can only be probed by
7 manually registering an associated platform_device.
8
9 While this works fine for cpufreq where the device gets attached a clkdev
10 lookup, it would be tedious to maintain a table of all the devices using
11 one of the clocks exposed by the firmware.
12
13 Since the DT on the other hand is the perfect place to store those
14 associations, make the firmware clocks driver probe-able through the device
15 tree so that we can represent it as a node.
16
17 Cc: Michael Turquette <mturquette@baylibre.com>
18 Cc: Stephen Boyd <sboyd@kernel.org>
19 Cc: linux-clk@vger.kernel.org
20 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
21 ---
22 drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++---
23 1 file changed, 8 insertions(+), 3 deletions(-)
24
25 --- a/drivers/clk/bcm/clk-raspberrypi.c
26 +++ b/drivers/clk/bcm/clk-raspberrypi.c
27 @@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct
28 struct raspberrypi_clk *rpi;
29 int ret;
30
31 - firmware_node = of_find_compatible_node(NULL, NULL,
32 - "raspberrypi,bcm2835-firmware");
33 + firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware", 0);
34 if (!firmware_node) {
35 dev_err(dev, "Missing firmware node\n");
36 return -ENOENT;
37 }
38
39 firmware = rpi_firmware_get(firmware_node);
40 - of_node_put(firmware_node);
41 if (!firmware)
42 return -EPROBE_DEFER;
43
44 @@ -300,9 +298,16 @@ static int raspberrypi_clk_remove(struct
45 return 0;
46 }
47
48 +static const struct of_device_id raspberrypi_clk_match[] = {
49 + { .compatible = "raspberrypi,firmware-clocks" },
50 + { },
51 +};
52 +MODULE_DEVICE_TABLE(of, raspberrypi_clk_match);
53 +
54 static struct platform_driver raspberrypi_clk_driver = {
55 .driver = {
56 .name = "raspberrypi-clk",
57 + .of_match_table = raspberrypi_clk_match,
58 },
59 .probe = raspberrypi_clk_probe,
60 .remove = raspberrypi_clk_remove,