ssp.h 20 KB

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