Skip to content

Commit 5190914

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 7570e08 commit 5190914

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"
@@ -263,6 +267,8 @@ map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
263267
static int v3d_platform_drm_probe(struct platform_device *pdev)
264268
{
265269
struct device *dev = &pdev->dev;
270+
struct rpi_firmware *firmware;
271+
struct device_node *node;
266272
struct drm_device *drm;
267273
struct v3d_dev *v3d;
268274
int ret;
@@ -327,7 +333,20 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
327333
dev_err(dev, "Failed to get clock (%ld)\n", PTR_ERR(v3d->clk));
328334
return PTR_ERR(v3d->clk);
329335
}
330-
v3d->clk_up_rate = clk_get_rate(v3d->clk);
336+
337+
node = rpi_firmware_find_node();
338+
if (!node)
339+
return -EINVAL;
340+
341+
firmware = rpi_firmware_get(node);
342+
of_node_put(node);
343+
if (!firmware)
344+
return -EPROBE_DEFER;
345+
346+
v3d->clk_up_rate = rpi_firmware_clk_get_max_rate(firmware,
347+
RPI_FIRMWARE_V3D_CLK_ID);
348+
rpi_firmware_put(firmware);
349+
331350
/* For downclocking, drop it to the minimum frequency we can get from
332351
* the CPRMAN clock generator dividing off our parent. The divider is
333352
* 4 bits, but ask for just higher than that so that rounding doesn't
@@ -364,7 +383,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
364383
ret = v3d_sysfs_init(dev);
365384
if (ret)
366385
goto drm_unregister;
367-
ret = clk_set_rate(v3d->clk, v3d->clk_down_rate);
386+
ret = clk_set_min_rate(v3d->clk, v3d->clk_down_rate);
368387
WARN_ON_ONCE(ret != 0);
369388

370389
return 0;

0 commit comments

Comments
 (0)