162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  FM Driver for Connectivity chip of Texas Instruments.
462306a36Sopenharmony_ci *  FM Common module header file
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci *  Copyright (C) 2011 Texas Instruments
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef _FMDRV_COMMON_H
1062306a36Sopenharmony_ci#define _FMDRV_COMMON_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#define FM_ST_REG_TIMEOUT   msecs_to_jiffies(6000)	/* 6 sec */
1362306a36Sopenharmony_ci#define FM_PKT_LOGICAL_CHAN_NUMBER  0x08   /* Logical channel 8 */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define REG_RD       0x1
1662306a36Sopenharmony_ci#define REG_WR      0x0
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistruct fm_reg_table {
1962306a36Sopenharmony_ci	u8 opcode;
2062306a36Sopenharmony_ci	u8 type;
2162306a36Sopenharmony_ci	u8 *name;
2262306a36Sopenharmony_ci};
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define STEREO_GET               0
2562306a36Sopenharmony_ci#define RSSI_LVL_GET             1
2662306a36Sopenharmony_ci#define IF_COUNT_GET             2
2762306a36Sopenharmony_ci#define FLAG_GET                 3
2862306a36Sopenharmony_ci#define RDS_SYNC_GET             4
2962306a36Sopenharmony_ci#define RDS_DATA_GET             5
3062306a36Sopenharmony_ci#define FREQ_SET                 10
3162306a36Sopenharmony_ci#define AF_FREQ_SET              11
3262306a36Sopenharmony_ci#define MOST_MODE_SET            12
3362306a36Sopenharmony_ci#define MOST_BLEND_SET           13
3462306a36Sopenharmony_ci#define DEMPH_MODE_SET           14
3562306a36Sopenharmony_ci#define SEARCH_LVL_SET           15
3662306a36Sopenharmony_ci#define BAND_SET                 16
3762306a36Sopenharmony_ci#define MUTE_STATUS_SET          17
3862306a36Sopenharmony_ci#define RDS_PAUSE_LVL_SET        18
3962306a36Sopenharmony_ci#define RDS_PAUSE_DUR_SET        19
4062306a36Sopenharmony_ci#define RDS_MEM_SET              20
4162306a36Sopenharmony_ci#define RDS_BLK_B_SET            21
4262306a36Sopenharmony_ci#define RDS_MSK_B_SET            22
4362306a36Sopenharmony_ci#define RDS_PI_MASK_SET          23
4462306a36Sopenharmony_ci#define RDS_PI_SET               24
4562306a36Sopenharmony_ci#define RDS_SYSTEM_SET           25
4662306a36Sopenharmony_ci#define INT_MASK_SET             26
4762306a36Sopenharmony_ci#define SEARCH_DIR_SET           27
4862306a36Sopenharmony_ci#define VOLUME_SET               28
4962306a36Sopenharmony_ci#define AUDIO_ENABLE_SET         29
5062306a36Sopenharmony_ci#define PCM_MODE_SET             30
5162306a36Sopenharmony_ci#define I2S_MODE_CONFIG_SET      31
5262306a36Sopenharmony_ci#define POWER_SET                32
5362306a36Sopenharmony_ci#define INTX_CONFIG_SET          33
5462306a36Sopenharmony_ci#define PULL_EN_SET              34
5562306a36Sopenharmony_ci#define HILO_SET                 35
5662306a36Sopenharmony_ci#define SWITCH2FREF              36
5762306a36Sopenharmony_ci#define FREQ_DRIFT_REPORT        37
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define PCE_GET                  40
6062306a36Sopenharmony_ci#define FIRM_VER_GET             41
6162306a36Sopenharmony_ci#define ASIC_VER_GET             42
6262306a36Sopenharmony_ci#define ASIC_ID_GET              43
6362306a36Sopenharmony_ci#define MAN_ID_GET               44
6462306a36Sopenharmony_ci#define TUNER_MODE_SET           45
6562306a36Sopenharmony_ci#define STOP_SEARCH              46
6662306a36Sopenharmony_ci#define RDS_CNTRL_SET            47
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define WRITE_HARDWARE_REG       100
6962306a36Sopenharmony_ci#define CODE_DOWNLOAD            101
7062306a36Sopenharmony_ci#define RESET                    102
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define FM_POWER_MODE            254
7362306a36Sopenharmony_ci#define FM_INTERRUPT             255
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/* Transmitter API */
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#define CHANL_SET                55
7862306a36Sopenharmony_ci#define CHANL_BW_SET		56
7962306a36Sopenharmony_ci#define REF_SET                  57
8062306a36Sopenharmony_ci#define POWER_ENB_SET            90
8162306a36Sopenharmony_ci#define POWER_ATT_SET            58
8262306a36Sopenharmony_ci#define POWER_LEV_SET            59
8362306a36Sopenharmony_ci#define AUDIO_DEV_SET            60
8462306a36Sopenharmony_ci#define PILOT_DEV_SET            61
8562306a36Sopenharmony_ci#define RDS_DEV_SET              62
8662306a36Sopenharmony_ci#define TX_BAND_SET              65
8762306a36Sopenharmony_ci#define PUPD_SET                 91
8862306a36Sopenharmony_ci#define AUDIO_IO_SET             63
8962306a36Sopenharmony_ci#define PREMPH_SET               64
9062306a36Sopenharmony_ci#define MONO_SET                 66
9162306a36Sopenharmony_ci#define MUTE                     92
9262306a36Sopenharmony_ci#define MPX_LMT_ENABLE           67
9362306a36Sopenharmony_ci#define PI_SET                   93
9462306a36Sopenharmony_ci#define ECC_SET                  69
9562306a36Sopenharmony_ci#define PTY                      70
9662306a36Sopenharmony_ci#define AF                       71
9762306a36Sopenharmony_ci#define DISPLAY_MODE             74
9862306a36Sopenharmony_ci#define RDS_REP_SET              77
9962306a36Sopenharmony_ci#define RDS_CONFIG_DATA_SET      98
10062306a36Sopenharmony_ci#define RDS_DATA_SET             99
10162306a36Sopenharmony_ci#define RDS_DATA_ENB             94
10262306a36Sopenharmony_ci#define TA_SET                   78
10362306a36Sopenharmony_ci#define TP_SET                   79
10462306a36Sopenharmony_ci#define DI_SET                   80
10562306a36Sopenharmony_ci#define MS_SET                   81
10662306a36Sopenharmony_ci#define PS_SCROLL_SPEED          82
10762306a36Sopenharmony_ci#define TX_AUDIO_LEVEL_TEST      96
10862306a36Sopenharmony_ci#define TX_AUDIO_LEVEL_TEST_THRESHOLD    73
10962306a36Sopenharmony_ci#define TX_AUDIO_INPUT_LEVEL_RANGE_SET   54
11062306a36Sopenharmony_ci#define RX_ANTENNA_SELECT        87
11162306a36Sopenharmony_ci#define I2C_DEV_ADDR_SET         86
11262306a36Sopenharmony_ci#define REF_ERR_CALIB_PARAM_SET          88
11362306a36Sopenharmony_ci#define REF_ERR_CALIB_PERIODICITY_SET    89
11462306a36Sopenharmony_ci#define SOC_INT_TRIGGER                  52
11562306a36Sopenharmony_ci#define SOC_AUDIO_PATH_SET               83
11662306a36Sopenharmony_ci#define SOC_PCMI_OVERRIDE                84
11762306a36Sopenharmony_ci#define SOC_I2S_OVERRIDE         85
11862306a36Sopenharmony_ci#define RSSI_BLOCK_SCAN_FREQ_SET 95
11962306a36Sopenharmony_ci#define RSSI_BLOCK_SCAN_START    97
12062306a36Sopenharmony_ci#define RSSI_BLOCK_SCAN_DATA_GET  5
12162306a36Sopenharmony_ci#define READ_FMANT_TUNE_VALUE            104
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/* SKB helpers */
12462306a36Sopenharmony_cistruct fm_skb_cb {
12562306a36Sopenharmony_ci	__u8 fm_op;
12662306a36Sopenharmony_ci	struct completion *completion;
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#define fm_cb(skb) ((struct fm_skb_cb *)(skb->cb))
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci/* FM Channel-8 command message format */
13262306a36Sopenharmony_cistruct fm_cmd_msg_hdr {
13362306a36Sopenharmony_ci	__u8 hdr;		/* Logical Channel-8 */
13462306a36Sopenharmony_ci	__u8 len;		/* Number of bytes follows */
13562306a36Sopenharmony_ci	__u8 op;		/* FM Opcode */
13662306a36Sopenharmony_ci	__u8 rd_wr;		/* Read/Write command */
13762306a36Sopenharmony_ci	__u8 dlen;		/* Length of payload */
13862306a36Sopenharmony_ci} __attribute__ ((packed));
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci#define FM_CMD_MSG_HDR_SIZE    5	/* sizeof(struct fm_cmd_msg_hdr) */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci/* FM Channel-8 event messgage format */
14362306a36Sopenharmony_cistruct fm_event_msg_hdr {
14462306a36Sopenharmony_ci	__u8 header;		/* Logical Channel-8 */
14562306a36Sopenharmony_ci	__u8 len;		/* Number of bytes follows */
14662306a36Sopenharmony_ci	__u8 status;		/* Event status */
14762306a36Sopenharmony_ci	__u8 num_fm_hci_cmds;	/* Number of pkts the host allowed to send */
14862306a36Sopenharmony_ci	__u8 op;		/* FM Opcode */
14962306a36Sopenharmony_ci	__u8 rd_wr;		/* Read/Write command */
15062306a36Sopenharmony_ci	__u8 dlen;		/* Length of payload */
15162306a36Sopenharmony_ci} __attribute__ ((packed));
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci#define FM_EVT_MSG_HDR_SIZE     7	/* sizeof(struct fm_event_msg_hdr) */
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci/* TI's magic number in firmware file */
15662306a36Sopenharmony_ci#define FM_FW_FILE_HEADER_MAGIC	     0x42535442
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define FM_ENABLE   1
15962306a36Sopenharmony_ci#define FM_DISABLE  0
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci/* FLAG_GET register bits */
16262306a36Sopenharmony_ci#define FM_FR_EVENT		BIT(0)
16362306a36Sopenharmony_ci#define FM_BL_EVENT		BIT(1)
16462306a36Sopenharmony_ci#define FM_RDS_EVENT		BIT(2)
16562306a36Sopenharmony_ci#define FM_BBLK_EVENT		BIT(3)
16662306a36Sopenharmony_ci#define FM_LSYNC_EVENT		BIT(4)
16762306a36Sopenharmony_ci#define FM_LEV_EVENT		BIT(5)
16862306a36Sopenharmony_ci#define FM_IFFR_EVENT		BIT(6)
16962306a36Sopenharmony_ci#define FM_PI_EVENT		BIT(7)
17062306a36Sopenharmony_ci#define FM_PD_EVENT		BIT(8)
17162306a36Sopenharmony_ci#define FM_STIC_EVENT		BIT(9)
17262306a36Sopenharmony_ci#define FM_MAL_EVENT		BIT(10)
17362306a36Sopenharmony_ci#define FM_POW_ENB_EVENT	BIT(11)
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci/*
17662306a36Sopenharmony_ci * Firmware files of FM. ASIC ID and ASIC version will be appened to this,
17762306a36Sopenharmony_ci * later.
17862306a36Sopenharmony_ci */
17962306a36Sopenharmony_ci#define FM_FMC_FW_FILE_START      ("fmc_ch8")
18062306a36Sopenharmony_ci#define FM_RX_FW_FILE_START       ("fm_rx_ch8")
18162306a36Sopenharmony_ci#define FM_TX_FW_FILE_START       ("fm_tx_ch8")
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define FM_UNDEFINED_FREQ		   0xFFFFFFFF
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci/* Band types */
18662306a36Sopenharmony_ci#define FM_BAND_EUROPE_US	0
18762306a36Sopenharmony_ci#define FM_BAND_JAPAN		1
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci/* Seek directions */
19062306a36Sopenharmony_ci#define FM_SEARCH_DIRECTION_DOWN	0
19162306a36Sopenharmony_ci#define FM_SEARCH_DIRECTION_UP		1
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/* Tunner modes */
19462306a36Sopenharmony_ci#define FM_TUNER_STOP_SEARCH_MODE	0
19562306a36Sopenharmony_ci#define FM_TUNER_PRESET_MODE		1
19662306a36Sopenharmony_ci#define FM_TUNER_AUTONOMOUS_SEARCH_MODE	2
19762306a36Sopenharmony_ci#define FM_TUNER_AF_JUMP_MODE		3
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* Min and Max volume */
20062306a36Sopenharmony_ci#define FM_RX_VOLUME_MIN	0
20162306a36Sopenharmony_ci#define FM_RX_VOLUME_MAX	70
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci/* Volume gain step */
20462306a36Sopenharmony_ci#define FM_RX_VOLUME_GAIN_STEP	0x370
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci/* Mute modes */
20762306a36Sopenharmony_ci#define	FM_MUTE_ON		0
20862306a36Sopenharmony_ci#define FM_MUTE_OFF		1
20962306a36Sopenharmony_ci#define	FM_MUTE_ATTENUATE	2
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci#define FM_RX_UNMUTE_MODE		0x00
21262306a36Sopenharmony_ci#define FM_RX_RF_DEP_MODE		0x01
21362306a36Sopenharmony_ci#define FM_RX_AC_MUTE_MODE		0x02
21462306a36Sopenharmony_ci#define FM_RX_HARD_MUTE_LEFT_MODE	0x04
21562306a36Sopenharmony_ci#define FM_RX_HARD_MUTE_RIGHT_MODE	0x08
21662306a36Sopenharmony_ci#define FM_RX_SOFT_MUTE_FORCE_MODE	0x10
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci/* RF dependent mute mode */
21962306a36Sopenharmony_ci#define FM_RX_RF_DEPENDENT_MUTE_ON	1
22062306a36Sopenharmony_ci#define FM_RX_RF_DEPENDENT_MUTE_OFF	0
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci/* RSSI threshold min and max */
22362306a36Sopenharmony_ci#define FM_RX_RSSI_THRESHOLD_MIN	-128
22462306a36Sopenharmony_ci#define FM_RX_RSSI_THRESHOLD_MAX	127
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci/* Stereo/Mono mode */
22762306a36Sopenharmony_ci#define FM_STEREO_MODE		0
22862306a36Sopenharmony_ci#define FM_MONO_MODE		1
22962306a36Sopenharmony_ci#define FM_STEREO_SOFT_BLEND	1
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci/* FM RX De-emphasis filter modes */
23262306a36Sopenharmony_ci#define FM_RX_EMPHASIS_FILTER_50_USEC	0
23362306a36Sopenharmony_ci#define FM_RX_EMPHASIS_FILTER_75_USEC	1
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci/* FM RDS modes */
23662306a36Sopenharmony_ci#define FM_RDS_DISABLE	0
23762306a36Sopenharmony_ci#define FM_RDS_ENABLE	1
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci#define FM_NO_PI_CODE	0
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci/* FM and RX RDS block enable/disable  */
24262306a36Sopenharmony_ci#define FM_RX_PWR_SET_FM_ON_RDS_OFF		0x1
24362306a36Sopenharmony_ci#define FM_RX_PWR_SET_FM_AND_RDS_BLK_ON		0x3
24462306a36Sopenharmony_ci#define FM_RX_PWR_SET_FM_AND_RDS_BLK_OFF	0x0
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci/* RX RDS */
24762306a36Sopenharmony_ci#define FM_RX_RDS_FLUSH_FIFO		0x1
24862306a36Sopenharmony_ci#define FM_RX_RDS_FIFO_THRESHOLD	64	/* tuples */
24962306a36Sopenharmony_ci#define FM_RDS_BLK_SIZE		3	/* 3 bytes */
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci/* RDS block types */
25262306a36Sopenharmony_ci#define FM_RDS_BLOCK_A		0
25362306a36Sopenharmony_ci#define FM_RDS_BLOCK_B		1
25462306a36Sopenharmony_ci#define FM_RDS_BLOCK_C		2
25562306a36Sopenharmony_ci#define FM_RDS_BLOCK_Ctag	3
25662306a36Sopenharmony_ci#define FM_RDS_BLOCK_D		4
25762306a36Sopenharmony_ci#define FM_RDS_BLOCK_E		5
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci#define FM_RDS_BLK_IDX_A		0
26062306a36Sopenharmony_ci#define FM_RDS_BLK_IDX_B		1
26162306a36Sopenharmony_ci#define FM_RDS_BLK_IDX_C		2
26262306a36Sopenharmony_ci#define FM_RDS_BLK_IDX_D		3
26362306a36Sopenharmony_ci#define FM_RDS_BLK_IDX_UNKNOWN	0xF0
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci#define FM_RDS_STATUS_ERR_MASK	0x18
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci/*
26862306a36Sopenharmony_ci * Represents an RDS group type & version.
26962306a36Sopenharmony_ci * There are 15 groups, each group has 2 versions: A and B.
27062306a36Sopenharmony_ci */
27162306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_0A	    BIT(0)
27262306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_0B	    BIT(1)
27362306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_1A	    BIT(2)
27462306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_1B	    BIT(3)
27562306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_2A	    BIT(4)
27662306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_2B	    BIT(5)
27762306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_3A	    BIT(6)
27862306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_3B	    BIT(7)
27962306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_4A	    BIT(8)
28062306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_4B	    BIT(9)
28162306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_5A	    BIT(10)
28262306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_5B	    BIT(11)
28362306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_6A	    BIT(12)
28462306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_6B	    BIT(13)
28562306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_7A	    BIT(14)
28662306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_7B	    BIT(15)
28762306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_8A	    BIT(16)
28862306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_8B	    BIT(17)
28962306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_9A	    BIT(18)
29062306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_9B	    BIT(19)
29162306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_10A	    BIT(20)
29262306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_10B	    BIT(21)
29362306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_11A	    BIT(22)
29462306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_11B	    BIT(23)
29562306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_12A	    BIT(24)
29662306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_12B	    BIT(25)
29762306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_13A	    BIT(26)
29862306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_13B	    BIT(27)
29962306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_14A	    BIT(28)
30062306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_14B	    BIT(29)
30162306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_15A	    BIT(30)
30262306a36Sopenharmony_ci#define FM_RDS_GROUP_TYPE_MASK_15B	    BIT(31)
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci/* RX Alternate Frequency info */
30562306a36Sopenharmony_ci#define FM_RDS_MIN_AF			  1
30662306a36Sopenharmony_ci#define FM_RDS_MAX_AF			204
30762306a36Sopenharmony_ci#define FM_RDS_MAX_AF_JAPAN		140
30862306a36Sopenharmony_ci#define FM_RDS_1_AF_FOLLOWS		225
30962306a36Sopenharmony_ci#define FM_RDS_25_AF_FOLLOWS		249
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci/* RDS system type (RDS/RBDS) */
31262306a36Sopenharmony_ci#define FM_RDS_SYSTEM_RDS		0
31362306a36Sopenharmony_ci#define FM_RDS_SYSTEM_RBDS		1
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ci/* AF on/off */
31662306a36Sopenharmony_ci#define FM_RX_RDS_AF_SWITCH_MODE_ON	1
31762306a36Sopenharmony_ci#define FM_RX_RDS_AF_SWITCH_MODE_OFF	0
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci/* Retry count when interrupt process goes wrong */
32062306a36Sopenharmony_ci#define FM_IRQ_TIMEOUT_RETRY_MAX	5	/* 5 times */
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci/* Audio IO set values */
32362306a36Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_I2S	0x01
32462306a36Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_ANALOG	0x02
32562306a36Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG	0x03
32662306a36Sopenharmony_ci#define FM_RX_AUDIO_ENABLE_DISABLE	0x00
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/* HI/LO set values */
32962306a36Sopenharmony_ci#define FM_RX_IFFREQ_TO_HI_SIDE		0x0
33062306a36Sopenharmony_ci#define FM_RX_IFFREQ_TO_LO_SIDE		0x1
33162306a36Sopenharmony_ci#define FM_RX_IFFREQ_HILO_AUTOMATIC	0x2
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci/*
33462306a36Sopenharmony_ci * Default RX mode configuration. Chip will be configured
33562306a36Sopenharmony_ci * with this default values after loading RX firmware.
33662306a36Sopenharmony_ci */
33762306a36Sopenharmony_ci#define FM_DEFAULT_RX_VOLUME		10
33862306a36Sopenharmony_ci#define FM_DEFAULT_RSSI_THRESHOLD	3
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ci/* Range for TX power level in units for dB/uV */
34162306a36Sopenharmony_ci#define FM_PWR_LVL_LOW			91
34262306a36Sopenharmony_ci#define FM_PWR_LVL_HIGH			122
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci/* Chip specific default TX power level value */
34562306a36Sopenharmony_ci#define FM_PWR_LVL_DEF			4
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_ci/* FM TX Pre-emphasis filter values */
34862306a36Sopenharmony_ci#define FM_TX_PREEMPH_OFF		1
34962306a36Sopenharmony_ci#define FM_TX_PREEMPH_50US		0
35062306a36Sopenharmony_ci#define FM_TX_PREEMPH_75US		2
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci/* FM TX antenna impedance values */
35362306a36Sopenharmony_ci#define FM_TX_ANT_IMP_50		0
35462306a36Sopenharmony_ci#define FM_TX_ANT_IMP_200		1
35562306a36Sopenharmony_ci#define FM_TX_ANT_IMP_500		2
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci/* Functions exported by FM common sub-module */
35862306a36Sopenharmony_ciint fmc_prepare(struct fmdev *);
35962306a36Sopenharmony_ciint fmc_release(struct fmdev *);
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_civoid fmc_update_region_info(struct fmdev *, u8);
36262306a36Sopenharmony_ciint fmc_send_cmd(struct fmdev *, u8, u16,
36362306a36Sopenharmony_ci				void *, unsigned int, void *, int *);
36462306a36Sopenharmony_ciint fmc_is_rds_data_available(struct fmdev *, struct file *,
36562306a36Sopenharmony_ci				struct poll_table_struct *);
36662306a36Sopenharmony_ciint fmc_transfer_rds_from_internal_buff(struct fmdev *, struct file *,
36762306a36Sopenharmony_ci					u8 __user *, size_t);
36862306a36Sopenharmony_ci
36962306a36Sopenharmony_ciint fmc_set_freq(struct fmdev *, u32);
37062306a36Sopenharmony_ciint fmc_set_mode(struct fmdev *, u8);
37162306a36Sopenharmony_ciint fmc_set_region(struct fmdev *, u8);
37262306a36Sopenharmony_ciint fmc_set_mute_mode(struct fmdev *, u8);
37362306a36Sopenharmony_ciint fmc_set_stereo_mono(struct fmdev *, u16);
37462306a36Sopenharmony_ciint fmc_set_rds_mode(struct fmdev *, u8);
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ciint fmc_get_freq(struct fmdev *, u32 *);
37762306a36Sopenharmony_ciint fmc_get_region(struct fmdev *, u8 *);
37862306a36Sopenharmony_ciint fmc_get_mode(struct fmdev *, u8 *);
37962306a36Sopenharmony_ci
38062306a36Sopenharmony_ci/*
38162306a36Sopenharmony_ci * channel spacing
38262306a36Sopenharmony_ci */
38362306a36Sopenharmony_ci#define FM_CHANNEL_SPACING_50KHZ 1
38462306a36Sopenharmony_ci#define FM_CHANNEL_SPACING_100KHZ 2
38562306a36Sopenharmony_ci#define FM_CHANNEL_SPACING_200KHZ 4
38662306a36Sopenharmony_ci#define FM_FREQ_MUL 50
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci#endif
38962306a36Sopenharmony_ci
390