Skip to content

Commit 99652db

Browse files
mripardpopcornmix
authored andcommitted
clk: bcm: rpi: Add DT provider for the clocks
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 Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent 7b6aea3 commit 99652db

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎drivers/clk/bcm/clk-raspberrypi.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#define A2W_PLL_FRAC_BITS 20
3333

34+
#define NUM_FW_CLKS 16
35+
3436
struct raspberrypi_clk {
3537
struct device *dev;
3638
struct rpi_firmware *firmware;
@@ -285,11 +287,13 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
285287

286288
static int raspberrypi_clk_probe(struct platform_device *pdev)
287289
{
290+
struct clk_hw_onecell_data *clk_data;
288291
struct device_node *firmware_node;
289292
struct device *dev = &pdev->dev;
290293
struct rpi_firmware *firmware;
291294
struct raspberrypi_clk *rpi;
292295
struct clk_hw *hw;
296+
int ret;
293297

294298
firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware", 0);
295299
if (!firmware_node) {
@@ -309,6 +313,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
309313
rpi->firmware = firmware;
310314
platform_set_drvdata(pdev, rpi);
311315

316+
clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, NUM_FW_CLKS),
317+
GFP_KERNEL);
318+
if (!clk_data)
319+
return -ENOMEM;
320+
312321
hw = raspberrypi_register_pllb(rpi);
313322
if (IS_ERR(hw)) {
314323
dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
@@ -318,6 +327,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
318327
hw = raspberrypi_register_pllb_arm(rpi);
319328
if (IS_ERR(hw))
320329
return PTR_ERR(hw);
330+
clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID] = hw;
331+
clk_data->num = RPI_FIRMWARE_ARM_CLK_ID + 1;
332+
333+
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
334+
clk_data);
335+
if (ret)
336+
return ret;
321337

322338
rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
323339
-1, NULL, 0);

0 commit comments

Comments
 (0)