firmware: rpi: Only create clocks device if we don't have a node for it
authorMaxime Ripard <maxime@cerno.tech>
Mon, 15 Jun 2020 08:40:43 +0000 (10:40 +0200)
committerStephen Boyd <sboyd@kernel.org>
Sat, 20 Jun 2020 00:21:15 +0000 (17:21 -0700)
The firmware clocks driver was previously probed through a platform_device
created by the firmware driver.

Since we will now have a node for that clocks driver, we need to create the
device only in the case where there's no node for it already.

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/72114c4287ebda2dbd952ea238d4489d359897e5.1592210452.git-series.maxime@cerno.tech
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/firmware/raspberrypi.c

index ef80988..b25901a 100644 (file)
@@ -208,6 +208,20 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
 
 static void rpi_register_clk_driver(struct device *dev)
 {
+       struct device_node *firmware;
+
+       /*
+        * Earlier DTs don't have a node for the firmware clocks but
+        * rely on us creating a platform device by hand. If we do
+        * have a node for the firmware clocks, just bail out here.
+        */
+       firmware = of_get_compatible_child(dev->of_node,
+                                          "raspberrypi,firmware-clocks");
+       if (firmware) {
+               of_node_put(firmware);
+               return;
+       }
+
        rpi_clk = platform_device_register_data(dev, "raspberrypi-clk",
                                                -1, NULL, 0);
 }