1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "smscoreapi.h"
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/dma-mapping.h>
27#include <linux/delay.h>
28#include <linux/io.h>
29#include <linux/slab.h>
30
31#include <linux/firmware.h>
32#include <linux/wait.h>
33#include <asm/byteorder.h>
34
35#include "sms-cards.h"
36#include "smsir.h"
37
38struct smscore_device_notifyee_t {
39 struct list_head entry;
40 hotplug_t hotplug;
41};
42
43struct smscore_idlist_t {
44 struct list_head entry;
45 int id;
46 int data_type;
47};
48
49struct smscore_client_t {
50 struct list_head entry;
51 struct smscore_device_t *coredev;
52 void *context;
53 struct list_head idlist;
54 onresponse_t onresponse_handler;
55 onremove_t onremove_handler;
56};
57
58static char *siano_msgs[] = {
59 [MSG_TYPE_BASE_VAL - MSG_TYPE_BASE_VAL] = "MSG_TYPE_BASE_VAL",
60 [MSG_SMS_GET_VERSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_REQ",
61 [MSG_SMS_GET_VERSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_RES",
62 [MSG_SMS_MULTI_BRIDGE_CFG - MSG_TYPE_BASE_VAL] = "MSG_SMS_MULTI_BRIDGE_CFG",
63 [MSG_SMS_GPIO_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_REQ",
64 [MSG_SMS_GPIO_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_RES",
65 [MSG_SMS_GPIO_SET_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_REQ",
66 [MSG_SMS_GPIO_SET_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_RES",
67 [MSG_SMS_GPIO_GET_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_REQ",
68 [MSG_SMS_GPIO_GET_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_RES",
69 [MSG_SMS_EEPROM_BURN_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_BURN_IND",
70 [MSG_SMS_LOG_ENABLE_CHANGE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_REQ",
71 [MSG_SMS_LOG_ENABLE_CHANGE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_RES",
72 [MSG_SMS_SET_MAX_TX_MSG_LEN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_REQ",
73 [MSG_SMS_SET_MAX_TX_MSG_LEN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_RES",
74 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE",
75 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST",
76 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ",
77 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES",
78 [MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND",
79 [MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND",
80 [MSG_SMS_CONFIGURE_RF_SWITCH_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_REQ",
81 [MSG_SMS_CONFIGURE_RF_SWITCH_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_RES",
82 [MSG_SMS_MRC_PATH_DISCONNECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_REQ",
83 [MSG_SMS_MRC_PATH_DISCONNECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_RES",
84 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ",
85 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES",
86 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ",
87 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES",
88 [MSG_WR_REG_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_REQ",
89 [MSG_WR_REG_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_RES",
90 [MSG_RD_REG_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_REQ",
91 [MSG_RD_REG_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_RES",
92 [MSG_RD_REG_ALL_RFT_REQ - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_REQ",
93 [MSG_RD_REG_ALL_RFT_RES - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_RES",
94 [MSG_HELP_INT - MSG_TYPE_BASE_VAL] = "MSG_HELP_INT",
95 [MSG_RUN_SCRIPT_INT - MSG_TYPE_BASE_VAL] = "MSG_RUN_SCRIPT_INT",
96 [MSG_SMS_EWS_INBAND_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_REQ",
97 [MSG_SMS_EWS_INBAND_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_RES",
98 [MSG_SMS_RFS_SELECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_REQ",
99 [MSG_SMS_RFS_SELECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_RES",
100 [MSG_SMS_MB_GET_VER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_REQ",
101 [MSG_SMS_MB_GET_VER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_RES",
102 [MSG_SMS_MB_WRITE_CFGFILE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_REQ",
103 [MSG_SMS_MB_WRITE_CFGFILE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_RES",
104 [MSG_SMS_MB_READ_CFGFILE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_REQ",
105 [MSG_SMS_MB_READ_CFGFILE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_RES",
106 [MSG_SMS_RD_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_REQ",
107 [MSG_SMS_RD_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_RES",
108 [MSG_SMS_WR_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_REQ",
109 [MSG_SMS_WR_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_RES",
110 [MSG_SMS_UPDATE_MEM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_REQ",
111 [MSG_SMS_UPDATE_MEM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_RES",
112 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ",
113 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES",
114 [MSG_SMS_RF_TUNE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_REQ",
115 [MSG_SMS_RF_TUNE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_RES",
116 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ",
117 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES",
118 [MSG_SMS_ISDBT_SB_RECEPTION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_REQ",
119 [MSG_SMS_ISDBT_SB_RECEPTION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_RES",
120 [MSG_SMS_GENERIC_EPROM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_REQ",
121 [MSG_SMS_GENERIC_EPROM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_RES",
122 [MSG_SMS_GENERIC_EPROM_READ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_REQ",
123 [MSG_SMS_GENERIC_EPROM_READ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_RES",
124 [MSG_SMS_EEPROM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_REQ",
125 [MSG_SMS_EEPROM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_RES",
126 [MSG_SMS_CUSTOM_READ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_REQ",
127 [MSG_SMS_CUSTOM_READ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_RES",
128 [MSG_SMS_CUSTOM_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_REQ",
129 [MSG_SMS_CUSTOM_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_RES",
130 [MSG_SMS_INIT_DEVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_REQ",
131 [MSG_SMS_INIT_DEVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_RES",
132 [MSG_SMS_ATSC_SET_ALL_IP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_REQ",
133 [MSG_SMS_ATSC_SET_ALL_IP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_RES",
134 [MSG_SMS_ATSC_START_ENSEMBLE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_REQ",
135 [MSG_SMS_ATSC_START_ENSEMBLE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_RES",
136 [MSG_SMS_SET_OUTPUT_MODE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_REQ",
137 [MSG_SMS_SET_OUTPUT_MODE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_RES",
138 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ",
139 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES",
140 [MSG_SMS_SUB_CHANNEL_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_REQ",
141 [MSG_SMS_SUB_CHANNEL_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_RES",
142 [MSG_SMS_SUB_CHANNEL_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_REQ",
143 [MSG_SMS_SUB_CHANNEL_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_RES",
144 [MSG_SMS_ATSC_IP_FILTER_ADD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_REQ",
145 [MSG_SMS_ATSC_IP_FILTER_ADD_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_RES",
146 [MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ",
147 [MSG_SMS_ATSC_IP_FILTER_REMOVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_RES",
148 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ",
149 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES",
150 [MSG_SMS_WAIT_CMD - MSG_TYPE_BASE_VAL] = "MSG_SMS_WAIT_CMD",
151 [MSG_SMS_ADD_PID_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_REQ",
152 [MSG_SMS_ADD_PID_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_RES",
153 [MSG_SMS_REMOVE_PID_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_REQ",
154 [MSG_SMS_REMOVE_PID_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_RES",
155 [MSG_SMS_FAST_INFORMATION_CHANNEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_REQ",
156 [MSG_SMS_FAST_INFORMATION_CHANNEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_RES",
157 [MSG_SMS_DAB_CHANNEL - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_CHANNEL",
158 [MSG_SMS_GET_PID_FILTER_LIST_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_REQ",
159 [MSG_SMS_GET_PID_FILTER_LIST_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_RES",
160 [MSG_SMS_POWER_DOWN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_REQ",
161 [MSG_SMS_POWER_DOWN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_RES",
162 [MSG_SMS_ATSC_SLT_EXIST_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SLT_EXIST_IND",
163 [MSG_SMS_ATSC_NO_SLT_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_NO_SLT_IND",
164 [MSG_SMS_GET_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_REQ",
165 [MSG_SMS_GET_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_RES",
166 [MSG_SMS_SEND_DUMP - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_DUMP",
167 [MSG_SMS_SCAN_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_REQ",
168 [MSG_SMS_SCAN_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_RES",
169 [MSG_SMS_SCAN_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_REQ",
170 [MSG_SMS_SCAN_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_RES",
171 [MSG_SMS_SCAN_PROGRESS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_PROGRESS_IND",
172 [MSG_SMS_SCAN_COMPLETE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_COMPLETE_IND",
173 [MSG_SMS_LOG_ITEM - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ITEM",
174 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ",
175 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES",
176 [MSG_SMS_HO_PER_SLICES_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PER_SLICES_IND",
177 [MSG_SMS_HO_INBAND_POWER_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_INBAND_POWER_IND",
178 [MSG_SMS_MANUAL_DEMOD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MANUAL_DEMOD_REQ",
179 [MSG_SMS_HO_TUNE_ON_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_REQ",
180 [MSG_SMS_HO_TUNE_ON_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_RES",
181 [MSG_SMS_HO_TUNE_OFF_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_REQ",
182 [MSG_SMS_HO_TUNE_OFF_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_RES",
183 [MSG_SMS_HO_PEEK_FREQ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_REQ",
184 [MSG_SMS_HO_PEEK_FREQ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_RES",
185 [MSG_SMS_HO_PEEK_FREQ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_IND",
186 [MSG_SMS_MB_ATTEN_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_REQ",
187 [MSG_SMS_MB_ATTEN_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_RES",
188 [MSG_SMS_ENABLE_STAT_IN_I2C_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_REQ",
189 [MSG_SMS_ENABLE_STAT_IN_I2C_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_RES",
190 [MSG_SMS_SET_ANTENNA_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_REQ",
191 [MSG_SMS_SET_ANTENNA_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_RES",
192 [MSG_SMS_GET_STATISTICS_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_REQ",
193 [MSG_SMS_GET_STATISTICS_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_RES",
194 [MSG_SMS_SLEEP_RESUME_COMP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLEEP_RESUME_COMP_IND",
195 [MSG_SMS_SWITCH_HOST_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_REQ",
196 [MSG_SMS_SWITCH_HOST_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_RES",
197 [MSG_SMS_DATA_DOWNLOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_REQ",
198 [MSG_SMS_DATA_DOWNLOAD_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_RES",
199 [MSG_SMS_DATA_VALIDITY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_REQ",
200 [MSG_SMS_DATA_VALIDITY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_RES",
201 [MSG_SMS_SWDOWNLOAD_TRIGGER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_REQ",
202 [MSG_SMS_SWDOWNLOAD_TRIGGER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_RES",
203 [MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ",
204 [MSG_SMS_SWDOWNLOAD_BACKDOOR_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_RES",
205 [MSG_SMS_GET_VERSION_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_REQ",
206 [MSG_SMS_GET_VERSION_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_RES",
207 [MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ",
208 [MSG_SMS_CLOCK_OUTPUT_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_RES",
209 [MSG_SMS_I2C_SET_FREQ_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_REQ",
210 [MSG_SMS_I2C_SET_FREQ_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_RES",
211 [MSG_SMS_GENERIC_I2C_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_REQ",
212 [MSG_SMS_GENERIC_I2C_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_RES",
213 [MSG_SMS_DVBT_BDA_DATA - MSG_TYPE_BASE_VAL] = "MSG_SMS_DVBT_BDA_DATA",
214 [MSG_SW_RELOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_REQ",
215 [MSG_SMS_DATA_MSG - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_MSG",
216 [MSG_TABLE_UPLOAD_REQ - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_REQ",
217 [MSG_TABLE_UPLOAD_RES - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_RES",
218 [MSG_SW_RELOAD_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_REQ",
219 [MSG_SW_RELOAD_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_RES",
220 [MSG_SW_RELOAD_EXEC_REQ - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_REQ",
221 [MSG_SW_RELOAD_EXEC_RES - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_RES",
222 [MSG_SMS_SPI_INT_LINE_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_REQ",
223 [MSG_SMS_SPI_INT_LINE_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_RES",
224 [MSG_SMS_GPIO_CONFIG_EX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_REQ",
225 [MSG_SMS_GPIO_CONFIG_EX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_RES",
226 [MSG_SMS_WATCHDOG_ACT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_REQ",
227 [MSG_SMS_WATCHDOG_ACT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_RES",
228 [MSG_SMS_LOOPBACK_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_REQ",
229 [MSG_SMS_LOOPBACK_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_RES",
230 [MSG_SMS_RAW_CAPTURE_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_REQ",
231 [MSG_SMS_RAW_CAPTURE_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_RES",
232 [MSG_SMS_RAW_CAPTURE_ABORT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_REQ",
233 [MSG_SMS_RAW_CAPTURE_ABORT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_RES",
234 [MSG_SMS_RAW_CAPTURE_COMPLETE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_COMPLETE_IND",
235 [MSG_SMS_DATA_PUMP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_IND",
236 [MSG_SMS_DATA_PUMP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_REQ",
237 [MSG_SMS_DATA_PUMP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_RES",
238 [MSG_SMS_FLASH_DL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_FLASH_DL_REQ",
239 [MSG_SMS_EXEC_TEST_1_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_REQ",
240 [MSG_SMS_EXEC_TEST_1_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_RES",
241 [MSG_SMS_ENBALE_TS_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_REQ",
242 [MSG_SMS_ENBALE_TS_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_RES",
243 [MSG_SMS_SPI_SET_BUS_WIDTH_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_REQ",
244 [MSG_SMS_SPI_SET_BUS_WIDTH_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_RES",
245 [MSG_SMS_SEND_EMM_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_REQ",
246 [MSG_SMS_SEND_EMM_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_RES",
247 [MSG_SMS_DISABLE_TS_INTERFACE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_REQ",
248 [MSG_SMS_DISABLE_TS_INTERFACE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_RES",
249 [MSG_SMS_IS_BUF_FREE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_REQ",
250 [MSG_SMS_IS_BUF_FREE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_RES",
251 [MSG_SMS_EXT_ANTENNA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_REQ",
252 [MSG_SMS_EXT_ANTENNA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_RES",
253 [MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE",
254 [MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE",
255 [MSG_SMS_BATTERY_LEVEL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_REQ",
256 [MSG_SMS_BATTERY_LEVEL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_RES",
257 [MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE",
258 [MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE",
259 [MSG_SMS_FM_RADIO_BLOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_FM_RADIO_BLOCK_IND",
260 [MSG_SMS_HOST_NOTIFICATION_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_HOST_NOTIFICATION_IND",
261 [MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE",
262 [MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE",
263 [MSG_SMS_CMMB_GET_NETWORKS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_REQ",
264 [MSG_SMS_CMMB_GET_NETWORKS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_RES",
265 [MSG_SMS_CMMB_START_SERVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_REQ",
266 [MSG_SMS_CMMB_START_SERVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_RES",
267 [MSG_SMS_CMMB_STOP_SERVICE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_REQ",
268 [MSG_SMS_CMMB_STOP_SERVICE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_RES",
269 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ",
270 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES",
271 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ",
272 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES",
273 [MSG_SMS_CMMB_START_CONTROL_INFO_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_REQ",
274 [MSG_SMS_CMMB_START_CONTROL_INFO_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_RES",
275 [MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ",
276 [MSG_SMS_CMMB_STOP_CONTROL_INFO_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_RES",
277 [MSG_SMS_ISDBT_TUNE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_REQ",
278 [MSG_SMS_ISDBT_TUNE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_RES",
279 [MSG_SMS_TRANSMISSION_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_TRANSMISSION_IND",
280 [MSG_SMS_PID_STATISTICS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_PID_STATISTICS_IND",
281 [MSG_SMS_POWER_DOWN_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_IND",
282 [MSG_SMS_POWER_DOWN_CONF - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_CONF",
283 [MSG_SMS_POWER_UP_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_IND",
284 [MSG_SMS_POWER_UP_CONF - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_CONF",
285 [MSG_SMS_POWER_MODE_SET_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_REQ",
286 [MSG_SMS_POWER_MODE_SET_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_RES",
287 [MSG_SMS_DEBUG_HOST_EVENT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_REQ",
288 [MSG_SMS_DEBUG_HOST_EVENT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_RES",
289 [MSG_SMS_NEW_CRYSTAL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_REQ",
290 [MSG_SMS_NEW_CRYSTAL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_RES",
291 [MSG_SMS_CONFIG_SPI_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_REQ",
292 [MSG_SMS_CONFIG_SPI_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_RES",
293 [MSG_SMS_I2C_SHORT_STAT_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SHORT_STAT_IND",
294 [MSG_SMS_START_IR_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_REQ",
295 [MSG_SMS_START_IR_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_RES",
296 [MSG_SMS_IR_SAMPLES_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_IR_SAMPLES_IND",
297 [MSG_SMS_CMMB_CA_SERVICE_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_CA_SERVICE_IND",
298 [MSG_SMS_SLAVE_DEVICE_DETECTED - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLAVE_DEVICE_DETECTED",
299 [MSG_SMS_INTERFACE_LOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_LOCK_IND",
300 [MSG_SMS_INTERFACE_UNLOCK_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_UNLOCK_IND",
301 [MSG_SMS_SEND_ROSUM_BUFF_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_REQ",
302 [MSG_SMS_SEND_ROSUM_BUFF_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_RES",
303 [MSG_SMS_ROSUM_BUFF - MSG_TYPE_BASE_VAL] = "MSG_SMS_ROSUM_BUFF",
304 [MSG_SMS_SET_AES128_KEY_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_REQ",
305 [MSG_SMS_SET_AES128_KEY_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_RES",
306 [MSG_SMS_MBBMS_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_REQ",
307 [MSG_SMS_MBBMS_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_RES",
308 [MSG_SMS_MBBMS_READ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_READ_IND",
309 [MSG_SMS_IQ_STREAM_START_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_REQ",
310 [MSG_SMS_IQ_STREAM_START_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_RES",
311 [MSG_SMS_IQ_STREAM_STOP_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_REQ",
312 [MSG_SMS_IQ_STREAM_STOP_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_RES",
313 [MSG_SMS_IQ_STREAM_DATA_BLOCK - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_DATA_BLOCK",
314 [MSG_SMS_GET_EEPROM_VERSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_REQ",
315 [MSG_SMS_GET_EEPROM_VERSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_RES",
316 [MSG_SMS_SIGNAL_DETECTED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SIGNAL_DETECTED_IND",
317 [MSG_SMS_NO_SIGNAL_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_NO_SIGNAL_IND",
318 [MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ",
319 [MSG_SMS_MRC_SHUTDOWN_SLAVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_RES",
320 [MSG_SMS_MRC_BRINGUP_SLAVE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_REQ",
321 [MSG_SMS_MRC_BRINGUP_SLAVE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_RES",
322 [MSG_SMS_EXTERNAL_LNA_CTRL_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_REQ",
323 [MSG_SMS_EXTERNAL_LNA_CTRL_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_RES",
324 [MSG_SMS_SET_PERIODIC_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_REQ",
325 [MSG_SMS_SET_PERIODIC_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_RES",
326 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ",
327 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES",
328 [LOCAL_TUNE - MSG_TYPE_BASE_VAL] = "LOCAL_TUNE",
329 [LOCAL_IFFT_H_ICI - MSG_TYPE_BASE_VAL] = "LOCAL_IFFT_H_ICI",
330 [MSG_RESYNC_REQ - MSG_TYPE_BASE_VAL] = "MSG_RESYNC_REQ",
331 [MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ",
332 [MSG_SMS_CMMB_GET_MRC_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_RES",
333 [MSG_SMS_LOG_EX_ITEM - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_EX_ITEM",
334 [MSG_SMS_DEVICE_DATA_LOSS_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEVICE_DATA_LOSS_IND",
335 [MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND",
336 [MSG_SMS_USER_MSG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_REQ",
337 [MSG_SMS_USER_MSG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_RES",
338 [MSG_SMS_SMART_CARD_INIT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_REQ",
339 [MSG_SMS_SMART_CARD_INIT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_RES",
340 [MSG_SMS_SMART_CARD_WRITE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_REQ",
341 [MSG_SMS_SMART_CARD_WRITE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_RES",
342 [MSG_SMS_SMART_CARD_READ_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_READ_IND",
343 [MSG_SMS_TSE_ENABLE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_REQ",
344 [MSG_SMS_TSE_ENABLE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_RES",
345 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ",
346 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES",
347 [MSG_SMS_LED_CONFIG_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_REQ",
348 [MSG_SMS_LED_CONFIG_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_RES",
349 [MSG_PWM_ANTENNA_REQ - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_REQ",
350 [MSG_PWM_ANTENNA_RES - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_RES",
351 [MSG_SMS_CMMB_SMD_SN_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_REQ",
352 [MSG_SMS_CMMB_SMD_SN_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_RES",
353 [MSG_SMS_CMMB_SET_CA_CW_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_REQ",
354 [MSG_SMS_CMMB_SET_CA_CW_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_RES",
355 [MSG_SMS_CMMB_SET_CA_SALT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_REQ",
356 [MSG_SMS_CMMB_SET_CA_SALT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_RES",
357 [MSG_SMS_NSCD_INIT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_REQ",
358 [MSG_SMS_NSCD_INIT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_RES",
359 [MSG_SMS_NSCD_PROCESS_SECTION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_REQ",
360 [MSG_SMS_NSCD_PROCESS_SECTION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_RES",
361 [MSG_SMS_DBD_CREATE_OBJECT_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_REQ",
362 [MSG_SMS_DBD_CREATE_OBJECT_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_RES",
363 [MSG_SMS_DBD_CONFIGURE_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_REQ",
364 [MSG_SMS_DBD_CONFIGURE_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_RES",
365 [MSG_SMS_DBD_SET_KEYS_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_REQ",
366 [MSG_SMS_DBD_SET_KEYS_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_RES",
367 [MSG_SMS_DBD_PROCESS_HEADER_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_REQ",
368 [MSG_SMS_DBD_PROCESS_HEADER_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_RES",
369 [MSG_SMS_DBD_PROCESS_DATA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_REQ",
370 [MSG_SMS_DBD_PROCESS_DATA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_RES",
371 [MSG_SMS_DBD_PROCESS_GET_DATA_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_REQ",
372 [MSG_SMS_DBD_PROCESS_GET_DATA_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_RES",
373 [MSG_SMS_NSCD_OPEN_SESSION_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_REQ",
374 [MSG_SMS_NSCD_OPEN_SESSION_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_RES",
375 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ",
376 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES",
377 [MSG_LAST_MSG_TYPE - MSG_TYPE_BASE_VAL] = "MSG_LAST_MSG_TYPE",
378};
379
380char *smscore_translate_msg(enum msg_types msgtype)
381{
382 int i = msgtype - MSG_TYPE_BASE_VAL;
383 char *msg;
384
385 if (i < 0 || i >= ARRAY_SIZE(siano_msgs))
386 return "Unknown msg type";
387
388 msg = siano_msgs[i];
389
390 if (!*msg)
391 return "Unknown msg type";
392
393 return msg;
394}
395EXPORT_SYMBOL_GPL(smscore_translate_msg);
396
397void smscore_set_board_id(struct smscore_device_t *core, int id)
398{
399 core->board_id = id;
400}
401
402int smscore_led_state(struct smscore_device_t *core, int led)
403{
404 if (led >= 0)
405 core->led_state = led;
406 return core->led_state;
407}
408EXPORT_SYMBOL_GPL(smscore_set_board_id);
409
410int smscore_get_board_id(struct smscore_device_t *core)
411{
412 return core->board_id;
413}
414EXPORT_SYMBOL_GPL(smscore_get_board_id);
415
416struct smscore_registry_entry_t {
417 struct list_head entry;
418 char devpath[32];
419 int mode;
420 enum sms_device_type_st type;
421};
422
423static struct list_head g_smscore_notifyees;
424static struct list_head g_smscore_devices;
425static struct mutex g_smscore_deviceslock;
426
427static struct list_head g_smscore_registry;
428static struct mutex g_smscore_registrylock;
429
430static int default_mode = DEVICE_MODE_NONE;
431
432module_param(default_mode, int, 0644);
433MODULE_PARM_DESC(default_mode, "default firmware id (device mode)");
434
435static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
436{
437 struct smscore_registry_entry_t *entry;
438 struct list_head *next;
439
440 kmutex_lock(&g_smscore_registrylock);
441 for (next = g_smscore_registry.next;
442 next != &g_smscore_registry;
443 next = next->next) {
444 entry = (struct smscore_registry_entry_t *) next;
445 if (!strcmp(entry->devpath, devpath)) {
446 kmutex_unlock(&g_smscore_registrylock);
447 return entry;
448 }
449 }
450 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
451 if (entry) {
452 entry->mode = default_mode;
453 strcpy(entry->devpath, devpath);
454 list_add(&entry->entry, &g_smscore_registry);
455 } else
456 pr_err("failed to create smscore_registry.\n");
457 kmutex_unlock(&g_smscore_registrylock);
458 return entry;
459}
460
461int smscore_registry_getmode(char *devpath)
462{
463 struct smscore_registry_entry_t *entry;
464
465 entry = smscore_find_registry(devpath);
466 if (entry)
467 return entry->mode;
468 else
469 pr_err("No registry found.\n");
470
471 return default_mode;
472}
473EXPORT_SYMBOL_GPL(smscore_registry_getmode);
474
475static enum sms_device_type_st smscore_registry_gettype(char *devpath)
476{
477 struct smscore_registry_entry_t *entry;
478
479 entry = smscore_find_registry(devpath);
480 if (entry)
481 return entry->type;
482 else
483 pr_err("No registry found.\n");
484
485 return -EINVAL;
486}
487
488static void smscore_registry_setmode(char *devpath, int mode)
489{
490 struct smscore_registry_entry_t *entry;
491
492 entry = smscore_find_registry(devpath);
493 if (entry)
494 entry->mode = mode;
495 else
496 pr_err("No registry found.\n");
497}
498
499static void smscore_registry_settype(char *devpath,
500 enum sms_device_type_st type)
501{
502 struct smscore_registry_entry_t *entry;
503
504 entry = smscore_find_registry(devpath);
505 if (entry)
506 entry->type = type;
507 else
508 pr_err("No registry found.\n");
509}
510
511
512static void list_add_locked(struct list_head *new, struct list_head *head,
513 spinlock_t *lock)
514{
515 unsigned long flags;
516
517 spin_lock_irqsave(lock, flags);
518
519 list_add(new, head);
520
521 spin_unlock_irqrestore(lock, flags);
522}
523
524
525
526
527
528
529
530
531
532int smscore_register_hotplug(hotplug_t hotplug)
533{
534 struct smscore_device_notifyee_t *notifyee;
535 struct list_head *next, *first;
536 int rc = 0;
537
538 kmutex_lock(&g_smscore_deviceslock);
539 notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
540 if (notifyee) {
541
542 first = &g_smscore_devices;
543 for (next = first->next;
544 next != first && !rc;
545 next = next->next) {
546 struct smscore_device_t *coredev =
547 (struct smscore_device_t *) next;
548 rc = hotplug(coredev, coredev->device, 1);
549 }
550
551 if (rc >= 0) {
552 notifyee->hotplug = hotplug;
553 list_add(¬ifyee->entry, &g_smscore_notifyees);
554 } else
555 kfree(notifyee);
556 } else
557 rc = -ENOMEM;
558
559 kmutex_unlock(&g_smscore_deviceslock);
560
561 return rc;
562}
563EXPORT_SYMBOL_GPL(smscore_register_hotplug);
564
565
566
567
568
569
570
571void smscore_unregister_hotplug(hotplug_t hotplug)
572{
573 struct list_head *next, *first;
574
575 kmutex_lock(&g_smscore_deviceslock);
576
577 first = &g_smscore_notifyees;
578
579 for (next = first->next; next != first;) {
580 struct smscore_device_notifyee_t *notifyee =
581 (struct smscore_device_notifyee_t *) next;
582 next = next->next;
583
584 if (notifyee->hotplug == hotplug) {
585 list_del(¬ifyee->entry);
586 kfree(notifyee);
587 }
588 }
589
590 kmutex_unlock(&g_smscore_deviceslock);
591}
592EXPORT_SYMBOL_GPL(smscore_unregister_hotplug);
593
594static void smscore_notify_clients(struct smscore_device_t *coredev)
595{
596 struct smscore_client_t *client;
597
598
599 while (!list_empty(&coredev->clients)) {
600 client = (struct smscore_client_t *) coredev->clients.next;
601 client->onremove_handler(client->context);
602 }
603}
604
605static int smscore_notify_callbacks(struct smscore_device_t *coredev,
606 struct device *device, int arrival)
607{
608 struct smscore_device_notifyee_t *elem;
609 int rc = 0;
610
611
612
613 list_for_each_entry(elem, &g_smscore_notifyees, entry) {
614 rc = elem->hotplug(coredev, device, arrival);
615 if (rc < 0)
616 break;
617 }
618
619 return rc;
620}
621
622static struct
623smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
624 dma_addr_t common_buffer_phys)
625{
626 struct smscore_buffer_t *cb;
627
628 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
629 if (!cb)
630 return NULL;
631
632 cb->p = buffer;
633 cb->offset_in_common = buffer - (u8 *) common_buffer;
634 if (common_buffer_phys)
635 cb->phys = common_buffer_phys + cb->offset_in_common;
636
637 return cb;
638}
639
640
641
642
643
644
645
646
647
648
649
650int smscore_register_device(struct smsdevice_params_t *params,
651 struct smscore_device_t **coredev,
652 void *mdev)
653{
654 struct smscore_device_t *dev;
655 u8 *buffer;
656
657 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
658 if (!dev)
659 return -ENOMEM;
660
661#ifdef CONFIG_MEDIA_CONTROLLER_DVB
662 dev->media_dev = mdev;
663#endif
664
665
666 INIT_LIST_HEAD(&dev->entry);
667
668
669 INIT_LIST_HEAD(&dev->clients);
670 INIT_LIST_HEAD(&dev->buffers);
671
672
673 spin_lock_init(&dev->clientslock);
674 spin_lock_init(&dev->bufferslock);
675
676
677 init_completion(&dev->version_ex_done);
678 init_completion(&dev->data_download_done);
679 init_completion(&dev->data_validity_done);
680 init_completion(&dev->trigger_done);
681 init_completion(&dev->init_device_done);
682 init_completion(&dev->reload_start_done);
683 init_completion(&dev->resume_done);
684 init_completion(&dev->gpio_configuration_done);
685 init_completion(&dev->gpio_set_level_done);
686 init_completion(&dev->gpio_get_level_done);
687 init_completion(&dev->ir_init_done);
688
689
690 init_waitqueue_head(&dev->buffer_mng_waitq);
691
692
693 dev->common_buffer_size = params->buffer_size * params->num_buffers;
694 if (params->usb_device)
695 buffer = kzalloc(dev->common_buffer_size, GFP_KERNEL);
696 else
697 buffer = dma_alloc_coherent(params->device,
698 dev->common_buffer_size,
699 &dev->common_buffer_phys,
700 GFP_KERNEL | GFP_DMA);
701 if (!buffer) {
702 smscore_unregister_device(dev);
703 return -ENOMEM;
704 }
705 dev->common_buffer = buffer;
706
707
708 for (; dev->num_buffers < params->num_buffers;
709 dev->num_buffers++, buffer += params->buffer_size) {
710 struct smscore_buffer_t *cb;
711
712 cb = smscore_createbuffer(buffer, dev->common_buffer,
713 dev->common_buffer_phys);
714 if (!cb) {
715 smscore_unregister_device(dev);
716 return -ENOMEM;
717 }
718
719 smscore_putbuffer(dev, cb);
720 }
721
722 pr_debug("allocated %d buffers\n", dev->num_buffers);
723
724 dev->mode = DEVICE_MODE_NONE;
725 dev->board_id = SMS_BOARD_UNKNOWN;
726 dev->context = params->context;
727 dev->device = params->device;
728 dev->usb_device = params->usb_device;
729 dev->setmode_handler = params->setmode_handler;
730 dev->detectmode_handler = params->detectmode_handler;
731 dev->sendrequest_handler = params->sendrequest_handler;
732 dev->preload_handler = params->preload_handler;
733 dev->postload_handler = params->postload_handler;
734
735 dev->device_flags = params->flags;
736 strcpy(dev->devpath, params->devpath);
737
738 smscore_registry_settype(dev->devpath, params->device_type);
739
740
741 kmutex_lock(&g_smscore_deviceslock);
742 list_add(&dev->entry, &g_smscore_devices);
743 kmutex_unlock(&g_smscore_deviceslock);
744
745 *coredev = dev;
746
747 pr_debug("device %p created\n", dev);
748
749 return 0;
750}
751EXPORT_SYMBOL_GPL(smscore_register_device);
752
753
754static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
755 void *buffer, size_t size, struct completion *completion) {
756 int rc;
757
758 if (!completion)
759 return -EINVAL;
760 init_completion(completion);
761
762 rc = coredev->sendrequest_handler(coredev->context, buffer, size);
763 if (rc < 0) {
764 pr_info("sendrequest returned error %d\n", rc);
765 return rc;
766 }
767
768 return wait_for_completion_timeout(completion,
769 msecs_to_jiffies(SMS_PROTOCOL_MAX_RAOUNDTRIP_MS)) ?
770 0 : -ETIME;
771}
772
773
774
775
776
777
778static int smscore_init_ir(struct smscore_device_t *coredev)
779{
780 int ir_io;
781 int rc;
782 void *buffer;
783
784 coredev->ir.dev = NULL;
785 ir_io = sms_get_board(smscore_get_board_id(coredev))->board_cfg.ir;
786 if (ir_io) {
787 pr_debug("IR loading\n");
788 rc = sms_ir_init(coredev);
789
790 if (rc != 0)
791 pr_err("Error initialization DTV IR sub-module\n");
792 else {
793 buffer = kmalloc(sizeof(struct sms_msg_data2) +
794 SMS_DMA_ALIGNMENT,
795 GFP_KERNEL | GFP_DMA);
796 if (buffer) {
797 struct sms_msg_data2 *msg =
798 (struct sms_msg_data2 *)
799 SMS_ALIGN_ADDRESS(buffer);
800
801 SMS_INIT_MSG(&msg->x_msg_header,
802 MSG_SMS_START_IR_REQ,
803 sizeof(struct sms_msg_data2));
804 msg->msg_data[0] = coredev->ir.controller;
805 msg->msg_data[1] = coredev->ir.timeout;
806
807 rc = smscore_sendrequest_and_wait(coredev, msg,
808 msg->x_msg_header. msg_length,
809 &coredev->ir_init_done);
810
811 kfree(buffer);
812 } else
813 pr_err("Sending IR initialization message failed\n");
814 }
815 } else
816 pr_info("IR port has not been detected\n");
817
818 return 0;
819}
820
821
822
823
824
825
826
827
828
829static int smscore_configure_board(struct smscore_device_t *coredev)
830{
831 struct sms_board *board;
832
833 board = sms_get_board(coredev->board_id);
834 if (!board) {
835 pr_err("no board configuration exist.\n");
836 return -EINVAL;
837 }
838
839 if (board->mtu) {
840 struct sms_msg_data mtu_msg;
841 pr_debug("set max transmit unit %d\n", board->mtu);
842
843 mtu_msg.x_msg_header.msg_src_id = 0;
844 mtu_msg.x_msg_header.msg_dst_id = HIF_TASK;
845 mtu_msg.x_msg_header.msg_flags = 0;
846 mtu_msg.x_msg_header.msg_type = MSG_SMS_SET_MAX_TX_MSG_LEN_REQ;
847 mtu_msg.x_msg_header.msg_length = sizeof(mtu_msg);
848 mtu_msg.msg_data[0] = board->mtu;
849
850 coredev->sendrequest_handler(coredev->context, &mtu_msg,
851 sizeof(mtu_msg));
852 }
853
854 if (board->crystal) {
855 struct sms_msg_data crys_msg;
856 pr_debug("set crystal value %d\n", board->crystal);
857
858 SMS_INIT_MSG(&crys_msg.x_msg_header,
859 MSG_SMS_NEW_CRYSTAL_REQ,
860 sizeof(crys_msg));
861 crys_msg.msg_data[0] = board->crystal;
862
863 coredev->sendrequest_handler(coredev->context, &crys_msg,
864 sizeof(crys_msg));
865 }
866
867 return 0;
868}
869
870
871
872
873
874
875
876
877
878int smscore_start_device(struct smscore_device_t *coredev)
879{
880 int rc;
881 int board_id = smscore_get_board_id(coredev);
882 int mode = smscore_registry_getmode(coredev->devpath);
883
884
885 if (board_id != SMS_BOARD_UNKNOWN && mode == DEVICE_MODE_NONE)
886 mode = sms_get_board(board_id)->default_mode;
887
888 rc = smscore_set_device_mode(coredev, mode);
889 if (rc < 0) {
890 pr_info("set device mode failed , rc %d\n", rc);
891 return rc;
892 }
893 rc = smscore_configure_board(coredev);
894 if (rc < 0) {
895 pr_info("configure board failed , rc %d\n", rc);
896 return rc;
897 }
898
899 kmutex_lock(&g_smscore_deviceslock);
900
901 rc = smscore_notify_callbacks(coredev, coredev->device, 1);
902 smscore_init_ir(coredev);
903
904 pr_debug("device %p started, rc %d\n", coredev, rc);
905
906 kmutex_unlock(&g_smscore_deviceslock);
907
908 return rc;
909}
910EXPORT_SYMBOL_GPL(smscore_start_device);
911
912
913static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
914 void *buffer, size_t size)
915{
916 struct sms_firmware *firmware = (struct sms_firmware *) buffer;
917 struct sms_msg_data4 *msg;
918 u32 mem_address, calc_checksum = 0;
919 u32 i, *ptr;
920 u8 *payload = firmware->payload;
921 int rc = 0;
922 firmware->start_address = le32_to_cpup((__le32 *)&firmware->start_address);
923 firmware->length = le32_to_cpup((__le32 *)&firmware->length);
924
925 mem_address = firmware->start_address;
926
927 pr_debug("loading FW to addr 0x%x size %d\n",
928 mem_address, firmware->length);
929 if (coredev->preload_handler) {
930 rc = coredev->preload_handler(coredev->context);
931 if (rc < 0)
932 return rc;
933 }
934
935
936 msg = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
937 if (!msg)
938 return -ENOMEM;
939
940 if (coredev->mode != DEVICE_MODE_NONE) {
941 pr_debug("sending reload command.\n");
942 SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_START_REQ,
943 sizeof(struct sms_msg_hdr));
944 rc = smscore_sendrequest_and_wait(coredev, msg,
945 msg->x_msg_header.msg_length,
946 &coredev->reload_start_done);
947 if (rc < 0) {
948 pr_err("device reload failed, rc %d\n", rc);
949 goto exit_fw_download;
950 }
951 mem_address = *(u32 *) &payload[20];
952 }
953
954 for (i = 0, ptr = (u32 *)firmware->payload; i < firmware->length/4 ;
955 i++, ptr++)
956 calc_checksum += *ptr;
957
958 while (size && rc >= 0) {
959 struct sms_data_download *data_msg =
960 (struct sms_data_download *) msg;
961 int payload_size = min_t(int, size, SMS_MAX_PAYLOAD_SIZE);
962
963 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_DATA_DOWNLOAD_REQ,
964 (u16)(sizeof(struct sms_msg_hdr) +
965 sizeof(u32) + payload_size));
966
967 data_msg->mem_addr = mem_address;
968 memcpy(data_msg->payload, payload, payload_size);
969
970 rc = smscore_sendrequest_and_wait(coredev, data_msg,
971 data_msg->x_msg_header.msg_length,
972 &coredev->data_download_done);
973
974 payload += payload_size;
975 size -= payload_size;
976 mem_address += payload_size;
977 }
978
979 if (rc < 0)
980 goto exit_fw_download;
981
982 pr_debug("sending MSG_SMS_DATA_VALIDITY_REQ expecting 0x%x\n",
983 calc_checksum);
984 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_DATA_VALIDITY_REQ,
985 sizeof(msg->x_msg_header) +
986 sizeof(u32) * 3);
987 msg->msg_data[0] = firmware->start_address;
988
989 msg->msg_data[1] = firmware->length;
990 msg->msg_data[2] = 0;
991 rc = smscore_sendrequest_and_wait(coredev, msg,
992 msg->x_msg_header.msg_length,
993 &coredev->data_validity_done);
994 if (rc < 0)
995 goto exit_fw_download;
996
997 if (coredev->mode == DEVICE_MODE_NONE) {
998 struct sms_msg_data *trigger_msg =
999 (struct sms_msg_data *) msg;
1000
1001 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
1002 SMS_INIT_MSG(&msg->x_msg_header,
1003 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
1004 sizeof(struct sms_msg_hdr) +
1005 sizeof(u32) * 5);
1006
1007 trigger_msg->msg_data[0] = firmware->start_address;
1008
1009 trigger_msg->msg_data[1] = 6;
1010 trigger_msg->msg_data[2] = 0x200;
1011 trigger_msg->msg_data[3] = 0;
1012 trigger_msg->msg_data[4] = 4;
1013
1014 rc = smscore_sendrequest_and_wait(coredev, trigger_msg,
1015 trigger_msg->x_msg_header.msg_length,
1016 &coredev->trigger_done);
1017 } else {
1018 SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_EXEC_REQ,
1019 sizeof(struct sms_msg_hdr));
1020 rc = coredev->sendrequest_handler(coredev->context, msg,
1021 msg->x_msg_header.msg_length);
1022 }
1023
1024 if (rc < 0)
1025 goto exit_fw_download;
1026
1027
1028
1029
1030
1031 msleep(400);
1032
1033exit_fw_download:
1034 kfree(msg);
1035
1036 if (coredev->postload_handler) {
1037 pr_debug("rc=%d, postload=0x%p\n",
1038 rc, coredev->postload_handler);
1039 if (rc >= 0)
1040 return coredev->postload_handler(coredev->context);
1041 }
1042
1043 pr_debug("rc=%d\n", rc);
1044 return rc;
1045}
1046
1047static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
1048 [SMS_NOVA_A0] = {
1049 [DEVICE_MODE_DVBT] = SMS_FW_DVB_NOVA_12MHZ,
1050 [DEVICE_MODE_DVBH] = SMS_FW_DVB_NOVA_12MHZ,
1051 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_NOVA_12MHZ,
1052 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_NOVA_12MHZ,
1053 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_NOVA_12MHZ,
1054 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_NOVA_12MHZ,
1055 },
1056 [SMS_NOVA_B0] = {
1057 [DEVICE_MODE_DVBT] = SMS_FW_DVB_NOVA_12MHZ_B0,
1058 [DEVICE_MODE_DVBH] = SMS_FW_DVB_NOVA_12MHZ_B0,
1059 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_NOVA_12MHZ_B0,
1060 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_NOVA_12MHZ_B0,
1061 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_NOVA_12MHZ_B0,
1062 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_NOVA_12MHZ_B0,
1063 [DEVICE_MODE_FM_RADIO] = SMS_FW_FM_RADIO,
1064 [DEVICE_MODE_FM_RADIO_BDA] = SMS_FW_FM_RADIO,
1065 },
1066 [SMS_VEGA] = {
1067 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_VEGA_12MHZ,
1068 },
1069 [SMS_VENICE] = {
1070 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_VENICE_12MHZ,
1071 },
1072 [SMS_MING] = {
1073 [DEVICE_MODE_CMMB] = SMS_FW_CMMB_MING_APP,
1074 },
1075 [SMS_PELE] = {
1076 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_PELE,
1077 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_PELE,
1078 },
1079 [SMS_RIO] = {
1080 [DEVICE_MODE_DVBT] = SMS_FW_DVB_RIO,
1081 [DEVICE_MODE_DVBH] = SMS_FW_DVBH_RIO,
1082 [DEVICE_MODE_DVBT_BDA] = SMS_FW_DVB_RIO,
1083 [DEVICE_MODE_ISDBT] = SMS_FW_ISDBT_RIO,
1084 [DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_RIO,
1085 [DEVICE_MODE_FM_RADIO] = SMS_FW_FM_RADIO_RIO,
1086 [DEVICE_MODE_FM_RADIO_BDA] = SMS_FW_FM_RADIO_RIO,
1087 },
1088 [SMS_DENVER_1530] = {
1089 [DEVICE_MODE_ATSC] = SMS_FW_ATSC_DENVER,
1090 },
1091 [SMS_DENVER_2160] = {
1092 [DEVICE_MODE_DAB_TDMB] = SMS_FW_TDMB_DENVER,
1093 },
1094};
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
1108 int mode)
1109{
1110 char **fw;
1111 int board_id = smscore_get_board_id(coredev);
1112 enum sms_device_type_st type;
1113
1114 type = smscore_registry_gettype(coredev->devpath);
1115
1116
1117 if (type <= SMS_UNKNOWN_TYPE || type >= SMS_NUM_OF_DEVICE_TYPES)
1118 return NULL;
1119 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
1120 return NULL;
1121
1122 pr_debug("trying to get fw name from sms_boards board_id %d mode %d\n",
1123 board_id, mode);
1124 fw = sms_get_board(board_id)->fw;
1125 if (!fw || !fw[mode]) {
1126 pr_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d\n",
1127 mode, type);
1128 return smscore_fw_lkup[type][mode];
1129 }
1130
1131 return fw[mode];
1132}
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
1145 int mode,
1146 loadfirmware_t loadfirmware_handler)
1147{
1148 int rc = -ENOENT;
1149 u8 *fw_buf;
1150 u32 fw_buf_size;
1151 const struct firmware *fw;
1152
1153 char *fw_filename = smscore_get_fw_filename(coredev, mode);
1154 if (!fw_filename) {
1155 pr_err("mode %d not supported on this device\n", mode);
1156 return -ENOENT;
1157 }
1158 pr_debug("Firmware name: %s\n", fw_filename);
1159
1160 if (!loadfirmware_handler &&
1161 !(coredev->device_flags & SMS_DEVICE_FAMILY2))
1162 return -EINVAL;
1163
1164 rc = request_firmware(&fw, fw_filename, coredev->device);
1165 if (rc < 0) {
1166 pr_err("failed to open firmware file '%s'\n", fw_filename);
1167 return rc;
1168 }
1169 pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size);
1170 fw_buf = kmalloc(ALIGN(fw->size + sizeof(struct sms_firmware),
1171 SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA);
1172 if (!fw_buf) {
1173 pr_err("failed to allocate firmware buffer\n");
1174 rc = -ENOMEM;
1175 } else {
1176 memcpy(fw_buf, fw->data, fw->size);
1177 fw_buf_size = fw->size;
1178
1179 rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
1180 smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
1181 : loadfirmware_handler(coredev->context, fw_buf,
1182 fw_buf_size);
1183 }
1184
1185 kfree(fw_buf);
1186 release_firmware(fw);
1187
1188 return rc;
1189}
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200void smscore_unregister_device(struct smscore_device_t *coredev)
1201{
1202 struct smscore_buffer_t *cb;
1203 int num_buffers = 0;
1204 int retry = 0;
1205
1206 kmutex_lock(&g_smscore_deviceslock);
1207
1208
1209 sms_ir_exit(coredev);
1210
1211 smscore_notify_clients(coredev);
1212 smscore_notify_callbacks(coredev, NULL, 0);
1213
1214
1215
1216
1217 while (1) {
1218 while (!list_empty(&coredev->buffers)) {
1219 cb = (struct smscore_buffer_t *) coredev->buffers.next;
1220 list_del(&cb->entry);
1221 kfree(cb);
1222 num_buffers++;
1223 }
1224 if (num_buffers == coredev->num_buffers)
1225 break;
1226 if (++retry > 10) {
1227 pr_info("exiting although not all buffers released.\n");
1228 break;
1229 }
1230
1231 pr_debug("waiting for %d buffer(s)\n",
1232 coredev->num_buffers - num_buffers);
1233 kmutex_unlock(&g_smscore_deviceslock);
1234 msleep(100);
1235 kmutex_lock(&g_smscore_deviceslock);
1236 }
1237
1238 pr_debug("freed %d buffers\n", num_buffers);
1239
1240 if (coredev->common_buffer) {
1241 if (coredev->usb_device)
1242 kfree(coredev->common_buffer);
1243 else
1244 dma_free_coherent(coredev->device,
1245 coredev->common_buffer_size,
1246 coredev->common_buffer,
1247 coredev->common_buffer_phys);
1248 }
1249 kfree(coredev->fw_buf);
1250
1251 list_del(&coredev->entry);
1252 kfree(coredev);
1253
1254 kmutex_unlock(&g_smscore_deviceslock);
1255
1256 pr_debug("device %p destroyed\n", coredev);
1257}
1258EXPORT_SYMBOL_GPL(smscore_unregister_device);
1259
1260static int smscore_detect_mode(struct smscore_device_t *coredev)
1261{
1262 void *buffer = kmalloc(sizeof(struct sms_msg_hdr) + SMS_DMA_ALIGNMENT,
1263 GFP_KERNEL | GFP_DMA);
1264 struct sms_msg_hdr *msg =
1265 (struct sms_msg_hdr *) SMS_ALIGN_ADDRESS(buffer);
1266 int rc;
1267
1268 if (!buffer)
1269 return -ENOMEM;
1270
1271 SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ,
1272 sizeof(struct sms_msg_hdr));
1273
1274 rc = smscore_sendrequest_and_wait(coredev, msg, msg->msg_length,
1275 &coredev->version_ex_done);
1276 if (rc == -ETIME) {
1277 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed first try\n");
1278
1279 if (wait_for_completion_timeout(&coredev->resume_done,
1280 msecs_to_jiffies(5000))) {
1281 rc = smscore_sendrequest_and_wait(
1282 coredev, msg, msg->msg_length,
1283 &coredev->version_ex_done);
1284 if (rc < 0)
1285 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n",
1286 rc);
1287 } else
1288 rc = -ETIME;
1289 }
1290
1291 kfree(buffer);
1292
1293 return rc;
1294}
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305static int smscore_init_device(struct smscore_device_t *coredev, int mode)
1306{
1307 void *buffer;
1308 struct sms_msg_data *msg;
1309 int rc = 0;
1310
1311 buffer = kmalloc(sizeof(struct sms_msg_data) +
1312 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
1313 if (!buffer)
1314 return -ENOMEM;
1315
1316 msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
1317 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
1318 sizeof(struct sms_msg_data));
1319 msg->msg_data[0] = mode;
1320
1321 rc = smscore_sendrequest_and_wait(coredev, msg,
1322 msg->x_msg_header. msg_length,
1323 &coredev->init_device_done);
1324
1325 kfree(buffer);
1326 return rc;
1327}
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
1340{
1341 int rc = 0;
1342
1343 pr_debug("set device mode to %d\n", mode);
1344 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
1345 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
1346 pr_err("invalid mode specified %d\n", mode);
1347 return -EINVAL;
1348 }
1349
1350 smscore_registry_setmode(coredev->devpath, mode);
1351
1352 if (!(coredev->device_flags & SMS_DEVICE_NOT_READY)) {
1353 rc = smscore_detect_mode(coredev);
1354 if (rc < 0) {
1355 pr_err("mode detect failed %d\n", rc);
1356 return rc;
1357 }
1358 }
1359
1360 if (coredev->mode == mode) {
1361 pr_debug("device mode %d already set\n", mode);
1362 return 0;
1363 }
1364
1365 if (!(coredev->modes_supported & (1 << mode))) {
1366 rc = smscore_load_firmware_from_file(coredev,
1367 mode, NULL);
1368 if (rc >= 0)
1369 pr_debug("firmware download success\n");
1370 } else {
1371 pr_debug("mode %d is already supported by running firmware\n",
1372 mode);
1373 }
1374 if (coredev->fw_version >= 0x800) {
1375 rc = smscore_init_device(coredev, mode);
1376 if (rc < 0)
1377 pr_err("device init failed, rc %d.\n", rc);
1378 }
1379 } else {
1380 if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
1381 pr_err("invalid mode specified %d\n", mode);
1382 return -EINVAL;
1383 }
1384
1385 smscore_registry_setmode(coredev->devpath, mode);
1386
1387 if (coredev->detectmode_handler)
1388 coredev->detectmode_handler(coredev->context,
1389 &coredev->mode);
1390
1391 if (coredev->mode != mode && coredev->setmode_handler)
1392 rc = coredev->setmode_handler(coredev->context, mode);
1393 }
1394
1395 if (rc >= 0) {
1396 char *buffer;
1397 coredev->mode = mode;
1398 coredev->device_flags &= ~SMS_DEVICE_NOT_READY;
1399
1400 buffer = kmalloc(sizeof(struct sms_msg_data) +
1401 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
1402 if (buffer) {
1403 struct sms_msg_data *msg = (struct sms_msg_data *) SMS_ALIGN_ADDRESS(buffer);
1404
1405 SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
1406 sizeof(struct sms_msg_data));
1407 msg->msg_data[0] = mode;
1408
1409 rc = smscore_sendrequest_and_wait(
1410 coredev, msg, msg->x_msg_header.msg_length,
1411 &coredev->init_device_done);
1412
1413 kfree(buffer);
1414 }
1415 }
1416
1417 if (rc < 0)
1418 pr_err("return error code %d.\n", rc);
1419 else
1420 pr_debug("Success setting device mode.\n");
1421
1422 return rc;
1423}
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433int smscore_get_device_mode(struct smscore_device_t *coredev)
1434{
1435 return coredev->mode;
1436}
1437EXPORT_SYMBOL_GPL(smscore_get_device_mode);
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449static struct
1450smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
1451 int data_type, int id)
1452{
1453 struct list_head *first;
1454 struct smscore_client_t *client;
1455 unsigned long flags;
1456 struct list_head *firstid;
1457 struct smscore_idlist_t *client_id;
1458
1459 spin_lock_irqsave(&coredev->clientslock, flags);
1460 first = &coredev->clients;
1461 list_for_each_entry(client, first, entry) {
1462 firstid = &client->idlist;
1463 list_for_each_entry(client_id, firstid, entry) {
1464 if ((client_id->id == id) &&
1465 (client_id->data_type == data_type ||
1466 (client_id->data_type == 0)))
1467 goto found;
1468 }
1469 }
1470 client = NULL;
1471found:
1472 spin_unlock_irqrestore(&coredev->clientslock, flags);
1473 return client;
1474}
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485void smscore_onresponse(struct smscore_device_t *coredev,
1486 struct smscore_buffer_t *cb) {
1487 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) ((u8 *) cb->p
1488 + cb->offset);
1489 struct smscore_client_t *client;
1490 int rc = -EBUSY;
1491 static unsigned long last_sample_time;
1492 static int data_total;
1493 unsigned long time_now = jiffies_to_msecs(jiffies);
1494
1495 if (!last_sample_time)
1496 last_sample_time = time_now;
1497
1498 if (time_now - last_sample_time > 10000) {
1499 pr_debug("data rate %d bytes/secs\n",
1500 (int)((data_total * 1000) /
1501 (time_now - last_sample_time)));
1502
1503 last_sample_time = time_now;
1504 data_total = 0;
1505 }
1506
1507 data_total += cb->size;
1508
1509 if ((phdr->msg_type == MSG_SMS_HO_PER_SLICES_IND) ||
1510 (phdr->msg_type == MSG_SMS_TRANSMISSION_IND)) {
1511 if (coredev->mode == DEVICE_MODE_DVBT_BDA)
1512 phdr->msg_dst_id = DVBT_BDA_CONTROL_MSG_ID;
1513 }
1514
1515
1516 client = smscore_find_client(coredev, phdr->msg_type, phdr->msg_dst_id);
1517
1518
1519
1520 if (client)
1521 rc = client->onresponse_handler(client->context, cb);
1522
1523 if (rc < 0) {
1524 switch (phdr->msg_type) {
1525 case MSG_SMS_ISDBT_TUNE_RES:
1526 break;
1527 case MSG_SMS_RF_TUNE_RES:
1528 break;
1529 case MSG_SMS_SIGNAL_DETECTED_IND:
1530 break;
1531 case MSG_SMS_NO_SIGNAL_IND:
1532 break;
1533 case MSG_SMS_SPI_INT_LINE_SET_RES:
1534 break;
1535 case MSG_SMS_INTERFACE_LOCK_IND:
1536 break;
1537 case MSG_SMS_INTERFACE_UNLOCK_IND:
1538 break;
1539 case MSG_SMS_GET_VERSION_EX_RES:
1540 {
1541 struct sms_version_res *ver =
1542 (struct sms_version_res *) phdr;
1543 pr_debug("Firmware id %d prots 0x%x ver %d.%d\n",
1544 ver->firmware_id, ver->supported_protocols,
1545 ver->rom_ver_major, ver->rom_ver_minor);
1546
1547 coredev->mode = ver->firmware_id == 255 ?
1548 DEVICE_MODE_NONE : ver->firmware_id;
1549 coredev->modes_supported = ver->supported_protocols;
1550 coredev->fw_version = ver->rom_ver_major << 8 |
1551 ver->rom_ver_minor;
1552
1553 complete(&coredev->version_ex_done);
1554 break;
1555 }
1556 case MSG_SMS_INIT_DEVICE_RES:
1557 complete(&coredev->init_device_done);
1558 break;
1559 case MSG_SW_RELOAD_START_RES:
1560 complete(&coredev->reload_start_done);
1561 break;
1562 case MSG_SMS_DATA_VALIDITY_RES:
1563 {
1564 struct sms_msg_data *validity = (struct sms_msg_data *) phdr;
1565
1566 pr_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x\n",
1567 validity->msg_data[0]);
1568 complete(&coredev->data_validity_done);
1569 break;
1570 }
1571 case MSG_SMS_DATA_DOWNLOAD_RES:
1572 complete(&coredev->data_download_done);
1573 break;
1574 case MSG_SW_RELOAD_EXEC_RES:
1575 break;
1576 case MSG_SMS_SWDOWNLOAD_TRIGGER_RES:
1577 complete(&coredev->trigger_done);
1578 break;
1579 case MSG_SMS_SLEEP_RESUME_COMP_IND:
1580 complete(&coredev->resume_done);
1581 break;
1582 case MSG_SMS_GPIO_CONFIG_EX_RES:
1583 complete(&coredev->gpio_configuration_done);
1584 break;
1585 case MSG_SMS_GPIO_SET_LEVEL_RES:
1586 complete(&coredev->gpio_set_level_done);
1587 break;
1588 case MSG_SMS_GPIO_GET_LEVEL_RES:
1589 {
1590 u32 *msgdata = (u32 *) phdr;
1591 coredev->gpio_get_res = msgdata[1];
1592 pr_debug("gpio level %d\n",
1593 coredev->gpio_get_res);
1594 complete(&coredev->gpio_get_level_done);
1595 break;
1596 }
1597 case MSG_SMS_START_IR_RES:
1598 complete(&coredev->ir_init_done);
1599 break;
1600 case MSG_SMS_IR_SAMPLES_IND:
1601 sms_ir_event(coredev,
1602 (const char *)
1603 ((char *)phdr
1604 + sizeof(struct sms_msg_hdr)),
1605 (int)phdr->msg_length
1606 - sizeof(struct sms_msg_hdr));
1607 break;
1608
1609 case MSG_SMS_DVBT_BDA_DATA:
1610
1611
1612
1613
1614
1615
1616 break;
1617
1618 default:
1619 pr_debug("message %s(%d) not handled.\n",
1620 smscore_translate_msg(phdr->msg_type),
1621 phdr->msg_type);
1622 break;
1623 }
1624 smscore_putbuffer(coredev, cb);
1625 }
1626}
1627EXPORT_SYMBOL_GPL(smscore_onresponse);
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638static struct smscore_buffer_t *get_entry(struct smscore_device_t *coredev)
1639{
1640 struct smscore_buffer_t *cb = NULL;
1641 unsigned long flags;
1642
1643 spin_lock_irqsave(&coredev->bufferslock, flags);
1644 if (!list_empty(&coredev->buffers)) {
1645 cb = (struct smscore_buffer_t *) coredev->buffers.next;
1646 list_del(&cb->entry);
1647 }
1648 spin_unlock_irqrestore(&coredev->bufferslock, flags);
1649 return cb;
1650}
1651
1652struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *coredev)
1653{
1654 struct smscore_buffer_t *cb = NULL;
1655
1656 wait_event(coredev->buffer_mng_waitq, (cb = get_entry(coredev)));
1657
1658 return cb;
1659}
1660EXPORT_SYMBOL_GPL(smscore_getbuffer);
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670void smscore_putbuffer(struct smscore_device_t *coredev,
1671 struct smscore_buffer_t *cb) {
1672 wake_up_interruptible(&coredev->buffer_mng_waitq);
1673 list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock);
1674}
1675EXPORT_SYMBOL_GPL(smscore_putbuffer);
1676
1677static int smscore_validate_client(struct smscore_device_t *coredev,
1678 struct smscore_client_t *client,
1679 int data_type, int id)
1680{
1681 struct smscore_idlist_t *listentry;
1682 struct smscore_client_t *registered_client;
1683
1684 if (!client) {
1685 pr_err("bad parameter.\n");
1686 return -EINVAL;
1687 }
1688 registered_client = smscore_find_client(coredev, data_type, id);
1689 if (registered_client == client)
1690 return 0;
1691
1692 if (registered_client) {
1693 pr_err("The msg ID already registered to another client.\n");
1694 return -EEXIST;
1695 }
1696 listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
1697 if (!listentry)
1698 return -ENOMEM;
1699
1700 listentry->id = id;
1701 listentry->data_type = data_type;
1702 list_add_locked(&listentry->entry, &client->idlist,
1703 &coredev->clientslock);
1704 return 0;
1705}
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721int smscore_register_client(struct smscore_device_t *coredev,
1722 struct smsclient_params_t *params,
1723 struct smscore_client_t **client)
1724{
1725 struct smscore_client_t *newclient;
1726
1727 if (smscore_find_client(coredev, params->data_type,
1728 params->initial_id)) {
1729 pr_err("Client already exist.\n");
1730 return -EEXIST;
1731 }
1732
1733 newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
1734 if (!newclient)
1735 return -ENOMEM;
1736
1737 INIT_LIST_HEAD(&newclient->idlist);
1738 newclient->coredev = coredev;
1739 newclient->onresponse_handler = params->onresponse_handler;
1740 newclient->onremove_handler = params->onremove_handler;
1741 newclient->context = params->context;
1742 list_add_locked(&newclient->entry, &coredev->clients,
1743 &coredev->clientslock);
1744 smscore_validate_client(coredev, newclient, params->data_type,
1745 params->initial_id);
1746 *client = newclient;
1747 pr_debug("%p %d %d\n", params->context, params->data_type,
1748 params->initial_id);
1749
1750 return 0;
1751}
1752EXPORT_SYMBOL_GPL(smscore_register_client);
1753
1754
1755
1756
1757
1758
1759
1760
1761void smscore_unregister_client(struct smscore_client_t *client)
1762{
1763 struct smscore_device_t *coredev = client->coredev;
1764 unsigned long flags;
1765
1766 spin_lock_irqsave(&coredev->clientslock, flags);
1767
1768
1769 while (!list_empty(&client->idlist)) {
1770 struct smscore_idlist_t *identry =
1771 (struct smscore_idlist_t *) client->idlist.next;
1772 list_del(&identry->entry);
1773 kfree(identry);
1774 }
1775
1776 pr_debug("%p\n", client->context);
1777
1778 list_del(&client->entry);
1779 kfree(client);
1780
1781 spin_unlock_irqrestore(&coredev->clientslock, flags);
1782}
1783EXPORT_SYMBOL_GPL(smscore_unregister_client);
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796int smsclient_sendrequest(struct smscore_client_t *client,
1797 void *buffer, size_t size)
1798{
1799 struct smscore_device_t *coredev;
1800 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
1801 int rc;
1802
1803 if (!client) {
1804 pr_err("Got NULL client\n");
1805 return -EINVAL;
1806 }
1807
1808 coredev = client->coredev;
1809
1810
1811 if (!coredev) {
1812 pr_err("Got NULL coredev\n");
1813 return -EINVAL;
1814 }
1815
1816 rc = smscore_validate_client(client->coredev, client, 0,
1817 phdr->msg_src_id);
1818 if (rc < 0)
1819 return rc;
1820
1821 return coredev->sendrequest_handler(coredev->context, buffer, size);
1822}
1823EXPORT_SYMBOL_GPL(smsclient_sendrequest);
1824
1825
1826
1827int smscore_configure_gpio(struct smscore_device_t *coredev, u32 pin,
1828 struct smscore_config_gpio *pinconfig)
1829{
1830 struct {
1831 struct sms_msg_hdr hdr;
1832 u32 data[6];
1833 } msg;
1834
1835 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
1836 msg.hdr.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1837 msg.hdr.msg_dst_id = HIF_TASK;
1838 msg.hdr.msg_flags = 0;
1839 msg.hdr.msg_type = MSG_SMS_GPIO_CONFIG_EX_REQ;
1840 msg.hdr.msg_length = sizeof(msg);
1841
1842 msg.data[0] = pin;
1843 msg.data[1] = pinconfig->pullupdown;
1844
1845
1846 msg.data[2] = pinconfig->outputslewrate == 0 ? 3 : 0;
1847
1848 switch (pinconfig->outputdriving) {
1849 case SMS_GPIO_OUTPUTDRIVING_S_16mA:
1850 msg.data[3] = 7;
1851 break;
1852 case SMS_GPIO_OUTPUTDRIVING_S_12mA:
1853 msg.data[3] = 5;
1854 break;
1855 case SMS_GPIO_OUTPUTDRIVING_S_8mA:
1856 msg.data[3] = 3;
1857 break;
1858 case SMS_GPIO_OUTPUTDRIVING_S_4mA:
1859 default:
1860 msg.data[3] = 2;
1861 break;
1862 }
1863
1864 msg.data[4] = pinconfig->direction;
1865 msg.data[5] = 0;
1866 } else
1867 return -EINVAL;
1868
1869 return coredev->sendrequest_handler(coredev->context,
1870 &msg, sizeof(msg));
1871}
1872
1873int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level)
1874{
1875 struct {
1876 struct sms_msg_hdr hdr;
1877 u32 data[3];
1878 } msg;
1879
1880 if (pin > MAX_GPIO_PIN_NUMBER)
1881 return -EINVAL;
1882
1883 msg.hdr.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1884 msg.hdr.msg_dst_id = HIF_TASK;
1885 msg.hdr.msg_flags = 0;
1886 msg.hdr.msg_type = MSG_SMS_GPIO_SET_LEVEL_REQ;
1887 msg.hdr.msg_length = sizeof(msg);
1888
1889 msg.data[0] = pin;
1890 msg.data[1] = level ? 1 : 0;
1891 msg.data[2] = 0;
1892
1893 return coredev->sendrequest_handler(coredev->context,
1894 &msg, sizeof(msg));
1895}
1896
1897
1898static int get_gpio_pin_params(u32 pin_num, u32 *p_translatedpin_num,
1899 u32 *p_group_num, u32 *p_group_cfg) {
1900
1901 *p_group_cfg = 1;
1902
1903 if (pin_num <= 1) {
1904 *p_translatedpin_num = 0;
1905 *p_group_num = 9;
1906 *p_group_cfg = 2;
1907 } else if (pin_num >= 2 && pin_num <= 6) {
1908 *p_translatedpin_num = 2;
1909 *p_group_num = 0;
1910 *p_group_cfg = 2;
1911 } else if (pin_num >= 7 && pin_num <= 11) {
1912 *p_translatedpin_num = 7;
1913 *p_group_num = 1;
1914 } else if (pin_num >= 12 && pin_num <= 15) {
1915 *p_translatedpin_num = 12;
1916 *p_group_num = 2;
1917 *p_group_cfg = 3;
1918 } else if (pin_num == 16) {
1919 *p_translatedpin_num = 16;
1920 *p_group_num = 23;
1921 } else if (pin_num >= 17 && pin_num <= 24) {
1922 *p_translatedpin_num = 17;
1923 *p_group_num = 3;
1924 } else if (pin_num == 25) {
1925 *p_translatedpin_num = 25;
1926 *p_group_num = 6;
1927 } else if (pin_num >= 26 && pin_num <= 28) {
1928 *p_translatedpin_num = 26;
1929 *p_group_num = 4;
1930 } else if (pin_num == 29) {
1931 *p_translatedpin_num = 29;
1932 *p_group_num = 5;
1933 *p_group_cfg = 2;
1934 } else if (pin_num == 30) {
1935 *p_translatedpin_num = 30;
1936 *p_group_num = 8;
1937 } else if (pin_num == 31) {
1938 *p_translatedpin_num = 31;
1939 *p_group_num = 17;
1940 } else
1941 return -1;
1942
1943 *p_group_cfg <<= 24;
1944
1945 return 0;
1946}
1947
1948int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num,
1949 struct smscore_config_gpio *p_gpio_config) {
1950
1951 u32 total_len;
1952 u32 translatedpin_num = 0;
1953 u32 group_num = 0;
1954 u32 electric_char;
1955 u32 group_cfg;
1956 void *buffer;
1957 int rc;
1958
1959 struct set_gpio_msg {
1960 struct sms_msg_hdr x_msg_header;
1961 u32 msg_data[6];
1962 } *p_msg;
1963
1964
1965 if (pin_num > MAX_GPIO_PIN_NUMBER)
1966 return -EINVAL;
1967
1968 if (!p_gpio_config)
1969 return -EINVAL;
1970
1971 total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6);
1972
1973 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
1974 GFP_KERNEL | GFP_DMA);
1975 if (!buffer)
1976 return -ENOMEM;
1977
1978 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
1979
1980 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
1981 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
1982 p_msg->x_msg_header.msg_flags = 0;
1983 p_msg->x_msg_header.msg_length = (u16) total_len;
1984 p_msg->msg_data[0] = pin_num;
1985
1986 if (!(coredev->device_flags & SMS_DEVICE_FAMILY2)) {
1987 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_CONFIG_REQ;
1988 if (get_gpio_pin_params(pin_num, &translatedpin_num, &group_num,
1989 &group_cfg) != 0) {
1990 rc = -EINVAL;
1991 goto free;
1992 }
1993
1994 p_msg->msg_data[1] = translatedpin_num;
1995 p_msg->msg_data[2] = group_num;
1996 electric_char = (p_gpio_config->pullupdown)
1997 | (p_gpio_config->inputcharacteristics << 2)
1998 | (p_gpio_config->outputslewrate << 3)
1999 | (p_gpio_config->outputdriving << 4);
2000 p_msg->msg_data[3] = electric_char;
2001 p_msg->msg_data[4] = p_gpio_config->direction;
2002 p_msg->msg_data[5] = group_cfg;
2003 } else {
2004 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_CONFIG_EX_REQ;
2005 p_msg->msg_data[1] = p_gpio_config->pullupdown;
2006 p_msg->msg_data[2] = p_gpio_config->outputslewrate;
2007 p_msg->msg_data[3] = p_gpio_config->outputdriving;
2008 p_msg->msg_data[4] = p_gpio_config->direction;
2009 p_msg->msg_data[5] = 0;
2010 }
2011
2012 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2013 &coredev->gpio_configuration_done);
2014
2015 if (rc != 0) {
2016 if (rc == -ETIME)
2017 pr_err("smscore_gpio_configure timeout\n");
2018 else
2019 pr_err("smscore_gpio_configure error\n");
2020 }
2021free:
2022 kfree(buffer);
2023
2024 return rc;
2025}
2026
2027int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 pin_num,
2028 u8 new_level) {
2029
2030 u32 total_len;
2031 int rc;
2032 void *buffer;
2033
2034 struct set_gpio_msg {
2035 struct sms_msg_hdr x_msg_header;
2036 u32 msg_data[3];
2037 } *p_msg;
2038
2039 if ((new_level > 1) || (pin_num > MAX_GPIO_PIN_NUMBER))
2040 return -EINVAL;
2041
2042 total_len = sizeof(struct sms_msg_hdr) +
2043 (3 * sizeof(u32));
2044
2045 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
2046 GFP_KERNEL | GFP_DMA);
2047 if (!buffer)
2048 return -ENOMEM;
2049
2050 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
2051
2052 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
2053 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
2054 p_msg->x_msg_header.msg_flags = 0;
2055 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_SET_LEVEL_REQ;
2056 p_msg->x_msg_header.msg_length = (u16) total_len;
2057 p_msg->msg_data[0] = pin_num;
2058 p_msg->msg_data[1] = new_level;
2059
2060
2061 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2062 &coredev->gpio_set_level_done);
2063
2064 if (rc != 0) {
2065 if (rc == -ETIME)
2066 pr_err("smscore_gpio_set_level timeout\n");
2067 else
2068 pr_err("smscore_gpio_set_level error\n");
2069 }
2070 kfree(buffer);
2071
2072 return rc;
2073}
2074
2075int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 pin_num,
2076 u8 *level) {
2077
2078 u32 total_len;
2079 int rc;
2080 void *buffer;
2081
2082 struct set_gpio_msg {
2083 struct sms_msg_hdr x_msg_header;
2084 u32 msg_data[2];
2085 } *p_msg;
2086
2087
2088 if (pin_num > MAX_GPIO_PIN_NUMBER)
2089 return -EINVAL;
2090
2091 total_len = sizeof(struct sms_msg_hdr) + (2 * sizeof(u32));
2092
2093 buffer = kmalloc(total_len + SMS_DMA_ALIGNMENT,
2094 GFP_KERNEL | GFP_DMA);
2095 if (!buffer)
2096 return -ENOMEM;
2097
2098 p_msg = (struct set_gpio_msg *) SMS_ALIGN_ADDRESS(buffer);
2099
2100 p_msg->x_msg_header.msg_src_id = DVBT_BDA_CONTROL_MSG_ID;
2101 p_msg->x_msg_header.msg_dst_id = HIF_TASK;
2102 p_msg->x_msg_header.msg_flags = 0;
2103 p_msg->x_msg_header.msg_type = MSG_SMS_GPIO_GET_LEVEL_REQ;
2104 p_msg->x_msg_header.msg_length = (u16) total_len;
2105 p_msg->msg_data[0] = pin_num;
2106 p_msg->msg_data[1] = 0;
2107
2108
2109 rc = smscore_sendrequest_and_wait(coredev, p_msg, total_len,
2110 &coredev->gpio_get_level_done);
2111
2112 if (rc != 0) {
2113 if (rc == -ETIME)
2114 pr_err("smscore_gpio_get_level timeout\n");
2115 else
2116 pr_err("smscore_gpio_get_level error\n");
2117 }
2118 kfree(buffer);
2119
2120
2121
2122
2123 *level = coredev->gpio_get_res;
2124
2125 return rc;
2126}
2127
2128static int __init smscore_module_init(void)
2129{
2130 INIT_LIST_HEAD(&g_smscore_notifyees);
2131 INIT_LIST_HEAD(&g_smscore_devices);
2132 kmutex_init(&g_smscore_deviceslock);
2133
2134 INIT_LIST_HEAD(&g_smscore_registry);
2135 kmutex_init(&g_smscore_registrylock);
2136
2137 return 0;
2138}
2139
2140static void __exit smscore_module_exit(void)
2141{
2142 kmutex_lock(&g_smscore_deviceslock);
2143 while (!list_empty(&g_smscore_notifyees)) {
2144 struct smscore_device_notifyee_t *notifyee =
2145 (struct smscore_device_notifyee_t *)
2146 g_smscore_notifyees.next;
2147
2148 list_del(¬ifyee->entry);
2149 kfree(notifyee);
2150 }
2151 kmutex_unlock(&g_smscore_deviceslock);
2152
2153 kmutex_lock(&g_smscore_registrylock);
2154 while (!list_empty(&g_smscore_registry)) {
2155 struct smscore_registry_entry_t *entry =
2156 (struct smscore_registry_entry_t *)
2157 g_smscore_registry.next;
2158
2159 list_del(&entry->entry);
2160 kfree(entry);
2161 }
2162 kmutex_unlock(&g_smscore_registrylock);
2163
2164 pr_debug("\n");
2165}
2166
2167module_init(smscore_module_init);
2168module_exit(smscore_module_exit);
2169
2170MODULE_DESCRIPTION("Siano MDTV Core module");
2171MODULE_AUTHOR("Siano Mobile Silicon, Inc. (uris@siano-ms.com)");
2172MODULE_LICENSE("GPL");
2173
2174
2175MODULE_FIRMWARE(SMS_FW_ATSC_DENVER);
2176MODULE_FIRMWARE(SMS_FW_CMMB_MING_APP);
2177MODULE_FIRMWARE(SMS_FW_CMMB_VEGA_12MHZ);
2178MODULE_FIRMWARE(SMS_FW_CMMB_VENICE_12MHZ);
2179MODULE_FIRMWARE(SMS_FW_DVBH_RIO);
2180MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ_B0);
2181MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ);
2182MODULE_FIRMWARE(SMS_FW_DVB_RIO);
2183MODULE_FIRMWARE(SMS_FW_FM_RADIO);
2184MODULE_FIRMWARE(SMS_FW_FM_RADIO_RIO);
2185MODULE_FIRMWARE(SMS_FW_DVBT_HCW_55XXX);
2186MODULE_FIRMWARE(SMS_FW_ISDBT_HCW_55XXX);
2187MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ_B0);
2188MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ);
2189MODULE_FIRMWARE(SMS_FW_ISDBT_PELE);
2190MODULE_FIRMWARE(SMS_FW_ISDBT_RIO);
2191MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_A);
2192MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_B);
2193MODULE_FIRMWARE(SMS_FW_DVBT_STELLAR);
2194MODULE_FIRMWARE(SMS_FW_TDMB_DENVER);
2195MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ_B0);
2196MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ);
2197