/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Tegra host1x Actmon Register Offsets
 *
 * Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 */

#ifndef __HOST1X_ACTMON_HARDWARE_H
#define __HOST1X_ACTMON_HARDWARE_H

#define HOST1X_ACTMON_MODULE_OFFSET				0x80

#define HOST1X_ACTMON_CTRL_REG					0x0
#define HOST1X_ACTMON_INTR_ENB_REG				0x4
#define HOST1X_ACTMON_INTR_STATUS_REG				0x8
#define HOST1X_ACTMON_MODULE_INIT_AVG_REG			0x14
#define HOST1X_ACTMON_MODULE_CTRL_REG				0x80
#define HOST1X_ACTMON_MODULE_INTR_ENB_REG			0x84
#define HOST1X_ACTMON_MODULE_INTR_STATUS_REG			0x88
#define HOST1X_ACTMON_MODULE_UPPER_WMARK_REG			0x8c
#define HOST1X_ACTMON_MODULE_LOWER_WMARK_REG			0x90
#define HOST1X_ACTMON_MODULE_AVG_UPPER_WMARK_REG		0x94
#define HOST1X_ACTMON_MODULE_AVG_LOWER_WMARK_REG		0x98
#define HOST1X_ACTMON_MODULE_AVG_COUNT_REG			0xa4
#define HOST1X_ACTMON_MODULE_COUNT_WEIGHT_REG			0xa8

#define HOST1X_ACTMON_CTRL_SOURCE(v)				((v & 0x3) << 8)
#define HOST1X_ACTMON_CTRL_SAMPLE_TICK(v)			((v & 0x1) << 10)
#define HOST1X_ACTMON_CTRL_SAMPLE_PERIOD(v)			((v & 0xff) << 0)
#define HOST1X_ACTMON_MODULE_CTRL_ACTMON_ENB(v)			((v & 0x1) << 31)
#define HOST1X_ACTMON_MODULE_CTRL_CONSEC_UPPER_NUM(v)		((v & 0x7) << 26)
#define HOST1X_ACTMON_MODULE_CTRL_CONSEC_LOWER_NUM(v)		((v & 0x7) << 21)
#define HOST1X_ACTMON_MODULE_CTRL_ENB_PERIODIC(v)		((v & 0x1) << 13)
#define HOST1X_ACTMON_MODULE_CTRL_K_VAL(v)			((v & 0x7) << 10)
#define HOST1X_ACTMON_MODULE_INTR_CONSEC_WMARK_ABOVE_ENB(v)	((v & 0x1) << 31)
#define HOST1X_ACTMON_MODULE_INTR_CONSEC_WMARK_BELOW_ENB(v)	((v & 0x1) << 30)
#define HOST1X_ACTMON_MODULE_INTR_AVG_WMARK_ABOVE_ENB(v)	((v & 0x1) << 29)
#define HOST1X_ACTMON_MODULE_INTR_AVG_WMARK_BELOW_ENB(v)	((v & 0x1) << 28)

#define HOST1X_ACTMON_CTRL_SAMPLE_PERIOD_MASK			0xff
#define HOST1X_ACTMON_MODULE_CTRL_CONSEC_UPPER_NUM_MASK		(0x7 << 26)
#define HOST1X_ACTMON_MODULE_CTRL_CONSEC_LOWER_NUM_MASK		(0x7 << 21)
#define HOST1X_ACTMON_MODULE_CTRL_K_VAL_MASK			(0x7 << 10)

#define HOST1X_ACTMON_MODULE_INTR_CONSEC_WMARK_ABOVE		BIT(31)
#define HOST1X_ACTMON_MODULE_INTR_CONSEC_WMARK_BELOW		BIT(30)
#define HOST1X_ACTMON_MODULE_INTR_AVG_WMARK_ABOVE		BIT(29)
#define HOST1X_ACTMON_MODULE_INTR_AVG_WMARK_BELOW		BIT(28)

#endif
