Skip to content

Commit de20dba

Browse files
committed
drm/v3d: Switch clock setting to new api
Signed-off-by: Dom Cobley <[email protected]> drm/v3d: Convert to new clock range API Signed-off-by: Maxime Ripard <[email protected]>
1 parent 770dba8 commit de20dba

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/gpu/drm/v3d/v3d_drv.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
#include <linux/dma-mapping.h>
1818
#include <linux/io.h>
1919
#include <linux/module.h>
20+
#include <linux/of.h>
2021
#include <linux/of_platform.h>
2122
#include <linux/platform_device.h>
2223
#include <linux/sched/clock.h>
2324
#include <linux/reset.h>
2425

2526
#include <drm/drm_drv.h>
2627
#include <drm/drm_managed.h>
28+
29+
#include <soc/bcm2835/raspberrypi-firmware.h>
30+
2731
#include <uapi/drm/v3d_drm.h>
2832

2933
#include "v3d_drv.h"
@@ -273,6 +277,8 @@ map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
273277
static int v3d_platform_drm_probe(struct platform_device *pdev)
274278
{
275279
struct device *dev = &pdev->dev;
280+
struct rpi_firmware *firmware;
281+
struct device_node *node;
276282
struct drm_device *drm;
277283
struct v3d_dev *v3d;
278284
int ret;
@@ -337,7 +343,20 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
337343
dev_err(dev, "Failed to get clock (%ld)\n", PTR_ERR(v3d->clk));
338344
return PTR_ERR(v3d->clk);
339345
}
340-
v3d->clk_up_rate = clk_get_rate(v3d->clk);
346+
347+
node = rpi_firmware_find_node();
348+
if (!node)
349+
return -EINVAL;
350+
351+
firmware = rpi_firmware_get(node);
352+
of_node_put(node);
353+
if (!firmware)
354+
return -EPROBE_DEFER;
355+
356+
v3d->clk_up_rate = rpi_firmware_clk_get_max_rate(firmware,
357+
RPI_FIRMWARE_V3D_CLK_ID);
358+
rpi_firmware_put(firmware);
359+
341360
/* For downclocking, drop it to the minimum frequency we can get from
342361
* the CPRMAN clock generator dividing off our parent. The divider is
343362
* 4 bits, but ask for just higher than that so that rounding doesn't
@@ -374,7 +393,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
374393
ret = v3d_sysfs_init(dev);
375394
if (ret)
376395
goto drm_unregister;
377-
ret = clk_set_rate(v3d->clk, v3d->clk_down_rate);
396+
ret = clk_set_min_rate(v3d->clk, v3d->clk_down_rate);
378397
WARN_ON_ONCE(ret != 0);
379398

380399
return 0;

0 commit comments

Comments
 (0)