linux/drivers/iio/common/ssp_sensors/ssp.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved.
 */

#ifndef __SSP_SENSORHUB_H__
#define __SSP_SENSORHUB_H__

#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/iio/common/ssp_sensors.h>
#include <linux/iio/iio.h>
#include <linux/spi/spi.h>

#define SSP_DEVICE_ID

#ifdef SSP_DBG
#define ssp_dbg
#else
#define ssp_dbg(format, ...)
#endif

#define SSP_SW_RESET_TIME
/* Sensor polling in ms */
#define SSP_DEFAULT_POLLING_DELAY
#define SSP_DEFAULT_RETRIES
#define SSP_DATA_PACKET_SIZE
#define SSP_HEADER_BUFFER_SIZE

enum {};

enum {};

/* Firmware download STATE */
enum {};

#define SSP_INVALID_REVISION
#define SSP_INVALID_REVISION2

/* AP -> SSP Instruction */
#define SSP_MSG2SSP_INST_BYPASS_SENSOR_ADD
#define SSP_MSG2SSP_INST_BYPASS_SENSOR_RM
#define SSP_MSG2SSP_INST_REMOVE_ALL
#define SSP_MSG2SSP_INST_CHANGE_DELAY
#define SSP_MSG2SSP_INST_LIBRARY_ADD
#define SSP_MSG2SSP_INST_LIBRARY_REMOVE
#define SSP_MSG2SSP_INST_LIB_NOTI
#define SSP_MSG2SSP_INST_LIB_DATA

#define SSP_MSG2SSP_AP_MCU_SET_GYRO_CAL
#define SSP_MSG2SSP_AP_MCU_SET_ACCEL_CAL
#define SSP_MSG2SSP_AP_STATUS_SHUTDOWN
#define SSP_MSG2SSP_AP_STATUS_WAKEUP
#define SSP_MSG2SSP_AP_STATUS_SLEEP
#define SSP_MSG2SSP_AP_STATUS_RESUME
#define SSP_MSG2SSP_AP_STATUS_SUSPEND
#define SSP_MSG2SSP_AP_STATUS_RESET
#define SSP_MSG2SSP_AP_STATUS_POW_CONNECTED
#define SSP_MSG2SSP_AP_STATUS_POW_DISCONNECTED
#define SSP_MSG2SSP_AP_TEMPHUMIDITY_CAL_DONE
#define SSP_MSG2SSP_AP_MCU_SET_DUMPMODE
#define SSP_MSG2SSP_AP_MCU_DUMP_CHECK
#define SSP_MSG2SSP_AP_MCU_BATCH_FLUSH
#define SSP_MSG2SSP_AP_MCU_BATCH_COUNT

#define SSP_MSG2SSP_AP_WHOAMI
#define SSP_MSG2SSP_AP_FIRMWARE_REV
#define SSP_MSG2SSP_AP_SENSOR_FORMATION
#define SSP_MSG2SSP_AP_SENSOR_PROXTHRESHOLD
#define SSP_MSG2SSP_AP_SENSOR_BARCODE_EMUL
#define SSP_MSG2SSP_AP_SENSOR_SCANNING
#define SSP_MSG2SSP_AP_SET_MAGNETIC_HWOFFSET
#define SSP_MSG2SSP_AP_GET_MAGNETIC_HWOFFSET
#define SSP_MSG2SSP_AP_SENSOR_GESTURE_CURRENT
#define SSP_MSG2SSP_AP_GET_THERM
#define SSP_MSG2SSP_AP_GET_BIG_DATA
#define SSP_MSG2SSP_AP_SET_BIG_DATA
#define SSP_MSG2SSP_AP_START_BIG_DATA
#define SSP_MSG2SSP_AP_SET_MAGNETIC_STATIC_MATRIX
#define SSP_MSG2SSP_AP_SENSOR_TILT
#define SSP_MSG2SSP_AP_MCU_SET_TIME
#define SSP_MSG2SSP_AP_MCU_GET_TIME

#define SSP_MSG2SSP_AP_FUSEROM

