HID: amd_sfh: Fix illuminance value
[linux-block.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_base_info {
92         union {
93                 u32 sfh_base[24];
94                 struct {
95                         struct sfh_platform_info plat_info;
96                         struct sfh_firmware_info  fw_info;
97                         struct sfh_sensor_list s_list;
98                 } sbase;
99         };
100 };
101
102 struct sfh_common_data {
103         u64 timestamp;
104         u32 intr_cnt;
105         u32 featvalid           : 16;
106         u32 rsvd                : 13;
107         u32 sensor_state        : 3;
108 };
109
110 struct sfh_float32 {
111         u32 x;
112         u32 y;
113         u32 z;
114 };
115
116 struct sfh_accel_data {
117         struct sfh_common_data commondata;
118         struct sfh_float32 acceldata;
119         u32 accelstatus;
120 };
121
122 struct sfh_gyro_data {
123         struct sfh_common_data commondata;
124         struct sfh_float32 gyrodata;
125         u32 result;
126 };
127
128 struct sfh_mag_data {
129         struct sfh_common_data commondata;
130         struct sfh_float32 magdata;
131         u32 accuracy;
132 };
133
134 struct sfh_als_data {
135         struct sfh_common_data commondata;
136         u32 lux;
137 };
138
139 struct hpd_status {
140         union {
141                 struct {
142                         u32 distance                    : 16;
143                         u32 probablity                  : 8;
144                         u32 presence                    : 2;
145                         u32 rsvd                        : 5;
146                         u32 state                       : 1;
147                 } shpd;
148                 u32 val;
149         };
150 };
151
152 void sfh_interface_init(struct amd_mp2_dev *mp2);
153 void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
154 #endif