1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * FM Driver for Connectivity chip of Texas Instruments.
4 * FM Common module header file
6 * Copyright (C) 2011 Texas Instruments
9 #ifndef _FMDRV_COMMON_H
10 #define _FMDRV_COMMON_H
12 #define FM_ST_REG_TIMEOUT msecs_to_jiffies(6000) /* 6 sec */
13 #define FM_PKT_LOGICAL_CHAN_NUMBER 0x08 /* Logical channel 8 */
25 #define RSSI_LVL_GET 1
26 #define IF_COUNT_GET 2
28 #define RDS_SYNC_GET 4
29 #define RDS_DATA_GET 5
31 #define AF_FREQ_SET 11
32 #define MOST_MODE_SET 12
33 #define MOST_BLEND_SET 13
34 #define DEMPH_MODE_SET 14
35 #define SEARCH_LVL_SET 15
37 #define MUTE_STATUS_SET 17
38 #define RDS_PAUSE_LVL_SET 18
39 #define RDS_PAUSE_DUR_SET 19
40 #define RDS_MEM_SET 20
41 #define RDS_BLK_B_SET 21
42 #define RDS_MSK_B_SET 22
43 #define RDS_PI_MASK_SET 23
45 #define RDS_SYSTEM_SET 25
46 #define INT_MASK_SET 26
47 #define SEARCH_DIR_SET 27
49 #define AUDIO_ENABLE_SET 29
50 #define PCM_MODE_SET 30
51 #define I2S_MODE_CONFIG_SET 31
53 #define INTX_CONFIG_SET 33
54 #define PULL_EN_SET 34
56 #define SWITCH2FREF 36
57 #define FREQ_DRIFT_REPORT 37
60 #define FIRM_VER_GET 41
61 #define ASIC_VER_GET 42
62 #define ASIC_ID_GET 43
64 #define TUNER_MODE_SET 45
65 #define STOP_SEARCH 46
66 #define RDS_CNTRL_SET 47
68 #define WRITE_HARDWARE_REG 100
69 #define CODE_DOWNLOAD 101
72 #define FM_POWER_MODE 254
73 #define FM_INTERRUPT 255
78 #define CHANL_BW_SET 56
80 #define POWER_ENB_SET 90
81 #define POWER_ATT_SET 58
82 #define POWER_LEV_SET 59
83 #define AUDIO_DEV_SET 60
84 #define PILOT_DEV_SET 61
85 #define RDS_DEV_SET 62
86 #define TX_BAND_SET 65
88 #define AUDIO_IO_SET 63
92 #define MPX_LMT_ENABLE 67
97 #define DISPLAY_MODE 74
98 #define RDS_REP_SET 77
99 #define RDS_CONFIG_DATA_SET 98
100 #define RDS_DATA_SET 99
101 #define RDS_DATA_ENB 94
106 #define PS_SCROLL_SPEED 82
107 #define TX_AUDIO_LEVEL_TEST 96
108 #define TX_AUDIO_LEVEL_TEST_THRESHOLD 73
109 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET 54
110 #define RX_ANTENNA_SELECT 87
111 #define I2C_DEV_ADDR_SET 86
112 #define REF_ERR_CALIB_PARAM_SET 88
113 #define REF_ERR_CALIB_PERIODICITY_SET 89
114 #define SOC_INT_TRIGGER 52
115 #define SOC_AUDIO_PATH_SET 83
116 #define SOC_PCMI_OVERRIDE 84
117 #define SOC_I2S_OVERRIDE 85
118 #define RSSI_BLOCK_SCAN_FREQ_SET 95
119 #define RSSI_BLOCK_SCAN_START 97
120 #define RSSI_BLOCK_SCAN_DATA_GET 5
121 #define READ_FMANT_TUNE_VALUE 104
126 struct completion
*completion
;
129 #define fm_cb(skb) ((struct fm_skb_cb *)(skb->cb))
131 /* FM Channel-8 command message format */
132 struct fm_cmd_msg_hdr
{
133 __u8 hdr
; /* Logical Channel-8 */
134 __u8 len
; /* Number of bytes follows */
135 __u8 op
; /* FM Opcode */
136 __u8 rd_wr
; /* Read/Write command */
137 __u8 dlen
; /* Length of payload */
138 } __attribute__ ((packed
));
140 #define FM_CMD_MSG_HDR_SIZE 5 /* sizeof(struct fm_cmd_msg_hdr) */
142 /* FM Channel-8 event messgage format */
143 struct fm_event_msg_hdr
{
144 __u8 header
; /* Logical Channel-8 */
145 __u8 len
; /* Number of bytes follows */
146 __u8 status
; /* Event status */
147 __u8 num_fm_hci_cmds
; /* Number of pkts the host allowed to send */
148 __u8 op
; /* FM Opcode */
149 __u8 rd_wr
; /* Read/Write command */
150 __u8 dlen
; /* Length of payload */
151 } __attribute__ ((packed
));
153 #define FM_EVT_MSG_HDR_SIZE 7 /* sizeof(struct fm_event_msg_hdr) */
155 /* TI's magic number in firmware file */
156 #define FM_FW_FILE_HEADER_MAGIC 0x42535442
161 /* FLAG_GET register bits */
162 #define FM_FR_EVENT BIT(0)
163 #define FM_BL_EVENT BIT(1)
164 #define FM_RDS_EVENT BIT(2)
165 #define FM_BBLK_EVENT BIT(3)
166 #define FM_LSYNC_EVENT BIT(4)
167 #define FM_LEV_EVENT BIT(5)
168 #define FM_IFFR_EVENT BIT(6)
169 #define FM_PI_EVENT BIT(7)
170 #define FM_PD_EVENT BIT(8)
171 #define FM_STIC_EVENT BIT(9)
172 #define FM_MAL_EVENT BIT(10)
173 #define FM_POW_ENB_EVENT BIT(11)
176 * Firmware files of FM. ASIC ID and ASIC version will be appened to this,
179 #define FM_FMC_FW_FILE_START ("fmc_ch8")
180 #define FM_RX_FW_FILE_START ("fm_rx_ch8")
181 #define FM_TX_FW_FILE_START ("fm_tx_ch8")
183 #define FM_UNDEFINED_FREQ 0xFFFFFFFF
186 #define FM_BAND_EUROPE_US 0
187 #define FM_BAND_JAPAN 1
189 /* Seek directions */
190 #define FM_SEARCH_DIRECTION_DOWN 0
191 #define FM_SEARCH_DIRECTION_UP 1
194 #define FM_TUNER_STOP_SEARCH_MODE 0
195 #define FM_TUNER_PRESET_MODE 1
196 #define FM_TUNER_AUTONOMOUS_SEARCH_MODE 2
197 #define FM_TUNER_AF_JUMP_MODE 3
199 /* Min and Max volume */
200 #define FM_RX_VOLUME_MIN 0
201 #define FM_RX_VOLUME_MAX 70
203 /* Volume gain step */
204 #define FM_RX_VOLUME_GAIN_STEP 0x370
208 #define FM_MUTE_OFF 1
209 #define FM_MUTE_ATTENUATE 2
211 #define FM_RX_UNMUTE_MODE 0x00
212 #define FM_RX_RF_DEP_MODE 0x01
213 #define FM_RX_AC_MUTE_MODE 0x02
214 #define FM_RX_HARD_MUTE_LEFT_MODE 0x04
215 #define FM_RX_HARD_MUTE_RIGHT_MODE 0x08
216 #define FM_RX_SOFT_MUTE_FORCE_MODE 0x10
218 /* RF dependent mute mode */
219 #define FM_RX_RF_DEPENDENT_MUTE_ON 1
220 #define FM_RX_RF_DEPENDENT_MUTE_OFF 0
222 /* RSSI threshold min and max */
223 #define FM_RX_RSSI_THRESHOLD_MIN -128
224 #define FM_RX_RSSI_THRESHOLD_MAX 127
226 /* Stereo/Mono mode */
227 #define FM_STEREO_MODE 0
228 #define FM_MONO_MODE 1
229 #define FM_STEREO_SOFT_BLEND 1
231 /* FM RX De-emphasis filter modes */
232 #define FM_RX_EMPHASIS_FILTER_50_USEC 0
233 #define FM_RX_EMPHASIS_FILTER_75_USEC 1
236 #define FM_RDS_DISABLE 0
237 #define FM_RDS_ENABLE 1
239 #define FM_NO_PI_CODE 0
241 /* FM and RX RDS block enable/disable */
242 #define FM_RX_PWR_SET_FM_ON_RDS_OFF 0x1
243 #define FM_RX_PWR_SET_FM_AND_RDS_BLK_ON 0x3
244 #define FM_RX_PWR_SET_FM_AND_RDS_BLK_OFF 0x0
247 #define FM_RX_RDS_FLUSH_FIFO 0x1
248 #define FM_RX_RDS_FIFO_THRESHOLD 64 /* tuples */
249 #define FM_RDS_BLK_SIZE 3 /* 3 bytes */
251 /* RDS block types */
252 #define FM_RDS_BLOCK_A 0
253 #define FM_RDS_BLOCK_B 1
254 #define FM_RDS_BLOCK_C 2
255 #define FM_RDS_BLOCK_Ctag 3
256 #define FM_RDS_BLOCK_D 4
257 #define FM_RDS_BLOCK_E 5
259 #define FM_RDS_BLK_IDX_A 0
260 #define FM_RDS_BLK_IDX_B 1
261 #define FM_RDS_BLK_IDX_C 2
262 #define FM_RDS_BLK_IDX_D 3
263 #define FM_RDS_BLK_IDX_UNKNOWN 0xF0
265 #define FM_RDS_STATUS_ERR_MASK 0x18
268 * Represents an RDS group type & version.
269 * There are 15 groups, each group has 2 versions: A and B.
271 #define FM_RDS_GROUP_TYPE_MASK_0A BIT(0)
272 #define FM_RDS_GROUP_TYPE_MASK_0B BIT(1)
273 #define FM_RDS_GROUP_TYPE_MASK_1A BIT(2)
274 #define FM_RDS_GROUP_TYPE_MASK_1B BIT(3)
275 #define FM_RDS_GROUP_TYPE_MASK_2A BIT(4)
276 #define FM_RDS_GROUP_TYPE_MASK_2B BIT(5)
277 #define FM_RDS_GROUP_TYPE_MASK_3A BIT(6)
278 #define FM_RDS_GROUP_TYPE_MASK_3B BIT(7)
279 #define FM_RDS_GROUP_TYPE_MASK_4A BIT(8)
280 #define FM_RDS_GROUP_TYPE_MASK_4B BIT(9)
281 #define FM_RDS_GROUP_TYPE_MASK_5A BIT(10)
282 #define FM_RDS_GROUP_TYPE_MASK_5B BIT(11)
283 #define FM_RDS_GROUP_TYPE_MASK_6A BIT(12)
284 #define FM_RDS_GROUP_TYPE_MASK_6B BIT(13)
285 #define FM_RDS_GROUP_TYPE_MASK_7A BIT(14)
286 #define FM_RDS_GROUP_TYPE_MASK_7B BIT(15)
287 #define FM_RDS_GROUP_TYPE_MASK_8A BIT(16)
288 #define FM_RDS_GROUP_TYPE_MASK_8B BIT(17)
289 #define FM_RDS_GROUP_TYPE_MASK_9A BIT(18)
290 #define FM_RDS_GROUP_TYPE_MASK_9B BIT(19)
291 #define FM_RDS_GROUP_TYPE_MASK_10A BIT(20)
292 #define FM_RDS_GROUP_TYPE_MASK_10B BIT(21)
293 #define FM_RDS_GROUP_TYPE_MASK_11A BIT(22)
294 #define FM_RDS_GROUP_TYPE_MASK_11B BIT(23)
295 #define FM_RDS_GROUP_TYPE_MASK_12A BIT(24)
296 #define FM_RDS_GROUP_TYPE_MASK_12B BIT(25)
297 #define FM_RDS_GROUP_TYPE_MASK_13A BIT(26)
298 #define FM_RDS_GROUP_TYPE_MASK_13B BIT(27)
299 #define FM_RDS_GROUP_TYPE_MASK_14A BIT(28)
300 #define FM_RDS_GROUP_TYPE_MASK_14B BIT(29)
301 #define FM_RDS_GROUP_TYPE_MASK_15A BIT(30)
302 #define FM_RDS_GROUP_TYPE_MASK_15B BIT(31)
304 /* RX Alternate Frequency info */
305 #define FM_RDS_MIN_AF 1
306 #define FM_RDS_MAX_AF 204
307 #define FM_RDS_MAX_AF_JAPAN 140
308 #define FM_RDS_1_AF_FOLLOWS 225
309 #define FM_RDS_25_AF_FOLLOWS 249
311 /* RDS system type (RDS/RBDS) */
312 #define FM_RDS_SYSTEM_RDS 0
313 #define FM_RDS_SYSTEM_RBDS 1
316 #define FM_RX_RDS_AF_SWITCH_MODE_ON 1
317 #define FM_RX_RDS_AF_SWITCH_MODE_OFF 0
319 /* Retry count when interrupt process goes wrong */
320 #define FM_IRQ_TIMEOUT_RETRY_MAX 5 /* 5 times */
322 /* Audio IO set values */
323 #define FM_RX_AUDIO_ENABLE_I2S 0x01
324 #define FM_RX_AUDIO_ENABLE_ANALOG 0x02
325 #define FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG 0x03
326 #define FM_RX_AUDIO_ENABLE_DISABLE 0x00
328 /* HI/LO set values */
329 #define FM_RX_IFFREQ_TO_HI_SIDE 0x0
330 #define FM_RX_IFFREQ_TO_LO_SIDE 0x1
331 #define FM_RX_IFFREQ_HILO_AUTOMATIC 0x2
334 * Default RX mode configuration. Chip will be configured
335 * with this default values after loading RX firmware.
337 #define FM_DEFAULT_RX_VOLUME 10
338 #define FM_DEFAULT_RSSI_THRESHOLD 3
340 /* Range for TX power level in units for dB/uV */
341 #define FM_PWR_LVL_LOW 91
342 #define FM_PWR_LVL_HIGH 122
344 /* Chip specific default TX power level value */
345 #define FM_PWR_LVL_DEF 4
347 /* FM TX Pre-emphasis filter values */
348 #define FM_TX_PREEMPH_OFF 1
349 #define FM_TX_PREEMPH_50US 0
350 #define FM_TX_PREEMPH_75US 2
352 /* FM TX antenna impedance values */
353 #define FM_TX_ANT_IMP_50 0
354 #define FM_TX_ANT_IMP_200 1
355 #define FM_TX_ANT_IMP_500 2
357 /* Functions exported by FM common sub-module */
358 int fmc_prepare(struct fmdev
*);
359 int fmc_release(struct fmdev
*);
361 void fmc_update_region_info(struct fmdev
*, u8
);
362 int fmc_send_cmd(struct fmdev
*, u8
, u16
,
363 void *, unsigned int, void *, int *);
364 int fmc_is_rds_data_available(struct fmdev
*, struct file
*,
365 struct poll_table_struct
*);
366 int fmc_transfer_rds_from_internal_buff(struct fmdev
*, struct file
*,
367 u8 __user
*, size_t);
369 int fmc_set_freq(struct fmdev
*, u32
);
370 int fmc_set_mode(struct fmdev
*, u8
);
371 int fmc_set_region(struct fmdev
*, u8
);
372 int fmc_set_mute_mode(struct fmdev
*, u8
);
373 int fmc_set_stereo_mono(struct fmdev
*, u16
);
374 int fmc_set_rds_mode(struct fmdev
*, u8
);
376 int fmc_get_freq(struct fmdev
*, u32
*);
377 int fmc_get_region(struct fmdev
*, u8
*);
378 int fmc_get_mode(struct fmdev
*, u8
*);
383 #define FM_CHANNEL_SPACING_50KHZ 1
384 #define FM_CHANNEL_SPACING_100KHZ 2
385 #define FM_CHANNEL_SPACING_200KHZ 4
386 #define FM_FREQ_MUL 50