be4d83485f57883160d86fa774eb48ea3df531d2
[openwrt/staging/adrian.git] /
1 From b39d5caa499559be6c309b9fd8f8b2f992504e18 Mon Sep 17 00:00:00 2001
2 From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
3 Date: Wed, 12 Jun 2019 20:24:57 +0200
4 Subject: [PATCH] clk: raspberrypi: register platform device for
5 raspberrypi-cpufreq
6
7 Commit e2bb18347c8e5c4187831f3700c380e3c759601a upstream.
8
9 As 'clk-raspberrypi' depends on RPi's firmware interface, which might be
10 configured as a module, the cpu clock might not be available for the
11 cpufreq driver during it's init process. So we register the
12 'raspberrypi-cpufreq' platform device after the probe sequence succeeds.
13
14 Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
15 Acked-by: Eric Anholt <eric@anholt.net>
16 Signed-off-by: Stephen Boyd <sboyd@kernel.org>
17 ---
18 drivers/clk/bcm/clk-raspberrypi.c | 15 +++++++++++++++
19 1 file changed, 15 insertions(+)
20
21 --- a/drivers/clk/bcm/clk-raspberrypi.c
22 +++ b/drivers/clk/bcm/clk-raspberrypi.c
23 @@ -34,6 +34,7 @@
24 struct raspberrypi_clk {
25 struct device *dev;
26 struct rpi_firmware *firmware;
27 + struct platform_device *cpufreq;
28
29 unsigned long min_rate;
30 unsigned long max_rate;
31 @@ -272,6 +273,7 @@ static int raspberrypi_clk_probe(struct
32
33 rpi->dev = dev;
34 rpi->firmware = firmware;
35 + platform_set_drvdata(pdev, rpi);
36
37 ret = raspberrypi_register_pllb(rpi);
38 if (ret) {
39 @@ -283,6 +285,18 @@ static int raspberrypi_clk_probe(struct
40 if (ret)
41 return ret;
42
43 + rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
44 + -1, NULL, 0);
45 +
46 + return 0;
47 +}
48 +
49 +static int raspberrypi_clk_remove(struct platform_device *pdev)
50 +{
51 + struct raspberrypi_clk *rpi = platform_get_drvdata(pdev);
52 +
53 + platform_device_unregister(rpi->cpufreq);
54 +
55 return 0;
56 }
57
58 @@ -291,6 +305,7 @@ static struct platform_driver raspberryp
59 .name = "raspberrypi-clk",
60 },
61 .probe = raspberrypi_clk_probe,
62 + .remove = raspberrypi_clk_remove,
63 };
64 module_platform_driver(raspberrypi_clk_driver);
65