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.
20 #include "smscoreapi.h"
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>
29 #include <linux/slab.h>
31 #include <linux/firmware.h>
32 #include <linux/wait.h>
33 #include <asm/byteorder.h>
35 #include "sms-cards.h"
38 struct smscore_device_notifyee_t
{
39 struct list_head entry
;
43 struct smscore_idlist_t
{
44 struct list_head entry
;
49 struct smscore_client_t
{
50 struct list_head entry
;
51 struct smscore_device_t
*coredev
;
53 struct list_head idlist
;
54 onresponse_t onresponse_handler
;
55 onremove_t onremove_handler
;
58 static 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",
380 char *smscore_translate_msg(enum msg_types msgtype
)
382 int i
= msgtype
- MSG_TYPE_BASE_VAL
;
385 if (i
< 0 || i
>= ARRAY_SIZE(siano_msgs
))
386 return "Unknown msg type";
391 return "Unknown msg type";
395 EXPORT_SYMBOL_GPL(smscore_translate_msg
);
397 void smscore_set_board_id(struct smscore_device_t
*core
, int id
)
402 int smscore_led_state(struct smscore_device_t
*core
, int led
)
405 core
->led_state
= led
;
406 return core
->led_state
;
408 EXPORT_SYMBOL_GPL(smscore_set_board_id
);
410 int smscore_get_board_id(struct smscore_device_t
*core
)
412 return core
->board_id
;
414 EXPORT_SYMBOL_GPL(smscore_get_board_id
);
416 struct smscore_registry_entry_t
{
417 struct list_head entry
;
420 enum sms_device_type_st type
;
423 static struct list_head g_smscore_notifyees
;
424 static struct list_head g_smscore_devices
;
425 static struct mutex g_smscore_deviceslock
;
427 static struct list_head g_smscore_registry
;
428 static struct mutex g_smscore_registrylock
;
430 static int default_mode
= DEVICE_MODE_NONE
;
432 module_param(default_mode
, int, 0644);
433 MODULE_PARM_DESC(default_mode
, "default firmware id (device mode)");
435 static struct smscore_registry_entry_t
*smscore_find_registry(char *devpath
)
437 struct smscore_registry_entry_t
*entry
;
438 struct list_head
*next
;
440 kmutex_lock(&g_smscore_registrylock
);
441 for (next
= g_smscore_registry
.next
;
442 next
!= &g_smscore_registry
;
444 entry
= (struct smscore_registry_entry_t
*) next
;
445 if (!strcmp(entry
->devpath
, devpath
)) {
446 kmutex_unlock(&g_smscore_registrylock
);
450 entry
= kmalloc(sizeof(*entry
), GFP_KERNEL
);
452 entry
->mode
= default_mode
;
453 strcpy(entry
->devpath
, devpath
);
454 list_add(&entry
->entry
, &g_smscore_registry
);
456 pr_err("failed to create smscore_registry.\n");
457 kmutex_unlock(&g_smscore_registrylock
);
461 int smscore_registry_getmode(char *devpath
)
463 struct smscore_registry_entry_t
*entry
;
465 entry
= smscore_find_registry(devpath
);
469 pr_err("No registry found.\n");
473 EXPORT_SYMBOL_GPL(smscore_registry_getmode
);
475 static enum sms_device_type_st
smscore_registry_gettype(char *devpath
)
477 struct smscore_registry_entry_t
*entry
;
479 entry
= smscore_find_registry(devpath
);
483 pr_err("No registry found.\n");
488 static void smscore_registry_setmode(char *devpath
, int mode
)
490 struct smscore_registry_entry_t
*entry
;
492 entry
= smscore_find_registry(devpath
);
496 pr_err("No registry found.\n");
499 static void smscore_registry_settype(char *devpath
,
500 enum sms_device_type_st type
)
502 struct smscore_registry_entry_t
*entry
;
504 entry
= smscore_find_registry(devpath
);
508 pr_err("No registry found.\n");
512 static void list_add_locked(struct list_head
*new, struct list_head
*head
,
517 spin_lock_irqsave(lock
, flags
);
521 spin_unlock_irqrestore(lock
, flags
);
525 * register a client callback that called when device plugged in/unplugged
526 * NOTE: if devices exist callback is called immediately for each device
528 * @param hotplug callback
530 * return: 0 on success, <0 on error.
532 int smscore_register_hotplug(hotplug_t hotplug
)
534 struct smscore_device_notifyee_t
*notifyee
;
535 struct list_head
*next
, *first
;
538 kmutex_lock(&g_smscore_deviceslock
);
539 notifyee
= kmalloc(sizeof(*notifyee
), GFP_KERNEL
);
541 /* now notify callback about existing devices */
542 first
= &g_smscore_devices
;
543 for (next
= first
->next
;
544 next
!= first
&& !rc
;
546 struct smscore_device_t
*coredev
=
547 (struct smscore_device_t
*) next
;
548 rc
= hotplug(coredev
, coredev
->device
, 1);
552 notifyee
->hotplug
= hotplug
;
553 list_add(¬ifyee
->entry
, &g_smscore_notifyees
);
559 kmutex_unlock(&g_smscore_deviceslock
);
563 EXPORT_SYMBOL_GPL(smscore_register_hotplug
);
566 * unregister a client callback that called when device plugged in/unplugged
568 * @param hotplug callback
571 void smscore_unregister_hotplug(hotplug_t hotplug
)
573 struct list_head
*next
, *first
;
575 kmutex_lock(&g_smscore_deviceslock
);
577 first
= &g_smscore_notifyees
;
579 for (next
= first
->next
; next
!= first
;) {
580 struct smscore_device_notifyee_t
*notifyee
=
581 (struct smscore_device_notifyee_t
*) next
;
584 if (notifyee
->hotplug
== hotplug
) {
585 list_del(¬ifyee
->entry
);
590 kmutex_unlock(&g_smscore_deviceslock
);
592 EXPORT_SYMBOL_GPL(smscore_unregister_hotplug
);
594 static void smscore_notify_clients(struct smscore_device_t
*coredev
)
596 struct smscore_client_t
*client
;
598 /* the client must call smscore_unregister_client from remove handler */
599 while (!list_empty(&coredev
->clients
)) {
600 client
= (struct smscore_client_t
*) coredev
->clients
.next
;
601 client
->onremove_handler(client
->context
);
605 static int smscore_notify_callbacks(struct smscore_device_t
*coredev
,
606 struct device
*device
, int arrival
)
608 struct smscore_device_notifyee_t
*elem
;
611 /* note: must be called under g_deviceslock */
613 list_for_each_entry(elem
, &g_smscore_notifyees
, entry
) {
614 rc
= elem
->hotplug(coredev
, device
, arrival
);
623 smscore_buffer_t
*smscore_createbuffer(u8
*buffer
, void *common_buffer
,
624 dma_addr_t common_buffer_phys
)
626 struct smscore_buffer_t
*cb
;
628 cb
= kzalloc(sizeof(*cb
), GFP_KERNEL
);
633 cb
->offset_in_common
= buffer
- (u8
*) common_buffer
;
634 cb
->phys
= common_buffer_phys
+ cb
->offset_in_common
;
640 * creates coredev object for a device, prepares buffers,
641 * creates buffer mappings, notifies registered hotplugs about new device.
643 * @param params device pointer to struct with device specific parameters
645 * @param coredev pointer to a value that receives created coredev object
647 * return: 0 on success, <0 on error.
649 int smscore_register_device(struct smsdevice_params_t
*params
,
650 struct smscore_device_t
**coredev
,
653 struct smscore_device_t
*dev
;
656 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
660 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
661 dev
->media_dev
= mdev
;
664 /* init list entry so it could be safe in smscore_unregister_device */
665 INIT_LIST_HEAD(&dev
->entry
);
668 INIT_LIST_HEAD(&dev
->clients
);
669 INIT_LIST_HEAD(&dev
->buffers
);
672 spin_lock_init(&dev
->clientslock
);
673 spin_lock_init(&dev
->bufferslock
);
675 /* init completion events */
676 init_completion(&dev
->version_ex_done
);
677 init_completion(&dev
->data_download_done
);
678 init_completion(&dev
->data_validity_done
);
679 init_completion(&dev
->trigger_done
);
680 init_completion(&dev
->init_device_done
);
681 init_completion(&dev
->reload_start_done
);
682 init_completion(&dev
->resume_done
);
683 init_completion(&dev
->gpio_configuration_done
);
684 init_completion(&dev
->gpio_set_level_done
);
685 init_completion(&dev
->gpio_get_level_done
);
686 init_completion(&dev
->ir_init_done
);
688 /* Buffer management */
689 init_waitqueue_head(&dev
->buffer_mng_waitq
);
691 /* alloc common buffer */
692 dev
->common_buffer_size
= params
->buffer_size
* params
->num_buffers
;
693 dev
->common_buffer
= dma_alloc_coherent(NULL
, dev
->common_buffer_size
,
694 &dev
->common_buffer_phys
,
695 GFP_KERNEL
| GFP_DMA
);
696 if (!dev
->common_buffer
) {
697 smscore_unregister_device(dev
);
701 /* prepare dma buffers */
702 for (buffer
= dev
->common_buffer
;
703 dev
->num_buffers
< params
->num_buffers
;
704 dev
->num_buffers
++, buffer
+= params
->buffer_size
) {
705 struct smscore_buffer_t
*cb
;
707 cb
= smscore_createbuffer(buffer
, dev
->common_buffer
,
708 dev
->common_buffer_phys
);
710 smscore_unregister_device(dev
);
714 smscore_putbuffer(dev
, cb
);
717 pr_debug("allocated %d buffers\n", dev
->num_buffers
);
719 dev
->mode
= DEVICE_MODE_NONE
;
720 dev
->board_id
= SMS_BOARD_UNKNOWN
;
721 dev
->context
= params
->context
;
722 dev
->device
= params
->device
;
723 dev
->setmode_handler
= params
->setmode_handler
;
724 dev
->detectmode_handler
= params
->detectmode_handler
;
725 dev
->sendrequest_handler
= params
->sendrequest_handler
;
726 dev
->preload_handler
= params
->preload_handler
;
727 dev
->postload_handler
= params
->postload_handler
;
729 dev
->device_flags
= params
->flags
;
730 strcpy(dev
->devpath
, params
->devpath
);
732 smscore_registry_settype(dev
->devpath
, params
->device_type
);
734 /* add device to devices list */
735 kmutex_lock(&g_smscore_deviceslock
);
736 list_add(&dev
->entry
, &g_smscore_devices
);
737 kmutex_unlock(&g_smscore_deviceslock
);
741 pr_debug("device %p created\n", dev
);
745 EXPORT_SYMBOL_GPL(smscore_register_device
);
748 static int smscore_sendrequest_and_wait(struct smscore_device_t
*coredev
,
749 void *buffer
, size_t size
, struct completion
*completion
) {
754 init_completion(completion
);
756 rc
= coredev
->sendrequest_handler(coredev
->context
, buffer
, size
);
758 pr_info("sendrequest returned error %d\n", rc
);
762 return wait_for_completion_timeout(completion
,
763 msecs_to_jiffies(SMS_PROTOCOL_MAX_RAOUNDTRIP_MS
)) ?
768 * Starts & enables IR operations
770 * return: 0 on success, < 0 on error.
772 static int smscore_init_ir(struct smscore_device_t
*coredev
)
778 coredev
->ir
.dev
= NULL
;
779 ir_io
= sms_get_board(smscore_get_board_id(coredev
))->board_cfg
.ir
;
780 if (ir_io
) {/* only if IR port exist we use IR sub-module */
781 pr_debug("IR loading\n");
782 rc
= sms_ir_init(coredev
);
785 pr_err("Error initialization DTV IR sub-module\n");
787 buffer
= kmalloc(sizeof(struct sms_msg_data2
) +
789 GFP_KERNEL
| GFP_DMA
);
791 struct sms_msg_data2
*msg
=
792 (struct sms_msg_data2
*)
793 SMS_ALIGN_ADDRESS(buffer
);
795 SMS_INIT_MSG(&msg
->x_msg_header
,
796 MSG_SMS_START_IR_REQ
,
797 sizeof(struct sms_msg_data2
));
798 msg
->msg_data
[0] = coredev
->ir
.controller
;
799 msg
->msg_data
[1] = coredev
->ir
.timeout
;
801 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
802 msg
->x_msg_header
. msg_length
,
803 &coredev
->ir_init_done
);
807 pr_err("Sending IR initialization message failed\n");
810 pr_info("IR port has not been detected\n");
816 * configures device features according to board configuration structure.
818 * @param coredev pointer to a coredev object returned by
819 * smscore_register_device
821 * return: 0 on success, <0 on error.
823 static int smscore_configure_board(struct smscore_device_t
*coredev
)
825 struct sms_board
*board
;
827 board
= sms_get_board(coredev
->board_id
);
829 pr_err("no board configuration exist.\n");
834 struct sms_msg_data mtu_msg
;
835 pr_debug("set max transmit unit %d\n", board
->mtu
);
837 mtu_msg
.x_msg_header
.msg_src_id
= 0;
838 mtu_msg
.x_msg_header
.msg_dst_id
= HIF_TASK
;
839 mtu_msg
.x_msg_header
.msg_flags
= 0;
840 mtu_msg
.x_msg_header
.msg_type
= MSG_SMS_SET_MAX_TX_MSG_LEN_REQ
;
841 mtu_msg
.x_msg_header
.msg_length
= sizeof(mtu_msg
);
842 mtu_msg
.msg_data
[0] = board
->mtu
;
844 coredev
->sendrequest_handler(coredev
->context
, &mtu_msg
,
848 if (board
->crystal
) {
849 struct sms_msg_data crys_msg
;
850 pr_debug("set crystal value %d\n", board
->crystal
);
852 SMS_INIT_MSG(&crys_msg
.x_msg_header
,
853 MSG_SMS_NEW_CRYSTAL_REQ
,
855 crys_msg
.msg_data
[0] = board
->crystal
;
857 coredev
->sendrequest_handler(coredev
->context
, &crys_msg
,
865 * sets initial device mode and notifies client hotplugs that device is ready
867 * @param coredev pointer to a coredev object returned by
868 * smscore_register_device
870 * return: 0 on success, <0 on error.
872 int smscore_start_device(struct smscore_device_t
*coredev
)
875 int board_id
= smscore_get_board_id(coredev
);
876 int mode
= smscore_registry_getmode(coredev
->devpath
);
878 /* Device is initialized as DEVICE_MODE_NONE */
879 if (board_id
!= SMS_BOARD_UNKNOWN
&& mode
== DEVICE_MODE_NONE
)
880 mode
= sms_get_board(board_id
)->default_mode
;
882 rc
= smscore_set_device_mode(coredev
, mode
);
884 pr_info("set device mode failed , rc %d\n", rc
);
887 rc
= smscore_configure_board(coredev
);
889 pr_info("configure board failed , rc %d\n", rc
);
893 kmutex_lock(&g_smscore_deviceslock
);
895 rc
= smscore_notify_callbacks(coredev
, coredev
->device
, 1);
896 smscore_init_ir(coredev
);
898 pr_debug("device %p started, rc %d\n", coredev
, rc
);
900 kmutex_unlock(&g_smscore_deviceslock
);
904 EXPORT_SYMBOL_GPL(smscore_start_device
);
907 static int smscore_load_firmware_family2(struct smscore_device_t
*coredev
,
908 void *buffer
, size_t size
)
910 struct sms_firmware
*firmware
= (struct sms_firmware
*) buffer
;
911 struct sms_msg_data4
*msg
;
912 u32 mem_address
, calc_checksum
= 0;
914 u8
*payload
= firmware
->payload
;
916 firmware
->start_address
= le32_to_cpup((__le32
*)&firmware
->start_address
);
917 firmware
->length
= le32_to_cpup((__le32
*)&firmware
->length
);
919 mem_address
= firmware
->start_address
;
921 pr_debug("loading FW to addr 0x%x size %d\n",
922 mem_address
, firmware
->length
);
923 if (coredev
->preload_handler
) {
924 rc
= coredev
->preload_handler(coredev
->context
);
929 /* PAGE_SIZE buffer shall be enough and dma aligned */
930 msg
= kmalloc(PAGE_SIZE
, GFP_KERNEL
| GFP_DMA
);
934 if (coredev
->mode
!= DEVICE_MODE_NONE
) {
935 pr_debug("sending reload command.\n");
936 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SW_RELOAD_START_REQ
,
937 sizeof(struct sms_msg_hdr
));
938 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
939 msg
->x_msg_header
.msg_length
,
940 &coredev
->reload_start_done
);
942 pr_err("device reload failed, rc %d\n", rc
);
943 goto exit_fw_download
;
945 mem_address
= *(u32
*) &payload
[20];
948 for (i
= 0, ptr
= (u32
*)firmware
->payload
; i
< firmware
->length
/4 ;
950 calc_checksum
+= *ptr
;
952 while (size
&& rc
>= 0) {
953 struct sms_data_download
*data_msg
=
954 (struct sms_data_download
*) msg
;
955 int payload_size
= min_t(int, size
, SMS_MAX_PAYLOAD_SIZE
);
957 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_DATA_DOWNLOAD_REQ
,
958 (u16
)(sizeof(struct sms_msg_hdr
) +
959 sizeof(u32
) + payload_size
));
961 data_msg
->mem_addr
= mem_address
;
962 memcpy(data_msg
->payload
, payload
, payload_size
);
964 rc
= smscore_sendrequest_and_wait(coredev
, data_msg
,
965 data_msg
->x_msg_header
.msg_length
,
966 &coredev
->data_download_done
);
968 payload
+= payload_size
;
969 size
-= payload_size
;
970 mem_address
+= payload_size
;
974 goto exit_fw_download
;
976 pr_debug("sending MSG_SMS_DATA_VALIDITY_REQ expecting 0x%x\n",
978 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_DATA_VALIDITY_REQ
,
979 sizeof(msg
->x_msg_header
) +
981 msg
->msg_data
[0] = firmware
->start_address
;
983 msg
->msg_data
[1] = firmware
->length
;
984 msg
->msg_data
[2] = 0; /* Regular checksum*/
985 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
986 msg
->x_msg_header
.msg_length
,
987 &coredev
->data_validity_done
);
989 goto exit_fw_download
;
991 if (coredev
->mode
== DEVICE_MODE_NONE
) {
992 struct sms_msg_data
*trigger_msg
=
993 (struct sms_msg_data
*) msg
;
995 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
996 SMS_INIT_MSG(&msg
->x_msg_header
,
997 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ
,
998 sizeof(struct sms_msg_hdr
) +
1001 trigger_msg
->msg_data
[0] = firmware
->start_address
;
1003 trigger_msg
->msg_data
[1] = 6; /* Priority */
1004 trigger_msg
->msg_data
[2] = 0x200; /* Stack size */
1005 trigger_msg
->msg_data
[3] = 0; /* Parameter */
1006 trigger_msg
->msg_data
[4] = 4; /* Task ID */
1008 rc
= smscore_sendrequest_and_wait(coredev
, trigger_msg
,
1009 trigger_msg
->x_msg_header
.msg_length
,
1010 &coredev
->trigger_done
);
1012 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SW_RELOAD_EXEC_REQ
,
1013 sizeof(struct sms_msg_hdr
));
1014 rc
= coredev
->sendrequest_handler(coredev
->context
, msg
,
1015 msg
->x_msg_header
.msg_length
);
1019 goto exit_fw_download
;
1022 * backward compatibility - wait to device_ready_done for
1023 * not more than 400 ms
1030 if (coredev
->postload_handler
) {
1031 pr_debug("rc=%d, postload=0x%p\n",
1032 rc
, coredev
->postload_handler
);
1034 return coredev
->postload_handler(coredev
->context
);
1037 pr_debug("rc=%d\n", rc
);
1041 static char *smscore_fw_lkup
[][DEVICE_MODE_MAX
] = {
1043 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_NOVA_12MHZ
,
1044 [DEVICE_MODE_DVBH
] = SMS_FW_DVB_NOVA_12MHZ
,
1045 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_NOVA_12MHZ
,
1046 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_NOVA_12MHZ
,
1047 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_NOVA_12MHZ
,
1048 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_NOVA_12MHZ
,
1051 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1052 [DEVICE_MODE_DVBH
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1053 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_NOVA_12MHZ_B0
,
1054 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
1055 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_NOVA_12MHZ_B0
,
1056 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_NOVA_12MHZ_B0
,
1057 [DEVICE_MODE_FM_RADIO
] = SMS_FW_FM_RADIO
,
1058 [DEVICE_MODE_FM_RADIO_BDA
] = SMS_FW_FM_RADIO
,
1061 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_VEGA_12MHZ
,
1064 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_VENICE_12MHZ
,
1067 [DEVICE_MODE_CMMB
] = SMS_FW_CMMB_MING_APP
,
1070 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_PELE
,
1071 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_PELE
,
1074 [DEVICE_MODE_DVBT
] = SMS_FW_DVB_RIO
,
1075 [DEVICE_MODE_DVBH
] = SMS_FW_DVBH_RIO
,
1076 [DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_RIO
,
1077 [DEVICE_MODE_ISDBT
] = SMS_FW_ISDBT_RIO
,
1078 [DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_RIO
,
1079 [DEVICE_MODE_FM_RADIO
] = SMS_FW_FM_RADIO_RIO
,
1080 [DEVICE_MODE_FM_RADIO_BDA
] = SMS_FW_FM_RADIO_RIO
,
1082 [SMS_DENVER_1530
] = {
1083 [DEVICE_MODE_ATSC
] = SMS_FW_ATSC_DENVER
,
1085 [SMS_DENVER_2160
] = {
1086 [DEVICE_MODE_DAB_TDMB
] = SMS_FW_TDMB_DENVER
,
1091 * get firmware file name from one of the two mechanisms : sms_boards or
1093 * @param coredev pointer to a coredev object returned by
1094 * smscore_register_device
1095 * @param mode requested mode of operation
1096 * @param lookup if 1, always get the fw filename from smscore_fw_lkup
1097 * table. if 0, try first to get from sms_boards
1099 * return: 0 on success, <0 on error.
1101 static char *smscore_get_fw_filename(struct smscore_device_t
*coredev
,
1105 int board_id
= smscore_get_board_id(coredev
);
1106 enum sms_device_type_st type
;
1108 type
= smscore_registry_gettype(coredev
->devpath
);
1110 /* Prevent looking outside the smscore_fw_lkup table */
1111 if (type
<= SMS_UNKNOWN_TYPE
|| type
>= SMS_NUM_OF_DEVICE_TYPES
)
1113 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
)
1116 pr_debug("trying to get fw name from sms_boards board_id %d mode %d\n",
1118 fw
= sms_get_board(board_id
)->fw
;
1119 if (!fw
|| !fw
[mode
]) {
1120 pr_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d\n",
1122 return smscore_fw_lkup
[type
][mode
];
1129 * loads specified firmware into a buffer and calls device loadfirmware_handler
1131 * @param coredev pointer to a coredev object returned by
1132 * smscore_register_device
1133 * @param filename null-terminated string specifies firmware file name
1134 * @param loadfirmware_handler device handler that loads firmware
1136 * return: 0 on success, <0 on error.
1138 static int smscore_load_firmware_from_file(struct smscore_device_t
*coredev
,
1140 loadfirmware_t loadfirmware_handler
)
1145 const struct firmware
*fw
;
1147 char *fw_filename
= smscore_get_fw_filename(coredev
, mode
);
1149 pr_err("mode %d not supported on this device\n", mode
);
1152 pr_debug("Firmware name: %s\n", fw_filename
);
1154 if (!loadfirmware_handler
&&
1155 !(coredev
->device_flags
& SMS_DEVICE_FAMILY2
))
1158 rc
= request_firmware(&fw
, fw_filename
, coredev
->device
);
1160 pr_err("failed to open firmware file '%s'\n", fw_filename
);
1163 pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename
, fw
->size
);
1164 fw_buf
= kmalloc(ALIGN(fw
->size
+ sizeof(struct sms_firmware
),
1165 SMS_ALLOC_ALIGNMENT
), GFP_KERNEL
| GFP_DMA
);
1167 pr_err("failed to allocate firmware buffer\n");
1170 memcpy(fw_buf
, fw
->data
, fw
->size
);
1171 fw_buf_size
= fw
->size
;
1173 rc
= (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) ?
1174 smscore_load_firmware_family2(coredev
, fw_buf
, fw_buf_size
)
1175 : loadfirmware_handler(coredev
->context
, fw_buf
,
1180 release_firmware(fw
);
1186 * notifies all clients registered with the device, notifies hotplugs,
1187 * frees all buffers and coredev object
1189 * @param coredev pointer to a coredev object returned by
1190 * smscore_register_device
1192 * return: 0 on success, <0 on error.
1194 void smscore_unregister_device(struct smscore_device_t
*coredev
)
1196 struct smscore_buffer_t
*cb
;
1197 int num_buffers
= 0;
1200 kmutex_lock(&g_smscore_deviceslock
);
1202 /* Release input device (IR) resources */
1203 sms_ir_exit(coredev
);
1205 smscore_notify_clients(coredev
);
1206 smscore_notify_callbacks(coredev
, NULL
, 0);
1208 /* at this point all buffers should be back
1209 * onresponse must no longer be called */
1212 while (!list_empty(&coredev
->buffers
)) {
1213 cb
= (struct smscore_buffer_t
*) coredev
->buffers
.next
;
1214 list_del(&cb
->entry
);
1218 if (num_buffers
== coredev
->num_buffers
)
1221 pr_info("exiting although not all buffers released.\n");
1225 pr_debug("waiting for %d buffer(s)\n",
1226 coredev
->num_buffers
- num_buffers
);
1227 kmutex_unlock(&g_smscore_deviceslock
);
1229 kmutex_lock(&g_smscore_deviceslock
);
1232 pr_debug("freed %d buffers\n", num_buffers
);
1234 if (coredev
->common_buffer
)
1235 dma_free_coherent(NULL
, coredev
->common_buffer_size
,
1236 coredev
->common_buffer
, coredev
->common_buffer_phys
);
1238 kfree(coredev
->fw_buf
);
1240 list_del(&coredev
->entry
);
1243 kmutex_unlock(&g_smscore_deviceslock
);
1245 pr_debug("device %p destroyed\n", coredev
);
1247 EXPORT_SYMBOL_GPL(smscore_unregister_device
);
1249 static int smscore_detect_mode(struct smscore_device_t
*coredev
)
1251 void *buffer
= kmalloc(sizeof(struct sms_msg_hdr
) + SMS_DMA_ALIGNMENT
,
1252 GFP_KERNEL
| GFP_DMA
);
1253 struct sms_msg_hdr
*msg
=
1254 (struct sms_msg_hdr
*) SMS_ALIGN_ADDRESS(buffer
);
1260 SMS_INIT_MSG(msg
, MSG_SMS_GET_VERSION_EX_REQ
,
1261 sizeof(struct sms_msg_hdr
));
1263 rc
= smscore_sendrequest_and_wait(coredev
, msg
, msg
->msg_length
,
1264 &coredev
->version_ex_done
);
1266 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed first try\n");
1268 if (wait_for_completion_timeout(&coredev
->resume_done
,
1269 msecs_to_jiffies(5000))) {
1270 rc
= smscore_sendrequest_and_wait(
1271 coredev
, msg
, msg
->msg_length
,
1272 &coredev
->version_ex_done
);
1274 pr_err("MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n",
1286 * send init device request and wait for response
1288 * @param coredev pointer to a coredev object returned by
1289 * smscore_register_device
1290 * @param mode requested mode of operation
1292 * return: 0 on success, <0 on error.
1294 static int smscore_init_device(struct smscore_device_t
*coredev
, int mode
)
1297 struct sms_msg_data
*msg
;
1300 buffer
= kmalloc(sizeof(struct sms_msg_data
) +
1301 SMS_DMA_ALIGNMENT
, GFP_KERNEL
| GFP_DMA
);
1305 msg
= (struct sms_msg_data
*)SMS_ALIGN_ADDRESS(buffer
);
1306 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_INIT_DEVICE_REQ
,
1307 sizeof(struct sms_msg_data
));
1308 msg
->msg_data
[0] = mode
;
1310 rc
= smscore_sendrequest_and_wait(coredev
, msg
,
1311 msg
->x_msg_header
. msg_length
,
1312 &coredev
->init_device_done
);
1319 * calls device handler to change mode of operation
1320 * NOTE: stellar/usb may disconnect when changing mode
1322 * @param coredev pointer to a coredev object returned by
1323 * smscore_register_device
1324 * @param mode requested mode of operation
1326 * return: 0 on success, <0 on error.
1328 int smscore_set_device_mode(struct smscore_device_t
*coredev
, int mode
)
1332 pr_debug("set device mode to %d\n", mode
);
1333 if (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) {
1334 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
) {
1335 pr_err("invalid mode specified %d\n", mode
);
1339 smscore_registry_setmode(coredev
->devpath
, mode
);
1341 if (!(coredev
->device_flags
& SMS_DEVICE_NOT_READY
)) {
1342 rc
= smscore_detect_mode(coredev
);
1344 pr_err("mode detect failed %d\n", rc
);
1349 if (coredev
->mode
== mode
) {
1350 pr_debug("device mode %d already set\n", mode
);
1354 if (!(coredev
->modes_supported
& (1 << mode
))) {
1355 rc
= smscore_load_firmware_from_file(coredev
,
1358 pr_debug("firmware download success\n");
1360 pr_debug("mode %d is already supported by running firmware\n",
1363 if (coredev
->fw_version
>= 0x800) {
1364 rc
= smscore_init_device(coredev
, mode
);
1366 pr_err("device init failed, rc %d.\n", rc
);
1369 if (mode
<= DEVICE_MODE_NONE
|| mode
>= DEVICE_MODE_MAX
) {
1370 pr_err("invalid mode specified %d\n", mode
);
1374 smscore_registry_setmode(coredev
->devpath
, mode
);
1376 if (coredev
->detectmode_handler
)
1377 coredev
->detectmode_handler(coredev
->context
,
1380 if (coredev
->mode
!= mode
&& coredev
->setmode_handler
)
1381 rc
= coredev
->setmode_handler(coredev
->context
, mode
);
1386 coredev
->mode
= mode
;
1387 coredev
->device_flags
&= ~SMS_DEVICE_NOT_READY
;
1389 buffer
= kmalloc(sizeof(struct sms_msg_data
) +
1390 SMS_DMA_ALIGNMENT
, GFP_KERNEL
| GFP_DMA
);
1392 struct sms_msg_data
*msg
= (struct sms_msg_data
*) SMS_ALIGN_ADDRESS(buffer
);
1394 SMS_INIT_MSG(&msg
->x_msg_header
, MSG_SMS_INIT_DEVICE_REQ
,
1395 sizeof(struct sms_msg_data
));
1396 msg
->msg_data
[0] = mode
;
1398 rc
= smscore_sendrequest_and_wait(
1399 coredev
, msg
, msg
->x_msg_header
.msg_length
,
1400 &coredev
->init_device_done
);
1407 pr_err("return error code %d.\n", rc
);
1409 pr_debug("Success setting device mode.\n");
1415 * calls device handler to get current mode of operation
1417 * @param coredev pointer to a coredev object returned by
1418 * smscore_register_device
1420 * return: current mode
1422 int smscore_get_device_mode(struct smscore_device_t
*coredev
)
1424 return coredev
->mode
;
1426 EXPORT_SYMBOL_GPL(smscore_get_device_mode
);
1429 * find client by response id & type within the clients list.
1430 * return client handle or NULL.
1432 * @param coredev pointer to a coredev object returned by
1433 * smscore_register_device
1434 * @param data_type client data type (SMS_DONT_CARE for all types)
1435 * @param id client id (SMS_DONT_CARE for all id)
1439 smscore_client_t
*smscore_find_client(struct smscore_device_t
*coredev
,
1440 int data_type
, int id
)
1442 struct list_head
*first
;
1443 struct smscore_client_t
*client
;
1444 unsigned long flags
;
1445 struct list_head
*firstid
;
1446 struct smscore_idlist_t
*client_id
;
1448 spin_lock_irqsave(&coredev
->clientslock
, flags
);
1449 first
= &coredev
->clients
;
1450 list_for_each_entry(client
, first
, entry
) {
1451 firstid
= &client
->idlist
;
1452 list_for_each_entry(client_id
, firstid
, entry
) {
1453 if ((client_id
->id
== id
) &&
1454 (client_id
->data_type
== data_type
||
1455 (client_id
->data_type
== 0)))
1461 spin_unlock_irqrestore(&coredev
->clientslock
, flags
);
1466 * find client by response id/type, call clients onresponse handler
1467 * return buffer to pool on error
1469 * @param coredev pointer to a coredev object returned by
1470 * smscore_register_device
1471 * @param cb pointer to response buffer descriptor
1474 void smscore_onresponse(struct smscore_device_t
*coredev
,
1475 struct smscore_buffer_t
*cb
) {
1476 struct sms_msg_hdr
*phdr
= (struct sms_msg_hdr
*) ((u8
*) cb
->p
1478 struct smscore_client_t
*client
;
1480 static unsigned long last_sample_time
; /* = 0; */
1481 static int data_total
; /* = 0; */
1482 unsigned long time_now
= jiffies_to_msecs(jiffies
);
1484 if (!last_sample_time
)
1485 last_sample_time
= time_now
;
1487 if (time_now
- last_sample_time
> 10000) {
1488 pr_debug("data rate %d bytes/secs\n",
1489 (int)((data_total
* 1000) /
1490 (time_now
- last_sample_time
)));
1492 last_sample_time
= time_now
;
1496 data_total
+= cb
->size
;
1497 /* Do we need to re-route? */
1498 if ((phdr
->msg_type
== MSG_SMS_HO_PER_SLICES_IND
) ||
1499 (phdr
->msg_type
== MSG_SMS_TRANSMISSION_IND
)) {
1500 if (coredev
->mode
== DEVICE_MODE_DVBT_BDA
)
1501 phdr
->msg_dst_id
= DVBT_BDA_CONTROL_MSG_ID
;
1505 client
= smscore_find_client(coredev
, phdr
->msg_type
, phdr
->msg_dst_id
);
1507 /* If no client registered for type & id,
1508 * check for control client where type is not registered */
1510 rc
= client
->onresponse_handler(client
->context
, cb
);
1513 switch (phdr
->msg_type
) {
1514 case MSG_SMS_ISDBT_TUNE_RES
:
1516 case MSG_SMS_RF_TUNE_RES
:
1518 case MSG_SMS_SIGNAL_DETECTED_IND
:
1520 case MSG_SMS_NO_SIGNAL_IND
:
1522 case MSG_SMS_SPI_INT_LINE_SET_RES
:
1524 case MSG_SMS_INTERFACE_LOCK_IND
:
1526 case MSG_SMS_INTERFACE_UNLOCK_IND
:
1528 case MSG_SMS_GET_VERSION_EX_RES
:
1530 struct sms_version_res
*ver
=
1531 (struct sms_version_res
*) phdr
;
1532 pr_debug("Firmware id %d prots 0x%x ver %d.%d\n",
1533 ver
->firmware_id
, ver
->supported_protocols
,
1534 ver
->rom_ver_major
, ver
->rom_ver_minor
);
1536 coredev
->mode
= ver
->firmware_id
== 255 ?
1537 DEVICE_MODE_NONE
: ver
->firmware_id
;
1538 coredev
->modes_supported
= ver
->supported_protocols
;
1539 coredev
->fw_version
= ver
->rom_ver_major
<< 8 |
1542 complete(&coredev
->version_ex_done
);
1545 case MSG_SMS_INIT_DEVICE_RES
:
1546 complete(&coredev
->init_device_done
);
1548 case MSG_SW_RELOAD_START_RES
:
1549 complete(&coredev
->reload_start_done
);
1551 case MSG_SMS_DATA_VALIDITY_RES
:
1553 struct sms_msg_data
*validity
= (struct sms_msg_data
*) phdr
;
1555 pr_debug("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x\n",
1556 validity
->msg_data
[0]);
1557 complete(&coredev
->data_validity_done
);
1560 case MSG_SMS_DATA_DOWNLOAD_RES
:
1561 complete(&coredev
->data_download_done
);
1563 case MSG_SW_RELOAD_EXEC_RES
:
1565 case MSG_SMS_SWDOWNLOAD_TRIGGER_RES
:
1566 complete(&coredev
->trigger_done
);
1568 case MSG_SMS_SLEEP_RESUME_COMP_IND
:
1569 complete(&coredev
->resume_done
);
1571 case MSG_SMS_GPIO_CONFIG_EX_RES
:
1572 complete(&coredev
->gpio_configuration_done
);
1574 case MSG_SMS_GPIO_SET_LEVEL_RES
:
1575 complete(&coredev
->gpio_set_level_done
);
1577 case MSG_SMS_GPIO_GET_LEVEL_RES
:
1579 u32
*msgdata
= (u32
*) phdr
;
1580 coredev
->gpio_get_res
= msgdata
[1];
1581 pr_debug("gpio level %d\n",
1582 coredev
->gpio_get_res
);
1583 complete(&coredev
->gpio_get_level_done
);
1586 case MSG_SMS_START_IR_RES
:
1587 complete(&coredev
->ir_init_done
);
1589 case MSG_SMS_IR_SAMPLES_IND
:
1590 sms_ir_event(coredev
,
1593 + sizeof(struct sms_msg_hdr
)),
1594 (int)phdr
->msg_length
1595 - sizeof(struct sms_msg_hdr
));
1598 case MSG_SMS_DVBT_BDA_DATA
:
1600 * It can be received here, if the frontend is
1601 * tuned into a valid channel and the proper firmware
1602 * is loaded. That happens when the module got removed
1603 * and re-inserted, without powering the device off
1608 pr_debug("message %s(%d) not handled.\n",
1609 smscore_translate_msg(phdr
->msg_type
),
1613 smscore_putbuffer(coredev
, cb
);
1616 EXPORT_SYMBOL_GPL(smscore_onresponse
);
1619 * return pointer to next free buffer descriptor from core pool
1621 * @param coredev pointer to a coredev object returned by
1622 * smscore_register_device
1624 * return: pointer to descriptor on success, NULL on error.
1627 static struct smscore_buffer_t
*get_entry(struct smscore_device_t
*coredev
)
1629 struct smscore_buffer_t
*cb
= NULL
;
1630 unsigned long flags
;
1632 spin_lock_irqsave(&coredev
->bufferslock
, flags
);
1633 if (!list_empty(&coredev
->buffers
)) {
1634 cb
= (struct smscore_buffer_t
*) coredev
->buffers
.next
;
1635 list_del(&cb
->entry
);
1637 spin_unlock_irqrestore(&coredev
->bufferslock
, flags
);
1641 struct smscore_buffer_t
*smscore_getbuffer(struct smscore_device_t
*coredev
)
1643 struct smscore_buffer_t
*cb
= NULL
;
1645 wait_event(coredev
->buffer_mng_waitq
, (cb
= get_entry(coredev
)));
1649 EXPORT_SYMBOL_GPL(smscore_getbuffer
);
1652 * return buffer descriptor to a pool
1654 * @param coredev pointer to a coredev object returned by
1655 * smscore_register_device
1656 * @param cb pointer buffer descriptor
1659 void smscore_putbuffer(struct smscore_device_t
*coredev
,
1660 struct smscore_buffer_t
*cb
) {
1661 wake_up_interruptible(&coredev
->buffer_mng_waitq
);
1662 list_add_locked(&cb
->entry
, &coredev
->buffers
, &coredev
->bufferslock
);
1664 EXPORT_SYMBOL_GPL(smscore_putbuffer
);
1666 static int smscore_validate_client(struct smscore_device_t
*coredev
,
1667 struct smscore_client_t
*client
,
1668 int data_type
, int id
)
1670 struct smscore_idlist_t
*listentry
;
1671 struct smscore_client_t
*registered_client
;
1674 pr_err("bad parameter.\n");
1677 registered_client
= smscore_find_client(coredev
, data_type
, id
);
1678 if (registered_client
== client
)
1681 if (registered_client
) {
1682 pr_err("The msg ID already registered to another client.\n");
1685 listentry
= kzalloc(sizeof(*listentry
), GFP_KERNEL
);
1690 listentry
->data_type
= data_type
;
1691 list_add_locked(&listentry
->entry
, &client
->idlist
,
1692 &coredev
->clientslock
);
1697 * creates smsclient object, check that id is taken by another client
1699 * @param coredev pointer to a coredev object from clients hotplug
1700 * @param initial_id all messages with this id would be sent to this client
1701 * @param data_type all messages of this type would be sent to this client
1702 * @param onresponse_handler client handler that is called to
1703 * process incoming messages
1704 * @param onremove_handler client handler that is called when device is removed
1705 * @param context client-specific context
1706 * @param client pointer to a value that receives created smsclient object
1708 * return: 0 on success, <0 on error.
1710 int smscore_register_client(struct smscore_device_t
*coredev
,
1711 struct smsclient_params_t
*params
,
1712 struct smscore_client_t
**client
)
1714 struct smscore_client_t
*newclient
;
1715 /* check that no other channel with same parameters exists */
1716 if (smscore_find_client(coredev
, params
->data_type
,
1717 params
->initial_id
)) {
1718 pr_err("Client already exist.\n");
1722 newclient
= kzalloc(sizeof(*newclient
), GFP_KERNEL
);
1726 INIT_LIST_HEAD(&newclient
->idlist
);
1727 newclient
->coredev
= coredev
;
1728 newclient
->onresponse_handler
= params
->onresponse_handler
;
1729 newclient
->onremove_handler
= params
->onremove_handler
;
1730 newclient
->context
= params
->context
;
1731 list_add_locked(&newclient
->entry
, &coredev
->clients
,
1732 &coredev
->clientslock
);
1733 smscore_validate_client(coredev
, newclient
, params
->data_type
,
1734 params
->initial_id
);
1735 *client
= newclient
;
1736 pr_debug("%p %d %d\n", params
->context
, params
->data_type
,
1737 params
->initial_id
);
1741 EXPORT_SYMBOL_GPL(smscore_register_client
);
1744 * frees smsclient object and all subclients associated with it
1746 * @param client pointer to smsclient object returned by
1747 * smscore_register_client
1750 void smscore_unregister_client(struct smscore_client_t
*client
)
1752 struct smscore_device_t
*coredev
= client
->coredev
;
1753 unsigned long flags
;
1755 spin_lock_irqsave(&coredev
->clientslock
, flags
);
1758 while (!list_empty(&client
->idlist
)) {
1759 struct smscore_idlist_t
*identry
=
1760 (struct smscore_idlist_t
*) client
->idlist
.next
;
1761 list_del(&identry
->entry
);
1765 pr_debug("%p\n", client
->context
);
1767 list_del(&client
->entry
);
1770 spin_unlock_irqrestore(&coredev
->clientslock
, flags
);
1772 EXPORT_SYMBOL_GPL(smscore_unregister_client
);
1775 * verifies that source id is not taken by another client,
1776 * calls device handler to send requests to the device
1778 * @param client pointer to smsclient object returned by
1779 * smscore_register_client
1780 * @param buffer pointer to a request buffer
1781 * @param size size (in bytes) of request buffer
1783 * return: 0 on success, <0 on error.
1785 int smsclient_sendrequest(struct smscore_client_t
*client
,
1786 void *buffer
, size_t size
)
1788 struct smscore_device_t
*coredev
;
1789 struct sms_msg_hdr
*phdr
= (struct sms_msg_hdr
*) buffer
;
1793 pr_err("Got NULL client\n");
1797 coredev
= client
->coredev
;
1799 /* check that no other channel with same id exists */
1801 pr_err("Got NULL coredev\n");
1805 rc
= smscore_validate_client(client
->coredev
, client
, 0,
1810 return coredev
->sendrequest_handler(coredev
->context
, buffer
, size
);
1812 EXPORT_SYMBOL_GPL(smsclient_sendrequest
);
1815 /* old GPIO managements implementation */
1816 int smscore_configure_gpio(struct smscore_device_t
*coredev
, u32 pin
,
1817 struct smscore_config_gpio
*pinconfig
)
1820 struct sms_msg_hdr hdr
;
1824 if (coredev
->device_flags
& SMS_DEVICE_FAMILY2
) {
1825 msg
.hdr
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1826 msg
.hdr
.msg_dst_id
= HIF_TASK
;
1827 msg
.hdr
.msg_flags
= 0;
1828 msg
.hdr
.msg_type
= MSG_SMS_GPIO_CONFIG_EX_REQ
;
1829 msg
.hdr
.msg_length
= sizeof(msg
);
1832 msg
.data
[1] = pinconfig
->pullupdown
;
1834 /* Convert slew rate for Nova: Fast(0) = 3 / Slow(1) = 0; */
1835 msg
.data
[2] = pinconfig
->outputslewrate
== 0 ? 3 : 0;
1837 switch (pinconfig
->outputdriving
) {
1838 case SMS_GPIO_OUTPUTDRIVING_S_16mA
:
1839 msg
.data
[3] = 7; /* Nova - 16mA */
1841 case SMS_GPIO_OUTPUTDRIVING_S_12mA
:
1842 msg
.data
[3] = 5; /* Nova - 11mA */
1844 case SMS_GPIO_OUTPUTDRIVING_S_8mA
:
1845 msg
.data
[3] = 3; /* Nova - 7mA */
1847 case SMS_GPIO_OUTPUTDRIVING_S_4mA
:
1849 msg
.data
[3] = 2; /* Nova - 4mA */
1853 msg
.data
[4] = pinconfig
->direction
;
1855 } else /* TODO: SMS_DEVICE_FAMILY1 */
1858 return coredev
->sendrequest_handler(coredev
->context
,
1862 int smscore_set_gpio(struct smscore_device_t
*coredev
, u32 pin
, int level
)
1865 struct sms_msg_hdr hdr
;
1869 if (pin
> MAX_GPIO_PIN_NUMBER
)
1872 msg
.hdr
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1873 msg
.hdr
.msg_dst_id
= HIF_TASK
;
1874 msg
.hdr
.msg_flags
= 0;
1875 msg
.hdr
.msg_type
= MSG_SMS_GPIO_SET_LEVEL_REQ
;
1876 msg
.hdr
.msg_length
= sizeof(msg
);
1879 msg
.data
[1] = level
? 1 : 0;
1882 return coredev
->sendrequest_handler(coredev
->context
,
1886 /* new GPIO management implementation */
1887 static int get_gpio_pin_params(u32 pin_num
, u32
*p_translatedpin_num
,
1888 u32
*p_group_num
, u32
*p_group_cfg
) {
1893 *p_translatedpin_num
= 0;
1896 } else if (pin_num
>= 2 && pin_num
<= 6) {
1897 *p_translatedpin_num
= 2;
1900 } else if (pin_num
>= 7 && pin_num
<= 11) {
1901 *p_translatedpin_num
= 7;
1903 } else if (pin_num
>= 12 && pin_num
<= 15) {
1904 *p_translatedpin_num
= 12;
1907 } else if (pin_num
== 16) {
1908 *p_translatedpin_num
= 16;
1910 } else if (pin_num
>= 17 && pin_num
<= 24) {
1911 *p_translatedpin_num
= 17;
1913 } else if (pin_num
== 25) {
1914 *p_translatedpin_num
= 25;
1916 } else if (pin_num
>= 26 && pin_num
<= 28) {
1917 *p_translatedpin_num
= 26;
1919 } else if (pin_num
== 29) {
1920 *p_translatedpin_num
= 29;
1923 } else if (pin_num
== 30) {
1924 *p_translatedpin_num
= 30;
1926 } else if (pin_num
== 31) {
1927 *p_translatedpin_num
= 31;
1932 *p_group_cfg
<<= 24;
1937 int smscore_gpio_configure(struct smscore_device_t
*coredev
, u8 pin_num
,
1938 struct smscore_config_gpio
*p_gpio_config
) {
1941 u32 translatedpin_num
= 0;
1948 struct set_gpio_msg
{
1949 struct sms_msg_hdr x_msg_header
;
1954 if (pin_num
> MAX_GPIO_PIN_NUMBER
)
1960 total_len
= sizeof(struct sms_msg_hdr
) + (sizeof(u32
) * 6);
1962 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
1963 GFP_KERNEL
| GFP_DMA
);
1967 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
1969 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
1970 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
1971 p_msg
->x_msg_header
.msg_flags
= 0;
1972 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
1973 p_msg
->msg_data
[0] = pin_num
;
1975 if (!(coredev
->device_flags
& SMS_DEVICE_FAMILY2
)) {
1976 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_CONFIG_REQ
;
1977 if (get_gpio_pin_params(pin_num
, &translatedpin_num
, &group_num
,
1983 p_msg
->msg_data
[1] = translatedpin_num
;
1984 p_msg
->msg_data
[2] = group_num
;
1985 electric_char
= (p_gpio_config
->pullupdown
)
1986 | (p_gpio_config
->inputcharacteristics
<< 2)
1987 | (p_gpio_config
->outputslewrate
<< 3)
1988 | (p_gpio_config
->outputdriving
<< 4);
1989 p_msg
->msg_data
[3] = electric_char
;
1990 p_msg
->msg_data
[4] = p_gpio_config
->direction
;
1991 p_msg
->msg_data
[5] = group_cfg
;
1993 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_CONFIG_EX_REQ
;
1994 p_msg
->msg_data
[1] = p_gpio_config
->pullupdown
;
1995 p_msg
->msg_data
[2] = p_gpio_config
->outputslewrate
;
1996 p_msg
->msg_data
[3] = p_gpio_config
->outputdriving
;
1997 p_msg
->msg_data
[4] = p_gpio_config
->direction
;
1998 p_msg
->msg_data
[5] = 0;
2001 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2002 &coredev
->gpio_configuration_done
);
2006 pr_err("smscore_gpio_configure timeout\n");
2008 pr_err("smscore_gpio_configure error\n");
2016 int smscore_gpio_set_level(struct smscore_device_t
*coredev
, u8 pin_num
,
2023 struct set_gpio_msg
{
2024 struct sms_msg_hdr x_msg_header
;
2025 u32 msg_data
[3]; /* keep it 3 ! */
2028 if ((new_level
> 1) || (pin_num
> MAX_GPIO_PIN_NUMBER
))
2031 total_len
= sizeof(struct sms_msg_hdr
) +
2032 (3 * sizeof(u32
)); /* keep it 3 ! */
2034 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
2035 GFP_KERNEL
| GFP_DMA
);
2039 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
2041 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
2042 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
2043 p_msg
->x_msg_header
.msg_flags
= 0;
2044 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_SET_LEVEL_REQ
;
2045 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
2046 p_msg
->msg_data
[0] = pin_num
;
2047 p_msg
->msg_data
[1] = new_level
;
2049 /* Send message to SMS */
2050 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2051 &coredev
->gpio_set_level_done
);
2055 pr_err("smscore_gpio_set_level timeout\n");
2057 pr_err("smscore_gpio_set_level error\n");
2064 int smscore_gpio_get_level(struct smscore_device_t
*coredev
, u8 pin_num
,
2071 struct set_gpio_msg
{
2072 struct sms_msg_hdr x_msg_header
;
2077 if (pin_num
> MAX_GPIO_PIN_NUMBER
)
2080 total_len
= sizeof(struct sms_msg_hdr
) + (2 * sizeof(u32
));
2082 buffer
= kmalloc(total_len
+ SMS_DMA_ALIGNMENT
,
2083 GFP_KERNEL
| GFP_DMA
);
2087 p_msg
= (struct set_gpio_msg
*) SMS_ALIGN_ADDRESS(buffer
);
2089 p_msg
->x_msg_header
.msg_src_id
= DVBT_BDA_CONTROL_MSG_ID
;
2090 p_msg
->x_msg_header
.msg_dst_id
= HIF_TASK
;
2091 p_msg
->x_msg_header
.msg_flags
= 0;
2092 p_msg
->x_msg_header
.msg_type
= MSG_SMS_GPIO_GET_LEVEL_REQ
;
2093 p_msg
->x_msg_header
.msg_length
= (u16
) total_len
;
2094 p_msg
->msg_data
[0] = pin_num
;
2095 p_msg
->msg_data
[1] = 0;
2097 /* Send message to SMS */
2098 rc
= smscore_sendrequest_and_wait(coredev
, p_msg
, total_len
,
2099 &coredev
->gpio_get_level_done
);
2103 pr_err("smscore_gpio_get_level timeout\n");
2105 pr_err("smscore_gpio_get_level error\n");
2109 /* Its a race between other gpio_get_level() and the copy of the single
2110 * global 'coredev->gpio_get_res' to the function's variable 'level'
2112 *level
= coredev
->gpio_get_res
;
2117 static int __init
smscore_module_init(void)
2119 INIT_LIST_HEAD(&g_smscore_notifyees
);
2120 INIT_LIST_HEAD(&g_smscore_devices
);
2121 kmutex_init(&g_smscore_deviceslock
);
2123 INIT_LIST_HEAD(&g_smscore_registry
);
2124 kmutex_init(&g_smscore_registrylock
);
2129 static void __exit
smscore_module_exit(void)
2131 kmutex_lock(&g_smscore_deviceslock
);
2132 while (!list_empty(&g_smscore_notifyees
)) {
2133 struct smscore_device_notifyee_t
*notifyee
=
2134 (struct smscore_device_notifyee_t
*)
2135 g_smscore_notifyees
.next
;
2137 list_del(¬ifyee
->entry
);
2140 kmutex_unlock(&g_smscore_deviceslock
);
2142 kmutex_lock(&g_smscore_registrylock
);
2143 while (!list_empty(&g_smscore_registry
)) {
2144 struct smscore_registry_entry_t
*entry
=
2145 (struct smscore_registry_entry_t
*)
2146 g_smscore_registry
.next
;
2148 list_del(&entry
->entry
);
2151 kmutex_unlock(&g_smscore_registrylock
);
2156 module_init(smscore_module_init
);
2157 module_exit(smscore_module_exit
);
2159 MODULE_DESCRIPTION("Siano MDTV Core module");
2160 MODULE_AUTHOR("Siano Mobile Silicon, Inc. (uris@siano-ms.com)");
2161 MODULE_LICENSE("GPL");
2163 /* This should match what's defined at smscoreapi.h */
2164 MODULE_FIRMWARE(SMS_FW_ATSC_DENVER
);
2165 MODULE_FIRMWARE(SMS_FW_CMMB_MING_APP
);
2166 MODULE_FIRMWARE(SMS_FW_CMMB_VEGA_12MHZ
);
2167 MODULE_FIRMWARE(SMS_FW_CMMB_VENICE_12MHZ
);
2168 MODULE_FIRMWARE(SMS_FW_DVBH_RIO
);
2169 MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ_B0
);
2170 MODULE_FIRMWARE(SMS_FW_DVB_NOVA_12MHZ
);
2171 MODULE_FIRMWARE(SMS_FW_DVB_RIO
);
2172 MODULE_FIRMWARE(SMS_FW_FM_RADIO
);
2173 MODULE_FIRMWARE(SMS_FW_FM_RADIO_RIO
);
2174 MODULE_FIRMWARE(SMS_FW_DVBT_HCW_55XXX
);
2175 MODULE_FIRMWARE(SMS_FW_ISDBT_HCW_55XXX
);
2176 MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ_B0
);
2177 MODULE_FIRMWARE(SMS_FW_ISDBT_NOVA_12MHZ
);
2178 MODULE_FIRMWARE(SMS_FW_ISDBT_PELE
);
2179 MODULE_FIRMWARE(SMS_FW_ISDBT_RIO
);
2180 MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_A
);
2181 MODULE_FIRMWARE(SMS_FW_DVBT_NOVA_B
);
2182 MODULE_FIRMWARE(SMS_FW_DVBT_STELLAR
);
2183 MODULE_FIRMWARE(SMS_FW_TDMB_DENVER
);
2184 MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ_B0
);
2185 MODULE_FIRMWARE(SMS_FW_TDMB_NOVA_12MHZ
);