18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  FM Driver for Connectivity chip of Texas Instruments.
48c2ecf20Sopenharmony_ci *  FM Common module header file
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci *  Copyright (C) 2011 Texas Instruments
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _FMDRV_COMMON_H
108c2ecf20Sopenharmony_ci#define _FMDRV_COMMON_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define FM_ST_REG_TIMEOUT   msecs_to_jiffies(6000)	/* 6 sec */
138c2ecf20Sopenharmony_ci#define FM_PKT_LOGICAL_CHAN_NUMBER  0x08   /* Logical channel 8 */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define REG_RD       0x1
168c2ecf20Sopenharmony_ci#define REG_WR      0x0
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct fm_reg_table {
198c2ecf20Sopenharmony_ci	u8 opcode;
208c2ecf20Sopenharmony_ci	u8 type;
218c2ecf20Sopenharmony_ci	u8 *name;
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define STEREO_GET               0
258c2ecf20Sopenharmony_ci#define RSSI_LVL_GET             1
268c2ecf20Sopenharmony_ci#define IF_COUNT_GET             2
278c2ecf20Sopenharmony_ci#define FLAG_GET                 3
288c2ecf20Sopenharmony_ci#define RDS_SYNC_GET             4
298c2ecf20Sopenharmony_ci#define RDS_DATA_GET             5
308c2ecf20Sopenharmony_ci#define FREQ_SET                 10
318c2ecf20Sopenharmony_ci#define AF_FREQ_SET              11
328c2ecf20Sopenharmony_ci#define MOST_MODE_SET            12
338c2ecf20Sopenharmony_ci#define MOST_BLEND_SET           13
348c2ecf20Sopenharmony_ci#define DEMPH_MODE_SET           14
358c2ecf20Sopenharmony_ci#define SEARCH_LVL_SET           15
368c2ecf20Sopenharmony_ci#define BAND_SET                 16
378c2ecf20Sopenharmony_ci#define MUTE_STATUS_SET          17
388c2ecf20Sopenharmony_ci#define RDS_PAUSE_LVL_SET        18
398c2ecf20Sopenharmony_ci#define RDS_PAUSE_DUR_SET        19
408c2ecf20Sopenharmony_ci#define RDS_MEM_SET              20
418c2ecf20Sopenharmony_ci#define RDS_BLK_B_SET            21
428c2ecf20Sopenharmony_ci#define RDS_MSK_B_SET            22
438c2ecf20Sopenharmony_ci#define RDS_PI_MASK_SET          23
448c2ecf20Sopenharmony_ci#define RDS_PI_SET               24
458c2ecf20Sopenharmony_ci#define RDS_SYSTEM_SET           25
468c2ecf20Sopenharmony_ci#define INT_MASK_SET             26
478c2ecf20Sopenharmony_ci#define SEARCH_DIR_SET           27
488c2ecf20Sopenharmony_ci#define VOLUME_SET               28
498c2ecf20Sopenharmony_ci#define AUDIO_ENABLE_SET         29
508c2ecf20Sopenharmony_ci#define PCM_MODE_SET             30
518c2ecf20Sopenharmony_ci#define I2S_MODE_CONFIG_SET      31
528c2ecf20Sopenharmony_ci#define POWER_SET                32
538c2ecf20Sopenharmony_ci#define INTX_CONFIG_SET          33
548c2ecf20Sopenharmony_ci#define PULL_EN_SET              34
558c2ecf20Sopenharmony_ci#define HILO_SET                 35
568c2ecf20Sopenharmony_ci#define SWITCH2FREF              36
578c2ecf20Sopenharmony_ci#define FREQ_DRIFT_REPORT        37
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define PCE_GET                  40
608c2ecf20Sopenharmony_ci#define FIRM_VER_GET             41
618c2ecf20Sopenharmony_ci#define ASIC_VER_GET             42
628c2ecf20Sopenharmony_ci#define ASIC_ID_GET              43
638c2ecf20Sopenharmony_ci#define MAN_ID_GET               44
648c2ecf20Sopenharmony_ci#define TUNER_MODE_SET           45
658c2ecf20Sopenharmony_ci#define STOP_SEARCH              46
668c2ecf20Sopenharmony_ci#define RDS_CNTRL_SET            47
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define WRITE_HARDWARE_REG       100
698c2ecf20Sopenharmony_ci#define CODE_DOWNLOAD            101
708c2ecf20Sopenharmony_ci#define RESET                    102
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define FM_POWER_MODE            254
738c2ecf20Sopenharmony_ci#define FM_INTERRUPT             255
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* Transmitter API */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define CHANL_SET                55
788c2ecf20Sopenharmony_ci#define CHANL_BW_SET		56
798c2ecf20Sopenharmony_ci#define REF_SET                  57
808c2ecf20Sopenharmony_ci#define POWER_ENB_SET            90
818c2ecf20Sopenharmony_ci#define POWER_ATT_SET            58
828c2ecf20Sopenharmony_ci#define POWER_LEV_SET            59
838c2ecf20Sopenharmony_ci#define AUDIO_DEV_SET            60
848c2ecf20Sopenharmony_ci#define PILOT_DEV_SET            61
858c2ecf20Sopenharmony_ci#define RDS_DEV_SET              62
868c2ecf20Sopenharmony_ci#define TX_BAND_SET              65
878c2ecf20Sopenharmony_ci#define PUPD_SET                 91
888c2ecf20Sopenharmony_ci#define AUDIO_IO_SET             63
898c2ecf20Sopenharmony_ci#define PREMPH_SET               64
908c2ecf20Sopenharmony_ci#define MONO_SET                 66
918c2ecf20Sopenharmony_ci#define MUTE                     92
928c2ecf20Sopenharmony_ci#define MPX_LMT_ENABLE           67
938c2ecf20Sopenharmony_ci#define PI_SET                   93
948c2ecf20Sopenharmony_ci#define ECC_SET                  69
958c2ecf20Sopenharmony_ci#define PTY                      70
968c2ecf20Sopenharmony_ci#define AF                       71
978c2ecf20Sopenharmony_ci#define DISPLAY_MODE             74
988c2ecf20Sopenharmony_ci#define RDS_REP_SET              77
998c2ecf20Sopenharmony_ci#define RDS_CONFIG_DATA_SET      98
1008c2ecf20Sopenharmony_ci#define RDS_DATA_SET             99
1018c2ecf20Sopenharmony_ci#define RDS_DATA_ENB             94
1028c2ecf20Sopenharmony_ci#define TA_SET                   78
1038c2ecf20Sopenharmony_ci#define TP_SET                   79
1048c2ecf20Sopenharmony_ci#define DI_SET                   80
1058c2ecf20Sopenharmony_ci#define MS_SET                   81
1068c2ecf20Sopenharmony_ci#define PS_SCROLL_SPEED          82
1078c2ecf20Sopenharmony_ci#define TX_AUDIO_LEVEL_TEST      96
1088c2ecf20Sopenharmony_ci#define TX_AUDIO_LEVEL_TEST_THRESHOLD    73
1098c2ecf20Sopenharmony_ci#define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
1108c2ecf20Sopenharmony_ci#define RX_ANTENNA_SELECT        87
1118c2ecf20Sopenharmony_ci#define I2C_DEV_ADDR_SET         86
1128c2ecf20Sopenharmony_ci#define REF_ERR_CALIB_PARAM_SET          88
1138c2ecf20Sopenharmony_ci#define REF_ERR_CALIB_PERIODICITY_SET    89
1148c2ecf20Sopenharmony_ci#define SOC_INT_TRIGGER                  52
1158c2ecf20Sopenharmony_ci#define SOC_AUDIO_PATH_SET               83
1168c2ecf20Sopenharmony_ci#define SOC_PCMI_OVERRIDE                84
1178c2ecf20Sopenharmony_ci#define SOC_I2S_OVERRIDE         85
1188c2ecf20Sopenharmony_ci#define RSSI_BLOCK_SCAN_FREQ_SET 95
1198c2ecf20Sopenharmony_ci#define RSSI_BLOCK_SCAN_START    97
1208c2ecf20Sopenharmony_ci#define RSSI_BLOCK_SCAN_DATA_GET  5
1218c2ecf20Sopenharmony_ci#define READ_FMANT_TUNE_VALUE            104
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/* SKB helpers */
1248c2ecf20Sopenharmony_cistruct fm_skb_cb {
1258c2ecf20Sopenharmony_ci	__u8 fm_op;
1268c2ecf20Sopenharmony_ci	struct completion *completion;
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define fm_cb(skb) ((struct fm_skb_cb *)(skb->cb))
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* FM Channel-8 command message format */
1328c2ecf20Sopenharmony_cistruct fm_cmd_msg_hdr {
1338c2ecf20Sopenharmony_ci	__u8 hdr;		/* Logical Channel-8 */
1348c2ecf20Sopenharmony_ci	__u8 len;		/* Number of bytes follows */
1358c2ecf20Sopenharmony_ci	__u8 op;		/* FM Opcode */
1368c2ecf20Sopenharmony_ci	__u8 rd_wr;		/* Read/Write command */
1378c2ecf20Sopenharmony_ci	__u8 dlen;		/* Length of payload */
1388c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define FM_CMD_MSG_HDR_SIZE    5	/* sizeof(struct fm_cmd_msg_hdr) */
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/* FM Channel-8 event messgage format */
1438c2ecf20Sopenharmony_cistruct fm_event_msg_hdr {
1448c2ecf20Sopenharmony_ci	__u8 header;		/* Logical Channel-8 */
1458c2ecf20Sopenharmony_ci	__u8 len;		/* Number of bytes follows */
1468c2ecf20Sopenharmony_ci	__u8 status;		/* Event status */
1478c2ecf20Sopenharmony_ci	__u8 num_fm_hci_cmds;	/* Number of pkts the host allowed to send */
1488c2ecf20Sopenharmony_ci	__u8 op;		/* FM Opcode */
1498c2ecf20Sopenharmony_ci	__u8 rd_wr;		/* Read/Write command */
1508c2ecf20Sopenharmony_ci	__u8 dlen;		/* Length of payload */
1518c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define FM_EVT_MSG_HDR_SIZE     7	/* sizeof(struct fm_event_msg_hdr) */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci/* TI's magic number in firmware file */
1568c2ecf20Sopenharmony_ci#define FM_FW_FILE_HEADER_MAGIC	     0x42535442
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define FM_ENABLE   1
1598c2ecf20Sopenharmony_ci#define FM_DISABLE  0
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci/* FLAG_GET register bits */
1628c2ecf20Sopenharmony_ci#define FM_FR_EVENT		BIT(0)
1638c2ecf20Sopenharmony_ci#define FM_BL_EVENT		BIT(1)
1648c2ecf20Sopenharmony_ci#define FM_RDS_EVENT		BIT(2)
1658c2ecf20Sopenharmony_ci#define FM_BBLK_EVENT		BIT(3)
1668c2ecf20Sopenharmony_ci#define FM_LSYNC_EVENT		BIT(4)
1678c2ecf20Sopenharmony_ci#define FM_LEV_EVENT		BIT(5)
1688c2ecf20Sopenharmony_ci#define FM_IFFR_EVENT		BIT(6)
1698c2ecf20Sopenharmony_ci#define FM_PI_EVENT		BIT(7)
1708c2ecf20Sopenharmony_ci#define FM_PD_EVENT		BIT(8)
1718c2ecf20Sopenharmony_ci#define FM_STIC_EVENT		BIT(9)
1728c2ecf20Sopenharmony_ci#define FM_MAL_EVENT		BIT(10)
1738c2ecf20Sopenharmony_ci#define FM_POW_ENB_EVENT	BIT(11)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/*
1768c2ecf20Sopenharmony_ci * Firmware files of FM. ASIC ID and ASIC version will be appened to this,
1778c2ecf20Sopenharmony_ci * later.
1788c2ecf20Sopenharmony_ci */
1798c2ecf20Sopenharmony_ci#define FM_FMC_FW_FILE_START      ("fmc_ch8")
1808c2ecf20Sopenharmony_ci#define FM_RX_FW_FILE_START       ("fm_rx_ch8")
1818c2ecf20Sopenharmony_ci#define FM_TX_FW_FILE_START       ("fm_tx_ch8")
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#define FM_UNDEFINED_FREQ		   0xFFFFFFFF
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* Band types */
1868c2ecf20Sopenharmony_ci#define FM_BAND_EUROPE_US	0
1878c2ecf20Sopenharmony_ci#define FM_BAND_JAPAN		1
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/* Seek directions */
1908c2ecf20Sopenharmony_ci#define FM_SEARCH_DIRECTION_DOWN	0
1918c2ecf20Sopenharmony_ci#define FM_SEARCH_DIRECTION_UP		1
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci/* Tunner modes */
1948c2ecf20Sopenharmony_ci#define FM_TUNER_STOP_SEARCH_MODE	0
1958c2ecf20Sopenharmony_ci#define FM_TUNER_PRESET_MODE		1
1968c2ecf20Sopenharmony_ci#define FM_TUNER_AUTONOMOUS_SEARCH_MODE	2
1978c2ecf20Sopenharmony_ci#define FM_TUNER_AF_JUMP_MODE		3
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* Min and Max volume */
2008c2ecf20Sopenharmony_ci#define FM_RX_VOLUME_MIN	0
2018c2ecf20Sopenharmony_ci#define FM_RX_VOLUME_MAX	70
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/* Volume gain step */
2048c2ecf20Sopenharmony_ci#define FM_RX_VOLUME_GAIN_STEP	0x370
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/* Mute modes */
2078c2ecf20Sopenharmony_ci#define	FM_MUTE_ON		0
2088c2ecf20Sopenharmony_ci#define FM_MUTE_OFF		1
2098c2ecf20Sopenharmony_ci#define	FM_MUTE_ATTENUATE	2
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#define FM_RX_UNMUTE_MODE		0x00
2128c2ecf20Sopenharmony_ci#define FM_RX_RF_DEP_MODE		0x01
2138c2ecf20Sopenharmony_ci#define FM_RX_AC_MUTE_MODE		0x02
2148c2ecf20Sopenharmony_ci#define FM_RX_HARD_MUTE_LEFT_MODE	0x04
2158c2ecf20Sopenharmony_ci#define FM_RX_HARD_MUTE_RIGHT_MODE	0x08
2168c2ecf20Sopenharmony_ci#define FM_RX_SOFT_MUTE_FORCE_MODE	0x10
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci/* RF dependent mute mode */
2198c2ecf20Sopenharmony_ci#define FM_RX_RF_DEPENDENT_MUTE_ON	1
2208c2ecf20Sopenharmony_ci#define FM_RX_RF_DEPENDENT_MUTE_OFF	0
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci/* RSSI threshold min and max */
2238c2ecf20Sopenharmony_ci#define FM_RX_RSSI_THRESHOLD_MIN	-128
2248c2ecf20Sopenharmony_ci#define FM_RX_RSSI_THRESHOLD_MAX	127
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/* Stereo/Mono mode */
2278c2ecf20Sopenharmony_ci#define FM_STEREO_MODE		0
2288c2ecf20Sopenharmony_ci#define FM_MONO_MODE		1
2298c2ecf20Sopenharmony_ci#define FM_STEREO_SOFT_BLEND	1
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/* FM RX De-emphasis filter modes */
2328c2ecf20Sopenharmony_ci#define FM_RX_EMPHASIS_FILTER_50_USEC	0
2338c2ecf20Sopenharmony_ci#define FM_RX_EMPHASIS_FILTER_75_USEC	1
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci/* FM RDS modes */
2368c2ecf20Sopenharmony_ci#define FM_RDS_DISABLE	0
2378c2ecf20Sopenharmony_ci#define FM_RDS_ENABLE	1
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#define FM_NO_PI_CODE	0
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* FM and RX RDS block enable/disable  */
2428c2ecf20Sopenharmony_ci#define FM_RX_PWR_SET_FM_ON_RDS_OFF		0x1
2438c2ecf20Sopenharmony_ci#define FM_RX_PWR_SET_FM_AND_RDS_BLK_ON		0x3
2448c2ecf20Sopenharmony_ci#define FM_RX_PWR_SET_FM_AND_RDS_BLK_OFF	0x0
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/* RX RDS */
2478c2ecf20Sopenharmony_ci#define FM_RX_RDS_FLUSH_FIFO		0x1
2488c2ecf20Sopenharmony_ci#define FM_RX_RDS_FIFO_THRESHOLD	64	/* tuples */
2498c2ecf20Sopenharmony_ci#define FM_RDS_BLK_SIZE		3	/* 3 bytes */
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci/* RDS block types */
2528c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_A		0
2538c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_B		1
2548c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_C		2
2558c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_Ctag	3
2568c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_D		4
2578c2ecf20Sopenharmony_ci#define FM_RDS_BLOCK_E		5
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci#define FM_RDS_BLK_IDX_A		0
2608c2ecf20Sopenharmony_ci#define FM_RDS_BLK_IDX_B		1
2618c2ecf20Sopenharmony_ci#define FM_RDS_BLK_IDX_C		2
2628c2ecf20Sopenharmony_ci#define FM_RDS_BLK_IDX_D		3
2638c2ecf20Sopenharmony_ci#define FM_RDS_BLK_IDX_UNKNOWN	0xF0
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci#define FM_RDS_STATUS_ERR_MASK	0x18
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/*
2688c2ecf20Sopenharmony_ci * Represents an RDS group type & version.
2698c2ecf20Sopenharmony_ci * There are 15 groups, each group has 2 versions: A and B.
2708c2ecf20Sopenharmony_ci */
2718c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_0A	    BIT(0)
2728c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_0B	    BIT(1)
2738c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_1A	    BIT(2)
2748c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_1B	    BIT(3)
2758c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_2A	    BIT(4)
2768c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_2B	    BIT(5)
2778c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_3A	    BIT(6)
2788c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_3B	    BIT(7)
2798c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_4A	    BIT(8)
2808c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_4B	    BIT(9)
2818c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_5A	    BIT(10)
2828c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_5B	    BIT(11)
2838c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_6A	    BIT(12)
2848c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_6B	    BIT(13)
2858c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_7A	    BIT(14)
2868c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_7B	    BIT(15)
2878c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_8A	    BIT(16)
2888c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_8B	    BIT(17)
2898c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_9A	    BIT(18)
2908c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_9B	    BIT(19)
2918c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_10A	    BIT(20)
2928c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_10B	    BIT(21)
2938c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_11A	    BIT(22)
2948c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_11B	    BIT(23)
2958c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_12A	    BIT(24)
2968c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_12B	    BIT(25)
2978c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_13A	    BIT(26)
2988c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_13B	    BIT(27)
2998c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_14A	    BIT(28)
3008c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_14B	    BIT(29)
3018c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_15A	    BIT(30)
3028c2ecf20Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_15B	    BIT(31)
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* RX Alternate Frequency info */
3058c2ecf20Sopenharmony_ci#define FM_RDS_MIN_AF			  1
3068c2ecf20Sopenharmony_ci#define FM_RDS_MAX_AF			204
3078c2ecf20Sopenharmony_ci#define FM_RDS_MAX_AF_JAPAN		140
3088c2ecf20Sopenharmony_ci#define FM_RDS_1_AF_FOLLOWS		225
3098c2ecf20Sopenharmony_ci#define FM_RDS_25_AF_FOLLOWS		249
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/* RDS system type (RDS/RBDS) */
3128c2ecf20Sopenharmony_ci#define FM_RDS_SYSTEM_RDS		0
3138c2ecf20Sopenharmony_ci#define FM_RDS_SYSTEM_RBDS		1
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci/* AF on/off */
3168c2ecf20Sopenharmony_ci#define FM_RX_RDS_AF_SWITCH_MODE_ON	1
3178c2ecf20Sopenharmony_ci#define FM_RX_RDS_AF_SWITCH_MODE_OFF	0
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci/* Retry count when interrupt process goes wrong */
3208c2ecf20Sopenharmony_ci#define FM_IRQ_TIMEOUT_RETRY_MAX	5	/* 5 times */
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/* Audio IO set values */
3238c2ecf20Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_I2S	0x01
3248c2ecf20Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_ANALOG	0x02
3258c2ecf20Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG	0x03
3268c2ecf20Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_DISABLE	0x00
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/* HI/LO set values */
3298c2ecf20Sopenharmony_ci#define FM_RX_IFFREQ_TO_HI_SIDE		0x0
3308c2ecf20Sopenharmony_ci#define FM_RX_IFFREQ_TO_LO_SIDE		0x1
3318c2ecf20Sopenharmony_ci#define FM_RX_IFFREQ_HILO_AUTOMATIC	0x2
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/*
3348c2ecf20Sopenharmony_ci * Default RX mode configuration. Chip will be configured
3358c2ecf20Sopenharmony_ci * with this default values after loading RX firmware.
3368c2ecf20Sopenharmony_ci */
3378c2ecf20Sopenharmony_ci#define FM_DEFAULT_RX_VOLUME		10
3388c2ecf20Sopenharmony_ci#define FM_DEFAULT_RSSI_THRESHOLD	3
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci/* Range for TX power level in units for dB/uV */
3418c2ecf20Sopenharmony_ci#define FM_PWR_LVL_LOW			91
3428c2ecf20Sopenharmony_ci#define FM_PWR_LVL_HIGH			122
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci/* Chip specific default TX power level value */
3458c2ecf20Sopenharmony_ci#define FM_PWR_LVL_DEF			4
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci/* FM TX Pre-emphasis filter values */
3488c2ecf20Sopenharmony_ci#define FM_TX_PREEMPH_OFF		1
3498c2ecf20Sopenharmony_ci#define FM_TX_PREEMPH_50US		0
3508c2ecf20Sopenharmony_ci#define FM_TX_PREEMPH_75US		2
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci/* FM TX antenna impedance values */
3538c2ecf20Sopenharmony_ci#define FM_TX_ANT_IMP_50		0
3548c2ecf20Sopenharmony_ci#define FM_TX_ANT_IMP_200		1
3558c2ecf20Sopenharmony_ci#define FM_TX_ANT_IMP_500		2
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/* Functions exported by FM common sub-module */
3588c2ecf20Sopenharmony_ciint fmc_prepare(struct fmdev *);
3598c2ecf20Sopenharmony_ciint fmc_release(struct fmdev *);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_civoid fmc_update_region_info(struct fmdev *, u8);
3628c2ecf20Sopenharmony_ciint fmc_send_cmd(struct fmdev *, u8, u16,
3638c2ecf20Sopenharmony_ci				void *, unsigned int, void *, int *);
3648c2ecf20Sopenharmony_ciint fmc_is_rds_data_available(struct fmdev *, struct file *,
3658c2ecf20Sopenharmony_ci				struct poll_table_struct *);
3668c2ecf20Sopenharmony_ciint fmc_transfer_rds_from_internal_buff(struct fmdev *, struct file *,
3678c2ecf20Sopenharmony_ci					u8 __user *, size_t);
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ciint fmc_set_freq(struct fmdev *, u32);
3708c2ecf20Sopenharmony_ciint fmc_set_mode(struct fmdev *, u8);
3718c2ecf20Sopenharmony_ciint fmc_set_region(struct fmdev *, u8);
3728c2ecf20Sopenharmony_ciint fmc_set_mute_mode(struct fmdev *, u8);
3738c2ecf20Sopenharmony_ciint fmc_set_stereo_mono(struct fmdev *, u16);
3748c2ecf20Sopenharmony_ciint fmc_set_rds_mode(struct fmdev *, u8);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ciint fmc_get_freq(struct fmdev *, u32 *);
3778c2ecf20Sopenharmony_ciint fmc_get_region(struct fmdev *, u8 *);
3788c2ecf20Sopenharmony_ciint fmc_get_mode(struct fmdev *, u8 *);
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci/*
3818c2ecf20Sopenharmony_ci * channel spacing
3828c2ecf20Sopenharmony_ci */
3838c2ecf20Sopenharmony_ci#define FM_CHANNEL_SPACING_50KHZ 1
3848c2ecf20Sopenharmony_ci#define FM_CHANNEL_SPACING_100KHZ 2
3858c2ecf20Sopenharmony_ci#define FM_CHANNEL_SPACING_200KHZ 4
3868c2ecf20Sopenharmony_ci#define FM_FREQ_MUL 50
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#endif
3898c2ecf20Sopenharmony_ci
390