blob: 4143ef9c4fabdeea4e11420bcce99c1889224f2c [file] [log] [blame]
Malcolm Priestley3dbbf822011-07-25 15:35:12 -03001/*
2 * Driver for it913x Frontend
3 *
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
19 */
20
21#ifndef IT913X_FE_H
22#define IT913X_FE_H
23
24#include <linux/dvb/frontend.h>
25#include "dvb_frontend.h"
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -030026
27struct ite_config {
28 u8 chip_ver;
29 u16 chip_type;
30 u32 firmware;
Malcolm Priestley990f49a2011-11-28 18:04:21 -030031 u8 firmware_ver;
32 u8 adc_x2;
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -030033 u8 tuner_id_0;
34 u8 tuner_id_1;
35 u8 dual_mode;
36 u8 adf;
37};
38
Malcolm Priestley3dbbf822011-07-25 15:35:12 -030039#if defined(CONFIG_DVB_IT913X_FE) || (defined(CONFIG_DVB_IT913X_FE_MODULE) && \
40defined(MODULE))
41extern struct dvb_frontend *it913x_fe_attach(struct i2c_adapter *i2c_adap,
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -030042 u8 i2c_addr, struct ite_config *config);
Malcolm Priestley3dbbf822011-07-25 15:35:12 -030043#else
44static inline struct dvb_frontend *it913x_fe_attach(
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -030045 struct i2c_adapter *i2c_adap,
46 u8 i2c_addr, struct ite_config *config)
Malcolm Priestley3dbbf822011-07-25 15:35:12 -030047{
48 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
49 return NULL;
50}
51#endif /* CONFIG_IT913X_FE */
52#define I2C_BASE_ADDR 0x10
53#define DEV_0 0x0
54#define DEV_1 0x10
55#define PRO_LINK 0x0
56#define PRO_DMOD 0x1
57#define DEV_0_DMOD (PRO_DMOD << 0x7)
58#define DEV_1_DMOD (DEV_0_DMOD | DEV_1)
59#define CHIP2_I2C_ADDR 0x3a
60
61#define AFE_MEM0 0xfb24
62
63#define MP2_SW_RST 0xf99d
64#define MP2IF2_SW_RST 0xf9a4
65
66#define PADODPU 0xd827
67#define THIRDODPU 0xd828
68#define AGC_O_D 0xd829
69
70#define EP0_TX_EN 0xdd11
71#define EP0_TX_NAK 0xdd13
72#define EP4_TX_LEN_LSB 0xdd88
73#define EP4_TX_LEN_MSB 0xdd89
74#define EP4_MAX_PKT 0xdd0c
75#define EP5_TX_LEN_LSB 0xdd8a
76#define EP5_TX_LEN_MSB 0xdd8b
77#define EP5_MAX_PKT 0xdd0d
78
79#define IO_MUX_POWER_CLK 0xd800
80#define CLK_O_EN 0xd81a
81#define I2C_CLK 0xf103
82#define I2C_CLK_100 0x7
83#define I2C_CLK_400 0x1a
84
85#define D_TPSD_LOCK 0xf5a9
86#define MP2IF2_EN 0xf9a3
87#define MP2IF_SERIAL 0xf985
88#define TSIS_ENABLE 0xf9cd
89#define MP2IF2_HALF_PSB 0xf9a5
90#define MP2IF_STOP_EN 0xf9b5
91#define MPEG_FULL_SPEED 0xf990
92#define TOP_HOSTB_SER_MODE 0xd91c
93
94#define PID_RST 0xf992
95#define PID_EN 0xf993
96#define PID_INX_EN 0xf994
97#define PID_INX 0xf995
98#define PID_LSB 0xf996
99#define PID_MSB 0xf997
100
101#define MP2IF_MPEG_PAR_MODE 0xf986
102#define DCA_UPPER_CHIP 0xf731
103#define DCA_LOWER_CHIP 0xf732
104#define DCA_PLATCH 0xf730
105#define DCA_FPGA_LATCH 0xf778
106#define DCA_STAND_ALONE 0xf73c
107#define DCA_ENABLE 0xf776
108
109#define DVBT_INTEN 0xf41f
110#define DVBT_ENABLE 0xf41a
111#define HOSTB_DCA_LOWER 0xd91f
112#define HOSTB_MPEG_PAR_MODE 0xd91b
113#define HOSTB_MPEG_SER_MODE 0xd91c
114#define HOSTB_MPEG_SER_DO7 0xd91d
115#define HOSTB_DCA_UPPER 0xd91e
116#define PADMISCDR2 0xd830
117#define PADMISCDR4 0xd831
118#define PADMISCDR8 0xd832
119#define PADMISCDRSR 0xd833
120#define LOCK3_OUT 0xd8fd
121
122#define GPIOH1_O 0xd8af
123#define GPIOH1_EN 0xd8b0
124#define GPIOH1_ON 0xd8b1
125#define GPIOH3_O 0xd8b3
126#define GPIOH3_EN 0xd8b4
127#define GPIOH3_ON 0xd8b5
128#define GPIOH5_O 0xd8bb
129#define GPIOH5_EN 0xd8bc
130#define GPIOH5_ON 0xd8bd
131
132#define AFE_MEM0 0xfb24
133
134#define REG_TPSD_TX_MODE 0xf900
135#define REG_TPSD_GI 0xf901
136#define REG_TPSD_HIER 0xf902
137#define REG_TPSD_CONST 0xf903
138#define REG_BW 0xf904
139#define REG_PRIV 0xf905
140#define REG_TPSD_HP_CODE 0xf906
141#define REG_TPSD_LP_CODE 0xf907
142
143#define MP2IF_SYNC_LK 0xf999
144#define ADC_FREQ 0xf1cd
145
146#define TRIGGER_OFSM 0x0000
147/* COEFF Registers start at 0x0001 to 0x0020 */
148#define COEFF_1_2048 0x0001
149#define XTAL_CLK 0x0025
150#define BFS_FCW 0x0029
151#define TPSD_LOCK 0x003c
152#define TRAINING_MODE 0x0040
153#define ADC_X_2 0x0045
154#define TUNER_ID 0x0046
155#define EMPTY_CHANNEL_STATUS 0x0047
156#define SIGNAL_LEVEL 0x0048
157#define SIGNAL_QUALITY 0x0049
158#define EST_SIGNAL_LEVEL 0x004a
159#define FREE_BAND 0x004b
160#define SUSPEND_FLAG 0x004c
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -0300161/* Build in tuner types */
Malcolm Priestley3dbbf822011-07-25 15:35:12 -0300162#define IT9137 0x38
Malcolm Priestleyb7d425d392011-10-31 12:02:08 -0300163#define IT9135_38 0x38
164#define IT9135_51 0x50
165#define IT9135_52 0x52
166#define IT9135_60 0x60
167#define IT9135_61 0x61
168#define IT9135_62 0x62
Malcolm Priestley3dbbf822011-07-25 15:35:12 -0300169
170enum {
171 CMD_DEMOD_READ = 0,
172 CMD_DEMOD_WRITE,
173 CMD_TUNER_READ,
174 CMD_TUNER_WRITE,
175 CMD_REG_EEPROM_READ,
176 CMD_REG_EEPROM_WRITE,
177 CMD_DATA_READ,
178 CMD_VAR_READ = 8,
179 CMD_VAR_WRITE,
180 CMD_PLATFORM_GET,
181 CMD_PLATFORM_SET,
182 CMD_IP_CACHE,
183 CMD_IP_ADD,
184 CMD_IP_REMOVE,
185 CMD_PID_ADD,
186 CMD_PID_REMOVE,
187 CMD_SIPSI_GET,
188 CMD_SIPSI_MPE_RESET,
189 CMD_H_PID_ADD = 0x15,
190 CMD_H_PID_REMOVE,
191 CMD_ABORT,
192 CMD_IR_GET,
193 CMD_IR_SET,
194 CMD_FW_DOWNLOAD = 0x21,
195 CMD_QUERYINFO,
196 CMD_BOOT,
197 CMD_FW_DOWNLOAD_BEGIN,
198 CMD_FW_DOWNLOAD_END,
199 CMD_RUN_CODE,
200 CMD_SCATTER_READ = 0x28,
201 CMD_SCATTER_WRITE,
202 CMD_GENERIC_READ,
203 CMD_GENERIC_WRITE
204};
205
206enum {
207 READ_LONG,
208 WRITE_LONG,
209 READ_SHORT,
210 WRITE_SHORT,
211 READ_DATA,
212 WRITE_DATA,
213 WRITE_CMD,
214};
215
Malcolm Priestley990f49a2011-11-28 18:04:21 -0300216enum {
217 IT9135_AUTO = 0,
218 IT9137_FW,
219 IT9135_V1_FW,
220 IT9135_V2_FW,
221};
222
Malcolm Priestley3dbbf822011-07-25 15:35:12 -0300223#endif /* IT913X_FE_H */