Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ properties:
# work with newer dts.
- const: img,img-axe
- const: img,img-rogue
- items:
- enum:
- thead,th1520-gpu
- const: img,img-bxm-4-64
- const: img,img-rogue
- items:
- enum:
- ti,j721s2-gpu
Expand Down Expand Up @@ -77,14 +82,18 @@ required:
additionalProperties: false

allOf:
# Constraints added alongside the new compatible strings that would otherwise
# create an ABI break.
- if:
properties:
compatible:
contains:
const: img,img-rogue
const: img,img-axe-1-16m
then:
properties:
power-domains:
items:
- description: Power domain A
power-domain-names:
maxItems: 1
required:
- power-domains
- power-domain-names
Expand All @@ -93,13 +102,20 @@ allOf:
properties:
compatible:
contains:
const: img,img-axe-1-16m
const: thead,th1520-gpu
then:
properties:
clocks:
minItems: 3
clock-names:
minItems: 3
power-domains:
maxItems: 1
power-domain-names:
maxItems: 1
items:
- description: The single, unified power domain for the GPU on the
TH1520 SoC, integrating all internal IP power domains.
power-domain-names: false
required:
- power-domains

- if:
properties:
Expand All @@ -109,9 +125,14 @@ allOf:
then:
properties:
power-domains:
minItems: 2
items:
- description: Power domain A
- description: Power domain B
power-domain-names:
minItems: 2
required:
- power-domains
- power-domain-names

- if:
properties:
Expand Down
21 changes: 21 additions & 0 deletions arch/riscv/boot/dts/thead/th1520.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@
#clock-cells = <0>;
};

gpu_mem_clk: mem-clk {
compatible = "fixed-clock";
clock-frequency = <0>;
clock-output-names = "gpu_mem_clk";
#clock-cells = <0>;
};

stmmac_axi_config: stmmac-axi-config {
snps,wr_osr_lmt = <15>;
snps,rd_osr_lmt = <15>;
Expand Down Expand Up @@ -500,6 +507,20 @@
#clock-cells = <1>;
};

gpu: gpu@ffef400000 {
compatible = "thead,th1520-gpu", "img,img-bxm-4-64",
"img,img-rogue";
reg = <0xff 0xef400000 0x0 0x100000>;
interrupt-parent = <&plic>;
interrupts = <102 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk_vo CLK_GPU_CORE>,
<&gpu_mem_clk>,
<&clk_vo CLK_GPU_CFG_ACLK>;
clock-names = "core", "mem", "sys";
power-domains = <&aon TH1520_GPU_PD>;
resets = <&rst TH1520_RESET_ID_GPU>;
};

rst: reset-controller@ffef528000 {
compatible = "thead,th1520-reset";
reg = <0xff 0xef528000 0x0 0x4f>;
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/imagination/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

config DRM_POWERVR
tristate "Imagination Technologies PowerVR (Series 6 and later) & IMG Graphics"
depends on ARM64
depends on (ARM64 || RISCV && 64BIT)
depends on DRM
depends on MMU
depends on PM
select DRM_EXEC
select DRM_GEM_SHMEM_HELPER
Expand Down
22 changes: 5 additions & 17 deletions drivers/gpu/drm/imagination/pvr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/firmware.h>
#include <linux/gfp.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
Expand Down Expand Up @@ -121,21 +122,6 @@ static int pvr_device_clk_init(struct pvr_device *pvr_dev)
return 0;
}

static int pvr_device_reset_init(struct pvr_device *pvr_dev)
{
struct drm_device *drm_dev = from_pvr_device(pvr_dev);
struct reset_control *reset;

reset = devm_reset_control_get_optional_exclusive(drm_dev->dev, NULL);
if (IS_ERR(reset))
return dev_err_probe(drm_dev->dev, PTR_ERR(reset),
"failed to get gpu reset line\n");

pvr_dev->reset = reset;

return 0;
}

