Skip to content
Merged
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
30 changes: 30 additions & 0 deletions Documentation/devicetree/bindings/arm/mediatek/mediatek,g3dsys.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
MediaTek g3dsys controller
============================

The MediaTek g3dsys controller provides various clocks and reset controller to
the GPU.

Required Properties:

- compatible: Should be:
- "mediatek,mt2701-g3dsys", "syscon":
for MT2701 SoC
- "mediatek,mt7623-g3dsys", "mediatek,mt2701-g3dsys", "syscon":
for MT7623 SoC
- #clock-cells: Must be 1
- #reset-cells: Must be 1

The g3dsys controller uses the common clk binding from
Documentation/devicetree/bindings/clock/clock-bindings.txt
The available clocks are defined in dt-bindings/clock/mt*-clk.h.

Example:

g3dsys: clock-controller@13000000 {
compatible = "mediatek,mt7623-g3dsys",
"mediatek,mt2701-g3dsys",
"syscon";
reg = <0 0x13000000 0 0x200>;
#clock-cells = <1>;
#reset-cells = <1>;
};
9 changes: 9 additions & 0 deletions Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Required properties:
+ rockchip,rk3228-mali
+ rockchip,rk3328-mali
+ stericsson,db8500-mali
+ mediatek,mt7623-mali

- reg: Physical base address and length of the GPU registers

Expand Down Expand Up @@ -85,6 +86,14 @@ to specify one more vendor-specific compatible, among:
* interrupt-names and interrupts:
+ combined: combined interrupt of all of the above lines

- mediatek,mt7623-mali
Required properties:
* resets: phandle to the reset line for the GPU
* mediatek,larb: phandle pointed to the local arbiter used to control the
access to external memory on the SoC.
see Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
for details

Example:

mali: gpu@1c40000 {
Expand Down
48 changes: 48 additions & 0 deletions arch/arm/boot/dts/mt7623.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,54 @@
power-domains = <&scpsys MT2701_POWER_DOMAIN_VDEC>;
};

g3dsys: clock-controller@13000000 {
compatible = "mediatek,mt7623-g3dsys",
"mediatek,mt2701-g3dsys",
"syscon";
reg = <0 0x13000000 0 0x200>;
#clock-cells = <1>;
#reset-cells = <1>;
};

larb3: larb@13010000 {
compatible = "mediatek,mt7623-smi-larb",
"mediatek,mt2701-smi-larb";
reg = <0 0x13010000 0 0x1000>;
mediatek,smi = <&smi_common>;
mediatek,larb-id = <3>;
clocks = <&clk26m>, <&clk26m>;
clock-names = "apb", "smi";
power-domains = <&scpsys MT2701_POWER_DOMAIN_MFG>;
};

mali: gpu@13040000 {
compatible = "mediatek,mt7623-mali", "arm,mali-450";
reg = <0 0x13040000 0 0x30000>;
interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 171 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 172 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 173 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 174 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 175 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 176 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 177 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 180 IRQ_TYPE_LEVEL_LOW>;
interrupt-names = "gp", "gpmmu", "pp0", "ppmmu0", "pp1",
"ppmmu1", "pp2", "ppmmu2", "pp";
clocks = <&topckgen CLK_TOP_MMPLL>,
<&g3dsys CLK_G3DSYS_CORE>;
clock-names = "bus", "core";
power-domains = <&scpsys MT2701_POWER_DOMAIN_MFG>;
mediatek,larb = <&larb3>;
resets = <&g3dsys MT2701_G3DSYS_CORE_RST>;
};

mmsys: syscon@14000000 {
compatible = "mediatek,mt2701-mmsys", "syscon";
reg = <0 0x14000000 0 0x1000>;
#clock-cells = <1>;
};

