smscoreapi.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /****************************************************************
  2. Siano Mobile Silicon, Inc.
  3. MDTV receiver kernel modules.
  4. Copyright (C) 2006-2008, Uri Shkolnik, Anatoly Greenblat
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ****************************************************************/
  16. #ifndef __SMS_CORE_API_H__
  17. #define __SMS_CORE_API_H__
  18. #include <linux/version.h>
  19. #include <linux/device.h>
  20. #include <linux/list.h>
  21. #include <linux/mm.h>
  22. #include <linux/scatterlist.h>
  23. #include <linux/types.h>
  24. #include <linux/mutex.h>
  25. #include <linux/wait.h>
  26. #include <linux/timer.h>
  27. #include <asm/page.h>
  28. #define kmutex_init(_p_) mutex_init(_p_)
  29. #define kmutex_lock(_p_) mutex_lock(_p_)
  30. #define kmutex_trylock(_p_) mutex_trylock(_p_)
  31. #define kmutex_unlock(_p_) mutex_unlock(_p_)
  32. #ifndef min
  33. #define min(a, b) (((a) < (b)) ? (a) : (b))
  34. #endif
  35. #define SMS_PROTOCOL_MAX_RAOUNDTRIP_MS (10000)
  36. #define SMS_ALLOC_ALIGNMENT 128
  37. #define SMS_DMA_ALIGNMENT 16
  38. #define SMS_ALIGN_ADDRESS(addr) \
  39. ((((uintptr_t)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1))
  40. #define SMS_DEVICE_FAMILY2 1
  41. #define SMS_ROM_NO_RESPONSE 2
  42. #define SMS_DEVICE_NOT_READY 0x8000000
  43. enum sms_device_type_st {
  44. SMS_STELLAR = 0,
  45. SMS_NOVA_A0,
  46. SMS_NOVA_B0,
  47. SMS_VEGA,
  48. SMS_NUM_OF_DEVICE_TYPES
  49. };
  50. struct smscore_device_t;
  51. struct smscore_client_t;
  52. struct smscore_buffer_t;
  53. typedef int (*hotplug_t)(struct smscore_device_t *coredev,
  54. struct device *device, int arrival);
  55. typedef int (*setmode_t)(void *context, int mode);
  56. typedef void (*detectmode_t)(void *context, int *mode);
  57. typedef int (*sendrequest_t)(void *context, void *buffer, size_t size);
  58. typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size);
  59. typedef int (*preload_t)(void *context);
  60. typedef int (*postload_t)(void *context);
  61. typedef int (*onresponse_t)(void *context, struct smscore_buffer_t *cb);
  62. typedef void (*onremove_t)(void *context);
  63. struct smscore_buffer_t {
  64. /* public members, once passed to clients can be changed freely */
  65. struct list_head entry;
  66. int size;
  67. int offset;
  68. /* private members, read-only for clients */
  69. void *p;
  70. dma_addr_t phys;
  71. unsigned long offset_in_common;
  72. };
  73. struct smsdevice_params_t {
  74. struct device *device;
  75. int buffer_size;
  76. int num_buffers;
  77. char devpath[32];
  78. unsigned long flags;
  79. setmode_t setmode_handler;
  80. detectmode_t detectmode_handler;
  81. sendrequest_t sendrequest_handler;
  82. preload_t preload_handler;
  83. postload_t postload_handler;
  84. void *context;
  85. enum sms_device_type_st device_type;
  86. };
  87. struct smsclient_params_t {
  88. int initial_id;
  89. int data_type;
  90. onresponse_t onresponse_handler;
  91. onremove_t onremove_handler;
  92. void *context;
  93. };
  94. struct smscore_device_t {
  95. struct list_head entry;
  96. struct list_head clients;
  97. struct list_head subclients;
  98. spinlock_t clientslock;
  99. struct list_head buffers;
  100. spinlock_t bufferslock;
  101. int num_buffers;
  102. void *common_buffer;
  103. int common_buffer_size;
  104. dma_addr_t common_buffer_phys;
  105. void *context;
  106. struct device *device;
  107. char devpath[32];
  108. unsigned long device_flags;
  109. setmode_t setmode_handler;
  110. detectmode_t detectmode_handler;
  111. sendrequest_t sendrequest_handler;
  112. preload_t preload_handler;
  113. postload_t postload_handler;
  114. int mode, modes_supported;
  115. /* host <--> device messages */
  116. struct completion version_ex_done, data_download_done, trigger_done;
  117. struct completion init_device_done, reload_start_done, resume_done;
  118. struct completion gpio_configuration_done, gpio_set_level_done;
  119. struct completion gpio_get_level_done, ir_init_done;
  120. /* Buffer management */
  121. wait_queue_head_t buffer_mng_waitq;
  122. /* GPIO */
  123. int gpio_get_res;
  124. /* Target hardware board */
  125. int board_id;
  126. /* Firmware */
  127. u8 *fw_buf;
  128. u32 fw_buf_size;
  129. /* Infrared (IR) */
  130. /* struct ir_t ir; */
  131. int led_state;
  132. };
  133. /* GPIO definitions for antenna frequency domain control (SMS8021) */
  134. #define SMS_ANTENNA_GPIO_0 1
  135. #define SMS_ANTENNA_GPIO_1 0
  136. #define BW_8_MHZ 0
  137. #define BW_7_MHZ 1
  138. #define BW_6_MHZ 2
  139. #define BW_5_MHZ 3
  140. #define BW_ISDBT_1SEG 4
  141. #define BW_ISDBT_3SEG 5
  142. #define MSG_HDR_FLAG_SPLIT_MSG 4
  143. #define MAX_GPIO_PIN_NUMBER 31
  144. #define HIF_TASK 11
  145. #define SMS_HOST_LIB 150
  146. #define DVBT_BDA_CONTROL_MSG_ID 201
  147. #define SMS_MAX_PAYLOAD_SIZE 240
  148. #define SMS_TUNE_TIMEOUT 500
  149. #define MSG_SMS_GPIO_CONFIG_REQ 507
  150. #define MSG_SMS_GPIO_CONFIG_RES 508
  151. #define MSG_SMS_GPIO_SET_LEVEL_REQ 509
  152. #define MSG_SMS_GPIO_SET_LEVEL_RES 510
  153. #define MSG_SMS_GPIO_GET_LEVEL_REQ 511
  154. #define MSG_SMS_GPIO_GET_LEVEL_RES 512
  155. #define MSG_SMS_RF_TUNE_REQ 561
  156. #define MSG_SMS_RF_TUNE_RES 562
  157. #define MSG_SMS_INIT_DEVICE_REQ 578
  158. #define MSG_SMS_INIT_DEVICE_RES 579
  159. #define MSG_SMS_ADD_PID_FILTER_REQ 601
  160. #define MSG_SMS_ADD_PID_FILTER_RES 602
  161. #define MSG_SMS_REMOVE_PID_FILTER_REQ 603
  162. #define MSG_SMS_REMOVE_PID_FILTER_RES 604
  163. #define MSG_SMS_DAB_CHANNEL 607
  164. #define MSG_SMS_GET_PID_FILTER_LIST_REQ 608
  165. #define MSG_SMS_GET_PID_FILTER_LIST_RES 609
  166. #define MSG_SMS_HO_PER_SLICES_IND 630
  167. #define MSG_SMS_SET_ANTENNA_CONFIG_REQ 651
  168. #define MSG_SMS_SET_ANTENNA_CONFIG_RES 652
  169. #define MSG_SMS_SLEEP_RESUME_COMP_IND 655
  170. #define MSG_SMS_DATA_DOWNLOAD_REQ 660
  171. #define MSG_SMS_DATA_DOWNLOAD_RES 661
  172. #define MSG_SMS_SWDOWNLOAD_TRIGGER_REQ 664
  173. #define MSG_SMS_SWDOWNLOAD_TRIGGER_RES 665
  174. #define MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ 666
  175. #define MSG_SMS_SWDOWNLOAD_BACKDOOR_RES 667
  176. #define MSG_SMS_GET_VERSION_EX_REQ 668
  177. #define MSG_SMS_GET_VERSION_EX_RES 669
  178. #define MSG_SMS_SET_CLOCK_OUTPUT_REQ 670
  179. #define MSG_SMS_I2C_SET_FREQ_REQ 685
  180. #define MSG_SMS_GENERIC_I2C_REQ 687
  181. #define MSG_SMS_GENERIC_I2C_RES 688
  182. #define MSG_SMS_DVBT_BDA_DATA 693
  183. #define MSG_SW_RELOAD_REQ 697
  184. #define MSG_SMS_DATA_MSG 699
  185. #define MSG_SW_RELOAD_START_REQ 702
  186. #define MSG_SW_RELOAD_START_RES 703
  187. #define MSG_SW_RELOAD_EXEC_REQ 704
  188. #define MSG_SW_RELOAD_EXEC_RES 705
  189. #define MSG_SMS_SPI_INT_LINE_SET_REQ 710
  190. #define MSG_SMS_GPIO_CONFIG_EX_REQ 712
  191. #define MSG_SMS_GPIO_CONFIG_EX_RES 713
  192. #define MSG_SMS_ISDBT_TUNE_REQ 776
  193. #define MSG_SMS_ISDBT_TUNE_RES 777
  194. #define MSG_SMS_TRANSMISSION_IND 782
  195. #define MSG_SMS_START_IR_REQ 800
  196. #define MSG_SMS_START_IR_RES 801
  197. #define MSG_SMS_IR_SAMPLES_IND 802
  198. #define MSG_SMS_SIGNAL_DETECTED_IND 827
  199. #define MSG_SMS_NO_SIGNAL_IND 828
  200. #define SMS_INIT_MSG_EX(ptr, type, src, dst, len) do { \
  201. (ptr)->msgType = type; (ptr)->msgSrcId = src; (ptr)->msgDstId = dst; \
  202. (ptr)->msgLength = len; (ptr)->msgFlags = 0; \
  203. } while (0)
  204. #define SMS_INIT_MSG(ptr, type, len) \
  205. SMS_INIT_MSG_EX(ptr, type, 0, HIF_TASK, len)
  206. enum SMS_DVB3_EVENTS {
  207. DVB3_EVENT_INIT = 0,
  208. DVB3_EVENT_SLEEP,
  209. DVB3_EVENT_HOTPLUG,
  210. DVB3_EVENT_FE_LOCK,
  211. DVB3_EVENT_FE_UNLOCK,
  212. DVB3_EVENT_UNC_OK,
  213. DVB3_EVENT_UNC_ERR
  214. };
  215. enum SMS_DEVICE_MODE {
  216. DEVICE_MODE_NONE = -1,
  217. DEVICE_MODE_DVBT = 0,
  218. DEVICE_MODE_DVBH,
  219. DEVICE_MODE_DAB_TDMB,
  220. DEVICE_MODE_DAB_TDMB_DABIP,
  221. DEVICE_MODE_DVBT_BDA,
  222. DEVICE_MODE_ISDBT,
  223. DEVICE_MODE_ISDBT_BDA,
  224. DEVICE_MODE_CMMB,
  225. DEVICE_MODE_RAW_TUNER,
  226. DEVICE_MODE_MAX,
  227. };
  228. struct SmsMsgHdr_ST {
  229. u16 msgType;
  230. u8 msgSrcId;
  231. u8 msgDstId;
  232. u16 msgLength; /* Length of entire message, including header */
  233. u16 msgFlags;
  234. };
  235. struct SmsMsgData_ST {
  236. struct SmsMsgHdr_ST xMsgHeader;
  237. u32 msgData[1];
  238. };
  239. struct SmsMsgData_ST2 {
  240. struct SmsMsgHdr_ST xMsgHeader;
  241. u32 msgData[2];
  242. };
  243. struct SmsDataDownload_ST {
  244. struct SmsMsgHdr_ST xMsgHeader;
  245. u32 MemAddr;
  246. u8 Payload[SMS_MAX_PAYLOAD_SIZE];
  247. };
  248. struct SmsVersionRes_ST {
  249. struct SmsMsgHdr_ST xMsgHeader;
  250. u16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */
  251. u8 Step; /* 0 - Step A */
  252. u8 MetalFix; /* 0 - Metal 0 */
  253. /* FirmwareId 0xFF if ROM, otherwise the
  254. * value indicated by SMSHOSTLIB_DEVICE_MODES_E */
  255. u8 FirmwareId;
  256. /* SupportedProtocols Bitwise OR combination of
  257. * supported protocols */
  258. u8 SupportedProtocols;
  259. u8 VersionMajor;
  260. u8 VersionMinor;
  261. u8 VersionPatch;
  262. u8 VersionFieldPatch;
  263. u8 RomVersionMajor;
  264. u8 RomVersionMinor;
  265. u8 RomVersionPatch;
  266. u8 RomVersionFieldPatch;
  267. u8 TextLabel[34];
  268. };
  269. struct SmsFirmware_ST {
  270. u32 CheckSum;
  271. u32 Length;
  272. u32 StartAddress;
  273. u8 Payload[1];
  274. };
  275. /* Statistics information returned as response for
  276. * SmsHostApiGetStatistics_Req */
  277. struct SMSHOSTLIB_STATISTICS_S {
  278. u32 Reserved; /* Reserved */
  279. /* Common parameters */
  280. u32 IsRfLocked; /* 0 - not locked, 1 - locked */
  281. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  282. u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
  283. /* Reception quality */
  284. s32 SNR; /* dB */
  285. u32 BER; /* Post Viterbi BER [1E-5] */
  286. u32 FIB_CRC; /* CRC errors percentage, valid only for DAB */
  287. u32 TS_PER; /* Transport stream PER,
  288. 0xFFFFFFFF indicate N/A, valid only for DVB-T/H */
  289. u32 MFER; /* DVB-H frame error rate in percentage,
  290. 0xFFFFFFFF indicate N/A, valid only for DVB-H */
  291. s32 RSSI; /* dBm */
  292. s32 InBandPwr; /* In band power in dBM */
  293. s32 CarrierOffset; /* Carrier Offset in bin/1024 */
  294. /* Transmission parameters */
  295. u32 Frequency; /* Frequency in Hz */
  296. u32 Bandwidth; /* Bandwidth in MHz, valid only for DVB-T/H */
  297. u32 TransmissionMode; /* Transmission Mode, for DAB modes 1-4,
  298. for DVB-T/H FFT mode carriers in Kilos */
  299. u32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET,
  300. valid only for DVB-T/H */
  301. u32 GuardInterval; /* Guard Interval from
  302. SMSHOSTLIB_GUARD_INTERVALS_ET, valid only for DVB-T/H */
  303. u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET,
  304. valid only for DVB-T/H */
  305. u32 LPCodeRate; /* Low Priority Code Rate from
  306. SMSHOSTLIB_CODE_RATE_ET, valid only for DVB-T/H */
  307. u32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET,
  308. valid only for DVB-T/H */
  309. u32 Constellation; /* Constellation from
  310. SMSHOSTLIB_CONSTELLATION_ET, valid only for DVB-T/H */
  311. /* Burst parameters, valid only for DVB-H */
  312. u32 BurstSize; /* Current burst size in bytes,
  313. valid only for DVB-H */
  314. u32 BurstDuration; /* Current burst duration in mSec,
  315. valid only for DVB-H */
  316. u32 BurstCycleTime; /* Current burst cycle time in mSec,
  317. valid only for DVB-H */
  318. u32 CalculatedBurstCycleTime;/* Current burst cycle time in mSec,
  319. as calculated by demodulator, valid only for DVB-H */
  320. u32 NumOfRows; /* Number of rows in MPE table,
  321. valid only for DVB-H */
  322. u32 NumOfPaddCols; /* Number of padding columns in MPE table,
  323. valid only for DVB-H */
  324. u32 NumOfPunctCols; /* Number of puncturing columns in MPE table,
  325. valid only for DVB-H */
  326. u32 ErrorTSPackets; /* Number of erroneous
  327. transport-stream packets */
  328. u32 TotalTSPackets; /* Total number of transport-stream packets */
  329. u32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include
  330. errors after MPE RS decoding */
  331. u32 NumOfInvalidMpeTlbs;/* Number of MPE tables which include errors
  332. after MPE RS decoding */
  333. u32 NumOfCorrectedMpeTlbs;/* Number of MPE tables which were
  334. corrected by MPE RS decoding */
  335. /* Common params */
  336. u32 BERErrorCount; /* Number of errornous SYNC bits. */
  337. u32 BERBitCount; /* Total number of SYNC bits. */
  338. /* Interface information */
  339. u32 SmsToHostTxErrors; /* Total number of transmission errors. */
  340. /* DAB/T-DMB */
  341. u32 PreBER; /* DAB/T-DMB only: Pre Viterbi BER [1E-5] */
  342. /* DVB-H TPS parameters */
  343. u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
  344. if set to 0xFFFFFFFF cell_id not yet recovered */
  345. u32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 -
  346. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  347. u32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 -
  348. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  349. u32 NumMPEReceived; /* DVB-H, Num MPE section received */
  350. u32 ReservedFields[10]; /* Reserved */
  351. };
  352. struct PID_STATISTICS_DATA_S {
  353. struct PID_BURST_S {
  354. u32 size;
  355. u32 padding_cols;
  356. u32 punct_cols;
  357. u32 duration;
  358. u32 cycle;
  359. u32 calc_cycle;
  360. } burst;
  361. u32 tot_tbl_cnt;
  362. u32 invalid_tbl_cnt;
  363. u32 tot_cor_tbl;
  364. };
  365. struct PID_DATA_S {
  366. u32 pid;
  367. u32 num_rows;
  368. struct PID_STATISTICS_DATA_S pid_statistics;
  369. };
  370. #define CORRECT_STAT_RSSI(_stat) ((_stat).RSSI *= -1)
  371. #define CORRECT_STAT_BANDWIDTH(_stat) (_stat.Bandwidth = 8 - _stat.Bandwidth)
  372. #define CORRECT_STAT_TRANSMISSON_MODE(_stat) \
  373. if (_stat.TransmissionMode == 0) \
  374. _stat.TransmissionMode = 2; \
  375. else if (_stat.TransmissionMode == 1) \
  376. _stat.TransmissionMode = 8; \
  377. else \
  378. _stat.TransmissionMode = 4;
  379. struct TRANSMISSION_STATISTICS_S {
  380. u32 Frequency; /* Frequency in Hz */
  381. u32 Bandwidth; /* Bandwidth in MHz */
  382. u32 TransmissionMode; /* FFT mode carriers in Kilos */
  383. u32 GuardInterval; /* Guard Interval from
  384. SMSHOSTLIB_GUARD_INTERVALS_ET */
  385. u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET */
  386. u32 LPCodeRate; /* Low Priority Code Rate from
  387. SMSHOSTLIB_CODE_RATE_ET */
  388. u32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET */
  389. u32 Constellation; /* Constellation from
  390. SMSHOSTLIB_CONSTELLATION_ET */
  391. /* DVB-H TPS parameters */
  392. u32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero;
  393. if set to 0xFFFFFFFF cell_id not yet recovered */
  394. u32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 -
  395. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  396. u32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 -
  397. Time Slicing indicator, bit 0 - MPE-FEC indicator */
  398. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  399. };
  400. struct RECEPTION_STATISTICS_S {
  401. u32 IsRfLocked; /* 0 - not locked, 1 - locked */
  402. u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
  403. u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
  404. u32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
  405. s32 SNR; /* dB */
  406. u32 BER; /* Post Viterbi BER [1E-5] */
  407. u32 BERErrorCount; /* Number of erronous SYNC bits. */
  408. u32 BERBitCount; /* Total number of SYNC bits. */
  409. u32 TS_PER; /* Transport stream PER,
  410. 0xFFFFFFFF indicate N/A */
  411. u32 MFER; /* DVB-H frame error rate in percentage,
  412. 0xFFFFFFFF indicate N/A, valid only for DVB-H */
  413. s32 RSSI; /* dBm */
  414. s32 InBandPwr; /* In band power in dBM */
  415. s32 CarrierOffset; /* Carrier Offset in bin/1024 */
  416. u32 ErrorTSPackets; /* Number of erroneous
  417. transport-stream packets */
  418. u32 TotalTSPackets; /* Total number of transport-stream packets */
  419. s32 MRC_SNR; /* dB */
  420. s32 MRC_RSSI; /* dBm */
  421. s32 MRC_InBandPwr; /* In band power in dBM */
  422. };
  423. /* Statistics information returned as response for
  424. * SmsHostApiGetStatisticsEx_Req for DVB applications, SMS1100 and up */
  425. struct SMSHOSTLIB_STATISTICS_DVB_S {
  426. /* Reception */
  427. struct RECEPTION_STATISTICS_S ReceptionData;
  428. /* Transmission parameters */
  429. struct TRANSMISSION_STATISTICS_S TransmissionData;
  430. /* Burst parameters, valid only for DVB-H */
  431. #define SRVM_MAX_PID_FILTERS 8
  432. struct PID_DATA_S PidData[SRVM_MAX_PID_FILTERS];
  433. };
  434. struct SRVM_SIGNAL_STATUS_S {
  435. u32 result;
  436. u32 snr;
  437. u32 tsPackets;
  438. u32 etsPackets;
  439. u32 constellation;
  440. u32 hpCode;
  441. u32 tpsSrvIndLP;
  442. u32 tpsSrvIndHP;
  443. u32 cellId;
  444. u32 reason;
  445. s32 inBandPower;
  446. u32 requestId;
  447. };
  448. struct SMSHOSTLIB_I2C_REQ_ST {
  449. u32 DeviceAddress; /* I2c device address */
  450. u32 WriteCount; /* number of bytes to write */
  451. u32 ReadCount; /* number of bytes to read */
  452. u8 Data[1];
  453. };
  454. struct SMSHOSTLIB_I2C_RES_ST {
  455. u32 Status; /* non-zero value in case of failure */
  456. u32 ReadCount; /* number of bytes read */
  457. u8 Data[1];
  458. };
  459. struct smscore_gpio_config {
  460. #define SMS_GPIO_DIRECTION_INPUT 0
  461. #define SMS_GPIO_DIRECTION_OUTPUT 1
  462. u8 direction;
  463. #define SMS_GPIO_PULLUPDOWN_NONE 0
  464. #define SMS_GPIO_PULLUPDOWN_PULLDOWN 1
  465. #define SMS_GPIO_PULLUPDOWN_PULLUP 2
  466. #define SMS_GPIO_PULLUPDOWN_KEEPER 3
  467. u8 pullupdown;
  468. #define SMS_GPIO_INPUTCHARACTERISTICS_NORMAL 0
  469. #define SMS_GPIO_INPUTCHARACTERISTICS_SCHMITT 1
  470. u8 inputcharacteristics;
  471. #define SMS_GPIO_OUTPUTSLEWRATE_FAST 0
  472. #define SMS_GPIO_OUTPUTSLEWRATE_SLOW 1
  473. u8 outputslewrate;
  474. #define SMS_GPIO_OUTPUTDRIVING_4mA 0
  475. #define SMS_GPIO_OUTPUTDRIVING_8mA 1
  476. #define SMS_GPIO_OUTPUTDRIVING_12mA 2
  477. #define SMS_GPIO_OUTPUTDRIVING_16mA 3
  478. u8 outputdriving;
  479. };
  480. extern void smscore_registry_setmode(char *devpath, int mode);
  481. extern int smscore_registry_getmode(char *devpath);
  482. extern int smscore_register_hotplug(hotplug_t hotplug);
  483. extern void smscore_unregister_hotplug(hotplug_t hotplug);
  484. extern int smscore_register_device(struct smsdevice_params_t *params,
  485. struct smscore_device_t **coredev);
  486. extern void smscore_unregister_device(struct smscore_device_t *coredev);
  487. extern int smscore_start_device(struct smscore_device_t *coredev);
  488. extern int smscore_load_firmware(struct smscore_device_t *coredev,
  489. char *filename,
  490. loadfirmware_t loadfirmware_handler);
  491. extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode);
  492. extern int smscore_get_device_mode(struct smscore_device_t *coredev);
  493. extern int smscore_register_client(struct smscore_device_t *coredev,
  494. struct smsclient_params_t *params,
  495. struct smscore_client_t **client);
  496. extern void smscore_unregister_client(struct smscore_client_t *client);
  497. extern int smsclient_sendrequest(struct smscore_client_t *client,
  498. void *buffer, size_t size);
  499. extern void smscore_onresponse(struct smscore_device_t *coredev,
  500. struct smscore_buffer_t *cb);
  501. extern int smscore_get_common_buffer_size(struct smscore_device_t *coredev);
  502. extern int smscore_map_common_buffer(struct smscore_device_t *coredev,
  503. struct vm_area_struct *vma);
  504. extern int smscore_get_fw_filename(struct smscore_device_t *coredev,
  505. int mode, char *filename);
  506. extern int smscore_send_fw_file(struct smscore_device_t *coredev,
  507. u8 *ufwbuf, int size);
  508. extern
  509. struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev);
  510. extern void smscore_putbuffer(struct smscore_device_t *coredev,
  511. struct smscore_buffer_t *cb);
  512. int smscore_configure_gpio(struct smscore_device_t *coredev, u32 pin,
  513. struct smscore_gpio_config *pinconfig);
  514. int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level);
  515. void smscore_set_board_id(struct smscore_device_t *core, int id);
  516. int smscore_get_board_id(struct smscore_device_t *core);
  517. int smscore_led_state(struct smscore_device_t *core, int led);
  518. /* ------------------------------------------------------------------------ */
  519. #define DBG_INFO 1
  520. #define DBG_ADV 2
  521. #define sms_printk(kern, fmt, arg...) \
  522. printk(kern "%s: " fmt "\n", __func__, ##arg)
  523. #define dprintk(kern, lvl, fmt, arg...) do {\
  524. if (sms_dbg & lvl) \
  525. sms_printk(kern, fmt, ##arg); } while (0)
  526. #define sms_log(fmt, arg...) sms_printk(KERN_INFO, fmt, ##arg)
  527. #define sms_err(fmt, arg...) \
  528. sms_printk(KERN_ERR, "line: %d: " fmt, __LINE__, ##arg)
  529. #define sms_warn(fmt, arg...) sms_printk(KERN_WARNING, fmt, ##arg)
  530. #define sms_info(fmt, arg...) \
  531. dprintk(KERN_INFO, DBG_INFO, fmt, ##arg)
  532. #define sms_debug(fmt, arg...) \
  533. dprintk(KERN_DEBUG, DBG_ADV, fmt, ##arg)
  534. #endif /* __SMS_CORE_API_H__ */