summaryrefslogtreecommitdiffstats
path: root/sensors/ssp.h
diff options
context:
space:
mode:
Diffstat (limited to 'sensors/ssp.h')
-rw-r--r--sensors/ssp.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/sensors/ssp.h b/sensors/ssp.h
new file mode 100644
index 0000000..48c9ad9
--- /dev/null
+++ b/sensors/ssp.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2012, Samsung Electronics Co. Ltd. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __SSP_PRJ_H__
+#define __SSP_PRJ_H__
+
+#include <stdint.h>
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define SSP_SW_RESET_TIME 3000
+#define DEFUALT_POLLING_DELAY (200 * NSEC_PER_MSEC)
+#define PROX_AVG_READ_NUM 80
+#define DEFAULT_RETRIES 3
+
+/* Sensor Sampling Time Define */
+enum {
+ SENSOR_NS_DELAY_FASTEST = 10000000, /* 10msec */
+ SENSOR_NS_DELAY_GAME = 20000000, /* 20msec */
+ SENSOR_NS_DELAY_UI = 66700000, /* 66.7msec */
+ SENSOR_NS_DELAY_NORMAL = 200000000, /* 200msec */
+};
+
+enum {
+ SENSOR_MS_DELAY_FASTEST = 10, /* 10msec */
+ SENSOR_MS_DELAY_GAME = 20, /* 20msec */
+ SENSOR_MS_DELAY_UI = 66, /* 66.7msec */
+ SENSOR_MS_DELAY_NORMAL = 200, /* 200msec */
+};
+
+enum {
+ SENSOR_CMD_DELAY_FASTEST = 0, /* 10msec */
+ SENSOR_CMD_DELAY_GAME, /* 20msec */
+ SENSOR_CMD_DELAY_UI, /* 66.7msec */
+ SENSOR_CMD_DELAY_NORMAL, /* 200msec */
+};
+
+/*
+ * SENSOR_DELAY_SET_STATE
+ * Check delay set to avoid sending ADD instruction twice
+ */
+enum {
+ INITIALIZATION_STATE = 0,
+ NO_SENSOR_STATE,
+ ADD_SENSOR_STATE,
+ RUNNING_SENSOR_STATE,
+};
+
+/* Gyroscope DPS */
+#define GYROSCOPE_DPS250 250
+#define GYROSCOPE_DPS500 500
+#define GYROSCOPE_DPS2000 2000
+
+/* kernel -> ssp manager cmd*/
+#define SSP_LIBRARY_SLEEP_CMD (1 << 5)
+#define SSP_LIBRARY_LARGE_DATA_CMD (1 << 6)
+#define SSP_LIBRARY_WAKEUP_CMD (1 << 7)
+
+/* ioctl command */
+#define AKMIO 0xA1
+#define ECS_IOCTL_GET_FUSEROMDATA _IOR(AKMIO, 0x01, unsigned char[3])
+#define ECS_IOCTL_GET_MAGDATA _IOR(AKMIO, 0x02, unsigned char[8])
+#define ECS_IOCTL_GET_ACCDATA _IOR(AKMIO, 0x03, int[3])
+
+/* AP -> SSP Instruction */
+#define MSG2SSP_INST_BYPASS_SENSOR_ADD 0xA1
+#define MSG2SSP_INST_BYPASS_SENSOR_REMOVE 0xA2
+#define MSG2SSP_INST_REMOVE_ALL 0xA3
+#define MSG2SSP_INST_CHANGE_DELAY 0xA4
+#define MSG2SSP_INST_SENSOR_SELFTEST 0xA8
+#define MSG2SSP_INST_LIBRARY_ADD 0xB1
+#define MSG2SSP_INST_LIBRARY_REMOVE 0xB2
+
+#define MSG2SSP_AP_STT 0xC8
+#define MSG2SSP_AP_STATUS_WAKEUP 0xD1
+#define MSG2SSP_AP_STATUS_SLEEP 0xD2
+#define MSG2SSP_AP_STATUS_RESET 0xD3
+#define MSG2SSP_AP_WHOAMI 0x0F
+#define MSG2SSP_AP_FIRMWARE_REV 0xF0
+#define MSG2SSP_AP_SENSOR_FORMATION 0xF1
+#define MSG2SSP_AP_SENSOR_PROXTHRESHOLD 0xF2
+#define MSG2SSP_AP_SENSOR_BARCODE_EMUL 0xF3
+#define MSG2SSP_AP_SENSOR_SCANNING 0xF4
+
+#define MSG2SSP_AP_FUSEROM 0X01
+
+/* AP -> SSP Data Protocol Frame Field */
+#define MSG2SSP_SSP_SLEEP 0xC1
+#define MSG2SSP_STS 0xC2 /* Start to Send */
+#define MSG2SSP_RTS 0xC4 /* Ready to Send */
+#define MSG2SSP_STT 0xC8
+#define MSG2SSP_SRM 0xCA /* Start to Read MSG */
+#define MSG2SSP_SSM 0xCB /* Start to Send MSG */
+#define MSG2SSP_SSD 0xCE /* Start to Send Data Type & Length */
+
+/* SSP -> AP ACK about write CMD */
+#define MSG_ACK 0x80 /* ACK from SSP to AP */
+#define MSG_NAK 0x70 /* NAK from SSP to AP */
+
+
+/* SSP_INSTRUCTION_CMD */
+enum {
+ REMOVE_SENSOR = 0,
+ ADD_SENSOR,
+ CHANGE_DELAY,
+ GO_SLEEP,
+ FACTORY_MODE,
+ REMOVE_LIBRARY,
+ ADD_LIBRARY,
+};
+
+/* SENSOR_TYPE */
+enum {
+ ACCELEROMETER_SENSOR = 0,
+ GYROSCOPE_SENSOR,
+ GEOMAGNETIC_SENSOR,
+ PRESSURE_SENSOR,
+ GESTURE_SENSOR,
+ PROXIMITY_SENSOR,
+ LIGHT_SENSOR,
+ PROXIMITY_RAW,
+ ORIENTATION_SENSOR,
+ SENSOR_MAX,
+};
+
+/* SENSOR_FACTORY_MODE_TYPE */
+enum {
+ ACCELEROMETER_FACTORY = 0,
+ GYROSCOPE_FACTORY,
+ GEOMAGNETIC_FACTORY,
+ PRESSURE_FACTORY,
+ MCU_FACTORY,
+ GYROSCOPE_TEMP_FACTORY,
+ GYROSCOPE_DPS_FACTORY,
+ MCU_SLEEP_FACTORY,
+ SENSOR_FACTORY_MAX,
+};
+
+struct sensor_value {
+ union {
+ struct {
+ __s16 x;
+ __s16 y;
+ __s16 z;
+ };
+ struct {
+ __u16 r;
+ __u16 g;
+ __u16 b;
+ __u16 w;
+ };
+ __u8 prox[4];
+ __s16 data[4];
+ __s32 pressure[3];
+ };
+};
+
+struct calibraion_data {
+ int x;
+ int y;
+ int z;
+};
+
+#endif