clk: bcm: rpi: Add DT provider for the clocks
authorMaxime Ripard <maxime@cerno.tech>
Mon, 15 Jun 2020 08:40:59 +0000 (10:40 +0200)
committerStephen Boyd <sboyd@kernel.org>
Sat, 20 Jun 2020 00:21:17 +0000 (17:21 -0700)
For the upcoming registration of the clocks provided by the firmware, make
sure it's exposed to the device tree providers.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/4d8dbe4aaae98b3d3812ad7c3dba53d645cadbaf.1592210452.git-series.maxime@cerno.tech
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/bcm/clk-raspberrypi.c

index d2cb90c..5f4e2d4 100644 (file)
@@ -31,6 +31,8 @@
 
 #define A2W_PLL_FRAC_BITS              20
 
+#define NUM_FW_CLKS                    16
+
 struct raspberrypi_clk {
        struct device *dev;
        struct rpi_firmware *firmware;
@@ -282,11 +284,13 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 
 static int raspberrypi_clk_probe(struct platform_device *pdev)
 {
+       struct clk_hw_onecell_data *clk_data;
        struct device_node *firmware_node;
        struct device *dev = &pdev->dev;
        struct rpi_firmware *firmware;
        struct raspberrypi_clk *rpi;
        struct clk_hw *hw;
+       int ret;
 
        /*
         * We can be probed either through the an old-fashioned
@@ -316,6 +320,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
        rpi->firmware = firmware;
        platform_set_drvdata(pdev, rpi);
 
+       clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, NUM_FW_CLKS),
+                               GFP_KERNEL);
+       if (!clk_data)
+               return -ENOMEM;
+
        hw = raspberrypi_register_pllb(rpi);
        if (IS_ERR(hw)) {
                dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
@@ -325,6 +334,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
        hw = raspberrypi_register_pllb_arm(rpi);
        if (IS_ERR(hw))
                return PTR_ERR(hw);
+       clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID] = hw;
+       clk_data->num = RPI_FIRMWARE_ARM_CLK_ID + 1;
+
+       ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+                                         clk_data);
+       if (ret)
+               return ret;
 
        rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
                                                     -1, NULL, 0);