18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
38c2ecf20Sopenharmony_ci/* Copyright 2019 Linaro, Ltd, Rob Herring <robh@kernel.org> */
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * Register definitions based on mali_midg_regmap.h
68c2ecf20Sopenharmony_ci * (C) COPYRIGHT 2010-2018 ARM Limited. All rights reserved.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef __PANFROST_REGS_H__
98c2ecf20Sopenharmony_ci#define __PANFROST_REGS_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define GPU_ID				0x00
128c2ecf20Sopenharmony_ci#define GPU_L2_FEATURES			0x004	/* (RO) Level 2 cache features */
138c2ecf20Sopenharmony_ci#define GPU_CORE_FEATURES		0x008	/* (RO) Shader Core Features */
148c2ecf20Sopenharmony_ci#define GPU_TILER_FEATURES		0x00C	/* (RO) Tiler Features */
158c2ecf20Sopenharmony_ci#define GPU_MEM_FEATURES		0x010	/* (RO) Memory system features */
168c2ecf20Sopenharmony_ci#define   GROUPS_L2_COHERENT		BIT(0)	/* Cores groups are l2 coherent */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define GPU_MMU_FEATURES		0x014	/* (RO) MMU features */
198c2ecf20Sopenharmony_ci#define GPU_AS_PRESENT			0x018	/* (RO) Address space slots present */
208c2ecf20Sopenharmony_ci#define GPU_JS_PRESENT			0x01C	/* (RO) Job slots present */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define GPU_INT_RAWSTAT			0x20
238c2ecf20Sopenharmony_ci#define GPU_INT_CLEAR			0x24
248c2ecf20Sopenharmony_ci#define GPU_INT_MASK			0x28
258c2ecf20Sopenharmony_ci#define GPU_INT_STAT			0x2c
268c2ecf20Sopenharmony_ci#define   GPU_IRQ_FAULT			BIT(0)
278c2ecf20Sopenharmony_ci#define   GPU_IRQ_MULTIPLE_FAULT	BIT(7)
288c2ecf20Sopenharmony_ci#define   GPU_IRQ_RESET_COMPLETED	BIT(8)
298c2ecf20Sopenharmony_ci#define   GPU_IRQ_POWER_CHANGED		BIT(9)
308c2ecf20Sopenharmony_ci#define   GPU_IRQ_POWER_CHANGED_ALL	BIT(10)
318c2ecf20Sopenharmony_ci#define   GPU_IRQ_PERFCNT_SAMPLE_COMPLETED BIT(16)
328c2ecf20Sopenharmony_ci#define   GPU_IRQ_CLEAN_CACHES_COMPLETED BIT(17)
338c2ecf20Sopenharmony_ci#define   GPU_IRQ_MASK_ALL			 \
348c2ecf20Sopenharmony_ci	  (GPU_IRQ_FAULT			|\
358c2ecf20Sopenharmony_ci	   GPU_IRQ_MULTIPLE_FAULT		|\
368c2ecf20Sopenharmony_ci	   GPU_IRQ_RESET_COMPLETED		|\
378c2ecf20Sopenharmony_ci	   GPU_IRQ_POWER_CHANGED		|\
388c2ecf20Sopenharmony_ci	   GPU_IRQ_POWER_CHANGED_ALL		|\
398c2ecf20Sopenharmony_ci	   GPU_IRQ_PERFCNT_SAMPLE_COMPLETED	|\
408c2ecf20Sopenharmony_ci	   GPU_IRQ_CLEAN_CACHES_COMPLETED)
418c2ecf20Sopenharmony_ci#define GPU_IRQ_MASK_ERROR	   		\
428c2ecf20Sopenharmony_ci	(					\
438c2ecf20Sopenharmony_ci	 GPU_IRQ_FAULT				|\
448c2ecf20Sopenharmony_ci	 GPU_IRQ_MULTIPLE_FAULT)
458c2ecf20Sopenharmony_ci#define GPU_CMD				0x30
468c2ecf20Sopenharmony_ci#define   GPU_CMD_SOFT_RESET		0x01
478c2ecf20Sopenharmony_ci#define   GPU_CMD_PERFCNT_CLEAR		0x03
488c2ecf20Sopenharmony_ci#define   GPU_CMD_PERFCNT_SAMPLE	0x04
498c2ecf20Sopenharmony_ci#define   GPU_CMD_CLEAN_CACHES		0x07
508c2ecf20Sopenharmony_ci#define   GPU_CMD_CLEAN_INV_CACHES	0x08
518c2ecf20Sopenharmony_ci#define GPU_STATUS			0x34
528c2ecf20Sopenharmony_ci#define   GPU_STATUS_PRFCNT_ACTIVE	BIT(2)
538c2ecf20Sopenharmony_ci#define GPU_LATEST_FLUSH_ID		0x38
548c2ecf20Sopenharmony_ci#define GPU_PWR_KEY			0x50	/* (WO) Power manager key register */
558c2ecf20Sopenharmony_ci#define  GPU_PWR_KEY_UNLOCK		0x2968A819
568c2ecf20Sopenharmony_ci#define GPU_PWR_OVERRIDE0		0x54	/* (RW) Power manager override settings */
578c2ecf20Sopenharmony_ci#define GPU_PWR_OVERRIDE1		0x58	/* (RW) Power manager override settings */
588c2ecf20Sopenharmony_ci#define GPU_FAULT_STATUS		0x3C
598c2ecf20Sopenharmony_ci#define GPU_FAULT_ADDRESS_LO		0x40
608c2ecf20Sopenharmony_ci#define GPU_FAULT_ADDRESS_HI		0x44
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define GPU_PERFCNT_BASE_LO		0x60
638c2ecf20Sopenharmony_ci#define GPU_PERFCNT_BASE_HI		0x64
648c2ecf20Sopenharmony_ci#define GPU_PERFCNT_CFG			0x68
658c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_MODE(x)	(x)
668c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_MODE_OFF	0
678c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_MODE_MANUAL	1
688c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_MODE_TILE	2
698c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_AS(x)		((x) << 4)
708c2ecf20Sopenharmony_ci#define   GPU_PERFCNT_CFG_SETSEL(x)	((x) << 8)
718c2ecf20Sopenharmony_ci#define GPU_PRFCNT_JM_EN		0x6c
728c2ecf20Sopenharmony_ci#define GPU_PRFCNT_SHADER_EN		0x70
738c2ecf20Sopenharmony_ci#define GPU_PRFCNT_TILER_EN		0x74
748c2ecf20Sopenharmony_ci#define GPU_PRFCNT_MMU_L2_EN		0x7c
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define GPU_THREAD_MAX_THREADS		0x0A0	/* (RO) Maximum number of threads per core */
778c2ecf20Sopenharmony_ci#define GPU_THREAD_MAX_WORKGROUP_SIZE	0x0A4	/* (RO) Maximum workgroup size */
788c2ecf20Sopenharmony_ci#define GPU_THREAD_MAX_BARRIER_SIZE	0x0A8	/* (RO) Maximum threads waiting at a barrier */
798c2ecf20Sopenharmony_ci#define GPU_THREAD_FEATURES		0x0AC	/* (RO) Thread features */
808c2ecf20Sopenharmony_ci#define GPU_THREAD_TLS_ALLOC		0x310   /* (RO) Number of threads per core that
818c2ecf20Sopenharmony_ci						 * TLS must be allocated for */
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define GPU_TEXTURE_FEATURES(n)		(0x0B0 + ((n) * 4))
848c2ecf20Sopenharmony_ci#define GPU_JS_FEATURES(n)		(0x0C0 + ((n) * 4))
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define GPU_SHADER_PRESENT_LO		0x100	/* (RO) Shader core present bitmap, low word */
878c2ecf20Sopenharmony_ci#define GPU_SHADER_PRESENT_HI		0x104	/* (RO) Shader core present bitmap, high word */
888c2ecf20Sopenharmony_ci#define GPU_TILER_PRESENT_LO		0x110	/* (RO) Tiler core present bitmap, low word */
898c2ecf20Sopenharmony_ci#define GPU_TILER_PRESENT_HI		0x114	/* (RO) Tiler core present bitmap, high word */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define GPU_L2_PRESENT_LO		0x120	/* (RO) Level 2 cache present bitmap, low word */
928c2ecf20Sopenharmony_ci#define GPU_L2_PRESENT_HI		0x124	/* (RO) Level 2 cache present bitmap, high word */
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define GPU_COHERENCY_FEATURES		0x300	/* (RO) Coherency features present */
958c2ecf20Sopenharmony_ci#define   COHERENCY_ACE_LITE		BIT(0)
968c2ecf20Sopenharmony_ci#define   COHERENCY_ACE			BIT(1)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define GPU_STACK_PRESENT_LO		0xE00   /* (RO) Core stack present bitmap, low word */
998c2ecf20Sopenharmony_ci#define GPU_STACK_PRESENT_HI		0xE04   /* (RO) Core stack present bitmap, high word */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define SHADER_READY_LO			0x140	/* (RO) Shader core ready bitmap, low word */
1028c2ecf20Sopenharmony_ci#define SHADER_READY_HI			0x144	/* (RO) Shader core ready bitmap, high word */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define TILER_READY_LO			0x150	/* (RO) Tiler core ready bitmap, low word */
1058c2ecf20Sopenharmony_ci#define TILER_READY_HI			0x154	/* (RO) Tiler core ready bitmap, high word */
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define L2_READY_LO			0x160	/* (RO) Level 2 cache ready bitmap, low word */
1088c2ecf20Sopenharmony_ci#define L2_READY_HI			0x164	/* (RO) Level 2 cache ready bitmap, high word */
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define STACK_READY_LO			0xE10   /* (RO) Core stack ready bitmap, low word */
1118c2ecf20Sopenharmony_ci#define STACK_READY_HI			0xE14   /* (RO) Core stack ready bitmap, high word */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define SHADER_PWRON_LO			0x180	/* (WO) Shader core power on bitmap, low word */
1158c2ecf20Sopenharmony_ci#define SHADER_PWRON_HI			0x184	/* (WO) Shader core power on bitmap, high word */
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define TILER_PWRON_LO			0x190	/* (WO) Tiler core power on bitmap, low word */
1188c2ecf20Sopenharmony_ci#define TILER_PWRON_HI			0x194	/* (WO) Tiler core power on bitmap, high word */
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define L2_PWRON_LO			0x1A0	/* (WO) Level 2 cache power on bitmap, low word */
1218c2ecf20Sopenharmony_ci#define L2_PWRON_HI			0x1A4	/* (WO) Level 2 cache power on bitmap, high word */
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#define STACK_PWRON_LO			0xE20   /* (RO) Core stack power on bitmap, low word */
1248c2ecf20Sopenharmony_ci#define STACK_PWRON_HI			0xE24   /* (RO) Core stack power on bitmap, high word */
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define SHADER_PWROFF_LO		0x1C0	/* (WO) Shader core power off bitmap, low word */
1288c2ecf20Sopenharmony_ci#define SHADER_PWROFF_HI		0x1C4	/* (WO) Shader core power off bitmap, high word */
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define TILER_PWROFF_LO			0x1D0	/* (WO) Tiler core power off bitmap, low word */
1318c2ecf20Sopenharmony_ci#define TILER_PWROFF_HI			0x1D4	/* (WO) Tiler core power off bitmap, high word */
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define L2_PWROFF_LO			0x1E0	/* (WO) Level 2 cache power off bitmap, low word */
1348c2ecf20Sopenharmony_ci#define L2_PWROFF_HI			0x1E4	/* (WO) Level 2 cache power off bitmap, high word */
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define STACK_PWROFF_LO			0xE30   /* (RO) Core stack power off bitmap, low word */
1378c2ecf20Sopenharmony_ci#define STACK_PWROFF_HI			0xE34   /* (RO) Core stack power off bitmap, high word */
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define SHADER_PWRTRANS_LO		0x200	/* (RO) Shader core power transition bitmap, low word */
1418c2ecf20Sopenharmony_ci#define SHADER_PWRTRANS_HI		0x204	/* (RO) Shader core power transition bitmap, high word */
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define TILER_PWRTRANS_LO		0x210	/* (RO) Tiler core power transition bitmap, low word */
1448c2ecf20Sopenharmony_ci#define TILER_PWRTRANS_HI		0x214	/* (RO) Tiler core power transition bitmap, high word */
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#define L2_PWRTRANS_LO			0x220	/* (RO) Level 2 cache power transition bitmap, low word */
1478c2ecf20Sopenharmony_ci#define L2_PWRTRANS_HI			0x224	/* (RO) Level 2 cache power transition bitmap, high word */
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci#define STACK_PWRTRANS_LO		0xE40   /* (RO) Core stack power transition bitmap, low word */
1508c2ecf20Sopenharmony_ci#define STACK_PWRTRANS_HI		0xE44   /* (RO) Core stack power transition bitmap, high word */
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define SHADER_PWRACTIVE_LO		0x240	/* (RO) Shader core active bitmap, low word */
1548c2ecf20Sopenharmony_ci#define SHADER_PWRACTIVE_HI		0x244	/* (RO) Shader core active bitmap, high word */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define TILER_PWRACTIVE_LO		0x250	/* (RO) Tiler core active bitmap, low word */
1578c2ecf20Sopenharmony_ci#define TILER_PWRACTIVE_HI		0x254	/* (RO) Tiler core active bitmap, high word */
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define L2_PWRACTIVE_LO			0x260	/* (RO) Level 2 cache active bitmap, low word */
1608c2ecf20Sopenharmony_ci#define L2_PWRACTIVE_HI			0x264	/* (RO) Level 2 cache active bitmap, high word */
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define GPU_JM_CONFIG			0xF00   /* (RW) Job Manager configuration register (Implementation specific register) */
1638c2ecf20Sopenharmony_ci#define GPU_SHADER_CONFIG		0xF04	/* (RW) Shader core configuration settings (Implementation specific register) */
1648c2ecf20Sopenharmony_ci#define GPU_TILER_CONFIG		0xF08   /* (RW) Tiler core configuration settings (Implementation specific register) */
1658c2ecf20Sopenharmony_ci#define GPU_L2_MMU_CONFIG		0xF0C	/* (RW) Configuration of the L2 cache and MMU (Implementation specific register) */
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci/* L2_MMU_CONFIG register */
1688c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_ALLOW_SNOOP_DISPARITY_SHIFT	23
1698c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_ALLOW_SNOOP_DISPARITY		(0x1 << L2_MMU_CONFIG_ALLOW_SNOOP_DISPARITY_SHIFT)
1708c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT	24
1718c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS		(0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
1728c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_OCTANT	(0x1 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
1738c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_QUARTER	(0x2 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
1748c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_HALF		(0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT	26
1778c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES		(0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
1788c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_OCTANT	(0x1 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
1798c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_QUARTER	(0x2 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
1808c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_HALF	(0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_3BIT_LIMIT_EXTERNAL_READS_SHIFT	12
1838c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_3BIT_LIMIT_EXTERNAL_READS		(0x7 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_3BIT_LIMIT_EXTERNAL_WRITES_SHIFT	15
1868c2ecf20Sopenharmony_ci#define L2_MMU_CONFIG_3BIT_LIMIT_EXTERNAL_WRITES	(0x7 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* SHADER_CONFIG register */
1898c2ecf20Sopenharmony_ci#define SC_ALT_COUNTERS			BIT(3)
1908c2ecf20Sopenharmony_ci#define SC_OVERRIDE_FWD_PIXEL_KILL	BIT(4)
1918c2ecf20Sopenharmony_ci#define SC_SDC_DISABLE_OQ_DISCARD	BIT(6)
1928c2ecf20Sopenharmony_ci#define SC_LS_ALLOW_ATTR_TYPES		BIT(16)
1938c2ecf20Sopenharmony_ci#define SC_LS_PAUSEBUFFER_DISABLE	BIT(16)
1948c2ecf20Sopenharmony_ci#define SC_TLS_HASH_ENABLE		BIT(17)
1958c2ecf20Sopenharmony_ci#define SC_LS_ATTR_CHECK_DISABLE	BIT(18)
1968c2ecf20Sopenharmony_ci#define SC_ENABLE_TEXGRD_FLAGS		BIT(25)
1978c2ecf20Sopenharmony_ci/* End SHADER_CONFIG register */
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* TILER_CONFIG register */
2008c2ecf20Sopenharmony_ci#define TC_CLOCK_GATE_OVERRIDE		BIT(0)
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci/* JM_CONFIG register */
2038c2ecf20Sopenharmony_ci#define JM_TIMESTAMP_OVERRIDE		BIT(0)
2048c2ecf20Sopenharmony_ci#define JM_CLOCK_GATE_OVERRIDE		BIT(1)
2058c2ecf20Sopenharmony_ci#define JM_JOB_THROTTLE_ENABLE		BIT(2)
2068c2ecf20Sopenharmony_ci#define JM_JOB_THROTTLE_LIMIT_SHIFT	3
2078c2ecf20Sopenharmony_ci#define JM_MAX_JOB_THROTTLE_LIMIT	0x3F
2088c2ecf20Sopenharmony_ci#define JM_FORCE_COHERENCY_FEATURES_SHIFT 2
2098c2ecf20Sopenharmony_ci#define JM_IDVS_GROUP_SIZE_SHIFT	16
2108c2ecf20Sopenharmony_ci#define JM_MAX_IDVS_GROUP_SIZE		0x3F
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* Job Control regs */
2148c2ecf20Sopenharmony_ci#define JOB_INT_RAWSTAT			0x1000
2158c2ecf20Sopenharmony_ci#define JOB_INT_CLEAR			0x1004
2168c2ecf20Sopenharmony_ci#define JOB_INT_MASK			0x1008
2178c2ecf20Sopenharmony_ci#define JOB_INT_STAT			0x100c
2188c2ecf20Sopenharmony_ci#define JOB_INT_JS_STATE		0x1010
2198c2ecf20Sopenharmony_ci#define JOB_INT_THROTTLE		0x1014
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define MK_JS_MASK(j)			(0x10001 << (j))
2228c2ecf20Sopenharmony_ci#define JOB_INT_MASK_ERR(j)		BIT((j) + 16)
2238c2ecf20Sopenharmony_ci#define JOB_INT_MASK_DONE(j)		BIT(j)
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci#define JS_BASE				0x1800
2268c2ecf20Sopenharmony_ci#define JS_HEAD_LO(n)			(JS_BASE + ((n) * 0x80) + 0x00)
2278c2ecf20Sopenharmony_ci#define JS_HEAD_HI(n)			(JS_BASE + ((n) * 0x80) + 0x04)
2288c2ecf20Sopenharmony_ci#define JS_TAIL_LO(n)			(JS_BASE + ((n) * 0x80) + 0x08)
2298c2ecf20Sopenharmony_ci#define JS_TAIL_HI(n)			(JS_BASE + ((n) * 0x80) + 0x0c)
2308c2ecf20Sopenharmony_ci#define JS_AFFINITY_LO(n)		(JS_BASE + ((n) * 0x80) + 0x10)
2318c2ecf20Sopenharmony_ci#define JS_AFFINITY_HI(n)		(JS_BASE + ((n) * 0x80) + 0x14)
2328c2ecf20Sopenharmony_ci#define JS_CONFIG(n)			(JS_BASE + ((n) * 0x80) + 0x18)
2338c2ecf20Sopenharmony_ci#define JS_XAFFINITY(n)			(JS_BASE + ((n) * 0x80) + 0x1c)
2348c2ecf20Sopenharmony_ci#define JS_COMMAND(n)			(JS_BASE + ((n) * 0x80) + 0x20)
2358c2ecf20Sopenharmony_ci#define JS_STATUS(n)			(JS_BASE + ((n) * 0x80) + 0x24)
2368c2ecf20Sopenharmony_ci#define JS_HEAD_NEXT_LO(n)		(JS_BASE + ((n) * 0x80) + 0x40)
2378c2ecf20Sopenharmony_ci#define JS_HEAD_NEXT_HI(n)		(JS_BASE + ((n) * 0x80) + 0x44)
2388c2ecf20Sopenharmony_ci#define JS_AFFINITY_NEXT_LO(n)		(JS_BASE + ((n) * 0x80) + 0x50)
2398c2ecf20Sopenharmony_ci#define JS_AFFINITY_NEXT_HI(n)		(JS_BASE + ((n) * 0x80) + 0x54)
2408c2ecf20Sopenharmony_ci#define JS_CONFIG_NEXT(n)		(JS_BASE + ((n) * 0x80) + 0x58)
2418c2ecf20Sopenharmony_ci#define JS_COMMAND_NEXT(n)		(JS_BASE + ((n) * 0x80) + 0x60)
2428c2ecf20Sopenharmony_ci#define JS_FLUSH_ID_NEXT(n)		(JS_BASE + ((n) * 0x80) + 0x70)
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci/* Possible values of JS_CONFIG and JS_CONFIG_NEXT registers */
2458c2ecf20Sopenharmony_ci#define JS_CONFIG_START_FLUSH_CLEAN		BIT(8)
2468c2ecf20Sopenharmony_ci#define JS_CONFIG_START_FLUSH_CLEAN_INVALIDATE	(3u << 8)
2478c2ecf20Sopenharmony_ci#define JS_CONFIG_START_MMU			BIT(10)
2488c2ecf20Sopenharmony_ci#define JS_CONFIG_JOB_CHAIN_FLAG		BIT(11)
2498c2ecf20Sopenharmony_ci#define JS_CONFIG_END_FLUSH_CLEAN		BIT(12)
2508c2ecf20Sopenharmony_ci#define JS_CONFIG_END_FLUSH_CLEAN_INVALIDATE	(3u << 12)
2518c2ecf20Sopenharmony_ci#define JS_CONFIG_ENABLE_FLUSH_REDUCTION	BIT(14)
2528c2ecf20Sopenharmony_ci#define JS_CONFIG_DISABLE_DESCRIPTOR_WR_BK	BIT(15)
2538c2ecf20Sopenharmony_ci#define JS_CONFIG_THREAD_PRI(n)			((n) << 16)
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci#define JS_COMMAND_NOP			0x00
2568c2ecf20Sopenharmony_ci#define JS_COMMAND_START		0x01
2578c2ecf20Sopenharmony_ci#define JS_COMMAND_SOFT_STOP		0x02	/* Gently stop processing a job chain */
2588c2ecf20Sopenharmony_ci#define JS_COMMAND_HARD_STOP		0x03	/* Rudely stop processing a job chain */
2598c2ecf20Sopenharmony_ci#define JS_COMMAND_SOFT_STOP_0		0x04	/* Execute SOFT_STOP if JOB_CHAIN_FLAG is 0 */
2608c2ecf20Sopenharmony_ci#define JS_COMMAND_HARD_STOP_0		0x05	/* Execute HARD_STOP if JOB_CHAIN_FLAG is 0 */
2618c2ecf20Sopenharmony_ci#define JS_COMMAND_SOFT_STOP_1		0x06	/* Execute SOFT_STOP if JOB_CHAIN_FLAG is 1 */
2628c2ecf20Sopenharmony_ci#define JS_COMMAND_HARD_STOP_1		0x07	/* Execute HARD_STOP if JOB_CHAIN_FLAG is 1 */
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci#define JS_STATUS_EVENT_ACTIVE		0x08
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/* MMU regs */
2688c2ecf20Sopenharmony_ci#define MMU_INT_RAWSTAT			0x2000
2698c2ecf20Sopenharmony_ci#define MMU_INT_CLEAR			0x2004
2708c2ecf20Sopenharmony_ci#define MMU_INT_MASK			0x2008
2718c2ecf20Sopenharmony_ci#define MMU_INT_STAT			0x200c
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/* AS_COMMAND register commands */
2748c2ecf20Sopenharmony_ci#define AS_COMMAND_NOP			0x00	/* NOP Operation */
2758c2ecf20Sopenharmony_ci#define AS_COMMAND_UPDATE		0x01	/* Broadcasts the values in AS_TRANSTAB and ASn_MEMATTR to all MMUs */
2768c2ecf20Sopenharmony_ci#define AS_COMMAND_LOCK			0x02	/* Issue a lock region command to all MMUs */
2778c2ecf20Sopenharmony_ci#define AS_COMMAND_UNLOCK		0x03	/* Issue a flush region command to all MMUs */
2788c2ecf20Sopenharmony_ci#define AS_COMMAND_FLUSH		0x04	/* Flush all L2 caches then issue a flush region command to all MMUs
2798c2ecf20Sopenharmony_ci						   (deprecated - only for use with T60x) */
2808c2ecf20Sopenharmony_ci#define AS_COMMAND_FLUSH_PT		0x04	/* Flush all L2 caches then issue a flush region command to all MMUs */
2818c2ecf20Sopenharmony_ci#define AS_COMMAND_FLUSH_MEM		0x05	/* Wait for memory accesses to complete, flush all the L1s cache then
2828c2ecf20Sopenharmony_ci						   flush all L2 caches then issue a flush region command to all MMUs */
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#define MMU_AS(as)			(0x2400 + ((as) << 6))
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LO(as)		(MMU_AS(as) + 0x00) /* (RW) Translation Table Base Address for address space n, low word */
2878c2ecf20Sopenharmony_ci#define AS_TRANSTAB_HI(as)		(MMU_AS(as) + 0x04) /* (RW) Translation Table Base Address for address space n, high word */
2888c2ecf20Sopenharmony_ci#define AS_MEMATTR_LO(as)		(MMU_AS(as) + 0x08) /* (RW) Memory attributes for address space n, low word. */
2898c2ecf20Sopenharmony_ci#define AS_MEMATTR_HI(as)		(MMU_AS(as) + 0x0C) /* (RW) Memory attributes for address space n, high word. */
2908c2ecf20Sopenharmony_ci#define AS_LOCKADDR_LO(as)		(MMU_AS(as) + 0x10) /* (RW) Lock region address for address space n, low word */
2918c2ecf20Sopenharmony_ci#define AS_LOCKADDR_HI(as)		(MMU_AS(as) + 0x14) /* (RW) Lock region address for address space n, high word */
2928c2ecf20Sopenharmony_ci#define AS_COMMAND(as)			(MMU_AS(as) + 0x18) /* (WO) MMU command register for address space n */
2938c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS(as)		(MMU_AS(as) + 0x1C) /* (RO) MMU fault status register for address space n */
2948c2ecf20Sopenharmony_ci#define AS_FAULTADDRESS_LO(as)		(MMU_AS(as) + 0x20) /* (RO) Fault Address for address space n, low word */
2958c2ecf20Sopenharmony_ci#define AS_FAULTADDRESS_HI(as)		(MMU_AS(as) + 0x24) /* (RO) Fault Address for address space n, high word */
2968c2ecf20Sopenharmony_ci#define AS_STATUS(as)			(MMU_AS(as) + 0x28) /* (RO) Status flags for address space n */
2978c2ecf20Sopenharmony_ci/* Additional Bifrost AS regsiters */
2988c2ecf20Sopenharmony_ci#define AS_TRANSCFG_LO(as)		(MMU_AS(as) + 0x30) /* (RW) Translation table configuration for address space n, low word */
2998c2ecf20Sopenharmony_ci#define AS_TRANSCFG_HI(as)		(MMU_AS(as) + 0x34) /* (RW) Translation table configuration for address space n, high word */
3008c2ecf20Sopenharmony_ci#define AS_FAULTEXTRA_LO(as)		(MMU_AS(as) + 0x38) /* (RO) Secondary fault address for address space n, low word */
3018c2ecf20Sopenharmony_ci#define AS_FAULTEXTRA_HI(as)		(MMU_AS(as) + 0x3C) /* (RO) Secondary fault address for address space n, high word */
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci/*
3048c2ecf20Sopenharmony_ci * Begin LPAE MMU TRANSTAB register values
3058c2ecf20Sopenharmony_ci */
3068c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_ADDR_SPACE_MASK	0xfffffffffffff000
3078c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_ADRMODE_IDENTITY	0x2
3088c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_ADRMODE_TABLE		0x3
3098c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_ADRMODE_MASK		0x3
3108c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_READ_INNER		BIT(2)
3118c2ecf20Sopenharmony_ci#define AS_TRANSTAB_LPAE_SHARE_OUTER		BIT(4)
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#define AS_STATUS_AS_ACTIVE			0x01
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS_ACCESS_TYPE_MASK		(0x3 << 8)
3168c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS_ACCESS_TYPE_ATOMIC	(0x0 << 8)
3178c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS_ACCESS_TYPE_EX		(0x1 << 8)
3188c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS_ACCESS_TYPE_READ		(0x2 << 8)
3198c2ecf20Sopenharmony_ci#define AS_FAULTSTATUS_ACCESS_TYPE_WRITE	(0x3 << 8)
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci#define AS_LOCK_REGION_MIN_SIZE                 (1ULL << 15)
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci#define gpu_write(dev, reg, data) writel(data, dev->iomem + reg)
3248c2ecf20Sopenharmony_ci#define gpu_read(dev, reg) readl(dev->iomem + reg)
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci#endif
327