2 * Siano core API module
4 * This file contains implementation for the interface to sms core component
8 * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation;
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
17 * See the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/kernel.h>
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/moduleparam.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/delay.h>
31 #include <linux/slab.h>
33 #include <linux/firmware.h>
34 #include <linux/wait.h>
35 #include <asm/byteorder.h>
37 #include "smscoreapi.h"
38 #include "sms-cards.h"
42 module_param_named(debug
, sms_dbg
, int, 0644);
43 MODULE_PARM_DESC(debug
, "set debug level (info=1, adv=2 (or-able))");
45 struct smscore_device_notifyee_t
{
46 struct list_head entry
;
50 struct smscore_idlist_t
{
51 struct list_head entry
;
56 struct smscore_client_t
{
57 struct list_head entry
;
58 struct smscore_device_t
*coredev
;
60 struct list_head idlist
;
61 onresponse_t onresponse_handler
;
62 onremove_t onremove_handler
;
65 static char *siano_msgs
[] = {
66 [MSG_TYPE_BASE_VAL
- MSG_TYPE_BASE_VAL
] = "MSG_TYPE_BASE_VAL",
67 [MSG_SMS_GET_VERSION_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_VERSION_REQ",
68 [MSG_SMS_GET_VERSION_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_VERSION_RES",
69 [MSG_SMS_MULTI_BRIDGE_CFG
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MULTI_BRIDGE_CFG",
70 [MSG_SMS_GPIO_CONFIG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_CONFIG_REQ",
71 [MSG_SMS_GPIO_CONFIG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_CONFIG_RES",
72 [MSG_SMS_GPIO_SET_LEVEL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_SET_LEVEL_REQ",
73 [MSG_SMS_GPIO_SET_LEVEL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_SET_LEVEL_RES",
74 [MSG_SMS_GPIO_GET_LEVEL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_GET_LEVEL_REQ",
75 [MSG_SMS_GPIO_GET_LEVEL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_GET_LEVEL_RES",
76 [MSG_SMS_EEPROM_BURN_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EEPROM_BURN_IND",
77 [MSG_SMS_LOG_ENABLE_CHANGE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOG_ENABLE_CHANGE_REQ",
78 [MSG_SMS_LOG_ENABLE_CHANGE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOG_ENABLE_CHANGE_RES",
79 [MSG_SMS_SET_MAX_TX_MSG_LEN_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_MAX_TX_MSG_LEN_REQ",
80 [MSG_SMS_SET_MAX_TX_MSG_LEN_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_MAX_TX_MSG_LEN_RES",
81 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE",
82 [MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST",
83 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ",
84 [MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES",
85 [MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND",
86 [MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND",
87 [MSG_SMS_CONFIGURE_RF_SWITCH_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CONFIGURE_RF_SWITCH_REQ",
88 [MSG_SMS_CONFIGURE_RF_SWITCH_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CONFIGURE_RF_SWITCH_RES",
89 [MSG_SMS_MRC_PATH_DISCONNECT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_PATH_DISCONNECT_REQ",
90 [MSG_SMS_MRC_PATH_DISCONNECT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_PATH_DISCONNECT_RES",
91 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ",
92 [MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES",
93 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ",
94 [MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES",
95 [MSG_WR_REG_RFT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_WR_REG_RFT_REQ",
96 [MSG_WR_REG_RFT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_WR_REG_RFT_RES",
97 [MSG_RD_REG_RFT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_RD_REG_RFT_REQ",
98 [MSG_RD_REG_RFT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_RD_REG_RFT_RES",
99 [MSG_RD_REG_ALL_RFT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_RD_REG_ALL_RFT_REQ",
100 [MSG_RD_REG_ALL_RFT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_RD_REG_ALL_RFT_RES",
101 [MSG_HELP_INT
- MSG_TYPE_BASE_VAL
] = "MSG_HELP_INT",
102 [MSG_RUN_SCRIPT_INT
- MSG_TYPE_BASE_VAL
] = "MSG_RUN_SCRIPT_INT",
103 [MSG_SMS_EWS_INBAND_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EWS_INBAND_REQ",
104 [MSG_SMS_EWS_INBAND_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EWS_INBAND_RES",
105 [MSG_SMS_RFS_SELECT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RFS_SELECT_REQ",
106 [MSG_SMS_RFS_SELECT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RFS_SELECT_RES",
107 [MSG_SMS_MB_GET_VER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_GET_VER_REQ",
108 [MSG_SMS_MB_GET_VER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_GET_VER_RES",
109 [MSG_SMS_MB_WRITE_CFGFILE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_WRITE_CFGFILE_REQ",
110 [MSG_SMS_MB_WRITE_CFGFILE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_WRITE_CFGFILE_RES",
111 [MSG_SMS_MB_READ_CFGFILE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_READ_CFGFILE_REQ",
112 [MSG_SMS_MB_READ_CFGFILE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_READ_CFGFILE_RES",
113 [MSG_SMS_RD_MEM_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RD_MEM_REQ",
114 [MSG_SMS_RD_MEM_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RD_MEM_RES",
115 [MSG_SMS_WR_MEM_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_WR_MEM_REQ",
116 [MSG_SMS_WR_MEM_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_WR_MEM_RES",
117 [MSG_SMS_UPDATE_MEM_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_UPDATE_MEM_REQ",
118 [MSG_SMS_UPDATE_MEM_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_UPDATE_MEM_RES",
119 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ",
120 [MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES",
121 [MSG_SMS_RF_TUNE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RF_TUNE_REQ",
122 [MSG_SMS_RF_TUNE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RF_TUNE_RES",
123 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ",
124 [MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES",
125 [MSG_SMS_ISDBT_SB_RECEPTION_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_SB_RECEPTION_REQ",
126 [MSG_SMS_ISDBT_SB_RECEPTION_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_SB_RECEPTION_RES",
127 [MSG_SMS_GENERIC_EPROM_WRITE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_EPROM_WRITE_REQ",
128 [MSG_SMS_GENERIC_EPROM_WRITE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_EPROM_WRITE_RES",
129 [MSG_SMS_GENERIC_EPROM_READ_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_EPROM_READ_REQ",
130 [MSG_SMS_GENERIC_EPROM_READ_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_EPROM_READ_RES",
131 [MSG_SMS_EEPROM_WRITE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EEPROM_WRITE_REQ",
132 [MSG_SMS_EEPROM_WRITE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EEPROM_WRITE_RES",
133 [MSG_SMS_CUSTOM_READ_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CUSTOM_READ_REQ",
134 [MSG_SMS_CUSTOM_READ_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CUSTOM_READ_RES",
135 [MSG_SMS_CUSTOM_WRITE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CUSTOM_WRITE_REQ",
136 [MSG_SMS_CUSTOM_WRITE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CUSTOM_WRITE_RES",
137 [MSG_SMS_INIT_DEVICE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_INIT_DEVICE_REQ",
138 [MSG_SMS_INIT_DEVICE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_INIT_DEVICE_RES",
139 [MSG_SMS_ATSC_SET_ALL_IP_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_SET_ALL_IP_REQ",
140 [MSG_SMS_ATSC_SET_ALL_IP_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_SET_ALL_IP_RES",
141 [MSG_SMS_ATSC_START_ENSEMBLE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_START_ENSEMBLE_REQ",
142 [MSG_SMS_ATSC_START_ENSEMBLE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_START_ENSEMBLE_RES",
143 [MSG_SMS_SET_OUTPUT_MODE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_OUTPUT_MODE_REQ",
144 [MSG_SMS_SET_OUTPUT_MODE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_OUTPUT_MODE_RES",
145 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ",
146 [MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES",
147 [MSG_SMS_SUB_CHANNEL_START_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SUB_CHANNEL_START_REQ",
148 [MSG_SMS_SUB_CHANNEL_START_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SUB_CHANNEL_START_RES",
149 [MSG_SMS_SUB_CHANNEL_STOP_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SUB_CHANNEL_STOP_REQ",
150 [MSG_SMS_SUB_CHANNEL_STOP_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SUB_CHANNEL_STOP_RES",
151 [MSG_SMS_ATSC_IP_FILTER_ADD_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_ADD_REQ",
152 [MSG_SMS_ATSC_IP_FILTER_ADD_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_ADD_RES",
153 [MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ",
154 [MSG_SMS_ATSC_IP_FILTER_REMOVE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_RES",
155 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ",
156 [MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES",
157 [MSG_SMS_WAIT_CMD
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_WAIT_CMD",
158 [MSG_SMS_ADD_PID_FILTER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ADD_PID_FILTER_REQ",
159 [MSG_SMS_ADD_PID_FILTER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ADD_PID_FILTER_RES",
160 [MSG_SMS_REMOVE_PID_FILTER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_REMOVE_PID_FILTER_REQ",
161 [MSG_SMS_REMOVE_PID_FILTER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_REMOVE_PID_FILTER_RES",
162 [MSG_SMS_FAST_INFORMATION_CHANNEL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_FAST_INFORMATION_CHANNEL_REQ",
163 [MSG_SMS_FAST_INFORMATION_CHANNEL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_FAST_INFORMATION_CHANNEL_RES",
164 [MSG_SMS_DAB_CHANNEL
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DAB_CHANNEL",
165 [MSG_SMS_GET_PID_FILTER_LIST_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_PID_FILTER_LIST_REQ",
166 [MSG_SMS_GET_PID_FILTER_LIST_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_PID_FILTER_LIST_RES",
167 [MSG_SMS_POWER_DOWN_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_DOWN_REQ",
168 [MSG_SMS_POWER_DOWN_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_DOWN_RES",
169 [MSG_SMS_ATSC_SLT_EXIST_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_SLT_EXIST_IND",
170 [MSG_SMS_ATSC_NO_SLT_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ATSC_NO_SLT_IND",
171 [MSG_SMS_GET_STATISTICS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_STATISTICS_REQ",
172 [MSG_SMS_GET_STATISTICS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_STATISTICS_RES",
173 [MSG_SMS_SEND_DUMP
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_DUMP",
174 [MSG_SMS_SCAN_START_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_START_REQ",
175 [MSG_SMS_SCAN_START_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_START_RES",
176 [MSG_SMS_SCAN_STOP_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_STOP_REQ",
177 [MSG_SMS_SCAN_STOP_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_STOP_RES",
178 [MSG_SMS_SCAN_PROGRESS_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_PROGRESS_IND",
179 [MSG_SMS_SCAN_COMPLETE_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SCAN_COMPLETE_IND",
180 [MSG_SMS_LOG_ITEM
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOG_ITEM",
181 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ",
182 [MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES",
183 [MSG_SMS_HO_PER_SLICES_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_PER_SLICES_IND",
184 [MSG_SMS_HO_INBAND_POWER_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_INBAND_POWER_IND",
185 [MSG_SMS_MANUAL_DEMOD_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MANUAL_DEMOD_REQ",
186 [MSG_SMS_HO_TUNE_ON_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_TUNE_ON_REQ",
187 [MSG_SMS_HO_TUNE_ON_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_TUNE_ON_RES",
188 [MSG_SMS_HO_TUNE_OFF_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_TUNE_OFF_REQ",
189 [MSG_SMS_HO_TUNE_OFF_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_TUNE_OFF_RES",
190 [MSG_SMS_HO_PEEK_FREQ_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_PEEK_FREQ_REQ",
191 [MSG_SMS_HO_PEEK_FREQ_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_PEEK_FREQ_RES",
192 [MSG_SMS_HO_PEEK_FREQ_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HO_PEEK_FREQ_IND",
193 [MSG_SMS_MB_ATTEN_SET_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_ATTEN_SET_REQ",
194 [MSG_SMS_MB_ATTEN_SET_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MB_ATTEN_SET_RES",
195 [MSG_SMS_ENABLE_STAT_IN_I2C_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ENABLE_STAT_IN_I2C_REQ",
196 [MSG_SMS_ENABLE_STAT_IN_I2C_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ENABLE_STAT_IN_I2C_RES",
197 [MSG_SMS_SET_ANTENNA_CONFIG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_ANTENNA_CONFIG_REQ",
198 [MSG_SMS_SET_ANTENNA_CONFIG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_ANTENNA_CONFIG_RES",
199 [MSG_SMS_GET_STATISTICS_EX_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_STATISTICS_EX_REQ",
200 [MSG_SMS_GET_STATISTICS_EX_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_STATISTICS_EX_RES",
201 [MSG_SMS_SLEEP_RESUME_COMP_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SLEEP_RESUME_COMP_IND",
202 [MSG_SMS_SWITCH_HOST_INTERFACE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWITCH_HOST_INTERFACE_REQ",
203 [MSG_SMS_SWITCH_HOST_INTERFACE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWITCH_HOST_INTERFACE_RES",
204 [MSG_SMS_DATA_DOWNLOAD_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_DOWNLOAD_REQ",
205 [MSG_SMS_DATA_DOWNLOAD_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_DOWNLOAD_RES",
206 [MSG_SMS_DATA_VALIDITY_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_VALIDITY_REQ",
207 [MSG_SMS_DATA_VALIDITY_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_VALIDITY_RES",
208 [MSG_SMS_SWDOWNLOAD_TRIGGER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWDOWNLOAD_TRIGGER_REQ",
209 [MSG_SMS_SWDOWNLOAD_TRIGGER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWDOWNLOAD_TRIGGER_RES",
210 [MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ",
211 [MSG_SMS_SWDOWNLOAD_BACKDOOR_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_RES",
212 [MSG_SMS_GET_VERSION_EX_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_VERSION_EX_REQ",
213 [MSG_SMS_GET_VERSION_EX_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_VERSION_EX_RES",
214 [MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ",
215 [MSG_SMS_CLOCK_OUTPUT_CONFIG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_RES",
216 [MSG_SMS_I2C_SET_FREQ_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_I2C_SET_FREQ_REQ",
217 [MSG_SMS_I2C_SET_FREQ_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_I2C_SET_FREQ_RES",
218 [MSG_SMS_GENERIC_I2C_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_I2C_REQ",
219 [MSG_SMS_GENERIC_I2C_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GENERIC_I2C_RES",
220 [MSG_SMS_DVBT_BDA_DATA
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DVBT_BDA_DATA",
221 [MSG_SW_RELOAD_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SW_RELOAD_REQ",
222 [MSG_SMS_DATA_MSG
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_MSG",
223 [MSG_TABLE_UPLOAD_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_TABLE_UPLOAD_REQ",
224 [MSG_TABLE_UPLOAD_RES
- MSG_TYPE_BASE_VAL
] = "MSG_TABLE_UPLOAD_RES",
225 [MSG_SW_RELOAD_START_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SW_RELOAD_START_REQ",
226 [MSG_SW_RELOAD_START_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SW_RELOAD_START_RES",
227 [MSG_SW_RELOAD_EXEC_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SW_RELOAD_EXEC_REQ",
228 [MSG_SW_RELOAD_EXEC_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SW_RELOAD_EXEC_RES",
229 [MSG_SMS_SPI_INT_LINE_SET_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_INT_LINE_SET_REQ",
230 [MSG_SMS_SPI_INT_LINE_SET_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_INT_LINE_SET_RES",
231 [MSG_SMS_GPIO_CONFIG_EX_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_CONFIG_EX_REQ",
232 [MSG_SMS_GPIO_CONFIG_EX_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GPIO_CONFIG_EX_RES",
233 [MSG_SMS_WATCHDOG_ACT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_WATCHDOG_ACT_REQ",
234 [MSG_SMS_WATCHDOG_ACT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_WATCHDOG_ACT_RES",
235 [MSG_SMS_LOOPBACK_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOOPBACK_REQ",
236 [MSG_SMS_LOOPBACK_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOOPBACK_RES",
237 [MSG_SMS_RAW_CAPTURE_START_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RAW_CAPTURE_START_REQ",
238 [MSG_SMS_RAW_CAPTURE_START_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RAW_CAPTURE_START_RES",
239 [MSG_SMS_RAW_CAPTURE_ABORT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RAW_CAPTURE_ABORT_REQ",
240 [MSG_SMS_RAW_CAPTURE_ABORT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RAW_CAPTURE_ABORT_RES",
241 [MSG_SMS_RAW_CAPTURE_COMPLETE_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_RAW_CAPTURE_COMPLETE_IND",
242 [MSG_SMS_DATA_PUMP_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_PUMP_IND",
243 [MSG_SMS_DATA_PUMP_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_PUMP_REQ",
244 [MSG_SMS_DATA_PUMP_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DATA_PUMP_RES",
245 [MSG_SMS_FLASH_DL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_FLASH_DL_REQ",
246 [MSG_SMS_EXEC_TEST_1_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXEC_TEST_1_REQ",
247 [MSG_SMS_EXEC_TEST_1_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXEC_TEST_1_RES",
248 [MSG_SMS_ENBALE_TS_INTERFACE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ENBALE_TS_INTERFACE_REQ",
249 [MSG_SMS_ENBALE_TS_INTERFACE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ENBALE_TS_INTERFACE_RES",
250 [MSG_SMS_SPI_SET_BUS_WIDTH_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_SET_BUS_WIDTH_REQ",
251 [MSG_SMS_SPI_SET_BUS_WIDTH_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SPI_SET_BUS_WIDTH_RES",
252 [MSG_SMS_SEND_EMM_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_EMM_REQ",
253 [MSG_SMS_SEND_EMM_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_EMM_RES",
254 [MSG_SMS_DISABLE_TS_INTERFACE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DISABLE_TS_INTERFACE_REQ",
255 [MSG_SMS_DISABLE_TS_INTERFACE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DISABLE_TS_INTERFACE_RES",
256 [MSG_SMS_IS_BUF_FREE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IS_BUF_FREE_REQ",
257 [MSG_SMS_IS_BUF_FREE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IS_BUF_FREE_RES",
258 [MSG_SMS_EXT_ANTENNA_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXT_ANTENNA_REQ",
259 [MSG_SMS_EXT_ANTENNA_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXT_ANTENNA_RES",
260 [MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE",
261 [MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE",
262 [MSG_SMS_BATTERY_LEVEL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BATTERY_LEVEL_REQ",
263 [MSG_SMS_BATTERY_LEVEL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_BATTERY_LEVEL_RES",
264 [MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE",
265 [MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE",
266 [MSG_SMS_FM_RADIO_BLOCK_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_FM_RADIO_BLOCK_IND",
267 [MSG_SMS_HOST_NOTIFICATION_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_HOST_NOTIFICATION_IND",
268 [MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE",
269 [MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE",
270 [MSG_SMS_CMMB_GET_NETWORKS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_NETWORKS_REQ",
271 [MSG_SMS_CMMB_GET_NETWORKS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_NETWORKS_RES",
272 [MSG_SMS_CMMB_START_SERVICE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_START_SERVICE_REQ",
273 [MSG_SMS_CMMB_START_SERVICE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_START_SERVICE_RES",
274 [MSG_SMS_CMMB_STOP_SERVICE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_STOP_SERVICE_REQ",
275 [MSG_SMS_CMMB_STOP_SERVICE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_STOP_SERVICE_RES",
276 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ",
277 [MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES",
278 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ",
279 [MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES",
280 [MSG_SMS_CMMB_START_CONTROL_INFO_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_START_CONTROL_INFO_REQ",
281 [MSG_SMS_CMMB_START_CONTROL_INFO_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_START_CONTROL_INFO_RES",
282 [MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ",
283 [MSG_SMS_CMMB_STOP_CONTROL_INFO_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_RES",
284 [MSG_SMS_ISDBT_TUNE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_TUNE_REQ",
285 [MSG_SMS_ISDBT_TUNE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ISDBT_TUNE_RES",
286 [MSG_SMS_TRANSMISSION_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_TRANSMISSION_IND",
287 [MSG_SMS_PID_STATISTICS_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_PID_STATISTICS_IND",
288 [MSG_SMS_POWER_DOWN_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_DOWN_IND",
289 [MSG_SMS_POWER_DOWN_CONF
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_DOWN_CONF",
290 [MSG_SMS_POWER_UP_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_UP_IND",
291 [MSG_SMS_POWER_UP_CONF
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_UP_CONF",
292 [MSG_SMS_POWER_MODE_SET_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_MODE_SET_REQ",
293 [MSG_SMS_POWER_MODE_SET_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_POWER_MODE_SET_RES",
294 [MSG_SMS_DEBUG_HOST_EVENT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DEBUG_HOST_EVENT_REQ",
295 [MSG_SMS_DEBUG_HOST_EVENT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DEBUG_HOST_EVENT_RES",
296 [MSG_SMS_NEW_CRYSTAL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NEW_CRYSTAL_REQ",
297 [MSG_SMS_NEW_CRYSTAL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NEW_CRYSTAL_RES",
298 [MSG_SMS_CONFIG_SPI_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CONFIG_SPI_REQ",
299 [MSG_SMS_CONFIG_SPI_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CONFIG_SPI_RES",
300 [MSG_SMS_I2C_SHORT_STAT_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_I2C_SHORT_STAT_IND",
301 [MSG_SMS_START_IR_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_START_IR_REQ",
302 [MSG_SMS_START_IR_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_START_IR_RES",
303 [MSG_SMS_IR_SAMPLES_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IR_SAMPLES_IND",
304 [MSG_SMS_CMMB_CA_SERVICE_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_CA_SERVICE_IND",
305 [MSG_SMS_SLAVE_DEVICE_DETECTED
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SLAVE_DEVICE_DETECTED",
306 [MSG_SMS_INTERFACE_LOCK_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_INTERFACE_LOCK_IND",
307 [MSG_SMS_INTERFACE_UNLOCK_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_INTERFACE_UNLOCK_IND",
308 [MSG_SMS_SEND_ROSUM_BUFF_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_ROSUM_BUFF_REQ",
309 [MSG_SMS_SEND_ROSUM_BUFF_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_ROSUM_BUFF_RES",
310 [MSG_SMS_ROSUM_BUFF
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_ROSUM_BUFF",
311 [MSG_SMS_SET_AES128_KEY_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_AES128_KEY_REQ",
312 [MSG_SMS_SET_AES128_KEY_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_AES128_KEY_RES",
313 [MSG_SMS_MBBMS_WRITE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MBBMS_WRITE_REQ",
314 [MSG_SMS_MBBMS_WRITE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MBBMS_WRITE_RES",
315 [MSG_SMS_MBBMS_READ_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MBBMS_READ_IND",
316 [MSG_SMS_IQ_STREAM_START_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IQ_STREAM_START_REQ",
317 [MSG_SMS_IQ_STREAM_START_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IQ_STREAM_START_RES",
318 [MSG_SMS_IQ_STREAM_STOP_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IQ_STREAM_STOP_REQ",
319 [MSG_SMS_IQ_STREAM_STOP_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IQ_STREAM_STOP_RES",
320 [MSG_SMS_IQ_STREAM_DATA_BLOCK
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_IQ_STREAM_DATA_BLOCK",
321 [MSG_SMS_GET_EEPROM_VERSION_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_EEPROM_VERSION_REQ",
322 [MSG_SMS_GET_EEPROM_VERSION_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_GET_EEPROM_VERSION_RES",
323 [MSG_SMS_SIGNAL_DETECTED_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SIGNAL_DETECTED_IND",
324 [MSG_SMS_NO_SIGNAL_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NO_SIGNAL_IND",
325 [MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ",
326 [MSG_SMS_MRC_SHUTDOWN_SLAVE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_RES",
327 [MSG_SMS_MRC_BRINGUP_SLAVE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_BRINGUP_SLAVE_REQ",
328 [MSG_SMS_MRC_BRINGUP_SLAVE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_BRINGUP_SLAVE_RES",
329 [MSG_SMS_EXTERNAL_LNA_CTRL_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXTERNAL_LNA_CTRL_REQ",
330 [MSG_SMS_EXTERNAL_LNA_CTRL_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_EXTERNAL_LNA_CTRL_RES",
331 [MSG_SMS_SET_PERIODIC_STATISTICS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_PERIODIC_STATISTICS_REQ",
332 [MSG_SMS_SET_PERIODIC_STATISTICS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SET_PERIODIC_STATISTICS_RES",
333 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ",
334 [MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES",
335 [LOCAL_TUNE
- MSG_TYPE_BASE_VAL
] = "LOCAL_TUNE",
336 [LOCAL_IFFT_H_ICI
- MSG_TYPE_BASE_VAL
] = "LOCAL_IFFT_H_ICI",
337 [MSG_RESYNC_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_RESYNC_REQ",
338 [MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ",
339 [MSG_SMS_CMMB_GET_MRC_STATISTICS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_RES",
340 [MSG_SMS_LOG_EX_ITEM
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LOG_EX_ITEM",
341 [MSG_SMS_DEVICE_DATA_LOSS_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DEVICE_DATA_LOSS_IND",
342 [MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND",
343 [MSG_SMS_USER_MSG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_USER_MSG_REQ",
344 [MSG_SMS_USER_MSG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_USER_MSG_RES",
345 [MSG_SMS_SMART_CARD_INIT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SMART_CARD_INIT_REQ",
346 [MSG_SMS_SMART_CARD_INIT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SMART_CARD_INIT_RES",
347 [MSG_SMS_SMART_CARD_WRITE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SMART_CARD_WRITE_REQ",
348 [MSG_SMS_SMART_CARD_WRITE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SMART_CARD_WRITE_RES",
349 [MSG_SMS_SMART_CARD_READ_IND
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SMART_CARD_READ_IND",
350 [MSG_SMS_TSE_ENABLE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_TSE_ENABLE_REQ",
351 [MSG_SMS_TSE_ENABLE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_TSE_ENABLE_RES",
352 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ",
353 [MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES",
354 [MSG_SMS_LED_CONFIG_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LED_CONFIG_REQ",
355 [MSG_SMS_LED_CONFIG_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_LED_CONFIG_RES",
356 [MSG_PWM_ANTENNA_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_PWM_ANTENNA_REQ",
357 [MSG_PWM_ANTENNA_RES
- MSG_TYPE_BASE_VAL
] = "MSG_PWM_ANTENNA_RES",
358 [MSG_SMS_CMMB_SMD_SN_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SMD_SN_REQ",
359 [MSG_SMS_CMMB_SMD_SN_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SMD_SN_RES",
360 [MSG_SMS_CMMB_SET_CA_CW_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_CA_CW_REQ",
361 [MSG_SMS_CMMB_SET_CA_CW_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_CA_CW_RES",
362 [MSG_SMS_CMMB_SET_CA_SALT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_CA_SALT_REQ",
363 [MSG_SMS_CMMB_SET_CA_SALT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_CMMB_SET_CA_SALT_RES",
364 [MSG_SMS_NSCD_INIT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_INIT_REQ",
365 [MSG_SMS_NSCD_INIT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_INIT_RES",
366 [MSG_SMS_NSCD_PROCESS_SECTION_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_PROCESS_SECTION_REQ",
367 [MSG_SMS_NSCD_PROCESS_SECTION_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_PROCESS_SECTION_RES",
368 [MSG_SMS_DBD_CREATE_OBJECT_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_CREATE_OBJECT_REQ",
369 [MSG_SMS_DBD_CREATE_OBJECT_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_CREATE_OBJECT_RES",
370 [MSG_SMS_DBD_CONFIGURE_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_CONFIGURE_REQ",
371 [MSG_SMS_DBD_CONFIGURE_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_CONFIGURE_RES",
372 [MSG_SMS_DBD_SET_KEYS_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_SET_KEYS_REQ",
373 [MSG_SMS_DBD_SET_KEYS_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_SET_KEYS_RES",
374 [MSG_SMS_DBD_PROCESS_HEADER_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_HEADER_REQ",
375 [MSG_SMS_DBD_PROCESS_HEADER_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_HEADER_RES",
376 [MSG_SMS_DBD_PROCESS_DATA_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_DATA_REQ",
377 [MSG_SMS_DBD_PROCESS_DATA_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_DATA_RES",
378 [MSG_SMS_DBD_PROCESS_GET_DATA_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_GET_DATA_REQ",
379 [MSG_SMS_DBD_PROCESS_GET_DATA_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_DBD_PROCESS_GET_DATA_RES",
380 [MSG_SMS_NSCD_OPEN_SESSION_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_OPEN_SESSION_REQ",
381 [MSG_SMS_NSCD_OPEN_SESSION_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_NSCD_OPEN_SESSION_RES",
382 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ",
383 [MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES
- MSG_TYPE_BASE_VAL
] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES",
384 [MSG_LAST_MSG_TYPE
- MSG_TYPE_BASE_VAL
] = "MSG_LAST_MSG_TYPE",
387 char *smscore_translate_msg(enum msg_types msgtype
)
389 int i
= msgtype
- MSG_TYPE_BASE_VAL
;
392 if (i
< 0 || i
>= ARRAY_SIZE(siano_msgs
))
393 return "Unknown msg type";
398 return "Unknown msg type";
402 EXPORT_SYMBOL_GPL(smscore_translate_msg
);
404 void smscore_set_board_id(struct smscore_device_t
*core
, int id
)
409 int smscore_led_state(struct smscore_device_t
*core
, int led
)
412 core
->led_state
= led
;
413 return core
->led_state
;
415 EXPORT_SYMBOL_GPL(smscore_set_board_id
);
417 int smscore_get_board_id(struct smscore_device_t
*core
)
419 return core
->board_id
;
421 EXPORT_SYMBOL_GPL(smscore_get_board_id
);
423 struct smscore_registry_entry_t
{
424 struct list_head entry
;
427 enum sms_device_type_st type
;
430 static struct list_head g_smscore_notifyees
;
431 static struct list_head g_smscore_devices
;
432 static struct mutex g_smscore_deviceslock
;
434 static struct list_head g_smscore_registry
;
435 static struct mutex g_smscore_registrylock
;
437 static int default_mode
= DEVICE_MODE_NONE
;
439 module_param(default_mode
, int, 0644);
440 MODULE_PARM_DESC(default_mode
, "default firmware id (device mode)");
442 static struct smscore_registry_entry_t
*smscore_find_registry(char *devpath
)
444 struct smscore_registry_entry_t
*entry
;
445 struct list_head
*next
;
447 kmutex_lock(&g_smscore_registrylock
);
448 for (next
= g_smscore_registry
.next
;
449 next
!= &g_smscore_registry
;
451 entry
= (struct smscore_registry_entry_t
*) next
;
452 if (!strcmp(entry
->devpath
, devpath
)) {
453 kmutex_unlock(&g_smscore_registrylock
);
457 entry
= kmalloc(sizeof(struct smscore_registry_entry_t
), GFP_KERNEL
);
459 entry
->mode
= default_mode
;
460 strcpy(entry
->devpath
, devpath
);
461 list_add(&entry
->entry
, &g_smscore_registry
);
463 sms_err("failed to create smscore_registry.");
464 kmutex_unlock(&g_smscore_registrylock
);
468 int smscore_registry_getmode(char *devpath
)
470 struct smscore_registry_entry_t
*entry
;
472 entry
= smscore_find_registry(devpath
);
476 sms_err("No registry found.");
480 EXPORT_SYMBOL_GPL(smscore_registry_getmode
);
482 static enum sms_device_type_st
smscore_registry_gettype(char *devpath
)
484 struct smscore_registry_entry_t
*entry
;
486 entry
= smscore_find_registry(devpath
);
490 sms_err("No registry found.");
495 static void smscore_registry_setmode(char *devpath
, int mode
)
497 struct smscore_registry_entry_t
*entry
;
499 entry
= smscore_find_registry(devpath
);
503 sms_err("No registry found.");
506 static void smscore_registry_settype(char *devpath
,
507 enum sms_device_type_st type
)
509 struct smscore_registry_entry_t
*entry
;
511 entry
= smscore_find_registry(devpath
);
515 sms_err("No registry found.");
519 static void list_add_locked(struct list_head
*new, struct list_head
*head
,
524 spin_lock_irqsave(lock
, flags
);
528 spin_unlock_irqrestore(lock
, flags
);
532 * register a client callback that called when device plugged in/unplugged
533 * NOTE: if devices exist callback is called immediately for each device
535 * @param hotplug callback
537 * @return 0 on success, <0 on error.
539 int smscore_register_hotplug(hotplug_t hotplug
)
541 struct smscore_device_notifyee_t
*notifyee
;
542 struct list_head
*next
, *first
;
545 kmutex_lock(&g_smscore_deviceslock
);
547 notifyee
= kmalloc(sizeof(struct smscore_device_notifyee_t
),
550 /* now notify callback about existing devices */
551 first
= &g_smscore_devices
;
552 for (next
= first
->next
;
553 next
!= first
&& !rc
;
555 struct smscore_device_t
*coredev
=
556 (struct smscore_device_t
*) next
;
557 rc
= hotplug(coredev
, coredev
->device
, 1);
561 notifyee
->hotplug
= hotplug
;
562 list_add(¬ifyee
->entry
, &g_smscore_notifyees
);
568 kmutex_unlock(&g_smscore_deviceslock
);
572 EXPORT_SYMBOL_GPL(smscore_register_hotplug
);
575 * unregister a client callback that called when device plugged in/unplugged
577 * @param hotplug callback
580 void smscore_unregister_hotplug(hotplug_t hotplug
)
582 struct list_head
*next
, *first
;
584 kmutex_lock(&g_smscore_deviceslock
);
586 first
= &g_smscore_notifyees
;
588 for (next
= first
->next
; next
!= first
;) {
589 struct smscore_device_notifyee_t
*notifyee
=
590 (struct smscore_device_notifyee_t
*) next
;
593 if (notifyee
->hotplug
== hotplug
) {
594 list_del(¬ifyee
->entry
);
599 kmutex_unlock(&g_smscore_deviceslock
);
601 EXPORT_SYMBOL_GPL(smscore_unregister_hotplug
);
603 static void smscore_notify_clients(struct smscore_device_t
*coredev
)
605 struct smscore_client_t
*client
;
607 /* the client must call smscore_unregister_client from remove handler */
608 while (!list_empty(&coredev
->clients
)) {
609 client
= (struct smscore_client_t
*) coredev
->clients
.next
;
610 client
->onremove_handler(client
->context
);
614 static int smscore_notify_callbacks(struct smscore_device_t
*coredev
,
615 struct device
*device
, int arrival
)
617 struct smscore_device_notifyee_t
*elem
;
620 /* note: must be called under g_deviceslock */
622 list_for_each_entry(elem
, &g_smscore_notifyees
, entry
) {
623 rc
= elem
->hotplug(coredev
, device
, arrival
);
632 smscore_buffer_t
*smscore_createbuffer(u8
*buffer
, void *common_buffer
,
633 dma_addr_t common_buffer_phys
)
635 struct smscore_buffer_t
*cb
;
637 cb
= kzalloc(sizeof(struct smscore_buffer_t
), GFP_KERNEL
);
639 sms_info("kzalloc(...) failed");
644 cb
->offset_in_common
= buffer
- (u8
*) common_buffer
;
645 cb
->phys
= common_buffer_phys
+ cb
->offset_in_common
;
651 * creates coredev object for a device, prepares buffers,
652 * creates buffer mappings, notifies registered hotplugs about new device.
654 * @param params device pointer to struct with device specific parameters
656 * @param coredev pointer to a value that receives created coredev object
658 * @return 0 on success, <0 on error.
660 int smscore_register_device(struct smsdevice_params_t
*params
,
661 struct smscore_device_t
**coredev
)
663 struct smscore_device_t
*dev
;
666 dev
= kzalloc(sizeof(struct smscore_device_t
), GFP_KERNEL
);
668 sms_info("kzalloc(...) failed");
672 /* init list entry so it could be safe in smscore_unregister_device */
673 INIT_LIST_HEAD(&dev
->entry
);
676 INIT_LIST_HEAD(&dev
->clients
);
677 INIT_LIST_HEAD(&dev
->buffers
);
680 spin_lock_init(&dev
->clientslock
);
681 spin_lock_init(&dev
->bufferslock
);
683 /* init completion events */
684 init_completion(&dev
->version_ex_done
);
685 init_completion(&dev
->data_download_done
);
686 init_completion(&dev
->data_validity_done
);
687 init_completion(&dev
->trigger_done
);
688 init_completion(&dev
->init_device_done
);
689 init_completion(&dev
->reload_start_done
);
690 init_completion(&dev
->resume_done
);
691 init_completion(&dev
->gpio_configuration_done
);
692 init_completion(&dev
->gpio_set_level_done
);
693 init_completion(&dev
->gpio_get_level_done
);
694 init_completion(&dev
->ir_init_done
);
696 /* Buffer management */
697 init_waitqueue_head(&dev
->buffer_mng_waitq
);
699 /* alloc common buffer */
700 dev
->common_buffer_size
= params
->buffer_size
* params
->num_buffers
;
701 dev
->common_buffer
= dma_alloc_coherent(NULL
, dev
->common_buffer_size
,
702 &dev
->common_buffer_phys
,
703 GFP_KERNEL
| GFP_DMA
);
704 if (!dev
->common_buffer
) {
705 smscore_unregister_device(dev
);
709 /* prepare dma buffers */
710 for (buffer
= dev
->common_buffer
;
711 dev
->num_buffers
< params
->num_buffers
;
712 dev
->num_buffers
++, buffer
+= params
->buffer_size
) {
713 struct smscore_buffer_t
*cb
;
715 cb
= smscore_createbuffer(buffer
, dev
->common_buffer
,
716 dev
->common_buffer_phys
);
718 smscore_unregister_device(dev
);
722 smscore_putbuffer(dev
, cb
);
725 sms_info("allocated %d buffers", dev
->num_buffers
);
727 dev
->mode
= DEVICE_MODE_NONE
;
728 dev
->board_id
= SMS_BOARD_UNKNOWN
;
729 dev
->context
= params
->context
;
730 dev
->device
= params
->device
;
731 dev
->setmode_handler
= params
->setmode_handler
;
732 dev
->detectmode_handler
= params
->detectmode_handler
;
733 dev
->sendrequest_handler
= params
->sendrequest_handler
;
734 dev
->preload_handler
= params
->preload_handler
;
735 dev
->postload_handler
= params
->postload_handler
;
737 dev
->device_flags
= params
->flags
;
738 strcpy(dev
->devpath
, params
->devpath
);
740 smscore_registry_settype(dev
->devpath
, params
->device_type
);
742 /* add device to devices list */
743 kmutex_lock(&g_smscore_deviceslock
);
744 list_add(&dev
->entry
, &g_smscore_devices
);
745 kmutex_unlock(&g_smscore_deviceslock
);
749 sms_info("device %p created", dev
);
753 EXPORT_SYMBOL_GPL(smscore_register_device
);
756 static int smscore_sendrequest_and_wait(struct smscore_device_t
*coredev
,
757 void *buffer
, size_t size
, struct completion
*completion
) {
760 if (completion
== NULL
)
762 init_completion(completion
);
764 rc
= coredev
->sendrequest_handler(coredev
->context
, buffer
, size
);
766 sms_info("sendrequest returned error %d", rc
);
770 return wait_for_completion_timeout(completion
,
771 msecs_to_jiffies(SMS_PROTOCOL_MAX_RAOUNDTRIP_MS
)) ?
776 * Starts & enables IR operations
778 * @return 0 on success, < 0 on error.
780 static int smscore_init_ir(struct smscore_device_t
*coredev
)
786 coredev
->ir
.dev
= NULL
;
787 ir_io
= sms_get_board(smscore_get_board_id(coredev
))->board_cfg
.ir
;
788 if (ir_io
) {/* only if IR port exist we use IR sub-module */
789 sms_info("IR loading");
790 rc
= sms_ir_init(coredev
);
793 sms_err("Error initialization DTV IR sub-module");
795 buffer
= kmalloc(sizeof(struct sms_msg_data2
) +
797 GFP_KERNEL
| GFP_DMA
);
799 struct sms_msg_data2
*msg
=
800 (struct sms_msg_data2
*)
801 SMS_ALIGN_ADDRESS(buffer
);
803 SMS_INIT_MSG(&msg
->x_msg_header
,
804 MSG_SMS_START_IR_REQ
,
805 sizeof(struct sms_msg_data2
));
806 msg
->msg_data
[0] = coredev
->ir
.controller
;
807 msg
->msg_data
[1] = coredev
->ir
.timeout
;
809 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
810 msg
->x_msg_header
. msg_length
,
811 &coredev
->ir_init_done
);
816 ("Sending IR initialization message failed");
819 sms_info("IR port has not been detected");
825 * configures device features according to board configuration structure.
827 * @param coredev pointer to a coredev object returned by
828 * smscore_register_device
830 * @return 0 on success, <0 on error.
832 static int smscore_configure_board(struct smscore_device_t
*coredev
)
834 struct sms_board
*board
;
836 board
= sms_get_board(coredev
->board_id
);
838 sms_err("no board configuration exist.");
843 struct sms_msg_data mtu_msg
;
844 sms_debug("set max transmit unit %d", board
->mtu
);
846 mtu_msg
.x_msg_header
.msg_src_id
= 0;
847 mtu_msg
.x_msg_header
.msg_dst_id
= HIF_TASK
;
848 mtu_msg
.x_msg_header
.msg_flags
= 0;
849 mtu_msg
.x_msg_header
.msg_type
= MSG_SMS_SET_MAX_TX_MSG_LEN_REQ
;
850 mtu_msg
.x_msg_header
.msg_length
= sizeof(mtu_msg
);
851 mtu_msg
.msg_data
[0] = board
->mtu
;
853 coredev
->sendrequest_handler(coredev
->context
, &mtu_msg
,
857 if (board
->crystal
) {
858 struct sms_msg_data crys_msg
;
859 sms_debug("set crystal value %d", board
->crystal
);
861 SMS_INIT_MSG(&crys_msg
.x_msg_header
,
862 MSG_SMS_NEW_CRYSTAL_REQ
,
864 crys_msg
.msg_data
[0] = board
->crystal
;
866 coredev
->sendrequest_handler(coredev
->context
, &crys_msg
,
874 * sets initial device mode and notifies client hotplugs that device is ready
876 * @param coredev pointer to a coredev object returned by
877 * smscore_register_device
879 * @return 0 on success, <0 on error.
881 int smscore_start_device(struct smscore_device_t
*coredev
)
884 int board_id
= smscore_get_board_id(coredev
);
885 int mode
= smscore_registry_getmode(coredev
->devpath
);
887 /* Device is initialized as DEVICE_MODE_NONE */
888 if (board_id
!= SMS_BOARD_UNKNOWN
&& mode
== DEVICE_MODE_NONE
)
889 mode
= sms_get_board(board_id
)->default_mode
;
891 rc
= smscore_set_device_mode(coredev
, mode
);
893 sms_info("set device mode faile , rc %d", rc
);
896 rc
= smscore_configure_board(coredev
);
898 sms_info("configure board failed , rc %d", rc
);
902 kmutex_lock(&g_smscore_deviceslock
);
904 rc
= smscore_notify_callbacks(coredev
, coredev
->device
, 1);
905 smscore_init_ir(coredev
);
907 sms_info("device %p started, rc %d", coredev
, rc
);
909 kmutex_unlock(&g_smscore_deviceslock
);
913 EXPORT_SYMBOL_GPL(smscore_start_device
);
916 static int smscore_load_firmware_family2(struct smscore_device_t
*coredev
,
917 void *buffer
, size_t size
)
919 struct sms_firmware
*firmware
= (struct sms_firmware
*) buffer
;
920 struct sms_msg_data4
*msg
;
921 u32 mem_address
, calc_checksum
= 0;
923 u8
*payload
= firmware
->payload
;
925 firmware
->start_address
= le32_to_cpup((__le32
*)&firmware
->start_address
);
926 firmware
->length
= le32_to_cpup((__le32
*)&firmware
->length
);
928 mem_address
= firmware
->start_address
;
930 sms_info("loading FW to addr 0x%x size %d",
931 mem_address
, firmware
->length
);
932 if (coredev
->preload_handler
) {
933 rc
= coredev
->preload_handler(coredev
->context
);
938 /* PAGE_SIZE buffer shall be enough and dma aligned */
939 msg
= kmalloc(PAGE_SIZE
, GFP_KERNEL
| GFP_DMA
);
943 if (coredev
->mode
!= DEVICE_MODE_NONE
) {
944 sms_debug("sending reload command.");
945 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SW_RELOAD_START_REQ
,
946 sizeof(struct sms_msg_hdr
));
947 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
948 msg
->x_msg_header
.msg_length
,
949 &coredev
->reload_start_done
);
951 sms_err("device reload failed, rc %d", rc
);
952 goto exit_fw_download
;
954 mem_address
= *(u32
*) &payload
[20];
957 for (i
= 0, ptr
= (u32
*)firmware
->payload
; i
< firmware
->length
/4 ;
959 calc_checksum
+= *ptr
;
961 while (size
&& rc
>= 0) {
962 struct sms_data_download
*data_msg
=
963 (struct sms_data_download
*) msg
;
964 int payload_size
= min_t(int, size
, SMS_MAX_PAYLOAD_SIZE
);
966 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_DATA_DOWNLOAD_REQ
,
967 (u16
)(sizeof(struct sms_msg_hdr
) +
968 sizeof(u32
) + payload_size
));
970 data_msg
->mem_addr
= mem_address
;
971 memcpy(data_msg
->payload
, payload
, payload_size
);
973 rc
= smscore_sendrequest_and_wait(coredev
, data_msg
,
974 data_msg
->x_msg_header
.msg_length
,
975 &coredev
->data_download_done
);
977 payload
+= payload_size
;
978 size
-= payload_size
;
979 mem_address
+= payload_size
;
983 goto exit_fw_download
;
985 sms_debug("sending MSG_SMS_DATA_VALIDITY_REQ expecting 0x%x",
987 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_DATA_VALIDITY_REQ
,
988 sizeof(msg
->x_msg_header
) +
990 msg
->msg_data
[0] = firmware
->start_address
;
992 msg
->msg_data
[1] = firmware
->length
;
993 msg
->msg_data
[2] = 0; /* Regular checksum*/
994 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
995 msg
->x_msg_header
.msg_length
,
996 &coredev
->data_validity_done
);
998 goto exit_fw_download
;
1000 if (coredev
->mode
== DEVICE_MODE_NONE
) {
1001 struct sms_msg_data
*trigger_msg
=
1002 (struct sms_msg_data
*) msg
;
1004 sms_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ");
1005 SMS_INIT_MSG(&msg
->x_msg_header
,
1006 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ
,
1007 sizeof(struct sms_msg_hdr
) +
1010 trigger_msg
->msg_data
[0] = firmware
->start_address
;
1012 trigger_msg
->msg_data
[1] = 6; /* Priority */
1013 trigger_msg
->msg_data
[2] = 0x200; /* Stack size */
1014 trigger_msg
->msg_data
[3] = 0; /* Parameter */
1015 trigger_msg
->msg_data
[4] = 4; /* Task ID */
1017 rc
= smscore_sendrequest_and_wait(coredev
, trigger_msg
,
1018 trigger_msg
->x_msg_header
.msg_length
,
1019 &coredev
->trigger_done
);
1021 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SW_RELOAD_EXEC_REQ
,
1022 sizeof(struct sms_msg_hdr
));
1023 rc
= coredev
->sendrequest_handler(coredev
->context
, msg
,
1024 msg
->x_msg_header
.msg_length
);
1028 goto exit_fw_download
;
1031 * backward compatibility - wait to device_ready_done for
1032 * not more than 400 ms
1039 if (coredev
->postload_handler
) {
1040 sms_debug("rc=%d, postload=0x%p", rc
, coredev
->postload_handler
);
1042 return coredev
->postload_handler(coredev
->context
);
1045 sms_debug("rc=%d", rc
);
1049 static char *smscore_fw_lkup
[][DEVICE_MODE_MAX
] = {
1051 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_NOVA_12MHZ
,
1052 [DEVICE_MODE_DVBH
] = SMS_FW_DVB_NOVA_12MHZ
,
1053 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_NOVA_12MHZ
,
1054 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_NOVA_12MHZ
,
1055 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_NOVA_12MHZ
,
1056 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_NOVA_12MHZ
,
1059 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1060 [DEVICE_MODE_DVBH
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1061 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_NOVA_12MHZ_B0
,
1062 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1063 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_NOVA_12MHZ_B0
,
1064 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_NOVA_12MHZ_B0
,
1065 [DEVICE_MODE_FM_RADIO
] = SMS_FW_FM_RADIO
,
1066 [DEVICE_MODE_FM_RADIO_BDA
] = SMS_FW_FM_RADIO
,
1069 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_VEGA_12MHZ
,
1072 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_VENICE_12MHZ
,
1075 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_MING_APP
,
1078 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_PELE
,
1079 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_PELE
,
1082 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_RIO
,
1083 [DEVICE_MODE_DVBH
] = SMS_FW_DVBH_RIO
,
1084 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_RIO
,
1085 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_RIO
,
1086 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_RIO
,
1087 [DEVICE_MODE_FM_RADIO
] = SMS_FW_FM_RADIO_RIO
,
1088 [DEVICE_MODE_FM_RADIO_BDA
] = SMS_FW_FM_RADIO_RIO
,
1090 [SMS_DENVER_1530
] = {
1091 [DEVICE_MODE_ATSC
] = SMS_FW_ATSC_DENVER
,
1093 [SMS_DENVER_2160
] = {
1094 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_DENVER
,
1099 * get firmware file name from one of the two mechanisms : sms_boards or
1101 * @param coredev pointer to a coredev object returned by
1102 * smscore_register_device
1103 * @param mode requested mode of operation
1104 * @param lookup if 1, always get the fw filename from smscore_fw_lkup
1105 * table. if 0, try first to get from sms_boards
1107 * @return 0 on success, <0 on error.
1109 static char *smscore_get_fw_filename(struct smscore_device_t
*coredev
,
1113 int board_id
= smscore_get_board_id(coredev
);
1114 enum sms_device_type_st type
;
1116 type
= smscore_registry_gettype(coredev
->devpath
);
1118 /* Prevent looking outside the smscore_fw_lkup table */
1119 if (type
<= SMS_UNKNOWN_TYPE
|| type
>= SMS_NUM_OF_DEVICE_TYPES
)
1121 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
)
1124 sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
1126 fw
= sms_get_board(board_id
)->fw
;
1127 if (!fw
|| !fw
[mode
]) {
1128 sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
1130 return smscore_fw_lkup
[type
][mode
];
1137 * loads specified firmware into a buffer and calls device loadfirmware_handler
1139 * @param coredev pointer to a coredev object returned by
1140 * smscore_register_device
1141 * @param filename null-terminated string specifies firmware file name
1142 * @param loadfirmware_handler device handler that loads firmware
1144 * @return 0 on success, <0 on error.
1146 static int smscore_load_firmware_from_file(struct smscore_device_t
*coredev
,
1148 loadfirmware_t loadfirmware_handler
)
1153 const struct firmware
*fw
;
1155 char *fw_filename
= smscore_get_fw_filename(coredev
, mode
);
1157 sms_err("mode %d not supported on this device", mode
);
1160 sms_debug("Firmware name: %s", fw_filename
);
1162 if (loadfirmware_handler
== NULL
&& !(coredev
->device_flags
1163 & SMS_DEVICE_FAMILY2
))
1166 rc
= request_firmware(&fw
, fw_filename
, coredev
->device
);
1168 sms_err("failed to open firmware file \"%s\"", fw_filename
);
1171 sms_info("read fw %s, buffer size=0x%zx", fw_filename
, fw
->size
);
1172 fw_buf
= kmalloc(ALIGN(fw
->size
, SMS_ALLOC_ALIGNMENT
),
1173 GFP_KERNEL
| GFP_DMA
);
1175 sms_err("failed to allocate firmware buffer");
1178 memcpy(fw_buf
, fw
->data
, fw
->size
);
1179 fw_buf_size
= fw
->size
;
1181 rc
= (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) ?
1182 smscore_load_firmware_family2(coredev
, fw_buf
, fw_buf_size
)
1183 : loadfirmware_handler(coredev
->context
, fw_buf
,
1188 release_firmware(fw
);
1194 * notifies all clients registered with the device, notifies hotplugs,
1195 * frees all buffers and coredev object
1197 * @param coredev pointer to a coredev object returned by
1198 * smscore_register_device
1200 * @return 0 on success, <0 on error.
1202 void smscore_unregister_device(struct smscore_device_t
*coredev
)
1204 struct smscore_buffer_t
*cb
;
1205 int num_buffers
= 0;
1208 kmutex_lock(&g_smscore_deviceslock
);
1210 /* Release input device (IR) resources */
1211 sms_ir_exit(coredev
);
1213 smscore_notify_clients(coredev
);
1214 smscore_notify_callbacks(coredev
, NULL
, 0);
1216 /* at this point all buffers should be back
1217 * onresponse must no longer be called */
1220 while (!list_empty(&coredev
->buffers
)) {
1221 cb
= (struct smscore_buffer_t
*) coredev
->buffers
.next
;
1222 list_del(&cb
->entry
);
1226 if (num_buffers
== coredev
->num_buffers
)
1229 sms_info("exiting although not all buffers released.");
1233 sms_info("waiting for %d buffer(s)",
1234 coredev
->num_buffers
- num_buffers
);
1235 kmutex_unlock(&g_smscore_deviceslock
);
1237 kmutex_lock(&g_smscore_deviceslock
);
1240 sms_info("freed %d buffers", num_buffers
);
1242 if (coredev
->common_buffer
)
1243 dma_free_coherent(NULL
, coredev
->common_buffer_size
,
1244 coredev
->common_buffer
, coredev
->common_buffer_phys
);
1246 kfree(coredev
->fw_buf
);
1248 list_del(&coredev
->entry
);
1251 kmutex_unlock(&g_smscore_deviceslock
);
1253 sms_info("device %p destroyed", coredev
);
1255 EXPORT_SYMBOL_GPL(smscore_unregister_device
);
1257 static int smscore_detect_mode(struct smscore_device_t
*coredev
)
1259 void *buffer
= kmalloc(sizeof(struct sms_msg_hdr
) + SMS_DMA_ALIGNMENT
,
1260 GFP_KERNEL
| GFP_DMA
);
1261 struct sms_msg_hdr
*msg
=
1262 (struct sms_msg_hdr
*) SMS_ALIGN_ADDRESS(buffer
);
1268 SMS_INIT_MSG(msg
, MSG_SMS_GET_VERSION_EX_REQ
,
1269 sizeof(struct sms_msg_hdr
));
1271 rc
= smscore_sendrequest_and_wait(coredev
, msg
, msg
->msg_length
,
1272 &coredev
->version_ex_done
);
1274 sms_err("MSG_SMS_GET_VERSION_EX_REQ failed first try");
1276 if (wait_for_completion_timeout(&coredev
->resume_done
,
1277 msecs_to_jiffies(5000))) {
1278 rc
= smscore_sendrequest_and_wait(
1279 coredev
, msg
, msg
->msg_length
,
1280 &coredev
->version_ex_done
);
1282 sms_err("MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d",
1294 * send init device request and wait for response
1296 * @param coredev pointer to a coredev object returned by
1297 * smscore_register_device
1298 * @param mode requested mode of operation
1300 * @return 0 on success, <0 on error.
1302 static int smscore_init_device(struct smscore_device_t
*coredev
, int mode
)
1305 struct sms_msg_data
*msg
;
1308 buffer
= kmalloc(sizeof(struct sms_msg_data
) +
1309 SMS_DMA_ALIGNMENT
, GFP_KERNEL
| GFP_DMA
);
1311 sms_err("Could not allocate buffer for init device message.");
1315 msg
= (struct sms_msg_data
*)SMS_ALIGN_ADDRESS(buffer
);
1316 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_INIT_DEVICE_REQ
,
1317 sizeof(struct sms_msg_data
));
1318 msg
->msg_data
[0] = mode
;
1320 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
1321 msg
->x_msg_header
. msg_length
,
1322 &coredev
->init_device_done
);
1329 * calls device handler to change mode of operation
1330 * NOTE: stellar/usb may disconnect when changing mode
1332 * @param coredev pointer to a coredev object returned by
1333 * smscore_register_device
1334 * @param mode requested mode of operation
1336 * @return 0 on success, <0 on error.
1338 int smscore_set_device_mode(struct smscore_device_t
*coredev
, int mode
)
1342 sms_debug("set device mode to %d", mode
);
1343 if (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) {
1344 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
) {
1345 sms_err("invalid mode specified %d", mode
);
1349 smscore_registry_setmode(coredev
->devpath
, mode
);
1351 if (!(coredev
->device_flags
& SMS_DEVICE_NOT_READY
)) {
1352 rc
= smscore_detect_mode(coredev
);
1354 sms_err("mode detect failed %d", rc
);
1359 if (coredev
->mode
== mode
) {
1360 sms_info("device mode %d already set", mode
);
1364 if (!(coredev
->modes_supported
& (1 << mode
))) {
1365 rc
= smscore_load_firmware_from_file(coredev
,
1368 sms_info("firmware download success");
1370 sms_info("mode %d is already supported by running firmware",
1373 if (coredev
->fw_version
>= 0x800) {
1374 rc
= smscore_init_device(coredev
, mode
);
1376 sms_err("device init failed, rc %d.", rc
);
1379 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
) {
1380 sms_err("invalid mode specified %d", mode
);
1384 smscore_registry_setmode(coredev
->devpath
, mode
);
1386 if (coredev
->detectmode_handler
)
1387 coredev
->detectmode_handler(coredev
->context
,
1390 if (coredev
->mode
!= mode
&& coredev
->setmode_handler
)
1391 rc
= coredev
->setmode_handler(coredev
->context
, mode
);
1396 coredev
->mode
= mode
;
1397 coredev
->device_flags
&= ~SMS_DEVICE_NOT_READY
;
1399 buffer
= kmalloc(sizeof(struct sms_msg_data
) +
1400 SMS_DMA_ALIGNMENT
, GFP_KERNEL
| GFP_DMA
);
1402 struct sms_msg_data
*msg
= (struct sms_msg_data
*) SMS_ALIGN_ADDRESS(buffer
);
1404 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_INIT_DEVICE_REQ
,
1405 sizeof(struct sms_msg_data
));
1406 msg
->msg_data
[0] = mode
;
1408 rc
= smscore_sendrequest_and_wait(
1409 coredev
, msg
, msg
->x_msg_header
.msg_length
,
1410 &coredev
->init_device_done
);
1417 sms_err("return error code %d.", rc
);
1419 sms_debug("Success setting device mode.");
1425 * calls device handler to get current mode of operation
1427 * @param coredev pointer to a coredev object returned by
1428 * smscore_register_device
1430 * @return current mode
1432 int smscore_get_device_mode(struct smscore_device_t
*coredev
)
1434 return coredev
->mode
;
1436 EXPORT_SYMBOL_GPL(smscore_get_device_mode
);
1439 * find client by response id & type within the clients list.
1440 * return client handle or NULL.
1442 * @param coredev pointer to a coredev object returned by
1443 * smscore_register_device
1444 * @param data_type client data type (SMS_DONT_CARE for all types)
1445 * @param id client id (SMS_DONT_CARE for all id)
1449 smscore_client_t
*smscore_find_client(struct smscore_device_t
*coredev
,
1450 int data_type
, int id
)
1452 struct list_head
*first
;
1453 struct smscore_client_t
*client
;
1454 unsigned long flags
;
1455 struct list_head
*firstid
;
1456 struct smscore_idlist_t
*client_id
;
1458 spin_lock_irqsave(&coredev
->clientslock
, flags
);
1459 first
= &coredev
->clients
;
1460 list_for_each_entry(client
, first
, entry
) {
1461 firstid
= &client
->idlist
;
1462 list_for_each_entry(client_id
, firstid
, entry
) {
1463 if ((client_id
->id
== id
) &&
1464 (client_id
->data_type
== data_type
||
1465 (client_id
->data_type
== 0)))
1471 spin_unlock_irqrestore(&coredev
->clientslock
, flags
);
1476 * find client by response id/type, call clients onresponse handler
1477 * return buffer to pool on error
1479 * @param coredev pointer to a coredev object returned by
1480 * smscore_register_device
1481 * @param cb pointer to response buffer descriptor
1484 void smscore_onresponse(struct smscore_device_t
*coredev
,
1485 struct smscore_buffer_t
*cb
) {
1486 struct sms_msg_hdr
*phdr
= (struct sms_msg_hdr
*) ((u8
*) cb
->p
1488 struct smscore_client_t
*client
;
1490 static unsigned long last_sample_time
; /* = 0; */
1491 static int data_total
; /* = 0; */
1492 unsigned long time_now
= jiffies_to_msecs(jiffies
);
1494 if (!last_sample_time
)
1495 last_sample_time
= time_now
;
1497 if (time_now
- last_sample_time
> 10000) {
1498 sms_debug("data rate %d bytes/secs",
1499 (int)((data_total
* 1000) /
1500 (time_now
- last_sample_time
)));
1502 last_sample_time
= time_now
;
1506 data_total
+= cb
->size
;
1507 /* Do we need to re-route? */
1508 if ((phdr
->msg_type
== MSG_SMS_HO_PER_SLICES_IND
) ||
1509 (phdr
->msg_type
== MSG_SMS_TRANSMISSION_IND
)) {
1510 if (coredev
->mode
== DEVICE_MODE_DVBT_BDA
)
1511 phdr
->msg_dst_id
= DVBT_BDA_CONTROL_MSG_ID
;
1515 client
= smscore_find_client(coredev
, phdr
->msg_type
, phdr
->msg_dst_id
);
1517 /* If no client registered for type & id,
1518 * check for control client where type is not registered */
1520 rc
= client
->onresponse_handler(client
->context
, cb
);
1523 switch (phdr
->msg_type
) {
1524 case MSG_SMS_ISDBT_TUNE_RES
:
1526 case MSG_SMS_RF_TUNE_RES
:
1528 case MSG_SMS_SIGNAL_DETECTED_IND
:
1530 case MSG_SMS_NO_SIGNAL_IND
:
1532 case MSG_SMS_SPI_INT_LINE_SET_RES
:
1534 case MSG_SMS_INTERFACE_LOCK_IND
:
1536 case MSG_SMS_INTERFACE_UNLOCK_IND
:
1538 case MSG_SMS_GET_VERSION_EX_RES
:
1540 struct sms_version_res
*ver
=
1541 (struct sms_version_res
*) phdr
;
1542 sms_debug("Firmware id %d prots 0x%x ver %d.%d",
1543 ver
->firmware_id
, ver
->supported_protocols
,
1544 ver
->rom_ver_major
, ver
->rom_ver_minor
);
1546 coredev
->mode
= ver
->firmware_id
== 255 ?
1547 DEVICE_MODE_NONE
: ver
->firmware_id
;
1548 coredev
->modes_supported
= ver
->supported_protocols
;
1549 coredev
->fw_version
= ver
->rom_ver_major
<< 8 |
1552 complete(&coredev
->version_ex_done
);
1555 case MSG_SMS_INIT_DEVICE_RES
:
1556 complete(&coredev
->init_device_done
);
1558 case MSG_SW_RELOAD_START_RES
:
1559 complete(&coredev
->reload_start_done
);
1561 case MSG_SMS_DATA_VALIDITY_RES
:
1563 struct sms_msg_data
*validity
= (struct sms_msg_data
*) phdr
;
1565 sms_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x",
1566 validity
->msg_data
[0]);
1567 complete(&coredev
->data_validity_done
);
1570 case MSG_SMS_DATA_DOWNLOAD_RES
:
1571 complete(&coredev
->data_download_done
);
1573 case MSG_SW_RELOAD_EXEC_RES
:
1575 case MSG_SMS_SWDOWNLOAD_TRIGGER_RES
:
1576 complete(&coredev
->trigger_done
);
1578 case MSG_SMS_SLEEP_RESUME_COMP_IND
:
1579 complete(&coredev
->resume_done
);
1581 case MSG_SMS_GPIO_CONFIG_EX_RES
:
1582 complete(&coredev
->gpio_configuration_done
);
1584 case MSG_SMS_GPIO_SET_LEVEL_RES
:
1585 complete(&coredev
->gpio_set_level_done
);
1587 case MSG_SMS_GPIO_GET_LEVEL_RES
:
1589 u32
*msgdata
= (u32
*) phdr
;
1590 coredev
->gpio_get_res
= msgdata
[1];
1591 sms_debug("gpio level %d",
1592 coredev
->gpio_get_res
);
1593 complete(&coredev
->gpio_get_level_done
);
1596 case MSG_SMS_START_IR_RES
:
1597 complete(&coredev
->ir_init_done
);
1599 case MSG_SMS_IR_SAMPLES_IND
:
1600 sms_ir_event(coredev
,
1603 + sizeof(struct sms_msg_hdr
)),
1604 (int)phdr
->msg_length
1605 - sizeof(struct sms_msg_hdr
));
1608 case MSG_SMS_DVBT_BDA_DATA
:
1610 * It can be received here, if the frontend is
1611 * tuned into a valid channel and the proper firmware
1612 * is loaded. That happens when the module got removed
1613 * and re-inserted, without powering the device off
1618 sms_debug("message %s(%d) not handled.",
1619 smscore_translate_msg(phdr
->msg_type
),
1623 smscore_putbuffer(coredev
, cb
);
1626 EXPORT_SYMBOL_GPL(smscore_onresponse
);
1629 * return pointer to next free buffer descriptor from core pool
1631 * @param coredev pointer to a coredev object returned by
1632 * smscore_register_device
1634 * @return pointer to descriptor on success, NULL on error.
1637 static struct smscore_buffer_t
*get_entry(struct smscore_device_t
*coredev
)
1639 struct smscore_buffer_t
*cb
= NULL
;
1640 unsigned long flags
;
1642 spin_lock_irqsave(&coredev
->bufferslock
, flags
);
1643 if (!list_empty(&coredev
->buffers
)) {
1644 cb
= (struct smscore_buffer_t
*) coredev
->buffers
.next
;
1645 list_del(&cb
->entry
);
1647 spin_unlock_irqrestore(&coredev
->bufferslock
, flags
);
1651 struct smscore_buffer_t
*smscore_getbuffer(struct smscore_device_t
*coredev
)
1653 struct smscore_buffer_t
*cb
= NULL
;
1655 wait_event(coredev
->buffer_mng_waitq
, (cb
= get_entry(coredev
)));
1659 EXPORT_SYMBOL_GPL(smscore_getbuffer
);
1662 * return buffer descriptor to a pool
1664 * @param coredev pointer to a coredev object returned by
1665 * smscore_register_device
1666 * @param cb pointer buffer descriptor
1669 void smscore_putbuffer(struct smscore_device_t
*coredev
,
1670 struct smscore_buffer_t
*cb
) {
1671 wake_up_interruptible(&coredev
->buffer_mng_waitq
);
1672 list_add_locked(&cb
->entry
, &coredev
->buffers
, &coredev
->bufferslock
);
1674 EXPORT_SYMBOL_GPL(smscore_putbuffer
);
1676 static int smscore_validate_client(struct smscore_device_t
*coredev
,
1677 struct smscore_client_t
*client
,
1678 int data_type
, int id
)
1680 struct smscore_idlist_t
*listentry
;
1681 struct smscore_client_t
*registered_client
;
1684 sms_err("bad parameter.");
1687 registered_client
= smscore_find_client(coredev
, data_type
, id
);
1688 if (registered_client
== client
)
1691 if (registered_client
) {
1692 sms_err("The msg ID already registered to another client.");
1695 listentry
= kzalloc(sizeof(struct smscore_idlist_t
), GFP_KERNEL
);
1697 sms_err("Can't allocate memory for client id.");
1701 listentry
->data_type
= data_type
;
1702 list_add_locked(&listentry
->entry
, &client
->idlist
,
1703 &coredev
->clientslock
);
1708 * creates smsclient object, check that id is taken by another client
1710 * @param coredev pointer to a coredev object from clients hotplug
1711 * @param initial_id all messages with this id would be sent to this client
1712 * @param data_type all messages of this type would be sent to this client
1713 * @param onresponse_handler client handler that is called to
1714 * process incoming messages
1715 * @param onremove_handler client handler that is called when device is removed
1716 * @param context client-specific context
1717 * @param client pointer to a value that receives created smsclient object
1719 * @return 0 on success, <0 on error.
1721 int smscore_register_client(struct smscore_device_t
*coredev
,
1722 struct smsclient_params_t
*params
,
1723 struct smscore_client_t
**client
)
1725 struct smscore_client_t
*newclient
;
1726 /* check that no other channel with same parameters exists */
1727 if (smscore_find_client(coredev
, params
->data_type
,
1728 params
->initial_id
)) {
1729 sms_err("Client already exist.");
1733 newclient
= kzalloc(sizeof(struct smscore_client_t
), GFP_KERNEL
);
1735 sms_err("Failed to allocate memory for client.");
1739 INIT_LIST_HEAD(&newclient
->idlist
);
1740 newclient
->coredev
= coredev
;
1741 newclient
->onresponse_handler
= params
->onresponse_handler
;
1742 newclient
->onremove_handler
= params
->onremove_handler
;
1743 newclient
->context
= params
->context
;
1744 list_add_locked(&newclient
->entry
, &coredev
->clients
,
1745 &coredev
->clientslock
);
1746 smscore_validate_client(coredev
, newclient
, params
->data_type
,
1747 params
->initial_id
);
1748 *client
= newclient
;
1749 sms_debug("%p %d %d", params
->context
, params
->data_type
,
1750 params
->initial_id
);
1754 EXPORT_SYMBOL_GPL(smscore_register_client
);
1757 * frees smsclient object and all subclients associated with it
1759 * @param client pointer to smsclient object returned by
1760 * smscore_register_client
1763 void smscore_unregister_client(struct smscore_client_t
*client
)
1765 struct smscore_device_t
*coredev
= client
->coredev
;
1766 unsigned long flags
;
1768 spin_lock_irqsave(&coredev
->clientslock
, flags
);
1771 while (!list_empty(&client
->idlist
)) {
1772 struct smscore_idlist_t
*identry
=
1773 (struct smscore_idlist_t
*) client
->idlist
.next
;
1774 list_del(&identry
->entry
);
1778 sms_info("%p", client
->context
);
1780 list_del(&client
->entry
);
1783 spin_unlock_irqrestore(&coredev
->clientslock
, flags
);
1785 EXPORT_SYMBOL_GPL(smscore_unregister_client
);
1788 * verifies that source id is not taken by another client,
1789 * calls device handler to send requests to the device
1791 * @param client pointer to smsclient object returned by
1792 * smscore_register_client
1793 * @param buffer pointer to a request buffer
1794 * @param size size (in bytes) of request buffer
1796 * @return 0 on success, <0 on error.
1798 int smsclient_sendrequest(struct smscore_client_t
*client
,
1799 void *buffer
, size_t size
)
1801 struct smscore_device_t
*coredev
;
1802 struct sms_msg_hdr
*phdr
= (struct sms_msg_hdr
*) buffer
;
1805 if (client
== NULL
) {
1806 sms_err("Got NULL client");
1810 coredev
= client
->coredev
;
1812 /* check that no other channel with same id exists */
1813 if (coredev
== NULL
) {
1814 sms_err("Got NULL coredev");
1818 rc
= smscore_validate_client(client
->coredev
, client
, 0,
1823 return coredev
->sendrequest_handler(coredev
->context
, buffer
, size
);
1825 EXPORT_SYMBOL_GPL(smsclient_sendrequest
);
1828 /* old GPIO managements implementation */
1829 int smscore_configure_gpio(struct smscore_device_t
*coredev
, u32 pin
,
1830 struct smscore_config_gpio
*pinconfig
)
1833 struct sms_msg_hdr hdr
;
1837 if (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) {
1838 msg
.hdr
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1839 msg
.hdr
.msg_dst_id
= HIF_TASK
;
1840 msg
.hdr
.msg_flags
= 0;
1841 msg
.hdr
.msg_type
= MSG_SMS_GPIO_CONFIG_EX_REQ
;
1842 msg
.hdr
.msg_length
= sizeof(msg
);
1845 msg
.data
[1] = pinconfig
->pullupdown
;
1847 /* Convert slew rate for Nova: Fast(0) = 3 / Slow(1) = 0; */
1848 msg
.data
[2] = pinconfig
->outputslewrate
== 0 ? 3 : 0;
1850 switch (pinconfig
->outputdriving
) {
1851 case SMS_GPIO_OUTPUTDRIVING_S_16mA
:
1852 msg
.data
[3] = 7; /* Nova - 16mA */
1854 case SMS_GPIO_OUTPUTDRIVING_S_12mA
:
1855 msg
.data
[3] = 5; /* Nova - 11mA */
1857 case SMS_GPIO_OUTPUTDRIVING_S_8mA
:
1858 msg
.data
[3] = 3; /* Nova - 7mA */
1860 case SMS_GPIO_OUTPUTDRIVING_S_4mA
:
1862 msg
.data
[3] = 2; /* Nova - 4mA */
1866 msg
.data
[4] = pinconfig
->direction
;
1868 } else /* TODO: SMS_DEVICE_FAMILY1 */
1871 return coredev
->sendrequest_handler(coredev
->context
,
1875 int smscore_set_gpio(struct smscore_device_t
*coredev
, u32 pin
, int level
)
1878 struct sms_msg_hdr hdr
;
1882 if (pin
> MAX_GPIO_PIN_NUMBER
)
1885 msg
.hdr
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1886 msg
.hdr
.msg_dst_id
= HIF_TASK
;
1887 msg
.hdr
.msg_flags
= 0;
1888 msg
.hdr
.msg_type
= MSG_SMS_GPIO_SET_LEVEL_REQ
;
1889 msg
.hdr
.msg_length
= sizeof(msg
);
1892 msg
.data
[1] = level
? 1 : 0;
1895 return coredev
->sendrequest_handler(coredev
->context
,
1899 /* new GPIO management implementation */
1900 static int get_gpio_pin_params(u32 pin_num
, u32
*p_translatedpin_num
,
1901 u32
*p_group_num
, u32
*p_group_cfg
) {
1906 *p_translatedpin_num
= 0;
1909 } else if (pin_num
>= 2 && pin_num
<= 6) {
1910 *p_translatedpin_num
= 2;
1913 } else if (pin_num
>= 7 && pin_num
<= 11) {
1914 *p_translatedpin_num
= 7;
1916 } else if (pin_num
>= 12 && pin_num
<= 15) {
1917 *p_translatedpin_num
= 12;
1920 } else if (pin_num
== 16) {
1921 *p_translatedpin_num
= 16;
1923 } else if (pin_num
>= 17 && pin_num
<= 24) {
1924 *p_translatedpin_num
= 17;
1926 } else if (pin_num
== 25) {
1927 *p_translatedpin_num
= 25;
1929 } else if (pin_num
>= 26 && pin_num
<= 28) {
1930 *p_translatedpin_num
= 26;
1932 } else if (pin_num
== 29) {
1933 *p_translatedpin_num
= 29;
1936 } else if (pin_num
== 30) {
1937 *p_translatedpin_num
= 30;
1939 } else if (pin_num
== 31) {
1940 *p_translatedpin_num
= 31;
1945 *p_group_cfg
<<= 24;
1950 int smscore_gpio_configure(struct smscore_device_t
*coredev
, u8 pin_num
,
1951 struct smscore_config_gpio
*p_gpio_config
) {
1954 u32 translatedpin_num
= 0;
1961 struct set_gpio_msg
{
1962 struct sms_msg_hdr x_msg_header
;
1967 if (pin_num
> MAX_GPIO_PIN_NUMBER
)
1970 if (p_gpio_config
== NULL
)
1973 total_len
= sizeof(struct sms_msg_hdr
) + (sizeof(u32
) * 6);
1975 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
1976 GFP_KERNEL
| GFP_DMA
);
1980 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
1982 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1983 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
1984 p_msg
->x_msg_header
.msg_flags
= 0;
1985 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
1986 p_msg
->msg_data
[0] = pin_num
;
1988 if (!(coredev
->device_flags
& SMS_DEVICE_FAMILY2
)) {
1989 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_CONFIG_REQ
;
1990 if (get_gpio_pin_params(pin_num
, &translatedpin_num
, &group_num
,
1996 p_msg
->msg_data
[1] = translatedpin_num
;
1997 p_msg
->msg_data
[2] = group_num
;
1998 electric_char
= (p_gpio_config
->pullupdown
)
1999 | (p_gpio_config
->inputcharacteristics
<< 2)
2000 | (p_gpio_config
->outputslewrate
<< 3)
2001 | (p_gpio_config
->outputdriving
<< 4);
2002 p_msg
->msg_data
[3] = electric_char
;
2003 p_msg
->msg_data
[4] = p_gpio_config
->direction
;
2004 p_msg
->msg_data
[5] = group_cfg
;
2006 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_CONFIG_EX_REQ
;
2007 p_msg
->msg_data
[1] = p_gpio_config
->pullupdown
;
2008 p_msg
->msg_data
[2] = p_gpio_config
->outputslewrate
;
2009 p_msg
->msg_data
[3] = p_gpio_config
->outputdriving
;
2010 p_msg
->msg_data
[4] = p_gpio_config
->direction
;
2011 p_msg
->msg_data
[5] = 0;
2014 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2015 &coredev
->gpio_configuration_done
);
2019 sms_err("smscore_gpio_configure timeout");
2021 sms_err("smscore_gpio_configure error");
2029 int smscore_gpio_set_level(struct smscore_device_t
*coredev
, u8 pin_num
,
2036 struct set_gpio_msg
{
2037 struct sms_msg_hdr x_msg_header
;
2038 u32 msg_data
[3]; /* keep it 3 ! */
2041 if ((new_level
> 1) || (pin_num
> MAX_GPIO_PIN_NUMBER
))
2044 total_len
= sizeof(struct sms_msg_hdr
) +
2045 (3 * sizeof(u32
)); /* keep it 3 ! */
2047 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
2048 GFP_KERNEL
| GFP_DMA
);
2052 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
2054 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
2055 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
2056 p_msg
->x_msg_header
.msg_flags
= 0;
2057 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_SET_LEVEL_REQ
;
2058 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
2059 p_msg
->msg_data
[0] = pin_num
;
2060 p_msg
->msg_data
[1] = new_level
;
2062 /* Send message to SMS */
2063 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2064 &coredev
->gpio_set_level_done
);
2068 sms_err("smscore_gpio_set_level timeout");
2070 sms_err("smscore_gpio_set_level error");
2077 int smscore_gpio_get_level(struct smscore_device_t
*coredev
, u8 pin_num
,
2084 struct set_gpio_msg
{
2085 struct sms_msg_hdr x_msg_header
;
2090 if (pin_num
> MAX_GPIO_PIN_NUMBER
)
2093 total_len
= sizeof(struct sms_msg_hdr
) + (2 * sizeof(u32
));
2095 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
2096 GFP_KERNEL
| GFP_DMA
);
2100 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
2102 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
2103 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
2104 p_msg
->x_msg_header
.msg_flags
= 0;
2105 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_GET_LEVEL_REQ
;
2106 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
2107 p_msg
->msg_data
[0] = pin_num
;
2108 p_msg
->msg_data
[1] = 0;
2110 /* Send message to SMS */
2111 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2112 &coredev
->gpio_get_level_done
);
2116 sms_err("smscore_gpio_get_level timeout");
2118 sms_err("smscore_gpio_get_level error");
2122 /* Its a race between other gpio_get_level() and the copy of the single
2123 * global 'coredev->gpio_get_res' to the function's variable 'level'
2125 *level
= coredev
->gpio_get_res
;
2130 static int __init
smscore_module_init(void)
2134 INIT_LIST_HEAD(&g_smscore_notifyees
);
2135 INIT_LIST_HEAD(&g_smscore_devices
);
2136 kmutex_init(&g_smscore_deviceslock
);
2138 INIT_LIST_HEAD(&g_smscore_registry
);
2139 kmutex_init(&g_smscore_registrylock
);
2144 static void __exit
smscore_module_exit(void)
2146 kmutex_lock(&g_smscore_deviceslock
);
2147 while (!list_empty(&g_smscore_notifyees
)) {
2148 struct smscore_device_notifyee_t
*notifyee
=
2149 (struct smscore_device_notifyee_t
*)
2150 g_smscore_notifyees
.next
;
2152 list_del(¬ifyee
->entry
);
2155 kmutex_unlock(&g_smscore_deviceslock
);
2157 kmutex_lock(&g_smscore_registrylock
);
2158 while (!list_empty(&g_smscore_registry
)) {
2159 struct smscore_registry_entry_t
*entry
=
2160 (struct smscore_registry_entry_t
*)
2161 g_smscore_registry
.next
;
2163 list_del(&entry
->entry
);
2166 kmutex_unlock(&g_smscore_registrylock
);
2171 module_init(smscore_module_init
);
2172 module_exit(smscore_module_exit
);
2174 MODULE_DESCRIPTION("Siano MDTV Core module");
2175 MODULE_AUTHOR("Siano Mobile Silicon, Inc. (uris@siano-ms.com)");
2176 MODULE_LICENSE("GPL");
2178 /* This should match what's defined at smscoreapi.h */
2179 MODULE_FIRMWARE(SMS_FW_ATSC_DENVER
);
2180 MODULE_FIRMWARE(SMS_FW_CMMB_MING_APP
);
2181 MODULE_FIRMWARE(SMS_FW_CMMB_VEGA_12MHZ
);
2182 MODULE_FIRMWARE(SMS_FW_CMMB_VENICE_12MHZ
);
2183 MODULE_FIRMWARE(SMS_FW_DVBH_RIO
);
2184 MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ_B0
);
2185 MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ
);
2186 MODULE_FIRMWARE(SMS_FW_DVB_RIO
);
2187 MODULE_FIRMWARE(SMS_FW_FM_RADIO
);
2188 MODULE_FIRMWARE(SMS_FW_FM_RADIO_RIO
);
2189 MODULE_FIRMWARE(SMS_FW_DVBT_HCW_55XXX
);
2190 MODULE_FIRMWARE(SMS_FW_ISDBT_HCW_55XXX
);
2191 MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ_B0
);
2192 MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ
);
2193 MODULE_FIRMWARE(SMS_FW_ISDBT_PELE
);
2194 MODULE_FIRMWARE(SMS_FW_ISDBT_RIO
);
2195 MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_A
);
2196 MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_B
);
2197 MODULE_FIRMWARE(SMS_FW_DVBT_STELLAR
);
2198 MODULE_FIRMWARE(SMS_FW_TDMB_DENVER
);
2199 MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ_B0
);
2200 MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ
);