hifsys: syscon@1a000000 {
compatible = "mediatek,mt7623-hifsys",
"mediatek,mt2701-hifsys",
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/mt7623n_evb_fwu_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ CONFIG_DRM_ARM=y
CONFIG_DRM_MALI_DISPLAY=y
CONFIG_DRM_MEDIATEK=y
CONFIG_DRM_MEDIATEK_HDMI=y
CONFIG_DRM_LIMA=y
CONFIG_COMMON_CLK_MT2701_MMSYS=y
CONFIG_COMMON_CLK_MT2701_IMGSYS=y
CONFIG_COMMON_CLK_MT2701_VDECSYS=y
Expand Down
6 changes: 6 additions & 0 deletions drivers/clk/mediatek/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ config COMMON_CLK_MT2701_BDPSYS
---help---
This driver supports MediaTek MT2701 bdpsys clocks.

config COMMON_CLK_MT2701_G3DSYS
bool "Clock driver for MediaTek MT2701 g3dsys"
depends on COMMON_CLK_MT2701
---help---
This driver supports MediaTek MT2701 g3dsys clocks.

config COMMON_CLK_MT2712
bool "Clock driver for MediaTek MT2712"
depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
Expand Down
1 change: 1 addition & 0 deletions drivers/clk/mediatek/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ obj-$(CONFIG_COMMON_CLK_MT6797_VENCSYS) += clk-mt6797-venc.o
obj-$(CONFIG_COMMON_CLK_MT2701) += clk-mt2701.o
obj-$(CONFIG_COMMON_CLK_MT2701_BDPSYS) += clk-mt2701-bdp.o
obj-$(CONFIG_COMMON_CLK_MT2701_ETHSYS) += clk-mt2701-eth.o
obj-$(CONFIG_COMMON_CLK_MT2701_G3DSYS) += clk-mt2701-g3d.o
obj-$(CONFIG_COMMON_CLK_MT2701_HIFSYS) += clk-mt2701-hif.o
obj-$(CONFIG_COMMON_CLK_MT2701_IMGSYS) += clk-mt2701-img.o
obj-$(CONFIG_COMMON_CLK_MT2701_MMSYS) += clk-mt2701-mm.o
Expand Down
95 changes: 95 additions & 0 deletions drivers/clk/mediatek/clk-mt2701-g3d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2018 MediaTek Inc.
* Author: Sean Wang <sean.wang@mediatek.com>
*
*/

#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>

#include "clk-mtk.h"
#include "clk-gate.h"

#include <dt-bindings/clock/mt2701-clk.h>

#define GATE_G3D(_id, _name, _parent, _shift) { \
.id = _id, \
.name = _name, \
.parent_name = _parent, \
.regs = &g3d_cg_regs, \
.shift = _shift, \
.ops = &mtk_clk_gate_ops_setclr, \
}

static const struct mtk_gate_regs g3d_cg_regs = {
.sta_ofs = 0x0,
.set_ofs = 0x4,
.clr_ofs = 0x8,
};

static const struct mtk_gate g3d_clks[] = {
GATE_G3D(CLK_G3DSYS_CORE, "g3d_core", "mfg_sel", 0),
};

static int clk_mt2701_g3dsys_init(struct platform_device *pdev)
{
struct clk_onecell_data *clk_data;
struct device_node *node = pdev->dev.of_node;
int r;

clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);

mtk_clk_register_gates(node, g3d_clks, ARRAY_SIZE(g3d_clks),
clk_data);

r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
if (r)
dev_err(&pdev->dev,
"could not register clock provider: %s: %d\n",
pdev->name, r);

mtk_register_reset_controller(node, 1, 0xc);

return r;
}

static const struct of_device_id of_match_clk_mt2701_g3d[] = {
{
.compatible = "mediatek,mt2701-g3dsys",
.data = clk_mt2701_g3dsys_init,
}, {
/* sentinel */
}
};

static int clk_mt2701_g3d_probe(struct platform_device *pdev)
{
int (*clk_init)(struct platform_device *);
int r;

clk_init = of_device_get_match_data(&pdev->dev);
if (!clk_init)
return -EINVAL;

r = clk_init(pdev);
if (r)
dev_err(&pdev->dev,
"could not register clock provider: %s: %d\n",
pdev->name, r);

return r;
}