/**
* pvr_device_process_active_queues() - Process all queue related events.
* @pvr_dev: PowerVR device to check
Expand Down Expand Up @@ -618,6 +604,9 @@ pvr_device_init(struct pvr_device *pvr_dev)
struct device *dev = drm_dev->dev;
int err;

/* Get the platform-specific data based on the compatible string. */
pvr_dev->device_data = of_device_get_match_data(dev);

/*
* Setup device parameters. We do this first in case other steps
* depend on them.
Expand All @@ -631,8 +620,7 @@ pvr_device_init(struct pvr_device *pvr_dev)
if (err)
return err;

/* Get the reset line for the GPU */
err = pvr_device_reset_init(pvr_dev);
err = pvr_dev->device_data->pwr_ops->init(pvr_dev);
if (err)
return err;

Expand Down
17 changes: 17 additions & 0 deletions drivers/gpu/drm/imagination/pvr_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ struct clk;
/* Forward declaration from <linux/firmware.h>. */
struct firmware;

/* Forward declaration from <linux/pwrseq/consumer.h> */
struct pwrseq_desc;

/**
* struct pvr_gpu_id - Hardware GPU ID information for a PowerVR device
* @b: Branch ID.
Expand All @@ -57,6 +60,14 @@ struct pvr_fw_version {
u16 major, minor;
};

/**
* struct pvr_device_data - Platform specific data associated with a compatible string.
* @pwr_ops: Pointer to a structure with platform-specific power functions.
*/
struct pvr_device_data {
const struct pvr_power_sequence_ops *pwr_ops;
};

/**
* struct pvr_device - powervr-specific wrapper for &struct drm_device
*/
Expand Down Expand Up @@ -98,6 +109,9 @@ struct pvr_device {
/** @fw_version: Firmware version detected at runtime. */
struct pvr_fw_version fw_version;

/** @device_data: Pointer to platform-specific data. */
const struct pvr_device_data *device_data;

/** @regs_resource: Resource representing device control registers. */
struct resource *regs_resource;

Expand Down Expand Up @@ -148,6 +162,9 @@ struct pvr_device {
*/
struct reset_control *reset;

/** @pwrseq: Pointer to a power sequencer, if one is used. */
struct pwrseq_desc *pwrseq;

/** @irq: IRQ number. */
int irq;

Expand Down
23 changes: 21 additions & 2 deletions drivers/gpu/drm/imagination/pvr_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,15 +1480,33 @@ static void pvr_remove(struct platform_device *plat_dev)
pvr_power_domains_fini(pvr_dev);
}

static const struct pvr_device_data pvr_device_data_manual = {
.pwr_ops = &pvr_power_sequence_ops_manual,
};

static const struct pvr_device_data pvr_device_data_pwrseq = {
.pwr_ops = &pvr_power_sequence_ops_pwrseq,
};

static const struct of_device_id dt_match[] = {
{ .compatible = "img,img-rogue", .data = NULL },
{
.compatible = "thead,th1520-gpu",
.data = &pvr_device_data_pwrseq,
},
{
.compatible = "img,img-rogue",
.data = &pvr_device_data_manual,
},

/*
* This legacy compatible string was introduced early on before the more generic
* "img,img-rogue" was added. Keep it around here for compatibility, but never use
* "img,img-axe" in new devicetrees.
*/
{ .compatible = "img,img-axe", .data = NULL },
{
.compatible = "img,img-axe",
.data = &pvr_device_data_manual,
},
{}
};
MODULE_DEVICE_TABLE(of, dt_match);
Expand All @@ -1513,4 +1531,5 @@ MODULE_DESCRIPTION(PVR_DRIVER_DESC);
MODULE_LICENSE("Dual MIT/GPL");
MODULE_IMPORT_NS("DMA_BUF");
MODULE_FIRMWARE("powervr/rogue_33.15.11.3_v1.fw");
MODULE_FIRMWARE("powervr/rogue_36.52.104.182_v1.fw");
MODULE_FIRMWARE("powervr/rogue_36.53.104.796_v1.fw");
Loading
Loading