17 #include <linux/module.h>
20 #include <linux/i2c.h>
21 #include <linux/slab.h>
26 #define I2C_ADDRESS 0x60
28 #define REG_PART_REV 0
31 #define REG_BANDWIDTH 8
54 #define dprintk(args...) do { if (debug) {printk(KERN_DEBUG "MT2266: " args); printk("\n"); }} while (0)
60 { .
addr = priv->
cfg->i2c_address, .flags = 0, .buf = &
reg, .len = 1 },
61 { .addr = priv->
cfg->i2c_address, .flags =
I2C_M_RD, .buf =
val, .len = 1 },
75 .addr = priv->
cfg->i2c_address, .flags = 0, .buf =
buf, .len = 2
88 .
addr = priv->
cfg->i2c_address, .flags = 0, .buf =
buf, .len = len
98 static u8 mt2266_init1[] = {
REG_TUNE, 0x00, 0x00, 0x28,
99 0x00, 0x52, 0x99, 0x3f };
101 static u8 mt2266_init2[] = {
102 0x17, 0x6d, 0x71, 0x61, 0xc0, 0xbf, 0xff, 0xdc, 0x00, 0x0a, 0xd4,
103 0x03, 0x64, 0x64, 0x64, 0x64, 0x22, 0xaa, 0xf2, 0x1e, 0x80, 0x14,
104 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, 0x5e, 0x3f, 0xff, 0xff,
105 0xff, 0x00, 0x77, 0x0f, 0x2d
108 static u8 mt2266_init_8mhz[] = {
REG_BANDWIDTH, 0x22, 0x22, 0x22, 0x22,
109 0x22, 0x22, 0x22, 0x22 };
111 static u8 mt2266_init_7mhz[] = {
REG_BANDWIDTH, 0x32, 0x32, 0x32, 0x32,
112 0x32, 0x32, 0x32, 0x32 };
114 static u8 mt2266_init_6mhz[] = {
REG_BANDWIDTH, 0xa7, 0xa7, 0xa7, 0xa7,
115 0xa7, 0xa7, 0xa7, 0xa7 };
117 static u8 mt2266_uhf[] = { 0x1d, 0xdc, 0x00, 0x0a, 0xd4, 0x03, 0x64, 0x64,
118 0x64, 0x64, 0x22, 0xaa, 0xf2, 0x1e, 0x80, 0x14 };
120 static u8 mt2266_vhf[] = { 0x1d, 0xfe, 0x00, 0x00, 0xb4, 0x03, 0xa5, 0xa5,
121 0xa5, 0xa5, 0x82, 0xaa, 0xf1, 0x17, 0x80, 0x1f };
123 #define FREF 30000 // Quartz oscillator 30 MHz
140 if (freq < 470000 && freq > 230000)
144 tune = 2 * freq * (8192/16) / (
FREF/16);
151 mt2266_writeregs(priv, mt2266_init_6mhz,
152 sizeof(mt2266_init_6mhz));
155 mt2266_writeregs(priv, mt2266_init_8mhz,
156 sizeof(mt2266_init_8mhz));
160 mt2266_writeregs(priv, mt2266_init_7mhz,
161 sizeof(mt2266_init_7mhz));
167 dprintk(
"Switch from UHF to VHF");
168 mt2266_writereg(priv, 0x05, 0x04);
169 mt2266_writereg(priv, 0x19, 0x61);
170 mt2266_writeregs(priv, mt2266_vhf,
sizeof(mt2266_vhf));
172 dprintk(
"Switch from VHF to UHF");
173 mt2266_writereg(priv, 0x05, 0x52);
174 mt2266_writereg(priv, 0x19, 0x61);
175 mt2266_writeregs(priv, mt2266_uhf,
sizeof(mt2266_uhf));
181 else if (freq <= 525000)
183 else if (freq <= 550000)
185 else if (freq <= 580000)
187 else if (freq <= 605000)
189 else if (freq <= 630000)
191 else if (freq <= 655000)
193 else if (freq <= 685000)
195 else if (freq <= 710000)
197 else if (freq <= 735000)
199 else if (freq <= 765000)
201 else if (freq <= 802000)
203 else if (freq <= 840000)
209 b[1] = (tune >> 8) & 0x1F;
212 mt2266_writeregs(priv,b,4);
214 dprintk(
"set_parms: tune=%d band=%d %s",
215 (
int) tune, (
int) lnaband,
217 dprintk(
"set_parms: [1..3]: %2x %2x %2x",
218 (
int) b[1], (
int) b[2], (
int)b[3]);
224 mt2266_writeregs(priv, b, 3);
236 dprintk(
"Lock when i=%i",(
int)i);
239 mt2266_writereg(priv, 0x05, 0x62);
246 static void mt2266_calibrate(
struct mt2266_priv *priv)
248 mt2266_writereg(priv, 0x11, 0x03);
249 mt2266_writereg(priv, 0x11, 0x01);
250 mt2266_writeregs(priv, mt2266_init1,
sizeof(mt2266_init1));
251 mt2266_writeregs(priv, mt2266_init2,
sizeof(mt2266_init2));
252 mt2266_writereg(priv, 0x33, 0x5e);
253 mt2266_writereg(priv, 0x10, 0x10);
254 mt2266_writereg(priv, 0x10, 0x00);
255 mt2266_writeregs(priv, mt2266_init_8mhz,
sizeof(mt2266_init_8mhz));
257 mt2266_writereg(priv, 0x17, 0x6d);
258 mt2266_writereg(priv, 0x1c, 0x00);
260 mt2266_writereg(priv, 0x17, 0x6d);
261 mt2266_writereg(priv, 0x1c, 0xff);
282 ret = mt2266_writereg(priv, 0x17, 0x6d);
285 ret = mt2266_writereg(priv, 0x1c, 0xff);
294 mt2266_writereg(priv, 0x17, 0x6d);
295 mt2266_writereg(priv, 0x1c, 0x00);
308 .name =
"Microtune MT2266",
309 .frequency_min = 174000000,
310 .frequency_max = 862000000,
311 .frequency_step = 50000,
313 .release = mt2266_release,
315 .sleep = mt2266_sleep,
316 .set_params = mt2266_set_params,
317 .get_frequency = mt2266_get_frequency,
318 .get_bandwidth = mt2266_get_bandwidth
334 if (mt2266_readreg(priv, 0, &
id)) {
346 mt2266_calibrate(priv);