0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef WL1273_CORE_H
0012 #define WL1273_CORE_H
0013
0014 #include <linux/i2c.h>
0015 #include <linux/mfd/core.h>
0016
0017 #define WL1273_FM_DRIVER_NAME "wl1273-fm"
0018 #define RX71_FM_I2C_ADDR 0x22
0019
0020 #define WL1273_STEREO_GET 0
0021 #define WL1273_RSSI_LVL_GET 1
0022 #define WL1273_IF_COUNT_GET 2
0023 #define WL1273_FLAG_GET 3
0024 #define WL1273_RDS_SYNC_GET 4
0025 #define WL1273_RDS_DATA_GET 5
0026 #define WL1273_FREQ_SET 10
0027 #define WL1273_AF_FREQ_SET 11
0028 #define WL1273_MOST_MODE_SET 12
0029 #define WL1273_MOST_BLEND_SET 13
0030 #define WL1273_DEMPH_MODE_SET 14
0031 #define WL1273_SEARCH_LVL_SET 15
0032 #define WL1273_BAND_SET 16
0033 #define WL1273_MUTE_STATUS_SET 17
0034 #define WL1273_RDS_PAUSE_LVL_SET 18
0035 #define WL1273_RDS_PAUSE_DUR_SET 19
0036 #define WL1273_RDS_MEM_SET 20
0037 #define WL1273_RDS_BLK_B_SET 21
0038 #define WL1273_RDS_MSK_B_SET 22
0039 #define WL1273_RDS_PI_MASK_SET 23
0040 #define WL1273_RDS_PI_SET 24
0041 #define WL1273_RDS_SYSTEM_SET 25
0042 #define WL1273_INT_MASK_SET 26
0043 #define WL1273_SEARCH_DIR_SET 27
0044 #define WL1273_VOLUME_SET 28
0045 #define WL1273_AUDIO_ENABLE 29
0046 #define WL1273_PCM_MODE_SET 30
0047 #define WL1273_I2S_MODE_CONFIG_SET 31
0048 #define WL1273_POWER_SET 32
0049 #define WL1273_INTX_CONFIG_SET 33
0050 #define WL1273_PULL_EN_SET 34
0051 #define WL1273_HILO_SET 35
0052 #define WL1273_SWITCH2FREF 36
0053 #define WL1273_FREQ_DRIFT_REPORT 37
0054
0055 #define WL1273_PCE_GET 40
0056 #define WL1273_FIRM_VER_GET 41
0057 #define WL1273_ASIC_VER_GET 42
0058 #define WL1273_ASIC_ID_GET 43
0059 #define WL1273_MAN_ID_GET 44
0060 #define WL1273_TUNER_MODE_SET 45
0061 #define WL1273_STOP_SEARCH 46
0062 #define WL1273_RDS_CNTRL_SET 47
0063
0064 #define WL1273_WRITE_HARDWARE_REG 100
0065 #define WL1273_CODE_DOWNLOAD 101
0066 #define WL1273_RESET 102
0067
0068 #define WL1273_FM_POWER_MODE 254
0069 #define WL1273_FM_INTERRUPT 255
0070
0071
0072
0073 #define WL1273_CHANL_SET 55
0074 #define WL1273_SCAN_SPACING_SET 56
0075 #define WL1273_REF_SET 57
0076 #define WL1273_POWER_ENB_SET 90
0077 #define WL1273_POWER_ATT_SET 58
0078 #define WL1273_POWER_LEV_SET 59
0079 #define WL1273_AUDIO_DEV_SET 60
0080 #define WL1273_PILOT_DEV_SET 61
0081 #define WL1273_RDS_DEV_SET 62
0082 #define WL1273_PUPD_SET 91
0083 #define WL1273_AUDIO_IO_SET 63
0084 #define WL1273_PREMPH_SET 64
0085 #define WL1273_MONO_SET 66
0086 #define WL1273_MUTE 92
0087 #define WL1273_MPX_LMT_ENABLE 67
0088 #define WL1273_PI_SET 93
0089 #define WL1273_ECC_SET 69
0090 #define WL1273_PTY 70
0091 #define WL1273_AF 71
0092 #define WL1273_DISPLAY_MODE 74
0093 #define WL1273_RDS_REP_SET 77
0094 #define WL1273_RDS_CONFIG_DATA_SET 98
0095 #define WL1273_RDS_DATA_SET 99
0096 #define WL1273_RDS_DATA_ENB 94
0097 #define WL1273_TA_SET 78
0098 #define WL1273_TP_SET 79
0099 #define WL1273_DI_SET 80
0100 #define WL1273_MS_SET 81
0101 #define WL1273_PS_SCROLL_SPEED 82
0102 #define WL1273_TX_AUDIO_LEVEL_TEST 96
0103 #define WL1273_TX_AUDIO_LEVEL_TEST_THRESHOLD 73
0104 #define WL1273_TX_AUDIO_INPUT_LEVEL_RANGE_SET 54
0105 #define WL1273_RX_ANTENNA_SELECT 87
0106 #define WL1273_I2C_DEV_ADDR_SET 86
0107 #define WL1273_REF_ERR_CALIB_PARAM_SET 88
0108 #define WL1273_REF_ERR_CALIB_PERIODICITY_SET 89
0109 #define WL1273_SOC_INT_TRIGGER 52
0110 #define WL1273_SOC_AUDIO_PATH_SET 83
0111 #define WL1273_SOC_PCMI_OVERRIDE 84
0112 #define WL1273_SOC_I2S_OVERRIDE 85
0113 #define WL1273_RSSI_BLOCK_SCAN_FREQ_SET 95
0114 #define WL1273_RSSI_BLOCK_SCAN_START 97
0115 #define WL1273_RSSI_BLOCK_SCAN_DATA_GET 5
0116 #define WL1273_READ_FMANT_TUNE_VALUE 104
0117
0118 #define WL1273_RDS_OFF 0
0119 #define WL1273_RDS_ON 1
0120 #define WL1273_RDS_RESET 2
0121
0122 #define WL1273_AUDIO_DIGITAL 0
0123 #define WL1273_AUDIO_ANALOG 1
0124
0125 #define WL1273_MODE_RX BIT(0)
0126 #define WL1273_MODE_TX BIT(1)
0127 #define WL1273_MODE_OFF BIT(2)
0128 #define WL1273_MODE_SUSPENDED BIT(3)
0129
0130 #define WL1273_RADIO_CHILD BIT(0)
0131 #define WL1273_CODEC_CHILD BIT(1)
0132
0133 #define WL1273_RX_MONO 1
0134 #define WL1273_RX_STEREO 0
0135 #define WL1273_TX_MONO 0
0136 #define WL1273_TX_STEREO 1
0137
0138 #define WL1273_MAX_VOLUME 0xffff
0139 #define WL1273_DEFAULT_VOLUME 0x78b8
0140
0141
0142 #define WL1273_PCM_DEF_MODE 0x00
0143
0144
0145 #define WL1273_AUDIO_ENABLE_I2S BIT(0)
0146 #define WL1273_AUDIO_ENABLE_ANALOG BIT(1)
0147
0148
0149 #define WL1273_AUDIO_IO_SET_ANALOG 0
0150 #define WL1273_AUDIO_IO_SET_I2S 1
0151
0152 #define WL1273_PUPD_SET_OFF 0x00
0153 #define WL1273_PUPD_SET_ON 0x01
0154 #define WL1273_PUPD_SET_RETENTION 0x10
0155
0156
0157 #define WL1273_IS2_WIDTH_32 0x0
0158 #define WL1273_IS2_WIDTH_40 0x1
0159 #define WL1273_IS2_WIDTH_22_23 0x2
0160 #define WL1273_IS2_WIDTH_23_22 0x3
0161 #define WL1273_IS2_WIDTH_48 0x4
0162 #define WL1273_IS2_WIDTH_50 0x5
0163 #define WL1273_IS2_WIDTH_60 0x6
0164 #define WL1273_IS2_WIDTH_64 0x7
0165 #define WL1273_IS2_WIDTH_80 0x8
0166 #define WL1273_IS2_WIDTH_96 0x9
0167 #define WL1273_IS2_WIDTH_128 0xa
0168 #define WL1273_IS2_WIDTH 0xf
0169
0170 #define WL1273_IS2_FORMAT_STD (0x0 << 4)
0171 #define WL1273_IS2_FORMAT_LEFT (0x1 << 4)
0172 #define WL1273_IS2_FORMAT_RIGHT (0x2 << 4)
0173 #define WL1273_IS2_FORMAT_USER (0x3 << 4)
0174
0175 #define WL1273_IS2_MASTER (0x0 << 6)
0176 #define WL1273_IS2_SLAVEW (0x1 << 6)
0177
0178 #define WL1273_IS2_TRI_AFTER_SENDING (0x0 << 7)
0179 #define WL1273_IS2_TRI_ALWAYS_ACTIVE (0x1 << 7)
0180
0181 #define WL1273_IS2_SDOWS_RR (0x0 << 8)
0182 #define WL1273_IS2_SDOWS_RF (0x1 << 8)
0183 #define WL1273_IS2_SDOWS_FR (0x2 << 8)
0184 #define WL1273_IS2_SDOWS_FF (0x3 << 8)
0185
0186 #define WL1273_IS2_TRI_OPT (0x0 << 10)
0187 #define WL1273_IS2_TRI_ALWAYS (0x1 << 10)
0188
0189 #define WL1273_IS2_RATE_48K (0x0 << 12)
0190 #define WL1273_IS2_RATE_44_1K (0x1 << 12)
0191 #define WL1273_IS2_RATE_32K (0x2 << 12)
0192 #define WL1273_IS2_RATE_22_05K (0x4 << 12)
0193 #define WL1273_IS2_RATE_16K (0x5 << 12)
0194 #define WL1273_IS2_RATE_12K (0x8 << 12)
0195 #define WL1273_IS2_RATE_11_025 (0x9 << 12)
0196 #define WL1273_IS2_RATE_8K (0xa << 12)
0197 #define WL1273_IS2_RATE (0xf << 12)
0198
0199 #define WL1273_I2S_DEF_MODE (WL1273_IS2_WIDTH_32 | \
0200 WL1273_IS2_FORMAT_STD | \
0201 WL1273_IS2_MASTER | \
0202 WL1273_IS2_TRI_AFTER_SENDING | \
0203 WL1273_IS2_SDOWS_RR | \
0204 WL1273_IS2_TRI_OPT | \
0205 WL1273_IS2_RATE_48K)
0206
0207 #define SCHAR_MIN (-128)
0208 #define SCHAR_MAX 127
0209
0210 #define WL1273_FR_EVENT BIT(0)
0211 #define WL1273_BL_EVENT BIT(1)
0212 #define WL1273_RDS_EVENT BIT(2)
0213 #define WL1273_BBLK_EVENT BIT(3)
0214 #define WL1273_LSYNC_EVENT BIT(4)
0215 #define WL1273_LEV_EVENT BIT(5)
0216 #define WL1273_IFFR_EVENT BIT(6)
0217 #define WL1273_PI_EVENT BIT(7)
0218 #define WL1273_PD_EVENT BIT(8)
0219 #define WL1273_STIC_EVENT BIT(9)
0220 #define WL1273_MAL_EVENT BIT(10)
0221 #define WL1273_POW_ENB_EVENT BIT(11)
0222 #define WL1273_SCAN_OVER_EVENT BIT(12)
0223 #define WL1273_ERROR_EVENT BIT(13)
0224
0225 #define TUNER_MODE_STOP_SEARCH 0
0226 #define TUNER_MODE_PRESET 1
0227 #define TUNER_MODE_AUTO_SEEK 2
0228 #define TUNER_MODE_AF 3
0229 #define TUNER_MODE_AUTO_SEEK_PI 4
0230 #define TUNER_MODE_AUTO_SEEK_BULK 5
0231
0232 #define RDS_BLOCK_SIZE 3
0233
0234 struct wl1273_fm_platform_data {
0235 int (*request_resources) (struct i2c_client *client);
0236 void (*free_resources) (void);
0237 void (*enable) (void);
0238 void (*disable) (void);
0239
0240 u8 forbidden_modes;
0241 unsigned int children;
0242 };
0243
0244 #define WL1273_FM_CORE_CELLS 2
0245
0246 #define WL1273_BAND_OTHER 0
0247 #define WL1273_BAND_JAPAN 1
0248
0249 #define WL1273_BAND_JAPAN_LOW 76000
0250 #define WL1273_BAND_JAPAN_HIGH 90000
0251 #define WL1273_BAND_OTHER_LOW 87500
0252 #define WL1273_BAND_OTHER_HIGH 108000
0253
0254 #define WL1273_BAND_TX_LOW 76000
0255 #define WL1273_BAND_TX_HIGH 108000
0256
0257 struct wl1273_core {
0258 struct mfd_cell cells[WL1273_FM_CORE_CELLS];
0259 struct wl1273_fm_platform_data *pdata;
0260
0261 unsigned int mode;
0262 unsigned int i2s_mode;
0263 unsigned int volume;
0264 unsigned int audio_mode;
0265 unsigned int channel_number;
0266 struct mutex lock;
0267
0268 struct i2c_client *client;
0269
0270 int (*read)(struct wl1273_core *core, u8, u16 *);
0271 int (*write)(struct wl1273_core *core, u8, u16);
0272 int (*write_data)(struct wl1273_core *core, u8 *, u16);
0273 int (*set_audio)(struct wl1273_core *core, unsigned int);
0274 int (*set_volume)(struct wl1273_core *core, unsigned int);
0275 };
0276
0277 #endif