diff options
author | Jochen Friedrich <jochen@scram.de> | 2009-02-02 12:50:09 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:39 -0400 |
commit | b72dbaefbdcdfc9b69fc3861b9de0a6240f5cc8a (patch) | |
tree | a5e6e497c9acae0f6418ae8a0ac4203d74f9f656 /drivers | |
parent | 812b1f9d54a5f75066f8a5c92166a979c48c98c6 (diff) |
V4L/DVB (10452): Add Freescale MC44S803 tuner driver
Add Freescale MC44S803 tuner driver.
Signed-off-by: Jochen Friedrich <jochen@scram.de>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/common/tuners/Kconfig | 8 | ||||
-rw-r--r-- | drivers/media/common/tuners/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/common/tuners/mc44s803.c | 371 | ||||
-rw-r--r-- | drivers/media/common/tuners/mc44s803.h | 46 | ||||
-rw-r--r-- | drivers/media/common/tuners/mc44s803_priv.h | 208 |
5 files changed, 634 insertions, 0 deletions
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig index 6f92beaa5ac8..7969b695cb50 100644 --- a/drivers/media/common/tuners/Kconfig +++ b/drivers/media/common/tuners/Kconfig | |||
@@ -29,6 +29,7 @@ config MEDIA_TUNER | |||
29 | select MEDIA_TUNER_TEA5767 if !MEDIA_TUNER_CUSTOMIZE | 29 | select MEDIA_TUNER_TEA5767 if !MEDIA_TUNER_CUSTOMIZE |
30 | select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE | 30 | select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE |
31 | select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMIZE | 31 | select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMIZE |
32 | select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMIZE | ||
32 | 33 | ||
33 | menuconfig MEDIA_TUNER_CUSTOMIZE | 34 | menuconfig MEDIA_TUNER_CUSTOMIZE |
34 | bool "Customize analog and hybrid tuner modules to build" | 35 | bool "Customize analog and hybrid tuner modules to build" |
@@ -164,4 +165,11 @@ config MEDIA_TUNER_MXL5007T | |||
164 | help | 165 | help |
165 | A driver for the silicon tuner MxL5007T from MaxLinear. | 166 | A driver for the silicon tuner MxL5007T from MaxLinear. |
166 | 167 | ||
168 | config MEDIA_TUNER_MC44S803 | ||
169 | tristate "Freescale MC44S803 Low Power CMOS Broadband tuners" | ||
170 | depends on VIDEO_MEDIA && I2C | ||
171 | default m if DVB_FE_CUSTOMISE | ||
172 | help | ||
173 | Say Y here to support the Freescale MC44S803 based tuners | ||
174 | |||
167 | endif # MEDIA_TUNER_CUSTOMIZE | 175 | endif # MEDIA_TUNER_CUSTOMIZE |
diff --git a/drivers/media/common/tuners/Makefile b/drivers/media/common/tuners/Makefile index 4dfbe5b8264f..4132b2be79e5 100644 --- a/drivers/media/common/tuners/Makefile +++ b/drivers/media/common/tuners/Makefile | |||
@@ -22,6 +22,7 @@ obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o | |||
22 | obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o | 22 | obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o |
23 | obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o | 23 | obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o |
24 | obj-$(CONFIG_MEDIA_TUNER_MXL5007T) += mxl5007t.o | 24 | obj-$(CONFIG_MEDIA_TUNER_MXL5007T) += mxl5007t.o |
25 | obj-$(CONFIG_MEDIA_TUNER_MC44S803) += mc44s803.o | ||
25 | 26 | ||
26 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 27 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
27 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | 28 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends |
diff --git a/drivers/media/common/tuners/mc44s803.c b/drivers/media/common/tuners/mc44s803.c new file mode 100644 index 000000000000..20c4485ce16a --- /dev/null +++ b/drivers/media/common/tuners/mc44s803.c | |||
@@ -0,0 +1,371 @@ | |||
1 | /* | ||
2 | * Driver for Freescale MC44S803 Low Power CMOS Broadband Tuner | ||
3 | * | ||
4 | * Copyright (c) 2009 Jochen Friedrich <jochen@scram.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/dvb/frontend.h> | ||
25 | #include <linux/i2c.h> | ||
26 | |||
27 | #include "dvb_frontend.h" | ||
28 | |||
29 | #include "mc44s803.h" | ||
30 | #include "mc44s803_priv.h" | ||
31 | |||
32 | #define mc_printk(level, format, arg...) \ | ||
33 | printk(level "mc44s803: " format , ## arg) | ||
34 | |||
35 | /* Writes a single register */ | ||
36 | static int mc44s803_writereg(struct mc44s803_priv *priv, u32 val) | ||
37 | { | ||
38 | u8 buf[3]; | ||
39 | struct i2c_msg msg = { | ||
40 | .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = 3 | ||
41 | }; | ||
42 | |||
43 | buf[0] = (val & 0xff0000) >> 16; | ||
44 | buf[1] = (val & 0xff00) >> 8; | ||
45 | buf[2] = (val & 0xff); | ||
46 | |||
47 | if (i2c_transfer(priv->i2c, &msg, 1) != 1) { | ||
48 | mc_printk(KERN_WARNING, "I2C write failed\n"); | ||
49 | return -EREMOTEIO; | ||
50 | } | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | /* Reads a single register */ | ||
55 | static int mc44s803_readreg(struct mc44s803_priv *priv, u8 reg, u32 *val) | ||
56 | { | ||
57 | u32 wval; | ||
58 | u8 buf[3]; | ||
59 | int ret; | ||
60 | struct i2c_msg msg[] = { | ||
61 | { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, | ||
62 | .buf = buf, .len = 3 }, | ||
63 | }; | ||
64 | |||
65 | wval = MC44S803_REG_SM(MC44S803_REG_DATAREG, MC44S803_ADDR) | | ||
66 | MC44S803_REG_SM(reg, MC44S803_D); | ||
67 | |||
68 | ret = mc44s803_writereg(priv, wval); | ||
69 | if (ret) | ||
70 | return ret; | ||
71 | |||
72 | if (i2c_transfer(priv->i2c, msg, 1) != 1) { | ||
73 | mc_printk(KERN_WARNING, "I2C read failed\n"); | ||
74 | return -EREMOTEIO; | ||
75 | } | ||
76 | |||
77 | *val = (buf[0] << 16) | (buf[1] << 8) | buf[2]; | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int mc44s803_release(struct dvb_frontend *fe) | ||
83 | { | ||
84 | struct mc44s803_priv *priv = fe->tuner_priv; | ||
85 | |||
86 | fe->tuner_priv = NULL; | ||
87 | kfree(priv); | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static int mc44s803_init(struct dvb_frontend *fe) | ||
93 | { | ||
94 | struct mc44s803_priv *priv = fe->tuner_priv; | ||
95 | u32 val; | ||
96 | int err; | ||
97 | |||
98 | if (fe->ops.i2c_gate_ctrl) | ||
99 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
100 | |||
101 | /* Reset chip */ | ||
102 | val = MC44S803_REG_SM(MC44S803_REG_RESET, MC44S803_ADDR) | | ||
103 | MC44S803_REG_SM(1, MC44S803_RS); | ||
104 | |||
105 | err = mc44s803_writereg(priv, val); | ||
106 | if (err) | ||
107 | goto exit; | ||
108 | |||
109 | val = MC44S803_REG_SM(MC44S803_REG_RESET, MC44S803_ADDR); | ||
110 | |||
111 | err = mc44s803_writereg(priv, val); | ||
112 | if (err) | ||
113 | goto exit; | ||
114 | |||
115 | /* Power Up and Start Osc */ | ||
116 | |||
117 | val = MC44S803_REG_SM(MC44S803_REG_REFOSC, MC44S803_ADDR) | | ||
118 | MC44S803_REG_SM(0xC0, MC44S803_REFOSC) | | ||
119 | MC44S803_REG_SM(1, MC44S803_OSCSEL); | ||
120 | |||
121 | err = mc44s803_writereg(priv, val); | ||
122 | if (err) | ||
123 | goto exit; | ||
124 | |||
125 | val = MC44S803_REG_SM(MC44S803_REG_POWER, MC44S803_ADDR) | | ||
126 | MC44S803_REG_SM(0x200, MC44S803_POWER); | ||
127 | |||
128 | err = mc44s803_writereg(priv, val); | ||
129 | if (err) | ||
130 | goto exit; | ||
131 | |||
132 | msleep(10); | ||
133 | |||
134 | val = MC44S803_REG_SM(MC44S803_REG_REFOSC, MC44S803_ADDR) | | ||
135 | MC44S803_REG_SM(0x40, MC44S803_REFOSC) | | ||
136 | MC44S803_REG_SM(1, MC44S803_OSCSEL); | ||
137 | |||
138 | err = mc44s803_writereg(priv, val); | ||
139 | if (err) | ||
140 | goto exit; | ||
141 | |||
142 | msleep(20); | ||
143 | |||
144 | /* Setup Mixer */ | ||
145 | |||
146 | val = MC44S803_REG_SM(MC44S803_REG_MIXER, MC44S803_ADDR) | | ||
147 | MC44S803_REG_SM(1, MC44S803_TRI_STATE) | | ||
148 | MC44S803_REG_SM(0x7F, MC44S803_MIXER_RES); | ||
149 | |||
150 | err = mc44s803_writereg(priv, val); | ||
151 | if (err) | ||
152 | goto exit; | ||
153 | |||
154 | /* Setup Cirquit Adjust */ | ||
155 | |||
156 | val = MC44S803_REG_SM(MC44S803_REG_CIRCADJ, MC44S803_ADDR) | | ||
157 | MC44S803_REG_SM(1, MC44S803_G1) | | ||
158 | MC44S803_REG_SM(1, MC44S803_G3) | | ||
159 | MC44S803_REG_SM(0x3, MC44S803_CIRCADJ_RES) | | ||
160 | MC44S803_REG_SM(1, MC44S803_G6) | | ||
161 | MC44S803_REG_SM(priv->cfg->dig_out, MC44S803_S1) | | ||
162 | MC44S803_REG_SM(0x3, MC44S803_LP) | | ||
163 | MC44S803_REG_SM(1, MC44S803_CLRF) | | ||
164 | MC44S803_REG_SM(1, MC44S803_CLIF); | ||
165 | |||
166 | err = mc44s803_writereg(priv, val); | ||
167 | if (err) | ||
168 | goto exit; | ||
169 | |||
170 | val = MC44S803_REG_SM(MC44S803_REG_CIRCADJ, MC44S803_ADDR) | | ||
171 | MC44S803_REG_SM(1, MC44S803_G1) | | ||
172 | MC44S803_REG_SM(1, MC44S803_G3) | | ||
173 | MC44S803_REG_SM(0x3, MC44S803_CIRCADJ_RES) | | ||
174 | MC44S803_REG_SM(1, MC44S803_G6) | | ||
175 | MC44S803_REG_SM(priv->cfg->dig_out, MC44S803_S1) | | ||
176 | MC44S803_REG_SM(0x3, MC44S803_LP); | ||
177 | |||
178 | err = mc44s803_writereg(priv, val); | ||
179 | if (err) | ||
180 | goto exit; | ||
181 | |||
182 | /* Setup Digtune */ | ||
183 | |||
184 | val = MC44S803_REG_SM(MC44S803_REG_DIGTUNE, MC44S803_ADDR) | | ||
185 | MC44S803_REG_SM(3, MC44S803_XOD); | ||
186 | |||
187 | err = mc44s803_writereg(priv, val); | ||
188 | if (err) | ||
189 | goto exit; | ||
190 | |||
191 | /* Setup AGC */ | ||
192 | |||
193 | val = MC44S803_REG_SM(MC44S803_REG_LNAAGC, MC44S803_ADDR) | | ||
194 | MC44S803_REG_SM(1, MC44S803_AT1) | | ||
195 | MC44S803_REG_SM(1, MC44S803_AT2) | | ||
196 | MC44S803_REG_SM(1, MC44S803_AGC_AN_DIG) | | ||
197 | MC44S803_REG_SM(1, MC44S803_AGC_READ_EN) | | ||
198 | MC44S803_REG_SM(1, MC44S803_LNA0); | ||
199 | |||
200 | err = mc44s803_writereg(priv, val); | ||
201 | if (err) | ||
202 | goto exit; | ||
203 | |||
204 | if (fe->ops.i2c_gate_ctrl) | ||
205 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
206 | return 0; | ||
207 | |||
208 | exit: | ||
209 | if (fe->ops.i2c_gate_ctrl) | ||
210 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
211 | |||
212 | mc_printk(KERN_WARNING, "I/O Error\n"); | ||
213 | return err; | ||
214 | } | ||
215 | |||
216 | static int mc44s803_set_params(struct dvb_frontend *fe, | ||
217 | struct dvb_frontend_parameters *params) | ||
218 | { | ||
219 | struct mc44s803_priv *priv = fe->tuner_priv; | ||
220 | u32 r1, r2, n1, n2, lo1, lo2, freq, val; | ||
221 | int err; | ||
222 | |||
223 | priv->frequency = params->frequency; | ||
224 | |||
225 | r1 = MC44S803_OSC / 1000000; | ||
226 | r2 = MC44S803_OSC / 100000; | ||
227 | |||
228 | n1 = (params->frequency + MC44S803_IF1 + 500000) / 1000000; | ||
229 | freq = MC44S803_OSC / r1 * n1; | ||
230 | lo1 = ((60 * n1) + (r1 / 2)) / r1; | ||
231 | freq = freq - params->frequency; | ||
232 | |||
233 | n2 = (freq - MC44S803_IF2 + 50000) / 100000; | ||
234 | lo2 = ((60 * n2) + (r2 / 2)) / r2; | ||
235 | |||
236 | if (fe->ops.i2c_gate_ctrl) | ||
237 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
238 | |||
239 | val = MC44S803_REG_SM(MC44S803_REG_REFDIV, MC44S803_ADDR) | | ||
240 | MC44S803_REG_SM(r1-1, MC44S803_R1) | | ||
241 | MC44S803_REG_SM(r2-1, MC44S803_R2) | | ||
242 | MC44S803_REG_SM(1, MC44S803_REFBUF_EN); | ||
243 | |||
244 | err = mc44s803_writereg(priv, val); | ||
245 | if (err) | ||
246 | goto exit; | ||
247 | |||
248 | val = MC44S803_REG_SM(MC44S803_REG_LO1, MC44S803_ADDR) | | ||
249 | MC44S803_REG_SM(n1-2, MC44S803_LO1); | ||
250 | |||
251 | err = mc44s803_writereg(priv, val); | ||
252 | if (err) | ||
253 | goto exit; | ||
254 | |||
255 | val = MC44S803_REG_SM(MC44S803_REG_LO2, MC44S803_ADDR) | | ||
256 | MC44S803_REG_SM(n2-2, MC44S803_LO2); | ||
257 | |||
258 | err = mc44s803_writereg(priv, val); | ||
259 | if (err) | ||
260 | goto exit; | ||
261 | |||
262 | val = MC44S803_REG_SM(MC44S803_REG_DIGTUNE, MC44S803_ADDR) | | ||
263 | MC44S803_REG_SM(1, MC44S803_DA) | | ||
264 | MC44S803_REG_SM(lo1, MC44S803_LO_REF) | | ||
265 | MC44S803_REG_SM(1, MC44S803_AT); | ||
266 | |||
267 | err = mc44s803_writereg(priv, val); | ||
268 | if (err) | ||
269 | goto exit; | ||
270 | |||
271 | val = MC44S803_REG_SM(MC44S803_REG_DIGTUNE, MC44S803_ADDR) | | ||
272 | MC44S803_REG_SM(2, MC44S803_DA) | | ||
273 | MC44S803_REG_SM(lo2, MC44S803_LO_REF) | | ||
274 | MC44S803_REG_SM(1, MC44S803_AT); | ||
275 | |||
276 | err = mc44s803_writereg(priv, val); | ||
277 | if (err) | ||
278 | goto exit; | ||
279 | |||
280 | if (fe->ops.i2c_gate_ctrl) | ||
281 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
282 | |||
283 | return 0; | ||
284 | |||
285 | exit: | ||
286 | if (fe->ops.i2c_gate_ctrl) | ||
287 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
288 | |||
289 | mc_printk(KERN_WARNING, "I/O Error\n"); | ||
290 | return err; | ||
291 | } | ||
292 | |||
293 | static int mc44s803_get_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
294 | { | ||
295 | struct mc44s803_priv *priv = fe->tuner_priv; | ||
296 | *frequency = priv->frequency; | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static const struct dvb_tuner_ops mc44s803_tuner_ops = { | ||
301 | .info = { | ||
302 | .name = "Freescale MC44S803", | ||
303 | .frequency_min = 48000000, | ||
304 | .frequency_max = 1000000000, | ||
305 | .frequency_step = 100000, | ||
306 | }, | ||
307 | |||
308 | .release = mc44s803_release, | ||
309 | .init = mc44s803_init, | ||
310 | .set_params = mc44s803_set_params, | ||
311 | .get_frequency = mc44s803_get_frequency | ||
312 | }; | ||
313 | |||
314 | /* This functions tries to identify a MC44S803 tuner by reading the ID | ||
315 | register. This is hasty. */ | ||
316 | struct dvb_frontend *mc44s803_attach(struct dvb_frontend *fe, | ||
317 | struct i2c_adapter *i2c, struct mc44s803_config *cfg) | ||
318 | { | ||
319 | struct mc44s803_priv *priv; | ||
320 | u32 reg; | ||
321 | u8 id; | ||
322 | int ret; | ||
323 | |||
324 | reg = 0; | ||
325 | |||
326 | priv = kzalloc(sizeof(struct mc44s803_priv), GFP_KERNEL); | ||
327 | if (priv == NULL) | ||
328 | return NULL; | ||
329 | |||
330 | priv->cfg = cfg; | ||
331 | priv->i2c = i2c; | ||
332 | priv->fe = fe; | ||
333 | |||
334 | if (fe->ops.i2c_gate_ctrl) | ||
335 | fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ | ||
336 | |||
337 | ret = mc44s803_readreg(priv, MC44S803_REG_ID, ®); | ||
338 | if (ret) | ||
339 | goto error; | ||
340 | |||
341 | id = MC44S803_REG_MS(reg, MC44S803_ID); | ||
342 | |||
343 | if (id != 0x14) { | ||
344 | mc_printk(KERN_ERR, "unsupported ID " | ||
345 | "(%x should be 0x14)\n", id); | ||
346 | goto error; | ||
347 | } | ||
348 | |||
349 | mc_printk(KERN_INFO, "successfully identified (ID = %x)\n", id); | ||
350 | memcpy(&fe->ops.tuner_ops, &mc44s803_tuner_ops, | ||
351 | sizeof(struct dvb_tuner_ops)); | ||
352 | |||
353 | fe->tuner_priv = priv; | ||
354 | |||
355 | if (fe->ops.i2c_gate_ctrl) | ||
356 | fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ | ||
357 | |||
358 | return fe; | ||
359 | |||
360 | error: | ||
361 | if (fe->ops.i2c_gate_ctrl) | ||
362 | fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ | ||
363 | |||
364 | kfree(priv); | ||
365 | return NULL; | ||
366 | } | ||
367 | EXPORT_SYMBOL(mc44s803_attach); | ||
368 | |||
369 | MODULE_AUTHOR("Jochen Friedrich"); | ||
370 | MODULE_DESCRIPTION("Freescale MC44S803 silicon tuner driver"); | ||
371 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/common/tuners/mc44s803.h b/drivers/media/common/tuners/mc44s803.h new file mode 100644 index 000000000000..34f3892d3f6d --- /dev/null +++ b/drivers/media/common/tuners/mc44s803.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Driver for Freescale MC44S803 Low Power CMOS Broadband Tuner | ||
3 | * | ||
4 | * Copyright (c) 2009 Jochen Friedrich <jochen@scram.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
20 | */ | ||
21 | |||
22 | #ifndef MC44S803_H | ||
23 | #define MC44S803_H | ||
24 | |||
25 | struct dvb_frontend; | ||
26 | struct i2c_adapter; | ||
27 | |||
28 | struct mc44s803_config { | ||
29 | u8 i2c_address; | ||
30 | u8 dig_out; | ||
31 | }; | ||
32 | |||
33 | #if defined(CONFIG_MEDIA_TUNER_MC44S803) || \ | ||
34 | (defined(CONFIG_MEDIA_TUNER_MC44S803_MODULE) && defined(MODULE)) | ||
35 | extern struct dvb_frontend *mc44s803_attach(struct dvb_frontend *fe, | ||
36 | struct i2c_adapter *i2c, struct mc44s803_config *cfg); | ||
37 | #else | ||
38 | static inline struct dvb_frontend *mc44s803_attach(struct dvb_frontend *fe, | ||
39 | struct i2c_adapter *i2c, struct mc44s803_config *cfg) | ||
40 | { | ||
41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
42 | return NULL; | ||
43 | } | ||
44 | #endif /* CONFIG_MEDIA_TUNER_MC44S803 */ | ||
45 | |||
46 | #endif | ||
diff --git a/drivers/media/common/tuners/mc44s803_priv.h b/drivers/media/common/tuners/mc44s803_priv.h new file mode 100644 index 000000000000..14a92780906d --- /dev/null +++ b/drivers/media/common/tuners/mc44s803_priv.h | |||
@@ -0,0 +1,208 @@ | |||
1 | /* | ||
2 | * Driver for Freescale MC44S803 Low Power CMOS Broadband Tuner | ||
3 | * | ||
4 | * Copyright (c) 2009 Jochen Friedrich <jochen@scram.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
20 | */ | ||
21 | |||
22 | #ifndef MC44S803_PRIV_H | ||
23 | #define MC44S803_PRIV_H | ||
24 | |||
25 | /* This driver is based on the information available in the datasheet | ||
26 | http://www.freescale.com/files/rf_if/doc/data_sheet/MC44S803.pdf | ||
27 | |||
28 | SPI or I2C Address : 0xc0-0xc6 | ||
29 | |||
30 | Reg.No | Function | ||
31 | ------------------------------------------- | ||
32 | 00 | Power Down | ||
33 | 01 | Reference Oszillator | ||
34 | 02 | Reference Dividers | ||
35 | 03 | Mixer and Reference Buffer | ||
36 | 04 | Reset/Serial Out | ||
37 | 05 | LO 1 | ||
38 | 06 | LO 2 | ||
39 | 07 | Circuit Adjust | ||
40 | 08 | Test | ||
41 | 09 | Digital Tune | ||
42 | 0A | LNA AGC | ||
43 | 0B | Data Register Address | ||
44 | 0C | Regulator Test | ||
45 | 0D | VCO Test | ||
46 | 0E | LNA Gain/Input Power | ||
47 | 0F | ID Bits | ||
48 | |||
49 | */ | ||
50 | |||
51 | #define MC44S803_OSC 26000000 /* 26 MHz */ | ||
52 | #define MC44S803_IF1 1086000000 /* 1086 MHz */ | ||
53 | #define MC44S803_IF2 36125000 /* 36.125 MHz */ | ||
54 | |||
55 | #define MC44S803_REG_POWER 0 | ||
56 | #define MC44S803_REG_REFOSC 1 | ||
57 | #define MC44S803_REG_REFDIV 2 | ||
58 | #define MC44S803_REG_MIXER 3 | ||
59 | #define MC44S803_REG_RESET 4 | ||
60 | #define MC44S803_REG_LO1 5 | ||
61 | #define MC44S803_REG_LO2 6 | ||
62 | #define MC44S803_REG_CIRCADJ 7 | ||
63 | #define MC44S803_REG_TEST 8 | ||
64 | #define MC44S803_REG_DIGTUNE 9 | ||
65 | #define MC44S803_REG_LNAAGC 0x0A | ||
66 | #define MC44S803_REG_DATAREG 0x0B | ||
67 | #define MC44S803_REG_REGTEST 0x0C | ||
68 | #define MC44S803_REG_VCOTEST 0x0D | ||
69 | #define MC44S803_REG_LNAGAIN 0x0E | ||
70 | #define MC44S803_REG_ID 0x0F | ||
71 | |||
72 | /* Register definitions */ | ||
73 | #define MC44S803_ADDR 0x0F | ||
74 | #define MC44S803_ADDR_S 0 | ||
75 | /* REG_POWER */ | ||
76 | #define MC44S803_POWER 0xFFFFF0 | ||
77 | #define MC44S803_POWER_S 4 | ||
78 | /* REG_REFOSC */ | ||
79 | #define MC44S803_REFOSC 0x1FF0 | ||
80 | #define MC44S803_REFOSC_S 4 | ||
81 | #define MC44S803_OSCSEL 0x2000 | ||
82 | #define MC44S803_OSCSEL_S 13 | ||
83 | /* REG_REFDIV */ | ||
84 | #define MC44S803_R2 0x1FF0 | ||
85 | #define MC44S803_R2_S 4 | ||
86 | #define MC44S803_REFBUF_EN 0x2000 | ||
87 | #define MC44S803_REFBUF_EN_S 13 | ||
88 | #define MC44S803_R1 0x7C000 | ||
89 | #define MC44S803_R1_S 14 | ||
90 | /* REG_MIXER */ | ||
91 | #define MC44S803_R3 0x70 | ||
92 | #define MC44S803_R3_S 4 | ||
93 | #define MC44S803_MUX3 0x80 | ||
94 | #define MC44S803_MUX3_S 7 | ||
95 | #define MC44S803_MUX4 0x100 | ||
96 | #define MC44S803_MUX4_S 8 | ||
97 | #define MC44S803_OSC_SCR 0x200 | ||
98 | #define MC44S803_OSC_SCR_S 9 | ||
99 | #define MC44S803_TRI_STATE 0x400 | ||
100 | #define MC44S803_TRI_STATE_S 10 | ||
101 | #define MC44S803_BUF_GAIN 0x800 | ||
102 | #define MC44S803_BUF_GAIN_S 11 | ||
103 | #define MC44S803_BUF_IO 0x1000 | ||
104 | #define MC44S803_BUF_IO_S 12 | ||
105 | #define MC44S803_MIXER_RES 0xFE000 | ||
106 | #define MC44S803_MIXER_RES_S 13 | ||
107 | /* REG_RESET */ | ||
108 | #define MC44S803_RS 0x10 | ||
109 | #define MC44S803_RS_S 4 | ||
110 | #define MC44S803_SO 0x20 | ||
111 | #define MC44S803_SO_S 5 | ||
112 | /* REG_LO1 */ | ||
113 | #define MC44S803_LO1 0xFFF0 | ||
114 | #define MC44S803_LO1_S 4 | ||
115 | /* REG_LO2 */ | ||
116 | #define MC44S803_LO2 0x7FFF0 | ||
117 | #define MC44S803_LO2_S 4 | ||
118 | /* REG_CIRCADJ */ | ||
119 | #define MC44S803_G1 0x20 | ||
120 | #define MC44S803_G1_S 5 | ||
121 | #define MC44S803_G3 0x80 | ||
122 | #define MC44S803_G3_S 7 | ||
123 | #define MC44S803_CIRCADJ_RES 0x300 | ||
124 | #define MC44S803_CIRCADJ_RES_S 8 | ||
125 | #define MC44S803_G6 0x400 | ||
126 | #define MC44S803_G6_S 10 | ||
127 | #define MC44S803_G7 0x800 | ||
128 | #define MC44S803_G7_S 11 | ||
129 | #define MC44S803_S1 0x1000 | ||
130 | #define MC44S803_S1_S 12 | ||
131 | #define MC44S803_LP 0x7E000 | ||
132 | #define MC44S803_LP_S 13 | ||
133 | #define MC44S803_CLRF 0x80000 | ||
134 | #define MC44S803_CLRF_S 19 | ||
135 | #define MC44S803_CLIF 0x100000 | ||
136 | #define MC44S803_CLIF_S 20 | ||
137 | /* REG_TEST */ | ||
138 | /* REG_DIGTUNE */ | ||
139 | #define MC44S803_DA 0xF0 | ||
140 | #define MC44S803_DA_S 4 | ||
141 | #define MC44S803_XOD 0x300 | ||
142 | #define MC44S803_XOD_S 8 | ||
143 | #define MC44S803_RST 0x10000 | ||
144 | #define MC44S803_RST_S 16 | ||
145 | #define MC44S803_LO_REF 0x1FFF00 | ||
146 | #define MC44S803_LO_REF_S 8 | ||
147 | #define MC44S803_AT 0x200000 | ||
148 | #define MC44S803_AT_S 21 | ||
149 | #define MC44S803_MT 0x400000 | ||
150 | #define MC44S803_MT_S 22 | ||
151 | /* REG_LNAAGC */ | ||
152 | #define MC44S803_G 0x3F0 | ||
153 | #define MC44S803_G_S 4 | ||
154 | #define MC44S803_AT1 0x400 | ||
155 | #define MC44S803_AT1_S 10 | ||
156 | #define MC44S803_AT2 0x800 | ||
157 | #define MC44S803_AT2_S 11 | ||
158 | #define MC44S803_HL_GR_EN 0x8000 | ||
159 | #define MC44S803_HL_GR_EN_S 15 | ||
160 | #define MC44S803_AGC_AN_DIG 0x10000 | ||
161 | #define MC44S803_AGC_AN_DIG_S 16 | ||
162 | #define MC44S803_ATTEN_EN 0x20000 | ||
163 | #define MC44S803_ATTEN_EN_S 17 | ||
164 | #define MC44S803_AGC_READ_EN 0x40000 | ||
165 | #define MC44S803_AGC_READ_EN_S 18 | ||
166 | #define MC44S803_LNA0 0x80000 | ||
167 | #define MC44S803_LNA0_S 19 | ||
168 | #define MC44S803_AGC_SEL 0x100000 | ||
169 | #define MC44S803_AGC_SEL_S 20 | ||
170 | #define MC44S803_AT0 0x200000 | ||
171 | #define MC44S803_AT0_S 21 | ||
172 | #define MC44S803_B 0xC00000 | ||
173 | #define MC44S803_B_S 22 | ||
174 | /* REG_DATAREG */ | ||
175 | #define MC44S803_D 0xF0 | ||
176 | #define MC44S803_D_S 4 | ||
177 | /* REG_REGTEST */ | ||
178 | /* REG_VCOTEST */ | ||
179 | /* REG_LNAGAIN */ | ||
180 | #define MC44S803_IF_PWR 0x700 | ||
181 | #define MC44S803_IF_PWR_S 8 | ||
182 | #define MC44S803_RF_PWR 0x3800 | ||
183 | #define MC44S803_RF_PWR_S 11 | ||
184 | #define MC44S803_LNA_GAIN 0xFC000 | ||
185 | #define MC44S803_LNA_GAIN_S 14 | ||
186 | /* REG_ID */ | ||
187 | #define MC44S803_ID 0x3E00 | ||
188 | #define MC44S803_ID_S 9 | ||
189 | |||
190 | /* Some macros to read/write fields */ | ||
191 | |||
192 | /* First shift, then mask */ | ||
193 | #define MC44S803_REG_SM(_val, _reg) \ | ||
194 | (((_val) << _reg##_S) & (_reg)) | ||
195 | |||
196 | /* First mask, then shift */ | ||
197 | #define MC44S803_REG_MS(_val, _reg) \ | ||
198 | (((_val) & (_reg)) >> _reg##_S) | ||
199 | |||
200 | struct mc44s803_priv { | ||
201 | struct mc44s803_config *cfg; | ||
202 | struct i2c_adapter *i2c; | ||
203 | struct dvb_frontend *fe; | ||
204 | |||
205 | u32 frequency; | ||
206 | }; | ||
207 | |||
208 | #endif | ||