summaryrefslogtreecommitdiffstats
path: root/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
blob: 9d31d5b510eb42bf1f3d4a759a66e6eab0f762b1 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * AMD MP2 1.1 communication interfaces
 *
 * Copyright (c) 2022, Advanced Micro Devices, Inc.
 * All Rights Reserved.
 *
 * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
 */

#ifndef AMD_SFH_INTERFACE_H
#define AMD_SFH_INTERFACE_H

#include "../amd_sfh_common.h"

#define SENSOR_DATA_MEM_SIZE_DEFAULT		256
#define TOTAL_STATIC_MEM_DEFAULT		1024
#define OFFSET_SFH_INFO_BASE_DEFAULT		0
#define OFFSET_SENSOR_DATA_DEFAULT		(OFFSET_SFH_INFO_BASE_DEFAULT + \
							TOTAL_STATIC_MEM_DEFAULT)
enum sensor_index {
	ACCEL_IDX,
	GYRO_IDX,
	MAG_IDX,
	ALS_IDX = 4,
	HPD_IDX = 5,
	MAX_IDX = 15,
};

struct sfh_cmd_base {
	union {
		u32 ul;
		struct {
			u32 sensor_id		: 4;
			u32 cmd_id		: 4;
			u32 sub_cmd_id		: 8;
			u32 sub_cmd_value	: 12;
			u32 rsvd		: 3;
			u32 intr_disable	: 1;
		} cmd;
	};
};

struct sfh_cmd_response {
	union {
		u32 resp;
		struct {
			u32 response	: 8;
			u32 sensor_id	: 4;
			u32 cmd_id	: 4;
			u32 sub_cmd	: 6;
			u32 rsvd2	: 10;
		} response;
	};
};

struct sfh_platform_info {
	union {
		u32 pi;
		struct {
			u32 cust_id		: 16;
			u32 plat_id		: 6;
			u32 interface_id	: 4;
			u32 rsvd		: 6;
		} pinfo;
	};
};

struct sfh_firmware_info {
	union {
		u32 fw_ver;
		struct {
			u32 minor_rev : 8;
			u32 major_rev : 8;
			u32 minor_ver : 8;
			u32 major_ver : 8;
		} fver;
	};
};

struct sfh_sensor_list {
	union {
		u32 slist;
		struct {
			u32 sensors	: 16;
			u32 rsvd	: 16;
		} sl;
	};
};

struct sfh_base_info {
	union {
		u32 sfh_base[24];
		struct {
			struct sfh_platform_info plat_info;
			struct sfh_firmware_info  fw_info;
			struct sfh_sensor_list s_list;
		} sbase;
	};
};

struct sfh_common_data {
	u64 timestamp;
	u32 intr_cnt;
	u32 featvalid		: 16;
	u32 rsvd		: 13;
	u32 sensor_state	: 3;
};

struct sfh_float32 {
	u32 x;
	u32 y;
	u32 z;
};

struct sfh_accel_data {
	struct sfh_common_data commondata;
	struct sfh_float32 acceldata;
	u32 accelstatus;
};

struct sfh_gyro_data {
	struct sfh_common_data commondata;
	struct sfh_float32 gyrodata;
	u32 result;
};

struct sfh_mag_data {
	struct sfh_common_data commondata;
	struct sfh_float32 magdata;
	u32 accuracy;
};

struct sfh_als_data {
	struct sfh_common_data commondata;
	u32 lux;
};

struct hpd_status {
	union {
		struct {
			u32 distance			: 16;
			u32 probablity			: 8;
			u32 presence			: 2;
			u32 rsvd			: 5;
			u32 state			: 1;
		} shpd;
		u32 val;
	};
};

void sfh_interface_init(struct amd_mp2_dev *mp2);
void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
#endif