/* voice data */
#define SSP_TYPE_WAKE_UP_VOICE_SERVICE
#define SSP_TYPE_WAKE_UP_VOICE_SOUND_SOURCE_AM
#define SSP_TYPE_WAKE_UP_VOICE_SOUND_SOURCE_GRAMMER

/* Factory Test */
#define SSP_ACCELEROMETER_FACTORY
#define SSP_GYROSCOPE_FACTORY
#define SSP_GEOMAGNETIC_FACTORY
#define SSP_PRESSURE_FACTORY
#define SSP_GESTURE_FACTORY
#define SSP_TEMPHUMIDITY_CRC_FACTORY
#define SSP_GYROSCOPE_TEMP_FACTORY
#define SSP_GYROSCOPE_DPS_FACTORY
#define SSP_MCU_FACTORY
#define SSP_MCU_SLEEP_FACTORY

/* SSP -> AP ACK about write CMD */
#define SSP_MSG_ACK
#define SSP_MSG_NAK

struct ssp_sensorhub_info {};

/* ssp_msg options bit */
#define SSP_RW
#define SSP_INDEX

#define SSP_AP2HUB_READ
#define SSP_AP2HUB_WRITE
#define SSP_HUB2AP_WRITE
#define SSP_AP2HUB_READY
#define SSP_AP2HUB_RETURN

/**
 * struct ssp_data - ssp platformdata structure
 * @spi:		spi device
 * @sensorhub_info:	info about sensorhub board specific features
 * @wdt_timer:		watchdog timer
 * @work_wdt:		watchdog work
 * @work_firmware:	firmware upgrade work queue
 * @work_refresh:	refresh work queue for reset request from MCU
 * @shut_down:		shut down flag
 * @mcu_dump_mode:	mcu dump mode for debug
 * @time_syncing:	time syncing indication flag
 * @timestamp:		previous time in ns calculated for time syncing
 * @check_status:	status table for each sensor
 * @com_fail_cnt:	communication fail count
 * @reset_cnt:		reset count
 * @timeout_cnt:	timeout count
 * @available_sensors:	available sensors seen by sensorhub (bit array)
 * @cur_firm_rev:	cached current firmware revision
 * @last_resume_state:	last AP resume/suspend state used to handle the PM
 *                      state of ssp
 * @last_ap_state:	(obsolete) sleep notification for MCU
 * @sensor_enable:	sensor enable mask
 * @delay_buf:		data acquisition intervals table
 * @batch_latency_buf:	yet unknown but existing in communication protocol
 * @batch_opt_buf:	yet unknown but existing in communication protocol
 * @accel_position:	yet unknown but existing in communication protocol
 * @mag_position:	yet unknown but existing in communication protocol
 * @fw_dl_state:	firmware download state
 * @comm_lock:		lock protecting the handshake
 * @pending_lock:	lock protecting pending list and completion
 * @mcu_reset_gpiod:	mcu reset line
 * @ap_mcu_gpiod:	ap to mcu gpio line
 * @mcu_ap_gpiod:	mcu to ap gpio line
 * @pending_list:	pending list for messages queued to be sent/read
 * @sensor_devs:	registered IIO devices table
 * @enable_refcount:	enable reference count for wdt (watchdog timer)
 * @header_buffer:	cache aligned buffer for packet header
 */
struct ssp_data {};

void ssp_clean_pending_list(struct ssp_data *data);

int ssp_command(struct ssp_data *data, char command, int arg);

int ssp_send_instruction(struct ssp_data *data, u8 inst, u8 sensor_type,
			 u8 *send_buf, u8 length);

int ssp_irq_msg(struct ssp_data *data);

int ssp_get_chipid(struct ssp_data *data);

int ssp_set_magnetic_matrix(struct ssp_data *data);

unsigned int ssp_get_sensor_scanning_info(struct ssp_data *data);

unsigned int ssp_get_firmware_rev(struct ssp_data *data);

int ssp_queue_ssp_refresh_task(struct ssp_data *data, unsigned int delay);

#endif /* __SSP_SENSORHUB_H__ */