From 825d8ab82cb32d2dbb4221de1e7bc2f6ef83c491 Mon Sep 17 00:00:00 2001
From: "Marty E. Plummer" <hanetzer@startmail.com>
Date: Wed, 19 Sep 2018 21:53:56 -0500
Subject: [PATCH] drm/panfrost: add job handling stubs

Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_device.c |  1 +
 drivers/gpu/drm/panfrost/panfrost_device.h |  3 ---
 drivers/gpu/drm/panfrost/panfrost_job.c    |  7 ++++++
 drivers/gpu/drm/panfrost/panfrost_job.h    | 13 +++++++++++
 drivers/gpu/drm/panfrost/panfrost_regs.h   | 26 ++++++++++++++++++++++
 5 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/panfrost/panfrost_job.h

diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
index 5ef7875727a63..1a93ebf8101f5 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.c
+++ b/drivers/gpu/drm/panfrost/panfrost_device.c
@@ -6,6 +6,7 @@
 
 #include "panfrost_device.h"
 #include "panfrost_gpu.h"
+#include "panfrost_job.h"
 #include "panfrost_mmu.h"
 
 struct panfrost_ip_desc {
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index 0cb05ba9ec2fe..cbbdac7d445bc 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -53,9 +53,6 @@ struct panfrost_device {
 int panfrost_device_init(struct panfrost_device *pfdev);
 void panfrost_device_fini(struct panfrost_device *pfdev);
 
-int panfrost_job_init(struct panfrost_ip *ip);
-void panfrost_job_fini(struct panfrost_ip *ip);
-
 const char *panfrost_ip_name(struct panfrost_ip *ip);
 
 #endif
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index 223273f6f90d7..a8247e2ee16b5 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -2,6 +2,13 @@
 /* Copyright 2018 Panfrost Team */
 
 #include "panfrost_device.h"
+#include "panfrost_job.h"
+#include "panfrost_regs.h"
+
+#define job_write(reg, data) writel(data, ip->iomem + PAN_JOB_##reg)
+#define job_read(reg) readl(ip->iomem + PAN_JOB_##reg)
+#define job_slot_write(js, reg, data) writel(data, ip->iomem + PAN_JOB_SLOT0 + ((js) << 7) + PAN_JS_##reg)
+#define job_slot_read(js, reg) readl(ip->iomem + PAN_JOB_SLOT0 + ((js) << 7) + PAN_JS_##reg)
 
 int panfrost_job_init(struct panfrost_ip *ip)
 {
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.h b/drivers/gpu/drm/panfrost/panfrost_job.h
new file mode 100644
index 0000000000000..58decd8fe6a34
--- /dev/null
+++ b/drivers/gpu/drm/panfrost/panfrost_job.h
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier:	GPL-2.0
+/* Copyright 2018 Panfrost Team */
+
+#ifndef __PANFROST_JOB_H__
+#define __PANFROST_JOB_H__
+
+struct panfrost_ip;
+struct panfrost_device;
+
+int panfrost_job_init(struct panfrost_ip *ip);
+void panfrost_job_fini(struct panfrost_ip *ip);
+
+#endif
diff --git a/drivers/gpu/drm/panfrost/panfrost_regs.h b/drivers/gpu/drm/panfrost/panfrost_regs.h
index 4c69c4fb4d593..6965277710075 100644
--- a/drivers/gpu/drm/panfrost/panfrost_regs.h
+++ b/drivers/gpu/drm/panfrost/panfrost_regs.h
@@ -40,6 +40,32 @@
 #define   PAN_GPU_CMD_SOFT_RESET		0x01
 #define PAN_GPU_STATUS				0x34
 
+/* Job Control regs */
+#define PAN_JOB_INT_RAWSTAT			0x000
+#define PAN_JOB_INT_CLEAR			0x004
+#define PAN_JOB_INT_MASK			0x008
+#define PAN_JOB_INT_STAT			0x00c
+#define PAN_JOB_JS_STATE			0x010
+#define PAN_JOB_INT_THROTTLE			0x014
+#define PAN_JOB_SLOT0				0x800
+#define   PAN_JS_HEAD_LO			0x000
+#define   PAN_JS_HEAD_HI			0x004
+#define   PAN_JS_TAIL_LO			0x008
+#define   PAN_JS_TAIL_HI			0x00c
+#define   PAN_JS_AFFINITY_LO			0x010
+#define   PAN_JS_AFFINITY_HI			0x014
+#define   PAN_JS_CONFIG				0x018
+#define   PAN_JS_XAFFINITY			0x01c
+#define   PAN_JS_COMMAND			0x020
+#define   PAN_JS_STATUS				0x024
+#define   PAN_JS_HEAD_NEXT_LO			0x040
+#define   PAN_JS_HEAD_NEXT_HI			0x044
+#define   PAN_JS_AFFINITY_NEXT_LO		0x050
+#define   PAN_JS_AFFINITY_NEXT_HI		0x054
+#define   PAN_JS_CONFIG_NEXT			0x058
+#define   PAN_JS_COMMAND_NEXT			0x060
+#define   PAN_JS_FLUSH_ID_NEXT			0x070
+
 /* MMU regs */
 #define PAN_MMU_INT_RAWSTAT			0x00
 #define PAN_MMU_INT_CLEAR			0x04
-- 
GitLab