109c434b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
29a0bf528SMauro Carvalho Chehab /*
39a0bf528SMauro Carvalho Chehab Driver for the Spase sp887x demodulator
49a0bf528SMauro Carvalho Chehab */
59a0bf528SMauro Carvalho Chehab
69a0bf528SMauro Carvalho Chehab /*
79a0bf528SMauro Carvalho Chehab * This driver needs external firmware. Please use the command
8fe63a1a6SMauro Carvalho Chehab * "<kerneldir>/scripts/get_dvb_firmware sp887x" to
99a0bf528SMauro Carvalho Chehab * download/extract it, and then copy it to /usr/lib/hotplug/firmware
109a0bf528SMauro Carvalho Chehab * or /lib/firmware (depending on configuration of firmware hotplug).
119a0bf528SMauro Carvalho Chehab */
129a0bf528SMauro Carvalho Chehab #define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw"
139a0bf528SMauro Carvalho Chehab
149a0bf528SMauro Carvalho Chehab #include <linux/init.h>
159a0bf528SMauro Carvalho Chehab #include <linux/module.h>
169a0bf528SMauro Carvalho Chehab #include <linux/device.h>
179a0bf528SMauro Carvalho Chehab #include <linux/firmware.h>
189a0bf528SMauro Carvalho Chehab #include <linux/string.h>
199a0bf528SMauro Carvalho Chehab #include <linux/slab.h>
209a0bf528SMauro Carvalho Chehab
21fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
229a0bf528SMauro Carvalho Chehab #include "sp887x.h"
239a0bf528SMauro Carvalho Chehab
249a0bf528SMauro Carvalho Chehab
259a0bf528SMauro Carvalho Chehab struct sp887x_state {
269a0bf528SMauro Carvalho Chehab struct i2c_adapter* i2c;
279a0bf528SMauro Carvalho Chehab const struct sp887x_config* config;
289a0bf528SMauro Carvalho Chehab struct dvb_frontend frontend;
299a0bf528SMauro Carvalho Chehab
309a0bf528SMauro Carvalho Chehab /* demodulator private data */
319a0bf528SMauro Carvalho Chehab u8 initialised:1;
329a0bf528SMauro Carvalho Chehab };
339a0bf528SMauro Carvalho Chehab
349a0bf528SMauro Carvalho Chehab static int debug;
359a0bf528SMauro Carvalho Chehab #define dprintk(args...) \
369a0bf528SMauro Carvalho Chehab do { \
379a0bf528SMauro Carvalho Chehab if (debug) printk(KERN_DEBUG "sp887x: " args); \
389a0bf528SMauro Carvalho Chehab } while (0)
399a0bf528SMauro Carvalho Chehab
i2c_writebytes(struct sp887x_state * state,u8 * buf,u8 len)409a0bf528SMauro Carvalho Chehab static int i2c_writebytes (struct sp887x_state* state, u8 *buf, u8 len)
419a0bf528SMauro Carvalho Chehab {
429a0bf528SMauro Carvalho Chehab struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = len };
439a0bf528SMauro Carvalho Chehab int err;
449a0bf528SMauro Carvalho Chehab
459a0bf528SMauro Carvalho Chehab if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
469a0bf528SMauro Carvalho Chehab printk ("%s: i2c write error (addr %02x, err == %i)\n",
479a0bf528SMauro Carvalho Chehab __func__, state->config->demod_address, err);
489a0bf528SMauro Carvalho Chehab return -EREMOTEIO;
499a0bf528SMauro Carvalho Chehab }
509a0bf528SMauro Carvalho Chehab
519a0bf528SMauro Carvalho Chehab return 0;
529a0bf528SMauro Carvalho Chehab }
539a0bf528SMauro Carvalho Chehab
sp887x_writereg(struct sp887x_state * state,u16 reg,u16 data)549a0bf528SMauro Carvalho Chehab static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data)
559a0bf528SMauro Carvalho Chehab {
569a0bf528SMauro Carvalho Chehab u8 b0 [] = { reg >> 8 , reg & 0xff, data >> 8, data & 0xff };
579a0bf528SMauro Carvalho Chehab struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 4 };
589a0bf528SMauro Carvalho Chehab int ret;
599a0bf528SMauro Carvalho Chehab
609a0bf528SMauro Carvalho Chehab if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) {
61cba862dcSMauro Carvalho Chehab /*
629a0bf528SMauro Carvalho Chehab * in case of soft reset we ignore ACK errors...
639a0bf528SMauro Carvalho Chehab */
649a0bf528SMauro Carvalho Chehab if (!(reg == 0xf1a && data == 0x000 &&
659a0bf528SMauro Carvalho Chehab (ret == -EREMOTEIO || ret == -EFAULT)))
669a0bf528SMauro Carvalho Chehab {
674bd69e7bSMauro Carvalho Chehab printk("%s: writereg error (reg %03x, data %03x, ret == %i)\n",
689a0bf528SMauro Carvalho Chehab __func__, reg & 0xffff, data & 0xffff, ret);
699a0bf528SMauro Carvalho Chehab return ret;
709a0bf528SMauro Carvalho Chehab }
719a0bf528SMauro Carvalho Chehab }
729a0bf528SMauro Carvalho Chehab
739a0bf528SMauro Carvalho Chehab return 0;
749a0bf528SMauro Carvalho Chehab }
759a0bf528SMauro Carvalho Chehab
sp887x_readreg(struct sp887x_state * state,u16 reg)769a0bf528SMauro Carvalho Chehab static int sp887x_readreg (struct sp887x_state* state, u16 reg)
779a0bf528SMauro Carvalho Chehab {
789a0bf528SMauro Carvalho Chehab u8 b0 [] = { reg >> 8 , reg & 0xff };
799a0bf528SMauro Carvalho Chehab u8 b1 [2];
809a0bf528SMauro Carvalho Chehab int ret;
819a0bf528SMauro Carvalho Chehab struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
829a0bf528SMauro Carvalho Chehab { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
839a0bf528SMauro Carvalho Chehab
849a0bf528SMauro Carvalho Chehab if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
859a0bf528SMauro Carvalho Chehab printk("%s: readreg error (ret == %i)\n", __func__, ret);
869a0bf528SMauro Carvalho Chehab return -1;
879a0bf528SMauro Carvalho Chehab }
889a0bf528SMauro Carvalho Chehab
899a0bf528SMauro Carvalho Chehab return (((b1[0] << 8) | b1[1]) & 0xfff);
909a0bf528SMauro Carvalho Chehab }
919a0bf528SMauro Carvalho Chehab
sp887x_microcontroller_stop(struct sp887x_state * state)929a0bf528SMauro Carvalho Chehab static void sp887x_microcontroller_stop (struct sp887x_state* state)
939a0bf528SMauro Carvalho Chehab {
949a0bf528SMauro Carvalho Chehab dprintk("%s\n", __func__);
959a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf08, 0x000);
969a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf09, 0x000);
979a0bf528SMauro Carvalho Chehab
989a0bf528SMauro Carvalho Chehab /* microcontroller STOP */
999a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf00, 0x000);
1009a0bf528SMauro Carvalho Chehab }
1019a0bf528SMauro Carvalho Chehab
sp887x_microcontroller_start(struct sp887x_state * state)1029a0bf528SMauro Carvalho Chehab static void sp887x_microcontroller_start (struct sp887x_state* state)
1039a0bf528SMauro Carvalho Chehab {
1049a0bf528SMauro Carvalho Chehab dprintk("%s\n", __func__);
1059a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf08, 0x000);
1069a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf09, 0x000);
1079a0bf528SMauro Carvalho Chehab
1089a0bf528SMauro Carvalho Chehab /* microcontroller START */
1099a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf00, 0x001);
1109a0bf528SMauro Carvalho Chehab }
1119a0bf528SMauro Carvalho Chehab
sp887x_setup_agc(struct sp887x_state * state)1129a0bf528SMauro Carvalho Chehab static void sp887x_setup_agc (struct sp887x_state* state)
1139a0bf528SMauro Carvalho Chehab {
1149a0bf528SMauro Carvalho Chehab /* setup AGC parameters */
1159a0bf528SMauro Carvalho Chehab dprintk("%s\n", __func__);
1169a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x33c, 0x054);
1179a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x33b, 0x04c);
1189a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x328, 0x000);
1199a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x327, 0x005);
1209a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x326, 0x001);
1219a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x325, 0x001);
1229a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x324, 0x001);
1239a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x318, 0x050);
1249a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x317, 0x3fe);
1259a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x316, 0x001);
1269a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x313, 0x005);
1279a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x312, 0x002);
1289a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x306, 0x000);
1299a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x303, 0x000);
1309a0bf528SMauro Carvalho Chehab }
1319a0bf528SMauro Carvalho Chehab
1329a0bf528SMauro Carvalho Chehab #define BLOCKSIZE 30
1339a0bf528SMauro Carvalho Chehab #define FW_SIZE 0x4000
134cba862dcSMauro Carvalho Chehab /*
1359a0bf528SMauro Carvalho Chehab * load firmware and setup MPEG interface...
1369a0bf528SMauro Carvalho Chehab */
sp887x_initial_setup(struct dvb_frontend * fe,const struct firmware * fw)1379a0bf528SMauro Carvalho Chehab static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw)
1389a0bf528SMauro Carvalho Chehab {
1399a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
1409a0bf528SMauro Carvalho Chehab u8 buf [BLOCKSIZE + 2];
1419a0bf528SMauro Carvalho Chehab int i;
1429a0bf528SMauro Carvalho Chehab int fw_size = fw->size;
143e594cda5SSudip Mukherjee const unsigned char *mem = fw->data + 10;
1449a0bf528SMauro Carvalho Chehab
1459a0bf528SMauro Carvalho Chehab dprintk("%s\n", __func__);
1469a0bf528SMauro Carvalho Chehab
1479a0bf528SMauro Carvalho Chehab /* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */
1489a0bf528SMauro Carvalho Chehab if (fw_size < FW_SIZE + 10)
1499a0bf528SMauro Carvalho Chehab return -ENODEV;
1509a0bf528SMauro Carvalho Chehab
1519a0bf528SMauro Carvalho Chehab /* soft reset */
1529a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf1a, 0x000);
1539a0bf528SMauro Carvalho Chehab
1549a0bf528SMauro Carvalho Chehab sp887x_microcontroller_stop (state);
1559a0bf528SMauro Carvalho Chehab
1569a0bf528SMauro Carvalho Chehab printk ("%s: firmware upload... ", __func__);
1579a0bf528SMauro Carvalho Chehab
1589a0bf528SMauro Carvalho Chehab /* setup write pointer to -1 (end of memory) */
1599a0bf528SMauro Carvalho Chehab /* bit 0x8000 in address is set to enable 13bit mode */
1609a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x8f08, 0x1fff);
1619a0bf528SMauro Carvalho Chehab
1629a0bf528SMauro Carvalho Chehab /* dummy write (wrap around to start of memory) */
1639a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x8f0a, 0x0000);
1649a0bf528SMauro Carvalho Chehab
1659a0bf528SMauro Carvalho Chehab for (i = 0; i < FW_SIZE; i += BLOCKSIZE) {
1669a0bf528SMauro Carvalho Chehab int c = BLOCKSIZE;
1679a0bf528SMauro Carvalho Chehab int err;
1689a0bf528SMauro Carvalho Chehab
16989d6e45cSMauro Carvalho Chehab if (c > FW_SIZE - i)
1709a0bf528SMauro Carvalho Chehab c = FW_SIZE - i;
1719a0bf528SMauro Carvalho Chehab
1729a0bf528SMauro Carvalho Chehab /* bit 0x8000 in address is set to enable 13bit mode */
1739a0bf528SMauro Carvalho Chehab /* bit 0x4000 enables multibyte read/write transfers */
1749a0bf528SMauro Carvalho Chehab /* write register is 0xf0a */
1759a0bf528SMauro Carvalho Chehab buf[0] = 0xcf;
1769a0bf528SMauro Carvalho Chehab buf[1] = 0x0a;
1779a0bf528SMauro Carvalho Chehab
1789a0bf528SMauro Carvalho Chehab memcpy(&buf[2], mem + i, c);
1799a0bf528SMauro Carvalho Chehab
1809a0bf528SMauro Carvalho Chehab if ((err = i2c_writebytes (state, buf, c+2)) < 0) {
1819a0bf528SMauro Carvalho Chehab printk ("failed.\n");
1829a0bf528SMauro Carvalho Chehab printk ("%s: i2c error (err == %i)\n", __func__, err);
1839a0bf528SMauro Carvalho Chehab return err;
1849a0bf528SMauro Carvalho Chehab }
1859a0bf528SMauro Carvalho Chehab }
1869a0bf528SMauro Carvalho Chehab
1879a0bf528SMauro Carvalho Chehab /* don't write RS bytes between packets */
1889a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc13, 0x001);
1899a0bf528SMauro Carvalho Chehab
1909a0bf528SMauro Carvalho Chehab /* suppress clock if (!data_valid) */
1919a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc14, 0x000);
1929a0bf528SMauro Carvalho Chehab
1939a0bf528SMauro Carvalho Chehab /* setup MPEG interface... */
1949a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc1a, 0x872);
1959a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc1b, 0x001);
1969a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */
1979a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc1a, 0x871);
1989a0bf528SMauro Carvalho Chehab
1999a0bf528SMauro Carvalho Chehab /* ADC mode, 2 for MT8872, 3 for SP8870/SP8871 */
2009a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x301, 0x002);
2019a0bf528SMauro Carvalho Chehab
2029a0bf528SMauro Carvalho Chehab sp887x_setup_agc(state);
2039a0bf528SMauro Carvalho Chehab
2049a0bf528SMauro Carvalho Chehab /* bit 0x010: enable data valid signal */
2059a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xd00, 0x010);
2069a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x0d1, 0x000);
2079a0bf528SMauro Carvalho Chehab return 0;
2089a0bf528SMauro Carvalho Chehab };
2099a0bf528SMauro Carvalho Chehab
configure_reg0xc05(struct dtv_frontend_properties * p,u16 * reg0xc05)2109a0bf528SMauro Carvalho Chehab static int configure_reg0xc05(struct dtv_frontend_properties *p, u16 *reg0xc05)
2119a0bf528SMauro Carvalho Chehab {
2129a0bf528SMauro Carvalho Chehab int known_parameters = 1;
2139a0bf528SMauro Carvalho Chehab
2149a0bf528SMauro Carvalho Chehab *reg0xc05 = 0x000;
2159a0bf528SMauro Carvalho Chehab
2169a0bf528SMauro Carvalho Chehab switch (p->modulation) {
2179a0bf528SMauro Carvalho Chehab case QPSK:
2189a0bf528SMauro Carvalho Chehab break;
2199a0bf528SMauro Carvalho Chehab case QAM_16:
2209a0bf528SMauro Carvalho Chehab *reg0xc05 |= (1 << 10);
2219a0bf528SMauro Carvalho Chehab break;
2229a0bf528SMauro Carvalho Chehab case QAM_64:
2239a0bf528SMauro Carvalho Chehab *reg0xc05 |= (2 << 10);
2249a0bf528SMauro Carvalho Chehab break;
2259a0bf528SMauro Carvalho Chehab case QAM_AUTO:
2269a0bf528SMauro Carvalho Chehab known_parameters = 0;
2279a0bf528SMauro Carvalho Chehab break;
2289a0bf528SMauro Carvalho Chehab default:
2299a0bf528SMauro Carvalho Chehab return -EINVAL;
230c2c1b415SPeter Senna Tschudin }
2319a0bf528SMauro Carvalho Chehab
2329a0bf528SMauro Carvalho Chehab switch (p->hierarchy) {
2339a0bf528SMauro Carvalho Chehab case HIERARCHY_NONE:
2349a0bf528SMauro Carvalho Chehab break;
2359a0bf528SMauro Carvalho Chehab case HIERARCHY_1:
2369a0bf528SMauro Carvalho Chehab *reg0xc05 |= (1 << 7);
2379a0bf528SMauro Carvalho Chehab break;
2389a0bf528SMauro Carvalho Chehab case HIERARCHY_2:
2399a0bf528SMauro Carvalho Chehab *reg0xc05 |= (2 << 7);
2409a0bf528SMauro Carvalho Chehab break;
2419a0bf528SMauro Carvalho Chehab case HIERARCHY_4:
2429a0bf528SMauro Carvalho Chehab *reg0xc05 |= (3 << 7);
2439a0bf528SMauro Carvalho Chehab break;
2449a0bf528SMauro Carvalho Chehab case HIERARCHY_AUTO:
2459a0bf528SMauro Carvalho Chehab known_parameters = 0;
2469a0bf528SMauro Carvalho Chehab break;
2479a0bf528SMauro Carvalho Chehab default:
2489a0bf528SMauro Carvalho Chehab return -EINVAL;
249c2c1b415SPeter Senna Tschudin }
2509a0bf528SMauro Carvalho Chehab
2519a0bf528SMauro Carvalho Chehab switch (p->code_rate_HP) {
2529a0bf528SMauro Carvalho Chehab case FEC_1_2:
2539a0bf528SMauro Carvalho Chehab break;
2549a0bf528SMauro Carvalho Chehab case FEC_2_3:
2559a0bf528SMauro Carvalho Chehab *reg0xc05 |= (1 << 3);
2569a0bf528SMauro Carvalho Chehab break;
2579a0bf528SMauro Carvalho Chehab case FEC_3_4:
2589a0bf528SMauro Carvalho Chehab *reg0xc05 |= (2 << 3);
2599a0bf528SMauro Carvalho Chehab break;
2609a0bf528SMauro Carvalho Chehab case FEC_5_6:
2619a0bf528SMauro Carvalho Chehab *reg0xc05 |= (3 << 3);
2629a0bf528SMauro Carvalho Chehab break;
2639a0bf528SMauro Carvalho Chehab case FEC_7_8:
2649a0bf528SMauro Carvalho Chehab *reg0xc05 |= (4 << 3);
2659a0bf528SMauro Carvalho Chehab break;
2669a0bf528SMauro Carvalho Chehab case FEC_AUTO:
2679a0bf528SMauro Carvalho Chehab known_parameters = 0;
2689a0bf528SMauro Carvalho Chehab break;
2699a0bf528SMauro Carvalho Chehab default:
2709a0bf528SMauro Carvalho Chehab return -EINVAL;
271c2c1b415SPeter Senna Tschudin }
2729a0bf528SMauro Carvalho Chehab
2739a0bf528SMauro Carvalho Chehab if (known_parameters)
2749a0bf528SMauro Carvalho Chehab *reg0xc05 |= (2 << 1); /* use specified parameters */
2759a0bf528SMauro Carvalho Chehab else
2769a0bf528SMauro Carvalho Chehab *reg0xc05 |= (1 << 1); /* enable autoprobing */
2779a0bf528SMauro Carvalho Chehab
2789a0bf528SMauro Carvalho Chehab return 0;
2799a0bf528SMauro Carvalho Chehab }
2809a0bf528SMauro Carvalho Chehab
281cba862dcSMauro Carvalho Chehab /*
2829a0bf528SMauro Carvalho Chehab * estimates division of two 24bit numbers,
2839a0bf528SMauro Carvalho Chehab * derived from the ves1820/stv0299 driver code
2849a0bf528SMauro Carvalho Chehab */
divide(int n,int d,int * quotient_i,int * quotient_f)2859a0bf528SMauro Carvalho Chehab static void divide (int n, int d, int *quotient_i, int *quotient_f)
2869a0bf528SMauro Carvalho Chehab {
2879a0bf528SMauro Carvalho Chehab unsigned int q, r;
2889a0bf528SMauro Carvalho Chehab
2899a0bf528SMauro Carvalho Chehab r = (n % d) << 8;
2909a0bf528SMauro Carvalho Chehab q = (r / d);
2919a0bf528SMauro Carvalho Chehab
2929a0bf528SMauro Carvalho Chehab if (quotient_i)
2939a0bf528SMauro Carvalho Chehab *quotient_i = q;
2949a0bf528SMauro Carvalho Chehab
2959a0bf528SMauro Carvalho Chehab if (quotient_f) {
2969a0bf528SMauro Carvalho Chehab r = (r % d) << 8;
2979a0bf528SMauro Carvalho Chehab q = (q << 8) | (r / d);
2989a0bf528SMauro Carvalho Chehab r = (r % d) << 8;
2999a0bf528SMauro Carvalho Chehab *quotient_f = (q << 8) | (r / d);
3009a0bf528SMauro Carvalho Chehab }
3019a0bf528SMauro Carvalho Chehab }
3029a0bf528SMauro Carvalho Chehab
sp887x_correct_offsets(struct sp887x_state * state,struct dtv_frontend_properties * p,int actual_freq)3039a0bf528SMauro Carvalho Chehab static void sp887x_correct_offsets (struct sp887x_state* state,
3049a0bf528SMauro Carvalho Chehab struct dtv_frontend_properties *p,
3059a0bf528SMauro Carvalho Chehab int actual_freq)
3069a0bf528SMauro Carvalho Chehab {
3079a0bf528SMauro Carvalho Chehab static const u32 srate_correction [] = { 1879617, 4544878, 8098561 };
3089a0bf528SMauro Carvalho Chehab int bw_index;
3099a0bf528SMauro Carvalho Chehab int freq_offset = actual_freq - p->frequency;
3109a0bf528SMauro Carvalho Chehab int sysclock = 61003; //[kHz]
3119a0bf528SMauro Carvalho Chehab int ifreq = 36000000;
3129a0bf528SMauro Carvalho Chehab int freq;
3139a0bf528SMauro Carvalho Chehab int frequency_shift;
3149a0bf528SMauro Carvalho Chehab
3159a0bf528SMauro Carvalho Chehab switch (p->bandwidth_hz) {
3169a0bf528SMauro Carvalho Chehab default:
3179a0bf528SMauro Carvalho Chehab case 8000000:
3189a0bf528SMauro Carvalho Chehab bw_index = 0;
3199a0bf528SMauro Carvalho Chehab break;
3209a0bf528SMauro Carvalho Chehab case 7000000:
3219a0bf528SMauro Carvalho Chehab bw_index = 1;
3229a0bf528SMauro Carvalho Chehab break;
3239a0bf528SMauro Carvalho Chehab case 6000000:
3249a0bf528SMauro Carvalho Chehab bw_index = 2;
3259a0bf528SMauro Carvalho Chehab break;
3269a0bf528SMauro Carvalho Chehab }
3279a0bf528SMauro Carvalho Chehab
3289a0bf528SMauro Carvalho Chehab if (p->inversion == INVERSION_ON)
3299a0bf528SMauro Carvalho Chehab freq = ifreq - freq_offset;
3309a0bf528SMauro Carvalho Chehab else
3319a0bf528SMauro Carvalho Chehab freq = ifreq + freq_offset;
3329a0bf528SMauro Carvalho Chehab
3339a0bf528SMauro Carvalho Chehab divide(freq / 333, sysclock, NULL, &frequency_shift);
3349a0bf528SMauro Carvalho Chehab
3359a0bf528SMauro Carvalho Chehab if (p->inversion == INVERSION_ON)
3369a0bf528SMauro Carvalho Chehab frequency_shift = -frequency_shift;
3379a0bf528SMauro Carvalho Chehab
3389a0bf528SMauro Carvalho Chehab /* sample rate correction */
3399a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x319, srate_correction[bw_index] >> 12);
3409a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x31a, srate_correction[bw_index] & 0xfff);
3419a0bf528SMauro Carvalho Chehab
3429a0bf528SMauro Carvalho Chehab /* carrier offset correction */
3439a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x309, frequency_shift >> 12);
3449a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x30a, frequency_shift & 0xfff);
3459a0bf528SMauro Carvalho Chehab }
3469a0bf528SMauro Carvalho Chehab
sp887x_setup_frontend_parameters(struct dvb_frontend * fe)3479a0bf528SMauro Carvalho Chehab static int sp887x_setup_frontend_parameters(struct dvb_frontend *fe)
3489a0bf528SMauro Carvalho Chehab {
3499a0bf528SMauro Carvalho Chehab struct dtv_frontend_properties *p = &fe->dtv_property_cache;
3509a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
3519a0bf528SMauro Carvalho Chehab unsigned actual_freq;
3529a0bf528SMauro Carvalho Chehab int err;
3539a0bf528SMauro Carvalho Chehab u16 val, reg0xc05;
3549a0bf528SMauro Carvalho Chehab
3559a0bf528SMauro Carvalho Chehab if (p->bandwidth_hz != 8000000 &&
3569a0bf528SMauro Carvalho Chehab p->bandwidth_hz != 7000000 &&
3579a0bf528SMauro Carvalho Chehab p->bandwidth_hz != 6000000)
3589a0bf528SMauro Carvalho Chehab return -EINVAL;
3599a0bf528SMauro Carvalho Chehab
3609a0bf528SMauro Carvalho Chehab if ((err = configure_reg0xc05(p, ®0xc05)))
3619a0bf528SMauro Carvalho Chehab return err;
3629a0bf528SMauro Carvalho Chehab
3639a0bf528SMauro Carvalho Chehab sp887x_microcontroller_stop(state);
3649a0bf528SMauro Carvalho Chehab
3659a0bf528SMauro Carvalho Chehab /* setup the PLL */
3669a0bf528SMauro Carvalho Chehab if (fe->ops.tuner_ops.set_params) {
3679a0bf528SMauro Carvalho Chehab fe->ops.tuner_ops.set_params(fe);
3689a0bf528SMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
3699a0bf528SMauro Carvalho Chehab }
3709a0bf528SMauro Carvalho Chehab if (fe->ops.tuner_ops.get_frequency) {
3719a0bf528SMauro Carvalho Chehab fe->ops.tuner_ops.get_frequency(fe, &actual_freq);
3729a0bf528SMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
3739a0bf528SMauro Carvalho Chehab } else {
3749a0bf528SMauro Carvalho Chehab actual_freq = p->frequency;
3759a0bf528SMauro Carvalho Chehab }
3769a0bf528SMauro Carvalho Chehab
3779a0bf528SMauro Carvalho Chehab /* read status reg in order to clear <pending irqs */
3789a0bf528SMauro Carvalho Chehab sp887x_readreg(state, 0x200);
3799a0bf528SMauro Carvalho Chehab
3809a0bf528SMauro Carvalho Chehab sp887x_correct_offsets(state, p, actual_freq);
3819a0bf528SMauro Carvalho Chehab
3829a0bf528SMauro Carvalho Chehab /* filter for 6/7/8 Mhz channel */
3839a0bf528SMauro Carvalho Chehab if (p->bandwidth_hz == 6000000)
3849a0bf528SMauro Carvalho Chehab val = 2;
3859a0bf528SMauro Carvalho Chehab else if (p->bandwidth_hz == 7000000)
3869a0bf528SMauro Carvalho Chehab val = 1;
3879a0bf528SMauro Carvalho Chehab else
3889a0bf528SMauro Carvalho Chehab val = 0;
3899a0bf528SMauro Carvalho Chehab
3909a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x311, val);
3919a0bf528SMauro Carvalho Chehab
3929a0bf528SMauro Carvalho Chehab /* scan order: 2k first = 0, 8k first = 1 */
3939a0bf528SMauro Carvalho Chehab if (p->transmission_mode == TRANSMISSION_MODE_2K)
3949a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x338, 0x000);
3959a0bf528SMauro Carvalho Chehab else
3969a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0x338, 0x001);
3979a0bf528SMauro Carvalho Chehab
3989a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc05, reg0xc05);
3999a0bf528SMauro Carvalho Chehab
4009a0bf528SMauro Carvalho Chehab if (p->bandwidth_hz == 6000000)
4019a0bf528SMauro Carvalho Chehab val = 2 << 3;
4029a0bf528SMauro Carvalho Chehab else if (p->bandwidth_hz == 7000000)
4039a0bf528SMauro Carvalho Chehab val = 3 << 3;
4049a0bf528SMauro Carvalho Chehab else
4059a0bf528SMauro Carvalho Chehab val = 0 << 3;
4069a0bf528SMauro Carvalho Chehab
4079a0bf528SMauro Carvalho Chehab /* enable OFDM and SAW bits as lock indicators in sync register 0xf17,
4089a0bf528SMauro Carvalho Chehab * optimize algorithm for given bandwidth...
4099a0bf528SMauro Carvalho Chehab */
4109a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf14, 0x160 | val);
4119a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xf15, 0x000);
4129a0bf528SMauro Carvalho Chehab
4139a0bf528SMauro Carvalho Chehab sp887x_microcontroller_start(state);
4149a0bf528SMauro Carvalho Chehab return 0;
4159a0bf528SMauro Carvalho Chehab }
4169a0bf528SMauro Carvalho Chehab
sp887x_read_status(struct dvb_frontend * fe,enum fe_status * status)4170df289a2SMauro Carvalho Chehab static int sp887x_read_status(struct dvb_frontend *fe, enum fe_status *status)
4189a0bf528SMauro Carvalho Chehab {
4199a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
4209a0bf528SMauro Carvalho Chehab u16 snr12 = sp887x_readreg(state, 0xf16);
4219a0bf528SMauro Carvalho Chehab u16 sync0x200 = sp887x_readreg(state, 0x200);
4229a0bf528SMauro Carvalho Chehab u16 sync0xf17 = sp887x_readreg(state, 0xf17);
4239a0bf528SMauro Carvalho Chehab
4249a0bf528SMauro Carvalho Chehab *status = 0;
4259a0bf528SMauro Carvalho Chehab
4269a0bf528SMauro Carvalho Chehab if (snr12 > 0x00f)
4279a0bf528SMauro Carvalho Chehab *status |= FE_HAS_SIGNAL;
4289a0bf528SMauro Carvalho Chehab
4299a0bf528SMauro Carvalho Chehab //if (sync0x200 & 0x004)
4309a0bf528SMauro Carvalho Chehab // *status |= FE_HAS_SYNC | FE_HAS_CARRIER;
4319a0bf528SMauro Carvalho Chehab
4329a0bf528SMauro Carvalho Chehab //if (sync0x200 & 0x008)
4339a0bf528SMauro Carvalho Chehab // *status |= FE_HAS_VITERBI;
4349a0bf528SMauro Carvalho Chehab
4359a0bf528SMauro Carvalho Chehab if ((sync0xf17 & 0x00f) == 0x002) {
4369a0bf528SMauro Carvalho Chehab *status |= FE_HAS_LOCK;
4379a0bf528SMauro Carvalho Chehab *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_CARRIER;
4389a0bf528SMauro Carvalho Chehab }
4399a0bf528SMauro Carvalho Chehab
4409a0bf528SMauro Carvalho Chehab if (sync0x200 & 0x001) { /* tuner adjustment requested...*/
4419a0bf528SMauro Carvalho Chehab int steps = (sync0x200 >> 4) & 0x00f;
4429a0bf528SMauro Carvalho Chehab if (steps & 0x008)
4439a0bf528SMauro Carvalho Chehab steps = -steps;
4449a0bf528SMauro Carvalho Chehab dprintk("sp887x: implement tuner adjustment (%+i steps)!!\n",
4459a0bf528SMauro Carvalho Chehab steps);
4469a0bf528SMauro Carvalho Chehab }
4479a0bf528SMauro Carvalho Chehab
4489a0bf528SMauro Carvalho Chehab return 0;
4499a0bf528SMauro Carvalho Chehab }
4509a0bf528SMauro Carvalho Chehab
sp887x_read_ber(struct dvb_frontend * fe,u32 * ber)4519a0bf528SMauro Carvalho Chehab static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber)
4529a0bf528SMauro Carvalho Chehab {
4539a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
4549a0bf528SMauro Carvalho Chehab
4559a0bf528SMauro Carvalho Chehab *ber = (sp887x_readreg(state, 0xc08) & 0x3f) |
4569a0bf528SMauro Carvalho Chehab (sp887x_readreg(state, 0xc07) << 6);
4579a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc08, 0x000);
4589a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc07, 0x000);
4599a0bf528SMauro Carvalho Chehab if (*ber >= 0x3fff0)
4609a0bf528SMauro Carvalho Chehab *ber = ~0;
4619a0bf528SMauro Carvalho Chehab
4629a0bf528SMauro Carvalho Chehab return 0;
4639a0bf528SMauro Carvalho Chehab }
4649a0bf528SMauro Carvalho Chehab
sp887x_read_signal_strength(struct dvb_frontend * fe,u16 * strength)4659a0bf528SMauro Carvalho Chehab static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
4669a0bf528SMauro Carvalho Chehab {
4679a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
4689a0bf528SMauro Carvalho Chehab
4699a0bf528SMauro Carvalho Chehab u16 snr12 = sp887x_readreg(state, 0xf16);
4709a0bf528SMauro Carvalho Chehab u32 signal = 3 * (snr12 << 4);
4719a0bf528SMauro Carvalho Chehab *strength = (signal < 0xffff) ? signal : 0xffff;
4729a0bf528SMauro Carvalho Chehab
4739a0bf528SMauro Carvalho Chehab return 0;
4749a0bf528SMauro Carvalho Chehab }
4759a0bf528SMauro Carvalho Chehab
sp887x_read_snr(struct dvb_frontend * fe,u16 * snr)4769a0bf528SMauro Carvalho Chehab static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr)
4779a0bf528SMauro Carvalho Chehab {
4789a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
4799a0bf528SMauro Carvalho Chehab
4809a0bf528SMauro Carvalho Chehab u16 snr12 = sp887x_readreg(state, 0xf16);
4819a0bf528SMauro Carvalho Chehab *snr = (snr12 << 4) | (snr12 >> 8);
4829a0bf528SMauro Carvalho Chehab
4839a0bf528SMauro Carvalho Chehab return 0;
4849a0bf528SMauro Carvalho Chehab }
4859a0bf528SMauro Carvalho Chehab
sp887x_read_ucblocks(struct dvb_frontend * fe,u32 * ucblocks)4869a0bf528SMauro Carvalho Chehab static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
4879a0bf528SMauro Carvalho Chehab {
4889a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
4899a0bf528SMauro Carvalho Chehab
4909a0bf528SMauro Carvalho Chehab *ucblocks = sp887x_readreg(state, 0xc0c);
4919a0bf528SMauro Carvalho Chehab if (*ucblocks == 0xfff)
4929a0bf528SMauro Carvalho Chehab *ucblocks = ~0;
4939a0bf528SMauro Carvalho Chehab
4949a0bf528SMauro Carvalho Chehab return 0;
4959a0bf528SMauro Carvalho Chehab }
4969a0bf528SMauro Carvalho Chehab
sp887x_i2c_gate_ctrl(struct dvb_frontend * fe,int enable)4979a0bf528SMauro Carvalho Chehab static int sp887x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
4989a0bf528SMauro Carvalho Chehab {
4999a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
5009a0bf528SMauro Carvalho Chehab
5019a0bf528SMauro Carvalho Chehab if (enable) {
5029a0bf528SMauro Carvalho Chehab return sp887x_writereg(state, 0x206, 0x001);
5039a0bf528SMauro Carvalho Chehab } else {
5049a0bf528SMauro Carvalho Chehab return sp887x_writereg(state, 0x206, 0x000);
5059a0bf528SMauro Carvalho Chehab }
5069a0bf528SMauro Carvalho Chehab }
5079a0bf528SMauro Carvalho Chehab
sp887x_sleep(struct dvb_frontend * fe)5089a0bf528SMauro Carvalho Chehab static int sp887x_sleep(struct dvb_frontend* fe)
5099a0bf528SMauro Carvalho Chehab {
5109a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
5119a0bf528SMauro Carvalho Chehab
5129a0bf528SMauro Carvalho Chehab /* tristate TS output and disable interface pins */
5139a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc18, 0x000);
5149a0bf528SMauro Carvalho Chehab
5159a0bf528SMauro Carvalho Chehab return 0;
5169a0bf528SMauro Carvalho Chehab }
5179a0bf528SMauro Carvalho Chehab
sp887x_init(struct dvb_frontend * fe)5189a0bf528SMauro Carvalho Chehab static int sp887x_init(struct dvb_frontend* fe)
5199a0bf528SMauro Carvalho Chehab {
5209a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
5219a0bf528SMauro Carvalho Chehab const struct firmware *fw = NULL;
5229a0bf528SMauro Carvalho Chehab int ret;
5239a0bf528SMauro Carvalho Chehab
5249a0bf528SMauro Carvalho Chehab if (!state->initialised) {
5259a0bf528SMauro Carvalho Chehab /* request the firmware, this will block until someone uploads it */
5269a0bf528SMauro Carvalho Chehab printk("sp887x: waiting for firmware upload (%s)...\n", SP887X_DEFAULT_FIRMWARE);
5279a0bf528SMauro Carvalho Chehab ret = state->config->request_firmware(fe, &fw, SP887X_DEFAULT_FIRMWARE);
5289a0bf528SMauro Carvalho Chehab if (ret) {
5299a0bf528SMauro Carvalho Chehab printk("sp887x: no firmware upload (timeout or file not found?)\n");
5309a0bf528SMauro Carvalho Chehab return ret;
5319a0bf528SMauro Carvalho Chehab }
5329a0bf528SMauro Carvalho Chehab
5339a0bf528SMauro Carvalho Chehab ret = sp887x_initial_setup(fe, fw);
5349a0bf528SMauro Carvalho Chehab release_firmware(fw);
5359a0bf528SMauro Carvalho Chehab if (ret) {
5369a0bf528SMauro Carvalho Chehab printk("sp887x: writing firmware to device failed\n");
5379a0bf528SMauro Carvalho Chehab return ret;
5389a0bf528SMauro Carvalho Chehab }
5399a0bf528SMauro Carvalho Chehab printk("sp887x: firmware upload complete\n");
5409a0bf528SMauro Carvalho Chehab state->initialised = 1;
5419a0bf528SMauro Carvalho Chehab }
5429a0bf528SMauro Carvalho Chehab
5439a0bf528SMauro Carvalho Chehab /* enable TS output and interface pins */
5449a0bf528SMauro Carvalho Chehab sp887x_writereg(state, 0xc18, 0x00d);
5459a0bf528SMauro Carvalho Chehab
5469a0bf528SMauro Carvalho Chehab return 0;
5479a0bf528SMauro Carvalho Chehab }
5489a0bf528SMauro Carvalho Chehab
sp887x_get_tune_settings(struct dvb_frontend * fe,struct dvb_frontend_tune_settings * fesettings)5499a0bf528SMauro Carvalho Chehab static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
5509a0bf528SMauro Carvalho Chehab {
5519a0bf528SMauro Carvalho Chehab fesettings->min_delay_ms = 350;
5529a0bf528SMauro Carvalho Chehab fesettings->step_size = 166666*2;
5539a0bf528SMauro Carvalho Chehab fesettings->max_drift = (166666*2)+1;
5549a0bf528SMauro Carvalho Chehab return 0;
5559a0bf528SMauro Carvalho Chehab }
5569a0bf528SMauro Carvalho Chehab
sp887x_release(struct dvb_frontend * fe)5579a0bf528SMauro Carvalho Chehab static void sp887x_release(struct dvb_frontend* fe)
5589a0bf528SMauro Carvalho Chehab {
5599a0bf528SMauro Carvalho Chehab struct sp887x_state* state = fe->demodulator_priv;
5609a0bf528SMauro Carvalho Chehab kfree(state);
5619a0bf528SMauro Carvalho Chehab }
5629a0bf528SMauro Carvalho Chehab
563bd336e63SMax Kellermann static const struct dvb_frontend_ops sp887x_ops;
5649a0bf528SMauro Carvalho Chehab
sp887x_attach(const struct sp887x_config * config,struct i2c_adapter * i2c)5659a0bf528SMauro Carvalho Chehab struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
5669a0bf528SMauro Carvalho Chehab struct i2c_adapter* i2c)
5679a0bf528SMauro Carvalho Chehab {
5689a0bf528SMauro Carvalho Chehab struct sp887x_state* state = NULL;
5699a0bf528SMauro Carvalho Chehab
5709a0bf528SMauro Carvalho Chehab /* allocate memory for the internal state */
5719a0bf528SMauro Carvalho Chehab state = kzalloc(sizeof(struct sp887x_state), GFP_KERNEL);
5729a0bf528SMauro Carvalho Chehab if (state == NULL) goto error;
5739a0bf528SMauro Carvalho Chehab
5749a0bf528SMauro Carvalho Chehab /* setup the state */
5759a0bf528SMauro Carvalho Chehab state->config = config;
5769a0bf528SMauro Carvalho Chehab state->i2c = i2c;
5779a0bf528SMauro Carvalho Chehab state->initialised = 0;
5789a0bf528SMauro Carvalho Chehab
5799a0bf528SMauro Carvalho Chehab /* check if the demod is there */
5809a0bf528SMauro Carvalho Chehab if (sp887x_readreg(state, 0x0200) < 0) goto error;
5819a0bf528SMauro Carvalho Chehab
5829a0bf528SMauro Carvalho Chehab /* create dvb_frontend */
5839a0bf528SMauro Carvalho Chehab memcpy(&state->frontend.ops, &sp887x_ops, sizeof(struct dvb_frontend_ops));
5849a0bf528SMauro Carvalho Chehab state->frontend.demodulator_priv = state;
5859a0bf528SMauro Carvalho Chehab return &state->frontend;
5869a0bf528SMauro Carvalho Chehab
5879a0bf528SMauro Carvalho Chehab error:
5889a0bf528SMauro Carvalho Chehab kfree(state);
5899a0bf528SMauro Carvalho Chehab return NULL;
5909a0bf528SMauro Carvalho Chehab }
5919a0bf528SMauro Carvalho Chehab
592bd336e63SMax Kellermann static const struct dvb_frontend_ops sp887x_ops = {
5939a0bf528SMauro Carvalho Chehab .delsys = { SYS_DVBT },
5949a0bf528SMauro Carvalho Chehab .info = {
5959a0bf528SMauro Carvalho Chehab .name = "Spase SP887x DVB-T",
596f1b1eabfSMauro Carvalho Chehab .frequency_min_hz = 50500 * kHz,
597f1b1eabfSMauro Carvalho Chehab .frequency_max_hz = 858000 * kHz,
598f1b1eabfSMauro Carvalho Chehab .frequency_stepsize_hz = 166666,
5999a0bf528SMauro Carvalho Chehab .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
6009a0bf528SMauro Carvalho Chehab FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
6019a0bf528SMauro Carvalho Chehab FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
6029a0bf528SMauro Carvalho Chehab FE_CAN_RECOVER
6039a0bf528SMauro Carvalho Chehab },
6049a0bf528SMauro Carvalho Chehab
6059a0bf528SMauro Carvalho Chehab .release = sp887x_release,
6069a0bf528SMauro Carvalho Chehab
6079a0bf528SMauro Carvalho Chehab .init = sp887x_init,
6089a0bf528SMauro Carvalho Chehab .sleep = sp887x_sleep,
6099a0bf528SMauro Carvalho Chehab .i2c_gate_ctrl = sp887x_i2c_gate_ctrl,
6109a0bf528SMauro Carvalho Chehab
6119a0bf528SMauro Carvalho Chehab .set_frontend = sp887x_setup_frontend_parameters,
6129a0bf528SMauro Carvalho Chehab .get_tune_settings = sp887x_get_tune_settings,
6139a0bf528SMauro Carvalho Chehab
6149a0bf528SMauro Carvalho Chehab .read_status = sp887x_read_status,
6159a0bf528SMauro Carvalho Chehab .read_ber = sp887x_read_ber,
6169a0bf528SMauro Carvalho Chehab .read_signal_strength = sp887x_read_signal_strength,
6179a0bf528SMauro Carvalho Chehab .read_snr = sp887x_read_snr,
6189a0bf528SMauro Carvalho Chehab .read_ucblocks = sp887x_read_ucblocks,
6199a0bf528SMauro Carvalho Chehab };
6209a0bf528SMauro Carvalho Chehab
6219a0bf528SMauro Carvalho Chehab module_param(debug, int, 0644);
6229a0bf528SMauro Carvalho Chehab MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
6239a0bf528SMauro Carvalho Chehab
6249a0bf528SMauro Carvalho Chehab MODULE_DESCRIPTION("Spase sp887x DVB-T demodulator driver");
6259a0bf528SMauro Carvalho Chehab MODULE_LICENSE("GPL");
6269a0bf528SMauro Carvalho Chehab
627*86495af1SGreg Kroah-Hartman EXPORT_SYMBOL_GPL(sp887x_attach);
628