summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include/nvgpu/xve.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/include/nvgpu/xve.h')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/xve.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/xve.h b/drivers/gpu/nvgpu/include/nvgpu/xve.h
new file mode 100644
index 00000000..ee599300
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/xve.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13#ifndef __NVGPU_XVE_H__
14#define __NVGPU_XVE_H__
15
16#include <nvgpu/types.h>
17#include <nvgpu/log2.h>
18
19/*
20 * For the available speeds bitmap.
21 */
22#define GPU_XVE_SPEED_2P5 (1 << 0)
23#define GPU_XVE_SPEED_5P0 (1 << 1)
24#define GPU_XVE_SPEED_8P0 (1 << 2)
25#define GPU_XVE_NR_SPEEDS 3
26
27#define GPU_XVE_SPEED_MASK (GPU_XVE_SPEED_2P5 | \
28 GPU_XVE_SPEED_5P0 | \
29 GPU_XVE_SPEED_8P0)
30
31/*
32 * The HW uses a 2 bit field where speed is defined by a number:
33 *
34 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_2P5 = 1
35 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_5P0 = 2
36 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_8P0 = 3
37 *
38 * This isn't ideal for a bitmap with available speeds. So the external
39 * APIs think about speeds as a bit in a bitmap and this function converts
40 * from those bits to the actual HW speed setting.
41 *
42 * @speed_bit must have only 1 bit set and must be one of the 3 available
43 * HW speeds. Not all chips support all speeds so use available_speeds() to
44 * determine what a given chip supports.
45 */
46static inline const char *xve_speed_to_str(u32 speed)
47{
48 if (!speed || !is_power_of_2(speed) ||
49 !(speed & GPU_XVE_SPEED_MASK))
50 return "Unknown ???";
51
52 return speed & GPU_XVE_SPEED_2P5 ? "Gen1" :
53 speed & GPU_XVE_SPEED_5P0 ? "Gen2" :
54 speed & GPU_XVE_SPEED_8P0 ? "Gen3" :
55 "Unknown ???";
56}
57
58#endif