static struct platform_driver clk_mt2701_g3d_drv = {
.probe = clk_mt2701_g3d_probe,
.driver = {
.name = "clk-mt2701-g3d",
.of_match_table = of_match_clk_mt2701_g3d,
},
};

builtin_platform_driver(clk_mt2701_g3d_drv);
2 changes: 2 additions & 0 deletions drivers/gpu/drm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ source "drivers/gpu/drm/pl111/Kconfig"

source "drivers/gpu/drm/tve200/Kconfig"

source "drivers/gpu/drm/lima/Kconfig"

# Keep legacy drivers last

menuconfig DRM_LEGACY
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ obj-$(CONFIG_DRM_MXSFB) += mxsfb/
obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
obj-$(CONFIG_DRM_PL111) += pl111/
obj-$(CONFIG_DRM_TVE200) += tve200/
obj-$(CONFIG_DRM_LIMA) += lima/
11 changes: 11 additions & 0 deletions drivers/gpu/drm/lima/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: GPL-2.0 OR MIT
# Copyright 2017-2018 Qiang Yu <yuq825@gmail.com>

config DRM_LIMA
tristate "LIMA (DRM support for ARM Mali 400/450 GPU)"
depends on DRM
depends on ARM || ARM64 || COMPILE_TEST
select DRM_SCHED
select DRM_TTM
help
DRM driver for ARM Mali 400/450 GPUs.
22 changes: 22 additions & 0 deletions drivers/gpu/drm/lima/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: GPL-2.0 OR MIT
# Copyright 2017-2018 Qiang Yu <yuq825@gmail.com>

lima-y := \
lima_drv.o \
lima_device.o \
lima_pmu.o \
lima_l2_cache.o \
lima_mmu.o \
lima_gp.o \
lima_pp.o \
lima_gem.o \
lima_vm.o \
lima_sched.o \
lima_ctx.o \
lima_gem_prime.o \
lima_dlbu.o \
lima_bcast.o \
lima_ttm.o \
lima_object.o

obj-$(CONFIG_DRM_LIMA) += lima.o
46 changes: 46 additions & 0 deletions drivers/gpu/drm/lima/lima_bcast.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-2.0 OR MIT
/* Copyright 2018 Qiang Yu <yuq825@gmail.com> */

#include <linux/io.h>
#include <linux/device.h>

#include "lima_device.h"
#include "lima_bcast.h"
#include "lima_regs.h"

#define bcast_write(reg, data) writel(data, ip->iomem + LIMA_BCAST_##reg)
#define bcast_read(reg) readl(ip->iomem + LIMA_BCAST_##reg)

void lima_bcast_enable(struct lima_device *dev)
{
struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp;
struct lima_ip *ip = dev->ip + lima_ip_bcast;
int i, mask = 0;

for (i = 0; i < pipe->num_processor; i++) {
struct lima_ip *pp = pipe->processor[i];
mask |= 1 << (pp->id - lima_ip_pp0);
}

bcast_write(BROADCAST_MASK, (mask << 16) | mask);
bcast_write(INTERRUPT_MASK, mask);
}

void lima_bcast_disable(struct lima_device *dev)
{
struct lima_ip *ip = dev->ip + lima_ip_bcast;

bcast_write(BROADCAST_MASK, 0);
bcast_write(INTERRUPT_MASK, 0);
}

int lima_bcast_init(struct lima_ip *ip)
{
return 0;
}

void lima_bcast_fini(struct lima_ip *ip)
{

}

15 changes: 15 additions & 0 deletions drivers/gpu/drm/lima/lima_bcast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/* Copyright 2018 Qiang Yu <yuq825@gmail.com> */

#ifndef __LIMA_BCAST_H__
#define __LIMA_BCAST_H__

struct lima_ip;

int lima_bcast_init(struct lima_ip *ip);
void lima_bcast_fini(struct lima_ip *ip);

void lima_bcast_enable(struct lima_device *dev);
void lima_bcast_disable(struct lima_device *dev);

#endif
Loading