ssp.h 23 KB

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