ssp.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. /*
  2. * Copyright (C) 2011, Samsung Electronics Co. Ltd. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __SSP_PRJ_H__
  16. #define __SSP_PRJ_H__
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/i2c.h>
  20. #include <linux/uaccess.h>
  21. #include <linux/slab.h>
  22. #include <linux/input.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/workqueue.h>
  25. #include <linux/gpio.h>
  26. #ifdef CONFIG_HAS_EARLYSUSPEND
  27. #include <linux/earlysuspend.h>
  28. #endif
  29. #include <linux/wakelock.h>
  30. #include <linux/miscdevice.h>
  31. #include <linux/ssp_platformdata.h>
  32. #include <linux/delay.h>
  33. #include <linux/firmware.h>
  34. #include <linux/timer.h>
  35. #include <linux/list.h>
  36. #include <linux/rtc.h>
  37. #include <linux/regulator/consumer.h>
  38. #ifdef CONFIG_SENSORS_SSP_STM
  39. #include <linux/spi/spi.h>
  40. #endif
  41. #ifdef CONFIG_HAS_EARLYSUSPEND
  42. #undef CONFIG_HAS_EARLYSUSPEND
  43. #endif
  44. #ifdef CONFIG_SENSORS_SSP_SENSORHUB
  45. #include "ssp_sensorhub.h"
  46. #endif
  47. #define SSP_DBG 1
  48. #ifdef CONFIG_SEC_DEBUG
  49. #define SSP_SEC_DEBUG 1
  50. #else
  51. #define SSP_SEC_DEBUG 0
  52. #endif
  53. #define SUCCESS 1
  54. #define FAIL 0
  55. #define ERROR -1
  56. #define FACTORY_DATA_MAX 100
  57. #undef SAVE_MAG_LOG/* Magnetic sensor data logging flag */
  58. #ifdef SAVE_MAG_LOG/*normal mode = 0, logging mode = 1*/
  59. #define MAG_LOG_MODE 1
  60. #else
  61. #define MAG_LOG_MODE 0
  62. #endif
  63. #if SSP_DBG
  64. #define SSP_FUNC_DBG 1
  65. #define SSP_DATA_DBG 0
  66. /* ssp mcu device ID */
  67. #define DEVICE_ID 0x55
  68. #define MAXIM_MAX21103_REV 2
  69. #define ssp_dbg(dev, format, ...) do { \
  70. printk(KERN_INFO dev, format, ##__VA_ARGS__); \
  71. } while (0)
  72. #else
  73. #define ssp_dbg(dev, format, ...)
  74. #endif
  75. #if SSP_FUNC_DBG
  76. #define func_dbg() do { \
  77. printk(KERN_INFO "[SSP]: %s\n", __func__); \
  78. } while (0)
  79. #else
  80. #define func_dbg()
  81. #endif
  82. #if SSP_DATA_DBG
  83. #define data_dbg(dev, format, ...) do { \
  84. printk(KERN_INFO dev, format, ##__VA_ARGS__); \
  85. } while (0)
  86. #else
  87. #define data_dbg(dev, format, ...)
  88. #endif
  89. #define SSP_SW_RESET_TIME 3000
  90. #define DEFUALT_POLLING_DELAY (200 * NSEC_PER_MSEC)
  91. #define PROX_AVG_READ_NUM 80
  92. #define DEFAULT_RETRIES 3
  93. #define DATA_PACKET_SIZE 960
  94. /* SSP Binary Type */
  95. enum {
  96. KERNEL_BINARY = 0,
  97. KERNEL_CRASHED_BINARY,
  98. UMS_BINARY,
  99. };
  100. /*
  101. * SENSOR_DELAY_SET_STATE
  102. * Check delay set to avoid sending ADD instruction twice
  103. */
  104. enum {
  105. INITIALIZATION_STATE = 0,
  106. NO_SENSOR_STATE,
  107. ADD_SENSOR_STATE,
  108. RUNNING_SENSOR_STATE,
  109. };
  110. /* Firmware download STATE */
  111. enum {
  112. FW_DL_STATE_FAIL = -1,
  113. FW_DL_STATE_NONE = 0,
  114. FW_DL_STATE_NEED_TO_SCHEDULE,
  115. FW_DL_STATE_SCHEDULED,
  116. FW_DL_STATE_DOWNLOADING,
  117. FW_DL_STATE_SYNC,
  118. FW_DL_STATE_DONE,
  119. };
  120. /* for MSG2SSP_AP_GET_THERM */
  121. enum {
  122. ADC_BATT = 0,
  123. ADC_CHG,
  124. };
  125. enum {
  126. SENSORS_BATCH_DRY_RUN = 0x00000001,
  127. SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002
  128. };
  129. enum {
  130. META_DATA_FLUSH_COMPLETE = 1,
  131. };
  132. #define SSP_INVALID_REVISION 99999
  133. #define SSP_INVALID_REVISION2 0xFFFFFF
  134. /* Gyroscope DPS */
  135. #define GYROSCOPE_DPS250 250
  136. #define GYROSCOPE_DPS500 500
  137. #define GYROSCOPE_DPS2000 2000
  138. /* Gesture Sensor Current */
  139. #define DEFUALT_IR_CURRENT 100
  140. /* kernel -> ssp manager cmd*/
  141. #define SSP_LIBRARY_SLEEP_CMD (1 << 5)
  142. #define SSP_LIBRARY_LARGE_DATA_CMD (1 << 6)
  143. #define SSP_LIBRARY_WAKEUP_CMD (1 << 7)
  144. /* AP -> SSP Instruction */
  145. #define MSG2SSP_INST_BYPASS_SENSOR_ADD 0xA1
  146. #define MSG2SSP_INST_BYPASS_SENSOR_REMOVE 0xA2
  147. #define MSG2SSP_INST_REMOVE_ALL 0xA3
  148. #define MSG2SSP_INST_CHANGE_DELAY 0xA4
  149. #define MSG2SSP_INST_LIBRARY_ADD 0xB1
  150. #define MSG2SSP_INST_LIBRARY_REMOVE 0xB2
  151. #define MSG2SSP_INST_LIB_NOTI 0xB4
  152. #define MSG2SSP_INST_LIB_DATA 0xC1
  153. #define MSG2SSP_AP_MCU_SET_GYRO_CAL 0xCD
  154. #define MSG2SSP_AP_MCU_SET_ACCEL_CAL 0xCE
  155. #define MSG2SSP_AP_MCU_SET_MAGNETIC_CAL 0xCF
  156. #define MSG2SSP_AP_STATUS_SHUTDOWN 0xD0
  157. #define MSG2SSP_AP_STATUS_WAKEUP 0xD1
  158. #define MSG2SSP_AP_STATUS_SLEEP 0xD2
  159. #define MSG2SSP_AP_STATUS_RESUME 0xD3
  160. #define MSG2SSP_AP_STATUS_SUSPEND 0xD4
  161. #define MSG2SSP_AP_STATUS_RESET 0xD5
  162. #define MSG2SSP_AP_STATUS_POW_CONNECTED 0xD6
  163. #define MSG2SSP_AP_STATUS_POW_DISCONNECTED 0xD7
  164. #define MSG2SSP_AP_TEMPHUMIDITY_CAL_DONE 0xDA
  165. #define MSG2SSP_AP_MCU_SET_DUMPMODE 0xDB
  166. #define MSG2SSP_AP_MCU_DUMP_CHECK 0xDC
  167. #define MSG2SSP_AP_MCU_BATCH_FLUSH 0xDD
  168. #define MSG2SSP_AP_MCU_BATCH_COUNT 0xDF
  169. #define MSG2SSP_AP_WHOAMI 0x0F
  170. #define MSG2SSP_AP_FIRMWARE_REV 0xF0
  171. #define MSG2SSP_AP_SENSOR_FORMATION 0xF1
  172. #define MSG2SSP_AP_SENSOR_PROXTHRESHOLD 0xF2
  173. #define MSG2SSP_AP_SENSOR_BARCODE_EMUL 0xF3
  174. #define MSG2SSP_AP_SENSOR_SCANNING 0xF4
  175. #define MSG2SSP_AP_SET_MAGNETIC_HWOFFSET 0xF5
  176. #define MSG2SSP_AP_GET_MAGNETIC_HWOFFSET 0xF6
  177. #define MSG2SSP_AP_SENSOR_GESTURE_CURRENT 0xF7
  178. #define MSG2SSP_AP_GET_THERM 0xF8
  179. #define MSG2SSP_AP_GET_BIG_DATA 0xF9
  180. #define MSG2SSP_AP_SET_BIG_DATA 0xFA
  181. #define MSG2SSP_AP_START_BIG_DATA 0xFB
  182. #define MSG2SSP_AP_SET_MAGNETIC_STATIC_MATRIX 0xFD
  183. #define MSG2SSP_AP_SENSOR_TILT 0xEA
  184. #define MSG2SSP_AP_MCU_SET_TIME 0xFE
  185. #define MSG2SSP_AP_MCU_GET_TIME 0xFF
  186. #define MSG2SSP_AP_MOBEAM_DATA_SET 0x31
  187. #define MSG2SSP_AP_MOBEAM_REGISTER_SET 0x32
  188. #define MSG2SSP_AP_MOBEAM_COUNT_SET 0x33
  189. #define MSG2SSP_AP_MOBEAM_START 0x34
  190. #define MSG2SSP_AP_MOBEAM_STOP 0x35
  191. #define MSG2SSP_AP_FUSEROM 0X01
  192. /* voice data */
  193. #define TYPE_WAKE_UP_VOICE_SERVICE 0x01
  194. #define TYPE_WAKE_UP_VOICE_SOUND_SOURCE_AM 0x01
  195. #define TYPE_WAKE_UP_VOICE_SOUND_SOURCE_GRAMMER 0x02
  196. /* Factory Test */
  197. #define ACCELEROMETER_FACTORY 0x80
  198. #define GYROSCOPE_FACTORY 0x81
  199. #define GEOMAGNETIC_FACTORY 0x82
  200. #define PRESSURE_FACTORY 0x85
  201. #define GESTURE_FACTORY 0x86
  202. #define TEMPHUMIDITY_CRC_FACTORY 0x88
  203. #define GYROSCOPE_TEMP_FACTORY 0x8A
  204. #define GYROSCOPE_DPS_FACTORY 0x8B
  205. #define MCU_FACTORY 0x8C
  206. #define MCU_SLEEP_FACTORY 0x8D
  207. /* Factory data length */
  208. #define ACCEL_FACTORY_DATA_LENGTH 1
  209. #define GYRO_FACTORY_DATA_LENGTH 36
  210. #define MAGNETIC_FACTORY_DATA_LENGTH 26
  211. #define PRESSURE_FACTORY_DATA_LENGTH 1
  212. #define MCU_FACTORY_DATA_LENGTH 5
  213. #define GYRO_TEMP_FACTORY_DATA_LENGTH 2
  214. #define GYRO_DPS_FACTORY_DATA_LENGTH 1
  215. #define TEMPHUMIDITY_FACTORY_DATA_LENGTH 1
  216. #define MCU_SLEEP_FACTORY_DATA_LENGTH FACTORY_DATA_MAX
  217. #define GESTURE_FACTORY_DATA_LENGTH 4
  218. /* SSP -> AP ACK about write CMD */
  219. #define MSG_ACK 0x80 /* ACK from SSP to AP */
  220. #define MSG_NAK 0x70 /* NAK from SSP to AP */
  221. /* Accelerometer sensor */
  222. #define MAX_ACCEL_1G 16384
  223. #define MAX_ACCEL_2G 32767
  224. #define MIN_ACCEL_2G -32768
  225. #define MAX_ACCEL_4G 65536
  226. #define MAX_GYRO 32767
  227. #define MIN_GYRO -32768
  228. #define MAX_COMP_BUFF 60
  229. /* temphumidity sensor*/
  230. struct shtc1_buffer {
  231. u16 batt[MAX_COMP_BUFF];
  232. u16 chg[MAX_COMP_BUFF];
  233. s16 temp[MAX_COMP_BUFF];
  234. u16 humidity[MAX_COMP_BUFF];
  235. u16 baro[MAX_COMP_BUFF];
  236. u16 gyro[MAX_COMP_BUFF];
  237. char len;
  238. };
  239. /* SSP_INSTRUCTION_CMD */
  240. enum {
  241. REMOVE_SENSOR = 0,
  242. ADD_SENSOR,
  243. CHANGE_DELAY,
  244. GO_SLEEP,
  245. REMOVE_LIBRARY,
  246. ADD_LIBRARY,
  247. GET_LOGGING,
  248. };
  249. /* SENSOR_TYPE */
  250. enum {
  251. ACCELEROMETER_SENSOR = 0,
  252. GYROSCOPE_SENSOR,
  253. GEOMAGNETIC_UNCALIB_SENSOR,
  254. GEOMAGNETIC_RAW,
  255. GEOMAGNETIC_SENSOR,
  256. PRESSURE_SENSOR,
  257. GESTURE_SENSOR,
  258. PROXIMITY_SENSOR,
  259. TEMPERATURE_HUMIDITY_SENSOR,
  260. LIGHT_SENSOR,
  261. PROXIMITY_RAW,
  262. ORIENTATION_SENSOR,
  263. STEP_DETECTOR = 12,
  264. SIG_MOTION_SENSOR,
  265. GYRO_UNCALIB_SENSOR,
  266. GAME_ROTATION_VECTOR = 15,
  267. ROTATION_VECTOR,
  268. STEP_COUNTER,
  269. BIO_HRM_RAW,
  270. BIO_HRM_RAW_FAC,
  271. BIO_HRM_LIB,
  272. SHAKE_CAM = 22,
  273. SENSOR_MAX,
  274. };
  275. struct meta_data_event {
  276. s32 what;
  277. s32 sensor;
  278. } __attribute__((__packed__));
  279. struct sensor_value {
  280. union {
  281. struct {
  282. s16 x;
  283. s16 y;
  284. s16 z;
  285. };
  286. struct { /*calibrated mag, gyro*/
  287. s16 cal_x;
  288. s16 cal_y;
  289. s16 cal_z;
  290. u8 accuracy;
  291. };
  292. struct { /*uncalibrated mag, gyro*/
  293. s16 uncal_x;
  294. s16 uncal_y;
  295. s16 uncal_z;
  296. s16 offset_x;
  297. s16 offset_y;
  298. s16 offset_z;
  299. };
  300. struct { /* rotation vector */
  301. s32 quat_a;
  302. s32 quat_b;
  303. s32 quat_c;
  304. s32 quat_d;
  305. u8 acc_rot;
  306. };
  307. struct {
  308. u16 r;
  309. u16 g;
  310. u16 b;
  311. u16 w;
  312. #ifdef CONFIG_SENSORS_SSP_TMG399X
  313. u8 a_time;
  314. u8 a_gain;
  315. #else
  316. u16 ir_cmp;
  317. u16 amb_pga;
  318. #endif
  319. };
  320. u8 step_det;
  321. u8 sig_motion;
  322. u32 step_diff;
  323. #if defined (CONFIG_SENSORS_SSP_MAX88921)
  324. u16 prox[4];
  325. s16 data[19];
  326. #else
  327. u8 prox[4];
  328. u8 data[20];
  329. #endif
  330. s32 pressure[3];
  331. struct meta_data_event meta_data;
  332. #ifdef SAVE_MAG_LOG
  333. u8 log_data[20];
  334. #endif
  335. };
  336. u64 timestamp;
  337. } __attribute__((__packed__));
  338. extern struct class *sensors_event_class;
  339. extern int poweroff_charging;
  340. extern int boot_mode_recovery;
  341. struct calibraion_data {
  342. s16 x;
  343. s16 y;
  344. s16 z;
  345. };
  346. struct hw_offset_data {
  347. char x;
  348. char y;
  349. char z;
  350. };
  351. /* ssp_msg options bit*/
  352. #define SSP_SPI 0 /* read write mask */
  353. #define SSP_RETURN 2 /* write and read option */
  354. #define SSP_GYRO_DPS 3 /* gyro dps mask */
  355. #define SSP_INDEX 3 /* data index mask */
  356. #define SSP_SPI_MASK (3 << SSP_SPI) /* read write mask */
  357. #define SSP_GYRO_DPS_MASK (3 << SSP_GYRO_DPS)
  358. #define SSP_INDEX_MASK (8191 << SSP_INDEX) /* dump index mask. Index is up to 8191 */
  359. /* proximity sensor threshold */
  360. #if defined(CONFIG_SEC_PATEK_PROJECT)
  361. #define DEFUALT_HIGH_THRESHOLD 90
  362. #define DEFUALT_LOW_THRESHOLD 65
  363. #define TBD_HIGH_THRESHOLD 90
  364. #define TBD_LOW_THRESHOLD 65
  365. #define WHITE_HIGH_THRESHOLD 90
  366. #define WHITE_LOW_THRESHOLD 65
  367. #else
  368. #define DEFUALT_HIGH_THRESHOLD 130
  369. #define DEFUALT_LOW_THRESHOLD 90
  370. #define TBD_HIGH_THRESHOLD 130
  371. #define TBD_LOW_THRESHOLD 90
  372. #define WHITE_HIGH_THRESHOLD 130
  373. #define WHITE_LOW_THRESHOLD 90
  374. #endif
  375. #ifdef CONFIG_DUAL_LCD
  376. #define HALL_SENSOR_INT_GPIO 426
  377. #endif
  378. struct ssp_msg {
  379. u8 cmd;
  380. u16 length;
  381. u16 options;
  382. u32 data;
  383. struct list_head list;
  384. struct completion *done;
  385. char *buffer;
  386. u8 free_buffer;
  387. bool *dead_hook;
  388. bool dead;
  389. } __attribute__((__packed__));
  390. enum {
  391. AP2HUB_READ = 0,
  392. AP2HUB_WRITE,
  393. HUB2AP_WRITE,
  394. AP2HUB_READY,
  395. AP2HUB_RETURN
  396. };
  397. enum {
  398. BIG_TYPE_DUMP = 0,
  399. BIG_TYPE_READ_LIB,
  400. /*+snamy.jeong 0706 for voice model download & pcm dump*/
  401. BIG_TYPE_VOICE_NET,
  402. BIG_TYPE_VOICE_GRAM,
  403. BIG_TYPE_VOICE_PCM,
  404. /*-snamy.jeong 0706 for voice model download & pcm dump*/
  405. BIG_TYPE_TEMP,
  406. BIG_TYPE_MAX,
  407. };
  408. struct ssp_data {
  409. struct iio_dev *accel_indio_dev;
  410. struct iio_dev *gyro_indio_dev;
  411. struct iio_dev *rot_indio_dev;
  412. struct iio_dev *game_rot_indio_dev;
  413. struct iio_dev *step_det_indio_dev;
  414. struct iio_dev *pressure_indio_dev;
  415. struct iio_trigger *accel_trig;
  416. struct iio_trigger *gyro_trig;
  417. struct iio_trigger *rot_trig;
  418. struct iio_trigger *game_rot_trig;
  419. struct iio_trigger *step_det_trig;
  420. struct iio_trigger *pressure_det_trig;
  421. struct input_dev *light_input_dev;
  422. struct input_dev *prox_input_dev;
  423. struct input_dev *temp_humi_input_dev;
  424. struct input_dev *mag_input_dev;
  425. struct input_dev *uncal_mag_input_dev;
  426. struct input_dev *gesture_input_dev;
  427. struct input_dev *sig_motion_input_dev;
  428. struct input_dev *uncalib_gyro_input_dev;
  429. struct input_dev *step_cnt_input_dev;
  430. struct input_dev *meta_input_dev;
  431. #ifdef CONFIG_SENSORS_SSP_STM
  432. struct spi_device *spi;
  433. #endif
  434. struct i2c_client *client;
  435. struct wake_lock ssp_wake_lock;
  436. struct miscdevice akmd_device;
  437. struct timer_list debug_timer;
  438. struct workqueue_struct *debug_wq;
  439. struct work_struct work_debug;
  440. struct calibraion_data accelcal;
  441. struct calibraion_data gyrocal;
  442. struct hw_offset_data magoffset;
  443. struct sensor_value buf[SENSOR_MAX];
  444. struct device *sen_dev;
  445. struct device *mcu_device;
  446. struct device *acc_device;
  447. struct device *gyro_device;
  448. struct device *mag_device;
  449. struct device *prs_device;
  450. struct device *prox_device;
  451. struct device *light_device;
  452. struct device *ges_device;
  453. struct device *temphumidity_device;
  454. struct delayed_work work_firmware;
  455. struct delayed_work work_refresh;
  456. struct miscdevice shtc1_device;
  457. struct miscdevice batch_io_device;
  458. /*snamy.jeong@samsung.com temporary code for voice data sending to mcu*/
  459. struct device *voice_device;
  460. bool bSspShutdown;
  461. bool bAccelAlert;
  462. bool bProximityRawEnabled;
  463. bool bGeomagneticRawEnabled;
  464. bool bGeomagneticLogged;
  465. bool bBarcodeEnabled;
  466. bool bMcuDumpMode;
  467. bool bBinaryChashed;
  468. bool bProbeIsDone;
  469. bool bDumping;
  470. bool bTimeSyncing;
  471. unsigned int uProxCanc;
  472. unsigned int uCrosstalk;
  473. unsigned int uProxCalResult;
  474. unsigned int uProxHiThresh;
  475. unsigned int uProxLoThresh;
  476. unsigned int uProxHiThresh_default;
  477. unsigned int uProxLoThresh_default;
  478. unsigned int uIr_Current;
  479. unsigned char uFuseRomData[3];
  480. unsigned char uMagCntlRegData;
  481. char *pchLibraryBuf;
  482. char chLcdLdi[2];
  483. int iIrq;
  484. int iLibraryLength;
  485. int aiCheckStatus[SENSOR_MAX];
  486. unsigned int uComFailCnt;
  487. unsigned int uResetCnt;
  488. unsigned int uTimeOutCnt;
  489. unsigned int uIrqCnt;
  490. unsigned int uDumpCnt;
  491. int sealevelpressure;
  492. unsigned int uGyroDps;
  493. unsigned int uSensorState;
  494. unsigned int uCurFirmRev;
  495. unsigned int uFactoryProxAvg[4];
  496. char uLastResumeState;
  497. char uLastAPState;
  498. s32 iPressureCal;
  499. u64 step_count_total;
  500. atomic_t aSensorEnable;
  501. int64_t adDelayBuf[SENSOR_MAX];
  502. s32 batchLatencyBuf[SENSOR_MAX];
  503. s8 batchOptBuf[SENSOR_MAX];
  504. int (*wakeup_mcu)(void);
  505. int (*check_mcu_ready)(void);
  506. int (*check_mcu_busy)(void);
  507. int (*set_mcu_reset)(int);
  508. int (*read_chg)(void);
  509. void (*get_sensor_data[SENSOR_MAX])(char *, int *,
  510. struct sensor_value *);
  511. void (*report_sensor_data[SENSOR_MAX])(struct ssp_data *,
  512. struct sensor_value *);
  513. #ifdef CONFIG_HAS_EARLYSUSPEND
  514. struct early_suspend early_suspend;
  515. #endif
  516. #ifdef CONFIG_SENSORS_SSP_SENSORHUB
  517. struct ssp_sensorhub_data *hub_data;
  518. #endif
  519. int ap_rev;
  520. int ssp_changes;
  521. int accel_position;
  522. int mag_position;
  523. int fw_dl_state;
  524. u8 mag_matrix_size;
  525. u8 *mag_matrix;
  526. #ifdef CONFIG_SENSORS_SSP_SHTC1
  527. char *comp_engine_ver;
  528. char *comp_engine_ver2;
  529. struct mutex cp_temp_adc_lock;
  530. struct mutex bulk_temp_read_lock;
  531. struct shtc1_buffer* bulk_buffer;
  532. #endif
  533. #ifdef CONFIG_SENSORS_SSP_STM
  534. struct mutex comm_mutex;
  535. struct mutex pending_mutex;
  536. #endif
  537. int mcu_int1;
  538. int mcu_int2;
  539. int ap_int;
  540. int rst;
  541. int chg;
  542. struct regulator *reg_hub;
  543. struct regulator *reg_sns;
  544. u8 regulator_is_enable;
  545. const char *ges_vdd;
  546. const char *ges_led;
  547. struct list_head pending_list;
  548. void (*ssp_big_task[BIG_TYPE_MAX])(struct work_struct *);
  549. u64 timestamp;
  550. };
  551. struct ssp_big {
  552. struct ssp_data* data;
  553. struct work_struct work;
  554. u32 length;
  555. u32 addr;
  556. };
  557. int ssp_iio_configure_ring(struct iio_dev *);
  558. void ssp_iio_unconfigure_ring(struct iio_dev *);
  559. int ssp_iio_probe_trigger(struct ssp_data *, struct iio_dev *, struct iio_trigger *);
  560. void ssp_iio_remove_trigger(struct iio_trigger *);
  561. #ifdef CONFIG_SENSORS_SSP_MOBEAM
  562. struct reg_index_table {
  563. unsigned char reg;
  564. unsigned char index;
  565. };
  566. #endif
  567. void ssp_enable(struct ssp_data *, bool);
  568. int waiting_init_mcu(struct ssp_data *);
  569. int waiting_wakeup_mcu(struct ssp_data *);
  570. int ssp_i2c_read(struct ssp_data *, char *, u16, char *, u16, int);
  571. int ssp_spi_async(struct ssp_data *, struct ssp_msg *);
  572. int ssp_spi_sync(struct ssp_data *, struct ssp_msg *, int);
  573. void clean_pending_list(struct ssp_data *);
  574. void toggle_mcu_reset(struct ssp_data *);
  575. int initialize_mcu(struct ssp_data *);
  576. int initialize_input_dev(struct ssp_data *);
  577. int initialize_sysfs(struct ssp_data *);
  578. void initialize_accel_factorytest(struct ssp_data *);
  579. void initialize_prox_factorytest(struct ssp_data *);
  580. void initialize_light_factorytest(struct ssp_data *);
  581. void initialize_gyro_factorytest(struct ssp_data *);
  582. void initialize_pressure_factorytest(struct ssp_data *);
  583. void initialize_magnetic_factorytest(struct ssp_data *);
  584. void initialize_function_pointer(struct ssp_data *);
  585. void initialize_magnetic(struct ssp_data *);
  586. void initialize_gesture_factorytest(struct ssp_data *data);
  587. void initialize_temphumidity_factorytest(struct ssp_data *data);
  588. void remove_accel_factorytest(struct ssp_data *);
  589. void remove_gyro_factorytest(struct ssp_data *);
  590. void remove_prox_factorytest(struct ssp_data *);
  591. void remove_light_factorytest(struct ssp_data *);
  592. void remove_pressure_factorytest(struct ssp_data *);
  593. void remove_magnetic_factorytest(struct ssp_data *);
  594. void remove_gesture_factorytest(struct ssp_data *data);
  595. void remove_temphumidity_factorytest(struct ssp_data *data);
  596. #ifdef CONFIG_SENSORS_SSP_MOBEAM
  597. void initialize_mobeam(struct ssp_data *data);
  598. void remove_mobeam(struct ssp_data *data);
  599. #endif
  600. void destroy_sensor_class(void);
  601. int initialize_event_symlink(struct ssp_data *);
  602. int sensors_create_symlink(struct kobject *target,
  603. const char *name);
  604. int accel_open_calibration(struct ssp_data *);
  605. int gyro_open_calibration(struct ssp_data *);
  606. int pressure_open_calibration(struct ssp_data *);
  607. int proximity_open_calibration(struct ssp_data *);
  608. int check_fwbl(struct ssp_data *);
  609. void remove_input_dev(struct ssp_data *);
  610. void remove_sysfs(struct ssp_data *);
  611. void remove_event_symlink(struct ssp_data *);
  612. int ssp_send_cmd(struct ssp_data *, char, int);
  613. int send_instruction(struct ssp_data *, u8, u8, u8 *, u8);
  614. int send_instruction_sync(struct ssp_data *, u8, u8, u8 *, u8);
  615. int flush(struct ssp_data *, u8);
  616. int get_batch_count(struct ssp_data *, u8);
  617. int select_irq_msg(struct ssp_data *);
  618. int get_chipid(struct ssp_data *);
  619. int get_fuserom_data(struct ssp_data *);
  620. int set_big_data_start(struct ssp_data *, u8 , u32);
  621. int mag_open_hwoffset(struct ssp_data *);
  622. int mag_store_hwoffset(struct ssp_data *);
  623. int set_hw_offset(struct ssp_data *);
  624. int get_hw_offset(struct ssp_data *);
  625. int set_gyro_cal(struct ssp_data *);
  626. int set_accel_cal(struct ssp_data *);
  627. int set_sensor_position(struct ssp_data *);
  628. int set_magnetic_static_matrix(struct ssp_data *);
  629. void sync_sensor_state(struct ssp_data *);
  630. void set_proximity_threshold(struct ssp_data *, unsigned int, unsigned int);
  631. void set_proximity_barcode_enable(struct ssp_data *, bool);
  632. #ifdef CONFIG_DUAL_LCD
  633. void set_magnetic_cal_with_folder_state(struct ssp_data *, bool);
  634. int ssp_get_flip_status(void);
  635. void magnetic_set_ssp_info(struct ssp_data *data);
  636. #endif
  637. void set_gesture_current(struct ssp_data *, unsigned char);
  638. int get_msdelay(int64_t);
  639. unsigned int get_sensor_scanning_info(struct ssp_data *);
  640. unsigned int get_firmware_rev(struct ssp_data *);
  641. int forced_to_download_binary(struct ssp_data *, int);
  642. int parse_dataframe(struct ssp_data *, char *, int);
  643. void enable_debug_timer(struct ssp_data *);
  644. void disable_debug_timer(struct ssp_data *);
  645. int initialize_debug_timer(struct ssp_data *);
  646. int proximity_open_lcd_ldi(struct ssp_data *);
  647. void report_meta_data(struct ssp_data *, struct sensor_value *);
  648. void report_acc_data(struct ssp_data *, struct sensor_value *);
  649. void report_gyro_data(struct ssp_data *, struct sensor_value *);
  650. void report_mag_data(struct ssp_data *, struct sensor_value *);
  651. void report_mag_uncaldata(struct ssp_data *, struct sensor_value *);
  652. void report_rot_data(struct ssp_data *, struct sensor_value *);
  653. void report_game_rot_data(struct ssp_data *, struct sensor_value *);
  654. void report_step_det_data(struct ssp_data *, struct sensor_value *);
  655. void report_gesture_data(struct ssp_data *, struct sensor_value *);
  656. void report_pressure_data(struct ssp_data *, struct sensor_value *);
  657. void report_light_data(struct ssp_data *, struct sensor_value *);
  658. void report_prox_data(struct ssp_data *, struct sensor_value *);
  659. void report_prox_raw_data(struct ssp_data *, struct sensor_value *);
  660. void report_geomagnetic_raw_data(struct ssp_data *, struct sensor_value *);
  661. void report_sig_motion_data(struct ssp_data *, struct sensor_value *);
  662. void report_uncalib_gyro_data(struct ssp_data *, struct sensor_value *);
  663. void report_step_cnt_data(struct ssp_data *, struct sensor_value *);
  664. int print_mcu_debug(char *, int *, int);
  665. void report_temp_humidity_data(struct ssp_data *, struct sensor_value *);
  666. void report_shake_cam_data(struct ssp_data *, struct sensor_value *);
  667. void report_bulk_comp_data(struct ssp_data *data);
  668. unsigned int get_module_rev(struct ssp_data *data);
  669. void reset_mcu(struct ssp_data *);
  670. int queue_refresh_task(struct ssp_data *data, int delay);
  671. void convert_acc_data(s16 *);
  672. int sensors_register(struct device *, void *,
  673. struct device_attribute*[], char *);
  674. void sensors_unregister(struct device *,
  675. struct device_attribute*[]);
  676. ssize_t mcu_reset_show(struct device *, struct device_attribute *, char *);
  677. ssize_t mcu_dump_show(struct device *, struct device_attribute *, char *);
  678. ssize_t mcu_revision_show(struct device *, struct device_attribute *, char *);
  679. ssize_t mcu_update_ums_bin_show(struct device *,
  680. struct device_attribute *, char *);
  681. ssize_t mcu_update_kernel_bin_show(struct device *,
  682. struct device_attribute *, char *);
  683. ssize_t mcu_update_kernel_crashed_bin_show(struct device *,
  684. struct device_attribute *, char *);
  685. ssize_t mcu_factorytest_store(struct device *, struct device_attribute *,
  686. const char *, size_t);
  687. ssize_t mcu_factorytest_show(struct device *,
  688. struct device_attribute *, char *);
  689. ssize_t mcu_model_name_show(struct device *,
  690. struct device_attribute *, char *);
  691. ssize_t mcu_sleep_factorytest_show(struct device *,
  692. struct device_attribute *, char *);
  693. ssize_t mcu_sleep_factorytest_store(struct device *,
  694. struct device_attribute *, const char *, size_t);
  695. ssize_t mpu6500_gyro_selftest(char *, struct ssp_data *);
  696. ssize_t k330_gyro_selftest(char *, struct ssp_data *);
  697. void ssp_dump_task(struct work_struct *work);
  698. void ssp_read_big_library_task(struct work_struct *work);
  699. void ssp_send_big_library_task(struct work_struct *work);
  700. void ssp_pcm_dump_task(struct work_struct *work);
  701. void ssp_temp_task(struct work_struct *work);
  702. int set_time(struct ssp_data *);
  703. int get_time(struct ssp_data *);
  704. #endif