Skip to content

Commit fbac2e7

Browse files
mripardbebarino
authored andcommitted
clk: bcm: rpi: Allow the driver to be probed by DT
The current firmware clock driver for the RaspberryPi can only be probed by manually registering an associated platform_device. While this works fine for cpufreq where the device gets attached a clkdev lookup, it would be tedious to maintain a table of all the devices using one of the clocks exposed by the firmware. Since the DT on the other hand is the perfect place to store those associations, make the firmware clocks driver probe-able through the device tree so that we can represent it as a node. Cc: Michael Turquette <[email protected]> Cc: [email protected] Reviewed-by: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Tested-by: Nicolas Saenz Julienne <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/cb8203b862e386ac6c3df3eff0bb5a238b6ec97a.1592210452.git-series.maxime@cerno.tech Signed-off-by: Stephen Boyd <[email protected]>
1 parent 511aba0 commit fbac2e7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,16 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
255255
struct raspberrypi_clk *rpi;
256256
int ret;
257257

258-
firmware_node = of_find_compatible_node(NULL, NULL,
259-
"raspberrypi,bcm2835-firmware");
258+
/*
259+
* We can be probed either through the an old-fashioned
260+
* platform device registration or through a DT node that is a
261+
* child of the firmware node. Handle both cases.
262+
*/
263+
if (dev->of_node)
264+
firmware_node = of_get_parent(dev->of_node);
265+
else
266+
firmware_node = of_find_compatible_node(NULL, NULL,
267+
"raspberrypi,bcm2835-firmware");
260268
if (!firmware_node) {
261269
dev_err(dev, "Missing firmware node\n");
262270
return -ENOENT;
@@ -300,9 +308,16 @@ static int raspberrypi_clk_remove(struct platform_device *pdev)
300308
return 0;
301309
}
302310

311+
static const struct of_device_id raspberrypi_clk_match[] = {
312+
{ .compatible = "raspberrypi,firmware-clocks" },
313+
{ },
314+
};
315+
MODULE_DEVICE_TABLE(of, raspberrypi_clk_match);
316+
303317
static struct platform_driver raspberrypi_clk_driver = {
304318
.driver = {
305319
.name = "raspberrypi-clk",
320+
.of_match_table = raspberrypi_clk_match,
306321
},
307322
.probe = raspberrypi_clk_probe,
308323
.remove = raspberrypi_clk_remove,

0 commit comments

Comments
 (0)