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