Skip to content

Commit

Permalink
drm/v3d: Switch clock setting to new api
Browse files Browse the repository at this point in the history
Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/v3d: Convert to new clock range API

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
  • Loading branch information
popcornmix committed Dec 16, 2024
1 parent 30fca65 commit 89cd0a4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions drivers/gpu/drm/v3d/v3d_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/sched/clock.h>
#include <linux/reset.h>

#include <drm/drm_drv.h>
#include <drm/drm_managed.h>

#include <soc/bcm2835/raspberrypi-firmware.h>

#include <uapi/drm/v3d_drm.h>

#include "v3d_drv.h"
Expand Down Expand Up @@ -263,6 +267,8 @@ map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
static int v3d_platform_drm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rpi_firmware *firmware;
struct device_node *node;
struct drm_device *drm;
struct v3d_dev *v3d;
int ret;
Expand Down Expand Up @@ -327,7 +333,20 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
dev_err(dev, "Failed to get clock (%ld)\n", PTR_ERR(v3d->clk));
return PTR_ERR(v3d->clk);
}
v3d->clk_up_rate = clk_get_rate(v3d->clk);

node = rpi_firmware_find_node();
if (!node)
return -EINVAL;

firmware = rpi_firmware_get(node);
of_node_put(node);
if (!firmware)
return -EPROBE_DEFER;

v3d->clk_up_rate = rpi_firmware_clk_get_max_rate(firmware,
RPI_FIRMWARE_V3D_CLK_ID);
rpi_firmware_put(firmware);

/* For downclocking, drop it to the minimum frequency we can get from
* the CPRMAN clock generator dividing off our parent. The divider is
* 4 bits, but ask for just higher than that so that rounding doesn't
Expand Down Expand Up @@ -364,7 +383,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
ret = v3d_sysfs_init(dev);
if (ret)
goto drm_unregister;
ret = clk_set_rate(v3d->clk, v3d->clk_down_rate);
ret = clk_set_min_rate(v3d->clk, v3d->clk_down_rate);
WARN_ON_ONCE(ret != 0);

return 0;
Expand Down

0 comments on commit 89cd0a4

Please sign in to comment.