Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * AMD MP2 1.1 communication interfaces
0004  *
0005  * Copyright (c) 2022, Advanced Micro Devices, Inc.
0006  * All Rights Reserved.
0007  *
0008  * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
0009  */
0010 
0011 #ifndef AMD_SFH_INTERFACE_H
0012 #define AMD_SFH_INTERFACE_H
0013 
0014 #include "../amd_sfh_common.h"
0015 
0016 #define SENSOR_DATA_MEM_SIZE_DEFAULT        256
0017 #define TOTAL_STATIC_MEM_DEFAULT        1024
0018 #define OFFSET_SFH_INFO_BASE_DEFAULT        0
0019 #define OFFSET_SENSOR_DATA_DEFAULT      (OFFSET_SFH_INFO_BASE_DEFAULT + \
0020                             TOTAL_STATIC_MEM_DEFAULT)
0021 enum sensor_index {
0022     ACCEL_IDX,
0023     GYRO_IDX,
0024     MAG_IDX,
0025     ALS_IDX = 4,
0026     HPD_IDX = 5,
0027     MAX_IDX = 15,
0028 };
0029 
0030 struct sfh_cmd_base {
0031     union {
0032         u32 ul;
0033         struct {
0034             u32 sensor_id       : 4;
0035             u32 cmd_id      : 4;
0036             u32 sub_cmd_id      : 6;
0037             u32 length      : 12;
0038             u32 rsvd        : 5;
0039             u32 intr_disable    : 1;
0040         } cmd;
0041     };
0042 };
0043 
0044 struct sfh_cmd_response {
0045     union {
0046         u32 resp;
0047         struct {
0048             u32 response    : 8;
0049             u32 sensor_id   : 4;
0050             u32 cmd_id  : 4;
0051             u32 sub_cmd : 6;
0052             u32 rsvd2   : 10;
0053         } response;
0054     };
0055 };
0056 
0057 struct sfh_platform_info {
0058     union {
0059         u32 pi;
0060         struct {
0061             u32 cust_id     : 16;
0062             u32 plat_id     : 6;
0063             u32 interface_id    : 4;
0064             u32 rsvd        : 6;
0065         } pinfo;
0066     };
0067 };
0068 
0069 struct sfh_firmware_info {
0070     union {
0071         u32 fw_ver;
0072         struct {
0073             u32 minor_rev : 8;
0074             u32 major_rev : 8;
0075             u32 minor_ver : 8;
0076             u32 major_ver : 8;
0077         } fver;
0078     };
0079 };
0080 
0081 struct sfh_sensor_list {
0082     union {
0083         u32 slist;
0084         struct {
0085             u32 sensors : 16;
0086             u32 rsvd    : 16;
0087         } sl;
0088     };
0089 };
0090 
0091 struct sfh_base_info {
0092     union {
0093         u32 sfh_base[24];
0094         struct {
0095             struct sfh_platform_info plat_info;
0096             struct sfh_firmware_info  fw_info;
0097             struct sfh_sensor_list s_list;
0098         } sbase;
0099     };
0100 };
0101 
0102 struct sfh_common_data {
0103     u64 timestamp;
0104     u32 intr_cnt;
0105     u32 featvalid       : 16;
0106     u32 rsvd        : 13;
0107     u32 sensor_state    : 3;
0108 };
0109 
0110 struct sfh_float32 {
0111     u32 x;
0112     u32 y;
0113     u32 z;
0114 };
0115 
0116 struct sfh_accel_data {
0117     struct sfh_common_data commondata;
0118     struct sfh_float32 acceldata;
0119     u32 accelstatus;
0120 };
0121 
0122 struct sfh_gyro_data {
0123     struct sfh_common_data commondata;
0124     struct sfh_float32 gyrodata;
0125     u32 result;
0126 };
0127 
0128 struct sfh_mag_data {
0129     struct sfh_common_data commondata;
0130     struct sfh_float32 magdata;
0131     u32 accuracy;
0132 };
0133 
0134 struct sfh_als_data {
0135     struct sfh_common_data commondata;
0136     u16 lux;
0137 };
0138 
0139 struct hpd_status {
0140     union {
0141         struct {
0142             u32 distance            : 16;
0143             u32 probablity          : 8;
0144             u32 presence            : 2;
0145             u32 rsvd            : 5;
0146             u32 state           : 1;
0147         } shpd;
0148         u32 val;
0149     };
0150 };
0151 
0152 void sfh_interface_init(struct amd_mp2_dev *mp2);
0153 void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
0154 #endif