GNU Linux-libre 6.7.9-gnu
[releases.git] / drivers / hid / amd-sfh-hid / sfh1_1 / amd_sfh_interface.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * AMD MP2 1.1 communication interfaces
4  *
5  * Copyright (c) 2022, Advanced Micro Devices, Inc.
6  * All Rights Reserved.
7  *
8  * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
9  */
10
11 #ifndef AMD_SFH_INTERFACE_H
12 #define AMD_SFH_INTERFACE_H
13
14 #include "../amd_sfh_common.h"
15
16 #define SENSOR_DATA_MEM_SIZE_DEFAULT            256
17 #define TOTAL_STATIC_MEM_DEFAULT                1024
18 #define OFFSET_SFH_INFO_BASE_DEFAULT            0
19 #define OFFSET_SENSOR_DATA_DEFAULT              (OFFSET_SFH_INFO_BASE_DEFAULT + \
20                                                         TOTAL_STATIC_MEM_DEFAULT)
21 enum sensor_index {
22         ACCEL_IDX,
23         GYRO_IDX,
24         MAG_IDX,
25         ALS_IDX = 4,
26         HPD_IDX = 5,
27         MAX_IDX = 15,
28 };
29
30 struct sfh_cmd_base {
31         union {
32                 u32 ul;
33                 struct {
34                         u32 sensor_id           : 4;
35                         u32 cmd_id              : 4;
36                         u32 sub_cmd_id          : 8;
37                         u32 sub_cmd_value       : 12;
38                         u32 rsvd                : 3;
39                         u32 intr_disable        : 1;
40                 } cmd;
41         };
42 };
43
44 struct sfh_cmd_response {
45         union {
46                 u32 resp;
47                 struct {
48                         u32 response    : 8;
49                         u32 sensor_id   : 4;
50                         u32 cmd_id      : 4;
51                         u32 sub_cmd     : 6;
52                         u32 rsvd2       : 10;
53                 } response;
54         };
55 };
56
57 struct sfh_platform_info {
58         union {
59                 u32 pi;
60                 struct {
61                         u32 cust_id             : 16;
62                         u32 plat_id             : 6;
63                         u32 interface_id        : 4;
64                         u32 rsvd                : 6;
65                 } pinfo;
66         };
67 };
68
69 struct sfh_firmware_info {
70         union {
71                 u32 fw_ver;
72                 struct {
73                         u32 minor_rev : 8;
74                         u32 major_rev : 8;
75                         u32 minor_ver : 8;
76                         u32 major_ver : 8;
77                 } fver;
78         };
79 };
80
81 struct sfh_sensor_list {
82         union {
83                 u32 slist;
84                 struct {
85                         u32 sensors     : 16;
86                         u32 rsvd        : 16;
87                 } sl;
88         };
89 };
90
91 struct sfh_sensor_prop {
92         union {
93                 u32 sprop;
94                 struct {
95                         u32 elist       : 16;
96                         u32 feat        : 16;
97                 } sf;
98         };
99 };
100
101 struct sfh_base_info {
102         union {
103                 u32 sfh_base[24];
104                 struct {
105                         struct sfh_platform_info plat_info;
106                         struct sfh_firmware_info  fw_info;
107                         struct sfh_sensor_list s_list;
108                         u32 rsvd;
109                         struct sfh_sensor_prop s_prop[16];
110                 } sbase;
111         };
112 };
113
114 struct sfh_common_data {
115         u64 timestamp;
116         u32 intr_cnt;
117         u32 featvalid           : 16;
118         u32 rsvd                : 13;
119         u32 sensor_state        : 3;
120 };
121
122 struct sfh_float32 {
123         u32 x;
124         u32 y;
125         u32 z;
126 };
127
128 struct sfh_accel_data {
129         struct sfh_common_data commondata;
130         struct sfh_float32 acceldata;
131         u32 accelstatus;
132 };
133
134 struct sfh_gyro_data {
135         struct sfh_common_data commondata;
136         struct sfh_float32 gyrodata;
137         u32 result;
138 };
139
140 struct sfh_mag_data {
141         struct sfh_common_data commondata;
142         struct sfh_float32 magdata;
143         u32 accuracy;
144 };
145
146 struct sfh_als_data {
147         struct sfh_common_data commondata;
148         u32 lux;
149         u32 light_color_temp;
150         u32 chromaticity_x;
151         u32 chromaticity_y;
152 };
153
154 struct hpd_status {
155         union {
156                 struct {
157                         u32 distance                    : 16;
158                         u32 probablity                  : 8;
159                         u32 presence                    : 2;
160                         u32 rsvd                        : 5;
161                         u32 state                       : 1;
162                 } shpd;
163                 u32 val;
164         };
165 };
166
167 void sfh_interface_init(struct amd_mp2_dev *mp2);
168 void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
169 #endif