summaryrefslogtreecommitdiff
path: root/drivers/accel/ivpu/ivpu_hw.h
blob: 1c0c98e3afb88d78fc514989cd8c7ca09d83737b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2020-2024 Intel Corporation
 */

#ifndef __IVPU_HW_H__
#define __IVPU_HW_H__

#include <linux/kfifo.h>

#include "ivpu_drv.h"
#include "ivpu_hw_btrs.h"
#include "ivpu_hw_ip.h"

#define IVPU_HW_IRQ_FIFO_LENGTH 1024

#define IVPU_HW_IRQ_SRC_IPC 1
#define IVPU_HW_IRQ_SRC_MMU_EVTQ 2
#define IVPU_HW_IRQ_SRC_DCT 3

struct ivpu_addr_range {
	resource_size_t start;
	resource_size_t end;
};

struct ivpu_hw_info {
	struct {
		bool (*btrs_irq_handler)(struct ivpu_device *vdev, int irq);
		bool (*ip_irq_handler)(struct ivpu_device *vdev, int irq);
		DECLARE_KFIFO(fifo, u8, IVPU_HW_IRQ_FIFO_LENGTH);
	} irq;
	struct {
		struct ivpu_addr_range global;
		struct ivpu_addr_range user;
		struct ivpu_addr_range shave;
		struct ivpu_addr_range dma;
	} ranges;
	struct {
		u8 min_ratio;
		u8 max_ratio;
		/*
		 * Pll ratio for the efficiency frequency. The VPU has optimum
		 * performance to power ratio at this frequency.
		 */
		u8 pn_ratio;
		u32 profiling_freq;
	} pll;
	u32 tile_fuse;
	u32 sched_mode;
	u32 sku;
	u16 config;
	int dma_bits;
	ktime_t d0i3_entry_host_ts;
	u64 d0i3_entry_vpu_ts;
};

int ivpu_hw_init(struct ivpu_device *vdev);
int ivpu_hw_power_up(struct ivpu_device *vdev);
int ivpu_hw_power_down(struct ivpu_device *vdev);
int ivpu_hw_reset(struct ivpu_device *vdev);
int ivpu_hw_boot_fw(struct ivpu_device *vdev);
void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable);
void ivpu_irq_handlers_init(struct ivpu_device *vdev);
void ivpu_hw_irq_enable(struct ivpu_device *vdev);
void ivpu_hw_irq_disable(struct ivpu_device *vdev);
irqreturn_t ivpu_hw_irq_handler(int irq, void *ptr);

static inline u32 ivpu_hw_btrs_irq_handler(struct ivpu_device *vdev, int irq)
{
	return vdev->hw->irq.btrs_irq_handler(vdev, irq);
}

static inline u32 ivpu_hw_ip_irq_handler(struct ivpu_device *vdev, int irq)
{
	return vdev->hw->irq.ip_irq_handler(vdev, irq);
}

static inline void ivpu_hw_range_init(struct ivpu_addr_range *range, u64 start, u64 size)
{
	range->start = start;
	range->end = start + size;
}

static inline u64 ivpu_hw_range_size(const struct ivpu_addr_range *range)
{
	return range->end - range->start;
}

static inline u32 ivpu_hw_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
{
	return ivpu_hw_btrs_ratio_to_freq(vdev, ratio);
}

static inline void ivpu_hw_irq_clear(struct ivpu_device *vdev)
{
	ivpu_hw_ip_irq_clear(vdev);
}

static inline u32 ivpu_hw_pll_freq_get(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_pll_freq_get(vdev);
}

static inline u32 ivpu_hw_profiling_freq_get(struct ivpu_device *vdev)
{
	return vdev->hw->pll.profiling_freq;
}

static inline void ivpu_hw_diagnose_failure(struct ivpu_device *vdev)
{
	ivpu_hw_ip_diagnose_failure(vdev);
	ivpu_hw_btrs_diagnose_failure(vdev);
}

static inline u32 ivpu_hw_telemetry_offset_get(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_telemetry_offset_get(vdev);
}

static inline u32 ivpu_hw_telemetry_size_get(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_telemetry_size_get(vdev);
}

static inline u32 ivpu_hw_telemetry_enable_get(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_telemetry_enable_get(vdev);
}

static inline bool ivpu_hw_is_idle(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_is_idle(vdev);
}

static inline int ivpu_hw_wait_for_idle(struct ivpu_device *vdev)
{
	return ivpu_hw_btrs_wait_for_idle(vdev);
}

static inline void ivpu_hw_ipc_tx_set(struct ivpu_device *vdev, u32 vpu_addr)
{
	ivpu_hw_ip_ipc_tx_set(vdev, vpu_addr);
}

static inline void ivpu_hw_db_set(struct ivpu_device *vdev, u32 db_id)
{
	ivpu_hw_ip_db_set(vdev, db_id);
}

static inline u32 ivpu_hw_ipc_rx_addr_get(struct ivpu_device *vdev)
{
	return ivpu_hw_ip_ipc_rx_addr_get(vdev);
}

static inline u32 ivpu_hw_ipc_rx_count_get(struct ivpu_device *vdev)
{
	return ivpu_hw_ip_ipc_rx_count_get(vdev);
}

#endif /* __IVPU_HW_H__ */